프로젝트

일반

사용자정보

개정판 5fbc4298

ID5fbc42981d5a28a78b8c59a480e562ed7f5f307b
상위 c9c0b30b
하위 1ea45410

humkyung 이(가) 약 7년 전에 추가함

Write orphan lines and symbols to xml

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
92 92
        self.equipments = []
93 93
        self.equipmentDataList = []
94 94
        self.lineNos = []
95
        self.lines = []
96
        self.symbols = []
95 97

  
96 98
    def setCurrentPidSource(self, image):
97 99
        self.currentPidSource = Source(image)
DTI_PID/DTI_PID/LineNoTracer.py
57 57
                
58 58
                for lineno in docData.lineNos:
59 59
                    if 1 == len(lineno.conns):
60
                        self.findConnectedObjects(lineno.conns[0], toler=10)
60
                        lineno.conns[0].owner = lineno  # set conns's owner to line no
61
                        self.findConnectedObjects(lineno, lineno.conns[0], toler=10)
61 62
                        connectedItems = lineno.getConnectedItems()
62 63
                        connectedLines = [item for item in connectedItems if type(item) is QEngineeringLineItem]
63 64
                        
......
78 79
        @author     humkyung
79 80
        @date       2018.04.16
80 81
        @history    humkyung 2018.05.08 find symbol or line connected to given object
82
                    humkyung 2018.05.10 set found object's owner
81 83
    '''
82
    def findConnectedObjects(self, startLine, toler):
84
    def findConnectedObjects(self, owner, startLine, toler):
83 85
        from QEngineeringLineItem import QEngineeringLineItem
84 86
        from SymbolSvgItem import SymbolSvgItem
85 87

  
......
101 103
            for match in matches:
102 104
                pool.append(match)
103 105
                visited.append(match)
106

  
107
        for match in matches:
108
            match.owner = owner
DTI_PID/DTI_PID/MainWindow.py
473 473
        @brief      recognize line
474 474
        @author     humkyung
475 475
        @date       2018.04.19
476
        @history    2018.04.26 Jeongwoo Variable name changed (texts → lineNos)
476
        @history    Jeongwoo 2018.04.26 Variable name changed (texts → lineNos)
477 477
                                        TextItem type changed (QEngineeringTextItem → QEngineeringLineNoTextItem)
478
        @history    2018.04.26 humkyung remove small objects before recognizing line
479
                    2018.05.02 Jeongwoo Show MessageBox when imageviewer doesn't have image
480
                    
478
                    humkyung 2018.04.26 remove small objects before recognizing line
479
                    Jeongwoo 2018.05.02 Show MessageBox when imageviewer doesn't have image
481 480
    '''
482 481
    def recognizeLine(self, MainWindow):
483 482
        from LineDetector import LineDetector
......
658 657
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
659 658

  
660 659
    '''
661
        @brief  generate output xml file
662
        @author humkyung
663
        @date   2018.04.23
660
        @brief      generate output xml file
661
        @author     humkyung
662
        @date       2018.04.23
664 663
        @history    2018.05.02  Jeongwoo    Show MessageBox when imageviewer doesn't have image
665 664
    '''
666 665
    def generateOutput(self):
......
674 673
        try:
675 674
            docData = AppDocData.instance()
676 675

  
677
            # TODO: how to check equipment
676
            docData.lines.clear()
677
            docData.lines = [item for item in self.graphicsView.scene.items() if type(item) is QEngineeringLineItem and item.owner is None]
678

  
679
            docData.symbols.clear()
680
            docData.symbols = [item for item in self.graphicsView.scene.items() if issubclass(type(item), SymbolSvgItem) and item.owner is None]
681

  
678 682
            docData.equipments.clear()
679 683
            for item in self.graphicsView.scene.items():
680 684
                if type(item) is QEngineeringEquipmentItem:
681 685
                    docData.equipments.append(item)
682
            # up to here
683 686

  
684 687
            xg.writeOutputXml(docData.imgName, docData.imgWidth, docData.imgHeight)
685 688
        except Exception as ex:
DTI_PID/DTI_PID/Shapes/QEngineeringEquipmentItem.py
76 76
        @author humkyung
77 77
        @date   2018.05.03
78 78
    '''
79
    def toXmlAsAttribute(self, owner):
79
    def toXmlAsAttribute(self, parentNode):
80 80
        for attr in self.attrs:
81
            owner.append(attr.toXml(self, None))
81
            parentNode.append(attr.toXml(self, None))
DTI_PID/DTI_PID/Shapes/QEngineeringInstrumentItem.py
146 146
        @author humkyung
147 147
        @date   2018.05.06
148 148
    '''
149
    def toXmlAsAttribute(self, owner):
149
    def toXmlAsAttribute(self, parentNode):
150 150
        from xml.etree.ElementTree import Element, SubElement, dump, ElementTree
151 151

  
152 152
        try:
153 153
            attrNode = Element('ATTRIBUTE')
154 154

  
155 155
            uidNode = Element('UID')
156
            uidNode.text = str(owner.uid)
156
            uidNode.text = str(self.uid)
157 157
            attrNode.append(uidNode)
158 158

  
159 159
            nameNode = Element('NAME')
......
164 164
            valueNode.text = self.measuredVariableCode
165 165
            attrNode.append(valueNode)
166 166

  
167
            owner.append(attrNode) 
167
            parentNode.append(attrNode) 
168 168
        except Exception as ex:
169 169
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
170 170

  
......
172 172
            attrNode = Element('ATTRIBUTE')
173 173

  
174 174
            uidNode = Element('UID')
175
            uidNode.text = str(owner.uid)
175
            uidNode.text = str(self.uid)
176 176
            attrNode.append(uidNode)
177 177

  
178 178
            nameNode = Element('NAME')
......
183 183
            valueNode.text = self.typeModifier
184 184
            attrNode.append(valueNode)
185 185

  
186
            owner.append(attrNode) 
186
            parentNode.append(attrNode) 
187 187
        except Exception as ex:
188 188
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
189 189

  
......
191 191
            attrNode = Element('ATTRIBUTE')
192 192

  
193 193
            uidNode = Element('UID')
194
            uidNode.text = str(owner.uid)
194
            uidNode.text = str(self.uid)
195 195
            attrNode.append(uidNode)
196 196

  
197 197
            nameNode = Element('NAME')
......
202 202
            valueNode.text = self.tagSeqNo
203 203
            attrNode.append(valueNode)
204 204

  
205
            owner.append(attrNode) 
205
            parentNode.append(attrNode) 
206 206
        except Exception as ex:
207 207
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
208 208

  
......
210 210
            attrNode = Element('ATTRIBUTE')
211 211

  
212 212
            uidNode = Element('UID')
213
            uidNode.text = str(owner.uid)
213
            uidNode.text = str(self.uid)
214 214
            attrNode.append(uidNode)
215 215

  
216 216
            nameNode = Element('NAME')
......
221 221
            valueNode.text = self.tagSuffix
222 222
            attrNode.append(valueNode)
223 223

  
224
            owner.append(attrNode) 
224
            parentNode.append(attrNode) 
225 225
        except Exception as ex:
226 226
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
DTI_PID/DTI_PID/Shapes/QEngineeringLineItem.py
22 22
        QGraphicsPolylineItem.__init__(self, parent)
23 23

  
24 24
        self.conns = [None, None]
25
        self._owner = None
25 26

  
26 27
        self.setPen(QPen(Qt.blue, 5, Qt.SolidLine))
27 28
        self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsFocusable)
......
30 31
        self.setAcceptTouchEvents(True)
31 32

  
32 33
    '''
34
        @breif  getter owner
35
        @author humkyung
36
        @date   2018.05.10
37
    '''
38
    @property
39
    def owner(self):
40
        return self._owner
41

  
42
    '''
43
        @brief  setter owner
44
        @author humkyung
45
        @date   2018.05.10
46
    '''
47
    @owner.setter
48
    def owner(self, value):
49
        self._owner = value
50

  
51
    '''
33 52
        @brief  construct a ProcessLineItem
34 53
        @author humkyung
35 54
    '''
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
37 37
        self.conns = []
38 38
        self.connectors = []
39 39
        self.attrs = [] # attributes
40
        self._owner = None
40 41

  
41 42
        self.setAcceptHoverEvents(True)
42 43
        self.setAcceptedMouseButtons(Qt.LeftButton)
......
54 55
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
55 56
        finally:
56 57
            f.close()
58
    '''
59
        @breif  getter owner
60
        @author humkyung
61
        @date   2018.05.10
62
    '''
63
    @property
64
    def owner(self):
65
        return self._owner
66

  
67
    '''
68
        @brief  setter owner
69
        @author humkyung
70
        @date   2018.05.10
71
    '''
72
    @owner.setter
73
    def owner(self, value):
74
        self._owner = value
57 75

  
58 76
    '''
59 77
        @brief  build symbol item
DTI_PID/DTI_PID/XmlGenerator.py
94 94
    @author     humkyung
95 95
    @date       2018.04.23
96 96
    @history    humkyung 2018.05.02 write equipment node
97
                humkyung 2018.05.10 write orphan lines
97 98
'''
98 99
def generateOutputXml(pidName, pidWidth, pidHeight):
99 100
    docData = AppDocData.instance()
......
112 113
        sortedList = sorted(docData.lineNos, key=lambda param:param.text())
113 114
        for lineno in sortedList:
114 115
            xml.append(lineno.toXml())
116

  
117
        for line in docData.lines:
118
            linenoNode = Element('LINE_NO')
119
            linenoNode.append(line.toXml())
120
            xml.append(linenoNode)
121

  
122
        for symbol in docData.symbols:
123
            xml.append(symbol.toXml())
115 124
    except Exception as ex:
116 125
        print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
117 126

  

내보내기 Unified diff