프로젝트

일반

사용자정보

개정판 af725313

IDaf725313a7254c4a97212a23e083f26f2190d57c
상위 5a9396ae
하위 d3b7de6d

함의성이(가) 5년 이상 전에 추가함

issue #481: add new validation check condition

Change-Id: I94cb9be09aec3bd2d465bca92fcc73ec10c8b009

차이점 보기:

DTI_PID/DTI_PID/Shapes/EngineeringAbstractItem.py
135 135
        """
136 136
        pass
137 137

  
138
    def isOverlap(self, rect1, rect2):
139
        """
140
        @brief  return true if rects have intersection, rect is QRect
141
        @author euisung
142
        @date   2019.09.02
143
        """
144
        lt1, rb1 = (rect1.left(), rect1.top()), (rect1.right(), rect1.bottom())
145
        lt2, tb2 = (rect2.left(), rect2.top()), (rect2.right(), rect2.bottom())
146
        if rect1.left() > rect2.right() or rect2.left() > rect1.right():
147
            return False
148
        if rect1.bottom() < rect2.top() or rect2.bottom() < rect1.top():
149
            return False
150

  
151
        return True
152

  
138 153
    def associations(self):
139 154
        """ return associated instance """
140 155
        # move to abstractitem
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
1002 1002

  
1003 1003
            docdata = AppDocData.instance()
1004 1004
            dataPath = docdata.getErrorItemSvgPath()
1005
            needFlowCheck = True
1005

  
1006
            connectedUid = []
1007

  
1006 1008
            for connector in self.connectors:
1009
                # for duplicattion check
1010
                if connector.connectedItem and issubclass(type(connector.connectedItem), QEngineeringAbstractItem):
1011
                    connectedUid.append(str(connector.connectedItem.uid))
1012

  
1007 1013
                # check if there is not connected connector
1008 1014
                if connector.connectedItem is None:
1009 1015
                    error = SymbolSvgItem.createItem('Error', dataPath)
1010 1016
                    error.setPosition(connector.center())
1011 1017
                    error.parent = self
1012
                    error.msg = 'disconnected'
1018
                    error.msg = _translate('disconnected', 'disconnected')
1013 1019
                    error.setToolTip(error.msg)
1014 1020
                    error.area = 'Drawing'
1015 1021
                    error.name = 'Error'
1016 1022
                    errors.append(error)
1017
                    needFlowCheck = False
1018
                # check if two items are connected each other
1019
                elif issubclass(type(connector.connectedItem), SymbolSvgItem) and type(connector.connectedItem) is QEngineeringEquipmentItem:
1023

  
1024
                # check line to symbol
1025
                elif issubclass(type(connector.connectedItem), SymbolSvgItem) and type(connector.connectedItem) is not QEngineeringEquipmentItem:
1020 1026
                    matches = [conn for conn in connector.connectedItem.connectors if conn.connectedItem is self]
1027
                    # check if two items are connected each other
1021 1028
                    if not matches:
1022 1029
                        error = SymbolSvgItem.createItem('Error', dataPath)
1023 1030
                        error.setPosition(connector.center())
1024 1031
                        error.parent = self
1025
                        error.msg = self.tr('disconnected')
1032
                        error.msg = _translate('disconnected from another side', 'disconnected from another side')
1033
                        error.setToolTip(error.msg)
1034
                        error.area = 'Drawing'
1035
                        error.name = 'Error'
1036
                        errors.append(error)
1037
                    # check connection position
1038
                    elif not self.isOverlap(connector.sceneBoundingRect(), matches[0].sceneBoundingRect()):
1039
                        error = SymbolSvgItem.createItem('Error', dataPath)
1040
                        error.setPosition(connector.center())
1041
                        error.parent = self
1042
                        error.msg = _translate('mismatched position', 'mismatched position')
1026 1043
                        error.setToolTip(error.msg)
1027 1044
                        error.area = 'Drawing'
1028 1045
                        error.name = 'Error'
1029 1046
                        errors.append(error)
1030
                # check if connected two lines has same direction
1047

  
1031 1048
                elif issubclass(type(connector.connectedItem), QEngineeringLineItem):
1049
                    # check if connected two lines has same direction
1032 1050
                    if connector._connected_at == QEngineeringAbstractItem.CONNECTED_AT_PT:
1033 1051
                        center = connector.center()
1034 1052

  
......
1060 1078

  
1061 1079
                errors.extend(connector.validate())
1062 1080

  
1063
            if needFlowCheck and type(self.connectors[0].connectedItem) is QEngineeringLineItem and type(self.connectors[1].connectedItem) is QEngineeringLineItem:
1064
                pass
1081
            # check duplicated connection
1082
            if len(connectedUid) is not len(set(connectedUid)):
1083
                error = SymbolSvgItem.createItem('Error', dataPath)
1084
                error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
1085
                error.parent = self
1086
                error.msg = _translate('duplicated connection', 'duplicated connection')
1087
                error.setToolTip(error.msg)
1088
                error.area = 'Drawing'
1089
                error.name = 'Error'
1090
                errors.append(error)
1065 1091

  
1066 1092
        except Exception as ex:
1067 1093
            from App import App 
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
243 243
        from EngineeringLineItem import QEngineeringLineItem
244 244
        from EngineeringSpecBreakItem import QEngineeringSpecBreakItem
245 245
        from EngineeringTextItem import QEngineeringTextItem
246
        from EngineeringEquipmentItem import QEngineeringEquipmentItem
246 247
        errors = []
247 248

  
248 249
        try:
......
325 326
            # set error position
326 327
            for error in errors:
327 328
                error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
329

  
330
            connectedUid = []
331
            for connector in self.connectors:
332
                # for duplicattion check
333
                if connector.connectedItem and issubclass(type(connector.connectedItem), QEngineeringAbstractItem):
334
                    connectedUid.append(str(connector.connectedItem.uid))
335

  
336
                if issubclass(type(connector.connectedItem), SymbolSvgItem) and type(connector.connectedItem) is not QEngineeringEquipmentItem:
337
                    matches = [conn for conn in connector.connectedItem.connectors if conn.connectedItem is self]
338
                    # check if two items are connected each other
339
                    if not matches:
340
                        error = SymbolSvgItem.createItem('Error', dataPath)
341
                        error.setPosition(connector.center())
342
                        error.parent = self
343
                        error.msg = self.tr('disconnected from opposite side')
344
                        error.setToolTip(error.msg)
345
                        error.area = self.area
346
                        error.name = 'Error'
347
                        errors.append(error)
348

  
349
            # check duplicated connection
350
            if len(connectedUid) is not len(set(connectedUid)):
351
                error = SymbolSvgItem.createItem('Error', dataPath)
352
                error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
353
                error.parent = self
354
                error.msg = self.tr('duplicated connection')
355
                error.setToolTip(error.msg)
356
                error.area = self.area
357
                error.name = 'Error'
358
                errors.append(error)
328 359
        except Exception as ex:
329 360
            from App import App 
330 361
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)

내보내기 Unified diff

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