프로젝트

일반

사용자정보

개정판 fceaf69c

IDfceaf69c5ae18032b75bca7dc01076df80c1e635
상위 7d24a1ec
하위 619e4b8e

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

validation test

Change-Id: I12a936575368fed16c0be3db2c4ed5055fb08db0

차이점 보기:

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

내보내기 Unified diff

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