프로젝트

일반

사용자정보

개정판 34529794

ID345297943e63f3942d2551c912d36c07be24c0d6
상위 7ea4d64d
하위 e201e34e

함의성이(가) 약 2년 전에 추가함

fix

Change-Id: If20ce9f77e4321578a40eaa509c17a127d761a95

차이점 보기:

DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
1010 1010
            return False
1011 1011
        
1012 1012
    def bind_end_break(self):
1013
            from shapely.geometry import Point
1014
            from EngineeringEndBreakItem import QEngineeringEndBreakItem
1015
            from EngineeringSpecBreakItem import QEngineeringSpecBreakItem
1016
            from EngineeringAbstractItem import QEngineeringAbstractItem
1017
            from EngineeringLineItem import QEngineeringLineItem
1018
            from AppDocData import AppDocData
1013
        from shapely.geometry import Point
1014
        from EngineeringEndBreakItem import QEngineeringEndBreakItem
1015
        from EngineeringSpecBreakItem import QEngineeringSpecBreakItem
1016
        from EngineeringAbstractItem import QEngineeringAbstractItem
1017
        from EngineeringLineItem import QEngineeringLineItem
1018
        from AppDocData import AppDocData
1019 1019

  
1020
            if self.prop('Freeze') or self.owner or self.prop('Connected Item'):
1021
                return
1022
            
1023
            app_doc_data = AppDocData.instance()
1024
            configs = app_doc_data.getConfigs('Line Detector', 'Length to connect line')
1025
            toler = int(configs[0].value) if configs else 20
1020
        if self.prop('Freeze') or self.owner or self.prop('Connected Item'):
1021
            return
1022
        
1023
        app_doc_data = AppDocData.instance()
1024
        configs = app_doc_data.getConfigs('Line Detector', 'Length to connect line')
1025
        toler = int(configs[0].value) if configs else 20
1026

  
1027
        lines = sorted([item for item in self.scene().items() if type(item) is QEngineeringLineItem], key=lambda param: param.length(), reverse=True)
1028
        symbols = [item for item in self.scene().items() if issubclass(type(item), SymbolSvgItem) and type(item) is not QEngineeringEndBreakItem and  type(item) is not QEngineeringSpecBreakItem]
1029
        end_breaks = [item for item in self.scene().items() if type(item) is QEngineeringEndBreakItem]
1030

  
1031
        usedItemPairs = []
1032
        for end_break in end_breaks:
1033
            if end_break.prop('Freeze') or end_break.owner or end_break.prop('Connected Item'):
1034
                usedItemPairs.append([end_break.owner, end_break.prop('Connected Item')])
1035
        
1036
        originPoint = Point(self.origin[0], self.origin[1])
1037
        minD = sys.maxsize
1038
        ownerItem = None
1039
        connectedItem = None
1040

  
1041
        for symbol in symbols:
1042
            for conn in symbol.connectors:
1043
                dist = originPoint.distance(Point(conn.sceneConnectPoint[0], conn.sceneConnectPoint[1]))
1044
                if not conn.connectedItem or not issubclass(type(conn.connectedItem), QEngineeringAbstractItem) or \
1045
                    [pair for pair in usedItemPairs if symbol in pair and conn.connectedItem in pair] or dist > 3 * toler or dist > minD:
1046
                    continue
1047

  
1048
                minD = dist
1049
                ownerItem = symbol
1050
                connectedItem = conn.connectedItem
1051

  
1052
        for line in lines:
1053
            for conn in line.connectors:
1054
                dist = originPoint.distance(Point(conn.sceneConnectPoint[0], conn.sceneConnectPoint[1]))
1055
                if not conn.connectedItem or not issubclass(type(conn.connectedItem), QEngineeringAbstractItem) or \
1056
                    conn._connected_at != QEngineeringAbstractItem.CONNECTED_AT_BODY  or \
1057
                    [pair for pair in usedItemPairs if line in pair and conn.connectedItem in pair] or dist > 3 * toler or dist > minD:
1058
                    continue
1059

  
1060
                minD = dist
1061
                ownerItem = line
1062
                connectedItem = conn.connectedItem
1026 1063

  
1027
            lines = sorted([item for item in self.scene().items() if type(item) is QEngineeringLineItem], key=lambda param: param.length(), reverse=True)
1028
            symbols = [item for item in self.scene().items() if issubclass(type(item), SymbolSvgItem) and type(item) is not QEngineeringEndBreakItem and  type(item) is not QEngineeringSpecBreakItem]
1029
            end_breaks = [item for item in self.scene().items() if type(item) is QEngineeringEndBreakItem]
1030

  
1031
            usedItemPairs = []
1032
            for end_break in end_breaks:
1033
                if end_break.prop('Freeze') or end_break.owner or end_break.prop('Connected Item'):
1034
                    usedItemPairs.append([end_break.owner, end_break.prop('Connected Item')])
1035
            
1036
            originPoint = Point(self.origin[0], self.origin[1])
1037
            minD = sys.maxsize
1038
            ownerItem = None
1039
            connectedItem = None
1040

  
1041
            for symbol in symbols:
1042
                for conn in symbol.connectors:
1043
                    dist = originPoint.distance(Point(conn.sceneConnectPoint[0], conn.sceneConnectPoint[1]))
1044
                    if not conn.connectedItem or not issubclass(type(conn.connectedItem), QEngineeringAbstractItem) or \
1045
                        [pair for pair in usedItemPairs if symbol in pair and conn.connectedItem in pair] or dist > 3 * toler or dist > minD:
1046
                        continue
1047

  
1048
                    minD = dist
1049
                    ownerItem = symbol
1050
                    connectedItem = conn.connectedItem
1051

  
1052
            for line in lines:
1053
                for conn in line.connectors:
1054
                    dist = originPoint.distance(Point(conn.sceneConnectPoint[0], conn.sceneConnectPoint[1]))
1055
                    if not conn.connectedItem or not issubclass(type(conn.connectedItem), QEngineeringAbstractItem) or \
1056
                        conn._connected_at != QEngineeringAbstractItem.CONNECTED_AT_BODY  or \
1057
                        [pair for pair in usedItemPairs if line in pair and conn.connectedItem in pair] or dist > 3 * toler or dist > minD:
1058
                        continue
1059

  
1060
                    minD = dist
1061
                    ownerItem = line
1062
                    connectedItem = conn.connectedItem
1063

  
1064
            if ownerItem and connectedItem:
1065
                self.set_property('Connected Item', connectedItem)
1066
                self.setToolTip('owner : ' + str(ownerItem))
1067
                self.owner = ownerItem
1068
                self.set_property('Freeze', True)
1064
        if ownerItem and connectedItem:
1065
            self.set_property('Connected Item', connectedItem)
1066
            self.setToolTip('owner : ' + str(ownerItem))
1067
            self.owner = ownerItem
1068
            self.set_property('Freeze', True)
1069 1069

  
1070 1070
    '''
1071 1071
        @brief  remove item when user press delete key

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)