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