개정판 6a5a526e
issue #563: inst test
Change-Id: I3c3b824cddbeba323c59e0c1ae902c2bd1f266ea
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
104 | 104 |
self._symbolType = {} |
105 | 105 |
self._lineNoPropertiesUID = {} |
106 | 106 |
self._attributeByType = {} |
107 |
self._connected_items_lists = []
|
|
107 |
self._connected_items_lists = None
|
|
108 | 108 |
|
109 | 109 |
# for load drawing data from database |
110 | 110 |
self._connecterss = {} |
... | ... | |
122 | 122 |
@author euisung |
123 | 123 |
@date 2018.11.28 |
124 | 124 |
''' |
125 |
from QEngineeringInstLineNoTextItem import QEngineeringInstLineNoTextItem |
|
126 |
|
|
125 | 127 |
self.equipments.clear() |
126 | 128 |
self.symbols.clear() |
127 | 129 |
self.lineNos.clear() |
... | ... | |
132 | 134 |
if trim: |
133 | 135 |
self.tracerLineNos.clear() |
134 | 136 |
self.lines.clear() |
137 |
self._connected_items_lists = QEngineeringInstLineNoTextItem() |
|
135 | 138 |
|
136 | 139 |
''' |
137 | 140 |
@brief clear |
... | ... | |
140 | 143 |
''' |
141 | 144 |
|
142 | 145 |
def clear(self): |
146 |
from QEngineeringInstLineNoTextItem import QEngineeringInstLineNoTextItem |
|
147 |
|
|
143 | 148 |
if self.activeDrawing and self.activeDrawing.UID: |
144 | 149 |
self.clear_occupying_drawing(self.activeDrawing.UID) |
145 | 150 |
|
... | ... | |
169 | 174 |
self._symbolType = {} |
170 | 175 |
self._lineNoPropertiesUID = {} |
171 | 176 |
self._attributeByType = {} |
172 |
self._connected_items_lists.clear()
|
|
177 |
self._connected_items_lists = QEngineeringInstLineNoTextItem()
|
|
173 | 178 |
|
174 | 179 |
self._connecterss = {} |
175 | 180 |
self._associationss = {} |
... | ... | |
2674 | 2679 |
rows = cursor.fetchall() |
2675 | 2680 |
if property.upper() in [name[0].upper() for name in rows]: |
2676 | 2681 |
""" |
2677 |
if not symbol_attribute_uid and not custom_table_uid and not custom and not inst_table_uid: |
|
2682 |
if not symbol_attribute_uid and not custom_table_uid and not custom and not inst_table_uid and not inst:
|
|
2678 | 2683 |
sql = 'select uid, code, description, Allowables from [{}] order by code DESC'.format(property) |
2679 |
elif symbol_attribute_uid and not custom_table_uid and not inst_table_uid: |
|
2684 |
elif symbol_attribute_uid and not custom_table_uid and not inst_table_uid and not inst:
|
|
2680 | 2685 |
sql = "select uid, code, description, Allowables from [{}] where SymbolAttribute_UID='{}' " \ |
2681 | 2686 |
"order by code DESC".format(property, symbol_attribute_uid) |
2682 | 2687 |
elif not symbol_attribute_uid and custom_table_uid and not inst_table_uid: |
DTI_PID/DTI_PID/CodeTables.py | ||
---|---|---|
169 | 169 |
return CodeTable.TABLES[_table_name] |
170 | 170 |
|
171 | 171 |
elif _table_name not in CodeTable.TABLES and inst: |
172 |
# custom code table using
|
|
172 |
# inst code table using
|
|
173 | 173 |
appDocData = AppDocData.instance() |
174 | 174 |
values = appDocData.getCodeTable(_table_name, False, inst=True) |
175 | 175 |
CodeTable.TABLES[_table_name] = CodeTable(custom_table_uid, values, inst=True) |
DTI_PID/DTI_PID/Commands/LoadCommand.py | ||
---|---|---|
28 | 28 |
from EngineeringEndBreakItem import QEngineeringEndBreakItem |
29 | 29 |
from EngineeringReducerItem import QEngineeringReducerItem |
30 | 30 |
from EngineeringFlowMarkItem import QEngineeringFlowMarkItem |
31 |
from EngineeringRunItem import QEngineeringRunItem |
|
31 | 32 |
from QEngineeringTrimLineNoTextItem import QEngineeringTrimLineNoTextItem |
33 |
from QEngineeringInstLineNoTextItem import QEngineeringInstLineNoTextItem |
|
32 | 34 |
|
33 | 35 |
|
34 | 36 |
class LoadCommand(AbstractCommand): |
... | ... | |
111 | 113 |
import concurrent.futures as futures |
112 | 114 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree, parse |
113 | 115 |
from App import App |
114 |
from EngineeringRunItem import QEngineeringRunItem |
|
115 |
from QEngineeringTrimLineNoTextItem import QEngineeringTrimLineNoTextItem |
|
116 | 116 |
from EngineeringGraphicsLineItem import QEngineeringGraphicsLineItem |
117 | 117 |
|
118 | 118 |
app_doc_data = AppDocData.instance() |
... | ... | |
316 | 316 |
value = value + 1 |
317 | 317 |
self.show_progress.emit(value) |
318 | 318 |
|
319 |
# for inst attribute |
|
320 |
for trimLineNo in root.iter('INST_LINE_NO'): |
|
321 |
line_no = QEngineeringInstLineNoTextItem() |
|
322 |
line_no.uid = uuid.UUID(trimLineNo.find('UID').text) |
|
323 |
|
|
324 |
if symbol and line: |
|
325 |
runs_node = trimLineNo.findall('RUN') |
|
326 |
if runs_node is None: continue |
|
327 |
|
|
328 |
for run in runs_node: |
|
329 |
line_run = QEngineeringRunItem() |
|
330 |
uids = [] |
|
331 |
for child in run: |
|
332 |
uidElement = child.find('UID') |
|
333 |
if uidElement is not None: |
|
334 |
uid = uidElement.text |
|
335 |
uids.append(uid) |
|
336 |
|
|
337 |
run_items = find_items(scene, uids) |
|
338 |
for run_item in run_items: |
|
339 |
line_run.items.append(run_item) |
|
340 |
|
|
341 |
line_run.owner = line_no |
|
342 |
line_no.runs.append(line_run) |
|
343 |
|
|
344 |
app_doc_data._connected_items_lists = line_no |
|
345 |
|
|
346 |
value = value + 1 |
|
347 |
self.show_progress.emit(value) |
|
348 |
|
|
319 | 349 |
QApplication.processEvents() |
320 | 350 |
|
321 | 351 |
if package: |
... | ... | |
361 | 391 |
def load_data_from_database(self, drawing, scene, symbol, text, line, unknown, package) -> int: |
362 | 392 |
"""load drawing data from database""" |
363 | 393 |
from App import App |
364 |
from EngineeringRunItem import QEngineeringRunItem |
|
365 |
from QEngineeringTrimLineNoTextItem import QEngineeringTrimLineNoTextItem |
|
366 | 394 |
|
367 | 395 |
def find_item(scene, uid): |
368 | 396 |
items = [item for item in scene.items() if hasattr(item, 'uid') and str(item.uid) == str(uid)] |
... | ... | |
536 | 564 |
value = value + 1 |
537 | 565 |
self.show_progress.emit(value) |
538 | 566 |
|
567 |
# for inst attribute |
|
568 |
for component in [component for component in components if |
|
569 |
component['Name'] == 'Inst Line NO' and component['SymbolType_UID'] == -1]: |
|
570 |
line_no = QEngineeringInstLineNoTextItem() |
|
571 |
line_no.uid = uuid.UUID(component['UID']) |
|
572 |
|
|
573 |
if symbol and line: |
|
574 |
runs = app_doc_data.get_pipe_runs(str(line_no.uid)) |
|
575 |
if not runs: continue |
|
576 |
|
|
577 |
for run in runs: |
|
578 |
line_run = QEngineeringRunItem() |
|
579 |
run_items = app_doc_data.get_pipe_run_items(run['UID']) |
|
580 |
uids = [] |
|
581 |
for record in run_items: |
|
582 |
uid = record['Components_UID'] |
|
583 |
uids.append(uid) |
|
584 |
|
|
585 |
run_items = find_items(scene, uids) |
|
586 |
for run_item in run_items: |
|
587 |
line_run.items.append(run_item) |
|
588 |
|
|
589 |
line_run.owner = line_no |
|
590 |
line_no.runs.append(line_run) |
|
591 |
|
|
592 |
app_doc_data._connected_items_lists = line_no |
|
593 |
|
|
594 |
value = value + 1 |
|
595 |
self.show_progress.emit(value) |
|
596 |
|
|
597 |
QApplication.processEvents() |
|
598 |
|
|
539 | 599 |
if package: |
540 | 600 |
for component in [component for component in components if |
541 | 601 |
component['Name'] == 'VendorPackage' and component['SymbolType_UID'] == -1]: |
DTI_PID/DTI_PID/Commands/SaveWorkCommand.py | ||
---|---|---|
31 | 31 |
from EngineeringTextItem import QEngineeringTextItem |
32 | 32 |
from QEngineeringTrimLineNoTextItem import QEngineeringTrimLineNoTextItem |
33 | 33 |
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem |
34 |
from EngineeringUnknownItem import QEngineeringUnknownItem |
|
34 | 35 |
|
35 | 36 |
try: |
36 | 37 |
appDocData = AppDocData.instance() |
... | ... | |
59 | 60 |
type(item) is not QEngineeringLineNoTextItem] |
60 | 61 |
db_items.extend([item for item in items if type(item) is QEngineeringLineNoTextItem]) |
61 | 62 |
db_items.extend([line for line in appDocData.tracerLineNos if type(line) is QEngineeringTrimLineNoTextItem]) |
63 |
db_items.append(appDocData._connected_items_lists) |
|
64 |
configs = appDocData.getConfigs('Data Save', 'Unknown Xml Only') |
|
65 |
if configs and int(configs[0].value) is -1: |
|
66 |
db_items.extend([item for item in items if type(item) is QEngineeringUnknownItem]) |
|
62 | 67 |
|
63 | 68 |
appDocData.saveToDatabase(db_items, self.show_progress) |
64 | 69 |
|
... | ... | |
86 | 91 |
app_doc_data = AppDocData.instance() |
87 | 92 |
path = os.path.join(app_doc_data.getCurrentProject().getTempPath(), app_doc_data.imgName + '.xml') |
88 | 93 |
xml, result = xg.write_to_xml(path, app_doc_data.activeDrawing.width, app_doc_data.activeDrawing.height, |
89 |
allItems, app_doc_data.tracerLineNos) |
|
94 |
allItems, app_doc_data.tracerLineNos + [app_doc_data._connected_items_lists])
|
|
90 | 95 |
if xml: |
91 | 96 |
from xml.etree import ElementTree |
92 | 97 |
ElementTree.ElementTree(xml).write(path) |
DTI_PID/DTI_PID/LineNoTracer.py | ||
---|---|---|
1545 | 1545 |
from EngineeringErrorItem import QEngineeringErrorItem |
1546 | 1546 |
from EngineeringTextItem import QEngineeringTextItem |
1547 | 1547 |
from SpecialItemTypesDialog import SpecialItemTracer |
1548 |
from QEngineeringInstLineNoTextItem import QEngineeringInstLineNoTextItem |
|
1549 |
from EngineeringRunItem import QEngineeringRunItem |
|
1548 | 1550 |
|
1549 | 1551 |
try: |
1550 | 1552 |
docdata = AppDocData.instance() |
... | ... | |
1585 | 1587 |
QApplication.processEvents() |
1586 | 1588 |
|
1587 | 1589 |
# trace connected items |
1588 |
docdata._connected_items_lists.clear()
|
|
1590 |
docdata._connected_items_lists = QEngineeringInstLineNoTextItem()
|
|
1589 | 1591 |
connected_items_lists = docdata._connected_items_lists |
1590 | 1592 |
|
1591 | 1593 |
items = symbols + lines |
... | ... | |
1611 | 1613 |
for item in connected_items_list: |
1612 | 1614 |
items.remove(item) |
1613 | 1615 |
|
1614 |
connected_items_lists.append(connected_items_list) |
|
1616 |
line_run = QEngineeringRunItem() |
|
1617 |
for run_item in connected_items_list: |
|
1618 |
line_run.items.append(run_item) |
|
1619 |
|
|
1620 |
line_run.owner = connected_items_lists |
|
1621 |
connected_items_lists.runs.append(line_run) |
|
1615 | 1622 |
# up to here |
1616 | 1623 |
|
1617 | 1624 |
# connect attribute |
DTI_PID/DTI_PID/Shapes/EngineeringAbstractItem.py | ||
---|---|---|
256 | 256 |
def EvaluatedSize(self): |
257 | 257 |
from EngineeringReducerItem import QEngineeringReducerItem |
258 | 258 |
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem |
259 |
from AppDocData import AppDocData |
|
259 | 260 |
|
260 | 261 |
try: |
261 | 262 |
if self.Size: return self.Size |
... | ... | |
300 | 301 |
|
301 | 302 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
302 | 303 |
sys.exc_info()[-1].tb_lineno) |
303 |
App.mainWnd().addMessage.emit(MessageType.Error, str(self.uid) + self.name + message) |
|
304 |
#App.mainWnd().addMessage.emit(MessageType.Error, str(self.uid) + self.name + message) |
|
305 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
304 | 306 |
|
305 | 307 |
def EvaluatedLineNo(self, prop): |
306 | 308 |
""" return line no attr """ |
DTI_PID/DTI_PID/Shapes/QEngineeringInstLineNoTextItem.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
""" |
|
3 |
This is engineering trim line no text item module |
|
4 |
""" |
|
5 |
|
|
6 |
import os.path |
|
7 |
import sys |
|
8 |
import copy |
|
9 |
try: |
|
10 |
from PyQt5.QtCore import Qt, QPointF, QRectF, pyqtSignal, QT_VERSION_STR, QRect |
|
11 |
from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QBrush, QPen, QTransform, QFont |
|
12 |
from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QGraphicsItem, QAbstractGraphicsShapeItem, QGraphicsTextItem |
|
13 |
except ImportError: |
|
14 |
try: |
|
15 |
from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR, QRect |
|
16 |
from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog, QFont |
|
17 |
except ImportError: |
|
18 |
raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.") |
|
19 |
|
|
20 |
from AppDocData import AppDocData |
|
21 |
from QEngineeringTrimLineNoTextItem import QEngineeringTrimLineNoTextItem |
|
22 |
|
|
23 |
class QEngineeringInstLineNoTextItem(QEngineeringTrimLineNoTextItem): |
|
24 |
""" |
|
25 |
for instrument attibute, saving connected items |
|
26 |
""" |
|
27 |
|
|
28 |
def __init__(self, parent=None): |
|
29 |
|
|
30 |
QEngineeringTrimLineNoTextItem.__init__(self, parent) |
|
31 |
|
|
32 |
def toXml(self): |
|
33 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree |
|
34 |
|
|
35 |
try: |
|
36 |
node = Element('INST_LINE_NO') |
|
37 |
uidNode = Element('UID') |
|
38 |
uidNode.text = str(self.uid) |
|
39 |
node.append(uidNode) |
|
40 |
|
|
41 |
for run in self.runs: |
|
42 |
node.append(run.toXml()) |
|
43 |
except Exception as ex: |
|
44 |
return None |
|
45 |
|
|
46 |
return node |
|
47 |
|
|
48 |
def toSql(self): |
|
49 |
""" generate sql phrase to save to database """ |
|
50 |
import uuid |
|
51 |
|
|
52 |
res = [] |
|
53 |
resLater = [] |
|
54 |
|
|
55 |
app_doc_data = AppDocData.instance() |
|
56 |
cols = ['UID', 'Drawings_UID', 'Symbol_UID'] |
|
57 |
rect = self.sceneBoundingRect() |
|
58 |
values = ['?', '?', "(select UID from Symbol where Name='Inst Line NO' and SymbolType_UID=-1)"] |
|
59 |
params = [(str(self.uid), str(app_doc_data.activeDrawing.UID))] |
|
60 |
sql = 'insert into Components({}) values({})'.format(','.join(cols), ','.join(values)) |
|
61 |
res.append((sql, tuple(params))) |
|
62 |
|
|
63 |
_index = 1 |
|
64 |
for run in self.runs: |
|
65 |
resLater.extend(run.to_sql(_index, self)) |
|
66 |
_index += 1 |
|
67 |
|
|
68 |
return res, resLater |
|
69 |
|
|
70 |
def explode(self, dummy=None): |
|
71 |
from App import App |
|
72 |
super().explode() |
|
73 |
treeWidget = App.mainWnd().itemTreeWidget |
|
74 |
treeWidget.findItemByData(self).parent().removeChild(treeWidget.findItemByData(self)) |
|
75 |
tracerLineNos = AppDocData.instance().tracerLineNos |
|
76 |
if self in tracerLineNos: |
|
77 |
tracerLineNos.pop(tracerLineNos.index(self)) |
DTI_PID/DTI_PID/Shapes/QEngineeringTrimLineNoTextItem.py | ||
---|---|---|
17 | 17 |
except ImportError: |
18 | 18 |
raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.") |
19 | 19 |
|
20 |
from EngineeringPolylineItem import QEngineeringPolylineItem |
|
21 |
from GraphicsBoundingBoxItem import QGraphicsBoundingBoxItem |
|
22 |
import OcrResultDialog |
|
23 | 20 |
from AppDocData import AppDocData |
24 | 21 |
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem |
25 | 22 |
|
... | ... | |
29 | 26 |
""" |
30 | 27 |
|
31 | 28 |
def __init__(self, parent=None): |
32 |
import uuid |
|
33 |
|
|
29 |
|
|
34 | 30 |
QEngineeringLineNoTextItem.__init__(self, parent) |
35 | 31 |
self.loc = (0, 0) |
36 | 32 |
self.size = (1, 1) |
... | ... | |
45 | 41 |
''' |
46 | 42 |
def toXml(self): |
47 | 43 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree |
48 |
from EngineeringLineItem import QEngineeringLineItem |
|
49 |
from SymbolSvgItem import SymbolSvgItem |
|
50 | 44 |
|
51 | 45 |
try: |
52 | 46 |
node = Element('TRIM_LINE_NO') |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
1975 | 1975 |
|
1976 | 1976 |
def EvaluatedCode(self, old_code, code_name): |
1977 | 1977 |
""" return new attribute code """ |
1978 |
#from LineNoTracer import LineNoTracer |
|
1979 |
#from EngineeringLineNoTextItem import QEngineeringLineNoTextItem |
|
1980 | 1978 |
from AppDocData import AppDocData |
1979 |
from CodeTables import CodeTable |
|
1981 | 1980 |
|
1982 | 1981 |
try: |
1983 | 1982 |
start_item = None |
1984 | 1983 |
if self.iType == 19: # Labels - Symbol |
1985 |
matches = [assoc for assoc in self.associations() if type(assoc) is SymbolSvgItem]
|
|
1984 |
matches = [assoc for assoc in self.associations() if issubclass(type(assoc), SymbolSvgItem)]
|
|
1986 | 1985 |
start_item = matches[0] if matches else None |
1987 | 1986 |
else: |
1988 | 1987 |
start_item = self |
... | ... | |
1990 | 1989 |
if not start_item: |
1991 | 1990 |
return '' |
1992 | 1991 |
|
1993 |
#container = QEngineeringLineNoTextItem() |
|
1994 |
#container.conns.append(start_item) |
|
1995 |
#symbols = [item for item in worker.scene.items() if issubclass(type(item), SymbolSvgItem) and not (type(item) is QEngineeringErrorItem) and not \ |
|
1996 |
# (type(item) is QEngineeringUnknownItem) and item.type != 'Notes' and not (type(item) is QEngineeringEndBreakItem)] |
|
1997 |
#lines = [item for item in worker.scene.items() if type(item) is QEngineeringLineItem] |
|
1998 |
#tracer = LineNoTracer(symbols, lines, [container], [], [], [], []) |
|
1999 |
|
|
2000 | 1992 |
app_doc_data = AppDocData.instance() |
2001 | 1993 |
connected_items_lists = app_doc_data._connected_items_lists |
1994 |
items = [connected_items_list.items for connected_items_list in connected_items_lists.runs if start_item in connected_items_list.items] |
|
1995 |
if len(items) != 1: |
|
1996 |
return '' |
|
1997 |
else: |
|
1998 |
items = [item.name for item in items[0] if issubclass(type(item), SymbolSvgItem)] |
|
2002 | 1999 |
|
2003 |
|
|
2004 |
|
|
2005 |
|
|
2006 |
|
|
2000 |
table = CodeTable.instance(code_name, inst=True) |
|
2007 | 2001 |
|
2008 |
new_code = None |
|
2002 |
for value in table.values: |
|
2003 |
if old_code == value[1] and [item for item in value[2] if item in items]: |
|
2004 |
return value[3] |
|
2009 | 2005 |
|
2010 |
return 'new_code'
|
|
2006 |
return '' |
|
2011 | 2007 |
except Exception as ex: |
2012 | 2008 |
from App import App |
2013 | 2009 |
from AppDocData import MessageType |
2014 | 2010 |
|
2015 | 2011 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
2016 | 2012 |
sys.exc_info()[-1].tb_lineno) |
2017 |
App.mainWnd().addMessage.emit(MessageType.Error, str(self.uid) + self.name + message) |
|
2013 |
#App.mainWnd().addMessage.emit(MessageType.Error, str(self.uid) + self.name + message) |
|
2014 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
2018 | 2015 |
|
2019 | 2016 |
def recursiveChangeAttributes(node, attName, attValue): |
2020 | 2017 |
while not node.isNull(): |
DTI_PID/DTI_PID/XmlGenerator.py | ||
---|---|---|
366 | 366 |
@author Jeongwoo |
367 | 367 |
@date 2018.05.28 |
368 | 368 |
''' |
369 |
|
|
370 |
|
|
371 | 369 |
def appendLineInfo(xmlPath, lineInfo): |
372 | 370 |
tree = parse(xmlPath) |
373 | 371 |
root = tree.getroot() |
... | ... | |
402 | 400 |
2018.06.14 Jeongwoo Add if-statement for QEngineeringUnknownItem data node |
403 | 401 |
2018.11.26 euisung remove scene dependency |
404 | 402 |
''' |
405 |
|
|
406 |
|
|
407 | 403 |
def write_to_xml(path, pidWidth, pidHeight, items, tracer_line_nos): |
408 | 404 |
from EngineeringAbstractItem import QEngineeringAbstractItem |
409 | 405 |
from EngineeringNoteItem import QEngineeringNoteItem |
... | ... | |
479 | 475 |
resultDic[key][1].append(str(item.uid)) |
480 | 476 |
|
481 | 477 |
for line in tracer_line_nos: |
482 |
if type(line) is QEngineeringTrimLineNoTextItem:
|
|
478 |
if issubclass(type(line), QEngineeringTrimLineNoTextItem):
|
|
483 | 479 |
trimNode = line.toXml() |
484 | 480 |
if trimNode: |
485 | 481 |
resultDic[str(type(item))][0] += 1 |
내보내기 Unified diff