프로젝트

일반

사용자정보

개정판 fceaf69c

IDfceaf69c5ae18032b75bca7dc01076df80c1e635
상위 7d24a1ec
하위 619e4b8e

함의성이(가) 8달 전에 추가함

validation test

Change-Id: I12a936575368fed16c0be3db2c4ed5055fb08db0

차이점 보기:

DTI_PID/DTI_PID/Commands/ValidateCommand.py
70 70
        super(ValidateCommand, self).__init__(imageViewer)
71 71
        self.name = 'Validate'
72 72

  
73
    def execute(self, param):
73
    def execute(self, items, rules):
74 74
        """ valite all items in scene """
75 75
        from EngineeringLineItem import QEngineeringLineItem
76 76
        from SymbolSvgItem import SymbolSvgItem
......
84 84
        try:
85 85
            # item validation check
86 86
            count = 0
87
            for item in param:
87
            for item in items:
88 88
                if type(item) is QEngineeringLineItem or issubclass(type(item), SymbolSvgItem) or issubclass(type(item), QEngineeringTextItem):
89
                    errors.extend(item.validate())
89
                    errors.extend(item.validate(rules))
90 90

  
91 91
                count += 1
92 92
                self.show_progress.emit(count)
DTI_PID/DTI_PID/MainWindow.py
482 482

  
483 483
                cmd = ValidateCommand(self.graphicsView)
484 484
                cmd.show_progress.connect(self.progress_bar.setValue)
485
                errors = cmd.execute(self.graphicsView.scene().items())
485
                errors = cmd.execute(self.graphicsView.scene().items(), dlg.rules)
486 486
                for error in errors:
487 487
                    error.transfer.onRemoved.connect(self.itemRemoved)
488 488
                    #self.graphicsView.scene().addItem(error)
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
1162 1162
            # self.buildItem()
1163 1163
            self.update()
1164 1164

  
1165
    def validate(self):
1165
    def validate(self, rules):
1166 1166
        '''
1167 1167
            @brief  validation check : connection
1168 1168
            @author euisung
......
1173 1173
        from EngineeringEquipmentItem import QEngineeringEquipmentItem
1174 1174
        from AppDocData import AppDocData
1175 1175
        import math
1176
        from ValidateCommand import LineValidation
1177

  
1176 1178
        errors = []
1177 1179

  
1178 1180
        try:
......
1189 1191
                    connectedUid.append(str(connector.connectedItem.uid))
1190 1192

  
1191 1193
                # check if there is not connected connector
1192
                if connector.connectedItem is None:
1193
                    error = SymbolSvgItem.createItem('Error', None, dataPath)
1194
                    error.setPosition(list(connector.center()))
1195
                    error.parent = self
1196
                    error.msg = _translate('Disconnection warning', 'Disconnection warning')
1197
                    error.setToolTip(error.msg)
1198
                    error.area = 'Drawing'
1199
                    error.name = 'Warning'
1200
                    errors.append(error)
1201

  
1202
                # check line to symbol
1203
                elif issubclass(type(connector.connectedItem), SymbolSvgItem) and type(
1204
                        connector.connectedItem) is not QEngineeringEquipmentItem:
1205
                    matches = [conn for conn in connector.connectedItem.connectors if conn.connectedItem is self]
1206
                    # check if two items are connected each other
1207
                    if not matches:
1208
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
1209
                        error.setPosition(list(connector.center()))
1210
                        error.parent = self
1211
                        error.msg = _translate('Disconnected from opposite side', 'Disconnected from opposite side')
1212
                        error.setToolTip(error.msg)
1213
                        error.area = 'Drawing'
1214
                        error.name = 'Error'
1215
                        error.items = [ connector.connectedItem ]
1216
                        errors.append(error)
1217
                    # check connection position
1218
                    elif not self.isOverlap(connector.sceneBoundingRect(), matches[0].sceneBoundingRect()):
1194
                if LineValidation.DisconnectionWarning in rules:
1195
                    if connector.connectedItem is None:
1219 1196
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
1220 1197
                        error.setPosition(list(connector.center()))
1221 1198
                        error.parent = self
1222
                        error.msg = _translate('Mismatched position error', 'Mismatched position error')
1199
                        error.msg = _translate('Disconnection warning', 'Disconnection warning')
1223 1200
                        error.setToolTip(error.msg)
1224 1201
                        error.area = 'Drawing'
1225
                        error.name = 'Error'
1226
                        error.items = [ connector.connectedItem ]
1202
                        error.name = 'Warning'
1227 1203
                        errors.append(error)
1228 1204

  
1229
                elif issubclass(type(connector.connectedItem), QEngineeringLineItem):
1230
                    # check if connected two lines has same direction
1231
                    if connector._connected_at == QEngineeringAbstractItem.CONNECTED_AT_PT:
1232
                        center = connector.center()
1233

  
1234
                        indices = [0, 0]
1235
                        indices[0] = 1 if QPointF(center[0], center[1]) == self.line().p1() else 2
1236
                        matches = [conn for conn in connector.connectedItem.connectors if
1237
                                   conn.connectedItem == self and conn._connected_at == QEngineeringAbstractItem.CONNECTED_AT_PT]
1238
                        if matches:
1239
                            indices[1] = 1 if QPointF(matches[0].center()[0], matches[0].center()[
1240
                                1]) == connector.connectedItem.line().p1() else 2
1241
                        else:
1205
                # check line to symbol
1206
                elif issubclass(type(connector.connectedItem), SymbolSvgItem) and type(
1207
                        connector.connectedItem) is not QEngineeringEquipmentItem:
1208
                    matches = [conn for conn in connector.connectedItem.connectors if conn.connectedItem is self]
1209
                    # check if two items are connected each other
1210
                    if not matches:
1211
                        if LineValidation.DisconnectedFromOppositeSide in rules:
1242 1212
                            error = SymbolSvgItem.createItem('Error', None, dataPath)
1243 1213
                            error.setPosition(list(connector.center()))
1244 1214
                            error.parent = self
......
1248 1218
                            error.name = 'Error'
1249 1219
                            error.items = [ connector.connectedItem ]
1250 1220
                            errors.append(error)
1251

  
1252
                        if indices[0] == indices[1]:
1221
                    # check connection position
1222
                    elif not self.isOverlap(connector.sceneBoundingRect(), matches[0].sceneBoundingRect()):
1223
                        if LineValidation.MismatchedPositionError in rules:
1253 1224
                            error = SymbolSvgItem.createItem('Error', None, dataPath)
1254 1225
                            error.setPosition(list(connector.center()))
1255 1226
                            error.parent = self
1256
                            error.msg = _translate('Flow direction error', 'Flow direction error')
1227
                            error.msg = _translate('Mismatched position error', 'Mismatched position error')
1257 1228
                            error.setToolTip(error.msg)
1258 1229
                            error.area = 'Drawing'
1259 1230
                            error.name = 'Error'
1260 1231
                            error.items = [ connector.connectedItem ]
1261 1232
                            errors.append(error)
1262 1233

  
1263
                        if self.lineType != connector.connectedItem.lineType:
1264
                            error = SymbolSvgItem.createItem('Error', None, dataPath)
1265
                            error.setPosition(list(connector.center()))
1266
                            error.parent = self
1267
                            error.msg = _translate('Line type error', 'Line type error')
1268
                            error.setToolTip(error.msg)
1269
                            error.area = 'Drawing'
1270
                            error.name = 'Error'
1271
                            error.items = [ connector.connectedItem ]
1272
                            errors.append(error)
1273
                    
1274
                    else:
1234
                elif issubclass(type(connector.connectedItem), QEngineeringLineItem):
1235
                    # check if connected two lines has same direction
1236
                    if connector._connected_at == QEngineeringAbstractItem.CONNECTED_AT_PT:
1275 1237
                        center = connector.center()
1276
                        line = connector.connectedItem
1277 1238

  
1278
                        configs = docdata.getConfigs('Line Detector', 'Length to connect line')
1279
                        toler = int(configs[0].value) if configs else 20
1280

  
1281
                        if line.distanceTo(center) > toler * 2:
1282
                            error = SymbolSvgItem.createItem('Error', None, dataPath)
1283
                            error.setPosition(list(connector.center()))
1284
                            error.parent = self
1285
                            error.msg = _translate('Line position error', 'Line position error')
1286
                            error.setToolTip(error.msg)
1287
                            error.area = 'Drawing'
1288
                            error.name = 'Error'
1289
                            error.items = [ line ]
1290
                            errors.append(error)
1291

  
1292
                errors.extend(connector.validate())
1239
                        indices = [0, 0]
1240
                        indices[0] = 1 if QPointF(center[0], center[1]) == self.line().p1() else 2
1241
                        matches = [conn for conn in connector.connectedItem.connectors if
1242
                                   conn.connectedItem == self and conn._connected_at == QEngineeringAbstractItem.CONNECTED_AT_PT]
1243
                        if matches:
1244
                            indices[1] = 1 if QPointF(matches[0].center()[0], matches[0].center()[
1245
                                1]) == connector.connectedItem.line().p1() else 2
1246
                        else:
1247
                            if LineValidation.DisconnectedFromOppositeSide in rules:
1248
                                error = SymbolSvgItem.createItem('Error', None, dataPath)
1249
                                error.setPosition(list(connector.center()))
1250
                                error.parent = self
1251
                                error.msg = _translate('Disconnected from opposite side', 'Disconnected from opposite side')
1252
                                error.setToolTip(error.msg)
1253
                                error.area = 'Drawing'
1254
                                error.name = 'Error'
1255
                                error.items = [ connector.connectedItem ]
1256
                                errors.append(error)
1257

  
1258
                        if LineValidation.FlowDirectionError in rules:
1259
                            if indices[0] == indices[1]:
1260
                                error = SymbolSvgItem.createItem('Error', None, dataPath)
1261
                                error.setPosition(list(connector.center()))
1262
                                error.parent = self
1263
                                error.msg = _translate('Flow direction error', 'Flow direction error')
1264
                                error.setToolTip(error.msg)
1265
                                error.area = 'Drawing'
1266
                                error.name = 'Error'
1267
                                error.items = [ connector.connectedItem ]
1268
                                errors.append(error)
1269

  
1270
                        if LineValidation.LineTypeError in rules:
1271
                            if self.lineType != connector.connectedItem.lineType:
1272
                                error = SymbolSvgItem.createItem('Error', None, dataPath)
1273
                                error.setPosition(list(connector.center()))
1274
                                error.parent = self
1275
                                error.msg = _translate('Line type error', 'Line type error')
1276
                                error.setToolTip(error.msg)
1277
                                error.area = 'Drawing'
1278
                                error.name = 'Error'
1279
                                error.items = [ connector.connectedItem ]
1280
                                errors.append(error)
1281
                    
1282
                    else:
1283
                        if LineValidation.LinePositionError in rules:
1284
                            center = connector.center()
1285
                            line = connector.connectedItem
1286

  
1287
                            configs = docdata.getConfigs('Line Detector', 'Length to connect line')
1288
                            toler = int(configs[0].value) if configs else 20
1289

  
1290
                            if line.distanceTo(center) > toler * 2:
1291
                                error = SymbolSvgItem.createItem('Error', None, dataPath)
1292
                                error.setPosition(list(connector.center()))
1293
                                error.parent = self
1294
                                error.msg = _translate('Line position error', 'Line position error')
1295
                                error.setToolTip(error.msg)
1296
                                error.area = 'Drawing'
1297
                                error.name = 'Error'
1298
                                error.items = [ line ]
1299
                                errors.append(error)
1300

  
1301
                #errors.extend(connector.validate())
1293 1302

  
1294 1303
            # check duplicated connection
1295
            if len(connectedUid) is not len(set(connectedUid)):
1296
                error = SymbolSvgItem.createItem('Error', None, dataPath)
1297
                error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
1298
                error.parent = self
1299
                error.msg = _translate('Duplicated connection error', 'Duplicated connection error')
1300
                error.setToolTip(error.msg)
1301
                error.area = 'Drawing'
1302
                error.name = 'Error'
1303
                errors.append(error)
1304

  
1305
            # check overlapping
1306
            lines = [item for item in self.scene().items() if item is not self and type(item) is QEngineeringLineItem]
1307
            for line in lines:
1308
                lineRect = line.sceneBoundingRect()
1309
                rect1 = QRectF(lineRect.left() - 3, lineRect.top() - 3, lineRect.width() + 6, lineRect.height() + 6)
1310
                if rect1.contains(self.sceneBoundingRect()) or (not (self.isVertical() ^ line.isVertical()) and lineRect.contains(self.sceneBoundingRect().center())):
1304
            if LineValidation.DuplicatedConnectionError in rules:
1305
                if len(connectedUid) is not len(set(connectedUid)):
1311 1306
                    error = SymbolSvgItem.createItem('Error', None, dataPath)
1312 1307
                    error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
1313 1308
                    error.parent = self
1314
                    error.msg = _translate('Line overlapping warning', 'Line overlapping warning')
1309
                    error.msg = _translate('Duplicated connection error', 'Duplicated connection error')
1315 1310
                    error.setToolTip(error.msg)
1316 1311
                    error.area = 'Drawing'
1317
                    error.name = 'Warning'
1318
                    error.items = [ line ]
1312
                    error.name = 'Error'
1319 1313
                    errors.append(error)
1320 1314

  
1315
            # check overlapping
1316
            if LineValidation.LineOverlappingWarning in rules:
1317
                lines = [item for item in self.scene().items() if item is not self and type(item) is QEngineeringLineItem]
1318
                for line in lines:
1319
                    lineRect = line.sceneBoundingRect()
1320
                    rect1 = QRectF(lineRect.left() - 3, lineRect.top() - 3, lineRect.width() + 6, lineRect.height() + 6)
1321
                    if rect1.contains(self.sceneBoundingRect()) or (not (self.isVertical() ^ line.isVertical()) and lineRect.contains(self.sceneBoundingRect().center())):
1322
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
1323
                        error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
1324
                        error.parent = self
1325
                        error.msg = _translate('Line overlapping warning', 'Line overlapping warning')
1326
                        error.setToolTip(error.msg)
1327
                        error.area = 'Drawing'
1328
                        error.name = 'Warning'
1329
                        error.items = [ line ]
1330
                        errors.append(error)
1331

  
1321 1332
            configs = docdata.getConfigs('Project', 'Operation Code')
1322 1333
            code = configs[0].value if 1 == len(configs) else ''
1323 1334
            if code == 'nK6uurpuiw==': # Samsung
1324 1335
                # check line angle
1325
                angle = self.angle()
1326
                allowed_error = 0.0008726646#0.0175
1327
                isAngleError = True
1328
                #degree 0
1329
                if abs(angle - 0) <= allowed_error:
1330
                    isAngleError = False
1331
                #degree 90
1332
                elif abs(angle - math.pi / 2) <= allowed_error:
1333
                    isAngleError = False
1334
                #degree 180
1335
                elif abs(angle - math.pi) <= allowed_error:
1336
                    isAngleError = False
1337
                #degree 270
1338
                elif abs(angle - math.pi * 3 / 2) <= allowed_error:
1339
                    isAngleError = False
1340

  
1341
                if isAngleError:
1336
                if LineValidation.LineAngleWarning in rules:
1337
                    angle = self.angle()
1338
                    allowed_error = 0.0008726646#0.0175
1339
                    isAngleError = True
1340
                    #degree 0
1341
                    if abs(angle - 0) <= allowed_error:
1342
                        isAngleError = False
1343
                    #degree 90
1344
                    elif abs(angle - math.pi / 2) <= allowed_error:
1345
                        isAngleError = False
1346
                    #degree 180
1347
                    elif abs(angle - math.pi) <= allowed_error:
1348
                        isAngleError = False
1349
                    #degree 270
1350
                    elif abs(angle - math.pi * 3 / 2) <= allowed_error:
1351
                        isAngleError = False
1352

  
1353
                    if isAngleError:
1354
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
1355
                        error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
1356
                        error.parent = self
1357
                        error.msg = _translate('Line angle warning', 'Line angle warning')
1358
                        error.setToolTip(error.msg)
1359
                        error.area = 'Drawing'
1360
                        error.name = 'Warning'
1361
                        errors.append(error)
1362

  
1363
            # loop check
1364
            if LineValidation.LoopPathError in rules:
1365
                visited = self.find_connected_objects_size(self)
1366
                if visited.index(self) == 1 and type(visited[0]) is QEngineeringLineItem and visited[0].connectors[1].connectedItem is self and \
1367
                        visited[0].connectors[0].connectedItem and visited[0].connectors[0].connectedItem in visited:
1368
                    visited.pop(1)
1342 1369
                    error = SymbolSvgItem.createItem('Error', None, dataPath)
1343 1370
                    error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
1344 1371
                    error.parent = self
1345
                    error.msg = _translate('Line angle warning', 'Line angle warning')
1372
                    error.msg = _translate('Loop path error', 'Loop path error')
1346 1373
                    error.setToolTip(error.msg)
1347 1374
                    error.area = 'Drawing'
1348
                    error.name = 'Warning'
1375
                    error.name = 'Error'
1376
                    error.items = visited
1349 1377
                    errors.append(error)
1350 1378

  
1351
            # loop check
1352
            visited = self.find_connected_objects_size(self)
1353
            if visited.index(self) == 1 and type(visited[0]) is QEngineeringLineItem and visited[0].connectors[1].connectedItem is self and \
1354
                    visited[0].connectors[0].connectedItem and visited[0].connectors[0].connectedItem in visited:
1355
                visited.pop(1)
1356
                error = SymbolSvgItem.createItem('Error', None, dataPath)
1357
                error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
1358
                error.parent = self
1359
                error.msg = _translate('Loop path error', 'Loop path error')
1360
                error.setToolTip(error.msg)
1361
                error.area = 'Drawing'
1362
                error.name = 'Error'
1363
                error.items = visited
1364
                errors.append(error)
1365

  
1366 1379
        except Exception as ex:
1367 1380
            from App import App
1368 1381
            from AppDocData import MessageType
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py
1286 1286

  
1287 1287
        return '_'.join(matches)
1288 1288
    
1289
    def validate(self):
1289
    def validate(self, rules):
1290 1290
        """ validation check """
1291 1291

  
1292 1292
        from SymbolSvgItem import SymbolSvgItem
......
1294 1294
        from EngineeringReducerItem import QEngineeringReducerItem
1295 1295
        from EngineeringLineItem import QEngineeringLineItem
1296 1296
        from EngineeringAbstractItem import QEngineeringAbstractItem
1297
        from ValidateCommand import LineNoValidation
1297 1298

  
1298 1299
        errors = []
1299 1300

  
......
1305 1306

  
1306 1307
            lineNoError = False
1307 1308

  
1308
            _error = super().validate()
1309
            _error = super().validate(rules)
1309 1310
            errors.extend(_error)
1310 1311

  
1311 1312
            _from = self.prop('From')
......
1321 1322
            else:
1322 1323
                return errors
1323 1324

  
1324
            size_errors = []
1325
            branch_errors = []
1326
            for run in self.runs:
1327
                sizes = []
1328
                for item in run.items:
1329
                    item_size = None
1330
                    attrs = item.getAttributes()
1331
                    for prop, value in attrs.items():
1332
                        if prop.Attribute.upper() == 'Size'.upper() or prop.Attribute.upper() == 'NominalDiameter'.upper():
1333
                            if value and value != 'None':
1334
                                item_size = value
1335
                                if type(item) is QEngineeringReducerItem or (issubclass(type(item), SymbolSvgItem) and item.iType == 22): # Relief Valve
1336
                                    sizes.append([item, item.mainSubSize[0], item.mainSubSize[1]])
1337
                                    break
1338
                                else:
1339
                                    sizes.append([item, value, value])
1340
                                    break
1325
            if LineNoValidation.BranchSizeError in rules or LineNoValidation.SizeChangeError in rules:
1326
                size_errors = []
1327
                branch_errors = []
1328
                for run in self.runs:
1329
                    sizes = []
1330
                    for item in run.items:
1331
                        item_size = None
1332
                        attrs = item.getAttributes()
1333
                        for prop, value in attrs.items():
1334
                            if prop.Attribute.upper() == 'Size'.upper() or prop.Attribute.upper() == 'NominalDiameter'.upper():
1335
                                if value and value != 'None':
1336
                                    item_size = value
1337
                                    if type(item) is QEngineeringReducerItem or (issubclass(type(item), SymbolSvgItem) and item.iType == 22): # Relief Valve
1338
                                        sizes.append([item, item.mainSubSize[0], item.mainSubSize[1]])
1339
                                        break
1340
                                    else:
1341
                                        sizes.append([item, value, value])
1342
                                        break
1343

  
1344
                        if item_size and type(item) is QEngineeringLineItem:
1345
                            for conn in item.connectors:
1346
                                if conn.connectedItem and type(conn.connectedItem) is QEngineeringLineItem and \
1347
                                    conn._connected_at == QEngineeringAbstractItem.CONNECTED_AT_BODY:
1348
                                    _item_size = None
1349
                                    attrs = conn.connectedItem.getAttributes()
1350
                                    for prop, value in attrs.items():
1351
                                        if prop.Attribute.upper() == 'Size'.upper() or prop.Attribute.upper() == 'NominalDiameter'.upper():
1352
                                            if value and value != 'None':
1353
                                                _item_size = value
1354
                                                break
1355
                                
1356
                                    if _item_size and self.inch_to_number(item_size) > self.inch_to_number(_item_size):
1357
                                        branch_errors.append(item)
1358
                                        branch_errors.append(conn.connectedItem)
1359

  
1360
                    if len(sizes) > 1:
1361
                        for index in range(len(sizes) - 1):
1362
                            if sizes[index][2] != sizes[index + 1][1] and \
1363
                                type(sizes[index][0]) is not QEngineeringReducerItem and type(sizes[index + 1][0]) is not QEngineeringReducerItem \
1364
                                and (hasattr(sizes[index][0], 'iType') and sizes[index][0].iType != 22) and \
1365
                                (hasattr(sizes[index + 1][0], 'iType') and sizes[index + 1][0].iType != 22):
1366
                                    size_errors.append(sizes[index][0])
1367
                                    size_errors.append(sizes[index + 1][0])
1368
                            elif sizes[index][1] not in sizes[index + 1] and sizes[index][2] not in sizes[index + 1]:
1369
                                    size_errors.append(sizes[index][0])
1370
                                    size_errors.append(sizes[index + 1][0])
1371

  
1372
                if LineNoValidation.SizeChangeError in rules:
1373
                    for size in size_errors:
1374
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
1375
                        error.setPosition([size.sceneBoundingRect().center().x(), size.sceneBoundingRect().center().y()])
1376
                        error.parent = size
1377
                        error.msg = _translate('Size change error', 'Size change error')
1378
                        error.setToolTip(error.msg)
1379
                        error.area = 'Drawing'
1380
                        error.name = 'Error'
1381
                        errors.append(error)
1382

  
1383
                if LineNoValidation.BranchSizeError in rules:
1384
                    for size in branch_errors:
1385
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
1386
                        error.setPosition([size.sceneBoundingRect().center().x(), size.sceneBoundingRect().center().y()])
1387
                        error.parent = size
1388
                        error.msg = _translate('Branch size error', 'Branch size error')
1389
                        error.setToolTip(error.msg)
1390
                        error.area = 'Drawing'
1391
                        error.name = 'Error'
1392
                        errors.append(error)
1393

  
1394
            if LineNoValidation.MainRunSizeWarning in rules:
1395
                if self.runs and self.runs[0].items:
1396
                    _size = self.Size
1397
                    found = False
1398
                    if _size:
1399
                        for item in self.runs[0].items:
1400
                            if type(item) is QEngineeringReducerItem or (issubclass(type(item), SymbolSvgItem) and item.iType == 22):
1401
                                continue
1402
                            _size2 = item.EvaluatedSize
1403
                            if _size2 and _size2 != 'None' and _size2 == _size:
1404
                                found = True
1405
                                break
1341 1406

  
1342
                    if item_size and type(item) is QEngineeringLineItem:
1343
                        for conn in item.connectors:
1344
                            if conn.connectedItem and type(conn.connectedItem) is QEngineeringLineItem and \
1345
                                conn._connected_at == QEngineeringAbstractItem.CONNECTED_AT_BODY:
1346
                                _item_size = None
1347
                                attrs = conn.connectedItem.getAttributes()
1348
                                for prop, value in attrs.items():
1349
                                    if prop.Attribute.upper() == 'Size'.upper() or prop.Attribute.upper() == 'NominalDiameter'.upper():
1350
                                        if value and value != 'None':
1351
                                            _item_size = value
1352
                                            break
1407
                            #attrs = item.getAttributes()
1408
                            #for prop, value in attrs.items():
1409
                            #    if prop.Attribute.upper() == 'Size'.upper() or prop.Attribute.upper() == 'NominalDiameter'.upper():
1410
                            #        if value and value != 'None' and _size != value:
1411
                            #            found = True
1412
                            #            break
1353 1413
                            
1354
                                if _item_size and self.inch_to_number(item_size) > self.inch_to_number(_item_size):
1355
                                    branch_errors.append(item)
1356
                                    branch_errors.append(conn.connectedItem)
1357

  
1358
                if len(sizes) > 1:
1359
                    for index in range(len(sizes) - 1):
1360
                        if sizes[index][2] != sizes[index + 1][1] and \
1361
                            type(sizes[index][0]) is not QEngineeringReducerItem and type(sizes[index + 1][0]) is not QEngineeringReducerItem \
1362
                            and (hasattr(sizes[index][0], 'iType') and sizes[index][0].iType != 22) and \
1363
                            (hasattr(sizes[index + 1][0], 'iType') and sizes[index + 1][0].iType != 22):
1364
                                size_errors.append(sizes[index][0])
1365
                                size_errors.append(sizes[index + 1][0])
1366
                        elif sizes[index][1] not in sizes[index + 1] and sizes[index][2] not in sizes[index + 1]:
1367
                                size_errors.append(sizes[index][0])
1368
                                size_errors.append(sizes[index + 1][0])
1369

  
1370
            for size in size_errors:
1371
                error = SymbolSvgItem.createItem('Error', None, dataPath)
1372
                error.setPosition([size.sceneBoundingRect().center().x(), size.sceneBoundingRect().center().y()])
1373
                error.parent = size
1374
                error.msg = _translate('Size change error', 'Size change error')
1375
                error.setToolTip(error.msg)
1376
                error.area = 'Drawing'
1377
                error.name = 'Error'
1378
                errors.append(error)
1379

  
1380
            for size in branch_errors:
1381
                error = SymbolSvgItem.createItem('Error', None, dataPath)
1382
                error.setPosition([size.sceneBoundingRect().center().x(), size.sceneBoundingRect().center().y()])
1383
                error.parent = size
1384
                error.msg = _translate('Branch size error', 'Branch size error')
1385
                error.setToolTip(error.msg)
1386
                error.area = 'Drawing'
1387
                error.name = 'Error'
1388
                errors.append(error)
1389

  
1390
            if self.runs and self.runs[0].items:
1391
                _size = self.Size
1392
                found = False
1393
                if _size:
1394
                    for item in self.runs[0].items:
1395
                        if type(item) is QEngineeringReducerItem or (issubclass(type(item), SymbolSvgItem) and item.iType == 22):
1396
                            continue
1397
                        _size2 = item.EvaluatedSize
1398
                        if _size2 and _size2 != 'None' and _size2 == _size:
1399
                            found = True
1400
                            break
1401

  
1402
                        #attrs = item.getAttributes()
1403
                        #for prop, value in attrs.items():
1404
                        #    if prop.Attribute.upper() == 'Size'.upper() or prop.Attribute.upper() == 'NominalDiameter'.upper():
1405
                        #        if value and value != 'None' and _size != value:
1406
                        #            found = True
1407
                        #            break
1408
                        
1409
                        if found:
1410
                            break
1411
                
1412
                if not found:
1414
                            if found:
1415
                                break
1416
                    
1417
                    if not found:
1418
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
1419
                        error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
1420
                        error.parent = self
1421
                        error.msg = _translate('Main run size warning', 'Main run size warning')
1422
                        error.setToolTip(error.msg)
1423
                        error.area = 'Drawing'
1424
                        error.name = 'Warning'
1425
                        errors.append(error)
1426

  
1427
            if LineNoValidation.FromToError in rules:
1428
                if lineNoError:
1413 1429
                    error = SymbolSvgItem.createItem('Error', None, dataPath)
1414 1430
                    error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
1415 1431
                    error.parent = self
1416
                    error.msg = _translate('Main run size warning', 'Main run size warning')
1432
                    error.msg = _translate('From/ To error', 'From/ To error')
1417 1433
                    error.setToolTip(error.msg)
1418 1434
                    error.area = 'Drawing'
1419
                    error.name = 'Warning'
1435
                    error.name = 'Error'
1420 1436
                    errors.append(error)
1421 1437

  
1422
            if lineNoError:
1423
                error = SymbolSvgItem.createItem('Error', None, dataPath)
1424
                error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
1425
                error.parent = self
1426
                error.msg = _translate('From/ To error', 'From/ To error')
1427
                error.setToolTip(error.msg)
1428
                error.area = 'Drawing'
1429
                error.name = 'Error'
1430
                errors.append(error)
1431

  
1432 1438
        except Exception as ex:
1433 1439
            from App import App
1434 1440
            from AppDocData import MessageType
DTI_PID/DTI_PID/Shapes/EngineeringSpecBreakItem.py
145 145
        matches = [self.attrs[attr] for attr in self.attrs if attr.Attribute == 'DownStream']
146 146
        return matches[0] if matches else None
147 147

  
148
    def validate(self):
148
    def validate(self, rules):
149 149
        """ validate specbreak item """
150 150
        from AppDocData import AppDocData
151 151
        from EngineeringAbstractItem import QEngineeringAbstractItem
152 152
        from SymbolSvgItem import SymbolSvgItem
153
        from ValidateCommand import SymbolValidation
153 154

  
154
        errors = [] 
155
        errors = []
155 156

  
156 157
        app_doc_data = AppDocData.instance()
157 158
        dataPath = app_doc_data.getErrorItemSvgPath()
158 159
        # UpStream and DownStream must be connected
159 160
        if not (self.up_stream and self.down_stream):
160
            error = SymbolSvgItem.createItem('Error', None, dataPath)
161
            error.parent = self
162
            error.msg = self.tr('UpStream or DownStream is disconnected')
163
            error.setToolTip(error.msg)
164
            error.area = 'Drawing'
165
            error.name = 'Error'
166
            errors.append(error)
167
        elif self.up_stream and self.down_stream:
168
            up_stream_item = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(self.up_stream)]
169
            down_stream_item = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(self.down_stream)]
170
            if not (up_stream_item and down_stream_item):
161
            if SymbolValidation.UpStreamOrDownStreamIsDisconnected in rules:
171 162
                error = SymbolSvgItem.createItem('Error', None, dataPath)
172 163
                error.parent = self
173
                error.msg = self.tr('UpStream or DownStream is None')
164
                error.msg = self.tr('UpStream or DownStream is disconnected')
174 165
                error.setToolTip(error.msg)
175 166
                error.area = 'Drawing'
176 167
                error.name = 'Error'
177 168
                errors.append(error)
178
            else:
179
                connected = [False, False]
180
                for connector in up_stream_item[0].connectors:
181
                    if connector.connectedItem == down_stream_item[0]:
182
                        connected[0] = True
183
                        if connector._connected_at == QEngineeringAbstractItem.CONNECTED_AT_BODY:
184
                            connected[1] = True
185

  
186
                if connected[1] == False:
187
                    for connector in down_stream_item[0].connectors:
188
                        if connector.connectedItem == up_stream_item[0]:
189
                            connected[1] = True
190
                            if connector._connected_at == QEngineeringAbstractItem.CONNECTED_AT_BODY:
191
                                connected[0] = True
192

  
193
                if not (connected[0] and connected[1]):
169
        elif self.up_stream and self.down_stream:
170
            up_stream_item = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(self.up_stream)]
171
            down_stream_item = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(self.down_stream)]
172
            if not (up_stream_item and down_stream_item):
173
                if SymbolValidation.UpStreamOrDownStreamIsNone in rules:
194 174
                    error = SymbolSvgItem.createItem('Error', None, dataPath)
195 175
                    error.parent = self
196
                    error.msg = self.tr('UpStream and DownStream is misconnected')
176
                    error.msg = self.tr('UpStream or DownStream is None')
197 177
                    error.setToolTip(error.msg)
198 178
                    error.area = 'Drawing'
199 179
                    error.name = 'Error'
200
                    error.items = [ up_stream_item[0], down_stream_item[0] ]
201 180
                    errors.append(error)
181
            else:
182
                if SymbolValidation.UpStreamAndDownStreamIsMisconnected in rules:
183
                    connected = [False, False]
184
                    for connector in up_stream_item[0].connectors:
185
                        if connector.connectedItem == down_stream_item[0]:
186
                            connected[0] = True
187
                            if connector._connected_at == QEngineeringAbstractItem.CONNECTED_AT_BODY:
188
                                connected[1] = True
189

  
190
                    if connected[1] == False:
191
                        for connector in down_stream_item[0].connectors:
192
                            if connector.connectedItem == up_stream_item[0]:
193
                                connected[1] = True
194
                                if connector._connected_at == QEngineeringAbstractItem.CONNECTED_AT_BODY:
195
                                    connected[0] = True
196

  
197
                    if not (connected[0] and connected[1]):
198
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
199
                        error.parent = self
200
                        error.msg = self.tr('UpStream and DownStream is misconnected')
201
                        error.setToolTip(error.msg)
202
                        error.area = 'Drawing'
203
                        error.name = 'Error'
204
                        error.items = [ up_stream_item[0], down_stream_item[0] ]
205
                        errors.append(error)
202 206

  
203 207
        # set error position
204 208
        for error in errors:
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py
183 183
    def hoverMoveEvent(self, event):
184 184
        pass
185 185

  
186
    def validate(self):
186
    def validate(self, rules):
187 187
        """ validation check """
188 188

  
189 189
        from EngineeringLineItem import QEngineeringLineItem
190
        from ValidateCommand import TextValidation
190 191

  
191 192
        errors = []
192 193

  
......
195 196
            dataPath = app_doc_data.getErrorItemSvgPath()
196 197

  
197 198
            # check overlapping
198
            texts = [item for item in self.scene().items() if item is not self and issubclass(type(item), QEngineeringTextItem)]
199
            for text in texts:
200
                textRect = text.sceneBoundingRect()
201
                rect1 = QRectF(textRect.left() - 3, textRect.top() - 3, textRect.width() + 6, textRect.height() + 6)
202
                rect2 = QRectF(textRect.left() + 3, textRect.top() + 3, textRect.width() - 6, textRect.height() - 6)
203
                if rect1.contains(self.sceneBoundingRect()) or rect2.contains(self.sceneBoundingRect().center()):
204
                    error = SymbolSvgItem.createItem('Error', None, dataPath)
205
                    error.parent = self
206
                    error.msg = self.tr('Text overlapping warning')
207
                    error.setToolTip(error.msg)
208
                    error.area = self.area
209
                    error.name = 'Warning'
210
                    error.items = [ text ]
211
                    errors.append(error)
212

  
213
                    error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
214

  
215
            lines = [item for item in self.scene().items() if item is not self and issubclass(type(item), QEngineeringLineItem)]
216
            for line in lines:
217
                lineRect = line.sceneBoundingRect()
218
                if lineRect.intersects(self.sceneBoundingRect()):
219
                    error = SymbolSvgItem.createItem('Error', None, dataPath)
220
                    error.parent = self
221
                    error.msg = self.tr('Text overlapping waring')
222
                    error.setToolTip(error.msg)
223
                    error.area = self.area
224
                    error.name = 'Warning'
225
                    error.items = [ line ]
226
                    errors.append(error)
227

  
228
                    error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
229

  
230
            if self.owner:
231
                if self not in self.owner.associations():
232
                    error = SymbolSvgItem.createItem('Error', None, dataPath)
233
                    error.parent = self
234
                    error.msg = self.tr('Association error')
235
                    error.setToolTip(error.msg)
236
                    error.area = self.area
237
                    error.name = 'Error'
238
                    error.items = [ self.owner ]
239
                    errors.append(error)
240

  
241
                    error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
199
            if TextValidation.TextOverlappingWarning in rules:
200
                texts = [item for item in self.scene().items() if item is not self and issubclass(type(item), QEngineeringTextItem)]
201
                for text in texts:
202
                    textRect = text.sceneBoundingRect()
203
                    rect1 = QRectF(textRect.left() - 3, textRect.top() - 3, textRect.width() + 6, textRect.height() + 6)
204
                    rect2 = QRectF(textRect.left() + 3, textRect.top() + 3, textRect.width() - 6, textRect.height() - 6)
205
                    if rect1.contains(self.sceneBoundingRect()) or rect2.contains(self.sceneBoundingRect().center()):
206
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
207
                        error.parent = self
208
                        error.msg = self.tr('Text overlapping warning')
209
                        error.setToolTip(error.msg)
210
                        error.area = self.area
211
                        error.name = 'Warning'
212
                        error.items = [ text ]
213
                        errors.append(error)
214

  
215
                        error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
216

  
217
                lines = [item for item in self.scene().items() if item is not self and issubclass(type(item), QEngineeringLineItem)]
218
                for line in lines:
219
                    lineRect = line.sceneBoundingRect()
220
                    if lineRect.intersects(self.sceneBoundingRect()):
221
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
222
                        error.parent = self
223
                        error.msg = self.tr('Text overlapping waring')
224
                        error.setToolTip(error.msg)
225
                        error.area = self.area
226
                        error.name = 'Warning'
227
                        error.items = [ line ]
228
                        errors.append(error)
229

  
230
                        error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
231

  
232
            if TextValidation.AssociationError in rules:
233
                if self.owner:
234
                    if self not in self.owner.associations():
235
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
236
                        error.parent = self
237
                        error.msg = self.tr('Association error')
238
                        error.setToolTip(error.msg)
239
                        error.area = self.area
240
                        error.name = 'Error'
241
                        error.items = [ self.owner ]
242
                        errors.append(error)
243

  
244
                        error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
242 245
                            
243 246
        except Exception as ex:
244 247
            from App import App
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
186 186
            self._color = self.DEFAULT_COLOR
187 187
        self.setColor(self._color)
188 188

  
189
    def validate(self):
189
    def validate(self, rules):
190 190
        """ validation check """
191 191

  
192 192
        from EngineeringLineItem import QEngineeringLineItem
......
196 196
        from EngineeringEndBreakItem import QEngineeringEndBreakItem
197 197
        from EngineeringReducerItem import QEngineeringReducerItem
198 198
        from QEngineeringSizeTextItem import QEngineeringSizeTextItem
199
        from ValidateCommand import SymbolValidation
200

  
199 201
        errors = []
200 202

  
201 203
        try:
......
206 208
            dataPath = app_doc_data.getErrorItemSvgPath()
207 209

  
208 210
            # validate connectors
209
            for connector in self.connectors:
210
                errors.extend(connector.validate())
211
            #for connector in self.connectors:
212
            #    errors.extend(connector.validate())
211 213

  
212 214
            # check if connected two lines has same direction
213
            if len(self.connectors) is 2:
214
                if (type(self.connectors[0].connectedItem) is QEngineeringLineItem and
215
                    self.connectors[0]._connected_at == QEngineeringAbstractItem.CONNECTED_AT_PT) and \
216
                        (type(self.connectors[1].connectedItem) is QEngineeringLineItem and
217
                         self.connectors[1]._connected_at == QEngineeringAbstractItem.CONNECTED_AT_PT):
218
                    indices = [0, 0]
219

  
220
                    center = self.connectors[0].center()
221
                    dx, dy = [0, 0], [0, 0]
222
                    dx[0] = center[0] - self.connectors[0].connectedItem.line().p1().x()
223
                    dy[0] = center[1] - self.connectors[0].connectedItem.line().p1().y()
224
                    dx[1] = center[0] - self.connectors[0].connectedItem.line().p2().x()
225
                    dy[1] = center[1] - self.connectors[0].connectedItem.line().p2().y()
226
                    indices[0] = 1 if (dx[0] * dx[0] + dy[0] * dy[0]) < (dx[1] * dx[1]) + (dy[1] * dy[1]) else 2
227

  
228
                    center = self.connectors[1].center()
229
                    dx[0] = center[0] - self.connectors[1].connectedItem.line().p1().x()
230
                    dy[0] = center[1] - self.connectors[1].connectedItem.line().p1().y()
231
                    dx[1] = center[0] - self.connectors[1].connectedItem.line().p2().x()
232
                    dy[1] = center[1] - self.connectors[1].connectedItem.line().p2().y()
233
                    indices[1] = 1 if (dx[0] * dx[0] + dy[0] * dy[0]) < (dx[1] * dx[1]) + (dy[1] * dy[1]) else 2
234

  
235
                    if indices[0] == indices[1]:
215
            if SymbolValidation.FlowDirectionError in rules:
216
                if len(self.connectors) is 2:
217
                    if (type(self.connectors[0].connectedItem) is QEngineeringLineItem and
218
                        self.connectors[0]._connected_at == QEngineeringAbstractItem.CONNECTED_AT_PT) and \
219
                            (type(self.connectors[1].connectedItem) is QEngineeringLineItem and
220
                            self.connectors[1]._connected_at == QEngineeringAbstractItem.CONNECTED_AT_PT):
221
                        indices = [0, 0]
222

  
223
                        center = self.connectors[0].center()
224
                        dx, dy = [0, 0], [0, 0]
225
                        dx[0] = center[0] - self.connectors[0].connectedItem.line().p1().x()
226
                        dy[0] = center[1] - self.connectors[0].connectedItem.line().p1().y()
227
                        dx[1] = center[0] - self.connectors[0].connectedItem.line().p2().x()
228
                        dy[1] = center[1] - self.connectors[0].connectedItem.line().p2().y()
229
                        indices[0] = 1 if (dx[0] * dx[0] + dy[0] * dy[0]) < (dx[1] * dx[1]) + (dy[1] * dy[1]) else 2
230

  
231
                        center = self.connectors[1].center()
232
                        dx[0] = center[0] - self.connectors[1].connectedItem.line().p1().x()
233
                        dy[0] = center[1] - self.connectors[1].connectedItem.line().p1().y()
234
                        dx[1] = center[0] - self.connectors[1].connectedItem.line().p2().x()
235
                        dy[1] = center[1] - self.connectors[1].connectedItem.line().p2().y()
236
                        indices[1] = 1 if (dx[0] * dx[0] + dy[0] * dy[0]) < (dx[1] * dx[1]) + (dy[1] * dy[1]) else 2
237

  
238
                        if indices[0] == indices[1]:
239
                            error = SymbolSvgItem.createItem('Error', None, dataPath)
240
                            error.parent = self
241
                            error.msg = self.tr('Flow direction error')
242
                            error.setToolTip(error.msg)
243
                            error.area = 'Drawing'
244
                            error.name = 'Error'
245
                            errors.append(error)
246

  
247
            # check disconnected point
248
            attrs = self.getAttributes()
249
            matches = [(attr, value) for attr, value in attrs.items() if attr.Attribute == 'OWNERSYMBOL']
250
            if matches:
251
                if SymbolValidation.NotCombined in rules:
252
                    if not matches[0][1]:
236 253
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
237 254
                        error.parent = self
238
                        error.msg = self.tr('Flow direction error')
255
                        error.msg = 'Not combined'
239 256
                        error.setToolTip(error.msg)
240 257
                        error.area = 'Drawing'
241 258
                        error.name = 'Error'
242 259
                        errors.append(error)
243

  
244
            # check disconnected point
245
            attrs = self.getAttributes()
246
            matches = [(attr, value) for attr, value in attrs.items() if attr.Attribute == 'OWNERSYMBOL']
247
            if matches:
248
                if not matches[0][1]:
249
                    error = SymbolSvgItem.createItem('Error', None, dataPath)
250
                    error.parent = self
251
                    error.msg = 'Not combined'
252
                    error.setToolTip(error.msg)
253
                    error.area = 'Drawing'
254
                    error.name = 'Error'
255
                    errors.append(error)
256 260
            else:
257
                disconnect = False
258
                if len(self.connectors) is not 0:
259
                    disconnect = True
260
                    for connector in self.connectors:
261
                        if connector.connectedItem is not None:
262
                            disconnect = False
263
                            break
264

  
265
                if disconnect:
266
                    error = SymbolSvgItem.createItem('Error', None, dataPath)
267
                    error.parent = self
268
                    error.msg = 'Disconnection error'
269
                    error.setToolTip(error.msg)
270
                    error.area = 'Drawing'
271
                    error.name = 'Error'
272
                    errors.append(error)
261
                if SymbolValidation.DisconnectionError in rules:
262
                    disconnect = False
263
                    if len(self.connectors) is not 0:
264
                        disconnect = True
265
                        for connector in self.connectors:
266
                            if connector.connectedItem is not None:
267
                                disconnect = False
268
                                break
269

  
270
                    if disconnect:
271
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
272
                        error.parent = self
273
                        error.msg = 'Disconnection error'
274
                        error.setToolTip(error.msg)
275
                        error.area = 'Drawing'
276
                        error.name = 'Error'
277
                        errors.append(error)
273 278

  
274 279
            # check if symbol size if 0
275 280
            # no more used
......
285 290
            '''
286 291

  
287 292
            # check if association item's owner exists
288
            for assoc in self.associations():
289
                if issubclass(type(assoc), QEngineeringTextItem) and not assoc.owner:
290
                    error = SymbolSvgItem.createItem('Error', None, dataPath)
291
                    error.parent = self
292
                    error.msg = self.tr('Association error')
293
                    error.setToolTip(error.msg)
294
                    error.area = self.area
295
                    error.name = 'Error'
296
                    error.items = [ assoc ]
297
                    errors.append(error)
293
            if SymbolValidation.AssociationError in rules:
294
                for assoc in self.associations():
295
                    if issubclass(type(assoc), QEngineeringTextItem) and not assoc.owner:
296
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
297
                        error.parent = self
298
                        error.msg = self.tr('Association error')
299
                        error.setToolTip(error.msg)
300
                        error.area = self.area
301
                        error.name = 'Error'
302
                        error.items = [ assoc ]
303
                        errors.append(error)
298 304

  
299
            if type(self) is QEngineeringReducerItem:
300
                if not [size for size in self.associations() if type(size) is QEngineeringSizeTextItem]:
301
                    error = SymbolSvgItem.createItem('Error', None, dataPath)
302
                    error.parent = self
303
                    error.msg = self.tr('No size label warning')
304
                    error.setToolTip(error.msg)
305
                    error.area = self.area
306
                    error.name = 'Warning'
307
                    errors.append(error)
305
            if SymbolValidation.NoSizeLabelWarning in rules:
306
                if type(self) is QEngineeringReducerItem:
307
                    if not [size for size in self.associations() if type(size) is QEngineeringSizeTextItem]:
308
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
309
                        error.parent = self
310
                        error.msg = self.tr('No size label warning')
311
                        error.setToolTip(error.msg)
312
                        error.area = self.area
313
                        error.name = 'Warning'
314
                        errors.append(error)
308 315

  
309 316
            if self.iType == 34 or self.iType == 17 or self.iType == 22:
310
                if not self.EvaluatedLabel('OWNERSYMBOL'):
311
                    error = SymbolSvgItem.createItem('Error', None, dataPath)
312
                    error.parent = self
313
                    error.msg = self.tr('No label warning')
314
                    error.setToolTip(error.msg)
315
                    error.area = self.area
316
                    error.name = 'Warning'
317
                    errors.append(error)
317
                if SymbolValidation.NoLabelWarning in rules:
318
                    if not self.EvaluatedLabel('OWNERSYMBOL'):
319
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
320
                        error.parent = self
321
                        error.msg = self.tr('No label warning')
322
                        error.setToolTip(error.msg)
323
                        error.area = self.area
324
                        error.name = 'Warning'
325
                        errors.append(error)
318 326

  
319
                labels = [item for item in self.scene().items() if issubclass(type(item), SymbolSvgItem) and (item.iType == 19 or item.iType == 29 or item.iType == 30)]
320
                labels = [label for label in labels if label.EvaluatedAttribute('OWNERSYMBOL') == self or \
321
                          (type(label.EvaluatedAttribute('OWNERSYMBOL')) is str and label.EvaluatedAttribute('OWNERSYMBOL') == str(self.uid))]
322
                if len(labels) > 1:
323
                    error = SymbolSvgItem.createItem('Error', None, dataPath)
324
                    error.parent = self
325
                    error.msg = self.tr('Multiple label error')
326
                    error.setToolTip(error.msg)
327
                    error.area = self.area
328
                    error.name = 'Error'
329
                    error.items = labels
330
                    errors.append(error)
327
                if SymbolValidation.MultipleLabelError in rules:
328
                    labels = [item for item in self.scene().items() if issubclass(type(item), SymbolSvgItem) and (item.iType == 19 or item.iType == 29 or item.iType == 30)]
329
                    labels = [label for label in labels if label.EvaluatedAttribute('OWNERSYMBOL') == self or \
330
                            (type(label.EvaluatedAttribute('OWNERSYMBOL')) is str and label.EvaluatedAttribute('OWNERSYMBOL') == str(self.uid))]
331
                    if len(labels) > 1:
332
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
333
                        error.parent = self
334
                        error.msg = self.tr('Multiple label error')
335
                        error.setToolTip(error.msg)
336
                        error.area = self.area
337
                        error.name = 'Error'
338
                        error.items = labels
339
                        errors.append(error)
331 340

  
332 341
            # check overlapping
333
            symbols = [item for item in self.scene().items() if item is not self and issubclass(type(item), SymbolSvgItem) and type(item) is not QEngineeringEquipmentItem and type(item) is not QEngineeringEndBreakItem and type(item) is not QEngineeringSpecBreakItem]
334
            for symbol in symbols:
335
                symbolRect = symbol.sceneBoundingRect()
336
                rect1 = QRectF(symbolRect.left() - 3, symbolRect.top() - 3, symbolRect.width() + 6, symbolRect.height() + 6)
337
                rect2 = QRectF(symbolRect.left() + 3, symbolRect.top() + 3, symbolRect.width() - 6, symbolRect.height() - 6)
338
                if rect1.contains(self.sceneBoundingRect()) or rect2.contains(self.mapToScene(self.transformOriginPoint())):
339
                    error = SymbolSvgItem.createItem('Error', None, dataPath)
340
                    error.parent = self
341
                    error.msg = self.tr('Symbol overlapping warning')
342
                    error.setToolTip(error.msg)
343
                    error.area = self.area
344
                    error.name = 'Warning'
345
                    error.items = [ symbol ]
346
                    errors.append(error)
342
            if SymbolValidation.SymbolOverlappingWarning in rules:
343
                symbols = [item for item in self.scene().items() if item is not self and issubclass(type(item), SymbolSvgItem) and type(item) is not QEngineeringEquipmentItem and type(item) is not QEngineeringEndBreakItem and type(item) is not QEngineeringSpecBreakItem]
344
                for symbol in symbols:
345
                    symbolRect = symbol.sceneBoundingRect()
346
                    rect1 = QRectF(symbolRect.left() - 3, symbolRect.top() - 3, symbolRect.width() + 6, symbolRect.height() + 6)
347
                    rect2 = QRectF(symbolRect.left() + 3, symbolRect.top() + 3, symbolRect.width() - 6, symbolRect.height() - 6)
348
                    if rect1.contains(self.sceneBoundingRect()) or rect2.contains(self.mapToScene(self.transformOriginPoint())):
349
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
350
                        error.parent = self
351
                        error.msg = self.tr('Symbol overlapping warning')
352
                        error.setToolTip(error.msg)
353
                        error.area = self.area
354
                        error.name = 'Warning'
355
                        error.items = [ symbol ]
356
                        errors.append(error)
347 357

  
348 358
            # set error position
349 359
            for error in errors:
......
360 370
                                type(connector.connectedItem) is QEngineeringLineItem:
361 371
                    matches = [conn for conn in connector.connectedItem.connectors if conn.connectedItem is self]
362 372
                    # check if two items are connected each other
363
                    if not matches:
364
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
365
                        error.setPosition(list(connector.center()))
366
                        error.parent = self
367
                        error.msg = self.tr('Disconnected from opposite side')
368
                        error.setToolTip(error.msg)
369
                        error.area = self.area
370
                        error.name = 'Error'
371
                        error.items = [ connector.connectedItem ]
372
                        errors.append(error)
373

  
374
            # check duplicated connection
375
            if len(connectedUid) is not len(set(connectedUid)):
376
                error = SymbolSvgItem.createItem('Error', None, dataPath)
377
                error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
378
                error.parent = self
379
                error.msg = self.tr('Duplicated connection error')
380
                error.setToolTip(error.msg)
381
                error.area = self.area
382
                error.name = 'Error'
383
                errors.append(error)
384

  
385
            # check line type
386
            if self.conn_type:
387
                for index in range(len(self.conn_type)):
388
                    item = self.connectors[index].connectedItem
389
                    if item and type(item) is QEngineeringLineItem:
390
                        if (QEngineeringLineItem.check_piping(self.conn_type[index], True) and not item.is_piping()) or \
391
                                (not QEngineeringLineItem.check_piping(self.conn_type[index]) and item.is_piping(True)):
373
                    if SymbolValidation.DisconnectedFromOppositeSide in rules:
374
                        if not matches:
392 375
                            error = SymbolSvgItem.createItem('Error', None, dataPath)
393
                            error.setPosition(list(self.connectors[index].center()))
376
                            error.setPosition(list(connector.center()))
394 377
                            error.parent = self
395
                            error.msg = self.tr('Line type error')
378
                            error.msg = self.tr('Disconnected from opposite side')
396 379
                            error.setToolTip(error.msg)
397 380
                            error.area = self.area
398 381
                            error.name = 'Error'
382
                            error.items = [ connector.connectedItem ]
399 383
                            errors.append(error)
384

  
385
            # check duplicated connection
386
            if SymbolValidation.DuplicatedConnectionError in rules:
387
                if len(connectedUid) is not len(set(connectedUid)):
388
                    error = SymbolSvgItem.createItem('Error', None, dataPath)
389
                    error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
390
                    error.parent = self
391
                    error.msg = self.tr('Duplicated connection error')
392
                    error.setToolTip(error.msg)
393
                    error.area = self.area
394
                    error.name = 'Error'
395
                    errors.append(error)
396

  
397
            # check line type
398
            if SymbolValidation.LineTypeError in rules:
399
                if self.conn_type:
400
                    for index in range(len(self.conn_type)):
401
                        item = self.connectors[index].connectedItem
402
                        if item and type(item) is QEngineeringLineItem:
403
                            if (QEngineeringLineItem.check_piping(self.conn_type[index], True) and not item.is_piping()) or \
404
                                    (not QEngineeringLineItem.check_piping(self.conn_type[index]) and item.is_piping(True)):
405
                                error = SymbolSvgItem.createItem('Error', None, dataPath)
406
                                error.setPosition(list(self.connectors[index].center()))
407
                                error.parent = self
408
                                error.msg = self.tr('Line type error')
409
                                error.setToolTip(error.msg)
410
                                error.area = self.area
411
                                error.name = 'Error'
412
                                errors.append(error)
400 413
            
401 414
            configs = app_doc_data.getConfigs('Project', 'Operation Code')
402 415
            code = configs[0].value if 1 == len(configs) else ''
......
418 431
                    if not conn.connectedItem:
419 432
                        continue
420 433

  
421
                    for conn2 in conn.connectedItem.connectors:
422
                        if not conn2.connectedItem or conn2.connectedItem is not self:
423
                            continue
434
                    if SymbolValidation.XMismatchedConnectionPoint in rules:
435
                        for conn2 in conn.connectedItem.connectors:
436
                            if not conn2.connectedItem or conn2.connectedItem is not self:
437
                                continue
424 438

  
425
                        if abs(conn.center()[0] - conn2.center()[0]) > allowed_error or abs(conn.center()[1] - conn2.center()[1]) > allowed_error:
439
                            if abs(conn.center()[0] - conn2.center()[0]) > allowed_error or abs(conn.center()[1] - conn2.center()[1]) > allowed_error:
440
                                error = SymbolSvgItem.createItem('Error', None, dataPath)
441
                                error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
442
                                error.parent = self
443
                                error.msg = self.tr('X Mismatched connection point')
444
                                error.setToolTip(error.msg)
445
                                error.area = self.area
446
                                error.name = 'Warning'
447
                                error.items = [ conn.connectedItem ]
448
                                errors.append(error)
449
                
450
                    if SymbolValidation.SymbolToSymbolConnectionWarning in rules:
451
                        if issubclass(type(conn.connectedItem), SymbolSvgItem):
426 452
                            error = SymbolSvgItem.createItem('Error', None, dataPath)
427 453
                            error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
428 454
                            error.parent = self
429
                            error.msg = self.tr('X Mismatched connection point')
455
                            error.msg = self.tr('Symbol to symbol connection warning')
430 456
                            error.setToolTip(error.msg)
431 457
                            error.area = self.area
432 458
                            error.name = 'Warning'
433 459
                            error.items = [ conn.connectedItem ]
434 460
                            errors.append(error)
435
                
436
                    if issubclass(type(conn.connectedItem), SymbolSvgItem):
437
                        error = SymbolSvgItem.createItem('Error', None, dataPath)
438
                        error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])
439
                        error.parent = self
440
                        error.msg = self.tr('Symbol to symbol connection warning')
441
                        error.setToolTip(error.msg)
442
                        error.area = self.area
443
                        error.name = 'Warning'
444
                        error.items = [ conn.connectedItem ]
445
                        errors.append(error)
446 461
                                
447 462
        except Exception as ex:
448 463
            from App import App
DTI_PID/DTI_PID/UI/Validation.ui
15 15
  </property>
16 16
  <layout class="QGridLayout" name="gridLayout_2">
17 17
   <item row="2" column="0">
18
    <widget class="QGroupBox" name="groupBox_4">
18
    <widget class="QGroupBox" name="groupBox_3">
19 19
     <property name="title">
20 20
      <string>Line</string>
21 21
     </property>
......
26 26
         <widget class="QLabel" name="label_5">
27 27
          <property name="font">
28 28
           <font>
29
            <weight>75</weight>
30
            <bold>true</bold>
29
            <weight>50</weight>
30
            <bold>false</bold>
31 31
           </font>
32 32
          </property>
33 33
          <property name="text">
......
36 36
         </widget>
37 37
        </item>
38 38
        <item row="2" column="1">
39
         <widget class="QCheckBox" name="checkBox_21">
39
         <widget class="QCheckBox" name="checkBoxL_4">
40 40
          <property name="text">
41 41
           <string>Disconnected from opposite side</string>
42 42
          </property>
43 43
         </widget>
44 44
        </item>
45 45
        <item row="3" column="0">
46
         <widget class="QCheckBox" name="checkBox_22">
46
         <widget class="QCheckBox" name="checkBoxL_5">
47 47
          <property name="text">
48
           <string>Mismatched position</string>
48
           <string>Mismatched position error</string>
49 49
          </property>
50 50
         </widget>
51 51
        </item>
52 52
        <item row="3" column="1">
53
         <widget class="QCheckBox" name="checkBox_23">
53
         <widget class="QCheckBox" name="checkBoxL_6">
54 54
          <property name="text">
55 55
           <string>Line position error</string>
56 56
          </property>
57 57
         </widget>
58 58
        </item>
59 59
        <item row="4" column="0">
60
         <widget class="QCheckBox" name="checkBox_24">
60
         <widget class="QCheckBox" name="checkBoxL_7">
61 61
          <property name="text">
62 62
           <string>Loop path error</string>
63 63
          </property>
64 64
         </widget>
65 65
        </item>
66 66
        <item row="1" column="0">
67
         <widget class="QCheckBox" name="checkBox_16">
67
         <widget class="QCheckBox" name="checkBoxL_1">
68 68
          <property name="text">
69 69
           <string>Line type error</string>
70 70
          </property>
......
74 74
         <widget class="QLabel" name="label_6">
75 75
          <property name="font">
76 76
           <font>
77
            <weight>75</weight>
78
            <bold>true</bold>
77
            <weight>50</weight>
78
            <bold>false</bold>
79 79
           </font>
80 80
          </property>
81 81
          <property name="text">
......
84 84
         </widget>
85 85
        </item>
86 86
        <item row="6" column="1">
87
         <widget class="QCheckBox" name="checkBox_19">
87
         <widget class="QCheckBox" name="checkBoxL_9">
88 88
          <property name="text">
89 89
           <string>Line overlapping warning</string>
90 90
          </property>
91 91
         </widget>
92 92
        </item>
93 93
        <item row="6" column="0">
94
         <widget class="QCheckBox" name="checkBox_18">
94
         <widget class="QCheckBox" name="checkBoxL_8">
95 95
          <property name="text">
96 96
           <string>Disconnection warning</string>
97 97
          </property>
98 98
         </widget>
99 99
        </item>
100 100
        <item row="1" column="1">
101
         <widget class="QCheckBox" name="checkBox_17">
101
         <widget class="QCheckBox" name="checkBoxL_2">
102 102
          <property name="text">
103 103
           <string>Duplicated connection error</string>
104 104
          </property>
105 105
         </widget>
106 106
        </item>
107 107
        <item row="2" column="0">
108
         <widget class="QCheckBox" name="checkBox_20">
108
         <widget class="QCheckBox" name="checkBoxL_3">
109 109
          <property name="text">
110 110
           <string>Flow direction error</string>
111 111
          </property>
112 112
         </widget>
113 113
        </item>
114 114
        <item row="7" column="0">
115
         <widget class="QCheckBox" name="checkBox_25">
115
         <widget class="QCheckBox" name="checkBoxL_10">
116 116
          <property name="text">
117 117
           <string>Line angle warning</string>
118 118
          </property>
......
134 134
    </widget>
135 135
   </item>
136 136
   <item row="0" column="0">
137
    <widget class="QGroupBox" name="groupBox_2">
137
    <widget class="QGroupBox" name="groupBox_1">
138 138
     <property name="title">
139 139
      <string>Symbol</string>
140 140
     </property>
......
145 145
         <enum>QLayout::SetFixedSize</enum>
146 146
        </property>
147 147
        <item row="9" column="0">
148
         <widget class="QCheckBox" name="checkBox_10">
148
         <widget class="QCheckBox" name="checkBoxS_13">
149 149
          <property name="text">
150 150
           <string>No size label warning</string>
151 151
          </property>
152 152
         </widget>
153 153
        </item>
154 154
        <item row="9" column="1">
155
         <widget class="QCheckBox" name="checkBox_11">
155
         <widget class="QCheckBox" name="checkBoxS_14">
156 156
          <property name="text">
157 157
           <string>No label warning</string>
158 158
          </property>
......
172 172
         </widget>
173 173
        </item>
174 174
        <item row="10" column="1">
175
         <widget class="QCheckBox" name="checkBox_13">
175
         <widget class="QCheckBox" name="checkBoxS_16">
176 176
          <property name="text">
177 177
           <string>Symbol to symbol connection warning</string>
178 178
          </property>
179 179
         </widget>
180 180
        </item>
181 181
        <item row="10" column="0">
182
         <widget class="QCheckBox" name="checkBox_12">
182
         <widget class="QCheckBox" name="checkBoxS_15">
183 183
          <property name="text">
184 184
           <string>Symbol overlapping warning</string>
185 185
          </property>
......
199 199
         </widget>
200 200
        </item>
201 201
        <item row="2" column="0">
202
         <widget class="QCheckBox" name="checkBox_3">
202
         <widget class="QCheckBox" name="checkBoxS_3">
203 203
          <property name="text">
204 204
           <string>Flow direction error</string>
205 205
          </property>
206 206
         </widget>
207 207
        </item>
208 208
        <item row="1" column="1">
209
         <widget class="QCheckBox" name="checkBox_2">
209
         <widget class="QCheckBox" name="checkBoxS_2">
210 210
          <property name="text">
211 211
           <string>Duplicated connection error</string>
212 212
          </property>
213 213
         </widget>
214 214
        </item>
215 215
        <item row="2" column="1">
216
         <widget class="QCheckBox" name="checkBox_4">
216
         <widget class="QCheckBox" name="checkBoxS_4">
217 217
          <property name="text">
218 218
           <string>Not combined</string>
219 219
          </property>
220 220
         </widget>
221 221
        </item>
222 222
        <item row="1" column="0">
223
         <widget class="QCheckBox" name="checkBox">
223
         <widget class="QCheckBox" name="checkBoxS_1">
224 224
          <property name="text">
225 225
           <string>Line type error</string>
226 226
          </property>
227 227
         </widget>
228 228
        </item>
229 229
        <item row="4" column="0">
230
         <widget class="QCheckBox" name="checkBox_7">
230
         <widget class="QCheckBox" name="checkBoxS_7">
231 231
          <property name="text">
232 232
           <string>Association error</string>
233 233
          </property>
234 234
         </widget>
235 235
        </item>
236 236
        <item row="4" column="1">
237
         <widget class="QCheckBox" name="checkBox_8">
237
         <widget class="QCheckBox" name="checkBoxS_8">
238 238
          <property name="text">
239 239
           <string>Multiple label error</string>
240 240
          </property>
241 241
         </widget>
242 242
        </item>
243 243
        <item row="3" column="1">
244
         <widget class="QCheckBox" name="checkBox_6">
244
         <widget class="QCheckBox" name="checkBoxS_6">
245 245
          <property name="text">
246 246
           <string>Disconnection error</string>
247 247
          </property>
248 248
         </widget>
249 249
        </item>
250 250
        <item row="3" column="0">
251
         <widget class="QCheckBox" name="checkBox_5">
251
         <widget class="QCheckBox" name="checkBoxS_5">
252 252
          <property name="text">
253 253
           <string>Disconnected from opposite side</string>
254 254
          </property>
255 255
         </widget>
256 256
        </item>
257 257
        <item row="5" column="1">
258
         <widget class="QCheckBox" name="checkBox_31">
258
         <widget class="QCheckBox" name="checkBoxS_10">
259 259
          <property name="text">
260 260
           <string>UpStream or DownStream is None</string>
261 261
          </property>
262 262
         </widget>
263 263
        </item>
264 264
        <item row="5" column="0">
265
         <widget class="QCheckBox" name="checkBox_30">
265
         <widget class="QCheckBox" name="checkBoxS_9">
266 266
          <property name="text">
267 267
           <string>UpStream or DownStream is disconnected</string>
268 268
          </property>
269 269
         </widget>
270 270
        </item>
271 271
        <item row="6" column="1">
272
         <widget class="QCheckBox" name="checkBox_9">
272
         <widget class="QCheckBox" name="checkBoxS_12">
273 273
          <property name="text">
274 274
           <string>X Mismatched connection point</string>
... 이 차이점은 표시할 수 있는 최대 줄수를 초과해서 이 차이점은 잘렸습니다.

내보내기 Unified diff

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