개정판 6fb1a52e
Add UID to items
DTI_PID/DTI_PID/Shapes/QEngineeringLineItem.py | ||
---|---|---|
267 | 267 |
if (pts[0] == end) or (pts[1] == start): start,end = end,start |
268 | 268 |
|
269 | 269 |
self._pol.clear() |
270 |
self._pol.append(QPointF(start[0], end[1]))
|
|
270 |
self._pol.append(QPointF(start[0], start[1]))
|
|
271 | 271 |
self._pol.append(QPointF(end[0], end[1])) |
272 | 272 |
self.buildPath() |
273 | 273 |
self.update() |
... | ... | |
301 | 301 |
|
302 | 302 |
try: |
303 | 303 |
node = Element('LINE') |
304 |
uidNode = Element('UID') |
|
305 |
uidNode.text = str(self.uid) |
|
304 | 306 |
|
305 | 307 |
startPt = self.startPoint() |
306 | 308 |
endPt = self.endPoint() |
307 | 309 |
|
308 |
startNode = Element('START') |
|
310 |
startNode = Element('STARTPOINT')
|
|
309 | 311 |
startNode.text = '{},{}'.format(startPt[0], startPt[1]) |
310 | 312 |
|
311 |
endNode = Element('END') |
|
313 |
endNode = Element('ENDPOINT')
|
|
312 | 314 |
endNode.text = '{},{}'.format(endPt[0], endPt[1]) |
313 | 315 |
|
316 |
node.append(uidNode) |
|
314 | 317 |
node.append(startNode) |
315 | 318 |
node.append(endNode) |
316 | 319 |
except Exception as ex: |
317 | 320 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
318 | 321 |
|
319 |
return node |
|
322 |
return node |
DTI_PID/DTI_PID/Shapes/QEngineeringTextItem.py | ||
---|---|---|
21 | 21 |
removed = pyqtSignal(QGraphicsTextItem) |
22 | 22 |
|
23 | 23 |
def __init__(self, parent=None): |
24 |
import uuid |
|
25 |
|
|
24 | 26 |
QGraphicsTextItem.__init__(self, parent) |
25 | 27 |
|
28 |
self.uid = uuid.uuid4() # generate UUID |
|
26 | 29 |
self.loc = None |
27 | 30 |
self.size = None |
28 | 31 |
self.angle = 0 # angle in radian |
... | ... | |
176 | 179 |
''' |
177 | 180 |
def toXml(self): |
178 | 181 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree |
182 |
from QEngineeringLineItem import QEngineeringLineItem |
|
183 |
from SymbolSvgItem import SymbolSvgItem |
|
179 | 184 |
|
180 | 185 |
try: |
181 | 186 |
node = Element('LINE_NO') |
187 |
uidNode = Element('UID') |
|
188 |
uidNode.text = str(self.uid) |
|
182 | 189 |
|
183 | 190 |
textNode = Element('TEXT') |
184 | 191 |
textNode.text = self.text() |
185 | 192 |
|
186 | 193 |
rect = self.sceneBoundingRect() |
187 |
xNode = Element('X') |
|
188 |
xNode.text = str(rect.left()) |
|
189 |
|
|
190 |
yNode = Element('Y') |
|
191 |
yNode.text = str(rect.top()) |
|
194 |
locNode = Element('LOCATION') |
|
195 |
locNode.text = '{},{}'.format(rect.left(), rect.top()) |
|
192 | 196 |
|
193 | 197 |
widthNode = Element('WIDTH') |
194 | 198 |
widthNode.text = str(rect.width()) |
... | ... | |
199 | 203 |
angleNode = Element('ANGLE') |
200 | 204 |
angleNode.text = str(self.angle) |
201 | 205 |
|
206 |
node.append(uidNode) |
|
202 | 207 |
node.append(textNode) |
203 |
node.append(xNode) |
|
204 |
node.append(yNode) |
|
208 |
node.append(locNode) |
|
205 | 209 |
node.append(widthNode) |
206 | 210 |
node.append(heightNode) |
207 | 211 |
node.append(angleNode) |
208 | 212 |
|
209 | 213 |
connectedItems = self.getConnectedItems() |
210 |
for item in connectedItems: |
|
214 |
connectedLines = [item for item in connectedItems if type(item) is QEngineeringLineItem] |
|
215 |
for item in connectedLines: |
|
216 |
node.append(item.toXml()) |
|
217 |
|
|
218 |
connectedSymbols = [item for item in connectedItems if type(item) is SymbolSvgItem] |
|
219 |
for item in connectedSymbols: |
|
211 | 220 |
node.append(item.toXml()) |
212 | 221 |
except Exception as ex: |
213 | 222 |
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/QGraphicsPolylineItem.py | ||
---|---|---|
13 | 13 |
|
14 | 14 |
class QGraphicsPolylineItem(QGraphicsPathItem): |
15 | 15 |
def __init__(self, parent=None): |
16 |
import uuid |
|
17 |
|
|
16 | 18 |
QGraphicsPathItem.__init__(self, parent) |
17 | 19 |
self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsFocusable) |
18 | 20 |
|
21 |
self.uid = uuid.uuid4() # generate UUID |
|
19 | 22 |
self._vertices = [] |
20 | 23 |
self.isCreated = False |
21 | 24 |
self._pt = None |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
17 | 17 |
@history 18.04.11 Jeongwoo Add Variable (Name, Type) |
18 | 18 |
''' |
19 | 19 |
def __init__(self, path): |
20 |
import uuid |
|
21 |
|
|
20 | 22 |
super(SymbolSvgItem, self).__init__(path) |
21 | 23 |
|
22 | 24 |
self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsFocusable) |
23 | 25 |
#QGraphicsItem.ItemIsMovable) |
24 | 26 |
|
27 |
self.uid = uuid.uuid4() # generate UUID |
|
25 | 28 |
self.name = '' |
26 | 29 |
self.type = '' |
27 | 30 |
self.angle = 0 |
... | ... | |
133 | 136 |
|
134 | 137 |
try: |
135 | 138 |
node = Element('SYMBOL') |
139 |
uidNode = Element('UID') |
|
140 |
uidNode.text = str(self.uid) |
|
136 | 141 |
|
137 | 142 |
nameNode = Element('NAME') |
138 | 143 |
nameNode.text = self.name |
139 | 144 |
|
140 | 145 |
rect = self.sceneBoundingRect() |
141 |
locNode = Element('STARTPOINT')
|
|
146 |
locNode = Element('LOCATION')
|
|
142 | 147 |
locNode.text = '{},{}'.format(rect.left(), rect.top()) |
143 | 148 |
|
144 | 149 |
sizeNode = Element('SIZE') |
145 | 150 |
sizeNode.text = '{},{}'.format(rect.width(), rect.height()) |
146 | 151 |
|
152 |
node.append(uidNode) |
|
147 | 153 |
node.append(nameNode) |
148 | 154 |
node.append(locNode) |
149 | 155 |
node.append(sizeNode) |
DTI_PID/DTI_PID/XmlGenerator.py | ||
---|---|---|
86 | 86 |
def generateOutputXml(pidName, pidWidth, pidHeight): |
87 | 87 |
docData = AppDocData.instance() |
88 | 88 |
|
89 |
xml = Element(ROOT_NODE_NAME) # Root Node |
|
90 |
SubElement(xml, ROOT_DWGNAME_NODE_NAME).text = pidName |
|
91 |
SubElement(xml, ROOT_SIZE_NODE_NAME).text = str(pidWidth) + "," + str(pidHeight) |
|
92 |
|
|
93 |
lineNoNodes = Element(LINE_NO_LIST_NODE_NAME) # Line No Node |
|
94 |
sortedList = sorted(docData.lineNos, key=lambda param:param.text()) |
|
95 |
for lineno in sortedList: |
|
96 |
node = lineno.toXml() |
|
97 |
lineNoNodes.append(node) |
|
89 |
try: |
|
90 |
xml = Element(ROOT_NODE_NAME) # Root Node |
|
91 |
SubElement(xml, ROOT_DWGNAME_NODE_NAME).text = pidName |
|
92 |
SubElement(xml, ROOT_SIZE_NODE_NAME).text = str(pidWidth) + "," + str(pidHeight) |
|
98 | 93 |
|
99 |
xml.append(lineNoNodes) |
|
94 |
sortedList = sorted(docData.lineNos, key=lambda param:param.text()) |
|
95 |
for lineno in sortedList: |
|
96 |
xml.append(lineno.toXml()) |
|
97 |
except Exception as ex: |
|
98 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
100 | 99 |
|
101 | 100 |
return xml |
102 | 101 |
|
내보내기 Unified diff