개정판 b081cb3e
issue #637: table on going
DTI_PID/DTI_PID/ItemPropertyTableWidget.py | ||
---|---|---|
58 | 58 |
''' |
59 | 59 |
def showItemProperty(self, item): |
60 | 60 |
try: |
61 |
from PyQt5 import QtGui |
|
61 | 62 |
if type(item) is QEngineeringLineItem: |
62 | 63 |
self.initTitleCell(item) |
63 | 64 |
self.setItem(0, 1, QTableWidgetItem(str(item.uid))) |
... | ... | |
65 | 66 |
self.setItem(2, 1, QTableWidgetItem('({},{})'.format(pt[0], pt[1]))) |
66 | 67 |
pt = item.endPoint() |
67 | 68 |
self.setItem(3, 1, QTableWidgetItem('({},{})'.format(pt[0], pt[1]))) |
68 |
self.setItem(4, 1, QTableWidgetItem('{}'.format('None' if item.connectors[0].connectedItem is None else item.connectors[0].connectedItem.uid))) |
|
69 |
self.setItem(5, 1, QTableWidgetItem('{}'.format('None' if item.connectors[1].connectedItem is None else item.connectors[1].connectedItem.uid))) |
|
69 |
connItem = QTableWidgetItem('{}'.format('None' if item.connectors[0].connectedItem is None else item.connectors[0].connectedItem.uid)) |
|
70 |
icon = QtGui.QIcon() |
|
71 |
icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
72 |
connItem.setIcon(icon) |
|
73 |
self.setItem(4, 1, connItem) |
|
74 |
connItem = QTableWidgetItem('{}'.format('None' if item.connectors[1].connectedItem is None else item.connectors[1].connectedItem.uid)) |
|
75 |
icon = QtGui.QIcon() |
|
76 |
icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
77 |
connItem.setIcon(icon) |
|
78 |
self.setItem(5, 1, connItem) |
|
70 | 79 |
elif issubclass(type(item), SymbolSvgItem): |
71 | 80 |
self.onSymbolClicked(item) |
72 | 81 |
elif type(item) is QEngineeringLineNoTextItem: |
... | ... | |
264 | 273 |
humkyung 2018.07.05 display connectivity |
265 | 274 |
''' |
266 | 275 |
def initContentsCell(self): |
276 |
from PyQt5 import QtGui |
|
267 | 277 |
self.attrValueList = [] |
268 | 278 |
self.intCell = [] |
269 | 279 |
self.stringCell = [] |
... | ... | |
310 | 320 |
keyItem.setText(key.DisplayAttribute) |
311 | 321 |
self.setItem(row, 0, keyItem) |
312 | 322 |
|
313 |
if type(self.symData) is QEngineeringSpecBreakItem and (key == 'Up Stream' or key == 'Down Stream'): |
|
323 |
if type(self.symData) is QEngineeringSpecBreakItem: |
|
324 |
''' |
|
314 | 325 |
comboBox = QComboBox() |
315 | 326 |
comboBox.addItem('') |
316 | 327 |
|
... | ... | |
327 | 338 |
comboBox.setCurrentIndex(tempIndex) |
328 | 339 |
|
329 | 340 |
self.setCellWidget(row, 1, comboBox) |
341 |
''' |
|
342 |
if key.Attribute == 'UpStream' or key.Attribute == 'DownStream': |
|
343 |
UpDownItem = QTableWidgetItem('{}'.format('None' if value is None else value.uid)) |
|
344 |
icon = QtGui.QIcon() |
|
345 |
icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
346 |
UpDownItem.setIcon(icon) |
|
347 |
self.setItem(row, 1, UpDownItem) |
|
348 |
|
|
349 |
elif key.Attribute == 'SetSpecs': |
|
350 |
setSpecsItem = QTableWidgetItem('Open ') |
|
351 |
icon = QtGui.QIcon() |
|
352 |
icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
353 |
setSpecsItem.setIcon(icon) |
|
354 |
self.setItem(row, 1, setSpecsItem) |
|
355 |
|
|
330 | 356 |
else: |
331 | 357 |
self.setItem(row, 1, valueItem) |
332 | 358 |
|
... | ... | |
645 | 671 |
cmd = SelectAttributeCommand.SelectAttributeCommand(items[0], attr, self.mainWindow.graphicsView) |
646 | 672 |
cmd.onSuccess.connect(self.onSuccessSelectAttribute) |
647 | 673 |
self.mainWindow.graphicsView.command = cmd |
674 |
elif type(items[0]) is QEngineeringLineItem: |
|
675 |
print('SB') |
|
648 | 676 |
#elif Qt.ItemIsEnabled is not self.item(row, column).flags(): |
649 | 677 |
# self.editItem(self.item(row, column)) |
650 | 678 |
|
DTI_PID/DTI_PID/Shapes/EngineeringSpecBreakItem.py | ||
---|---|---|
10 | 10 |
|
11 | 11 |
from AppDocData import * |
12 | 12 |
from SymbolSvgItem import SymbolSvgItem |
13 |
from SymbolAttr import SymbolAttr |
|
13 | 14 |
from UserInputAttribute import UserInputAttribute |
14 | 15 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
15 | 16 |
|
... | ... | |
26 | 27 |
def __init__(self, path, uid=None): |
27 | 28 |
SymbolSvgItem.__init__(self, path, uid) |
28 | 29 |
|
30 |
attr = SymbolAttr() |
|
31 |
attr.Attribute = 'UpStream' |
|
32 |
attr.AttributeType = 'Comp Item' |
|
33 |
self.attrs[attr] = None |
|
34 |
attr = SymbolAttr() |
|
35 |
attr.Attribute = 'DownStream' |
|
36 |
attr.AttributeType = 'Comp Item' |
|
37 |
self.attrs[attr] = None |
|
38 |
attr = SymbolAttr() |
|
39 |
attr.Attribute = 'SetSpecs' |
|
40 |
attr.AttributeType = 'Link Dialog' |
|
41 |
self.attrs[attr] = 'Double Click' |
|
42 |
|
|
29 | 43 |
|
30 | 44 |
''' |
31 | 45 |
@brief get attribute |
... | ... | |
34 | 48 |
@history kyouho 2018.07.18 Add only attr QEngineeringTextItem |
35 | 49 |
''' |
36 | 50 |
def getAttributes(self): |
37 |
_attrs = {} |
|
38 |
try: |
|
39 |
from AppDocData import AppDocData |
|
40 |
|
|
41 |
# 해당 Type의 attribute setting |
|
42 |
docData = AppDocData.instance() |
|
43 |
symbolAttrs = docData.getSymbolAttribute(self.type) |
|
44 |
|
|
45 |
for attr in symbolAttrs: |
|
46 |
matches = [prop for prop in self.attrs if prop.UID == attr.UID] |
|
47 |
if len(matches) == 1: |
|
48 |
_attrs[matches[0]] = self.attrs[matches[0]] |
|
49 |
else: |
|
50 |
_attrs[attr] = '' |
|
51 |
except Exception as ex: |
|
52 |
from App import App |
|
53 |
from AppDocData import MessageType |
|
54 |
|
|
55 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
56 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
57 |
|
|
58 |
return _attrs |
|
51 |
""" |
|
52 |
attributes MUST have UpStream, DownStream attribute |
|
53 |
""" |
|
54 |
return self.attrs |
|
59 | 55 |
|
60 | 56 |
''' |
61 | 57 |
@brief generate xml code for nozzle |
... | ... | |
64 | 60 |
''' |
65 | 61 |
def toXml(self): |
66 | 62 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree |
63 |
from EngineeringTextItem import QEngineeringTextItem |
|
64 |
from EngineeringSpecBreakItem import QEngineeringSpecBreakItem |
|
65 |
from SymbolAttr import SymbolAttr |
|
67 | 66 |
|
68 | 67 |
try: |
69 |
node = SymbolSvgItem.toXml(self) |
|
68 |
node = Element('SYMBOL') |
|
69 |
uidNode = Element('UID') |
|
70 |
uidNode.text = str(self.uid) |
|
71 |
node.append(uidNode) |
|
72 |
|
|
73 |
nameNode = Element('NAME') |
|
74 |
nameNode.text = self.name |
|
75 |
node.append(nameNode) |
|
76 |
|
|
77 |
typeNode = Element('TYPE') |
|
78 |
typeNode.text = self.type |
|
79 |
node.append(typeNode) |
|
80 |
|
|
81 |
# write owner's uid to xml |
|
82 |
if self.owner is not None: |
|
83 |
ownerNode = Element('OWNER') |
|
84 |
ownerNode.text = str(self.owner.uid) |
|
85 |
node.append(ownerNode) |
|
86 |
# up to here |
|
87 |
|
|
88 |
originNode = Element('ORIGINALPOINT') |
|
89 |
originNode.text = '{},{}'.format(self.origin[0], self.origin[1]) |
|
90 |
node.append(originNode) |
|
91 |
|
|
92 |
connectorsNode = Element('CONNECTORS') |
|
93 |
for connector in self.connectors: |
|
94 |
connectorsNode.append(connector.toXml()) |
|
95 |
''' |
|
96 |
connectorNode = Element('CONNECTOR') |
|
97 |
connectedItemNode = Element('CONNECTEDITEM') |
|
98 |
connectedItemNode.text = str(connector.connectedItem.uid) if connector.connectedItem is not None else 'None' |
|
99 |
connectPointNode = Element('CONNECTPOINT') |
|
100 |
connectPointNode.text = str(connector.connectPoint[0]) + ',' + str(connector.connectPoint[1]) |
|
101 |
sceneConnectPointNode = Element('SCENECONNECTPOINT') |
|
102 |
sceneConnectPointNode.text = str(connector.sceneConnectPoint[0]) + ',' + str(connector.sceneConnectPoint[1]) |
|
103 |
|
|
104 |
connectorNode.append(connectedItemNode) |
|
105 |
connectorNode.append(connectPointNode) |
|
106 |
connectorNode.append(sceneConnectPointNode) |
|
107 |
connectorsNode.append(connectorNode) |
|
108 |
''' |
|
109 |
node.append(connectorsNode) |
|
110 |
|
|
111 |
connectionNode = Element('CONNECTIONPOINT') |
|
112 |
connection_point = [] |
|
113 |
if self.connectors is not None: |
|
114 |
for connector in self.connectors: |
|
115 |
connection_point.append(repr(connector)) |
|
116 |
connectionNode.text = '/'.join(connection_point) |
|
117 |
node.append(connectionNode) |
|
118 |
|
|
119 |
rect = self.sceneBoundingRect() |
|
120 |
locNode = Element('LOCATION') |
|
121 |
locNode.text = '{},{}'.format(self.loc[0], self.loc[1]) |
|
122 |
node.append(locNode) |
|
123 |
|
|
124 |
sizeNode = Element('SIZE') |
|
125 |
sizeNode.text = '{},{}'.format(rect.width(), rect.height()) |
|
126 |
node.append(sizeNode) |
|
127 |
|
|
128 |
angleNode = Element('ANGLE') |
|
129 |
angleNode.text = str(self.angle) |
|
130 |
node.append(angleNode) |
|
131 |
|
|
132 |
parentSymbolNode = Element('PARENT') |
|
133 |
parentSymbolNode.text = str(self.parentSymbol) |
|
134 |
node.append(parentSymbolNode) |
|
135 |
|
|
136 |
childSymbolNode = Element('CHILD') |
|
137 |
childSymbolNode.text = str(self.childSymbol) |
|
138 |
node.append(childSymbolNode) |
|
139 |
|
|
140 |
hasInstrumentLabelNode = Element('HASINSTRUMENTLABEL') |
|
141 |
hasInstrumentLabelNode.text = str(self.hasInstrumentLabel) |
|
142 |
node.append(hasInstrumentLabelNode) |
|
143 |
|
|
144 |
areaNode = Element('AREA') |
|
145 |
areaNode.text = self.area |
|
146 |
node.append(areaNode) |
|
147 |
|
|
148 |
attributesNode = Element('SYMBOLATTRIBUTES') |
|
149 |
_attrs = self.getAttributes() |
|
150 |
for attr in _attrs: |
|
151 |
if type(attr) is SymbolAttr: |
|
152 |
_node = attr.toXml() |
|
153 |
_node.text = _attrs[attr] |
|
154 |
attributesNode.append(_node) |
|
155 |
elif type(attr) is tuple and type(self) is QEngineeringSpecBreakItem: |
|
156 |
attributeNode = Element(attr[0].upper().replace(' ','')) |
|
157 |
attributeNode.text = str(attr[1] if attr[1] is not None else '') |
|
158 |
attributesNode.append(attributeNode) |
|
159 |
|
|
160 |
node.append(attributesNode) |
|
161 |
|
|
162 |
currentPointModeIndexNode = Element('CURRENTPOINTMODEINDEX') |
|
163 |
currentPointModeIndexNode.text = str(self.currentPointModeIndex) |
|
164 |
node.append(currentPointModeIndexNode) |
|
70 | 165 |
except Exception as ex: |
71 | 166 |
from App import App |
72 | 167 |
from AppDocData import MessageType |
내보내기 Unified diff