개정판 d7ddc5c0
dev issue #637: edit spec break item logic
DTI_PID/DTI_PID/Commands/DefaultCommand.py | ||
---|---|---|
127 | 127 |
self.symbol.specBreak_offsetX = offsetX |
128 | 128 |
self.symbol.specBreak_offsetY = offsetY |
129 | 129 |
|
130 |
connLoc = self.symbol.connectors[0]._loc |
|
131 |
self.symbol.connectors[0].setPos((float(connLoc[0] + offsetX), float(connLoc[1] + offsetY))) |
|
132 |
self.symbol.loc = (self.symbol.loc[0] - offsetX, self.symbol.loc[1] - offsetY) |
|
133 |
|
|
130 |
self.symbol.connectors[0].connectPoint = (self.symbol.connectors[0].connectPoint[0] + offsetX, self.symbol.connectors[0].connectPoint[1] + offsetY) |
|
131 |
self.symbol.connectors[0].setPos((self.symbol.connectors[0].connectPoint[0], self.symbol.connectors[0].connectPoint[1])) |
|
134 | 132 |
|
135 | 133 |
self.symbol = None |
136 | 134 |
self.isCopy = False |
DTI_PID/DTI_PID/Shapes/EngineeringSpecBreakItem.py | ||
---|---|---|
8 | 8 |
from PyQt5.QtSvg import * |
9 | 9 |
from PyQt5.QtWidgets import (QApplication, QGraphicsItem) |
10 | 10 |
|
11 |
from AppDocData import * |
|
11 | 12 |
from SymbolSvgItem import SymbolSvgItem |
13 |
from UserInputAttribute import UserInputAttribute |
|
12 | 14 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
13 | 15 |
|
14 | 16 |
class QEngineeringSpecBreakItem(SymbolSvgItem): |
... | ... | |
19 | 21 |
''' |
20 | 22 |
def __init__(self, path, uid=None): |
21 | 23 |
SymbolSvgItem.__init__(self, path, uid) |
24 |
|
|
25 |
self.specBreak_offsetX = 0 |
|
26 |
self.specBreak_offsetY = 0 |
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
''' |
|
32 |
@brief get attribute |
|
33 |
@author humkyung |
|
34 |
@date 2018.06.14 |
|
35 |
@history kyouho 2018.07.18 Add only attr QEngineeringTextItem |
|
36 |
''' |
|
37 |
def getAttributes(self): |
|
38 |
from EngineeringTextItem import QEngineeringTextItem |
|
39 |
from QEngineeringInstrumentItem import QEngineeringInstrumentItem |
|
40 |
from EngineeringSpecBreakItem import QEngineeringSpecBreakItem |
|
41 |
attrs = {} |
|
42 |
|
|
43 |
# 해당 Type의 attribute setting |
|
44 |
docData = AppDocData.instance() |
|
45 |
|
|
46 |
attrs['Up Stream'] = '' |
|
47 |
attrs['Down Stream'] = '' |
|
48 |
|
|
49 |
symbolAttrs = docData.getSymbolAttribute(self.type) |
|
50 |
for attr in symbolAttrs: |
|
51 |
attrs[attr[0]] = '' |
|
52 |
|
|
53 |
for attr in self.attrs: |
|
54 |
if type(attr) is QEngineeringTextItem or issubclass(type(attr), SymbolSvgItem): |
|
55 |
attrs[attr.attribute] = attr.uid |
|
56 |
elif type(attr) is QEngineeringInstrumentItem: |
|
57 |
attrs['Label'] = '{}'.format(attr) |
|
58 |
elif type(attr) is UserInputAttribute: |
|
59 |
attrs[attr.attribute] = attr.text |
|
60 |
elif type(attr) is tuple: |
|
61 |
attrs[attr[0]] = attr[1] |
|
62 |
|
|
63 |
return attrs |
|
64 |
|
|
65 |
|
|
66 |
''' |
|
67 |
@brief generate xml code for nozzle |
|
68 |
@author humkyung |
|
69 |
@date 2018.07.19 |
|
70 |
''' |
|
71 |
def toXml(self): |
|
72 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree |
|
73 |
|
|
74 |
try: |
|
75 |
node = SymbolSvgItem.toXml(self) |
|
76 |
|
|
77 |
specBreakOffsetXNode = Element('SPECBREAKOFFSETX') |
|
78 |
specBreakOffsetXNode.text = str(self.specBreak_offsetX) |
|
79 |
node.append(specBreakOffsetXNode) |
|
80 |
|
|
81 |
specBreakOffsetYNode = Element('SPECBREAKOFFSETY') |
|
82 |
specBreakOffsetYNode.text = str(self.specBreak_offsetY) |
|
83 |
node.append(specBreakOffsetYNode) |
|
84 |
|
|
85 |
except Exception as ex: |
|
86 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
87 |
|
|
88 |
return node |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
58 | 58 |
self.currentCursor = 0 |
59 | 59 |
self.transfer = Transfer() |
60 | 60 |
|
61 |
self.specBreak_offsetX = 0 |
|
62 |
self.specBreak_offsetY = 0 |
|
63 |
|
|
64 |
|
|
65 | 61 |
try: |
66 | 62 |
f = QFile(path) |
67 | 63 |
f.open(QIODevice.ReadOnly) |
... | ... | |
140 | 136 |
|
141 | 137 |
self.setConnector() |
142 | 138 |
self.connectors[index].direction = direction |
143 |
self.connectors[index].setPos((x - self.specBreak_offsetX, y - self.specBreak_offsetY))
|
|
139 |
self.connectors[index].setPos((x, y))
|
|
144 | 140 |
self.connectors[index].connectPoint = (x, y) |
145 | 141 |
self.connectors[index].sceneConnectPoint = (connPts[index][0], connPts[index][1]) if len(connPts[index]) == 2 else (connPts[index][1], connPts[index][2]) \ |
146 | 142 |
if len(connPts) > index else None |
... | ... | |
532 | 528 |
def getAttributes(self): |
533 | 529 |
from EngineeringTextItem import QEngineeringTextItem |
534 | 530 |
from QEngineeringInstrumentItem import QEngineeringInstrumentItem |
535 |
from EngineeringSpecBreakItem import QEngineeringSpecBreakItem |
|
536 | 531 |
attrs = {} |
537 | 532 |
|
538 | 533 |
# 해당 Type의 attribute setting |
539 | 534 |
docData = AppDocData.instance() |
540 |
if type(self) is QEngineeringSpecBreakItem: |
|
541 |
attrs['Up Stream'] = '' |
|
542 |
attrs['Down Stream'] = '' |
|
543 | 535 |
|
544 | 536 |
symbolAttrs = docData.getSymbolAttribute(self.type) |
545 | 537 |
for attr in symbolAttrs: |
546 | 538 |
attrs[attr[0]] = '' |
547 | 539 |
|
548 |
|
|
549 | 540 |
for attr in self.attrs: |
550 | 541 |
if type(attr) is QEngineeringTextItem or issubclass(type(attr), SymbolSvgItem): |
551 | 542 |
attrs[attr.attribute] = attr.uid |
... | ... | |
553 | 544 |
attrs['Label'] = '{}'.format(attr) |
554 | 545 |
elif type(attr) is UserInputAttribute: |
555 | 546 |
attrs[attr.attribute] = attr.text |
556 |
elif type(attr) is tuple: |
|
557 |
attrs[attr[0]] = attr[1] |
|
558 | 547 |
|
559 | 548 |
return attrs |
560 | 549 |
|
... | ... | |
675 | 664 |
currentPointModeIndexNode.text = str(self.currentPointModeIndex) |
676 | 665 |
node.append(currentPointModeIndexNode) |
677 | 666 |
|
678 |
if type(self) is QEngineeringSpecBreakItem: |
|
679 |
specBreakOffsetXNode = Element('SPECBREAKOFFSETX') |
|
680 |
specBreakOffsetXNode.text = str(self.specBreak_offsetX) |
|
681 |
node.append(specBreakOffsetXNode) |
|
682 |
|
|
683 |
specBreakOffsetYNode = Element('SPECBREAKOFFSETY') |
|
684 |
specBreakOffsetYNode.text = str(self.specBreak_offsetY) |
|
685 |
node.append(specBreakOffsetYNode) |
|
686 |
|
|
687 |
|
|
688 |
|
|
689 | 667 |
except Exception as ex: |
690 | 668 |
return str(self.uid) |
691 | 669 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
... | ... | |
929 | 907 |
''' |
930 | 908 |
def addSvgItemToScene(self, scene): |
931 | 909 |
transform = QTransform() |
932 |
transform.translate(self.loc[0] + self.symbolOrigin[0] + self.specBreak_offsetX, self.loc[1] + self.symbolOrigin[1] + self.specBreak_offsetY)
|
|
910 |
transform.translate(self.loc[0] + self.symbolOrigin[0], self.loc[1] + self.symbolOrigin[1])
|
|
933 | 911 |
transform.rotateRadians(-self.angle) |
934 | 912 |
currentPoint = self.getCurrentPoint() |
935 |
transform.translate(-currentPoint[0] - self.specBreak_offsetX, -currentPoint[1] - self.specBreak_offsetY)
|
|
913 |
transform.translate(-currentPoint[0], -currentPoint[1])
|
|
936 | 914 |
|
937 | 915 |
self.setTransform(transform) |
938 | 916 |
scene.addItem(self) |
... | ... | |
1015 | 993 |
def reSettingSymbol(self, standardPoint, angle): |
1016 | 994 |
transform = QTransform() |
1017 | 995 |
|
1018 |
transform.translate(self.loc[0] + self.symbolOrigin[0] + self.specBreak_offsetX, self.loc[1] + self.symbolOrigin[1] + self.specBreak_offsetY)
|
|
996 |
transform.translate(self.loc[0] + self.symbolOrigin[0], self.loc[1] + self.symbolOrigin[1])
|
|
1019 | 997 |
transform.rotateRadians(-angle) |
1020 |
transform.translate(-standardPoint[0] - self.specBreak_offsetX, -standardPoint[1] - self.specBreak_offsetY)
|
|
998 |
transform.translate(-standardPoint[0], -standardPoint[1])
|
|
1021 | 999 |
|
1022 | 1000 |
self.setTransform(transform) |
1023 | 1001 |
|
... | ... | |
1066 | 1044 |
@date 2018.07.25 |
1067 | 1045 |
''' |
1068 | 1046 |
def getCurrentPoint(self): |
1047 |
from EngineeringSpecBreakItem import QEngineeringSpecBreakItem |
|
1048 |
|
|
1069 | 1049 |
pointList = [] |
1070 | 1050 |
pointList.append(self.symbolOrigin) |
1071 | 1051 |
for connector in self.connectors: |
1072 | 1052 |
pointList.append(connector.connectPoint) |
1073 | 1053 |
|
1054 |
if type(self) is QEngineeringSpecBreakItem: |
|
1055 |
self.currentPointModeIndex = 1 |
|
1056 |
|
|
1074 | 1057 |
return pointList[self.currentPointModeIndex] |
1075 | 1058 |
|
1076 | 1059 |
''' |
내보내기 Unified diff