프로젝트

일반

사용자정보

개정판 fe9b2bbf

IDfe9b2bbff02c3444a8adb593050b96865ba6f54c
상위 ba959d7e
하위 76c99a20

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

add size validation rules

Change-Id: Iac2bba5c7e31664a9896094b24b1ae9f2ee318f0

차이점 보기:

DTI_PID/DTI_PID/ConfigurationAreaDialog.py
16 16
from Area import Area
17 17

  
18 18
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\Shapes')
19
import EngineeringPolylineItem
20
from EngineeringLineItem import QEngineeringLineItem
21 19
from GraphicsBoundingBoxItem import QGraphicsBoundingBoxItem
22 20
import Configuration_Area_UI
23 21

  
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py
966 966
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
967 967
                                                           sys.exc_info()[-1].tb_lineno)
968 968
            App.mainWnd().addMessage.emit(MessageType.Error, message)
969

  
970
    def inch_to_number(self, inch_str):
971
        inchs = inch_str.replace('"', '').split('-')
972
        number = 0
973
        for inch in inchs:
974
            if '/' not in inch:
975
                number += float(inch)
976
            else:
977
                fraction = inch.split('/')
978
                number += float(fraction[0]) / float(fraction[1])
979

  
980
        return number
969 981
    
970 982
    def validate(self):
971 983
        """ validation check """
......
973 985
        from SymbolSvgItem import SymbolSvgItem
974 986
        from AppDocData import AppDocData
975 987
        from EngineeringReducerItem import QEngineeringReducerItem
988
        from EngineeringLineItem import QEngineeringLineItem
989
        from EngineeringAbstractItem import QEngineeringAbstractItem
990

  
976 991
        errors = []
977 992

  
978 993
        try:
......
997 1012
                return errors
998 1013

  
999 1014
            size_errors = []
1015
            branch_errors = []
1000 1016
            for run in self.runs:
1001 1017
                sizes = []
1002 1018
                for item in run.items:
1019
                    item_size = None
1003 1020
                    attrs = item.getAttributes()
1004 1021
                    for prop, value in attrs.items():
1005 1022
                        if prop.Attribute.upper() == 'Size'.upper() or prop.Attribute.upper() == 'NominalDiameter'.upper():
1006 1023
                            if value and value != 'None':
1024
                                item_size = value
1007 1025
                                if type(item) is QEngineeringReducerItem:
1008 1026
                                    sizes.append([item, item.mainSubSize[0], item.mainSubSize[1]])
1009 1027
                                    break
1010 1028
                                else:
1011 1029
                                    sizes.append([item, value, value])
1012 1030
                                    break
1031

  
1032
                    if item_size and type(item) is QEngineeringLineItem:
1033
                        for conn in item.connectors:
1034
                            if conn.connectedItem and type(conn.connectedItem) is QEngineeringLineItem and \
1035
                                conn._connected_at == QEngineeringAbstractItem.CONNECTED_AT_BODY:
1036
                                _item_size = None
1037
                                attrs = conn.connectedItem.getAttributes()
1038
                                for prop, value in attrs.items():
1039
                                    if prop.Attribute.upper() == 'Size'.upper() or prop.Attribute.upper() == 'NominalDiameter'.upper():
1040
                                        if value and value != 'None':
1041
                                            _item_size = value
1042
                                            break
1043
                            
1044
                                if _item_size and self.inch_to_number(item_size) > self.inch_to_number(_item_size):
1045
                                    branch_errors.append(item)
1046
                                    branch_errors.append(conn.connectedItem)
1047

  
1013 1048
                if len(sizes) > 1:
1014 1049
                    for index in range(len(sizes) - 1):
1015
                        if sizes[index][2] != sizes[index + 1][1]:
1016
                            if type(sizes[index][0]) is not QEngineeringReducerItem and type(sizes[index + 1][0]) is not QEngineeringReducerItem \
1017
                                and (hasattr(sizes[index][0], 'iType') and sizes[index][0].iType != 22) and \
1018
                                    (hasattr(sizes[index + 1][0], 'iType') and sizes[index + 1][0].iType != 22):
1050
                        if sizes[index][2] != sizes[index + 1][1] and \
1051
                            type(sizes[index][0]) is not QEngineeringReducerItem and type(sizes[index + 1][0]) is not QEngineeringReducerItem \
1052
                            and (hasattr(sizes[index][0], 'iType') and sizes[index][0].iType != 22) and \
1053
                            (hasattr(sizes[index + 1][0], 'iType') and sizes[index + 1][0].iType != 22):
1054
                                size_errors.append(sizes[index][0])
1055
                                size_errors.append(sizes[index + 1][0])
1056
                        elif sizes[index][1] not in sizes[index + 1] and sizes[index][2] not in sizes[index + 1]:
1019 1057
                                size_errors.append(sizes[index][0])
1020 1058
                                size_errors.append(sizes[index + 1][0])
1021 1059

  
......
1029 1067
                error.name = 'Error'
1030 1068
                errors.append(error)
1031 1069

  
1070
            for size in branch_errors:
1071
                error = SymbolSvgItem.createItem('Error', None, dataPath)
1072
                error.setPosition([size.sceneBoundingRect().center().x(), size.sceneBoundingRect().center().y()])
1073
                error.parent = self
1074
                error.msg = _translate('Branch Size error', 'Branch Size error')
1075
                error.setToolTip(error.msg)
1076
                error.area = 'Drawing'
1077
                error.name = 'Error'
1078
                errors.append(error)
1079

  
1032 1080
            if lineNoError:
1033 1081
                error = SymbolSvgItem.createItem('Error', None, dataPath)
1034 1082
                error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()])

내보내기 Unified diff

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