개정판 9ec5f5cc
Write pipe run to xml
DTI_PID/DTI_PID/LineNoTracer.py | ||
---|---|---|
64 | 64 |
# find primary lines |
65 | 65 |
for lineno in docData.lineNos: |
66 | 66 |
if 1 == len(lineno.conns): |
67 |
#lineno.conns[0].owner = lineno # set conns's owner to line no |
|
68 | 67 |
connectedItems = self.findConnectedObjects(lineno.conns[0], toler=10) |
69 | 68 |
for item in connectedItems: item.owner = lineno # set item's owner |
70 | 69 |
|
71 | 70 |
pipeRun = QEngineeringRunItem() |
72 |
connectedLines = [item for item in connectedItems if type(item) is QEngineeringLineItem] |
|
73 |
pipeRun.items = [item for item in connectedItems if issubclass(type(item), SymbolSvgItem)] |
|
71 |
pipeRun.items = connectedItems |
|
74 | 72 |
lineno.runs.append(pipeRun) |
73 |
|
|
74 |
connectedLines = [item for item in connectedItems if type(item) is QEngineeringLineItem] |
|
75 | 75 |
|
76 | 76 |
maxLength = None |
77 | 77 |
maxLengthItem = None |
... | ... | |
93 | 93 |
for item in connectedItems: item.owner = matches[0].owner # set item's owner |
94 | 94 |
|
95 | 95 |
pipeRun = QEngineeringRunItem() |
96 |
connectedLines = [item for item in connectedItems if type(item) is QEngineeringLineItem] |
|
97 |
pipeRun.items = [item for item in connectedItems if issubclass(type(item), SymbolSvgItem)] |
|
96 |
pipeRun.items = connectedItems |
|
98 | 97 |
if pipeRun.items is not None and len(pipeRun.items) > 0: |
99 | 98 |
matches[0].owner.runs.append(pipeRun) |
99 |
|
|
100 |
connectedLines = [item for item in connectedItems if type(item) is QEngineeringLineItem] |
|
100 | 101 |
|
101 | 102 |
maxLength = None |
102 | 103 |
maxLengthItem = None |
DTI_PID/DTI_PID/Shapes/QEngineeringAbstractItem.py | ||
---|---|---|
45 | 45 |
''' |
46 | 46 |
@owner.setter |
47 | 47 |
def owner(self, value): |
48 |
self._owner = value |
|
48 |
self._owner = value |
|
49 |
|
|
50 |
''' |
|
51 |
@brief write to xml |
|
52 |
@author humkyung |
|
53 |
@date 2018.05.16 |
|
54 |
''' |
|
55 |
def toXml(self): |
|
56 |
pass |
|
57 |
|
|
58 |
''' |
|
59 |
@brief write attribute to xml |
|
60 |
@author humkyung |
|
61 |
@date 2018.05.16 |
|
62 |
''' |
|
63 |
def toXmlAsAttribute(self, parent): |
|
64 |
pass |
DTI_PID/DTI_PID/Shapes/QEngineeringLineNoTextItem.py | ||
---|---|---|
72 | 72 |
@author humkyung |
73 | 73 |
@date 2018.04.23 |
74 | 74 |
@history humkyung 2018.05.02 write symbol's attribute |
75 |
humkyung 2018.05.16 write run information to xml |
|
75 | 76 |
''' |
76 | 77 |
def toXml(self): |
77 | 78 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree |
... | ... | |
87 | 88 |
node = Element('LINE_NO') |
88 | 89 |
uidNode = Element('UID') |
89 | 90 |
uidNode.text = str(self.uid) |
91 |
node.append(uidNode) |
|
90 | 92 |
|
91 | 93 |
textNode = Element('TEXT') |
92 | 94 |
textNode.text = self.text() |
95 |
node.append(textNode) |
|
93 | 96 |
|
94 | 97 |
rect = self.sceneBoundingRect() |
95 | 98 |
locNode = Element('LOCATION') |
96 | 99 |
locNode.text = '{},{}'.format(rect.left(), rect.top()) |
100 |
node.append(locNode) |
|
97 | 101 |
|
98 | 102 |
widthNode = Element('WIDTH') |
99 | 103 |
widthNode.text = str(rect.width()) |
104 |
node.append(widthNode) |
|
100 | 105 |
|
101 | 106 |
heightNode = Element('HEIGHT') |
102 | 107 |
heightNode.text = str(rect.height()) |
108 |
node.append(heightNode) |
|
103 | 109 |
|
104 | 110 |
angleNode = Element('ANGLE') |
105 | 111 |
angleNode.text = str(self.angle) |
106 |
|
|
107 |
node.append(uidNode) |
|
108 |
node.append(textNode) |
|
109 |
node.append(locNode) |
|
110 |
node.append(widthNode) |
|
111 |
node.append(heightNode) |
|
112 | 112 |
node.append(angleNode) |
113 | 113 |
|
114 |
connectedItems = self.getConnectedItems() |
|
115 |
connectedLines = [item for item in connectedItems if type(item) is QEngineeringLineItem] |
|
114 |
for run in self.runs: |
|
115 |
node.append(run.toXml()) |
|
116 |
|
|
117 |
#connectedItems = self.getConnectedItems() |
|
118 |
#connectedLines = [item for item in connectedItems if type(item) is QEngineeringLineItem] |
|
116 | 119 |
''' |
117 | 120 |
while len(connectedLines) > 0: |
118 | 121 |
line = connectedLines.pop() |
... | ... | |
137 | 140 |
for item in groupItems: connectedLines.remove(item) |
138 | 141 |
''' |
139 | 142 |
|
140 |
for item in connectedLines: |
|
141 |
node.append(item.toXml()) |
|
143 |
#for item in connectedLines:
|
|
144 |
# node.append(item.toXml())
|
|
142 | 145 |
|
143 |
connectedSymbols = [item for item in connectedItems if issubclass(type(item), SymbolSvgItem)] |
|
144 |
for item in connectedSymbols: |
|
145 |
node.append(item.toXml()) |
|
146 |
#connectedSymbols = [item for item in connectedItems if issubclass(type(item), SymbolSvgItem)]
|
|
147 |
#for item in connectedSymbols:
|
|
148 |
# node.append(item.toXml())
|
|
146 | 149 |
|
147 | 150 |
attrs = self.getLineNoAttributes() |
148 | 151 |
for key,value in attrs.items(): |
... | ... | |
162 | 165 |
|
163 | 166 |
node.append(attrNode) |
164 | 167 |
|
165 |
for item in connectedSymbols: |
|
166 |
item.toXmlAsAttribute(node) |
|
168 |
#for item in connectedSymbols:
|
|
169 |
# item.toXmlAsAttribute(node)
|
|
167 | 170 |
except Exception as ex: |
168 | 171 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
169 | 172 |
|
DTI_PID/DTI_PID/Shapes/QEngineeringRunItem.py | ||
---|---|---|
1 |
from PyQt5.QtCore import pyqtSignal, QObject
|
|
1 |
import sys
|
|
2 | 2 |
import os.path |
3 | 3 |
import copy |
4 | 4 |
try: |
5 |
from PyQt5.QtCore import Qt, QPointF, QRectF, pyqtSignal, QT_VERSION_STR |
|
5 |
from PyQt5.QtCore import Qt, QPointF, QRectF, pyqtSignal, QObject, QT_VERSION_STR
|
|
6 | 6 |
from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QBrush, QPen, QTransform |
7 | 7 |
from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QGraphicsItem, QAbstractGraphicsShapeItem, QGraphicsPathItem |
8 | 8 |
except ImportError: |
9 | 9 |
try: |
10 |
from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR |
|
10 |
from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QObject, QT_VERSION_STR
|
|
11 | 11 |
from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog |
12 | 12 |
except ImportError: |
13 | 13 |
raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.") |
... | ... | |
38 | 38 |
''' |
39 | 39 |
@items.setter |
40 | 40 |
def items(self, value): |
41 |
self._items = value |
|
41 |
self._items = value |
|
42 |
|
|
43 |
''' |
|
44 |
@brief write to xml |
|
45 |
@author humkyung |
|
46 |
@date 2018.05.16 |
|
47 |
''' |
|
48 |
def toXml(self): |
|
49 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree |
|
50 |
from QEngineeringLineItem import QEngineeringLineItem |
|
51 |
from SymbolSvgItem import SymbolSvgItem |
|
52 |
|
|
53 |
try: |
|
54 |
node = Element('RUN') |
|
55 |
|
|
56 |
connectedLines = [item for item in self.items if type(item) is QEngineeringLineItem] |
|
57 |
''' |
|
58 |
while len(connectedLines) > 0: |
|
59 |
line = connectedLines.pop() |
|
60 |
if line.isHorizontal(): |
|
61 |
groupItems = [item for item in connectedLines if item.isHorizontal() and (line.startPoint()[1] - item.startPoint()[1] < 1)] |
|
62 |
elif line.isVertical(): |
|
63 |
groupItems = [item for item in connectedLines if item.isVertical() and (line.startPoint()[0] - item.startPoint()[0] < 1)] |
|
64 |
|
|
65 |
pts = [] |
|
66 |
pts.append(line.startPoint()) |
|
67 |
pts.append(line.endPoint()) |
|
68 |
for item in groupItems: |
|
69 |
pts.append(item.startPoint()) |
|
70 |
pts.append(item.endPoint()) |
|
71 |
longestPoints = self.getLongestTwoPoints(pts) |
|
72 |
if 2 == len(longestPoints): |
|
73 |
tmp = QEngineeringLineItem() |
|
74 |
tmp._pol.append(QPointF(longestPoints[0][0], longestPoints[0][1])) |
|
75 |
tmp._pol.append(QPointF(longestPoints[1][0], longestPoints[1][1])) |
|
76 |
node.append(tmp.toXml()) |
|
77 |
|
|
78 |
for item in groupItems: connectedLines.remove(item) |
|
79 |
''' |
|
80 |
|
|
81 |
for item in connectedLines: |
|
82 |
node.append(item.toXml()) |
|
83 |
|
|
84 |
connectedSymbols = [item for item in self.items if issubclass(type(item), SymbolSvgItem)] |
|
85 |
for item in connectedSymbols: |
|
86 |
node.append(item.toXml()) |
|
87 |
|
|
88 |
for item in connectedSymbols: |
|
89 |
item.toXmlAsAttribute(node) |
|
90 |
|
|
91 |
except Exception as ex: |
|
92 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
93 |
|
|
94 |
return node |
DTI_PID/DTI_PID/XmlGenerator.py | ||
---|---|---|
95 | 95 |
@date 2018.04.23 |
96 | 96 |
@history humkyung 2018.05.02 write equipment node |
97 | 97 |
humkyung 2018.05.10 write orphan lines |
98 |
humkyung 2018.05.16 remove code to write orphan lines and symbols |
|
98 | 99 |
''' |
99 | 100 |
def generateOutputXml(pidName, pidWidth, pidHeight): |
100 | 101 |
docData = AppDocData.instance() |
... | ... | |
113 | 114 |
sortedList = sorted(docData.lineNos, key=lambda param:param.text()) |
114 | 115 |
for lineno in sortedList: |
115 | 116 |
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()) |
|
124 | 117 |
except Exception as ex: |
125 | 118 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
126 | 119 |
|
내보내기 Unified diff