개정판 f21ec5b3
Write equipment information to xml file
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
88 | 88 |
self.imgHeight = 0 |
89 | 89 |
|
90 | 90 |
self._areas = [] |
91 |
self.equipments = [] |
|
91 | 92 |
self.lineNos = [] |
92 | 93 |
|
93 | 94 |
def setCurrentPidSource(self, image): |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
461 | 461 |
svgFilePath = project.getSvgFilePath() + '/' + type + '/' + name + '.svg' |
462 | 462 |
if os.path.isfile(svgFilePath): |
463 | 463 |
svg = SymbolSvgItem(svgFilePath) |
464 |
svg.name = name |
|
465 |
svg.type = type |
|
466 |
svg.angle = angle |
|
467 |
svg.loc = pt |
|
468 |
svg.size = size |
|
469 |
svg.origin = origin |
|
470 |
svg.connPts = connPts |
|
464 |
svg.buildItem(name, type, angle, pt, size, origin, connPts) |
|
471 | 465 |
|
472 | 466 |
#### lambda param=svg : bind 'svg' object to lambda('param') |
473 | 467 |
#### If case of 'lambda svg=svg:', function uses the 'svg' value bound to lambda |
... | ... | |
487 | 481 |
transform.translate(pt[0],pt[1]) |
488 | 482 |
svg.setTransform(transform) |
489 | 483 |
self.graphicsView.scene.addItem(svg) |
484 |
for connector in svg.connectors: |
|
485 |
self.graphicsView.scene.addItem(connector) |
|
490 | 486 |
else: |
491 | 487 |
item = QGraphicsBoundingBoxItem(pt[0], pt[1], size[0], size[1]) |
492 | 488 |
item.isSymbol = True |
... | ... | |
547 | 543 |
|
548 | 544 |
try: |
549 | 545 |
docData = AppDocData.instance() |
546 |
|
|
547 |
# TODO: how to check equipment |
|
548 |
docData.equipments.clear() |
|
549 |
for item in self.graphicsView.scene.items(): |
|
550 |
if (type(item) is SymbolSvgItem) and item.type == 'Specialty Components': |
|
551 |
docData.equipments.append(item) |
|
552 |
# up to here |
|
553 |
|
|
550 | 554 |
xg.writeOutputXml(docData.imgName, docData.imgWidth, docData.imgHeight) |
551 | 555 |
except Exception as ex: |
552 | 556 |
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/QtImageViewer.py | ||
---|---|---|
406 | 406 |
symbol = AppDocData.instance().getSymbolByQuery('name', svgFileName) |
407 | 407 |
svgFilePath = os.path.join(AppDocData.instance().getCurrentProject().getSvgFilePath(), symbol.getType(), svgFileName+'.svg') |
408 | 408 |
svg = SymbolSvgItem(svgFilePath) |
409 |
svg.name = svgFileName |
|
410 |
svg.type = symbol.getType() |
|
411 |
svg.angle = 0 |
|
412 |
svg.origin = [float(x) for x in symbol.getOriginalPoint().split(',')] |
|
409 |
connPts = None |
|
413 | 410 |
strConnPts = symbol.getConnectionPoint() |
414 | 411 |
if strConnPts is not None: |
415 |
svg.connPts = [(float(x.split(',')[0]), float(x.split(',')[1])) for x in strConnPts.split('/')] |
|
412 |
connPts = [(float(x.split(',')[0]), float(x.split(',')[1])) for x in strConnPts.split('/')] |
|
413 |
|
|
414 |
svg.buildItem(svgFileName, symbol.getType(), 0, None, None, [float(x) for x in symbol.getOriginalPoint().split(',')], connPts) |
|
416 | 415 |
|
417 | 416 |
matches = [item for item in self.scene.items() if (type(item) is QEngineeringLineItem) and (item.distanceTo((scenePos.x(), scenePos.y())) < 20)] |
418 | 417 |
if len(matches) == 1: |
... | ... | |
424 | 423 |
svg.loc = [scenePos.x() - svg.origin[0], scenePos.y() - svg.origin[1]] |
425 | 424 |
svg.size = [svg.boundingRect().width(), svg.boundingRect().height()] |
426 | 425 |
self.scene.addItem(svg) |
426 |
for connector in svg.connectors: |
|
427 |
self.scene.addItem(connector) |
|
427 | 428 |
|
428 | 429 |
event.acceptProposedAction() |
429 | 430 |
|
DTI_PID/DTI_PID/Shapes/QEngineeringLineItem.py | ||
---|---|---|
264 | 264 |
symbol.loc = [origin.x - symbol.origin[0], origin.y - symbol.origin[1]] |
265 | 265 |
symbol.size = [symbol.boundingRect().width(), symbol.boundingRect().height()] |
266 | 266 |
self.scene().addItem(symbol) |
267 |
for connector in symbol.connectors: |
|
268 |
self.scene().addItem(connector) |
|
267 | 269 |
|
268 | 270 |
''' |
269 | 271 |
@brief remove symbol |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
9 | 9 |
from PyQt5.QtSvg import * |
10 | 10 |
from PyQt5.QtWidgets import (QApplication, QGraphicsItem) |
11 | 11 |
|
12 |
from QConnectorItem import QConnectorItem |
|
13 |
|
|
12 | 14 |
class SymbolSvgItem(QGraphicsSvgItem): |
13 | 15 |
clicked = pyqtSignal(QGraphicsSvgItem) |
14 | 16 |
removed = pyqtSignal(QGraphicsItem) |
... | ... | |
19 | 21 |
def __init__(self, path): |
20 | 22 |
import uuid |
21 | 23 |
|
22 |
super(SymbolSvgItem, self).__init__(path)
|
|
24 |
QGraphicsSvgItem.__init__(self, path)
|
|
23 | 25 |
|
24 | 26 |
self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsFocusable) |
25 | 27 |
#QGraphicsItem.ItemIsMovable) |
... | ... | |
32 | 34 |
self.loc = None |
33 | 35 |
self.size = None |
34 | 36 |
self.conns = [] |
37 |
self.connectors = [] |
|
35 | 38 |
|
36 | 39 |
self.setAcceptHoverEvents(True) |
37 | 40 |
self.setAcceptedMouseButtons(Qt.LeftButton) |
38 | 41 |
self.setAcceptTouchEvents(True) |
39 | 42 |
|
40 | 43 |
''' |
44 |
@brief build symbol item |
|
45 |
@author humkyung |
|
46 |
@date 2018.05.02 |
|
47 |
''' |
|
48 |
def buildItem(self, name, type, angle, loc, size, origin, connPts): |
|
49 |
try: |
|
50 |
self.name = name |
|
51 |
self.type = type |
|
52 |
self.angle = angle |
|
53 |
self.loc = loc |
|
54 |
self.size = size |
|
55 |
self.origin = origin |
|
56 |
self.connPts = connPts |
|
57 |
|
|
58 |
for pt in self.connPts: |
|
59 |
connector = QConnectorItem() |
|
60 |
connector.setPos(pt) |
|
61 |
connector.setVisible(False) |
|
62 |
self.connectors.append(connector) |
|
63 |
except Exception as ex: |
|
64 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
65 |
|
|
66 |
''' |
|
41 | 67 |
@brief return bounding box of symbol |
42 | 68 |
@author humkyung |
43 | 69 |
@date 2018.04.08 |
... | ... | |
112 | 138 |
QApplication.instance().setOverrideCursor(cursor) |
113 | 139 |
self.update() |
114 | 140 |
|
141 |
for connector in self.connectors: |
|
142 |
connector.setVisible(True) |
|
143 |
connector.update() |
|
144 |
|
|
115 | 145 |
def hoverLeaveEvent(self, event): |
116 | 146 |
QApplication.instance().restoreOverrideCursor() |
117 | 147 |
self.update() |
118 | 148 |
|
149 |
for connector in self.connectors: |
|
150 |
connector.setVisible(False) |
|
151 |
connector.update() |
|
152 |
|
|
119 | 153 |
''' |
120 | 154 |
@brief change cursor to CrossCursor if mouse point is close to connection point |
121 | 155 |
@author humkyung |
DTI_PID/DTI_PID/XmlGenerator.py | ||
---|---|---|
89 | 89 |
return path |
90 | 90 |
|
91 | 91 |
''' |
92 |
@brief generate output xml |
|
93 |
@author humkyung |
|
94 |
@date 2018.04.23 |
|
92 |
@brief generate output xml |
|
93 |
@author humkyung |
|
94 |
@date 2018.04.23 |
|
95 |
@history humkyung 2018.05.02 write equipment node |
|
95 | 96 |
''' |
96 | 97 |
def generateOutputXml(pidName, pidWidth, pidHeight): |
97 | 98 |
docData = AppDocData.instance() |
... | ... | |
102 | 103 |
SubElement(xml, ROOT_SIZE_NODE_NAME).text = str(pidWidth) + "," + str(pidHeight) |
103 | 104 |
SubElement(xml, 'UNIT').text = docData.getCurrentProject().unit() |
104 | 105 |
|
106 |
for equipment in docData.equipments: |
|
107 |
equipmentNode = Element('EQUIPMENT') |
|
108 |
equipmentNode.append(equipment.toXml()) |
|
109 |
xml.append(equipmentNode) |
|
110 |
|
|
105 | 111 |
sortedList = sorted(docData.lineNos, key=lambda param:param.text()) |
106 | 112 |
for lineno in sortedList: |
107 | 113 |
xml.append(lineno.toXml()) |
내보내기 Unified diff