프로젝트

일반

사용자정보

개정판 c235988e

IDc235988e26ea0294a5c5cc37ad6adb283e970be1
상위 833b2cd8
하위 7c180550

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

issue #000: sym attr improve

Change-Id: Ic4a50802d0d8756d96e44c2ec646b28aa7c3acf8

차이점 보기:

DTI_PID/DTI_PID/ImportTextFromCADDialog.py
655 655

  
656 656
                item = SymbolSvgItem.createItem(symbol.getType(), symbol.getName(), path=svg_file_path)
657 657
                loc = [min(min_extents[0], max_extents[0]), min(min_extents[1], max_extents[1])]
658
                item.buildItem(name, symbol.getType(), angle, loc, (_width, _height), origin, connPts=None,
658
                connPts = None
659
                strConnPts = symbol.getConnectionPoint()
660
                if strConnPts is not None and strConnPts != '':
661
                    connPts = [(float(x.split(',')[0]), float(x.split(',')[1])) if len(x.split(',')) == 2 else (
662
                        x.split(',')[0], float(x.split(',')[1]), float(x.split(',')[2])) \
663
                            for x in strConnPts.split('/')]
664

  
665
                item.buildItem(name, symbol.getType(), angle, loc, (_width, _height), origin, connPts=connPts,
659 666
                               parentSymbol=None, childSymbol=None, hasInstrumentLabel=False, dbUid=uid)
660 667
                item.converted = True
661 668

  
......
776 783

  
777 784
            return node
778 785
        except Exception as ex:
786
            from App import App
787
            from AppDocData import MessageType
788

  
779 789
            message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \
780
                    f"{sys.exc_info()[-1].tb_lineno}"
790
                      f"{sys.exc_info()[-1].tb_lineno}"
781 791

  
782
            print(message)
792
            App.mainWnd().addMessage.emit(MessageType.Error, message)
783 793

  
784 794
    def lines_to_xml(self, layers: list, line_types: list, line_node, id2_bbox, autocad_bbox):
785 795
        """try to convert line element to id2 xml"""
......
801 811

  
802 812
            return res
803 813

  
804
        scale = max([id2_bbox[2] / autocad_bbox[2], id2_bbox[3] / autocad_bbox[3]])
805
        offsets = [id2_bbox[0] - autocad_bbox[0] * scale, (id2_bbox[1] + id2_bbox[3]) - autocad_bbox[1] * scale]
806

  
807
        pts = []
808
        for vertex in line_node.iter('Vertex'):
809
            pts.append((float(vertex.attrib['X']) * scale + offsets[0],
810
                        -float(vertex.attrib['Y']) * scale + offsets[1]))
811

  
812
        """get id2 line type uid"""
813
        line_type, line_type_cond = get_line_type(layers, line_types, line_node.attrib['Layer'],
814
                                                  line_node.attrib['Linetype']), None
815
        model = self.ui.treeViewLineType.model()
816
        for row in range(model.rowCount()):
817
            parent_index = model.index(row, 0)
818
            id2_line_type = model.itemFromIndex(parent_index).text()
819

  
820
            child_count = model.rowCount(parent_index)
821
            for child_row in range(child_count):
822
                child_index = model.index(child_row, 1, parent_index)
823
                autocad_line_type = model.itemFromIndex(child_index).text()
824
                if autocad_line_type == line_type:
825
                    matches = [item for item in LineTypeConditions.items() if item.name == id2_line_type]
826
                    if matches:
827
                        line_type_cond = matches[0]
828
                    break
829
        """up to here"""
830

  
831
        node = None
832
        for idx in range(len(pts) - 1):
833
            start, end = pts[idx], pts[idx + 1]
814
        try:
815
            scale = max([id2_bbox[2] / autocad_bbox[2], id2_bbox[3] / autocad_bbox[3]])
816
            offsets = [id2_bbox[0] - autocad_bbox[0] * scale, (id2_bbox[1] + id2_bbox[3]) - autocad_bbox[1] * scale]
834 817

  
835
            item = QEngineeringLineItem(vertices=[start, end], thickness=5)
836
            
837
            angle = math.degrees(item.angle())
838
            if not ((-5 < angle < 5) or (85 < angle < 95) or (175 < angle < 185) or (355 < angle < 365)):
839
                continue
818
            pts = []
819
            for vertex in line_node.iter('Vertex'):
820
                pts.append((float(vertex.attrib['X']) * scale + offsets[0],
821
                            -float(vertex.attrib['Y']) * scale + offsets[1]))
840 822

  
841
            item.area = 'Drawing'
823
            """get id2 line type uid"""
824
            line_type, line_type_cond = get_line_type(layers, line_types, line_node.attrib['Layer'],
825
                                                    line_node.attrib['Linetype']), None
826
            model = self.ui.treeViewLineType.model()
827
            for row in range(model.rowCount()):
828
                parent_index = model.index(row, 0)
829
                id2_line_type = model.itemFromIndex(parent_index).text()
842 830

  
843
            if line_type_cond:
844
                item.lineType = line_type_cond.name
831
                child_count = model.rowCount(parent_index)
832
                for child_row in range(child_count):
833
                    child_index = model.index(child_row, 1, parent_index)
834
                    autocad_line_type = model.itemFromIndex(child_index).text()
835
                    if autocad_line_type == line_type:
836
                        matches = [item for item in LineTypeConditions.items() if item.name == id2_line_type]
837
                        if matches:
838
                            line_type_cond = matches[0]
839
                        break
840
            """up to here"""
845 841

  
846
            node = item.toXml()
842
            node = None
843
            for idx in range(len(pts) - 1):
844
                start, end = pts[idx], pts[idx + 1]
845

  
846
                item = QEngineeringLineItem(vertices=[start, end], thickness=5)
847
                if item.length() < 40:
848
                    continue
849
                
850
                angle = math.degrees(item.angle())
851
                if not ((-5 < angle < 5) or (85 < angle < 95) or (175 < angle < 185) or (355 < angle < 365)):
852
                    continue
853

  
854
                item.area = 'Drawing'
855

  
856
                if line_type_cond:
857
                    item.lineType = line_type_cond.name
858

  
859
                node = item.toXml()
860

  
861
                '''
862
                """create a element for id2"""
863
                node = Element('LINE')
864
                node.attrib['OWNER'] = 'None'
865
                _node = SubElement(node, 'UID')
866
                _node.text = str(uuid.uuid4())
867

  
868
                _node = SubElement(node, 'STARTPOINT')
869
                _node.text = f"{start[0]},{start[1]}"
870

  
871
                _node = SubElement(node, 'ENDPOINT')
872
                _node.text = f"{end[0]},{end[1]}"
873

  
874
                if line_type_cond:
875
                    _node = SubElement(node, 'TYPE')
876
                    _node.text = line_type_cond.name
877
                    _node.attrib['TYPEUID'] = line_type_cond.uid
878

  
879
                _node = SubElement(node, 'AREA')
880
                _node.text = 'Drawing'
881

  
882
                _node = SubElement(node, 'THICKNESS')
883
                _node.text = '1'
884

  
885
                _node = SubElement(node, 'FLOWMARK')
886
                _node.text = 'None'
887

  
888
                _node = SubElement(node, 'CONNECTORS')
889
                for conn in range(2):
890
                    __node = SubElement(_node, 'CONNECTOR')
891
                    __node.attrib['CONNECTED_AT'] = '0'
892
                    __node.attrib['UID'] = str(uuid.uuid4())
893
                    ___node = SubElement(__node, 'CONNECTEDITEM')
894
                    ___node.text = 'None'
895
                    ___node = SubElement(__node, 'CONNECTPOINT')
896
                    ___node.text = f"{start[0]},{start[1]}" if conn == 0 else f"{end[0]},{end[1]}"
897
                    ___node = SubElement(__node, 'SCENECONNECTPOINT')
898
                    ___node.text = f"{start[0]},{start[1]}" if conn == 0 else f"{end[0]},{end[1]}"
899
                """up to here"""
900
                '''
847 901

  
848
            '''
849
            """create a element for id2"""
850
            node = Element('LINE')
851
            node.attrib['OWNER'] = 'None'
852
            _node = SubElement(node, 'UID')
853
            _node.text = str(uuid.uuid4())
854

  
855
            _node = SubElement(node, 'STARTPOINT')
856
            _node.text = f"{start[0]},{start[1]}"
857

  
858
            _node = SubElement(node, 'ENDPOINT')
859
            _node.text = f"{end[0]},{end[1]}"
860

  
861
            if line_type_cond:
862
                _node = SubElement(node, 'TYPE')
863
                _node.text = line_type_cond.name
864
                _node.attrib['TYPEUID'] = line_type_cond.uid
865

  
866
            _node = SubElement(node, 'AREA')
867
            _node.text = 'Drawing'
868

  
869
            _node = SubElement(node, 'THICKNESS')
870
            _node.text = '1'
871

  
872
            _node = SubElement(node, 'FLOWMARK')
873
            _node.text = 'None'
874

  
875
            _node = SubElement(node, 'CONNECTORS')
876
            for conn in range(2):
877
                __node = SubElement(_node, 'CONNECTOR')
878
                __node.attrib['CONNECTED_AT'] = '0'
879
                __node.attrib['UID'] = str(uuid.uuid4())
880
                ___node = SubElement(__node, 'CONNECTEDITEM')
881
                ___node.text = 'None'
882
                ___node = SubElement(__node, 'CONNECTPOINT')
883
                ___node.text = f"{start[0]},{start[1]}" if conn == 0 else f"{end[0]},{end[1]}"
884
                ___node = SubElement(__node, 'SCENECONNECTPOINT')
885
                ___node.text = f"{start[0]},{start[1]}" if conn == 0 else f"{end[0]},{end[1]}"
886
            """up to here"""
887
            '''
902
            return node
903
        
904
        except Exception as ex:
905
            from App import App
906
            from AppDocData import MessageType
888 907

  
889
        return node
908
            message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \
909
                      f"{sys.exc_info()[-1].tb_lineno}"
890 910

  
911
            App.mainWnd().addMessage.emit(MessageType.Error, message)
891 912

  
892 913
def close(self):
893 914
    QDialog.reject(self)
DTI_PID/DTI_PID/SymbolAttrTargetDialog.py
52 52
        
53 53
        self.isAccepted = False
54 54

  
55
        self.allChange = False
56
        self.targetChange = False
57

  
55 58
        self.ui.tableWidget.resizeColumnsToContents()
56 59
        self.ui.checkBox.stateChanged.connect(self.checkBoxChanged)
57 60
        if self.target == 'ALL':
58 61
            self.ui.checkBox.stateChanged.emit(self.ui.checkBox.checkState())
59 62

  
63
        self.ui.tableWidget.itemChanged.connect(self.changeTarget)
64
    
65
    def changeTarget(self, item):
66
        if item.column() == 1 and not self.allChange:
67
            self.targetChange = True
68

  
69
            if item.checkState() == Qt.Unchecked:
70
                self.ui.checkBox.setChecked(Qt.Unchecked)
71
            else:
72
                uncheck = False
73
                for row in range(self.ui.tableWidget.rowCount()):
74
                    if self.ui.tableWidget.item(row, 1).checkState() == Qt.Unchecked:
75
                        uncheck = True
76
                        break
77
                
78
                if not uncheck:
79
                    self.ui.checkBox.setChecked(Qt.Checked)
80

  
81
            self.targetChange = False
82

  
60 83
    def checkBoxChanged(self, checkState):
61
        if checkState is int(Qt.Checked):
84
        self.allChange = True
85

  
86
        if checkState is int(Qt.Checked) and not self.targetChange:
62 87
            for row in range(self.ui.tableWidget.rowCount()):
63 88
                self.ui.tableWidget.item(row, 1).setCheckState(Qt.Checked)
64
            self.ui.tableWidget.setEnabled(False)
65
        elif checkState is int(Qt.Unchecked):
89
            #self.ui.tableWidget.setEnabled(False)
90
        elif checkState is int(Qt.Unchecked) and not self.targetChange:
66 91
            for row in range(self.ui.tableWidget.rowCount()):
67 92
                self.ui.tableWidget.item(row, 1).setCheckState(Qt.Unchecked)
68
            self.ui.tableWidget.setEnabled(True)
93
            #self.ui.tableWidget.setEnabled(True)
94

  
95
        self.allChange = False
69 96
 
70 97
    '''
71 98
        @brief  accept dialog

내보내기 Unified diff

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