개정판 4d9163f7
issue #646: MSSQL을 지원하도록 수정
Change-Id: I8257e4a71bf4ba73ed8c3b43cbf25c7e57bb7134
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
1982 | 1982 |
def read_symbol_shape(self, symbol_name): |
1983 | 1983 |
"""read symbol shape(image and svg)""" |
1984 | 1984 |
|
1985 |
res = None
|
|
1985 |
res = (None, None)
|
|
1986 | 1986 |
|
1987 | 1987 |
with self.project.database.connect() as conn: |
1988 | 1988 |
try: |
... | ... | |
2036 | 2036 |
|
2037 | 2037 |
sql = f"update Symbol set {','.join(cols)} where UID={symbol}" |
2038 | 2038 |
# Convert data into tuple format |
2039 |
cursor.execute(sql, tuple(params))
|
|
2039 |
cursor.execute(self.project.database.to_sql(sql), tuple(params))
|
|
2040 | 2040 |
conn.commit() |
2041 | 2041 |
|
2042 | 2042 |
# Catch the exception |
DTI_PID/DTI_PID/LineNoTracer.py | ||
---|---|---|
564 | 564 |
#print(type(line_end)) |
565 | 565 |
for connector in line_end.connectors: |
566 | 566 |
if connector.connectedItem is not None and type(connector.connectedItem.owner) is QEngineeringLineNoTextItem and connector.connectedItem.owner is not line_end.owner: |
567 |
end_break = SymbolSvgItem.createItem(symbol.getType(), svgFilePath) |
|
567 |
end_break = SymbolSvgItem.createItem(symbol.getType(), None, svgFilePath)
|
|
568 | 568 |
pt = [connector.center()[0] - float(symbol.getOriginalPoint().split(',')[0]), connector.center()[1] - float(symbol.getOriginalPoint().split(',')[1])] |
569 | 569 |
origin = [0, 0] |
570 | 570 |
if 2 == len(symbol.getOriginalPoint().split(',')): |
... | ... | |
672 | 672 |
for spec in spec_breaks: |
673 | 673 |
for connector in spec[0].connectors: |
674 | 674 |
if connector.connectedItem is spec[1]: |
675 |
spec_break = SymbolSvgItem.createItem(symbol.getType(), svgFilePath) |
|
675 |
spec_break = SymbolSvgItem.createItem(symbol.getType(), None, svgFilePath)
|
|
676 | 676 |
pt = [60 + connector.center()[0] - float(symbol.getOriginalPoint().split(',')[0]), 90 + connector.center()[1] - float(symbol.getOriginalPoint().split(',')[1])] |
677 | 677 |
origin = [0, 0] |
678 | 678 |
if 2 == len(symbol.getOriginalPoint().split(',')): |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
2212 | 2212 |
|
2213 | 2213 |
svgFilePath = os.path.join(project.getSvgFilePath(), _type, name + '.svg') |
2214 | 2214 |
if os.path.isfile(svgFilePath): |
2215 |
svg = SymbolSvgItem.createItem(_type, svgFilePath, owner=None, flip=flip) |
|
2216 |
# print(pt) |
|
2217 |
# print(origin) |
|
2215 |
svg = SymbolSvgItem.createItem(_type, None, svgFilePath, owner=None, flip=flip) |
|
2218 | 2216 |
svg.buildItem(name, _type, angle, pt, size, origin, connPts, parentSymbol, childSymbol, |
2219 | 2217 |
hasInstrumentLabel) |
2220 | 2218 |
svg.reCalculationRotatedItem() |
DTI_PID/DTI_PID/QtImageViewer.py | ||
---|---|---|
660 | 660 |
svg_file_name = symbol.sName |
661 | 661 |
svgFilePath = os.path.join(app_doc_data.getCurrentProject().getSvgFilePath(), symbol.getType(), |
662 | 662 |
svg_file_name + '.svg') |
663 |
svg = SymbolSvgItem.createItem(symbol.getType(), svgFilePath) |
|
663 |
svg = SymbolSvgItem.createItem(symbol.getType(), None, svgFilePath)
|
|
664 | 664 |
connPts = None |
665 | 665 |
strConnPts = symbol.getConnectionPoint() |
666 | 666 |
if strConnPts is not None and strConnPts != '': |
DTI_PID/DTI_PID/Scripts/ID2.sql | ||
---|---|---|
48 | 48 |
Width INTEGER, |
49 | 49 |
Height INTEGER, |
50 | 50 |
Flip INTEGER, |
51 |
Image VARCHAR(MAX), |
|
52 |
Svg VARCHAR(MAX), |
|
51 | 53 |
FOREIGN KEY ( |
52 | 54 |
SymbolType_UID |
53 | 55 |
) |
DTI_PID/DTI_PID/Shapes/EngineeringConnectorItem.py | ||
---|---|---|
514 | 514 |
app_doc_data = AppDocData.instance() |
515 | 515 |
path = app_doc_data.getErrorItemSvgPath() |
516 | 516 |
|
517 |
error = SymbolSvgItem.createItem('Error', path) |
|
517 |
error = SymbolSvgItem.createItem('Error', None, path)
|
|
518 | 518 |
error.setPosition(self.center()) |
519 | 519 |
error.parent = self.parentItem() |
520 | 520 |
error.msg = "connection point's position error" |
DTI_PID/DTI_PID/Shapes/EngineeringEndBreakItem.py | ||
---|---|---|
27 | 27 |
from SymbolAttr import SymbolProp |
28 | 28 |
from EngineeringFreezeItem import QEngineeringFreezeItem |
29 | 29 |
|
30 |
SymbolSvgItem.__init__(self, path, uid, flip=flip) |
|
30 |
SymbolSvgItem.__init__(self, None, path, uid, flip=flip)
|
|
31 | 31 |
self.setZValue(QEngineeringEndBreakItem.ZVALUE) |
32 | 32 |
#self.connected_lines = [] |
33 | 33 |
#attr = SymbolAttr() |
... | ... | |
46 | 46 |
#self.freeze_item.setZValue(self.zValue() + 1) |
47 | 47 |
#self.freeze_item.setPen(Qt.black) |
48 | 48 |
|
49 |
|
|
50 |
''' |
|
51 |
def setPosition(self, loc, origin): |
|
52 |
transform = QTransform() |
|
53 |
transform.translate(loc[0] - origin[0], loc[1] - origin[1]) |
|
54 |
self.origin = origin |
|
55 |
self.loc = loc |
|
56 |
self.setTransform(transform) |
|
57 |
|
|
58 |
def getAttributes(self): |
|
59 |
""" |
|
60 |
attributes MUST have Connected Line attribute |
|
61 |
""" |
|
62 |
return self.attrs |
|
63 |
|
|
64 |
def keyPressEvent(self, event): |
|
65 |
if self.isSelected() and event.key() == Qt.Key_Delete: |
|
66 |
self.scene().removeItem(self) |
|
67 |
''' |
|
68 |
|
|
69 |
''' |
|
70 |
@staticmethod |
|
71 |
def fromXml(node): |
|
72 |
import uuid |
|
73 |
from AppDocData import AppDocData |
|
74 |
|
|
75 |
end_break = None |
|
76 |
|
|
77 |
try: |
|
78 |
docdata = AppDocData.instance() |
|
79 |
dataPath = docdata.getErrorItemSvgPath() |
|
80 |
|
|
81 |
uidNode = node.find('UID') |
|
82 |
uid = uidNode.text if uidNode is not None else uuid.uuid4() # generate UUID |
|
83 |
|
|
84 |
pt = [float(x) for x in node.find('LOCATION').text.split(',')] |
|
85 |
name = node.find('NAME').text |
|
86 |
origin = [float(x) for x in node.find('ORIGINALPOINT').text.split(',')] |
|
87 |
areaNode = node.find('AREA').text |
|
88 |
connectedLineNode = [uid for uid in node.find('CONNECTED_LINE').text.split(',')] |
|
89 |
|
|
90 |
end_break = SymbolSvgItem.createItem('End Break', dataPath) |
|
91 |
end_break.setPosition(pt, origin) |
|
92 |
end_break.connected_lines = [connectedLineNode[0], connectedLineNode[1]] |
|
93 |
end_break.setToolTip(str(end_break.connected_lines)) |
|
94 |
end_break.area = areaNode |
|
95 |
end_break.name = name |
|
96 |
except Exception as ex: |
|
97 |
from App import App |
|
98 |
from AppDocData import MessageType |
|
99 |
|
|
100 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
101 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
102 |
|
|
103 |
return end_break |
|
104 |
|
|
105 |
|
|
106 |
def toXml(self): |
|
107 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree |
|
108 |
|
|
109 |
try: |
|
110 |
node = Element('END_BREAK') |
|
111 |
uidNode = Element('UID') |
|
112 |
uidNode.text = str(self.uid) |
|
113 |
node.append(uidNode) |
|
114 |
|
|
115 |
nameNode = Element('NAME') |
|
116 |
nameNode.text = self.name |
|
117 |
node.append(nameNode) |
|
118 |
|
|
119 |
areaNode = Element('AREA') |
|
120 |
areaNode.text = self.area |
|
121 |
node.append(areaNode) |
|
122 |
|
|
123 |
locNode = Element('LOCATION') |
|
124 |
locNode.text = '{},{}'.format(self.loc[0], self.loc[1]) |
|
125 |
node.append(locNode) |
|
126 |
|
|
127 |
originNode = Element('ORIGINALPOINT') |
|
128 |
originNode.text = '{},{}'.format(self.origin[0], self.origin[1]) |
|
129 |
node.append(originNode) |
|
130 |
|
|
131 |
connectedLineNode = Element('CONNECTED_LINE') |
|
132 |
connectedLineNode.text = '{},{}'.format(self.connected_lines[0], self.connected_lines[1]) |
|
133 |
node.append(connectedLineNode) |
|
134 |
|
|
135 |
except Exception as ex: |
|
136 |
from App import App |
|
137 |
from AppDocData import MessageType |
|
138 |
|
|
139 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
140 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
141 |
|
|
142 |
return None |
|
143 |
|
|
144 |
return node |
|
145 |
''' |
DTI_PID/DTI_PID/Shapes/EngineeringEquipmentItem.py | ||
---|---|---|
25 | 25 |
def __init__(self, path, uid=None, flip=0): |
26 | 26 |
from SymbolAttr import SymbolProp |
27 | 27 |
|
28 |
SymbolSvgItem.__init__(self, path, uid, flip=flip) |
|
28 |
SymbolSvgItem.__init__(self, None, path, uid, flip=flip)
|
|
29 | 29 |
self.setZValue(QEngineeringEquipmentItem.ZVALUE) |
30 | 30 |
|
31 | 31 |
self._properties = \ |
DTI_PID/DTI_PID/Shapes/EngineeringErrorItem.py | ||
---|---|---|
25 | 25 |
''' |
26 | 26 |
ZVALUE = 20 |
27 | 27 |
def __init__(self, path, uid=None, flip=0): |
28 |
SymbolSvgItem.__init__(self, path, uid, flip=flip) |
|
28 |
SymbolSvgItem.__init__(self, None, path, uid, flip=flip)
|
|
29 | 29 |
self.setZValue(QEngineeringErrorItem.ZVALUE) |
30 | 30 |
self.msg = None |
31 | 31 |
|
DTI_PID/DTI_PID/Shapes/EngineeringFlowMarkItem.py | ||
---|---|---|
27 | 27 |
from SymbolAttr import SymbolProp |
28 | 28 |
from EngineeringFreezeItem import QEngineeringFreezeItem |
29 | 29 |
|
30 |
SymbolSvgItem.__init__(self, path, uid, flip=flip) |
|
30 |
SymbolSvgItem.__init__(self, None, path, uid, flip=flip)
|
|
31 | 31 |
self.setZValue(QEngineeringFlowMarkItem.ZVALUE) |
32 | 32 |
|
33 | 33 |
self._properties = \ |
DTI_PID/DTI_PID/Shapes/EngineeringInstrumentItem.py | ||
---|---|---|
28 | 28 |
''' |
29 | 29 |
|
30 | 30 |
def __init__(self, path, uid=None, flip=0): |
31 |
SymbolSvgItem.__init__(self, path, uid, flip=flip) |
|
31 |
SymbolSvgItem.__init__(self, None, path, uid, flip=flip)
|
|
32 | 32 |
|
33 | 33 |
self._measuredVairableCode = None |
34 | 34 |
self._typeModifier = None |
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py | ||
---|---|---|
1067 | 1067 |
|
1068 | 1068 |
# check if there is not connected connector |
1069 | 1069 |
if connector.connectedItem is None: |
1070 |
error = SymbolSvgItem.createItem('Error', dataPath) |
|
1070 |
error = SymbolSvgItem.createItem('Error', None, dataPath)
|
|
1071 | 1071 |
error.setPosition(connector.center()) |
1072 | 1072 |
error.parent = self |
1073 | 1073 |
error.msg = _translate('disconnected', 'disconnected') |
... | ... | |
1082 | 1082 |
matches = [conn for conn in connector.connectedItem.connectors if conn.connectedItem is self] |
1083 | 1083 |
# check if two items are connected each other |
1084 | 1084 |
if not matches: |
1085 |
error = SymbolSvgItem.createItem('Error', dataPath) |
|
1085 |
error = SymbolSvgItem.createItem('Error', None, dataPath)
|
|
1086 | 1086 |
error.setPosition(connector.center()) |
1087 | 1087 |
error.parent = self |
1088 | 1088 |
error.msg = _translate('disconnected from opposite side', 'disconnected from opposite side') |
... | ... | |
1092 | 1092 |
errors.append(error) |
1093 | 1093 |
# check connection position |
1094 | 1094 |
elif not self.isOverlap(connector.sceneBoundingRect(), matches[0].sceneBoundingRect()): |
1095 |
error = SymbolSvgItem.createItem('Error', dataPath) |
|
1095 |
error = SymbolSvgItem.createItem('Error', None, dataPath)
|
|
1096 | 1096 |
error.setPosition(connector.center()) |
1097 | 1097 |
error.parent = self |
1098 | 1098 |
error.msg = _translate('mismatched position', 'mismatched position') |
... | ... | |
1114 | 1114 |
indices[1] = 1 if QPointF(matches[0].center()[0], matches[0].center()[ |
1115 | 1115 |
1]) == connector.connectedItem.line().p1() else 2 |
1116 | 1116 |
else: |
1117 |
error = SymbolSvgItem.createItem('Error', dataPath) |
|
1117 |
error = SymbolSvgItem.createItem('Error', None, dataPath)
|
|
1118 | 1118 |
error.setPosition(connector.center()) |
1119 | 1119 |
error.parent = self |
1120 | 1120 |
error.msg = _translate('disconnected from opposite side', 'disconnected from opposite side') |
... | ... | |
1124 | 1124 |
errors.append(error) |
1125 | 1125 |
|
1126 | 1126 |
if indices[0] == indices[1]: |
1127 |
error = SymbolSvgItem.createItem('Error', dataPath) |
|
1127 |
error = SymbolSvgItem.createItem('Error', None, dataPath)
|
|
1128 | 1128 |
error.setPosition(connector.center()) |
1129 | 1129 |
error.parent = self |
1130 | 1130 |
error.msg = _translate('flow direction error', 'flow direction error') |
... | ... | |
1134 | 1134 |
errors.append(error) |
1135 | 1135 |
|
1136 | 1136 |
if self.lineType != connector.connectedItem.lineType: |
1137 |
error = SymbolSvgItem.createItem('Error', dataPath) |
|
1137 |
error = SymbolSvgItem.createItem('Error', None, dataPath)
|
|
1138 | 1138 |
error.setPosition(connector.center()) |
1139 | 1139 |
error.parent = self |
1140 | 1140 |
error.msg = _translate('line type error', 'line type error') |
... | ... | |
1147 | 1147 |
|
1148 | 1148 |
# check duplicated connection |
1149 | 1149 |
if len(connectedUid) is not len(set(connectedUid)): |
1150 |
error = SymbolSvgItem.createItem('Error', dataPath) |
|
1150 |
error = SymbolSvgItem.createItem('Error', None, dataPath)
|
|
1151 | 1151 |
error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()]) |
1152 | 1152 |
error.parent = self |
1153 | 1153 |
error.msg = _translate('duplicated connection', 'duplicated connection') |
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py | ||
---|---|---|
514 | 514 |
for line_end in [line_from, line_to]: |
515 | 515 |
for connector in line_end.connectors: |
516 | 516 |
if connector.connectedItem is not None and connector.connectedItem.owner is not self: |
517 |
end_break = SymbolSvgItem.createItem(symbol.getType(), svgFilePath) |
|
517 |
end_break = SymbolSvgItem.createItem(symbol.getType(), None, svgFilePath)
|
|
518 | 518 |
pt = [connector.center()[0] - float(symbol.getOriginalPoint().split(',')[0]), connector.center()[1] - float(symbol.getOriginalPoint().split(',')[1])] |
519 | 519 |
origin = [0,0] |
520 | 520 |
if 2 == len(symbol.getOriginalPoint().split(',')): |
... | ... | |
527 | 527 |
end_break.area = 'Drawing' |
528 | 528 |
end_break.owner = line_end |
529 | 529 |
end_breaks.append(end_break) |
530 |
|
|
531 |
''' |
|
532 |
svgFileName = end_break_names[0].sName |
|
533 |
symbol = AppDocData.instance().getSymbolByQuery('name', svgFileName) |
|
534 |
svgFilePath = os.path.join(AppDocData.instance().getCurrentProject().getSvgFilePath(), symbol.getType(), svgFileName+'.svg') |
|
535 |
|
|
536 |
if type(line_from) is QEngineeringLineItem and line_from.connectors[0].connectedItem is not None and type(line_from.connectors[0].connectedItem) is QEngineeringLineItem: |
|
537 |
end_break = SymbolSvgItem.createItem(symbol.getType(), svgFilePath) |
|
538 |
pt = [line_from.connectors[0].center()[0] - float(symbol.getOriginalPoint().split(',')[0]), line_from.connectors[0].center()[1] - float(symbol.getOriginalPoint().split(',')[1])] |
|
539 |
origin = [0,0] |
|
540 |
if 2 == len(symbol.getOriginalPoint().split(',')): |
|
541 |
tokens = symbol.getOriginalPoint().split(',') |
|
542 |
origin = [pt[0] + float(tokens[0]), pt[1] + float(tokens[1])] |
|
543 |
end_break.buildItem(svgFileName, symbol.getType(), 5.7, pt, [end_break.boundingRect().width(), end_break.boundingRect().height()], origin, [], symbol.getBaseSymbol(), symbol.getAdditionalSymbol(), symbol.getHasInstrumentLabel()) |
|
544 |
for prop, value in end_break.properties.items(): |
|
545 |
if prop.Attribute == 'Connected Item': |
|
546 |
end_break.properties[prop] = line_to.connectors[0].connectedItem |
|
547 |
end_break.setToolTip('owner : ' + str(line_to)) |
|
548 |
end_break.area = 'Drawing' |
|
549 |
end_break.owner = line_from |
|
550 |
end_breaks.append(end_break) |
|
551 |
|
|
552 |
if type(line_to) is QEngineeringLineItem and line_to.connectors[1].connectedItem is not None and type(line_from.connectors[1].connectedItem) is QEngineeringLineItem: |
|
553 |
end_break = SymbolSvgItem.createItem(symbol.getType(), svgFilePath) |
|
554 |
pt = [line_to.connectors[1].center()[0] - float(symbol.getOriginalPoint().split(',')[0]), line_to.connectors[1].center()[1] - float(symbol.getOriginalPoint().split(',')[1])] |
|
555 |
origin = [0,0] |
|
556 |
if 2 == len(symbol.getOriginalPoint().split(',')): |
|
557 |
tokens = symbol.getOriginalPoint().split(',') |
|
558 |
origin = [pt[0] + float(tokens[0]), pt[1] + float(tokens[1])] |
|
559 |
end_break.buildItem(svgFileName, symbol.getType(), 5.7, pt, [end_break.boundingRect().width(), end_break.boundingRect().height()], origin, [], symbol.getBaseSymbol(), symbol.getAdditionalSymbol(), symbol.getHasInstrumentLabel()) |
|
560 |
for prop, value in end_break.properties.items(): |
|
561 |
if prop.Attribute == 'Connected Item': |
|
562 |
end_break.properties[prop] = line_to.connectors[1].connectedItem |
|
563 |
end_break.setToolTip('owner : ' + str(line_to)) |
|
564 |
end_break.area = 'Drawing' |
|
565 |
end_break.owner = line_to |
|
566 |
end_breaks.append(end_break) |
|
567 |
''' |
|
568 |
|
|
569 | 530 |
except Exception as ex: |
570 | 531 |
from App import App |
571 | 532 |
from AppDocData import MessageType |
DTI_PID/DTI_PID/Shapes/EngineeringNozzleItem.py | ||
---|---|---|
18 | 18 |
''' |
19 | 19 |
''' |
20 | 20 |
def __init__(self, path, uid=None, flip=0): |
21 |
SymbolSvgItem.__init__(self, path, uid, flip=flip) |
|
21 |
SymbolSvgItem.__init__(self, None, path, uid, flip=flip)
|
|
22 | 22 |
|
23 | 23 |
self._props = [['Name', None], ['Size', None]] |
24 | 24 |
self.setZValue(QEngineeringNozzleItem.ZVALUE) |
DTI_PID/DTI_PID/Shapes/EngineeringReducerItem.py | ||
---|---|---|
23 | 23 |
def __init__(self, path, uid=None, flip=0): |
24 | 24 |
from SymbolAttr import SymbolProp |
25 | 25 |
|
26 |
SymbolSvgItem.__init__(self, path, uid, flip) |
|
26 |
SymbolSvgItem.__init__(self, None, path, uid, flip)
|
|
27 | 27 |
|
28 | 28 |
self.setZValue(QEngineeringReducerItem.ZVALUE) |
29 | 29 |
|
DTI_PID/DTI_PID/Shapes/EngineeringSpecBreakItem.py | ||
---|---|---|
23 | 23 |
''' |
24 | 24 |
def __init__(self, path, uid=None, flip=0): |
25 | 25 |
from SymbolAttr import SymbolProp |
26 |
SymbolSvgItem.__init__(self, path, uid, flip=flip) |
|
26 |
SymbolSvgItem.__init__(self, None, path, uid, flip=flip)
|
|
27 | 27 |
|
28 | 28 |
''' |
29 | 29 |
attr = SymbolAttr() |
... | ... | |
103 | 103 |
dataPath = app_doc_data.getErrorItemSvgPath() |
104 | 104 |
# UpStream and DownStream must be connected |
105 | 105 |
if not (self.up_stream and self.down_stream): |
106 |
error = SymbolSvgItem.createItem('Error', dataPath) |
|
106 |
error = SymbolSvgItem.createItem('Error', None, dataPath)
|
|
107 | 107 |
error.parent = self |
108 | 108 |
error.msg = self.tr('UpStream or DownStream is disconnected') |
109 | 109 |
error.setToolTip(error.msg) |
... | ... | |
114 | 114 |
up_stream_item = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(self.up_stream)] |
115 | 115 |
down_stream_item = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(self.down_stream)] |
116 | 116 |
if not (up_stream_item and down_stream_item): |
117 |
error = SymbolSvgItem.createItem('Error', dataPath) |
|
117 |
error = SymbolSvgItem.createItem('Error', None, dataPath)
|
|
118 | 118 |
error.parent = self |
119 | 119 |
error.msg = self.tr('UpStream or DownStream is None') |
120 | 120 |
error.setToolTip(error.msg) |
... | ... | |
137 | 137 |
connected[0] = True |
138 | 138 |
|
139 | 139 |
if not (connected[0] and connected[1]): |
140 |
error = SymbolSvgItem.createItem('Error', dataPath) |
|
140 |
error = SymbolSvgItem.createItem('Error', None, dataPath)
|
|
141 | 141 |
error.parent = self |
142 | 142 |
error.msg = self.tr('UpStream and DownStream is misconnected') |
143 | 143 |
error.setToolTip(error.msg) |
DTI_PID/DTI_PID/Shapes/QEngineeringOPCItem.py | ||
---|---|---|
20 | 20 |
def __init__(self, path, uid=None, flip=0): |
21 | 21 |
from SymbolAttr import SymbolProp |
22 | 22 |
|
23 |
SymbolSvgItem.__init__(self, path, uid, flip=flip) |
|
23 |
SymbolSvgItem.__init__(self, None, path, uid, flip=flip)
|
|
24 | 24 |
|
25 | 25 |
self._properties = \ |
26 | 26 |
{\ |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
33 | 33 |
18.05.30 Jeongwoo Add self variables (parentSymbol, childSymbol) |
34 | 34 |
''' |
35 | 35 |
|
36 |
def __init__(self, path, uid=None, flip=0): |
|
36 |
def __init__(self, name, path, uid=None, flip=0):
|
|
37 | 37 |
import uuid |
38 | 38 |
from SymbolAttr import SymbolProp |
39 | 39 |
|
... | ... | |
45 | 45 |
|
46 | 46 |
self.dbUid = None # symbol UID |
47 | 47 |
self.uid = uuid.uuid4() if uid is None else uuid.UUID(uid) |
48 |
self.name = ''
|
|
48 |
self.name = name
|
|
49 | 49 |
self.type = '' |
50 | 50 |
self.angle = 0 |
51 | 51 |
self.origin = None |
... | ... | |
77 | 77 |
try: |
78 | 78 |
app_doc_data = AppDocData.instance() |
79 | 79 |
svg = None |
80 |
if path and os.path.isfile(path): |
|
80 |
if self.name: |
|
81 |
_, svg = app_doc_data.read_symbol_shape(self.name) |
|
82 |
|
|
83 |
if not svg and path and os.path.isfile(path): |
|
81 | 84 |
f = QFile(path) |
82 | 85 |
f.open(QIODevice.ReadOnly) |
83 | 86 |
svg = f.readAll() |
... | ... | |
90 | 93 |
|
91 | 94 |
self._color = self.get_attribute('fill') |
92 | 95 |
except Exception as ex: |
93 |
print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
94 |
sys.exc_info()[-1].tb_lineno)) |
|
96 |
from App import App |
|
97 |
|
|
98 |
message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
99 |
sys.exc_info()[-1].tb_lineno) |
|
100 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
95 | 101 |
|
96 | 102 |
self.setZValue(SymbolSvgItem.ZVALUE) |
97 | 103 |
|
... | ... | |
296 | 302 |
indices[1] = 1 if (dx[0] * dx[0] + dy[0] * dy[0]) < (dx[1] * dx[1]) + (dy[1] * dy[1]) else 2 |
297 | 303 |
|
298 | 304 |
if indices[0] == indices[1]: |
299 |
error = SymbolSvgItem.createItem('Error', dataPath) |
|
305 |
error = SymbolSvgItem.createItem('Error', None, dataPath)
|
|
300 | 306 |
error.parent = self |
301 | 307 |
error.msg = self.tr('flow direction error') |
302 | 308 |
error.setToolTip(error.msg) |
... | ... | |
314 | 320 |
break |
315 | 321 |
|
316 | 322 |
if disconnect: |
317 |
error = SymbolSvgItem.createItem('Error', dataPath) |
|
323 |
error = SymbolSvgItem.createItem('Error', None, dataPath)
|
|
318 | 324 |
error.parent = self |
319 | 325 |
error.msg = 'disconnected' |
320 | 326 |
error.setToolTip(error.msg) |
... | ... | |
324 | 330 |
|
325 | 331 |
# check if symbol size if 0 |
326 | 332 |
if self.size[0] == 0 or self.size[1] == 0: |
327 |
error = SymbolSvgItem.createItem('Error', dataPath) |
|
333 |
error = SymbolSvgItem.createItem('Error', None, dataPath)
|
|
328 | 334 |
error.parent = self |
329 | 335 |
error.msg = self.tr('size error') |
330 | 336 |
error.setToolTip(error.msg) |
... | ... | |
335 | 341 |
# check if association item's owner exists |
336 | 342 |
for assoc in self.associations(): |
337 | 343 |
if issubclass(type(assoc), QEngineeringTextItem) and not assoc.owner: |
338 |
error = SymbolSvgItem.createItem('Error', dataPath) |
|
344 |
error = SymbolSvgItem.createItem('Error', None, dataPath)
|
|
339 | 345 |
error.parent = self |
340 | 346 |
error.msg = self.tr('association error') |
341 | 347 |
error.setToolTip(error.msg) |
... | ... | |
359 | 365 |
matches = [conn for conn in connector.connectedItem.connectors if conn.connectedItem is self] |
360 | 366 |
# check if two items are connected each other |
361 | 367 |
if not matches: |
362 |
error = SymbolSvgItem.createItem('Error', dataPath) |
|
368 |
error = SymbolSvgItem.createItem('Error', None, dataPath)
|
|
363 | 369 |
error.setPosition(connector.center()) |
364 | 370 |
error.parent = self |
365 | 371 |
error.msg = self.tr('disconnected from opposite side') |
... | ... | |
370 | 376 |
|
371 | 377 |
# check duplicated connection |
372 | 378 |
if len(connectedUid) is not len(set(connectedUid)): |
373 |
error = SymbolSvgItem.createItem('Error', dataPath) |
|
379 |
error = SymbolSvgItem.createItem('Error', None, dataPath)
|
|
374 | 380 |
error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()]) |
375 | 381 |
error.parent = self |
376 | 382 |
error.msg = self.tr('duplicated connection') |
... | ... | |
1385 | 1391 |
project = app_doc_data.getCurrentProject() |
1386 | 1392 |
svgFilePath = os.path.join(project.getSvgFilePath(), _type, name + '.svg') |
1387 | 1393 |
if os.path.isfile(svgFilePath): |
1388 |
item = SymbolSvgItem.createItem(_type, svgFilePath, uid, owner=owner, flip=flipLabel) |
|
1394 |
item = SymbolSvgItem.createItem(_type, name, svgFilePath, uid, owner=owner, flip=flipLabel)
|
|
1389 | 1395 |
item.setVisible(False) |
1390 | 1396 |
|
1391 | 1397 |
# if additional symbol was changed, change symbol info |
... | ... | |
1534 | 1540 |
project = appDocData.getCurrentProject() |
1535 | 1541 |
svgFilePath = os.path.join(project.getSvgFilePath(), _type, name + '.svg') |
1536 | 1542 |
if os.path.isfile(svgFilePath): |
1537 |
item = SymbolSvgItem.createItem(_type, svgFilePath, uid, owner=owner, flip=flipLabel) |
|
1543 |
item = SymbolSvgItem.createItem(_type, name, svgFilePath, uid, owner=owner, flip=flipLabel)
|
|
1538 | 1544 |
item.setVisible(False) |
1539 | 1545 |
|
1540 | 1546 |
# if additional symbol was changed, change symbol info |
... | ... | |
1649 | 1655 |
''' |
1650 | 1656 |
|
1651 | 1657 |
@staticmethod |
1652 |
def createItem(type, path, uid=None, owner=None, flip=0): |
|
1658 |
def createItem(type, name, path, uid=None, owner=None, flip=0):
|
|
1653 | 1659 |
from QEngineeringOPCItem import QEngineeringOPCItem |
1654 | 1660 |
from EngineeringEquipmentItem import QEngineeringEquipmentItem |
1655 | 1661 |
from EngineeringInstrumentItem import QEngineeringInstrumentItem |
... | ... | |
1662 | 1668 |
from AppDocData import AppDocData |
1663 | 1669 |
import uuid |
1664 | 1670 |
|
1665 |
docData = AppDocData.instance()
|
|
1671 |
app_doc_data = AppDocData.instance()
|
|
1666 | 1672 |
|
1667 | 1673 |
item = None |
1668 |
cateogry = docData.getSymbolCategoryByType(type) |
|
1669 |
if type == "Piping OPC's": |
|
1670 |
item = QEngineeringOPCItem(path, uid, flip=flip) |
|
1671 |
elif cateogry == 'Equipment': |
|
1672 |
item = QEngineeringEquipmentItem(path, uid, flip=flip) |
|
1673 |
elif cateogry == 'Instrumentation': |
|
1674 |
item = QEngineeringInstrumentItem(path, uid, flip=flip) |
|
1675 |
# elif type == 'Nozzles': |
|
1676 |
# item = QEngineeringNozzleItem(path, uid, flip=flip) |
|
1677 |
elif type == 'Segment Breaks': |
|
1678 |
item = QEngineeringSpecBreakItem(path, uid, flip=flip) |
|
1679 |
elif type == 'Reducers': |
|
1680 |
item = QEngineeringReducerItem(path, uid, flip=flip) |
|
1681 |
elif type == 'Error': |
|
1682 |
item = QEngineeringErrorItem(path, uid, flip=flip) |
|
1683 |
elif type == 'End Break': |
|
1684 |
item = QEngineeringEndBreakItem(path, uid, flip=flip) |
|
1685 |
# elif type == 'Flow Mark': |
|
1686 |
# item = QEngineeringFlowMarkItem(path, uid, flip=flip) |
|
1687 |
else: |
|
1688 |
item = SymbolSvgItem(path, uid, flip=flip) |
|
1674 |
try: |
|
1675 |
cateogry = app_doc_data.getSymbolCategoryByType(type) |
|
1676 |
if type == "Piping OPC's": |
|
1677 |
item = QEngineeringOPCItem(path, uid, flip=flip) |
|
1678 |
elif cateogry == 'Equipment': |
|
1679 |
item = QEngineeringEquipmentItem(path, uid, flip=flip) |
|
1680 |
elif cateogry == 'Instrumentation': |
|
1681 |
item = QEngineeringInstrumentItem(path, uid, flip=flip) |
|
1682 |
# elif type == 'Nozzles': |
|
1683 |
# item = QEngineeringNozzleItem(path, uid, flip=flip) |
|
1684 |
elif type == 'Segment Breaks': |
|
1685 |
item = QEngineeringSpecBreakItem(path, uid, flip=flip) |
|
1686 |
elif type == 'Reducers': |
|
1687 |
item = QEngineeringReducerItem(path, uid, flip=flip) |
|
1688 |
elif type == 'Error': |
|
1689 |
item = QEngineeringErrorItem(path, uid, flip=flip) |
|
1690 |
elif type == 'End Break': |
|
1691 |
item = QEngineeringEndBreakItem(path, uid, flip=flip) |
|
1692 |
# elif type == 'Flow Mark': |
|
1693 |
# item = QEngineeringFlowMarkItem(path, uid, flip=flip) |
|
1694 |
else: |
|
1695 |
item = SymbolSvgItem(name, path, uid, flip=flip) |
|
1696 |
|
|
1697 |
if owner is not None: |
|
1698 |
item.owner = uuid.UUID(owner) |
|
1689 | 1699 |
|
1690 |
if owner is not None: |
|
1691 |
item.owner = uuid.UUID(owner) |
|
1700 |
except Exception as ex: |
|
1701 |
from App import App |
|
1702 |
from AppDocData import MessageType |
|
1703 |
|
|
1704 |
message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1705 |
sys.exc_info()[-1].tb_lineno) |
|
1706 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
1692 | 1707 |
|
1693 | 1708 |
return item |
1694 | 1709 |
|
DTI_PID/DTI_PID/SymbolTreeWidget.py | ||
---|---|---|
202 | 202 |
_, svg = app_doc_data.read_symbol_shape(symbol.sName) |
203 | 203 |
if svg: |
204 | 204 |
pixmap = QPixmap(QSize(32, 32)) |
205 |
pixmap.loadFromData(svg) |
|
205 |
pixmap.loadFromData(svg if isinstance(svg, bytes) else svg.encode())
|
|
206 | 206 |
icon = QIcon(pixmap) |
207 | 207 |
symbolItem.setIcon(0, icon) |
208 | 208 |
symbolItem.svgFilePath = None # save svg file path |
내보내기 Unified diff