개정판 df4661c5
issue #503: apply vendor package to item
Change-Id: I75290df20793b0cab759dff140a62d7d5503be8f
DTI_PID/DTI_PID/ItemTreeWidget.py | ||
---|---|---|
203 | 203 |
""" explode all line nos """ |
204 | 204 |
|
205 | 205 |
try: |
206 |
for i in self.LineNoTreeItem.childCount():
|
|
206 |
for i in reversed(range(self.LineNoTreeItem.childCount())):
|
|
207 | 207 |
self.explode_line_no(self.LineNoTreeItem.child(i)) |
208 | 208 |
finally: |
209 | 209 |
pass |
DTI_PID/DTI_PID/LineNoTracer.py | ||
---|---|---|
35 | 35 |
self._lineNos = lineNos |
36 | 36 |
self._spec_breaks = specBreak |
37 | 37 |
self._lineIndicator = lineIndicator |
38 |
self._vendor = vendor |
|
39 | 38 |
|
40 | 39 |
""" |
41 | 40 |
for spec in self._specBreak: |
... | ... | |
336 | 335 |
matches = [spec_break for spec_break in self._spec_breaks if spec_break.is_connected(obj)] |
337 | 336 |
if matches or issubclass(type(obj), QEngineeringEquipmentItem): continue |
338 | 337 |
""" end loop if obj is to """ |
339 |
if obj is to: break
|
|
338 |
if str(obj.uid) is str(to): break
|
|
340 | 339 |
|
341 | 340 |
if type(obj) is QEngineeringLineItem: |
342 | 341 |
symbolMatches = [x for x in self._symbols if (x.owner is None) and (x not in visited) and obj.is_connected(x)] |
... | ... | |
410 | 409 |
lineNos = [] |
411 | 410 |
specBreak = [] |
412 | 411 |
lineIndicator = [] |
413 |
vendor = [] |
|
412 |
vendor_packages = [item for item in worker.graphicsView.scene.items() if type(item) is QEngineeringVendorItem] |
|
413 |
|
|
414 |
configs = AppDocData.instance().getConfigs('Supplied by Tag Rule', 'by Vendor') |
|
415 |
vendorTag = configs[0].value if configs else 'By Vendor' |
|
414 | 416 |
for item in worker.graphicsView.scene.items(): |
415 | 417 |
if type(item) is QEngineeringSpecBreakItem: |
416 | 418 |
specBreak.append(item) |
417 |
elif issubclass(type(item), SymbolSvgItem): |
|
418 |
symbols.append(item) |
|
419 |
elif issubclass(type(item), SymbolSvgItem) and not type(item) is QEngineeringUnknownItem: |
|
420 |
matches = [vendor_package for vendor_package in vendor_packages if vendor_package.includes(item)] |
|
421 |
if matches: |
|
422 |
item.set_property('Supplied By', vendorTag) |
|
423 |
else: |
|
424 |
item.set_property('Supplied By', '') |
|
425 |
symbols.append(item) |
|
419 | 426 |
elif type(item) is QEngineeringLineNoTextItem: |
420 | 427 |
lineNos.append(item) |
421 | 428 |
elif type(item) is QEngineeringLineItem: |
422 |
lines.append(item) |
|
429 |
matches = [vendor_package for vendor_package in vendor_packages if vendor_package.includes(item)] |
|
430 |
if not matches: lines.append(item) |
|
423 | 431 |
elif type(item) is QEngineeringUnknownItem and item.lineIndicator != 'False': |
424 | 432 |
lineIndicator.append(item) |
425 |
elif type(item) is QEngineeringVendorItem: |
|
426 |
vendor.append(item) |
|
427 | 433 |
|
428 | 434 |
# trace line no |
429 |
tracer = LineNoTracer(symbols, lines, lineNos, specBreak, lineIndicator, vendor) |
|
435 |
tracer = LineNoTracer(symbols, lines, lineNos, specBreak, lineIndicator, vendor_packages)
|
|
430 | 436 |
tracer.execute(worker.displayMessage, worker.updateProgress) |
431 | 437 |
# up to here |
432 | 438 |
|
... | ... | |
446 | 452 |
and type(symbol) is not QEngineeringOPCItem and type(symbol) is not QEngineeringSpecBreakItem] |
447 | 453 |
for valve in valves: |
448 | 454 |
valve.connectAttribute(labels, clear=False) |
449 |
|
|
450 |
# vendor package |
|
451 |
configs = AppDocData.instance().getConfigs('Supplied by Tag Rule', 'by Vendor') |
|
452 |
vendorTag = configs[0].value if configs else 'By Vendor' |
|
453 |
for vendorItem in vendor: |
|
454 |
for symbol in symbols: |
|
455 |
if vendorItem.includes(symbol): |
|
456 |
matches = [prop for prop,value in symbol.properties.items() if prop.Attribute == 'Supplied By'] |
|
457 |
if matches: symbol.properties[matches[0]] = vendorTag |
|
458 |
else: |
|
459 |
matches = [prop for prop,value in symbol.properties.items() if prop.Attribute == 'Supplied By'] |
|
460 |
if matches: symbol.properties[matches[0]] = '' |
|
461 |
# up to here |
|
462 | 455 |
except Exception as ex: |
463 | 456 |
from App import App |
464 | 457 |
message = '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/MainWindow.py | ||
---|---|---|
192 | 192 |
self.actionRecognition.triggered.connect(self.recognize) |
193 | 193 |
self.pushButtonBatchRecognition.clicked.connect(self.recognizeBatch) |
194 | 194 |
self.pushButtonRefreshDrawings.clicked.connect(self.load_drawing_list) |
195 |
self.actionLineRecognition.triggered.connect(self.recognizeLine)
|
|
195 |
self.actionLineRecognition.triggered.connect(self.connect_attributes)
|
|
196 | 196 |
self.actionArea.triggered.connect(self.areaConfiguration) |
197 | 197 |
self.actionConfiguration.triggered.connect(self.configuration) |
198 | 198 |
self.actionOCR.triggered.connect(self.onAreaOcr) |
... | ... | |
1617 | 1617 |
Jeongwoo 2018.05.25 Move codes about LineDetector |
1618 | 1618 |
humkyung 2018.06.17 show progress dialog |
1619 | 1619 |
''' |
1620 |
def recognizeLine(self, MainWindow):
|
|
1620 |
def connect_attributes(self, MainWindow):
|
|
1621 | 1621 |
from LineNoTracer import LineNoTracer |
1622 | 1622 |
from ConnectAttrDialog import QConnectAttrDialog |
1623 | 1623 |
|
... | ... | |
2374 | 2374 |
for line in root.find('LINEINFOS').iter('LINE'): |
2375 | 2375 |
item = QEngineeringLineItem.fromXml(line) |
2376 | 2376 |
item.transfer.onRemoved.connect(self.itemRemoved) |
2377 |
if item: self.addLineItemToScene(item) |
|
2377 |
if item: |
|
2378 |
self.graphicsView.scene.addItem(item) |
|
2378 | 2379 |
|
2379 | 2380 |
self.progress.setValue(self.progress.value() + 1) |
2380 | 2381 |
|
... | ... | |
2417 | 2418 |
uid = uidElement.text |
2418 | 2419 |
run_item = self.graphicsView.findItemByUid(uid) |
2419 | 2420 |
if run_item is not None: |
2420 |
run_item._owner = item
|
|
2421 |
run_item._owner = line_no
|
|
2421 | 2422 |
line_run.items.append(run_item) |
2422 | 2423 |
line_run.owner = line_no |
2423 | 2424 |
line_no.runs.append(line_run) |
... | ... | |
2462 | 2463 |
|
2463 | 2464 |
# up to here |
2464 | 2465 |
|
2465 |
# set symbol's connectItem |
|
2466 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
|
2467 |
connectors = [item for item in self.graphicsView.scene.items() if type(item) == QEngineeringConnectorItem and item.connectedItem is not None] |
|
2468 |
for connector in connectors: |
|
2469 |
# 처음에는 UID가 connectedItem에 String으로 들어가있기 때문에 |
|
2470 |
connector.connectedItem = self.graphicsView.findItemByUid(connector.connectedItem) |
|
2471 |
|
|
2472 |
symbols = [item for item in self.graphicsView.scene.items() if issubclass(type(item), SymbolSvgItem) and len(item.attrs) > 0 and type(item) is not QEngineeringSpecBreakItem] |
|
2473 |
for symbol in symbols: |
|
2474 |
# 처음에는 attrs의 uid가 connectedItem에 String으로 들어가있기 때문에 |
|
2475 |
for key in symbol.attrs.keys(): |
|
2476 |
if type(symbol.attrs[key]) is not UserInputAttribute and type(symbol.attrs[key]) is not tuple: |
|
2477 |
symbol.attrs[key] = self.graphicsView.findItemByUid(symbol.attrs[key]) |
|
2478 |
|
|
2479 | 2466 |
""" update scene """ |
2480 | 2467 |
self.graphicsView.scene.update(self.graphicsView.sceneRect()) |
2481 | 2468 |
for item in self.graphicsView.scene.items(): |
DTI_PID/DTI_PID/Shapes/EngineeringConnectorItem.py | ||
---|---|---|
52 | 52 |
self._symbol_idx = '0' |
53 | 53 |
self._spec_break = None |
54 | 54 |
self.highlight = False |
55 |
self.connectedItem = None |
|
55 |
self._connectedItem = None
|
|
56 | 56 |
self._connected_at = QEngineeringAbstractItem.CONNECTED_AT_PT # default value is connected at pt |
57 | 57 |
self.sceneConnectPoint = None |
58 | 58 |
self.connectPoint = None |
... | ... | |
63 | 63 |
|
64 | 64 |
self._drawing_mode = QEngineeringConnectorItem.AXIS_MODE |
65 | 65 |
|
66 |
@property |
|
67 |
def connectedItem(self): |
|
68 |
""" getter of connectedItem """ |
|
69 |
import uuid |
|
70 |
|
|
71 |
if type(self._connectedItem) is uuid.UUID: |
|
72 |
matches = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(self._connectedItem)] |
|
73 |
if matches: self._connectedItem = matches[0] |
|
74 |
|
|
75 |
return self._connectedItem |
|
76 |
|
|
77 |
@connectedItem.setter |
|
78 |
def connectedItem(self, value): |
|
79 |
""" setter of connectedItem """ |
|
80 |
self._connectedItem = value |
|
81 |
|
|
66 | 82 |
''' |
67 | 83 |
@brief getter of direction |
68 | 84 |
@author humkyung |
... | ... | |
409 | 425 |
""" parse given node """ |
410 | 426 |
import uuid |
411 | 427 |
|
412 |
if 'UID' in node.attrib: self.uid = uuid.UUID(node.attrib['UID'], version=4) |
|
428 |
try: |
|
429 |
if 'UID' in node.attrib: self.uid = uuid.UUID(node.attrib['UID'], version=4) |
|
413 | 430 |
|
414 |
if 'CONNECTED_AT' in node.attrib: |
|
415 |
self._connected_at = QEngineeringAbstractItem.CONNECTED_AT_PT if node.attrib['CONNECTED_AT'] == '0' else QEngineeringAbstractItem.CONNECTED_AT_BODY |
|
416 |
else: |
|
417 |
self._connected_at = QEngineeringAbstractItem.CONNECTED_AT_PT |
|
431 |
if 'CONNECTED_AT' in node.attrib:
|
|
432 |
self._connected_at = QEngineeringAbstractItem.CONNECTED_AT_PT if node.attrib['CONNECTED_AT'] == '0' else QEngineeringAbstractItem.CONNECTED_AT_BODY
|
|
433 |
else:
|
|
434 |
self._connected_at = QEngineeringAbstractItem.CONNECTED_AT_PT
|
|
418 | 435 |
|
419 |
connectedItemStr = node.find('CONNECTEDITEM').text |
|
420 |
connectPointStr = node.find('CONNECTPOINT').text.split(',') |
|
421 |
sceneConnectPointStr = node.find('SCENECONNECTPOINT').text.split(',') |
|
436 |
connectedItemStr = node.find('CONNECTEDITEM').text
|
|
437 |
connectPointStr = node.find('CONNECTPOINT').text.split(',')
|
|
438 |
sceneConnectPointStr = node.find('SCENECONNECTPOINT').text.split(',')
|
|
422 | 439 |
|
423 |
self.connectedItem = connectedItemStr if connectedItemStr != 'None' else None
|
|
424 |
self.connectPoint = (float(connectPointStr[0]), float(connectPointStr[1])) |
|
425 |
self.sceneConnectPoint = (float(sceneConnectPointStr[0]), float(sceneConnectPointStr[1])) |
|
440 |
self._connectedItem = uuid.UUID(connectedItemStr, version=4) if connectedItemStr != 'None' else None
|
|
441 |
self.connectPoint = (float(connectPointStr[0]), float(connectPointStr[1]))
|
|
442 |
self.sceneConnectPoint = (float(sceneConnectPointStr[0]), float(sceneConnectPointStr[1]))
|
|
426 | 443 |
|
427 |
self.setBrush(Qt.yellow) if self.connectedItem else self.setBrush(Qt.blue) |
|
444 |
self.setBrush(Qt.yellow) if self.connectedItem else self.setBrush(Qt.blue) |
|
445 |
except Exception as ex: |
|
446 |
from App import App |
|
447 |
from AppDocData import MessageType |
|
448 |
|
|
449 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
450 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
428 | 451 |
|
429 | 452 |
@staticmethod |
430 | 453 |
def fromXml(node): |
... | ... | |
436 | 459 |
|
437 | 460 |
def toXml(self): |
438 | 461 |
""" generate xml code for connector """ |
462 |
import uuid |
|
439 | 463 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree |
440 | 464 |
|
441 | 465 |
try: |
... | ... | |
443 | 467 |
node.attrib['UID'] = str(self.uid) |
444 | 468 |
node.attrib['CONNECTED_AT'] = str(self._connected_at) |
445 | 469 |
connectedItemNode = Element('CONNECTEDITEM') |
446 |
connectedItemNode.text = str(self.connectedItem.uid) if self.connectedItem else 'None' |
|
470 |
connectedItemNode.text = str(self.connectedItem.uid) if self.connectedItem and not type(self.connectedItem) is uuid.UUID else 'None'
|
|
447 | 471 |
connectPointNode = Element('CONNECTPOINT') |
448 | 472 |
connectPointNode.text = str(self.connectPoint[0]) + ',' + str(self.connectPoint[1]) |
449 | 473 |
sceneConnectPointNode = Element('SCENECONNECTPOINT') |
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py | ||
---|---|---|
256 | 256 |
|
257 | 257 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
258 | 258 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
259 |
return None |
|
259 | 260 |
|
260 | 261 |
return item |
261 | 262 |
|
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
18 | 18 |
import SelectAttributeCommand |
19 | 19 |
|
20 | 20 |
class SymbolSvgItem(QGraphicsSvgItem, QEngineeringAbstractItem): |
21 |
""" This is symbolsvgitem class """ |
|
22 |
|
|
21 | 23 |
clicked = pyqtSignal(QGraphicsSvgItem) |
22 | 24 |
ZVALUE = 50 |
23 | 25 |
HOVER_COLOR = 'url(#hover)' |
... | ... | |
108 | 110 |
@property |
109 | 111 |
def properties(self): |
110 | 112 |
""" getter of properties """ |
113 |
import uuid |
|
114 |
|
|
115 |
for prop,value in self._properties.items(): |
|
116 |
if prop.is_selectable and type(value) is uuid.UUID: |
|
117 |
matches = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(value)] |
|
118 |
if matches: self._properties[prop] = matches[0] |
|
119 |
|
|
111 | 120 |
return self._properties |
112 | 121 |
|
113 | 122 |
@properties.setter |
... | ... | |
115 | 124 |
""" setter of properties """ |
116 | 125 |
self._properties = value |
117 | 126 |
|
127 |
def set_property(self, property, value): |
|
128 |
""" set property with given value """ |
|
129 |
matches = [prop for prop,_ in self._properties.items() if prop.Attribute == property] |
|
130 |
if matches: self._properties[matches[0]] = value |
|
131 |
|
|
118 | 132 |
def validate(self): |
119 | 133 |
''' |
120 | 134 |
@brief validation check : flow |
DTI_PID/DTI_PID/SymbolAttr.py | ||
---|---|---|
9 | 9 |
def __init__(self, UID, Attribute, AttributType, DisplayAttribute=None, Length=None, Expression=None): |
10 | 10 |
import uuid |
11 | 11 |
|
12 |
self.UID = uuid.uuid4() if UID is None else UID
|
|
12 |
self.UID = uuid.uuid4() if UID is None else uuid.UUID(UID, version=4)
|
|
13 | 13 |
self.Attribute = Attribute |
14 | 14 |
self.AttributeType = AttributType |
15 | 15 |
self.DisplayAttribute = DisplayAttribute if DisplayAttribute else Attribute |
... | ... | |
41 | 41 |
""" parse xml node for property """ |
42 | 42 |
import uuid |
43 | 43 |
|
44 |
self.UID = uuid.UUID(node.attrib['UID']) |
|
44 |
self.UID = uuid.UUID(node.attrib['UID'], version=4)
|
|
45 | 45 |
self.Attribute = node.attrib['Attribute'] |
46 | 46 |
self.AttributeType = node.attrib['AttributeType'] |
47 | 47 |
self.DisplayAttribute = node.attrib['DisplayAttribute'] |
... | ... | |
81 | 81 |
import uuid |
82 | 82 |
|
83 | 83 |
attr = SymbolAttr() |
84 |
attr.UID = uuid.UUID(node.attrib['UID']) |
|
84 |
attr.UID = uuid.UUID(node.attrib['UID'], version=4)
|
|
85 | 85 |
attr.Attribute = node.attrib['Attribute'] |
86 | 86 |
attr.DisplayAttribute = node.attrib['DisplayAttribute'] |
87 | 87 |
attr.AttributeType = node.attrib['AttributeType'] |
DTI_PID/DTI_PID/XmlGenerator.py | ||
---|---|---|
420 | 420 |
|
421 | 421 |
if node: |
422 | 422 |
resultDic[key][0] += 1 |
423 |
if type(item) in node_dictionary: node_dictionary[type(item)].append(node) |
|
423 |
_type = type(item) |
|
424 |
if issubclass(type(item), SymbolSvgItem): _type = SymbolSvgItem |
|
425 |
if _type in node_dictionary: node_dictionary[_type].append(node) |
|
424 | 426 |
else: |
425 | 427 |
resultDic[key][1].append(str(item.uid)) |
426 | 428 |
|
내보내기 Unified diff