개정판 bc21c61a
merge separated lines before writing output xml file
DTI_PID/DTI_PID/Shapes/QEngineeringLineNoTextItem.py | ||
---|---|---|
114 | 114 |
for run in self.runs: |
115 | 115 |
node.append(run.toXml()) |
116 | 116 |
|
117 |
#connectedItems = self.getConnectedItems() |
|
118 |
#connectedLines = [item for item in connectedItems if type(item) is QEngineeringLineItem] |
|
119 |
''' |
|
120 |
while len(connectedLines) > 0: |
|
121 |
line = connectedLines.pop() |
|
122 |
if line.isHorizontal(): |
|
123 |
groupItems = [item for item in connectedLines if item.isHorizontal() and (line.startPoint()[1] - item.startPoint()[1] < 1)] |
|
124 |
elif line.isVertical(): |
|
125 |
groupItems = [item for item in connectedLines if item.isVertical() and (line.startPoint()[0] - item.startPoint()[0] < 1)] |
|
126 |
|
|
127 |
pts = [] |
|
128 |
pts.append(line.startPoint()) |
|
129 |
pts.append(line.endPoint()) |
|
130 |
for item in groupItems: |
|
131 |
pts.append(item.startPoint()) |
|
132 |
pts.append(item.endPoint()) |
|
133 |
longestPoints = self.getLongestTwoPoints(pts) |
|
134 |
if 2 == len(longestPoints): |
|
135 |
tmp = QEngineeringLineItem() |
|
136 |
tmp._pol.append(QPointF(longestPoints[0][0], longestPoints[0][1])) |
|
137 |
tmp._pol.append(QPointF(longestPoints[1][0], longestPoints[1][1])) |
|
138 |
node.append(tmp.toXml()) |
|
139 |
|
|
140 |
for item in groupItems: connectedLines.remove(item) |
|
141 |
''' |
|
142 |
|
|
143 |
#for item in connectedLines: |
|
144 |
# node.append(item.toXml()) |
|
145 |
|
|
146 |
#connectedSymbols = [item for item in connectedItems if issubclass(type(item), SymbolSvgItem)] |
|
147 |
#for item in connectedSymbols: |
|
148 |
# node.append(item.toXml()) |
|
149 |
|
|
150 | 117 |
attrs = self.getLineNoAttributes() |
151 | 118 |
for key,value in attrs.items(): |
152 | 119 |
attrNode = Element('ATTRIBUTE') |
... | ... | |
164 | 131 |
attrNode.append(valueNode) |
165 | 132 |
|
166 | 133 |
node.append(attrNode) |
167 |
|
|
168 |
#for item in connectedSymbols: |
|
169 |
# item.toXmlAsAttribute(node) |
|
170 | 134 |
except Exception as ex: |
171 | 135 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
172 | 136 |
|
DTI_PID/DTI_PID/Shapes/QEngineeringRunItem.py | ||
---|---|---|
41 | 41 |
self._items = value |
42 | 42 |
|
43 | 43 |
''' |
44 |
@brief get two points which's length is max |
|
45 |
@author humkyung |
|
46 |
@date 2018.05.23 |
|
47 |
''' |
|
48 |
def getLongestTwoPoints(self, pts): |
|
49 |
import math |
|
50 |
res = [None, None] |
|
51 |
|
|
52 |
maxDistance = None |
|
53 |
for i in range(len(pts)): |
|
54 |
for j in range(i+1, len(pts)): |
|
55 |
dx = pts[i][0] - pts[j][0] |
|
56 |
dy = pts[i][1] - pts[j][1] |
|
57 |
dist = math.sqrt(dx*dx + dy*dy) |
|
58 |
if (maxDistance is None) or (maxDistance < dist): |
|
59 |
maxDistance = dist |
|
60 |
res[0] = pts[i] |
|
61 |
res[1] = pts[j] |
|
62 |
|
|
63 |
return res |
|
64 |
|
|
65 |
''' |
|
44 | 66 |
@brief write to xml |
45 | 67 |
@author humkyung |
46 | 68 |
@date 2018.05.16 |
... | ... | |
54 | 76 |
node = Element('RUN') |
55 | 77 |
|
56 | 78 |
connectedLines = [item for item in self.items if type(item) is QEngineeringLineItem] |
57 |
''' |
|
79 |
|
|
80 |
# merge lines |
|
58 | 81 |
while len(connectedLines) > 0: |
59 | 82 |
line = connectedLines.pop() |
60 | 83 |
if line.isHorizontal(): |
... | ... | |
76 | 99 |
node.append(tmp.toXml()) |
77 | 100 |
|
78 | 101 |
for item in groupItems: connectedLines.remove(item) |
79 |
'''
|
|
102 |
# up to here
|
|
80 | 103 |
|
104 |
# write lines which're not merged |
|
81 | 105 |
for item in connectedLines: |
82 | 106 |
node.append(item.toXml()) |
83 | 107 |
|
DTI_PID/DTI_PID/XmlGenerator.py | ||
---|---|---|
65 | 65 |
@date |
66 | 66 |
''' |
67 | 67 |
def writeXml(pidName, pidWidth, pidHeight, searchedSymbolList, textInfoList, imgLineList, noteTextInfoList): |
68 |
path = os.path.join(AppDocData.instance().getCurrentProject().getOutputPath(), pidName + '.xml')
|
|
68 |
path = os.path.join(AppDocData.instance().getCurrentProject().getTempPath(), pidName + '.xml')
|
|
69 | 69 |
try: |
70 | 70 |
xmlData = generateXml(pidName, pidWidth, pidHeight, searchedSymbolList, textInfoList, imgLineList, noteTextInfoList) |
71 | 71 |
ElementTree(xmlData).write(path) |
... | ... | |
80 | 80 |
@date 2018.04.23 |
81 | 81 |
''' |
82 | 82 |
def writeOutputXml(pidName, pidWidth, pidHeight): |
83 |
path = os.path.join(AppDocData.instance().getCurrentProject().getOutputPath(), 'output_' + pidName + '.xml')
|
|
83 |
path = os.path.join(AppDocData.instance().getCurrentProject().getOutputPath(), pidName + '.xml') |
|
84 | 84 |
try: |
85 | 85 |
xmlData = generateOutputXml(pidName, pidWidth, pidHeight) |
86 | 86 |
ElementTree(xmlData).write(path) |
내보내기 Unified diff