hytos / DTI_PID / DTI_PID / Commands / LoadCommand.py @ 56bd2c0f
이력 | 보기 | 이력해설 | 다운로드 (28.5 KB)
1 |
# coding: utf-8
|
---|---|
2 |
""" This is Load command module """
|
3 |
import os.path |
4 |
import sys |
5 |
from enum import Enum |
6 |
import uuid |
7 |
from PyQt5.QtCore import * |
8 |
from PyQt5.QtWidgets import * |
9 |
from PyQt5.QtGui import * |
10 |
from AppDocData import AppDocData |
11 |
from AbstractCommand import AbstractCommand |
12 |
|
13 |
from EngineeringAbstractItem import QEngineeringAbstractItem |
14 |
from EngineeringPolylineItem import QEngineeringPolylineItem |
15 |
from EngineeringLineItem import QEngineeringLineItem |
16 |
from SymbolSvgItem import SymbolSvgItem |
17 |
from GraphicsBoundingBoxItem import QGraphicsBoundingBoxItem |
18 |
from EngineeringTextItem import QEngineeringTextItem |
19 |
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem |
20 |
from EngineeringNoteItem import QEngineeringNoteItem |
21 |
from QEngineeringSizeTextItem import QEngineeringSizeTextItem |
22 |
from EngineeringUnknownItem import QEngineeringUnknownItem |
23 |
from EngineeringEquipmentItem import QEngineeringEquipmentItem |
24 |
from EngineeringInstrumentItem import QEngineeringInstrumentItem |
25 |
from EngineeringSpecBreakItem import QEngineeringSpecBreakItem |
26 |
from EngineeringErrorItem import QEngineeringErrorItem |
27 |
from EngineeringVendorItem import QEngineeringVendorItem |
28 |
from EngineeringEndBreakItem import QEngineeringEndBreakItem |
29 |
from EngineeringReducerItem import QEngineeringReducerItem |
30 |
from EngineeringFlowMarkItem import QEngineeringFlowMarkItem |
31 |
from EngineeringRunItem import QEngineeringRunItem |
32 |
from QEngineeringTrimLineNoTextItem import QEngineeringTrimLineNoTextItem |
33 |
from QEngineeringInstLineNoTextItem import QEngineeringInstLineNoTextItem |
34 |
|
35 |
|
36 |
class LoadCommand(AbstractCommand): |
37 |
display_message = pyqtSignal(Enum, str)
|
38 |
set_maximum = pyqtSignal(int)
|
39 |
show_progress = pyqtSignal(int)
|
40 |
|
41 |
def __init__(self): |
42 |
super(LoadCommand, self).__init__(None) |
43 |
|
44 |
def execute(self, params, symbol=True, text=True, line=True, unknown=True, package=True, update=True): |
45 |
"""load data form xml file for database"""
|
46 |
from datetime import datetime |
47 |
from App import App |
48 |
from AppDocData import AppDocData |
49 |
from AppDocData import MessageType |
50 |
import concurrent.futures as futures |
51 |
|
52 |
# Yield successive n-sized
|
53 |
# chunks from l.
|
54 |
def divide_chunks(l, n): |
55 |
# looping till length l
|
56 |
for i in range(0, len(l), n): |
57 |
yield l[i:i + n]
|
58 |
|
59 |
def update_items(param): |
60 |
items, dic_items = param[0], param[1] |
61 |
for item in items: |
62 |
# binding items
|
63 |
#item.owner
|
64 |
#for connector in item.connectors:
|
65 |
# connector.connectedItem
|
66 |
|
67 |
if item._owner and (type(item._owner) is uuid.UUID or type(item._owner) is not str): |
68 |
if str(item._owner) in dic_items: |
69 |
item._owner = dic_items[str(item._owner)]
|
70 |
else:
|
71 |
item._owner = None
|
72 |
else:
|
73 |
item._owner = None
|
74 |
|
75 |
for connector in item.connectors: |
76 |
if connector._connectedItem and (type(connector._connectedItem) is uuid.UUID or type(connector._connectedItem) is not str): |
77 |
if str(connector._connectedItem) in dic_items: |
78 |
connector._connectedItem = dic_items[str(connector._connectedItem)]
|
79 |
else:
|
80 |
connector._connectedItem = None
|
81 |
else:
|
82 |
connector._connectedItem = None
|
83 |
|
84 |
return items
|
85 |
|
86 |
app_doc_data = AppDocData.instance() |
87 |
try:
|
88 |
drawing, scene = params[0], params[1] |
89 |
file_name = os.path.splitext(os.path.basename(drawing.file_path))[0]
|
90 |
path = os.path.join(app_doc_data.getCurrentProject().getTempPath(), file_name + '.xml')
|
91 |
configs = app_doc_data.getConfigs('Data Load', 'Xml First') |
92 |
if configs and int(configs[0].value) >= 1 and os.path.isfile(path): |
93 |
value = self.load_data_from_xml(drawing, scene, symbol, text, line, unknown, package)
|
94 |
elif configs and int(configs[0].value) <= 1: |
95 |
value = self.load_data_from_database(drawing, scene, symbol, text, line, unknown, package)
|
96 |
|
97 |
"""update items"""
|
98 |
if update:
|
99 |
_items = [_item for _item in scene.items() if hasattr(_item, 'owner') or hasattr(_item, 'connectors')] |
100 |
dic_items = {} |
101 |
for _item in _items: |
102 |
dic_items[str(_item.uid)] = _item
|
103 |
|
104 |
if _items:
|
105 |
items = divide_chunks(_items, App.THREAD_MAX_WORKER if len(_items) > App.THREAD_MAX_WORKER else |
106 |
len(_items))
|
107 |
with futures.ThreadPoolExecutor(max_workers=App.THREAD_MAX_WORKER) as pool: |
108 |
future_items = {pool.submit(update_items, (_items, dic_items)): _items for _items in items} |
109 |
for future in futures.as_completed(future_items): |
110 |
_items = future.result() |
111 |
value = value + len(_items)
|
112 |
self.show_progress.emit(value)
|
113 |
except Exception as ex: |
114 |
from AppDocData import MessageType |
115 |
|
116 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \
|
117 |
f"{sys.exc_info()[-1].tb_lineno}"
|
118 |
self.display_message.emit(MessageType.Error, message)
|
119 |
finally:
|
120 |
app_doc_data.clearTempDBData() |
121 |
|
122 |
def load_data_from_xml(self, drawing, scene, symbol, text, line, unknown, package) -> int: |
123 |
def find_item(scene, uid): |
124 |
items = [item for item in scene.items() if hasattr(item, 'uid') and str(item.uid) == str(uid)] |
125 |
return items[0] if items else None |
126 |
|
127 |
def find_items(scene, uids): |
128 |
uids = [str(uid) for uid in uids] |
129 |
items = [(item, uids.index(str(item.uid))) for item in scene.items() if hasattr(item, 'uid') and str(item.uid) in uids] |
130 |
|
131 |
items = [item[0] for item in sorted(items, key= lambda param:param[1])] |
132 |
|
133 |
return items
|
134 |
|
135 |
import concurrent.futures as futures |
136 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree, parse |
137 |
from App import App |
138 |
from EngineeringGraphicsLineItem import QEngineeringGraphicsLineItem |
139 |
|
140 |
app_doc_data = AppDocData.instance() |
141 |
value = 0
|
142 |
|
143 |
try:
|
144 |
file_name = os.path.splitext(os.path.basename(drawing.file_path))[0]
|
145 |
path = os.path.join(app_doc_data.getCurrentProject().getTempPath(), file_name + '.xml')
|
146 |
scene.blockSignals(True)
|
147 |
|
148 |
symbols = [] |
149 |
lines = [] |
150 |
|
151 |
xml = parse(path) |
152 |
root = xml.getroot() |
153 |
|
154 |
maxValue = 0
|
155 |
if symbol:
|
156 |
maxValue = maxValue + len(list(root.iter('SYMBOL'))) - \ |
157 |
len(list(root.iterfind('LINENOS/LINE_NO/RUN/SYMBOL'))) - \ |
158 |
len(list(root.iterfind('TRIMLINENOS/TRIM_LINE_NO/RUN/SYMBOL'))) |
159 |
if text:
|
160 |
maxValue = maxValue + len(list(root.iterfind('TEXTINFOS/ATTRIBUTE'))) |
161 |
maxValue = maxValue + len(list(root.iterfind('NOTES/ATTRIBUTE'))) |
162 |
maxValue = maxValue + len(list(root.iter('LINE_NO'))) |
163 |
maxValue = maxValue + len(list(root.iter('TRIM_LINE_NO'))) |
164 |
if line:
|
165 |
maxValue = maxValue + len(list(root.iter('LINE'))) - \ |
166 |
len(list(root.iterfind('LINENOS/LINE_NO/RUN/LINE'))) - \ |
167 |
len(list(root.iterfind('TRIMLINENOS/TRIM_LINE_NO/RUN/LINE'))) |
168 |
maxValue = maxValue + len(list(root.iter('GRAPHICS_LINE'))) |
169 |
if unknown:
|
170 |
maxValue = maxValue + len(list(root.iter('UNKNOWN'))) |
171 |
|
172 |
maxValue *= 5
|
173 |
self.set_maximum.emit(maxValue) if maxValue > 0 else None |
174 |
|
175 |
if symbol:
|
176 |
for symbol in root.find('SYMBOLS').iter('SYMBOL'): |
177 |
item = SymbolSvgItem.fromXml(symbol) |
178 |
if item is not None: |
179 |
symbols.append(item) |
180 |
#app_doc_data.symbols.append(item)
|
181 |
item.addSvgItemToScene(scene) |
182 |
else:
|
183 |
pt = [float(x) for x in symbol.find('LOCATION').text.split(',')] |
184 |
size = [float(x) for x in symbol.find('SIZE').text.split(',')] |
185 |
angle = float(symbol.find('ANGLE').text) |
186 |
item = QGraphicsBoundingBoxItem(pt[0], pt[1], size[0], size[1]) |
187 |
item.isSymbol = True
|
188 |
item.angle = angle |
189 |
item.setPen(QPen(Qt.red, 5, Qt.SolidLine))
|
190 |
scene.addItem(item) |
191 |
|
192 |
value = value + 4
|
193 |
self.show_progress.emit(value)
|
194 |
|
195 |
QApplication.processEvents() |
196 |
|
197 |
if text:
|
198 |
# parse texts
|
199 |
for text in root.find('TEXTINFOS').iter('ATTRIBUTE'): |
200 |
item = QEngineeringTextItem.fromXml(text) |
201 |
if item is not None: |
202 |
uid = text.find('UID')
|
203 |
attributeValue = text.find('ATTRIBUTEVALUE')
|
204 |
name = text.find('NAME').text
|
205 |
item.addTextItemToScene(scene) |
206 |
# docData.texts.append(item)
|
207 |
|
208 |
if name == 'TEXT': |
209 |
if uid is not None and attributeValue is not None: |
210 |
item.uid = uid.text |
211 |
item.attribute = attributeValue.text |
212 |
|
213 |
value = value + 4
|
214 |
self.show_progress.emit(value)
|
215 |
|
216 |
QApplication.processEvents() |
217 |
|
218 |
# note
|
219 |
for text in root.find('NOTES').iter('ATTRIBUTE'): |
220 |
item = QEngineeringTextItem.fromXml(text) |
221 |
if item is not None: |
222 |
uid = text.find('UID')
|
223 |
attributeValue = text.find('ATTRIBUTEVALUE')
|
224 |
name = text.find('NAME').text
|
225 |
item.addTextItemToScene(scene) |
226 |
|
227 |
if name == 'NOTE': |
228 |
if uid is not None: |
229 |
item.uid = uid.text |
230 |
|
231 |
value = value + 4
|
232 |
self.show_progress.emit(value)
|
233 |
|
234 |
QApplication.processEvents() |
235 |
|
236 |
if line:
|
237 |
for line in root.find('LINEINFOS').iter('LINE'): |
238 |
item = QEngineeringLineItem.fromXml(line) |
239 |
if item:
|
240 |
scene.addItem(item) |
241 |
lines.append(item) |
242 |
|
243 |
value = value + 4
|
244 |
self.show_progress.emit(value)
|
245 |
|
246 |
for line in root.find('LINEINFOS').iter('GRAPHICS_LINE'): |
247 |
item = QEngineeringGraphicsLineItem.fromXml(line) |
248 |
if item:
|
249 |
scene.addItem(item) |
250 |
|
251 |
value = value + 4
|
252 |
self.show_progress.emit(value)
|
253 |
|
254 |
QApplication.processEvents() |
255 |
|
256 |
if unknown:
|
257 |
for unknown in root.iter('UNKNOWN'): |
258 |
item = QEngineeringUnknownItem.fromXml(unknown) |
259 |
if item is not None: |
260 |
scene.addItem(item) |
261 |
|
262 |
value = value + 4
|
263 |
self.show_progress.emit(value)
|
264 |
|
265 |
QApplication.processEvents() |
266 |
|
267 |
if text:
|
268 |
for line_no_node in root.find('LINENOS').iter('LINE_NO'): |
269 |
line_no = QEngineeringLineNoTextItem.fromXml(line_no_node) |
270 |
if line_no is None: continue |
271 |
line_no.addTextItemToScene(scene) |
272 |
|
273 |
if type(line_no) is not QEngineeringLineNoTextItem: continue |
274 |
|
275 |
if symbol and line: |
276 |
runs_node = line_no_node.findall('RUN')
|
277 |
if runs_node is None: continue |
278 |
|
279 |
for run_node in runs_node: |
280 |
line_run = QEngineeringRunItem() |
281 |
uids = [child_node.find('UID').text for child_node in run_node] |
282 |
#for child_node in run_node:
|
283 |
# uidElement = child_node.find('UID')
|
284 |
# if uidElement is not None:
|
285 |
# uid = uidElement.text
|
286 |
# uids.append(uid)
|
287 |
# '''
|
288 |
# run_item = find_item(scene, uid)
|
289 |
# if run_item is not None:
|
290 |
# run_item._owner = line_no
|
291 |
# line_run.items.append(run_item)
|
292 |
# '''
|
293 |
run_items = find_items(scene, uids) |
294 |
for run_item in run_items: |
295 |
run_item._owner = line_no |
296 |
line_run.items.append(run_item) |
297 |
|
298 |
line_run.owner = line_no |
299 |
line_no.runs.append(line_run) |
300 |
|
301 |
value = value + 4
|
302 |
self.show_progress.emit(value)
|
303 |
|
304 |
QApplication.processEvents() |
305 |
|
306 |
for trimLineNo in root.iter('TRIM_LINE_NO'): |
307 |
line_no = QEngineeringTrimLineNoTextItem() |
308 |
line_no.uid = uuid.UUID(trimLineNo.find('UID').text)
|
309 |
|
310 |
if symbol and line: |
311 |
runs_node = trimLineNo.findall('RUN')
|
312 |
if runs_node is None: continue |
313 |
|
314 |
for run in runs_node: |
315 |
line_run = QEngineeringRunItem() |
316 |
uids = [child.find('UID').text for child in run] |
317 |
#for child in run:
|
318 |
# uidElement = child.find('UID')
|
319 |
# if uidElement is not None:
|
320 |
# uid = uidElement.text
|
321 |
# uids.append(uid)
|
322 |
# '''
|
323 |
# run_item = find_item(scene, uid)
|
324 |
# if run_item is not None:
|
325 |
# run_item.owner = line_no
|
326 |
# line_run.items.append(run_item)
|
327 |
# '''
|
328 |
run_items = find_items(scene, uids) |
329 |
for run_item in run_items: |
330 |
run_item._owner = line_no |
331 |
line_run.items.append(run_item) |
332 |
|
333 |
line_run.owner = line_no |
334 |
line_no.runs.append(line_run) |
335 |
|
336 |
app_doc_data.tracerLineNos.append(line_no) |
337 |
|
338 |
value = value + 4
|
339 |
self.show_progress.emit(value)
|
340 |
|
341 |
# for inst attribute
|
342 |
for trimLineNo in root.iter('INST_LINE_NO'): |
343 |
line_no = QEngineeringInstLineNoTextItem() |
344 |
line_no.uid = uuid.UUID(trimLineNo.find('UID').text)
|
345 |
|
346 |
if symbol and line: |
347 |
runs_node = trimLineNo.findall('RUN')
|
348 |
if runs_node is None: continue |
349 |
|
350 |
for run in runs_node: |
351 |
line_run = QEngineeringRunItem() |
352 |
uids = [] |
353 |
for child in run: |
354 |
uidElement = child.find('UID')
|
355 |
if uidElement is not None: |
356 |
uid = uidElement.text |
357 |
uids.append(uid) |
358 |
|
359 |
run_items = find_items(scene, uids) |
360 |
for run_item in run_items: |
361 |
line_run.items.append(run_item) |
362 |
|
363 |
line_run.owner = line_no |
364 |
line_no.runs.append(line_run) |
365 |
|
366 |
app_doc_data._connected_items_lists = line_no |
367 |
|
368 |
value = value + 4
|
369 |
self.show_progress.emit(value)
|
370 |
|
371 |
QApplication.processEvents() |
372 |
|
373 |
if package:
|
374 |
if root.find('VENDORS') is not None: |
375 |
for vendor in root.find('VENDORS').iter('VENDOR'): |
376 |
item = QEngineeringVendorItem.fromXml(vendor) |
377 |
scene.addItem(item) |
378 |
|
379 |
# cad graphic item load
|
380 |
if root.find('GRAPHICS') is not None: |
381 |
for graphic in root.find('GRAPHICS').iter('GRAPHIC'): |
382 |
app_doc_data.cadGraphics.append(graphic) |
383 |
# up to here
|
384 |
|
385 |
# connect flow item to line
|
386 |
for line in lines: |
387 |
line.update_arrow() |
388 |
#app_doc_data.lines.append(line)
|
389 |
# for flowMark in [item for item in symbols if type(item) is QEngineeringFlowMarkItem]:
|
390 |
# for line in lines:
|
391 |
# if flowMark.owner is line:
|
392 |
# line._flowMark.append(flowMark)
|
393 |
# flowMark.setParentItem(line)
|
394 |
# up to here
|
395 |
|
396 |
"""
|
397 |
group_box = QGroupBox("Contact Details")
|
398 |
number_label = QLabel("Telephone number");
|
399 |
number_edit = QTextEdit('hello\nthis is ....')
|
400 |
layout = QFormLayout()
|
401 |
layout.addRow(number_label, number_edit)
|
402 |
group_box.setLayout(layout)
|
403 |
|
404 |
proxy = QGraphicsProxyWidget()
|
405 |
proxy.setWidget(group_box)
|
406 |
scene.addItem(proxy) # (group_box, QGraphicsItem.ItemIgnoresTransformations)
|
407 |
"""
|
408 |
except Exception as ex: |
409 |
from AppDocData import MessageType |
410 |
|
411 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \
|
412 |
f"{sys.exc_info()[-1].tb_lineno}"
|
413 |
self.display_message.emit(MessageType.Error, message)
|
414 |
finally:
|
415 |
scene.blockSignals(False)
|
416 |
|
417 |
return value
|
418 |
|
419 |
def load_data_from_database(self, drawing, scene, symbol, text, line, unknown, package) -> int: |
420 |
"""load drawing data from database"""
|
421 |
from App import App |
422 |
|
423 |
def find_item(scene, uid): |
424 |
items = [item for item in scene.items() if hasattr(item, 'uid') and str(item.uid) == str(uid)] |
425 |
return items[0] if items else None |
426 |
|
427 |
def find_items(scene, uids): |
428 |
uids = [str(uid) for uid in uids] |
429 |
items = [(item, uids.index(str(item.uid))) for item in scene.items() if hasattr(item, 'uid') and str(item.uid) in uids] |
430 |
|
431 |
items = [item[0] for item in sorted(items, key= lambda param:param[1])] |
432 |
|
433 |
return items
|
434 |
|
435 |
value = 0
|
436 |
app_doc_data = AppDocData.instance() |
437 |
try:
|
438 |
symbols = [] |
439 |
lines = [] |
440 |
|
441 |
components = app_doc_data.get_components(drawing.UID) |
442 |
maxValue = len(components) * 5 |
443 |
self.set_maximum.emit(maxValue) if maxValue > 0 else None |
444 |
|
445 |
if symbol:
|
446 |
""" parsing all symbols """
|
447 |
for symbol in [component for component in components if int(component['SymbolType_UID']) != -1]: |
448 |
item = SymbolSvgItem.from_database(symbol) |
449 |
if item is not None: |
450 |
symbols.append(item) |
451 |
#app_doc_data.symbols.append(item)
|
452 |
item.addSvgItemToScene(scene) |
453 |
else:
|
454 |
pt = [float(symbol['X']), float(symbol['Y'])] |
455 |
size = [float(symbol['Width']), float(symbol['Height'])] |
456 |
angle = float(symbol['Rotation']) |
457 |
item = QGraphicsBoundingBoxItem(pt[0], pt[1], size[0], size[1]) |
458 |
item.isSymbol = True
|
459 |
item.angle = angle |
460 |
item.setPen(QPen(Qt.red, 5, Qt.SolidLine))
|
461 |
scene.addItem(item) |
462 |
|
463 |
value = value + 4
|
464 |
self.show_progress.emit(value + 1) |
465 |
|
466 |
QApplication.processEvents() |
467 |
|
468 |
if text:
|
469 |
# parse texts
|
470 |
for text in [component for component in components if |
471 |
component['Name'] == 'Text' and component['SymbolType_UID'] == -1]: |
472 |
item = QEngineeringTextItem.from_database(text) |
473 |
if item is not None: |
474 |
item.uid = text['UID']
|
475 |
item.attribute = text['Value']
|
476 |
name = text['Name']
|
477 |
item.addTextItemToScene(scene) |
478 |
|
479 |
value = value + 4
|
480 |
self.show_progress.emit(value)
|
481 |
|
482 |
QApplication.processEvents() |
483 |
|
484 |
# note
|
485 |
for note in [component for component in components if |
486 |
component['Name'] == 'Note' and component['SymbolType_UID'] == -1]: |
487 |
item = QEngineeringTextItem.from_database(note) |
488 |
if item is not None: |
489 |
item.uid = note['UID']
|
490 |
attributeValue = note['Value']
|
491 |
name = note['Name']
|
492 |
item.addTextItemToScene(scene) |
493 |
|
494 |
value = value + 4
|
495 |
self.show_progress.emit(value)
|
496 |
|
497 |
QApplication.processEvents() |
498 |
|
499 |
if line:
|
500 |
for line in [component for component in components if |
501 |
component['Name'] == 'Line' and component['SymbolType_UID'] == -1]: |
502 |
item = QEngineeringLineItem.from_database(line) |
503 |
if item:
|
504 |
scene.addItem(item) |
505 |
lines.append(item) |
506 |
|
507 |
value = value + 4
|
508 |
self.show_progress.emit(value)
|
509 |
|
510 |
QApplication.processEvents() |
511 |
|
512 |
if unknown:
|
513 |
for unknown in [component for component in components if |
514 |
component['Name'] == 'Unknown' and component['SymbolType_UID'] == -1]: |
515 |
item = QEngineeringUnknownItem.from_database(unknown) |
516 |
if item is not None: |
517 |
scene.addItem(item) |
518 |
|
519 |
value = value + 4
|
520 |
self.show_progress.emit(value)
|
521 |
|
522 |
QApplication.processEvents() |
523 |
|
524 |
if text:
|
525 |
for component in [component for component in components if |
526 |
component['Name'] == 'Line NO' and component['SymbolType_UID'] == -1]: |
527 |
line_no = QEngineeringLineNoTextItem.from_database(component) |
528 |
if type(line_no) is QEngineeringLineNoTextItem: |
529 |
line_no.addTextItemToScene(scene) |
530 |
|
531 |
if symbol and line: |
532 |
runs = app_doc_data.get_pipe_runs(str(line_no.uid))
|
533 |
if not runs: continue |
534 |
for run in runs: |
535 |
line_run = QEngineeringRunItem() |
536 |
run_items = app_doc_data.get_pipe_run_items(run['UID'])
|
537 |
uids = [record['Components_UID'] for record in run_items] |
538 |
#for record in run_items:
|
539 |
# uid = record['Components_UID']
|
540 |
# uids.append(uid)
|
541 |
# '''
|
542 |
# run_item = find_item(scene, uid)
|
543 |
# if run_item is not None:
|
544 |
# run_item._owner = line_no
|
545 |
# line_run.items.append(run_item)
|
546 |
# '''
|
547 |
run_items = find_items(scene, uids) |
548 |
for run_item in run_items: |
549 |
run_item._owner = line_no |
550 |
line_run.items.append(run_item) |
551 |
|
552 |
line_run.owner = line_no |
553 |
line_no.runs.append(line_run) |
554 |
|
555 |
value = value + 4
|
556 |
self.show_progress.emit(value)
|
557 |
|
558 |
QApplication.processEvents() |
559 |
|
560 |
for component in [component for component in components if |
561 |
component['Name'] == 'Trim Line NO' and component['SymbolType_UID'] == -1]: |
562 |
line_no = QEngineeringTrimLineNoTextItem() |
563 |
line_no.uid = uuid.UUID(component['UID'])
|
564 |
|
565 |
if symbol and line: |
566 |
runs = app_doc_data.get_pipe_runs(str(line_no.uid))
|
567 |
if not runs: continue |
568 |
|
569 |
for run in runs: |
570 |
line_run = QEngineeringRunItem() |
571 |
run_items = app_doc_data.get_pipe_run_items(run['UID'])
|
572 |
uids = [record['Components_UID'] for record in run_items] |
573 |
#for record in run_items:
|
574 |
# uid = record['Components_UID']
|
575 |
# uids.append(uid)
|
576 |
# '''
|
577 |
# run_item = find_item(scene, uid)
|
578 |
# if run_item is not None:
|
579 |
# run_item.owner = line_no
|
580 |
# line_run.items.append(run_item)
|
581 |
# '''
|
582 |
run_items = find_items(scene, uids) |
583 |
for run_item in run_items: |
584 |
run_item._owner = line_no |
585 |
line_run.items.append(run_item) |
586 |
|
587 |
line_run.owner = line_no |
588 |
line_no.runs.append(line_run) |
589 |
|
590 |
app_doc_data.tracerLineNos.append(line_no) |
591 |
|
592 |
value = value + 4
|
593 |
self.show_progress.emit(value)
|
594 |
|
595 |
# for inst attribute
|
596 |
for component in [component for component in components if |
597 |
component['Name'] == 'Inst Line NO' and component['SymbolType_UID'] == -1]: |
598 |
line_no = QEngineeringInstLineNoTextItem() |
599 |
line_no.uid = uuid.UUID(component['UID'])
|
600 |
|
601 |
if symbol and line: |
602 |
runs = app_doc_data.get_pipe_runs(str(line_no.uid))
|
603 |
if not runs: continue |
604 |
|
605 |
for run in runs: |
606 |
line_run = QEngineeringRunItem() |
607 |
run_items = app_doc_data.get_pipe_run_items(run['UID'])
|
608 |
uids = [record['Components_UID'] for record in run_items] |
609 |
#for record in run_items:
|
610 |
# uid = record['Components_UID']
|
611 |
# uids.append(uid)
|
612 |
|
613 |
run_items = find_items(scene, uids) |
614 |
for run_item in run_items: |
615 |
line_run.items.append(run_item) |
616 |
|
617 |
line_run.owner = line_no |
618 |
line_no.runs.append(line_run) |
619 |
|
620 |
app_doc_data._connected_items_lists = line_no |
621 |
|
622 |
value = value + 4
|
623 |
self.show_progress.emit(value)
|
624 |
|
625 |
QApplication.processEvents() |
626 |
|
627 |
if package:
|
628 |
for component in [component for component in components if |
629 |
component['Name'] == 'VendorPackage' and component['SymbolType_UID'] == -1]: |
630 |
item = QEngineeringVendorItem.from_database(component) |
631 |
if item is not None: |
632 |
scene.addItem(item) |
633 |
|
634 |
# connect flow item to line
|
635 |
for line in lines: |
636 |
line.update_arrow() |
637 |
#app_doc_data.lines.append(line)
|
638 |
# for flowMark in [item for item in symbols if type(item) is QEngineeringFlowMarkItem]:
|
639 |
# for line in lines:
|
640 |
# if flowMark.owner is line:
|
641 |
# line._flowMark.append(flowMark)
|
642 |
# flowMark.setParentItem(line)
|
643 |
# up to here
|
644 |
except Exception as ex: |
645 |
from AppDocData import MessageType |
646 |
|
647 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \
|
648 |
f"{sys.exc_info()[-1].tb_lineno}"
|
649 |
self.display_message.emit(MessageType.Error, message)
|
650 |
finally:
|
651 |
pass
|
652 |
# scene.blockSignals(False)
|
653 |
|
654 |
return value
|