개정판 15e3c78a
issue #641: 도면을 열때 symbol, text, line, unknown을 선택해서 열수 있다
Change-Id: Ic3abd1d8454b6c089f39d5599138046b90430b32
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
108 | 108 |
self._associationss = {} |
109 | 109 |
self._attributess = {} |
110 | 110 |
|
111 |
self._scene = QtImageViewerScene(None) |
|
112 |
|
|
113 |
@property |
|
114 |
def scene(self): |
|
115 |
"""getter scene""" |
|
116 |
return self._scene |
|
117 |
|
|
118 | 111 |
def clearTempDBData(self): |
119 | 112 |
self._connecterss = {} |
120 | 113 |
self._associationss = {} |
DTI_PID/DTI_PID/Commands/LoadCommand.py | ||
---|---|---|
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 QEngineeringTrimLineNoTextItem import QEngineeringTrimLineNoTextItem |
|
32 |
|
|
33 |
|
|
34 |
class LoadCommand(AbstractCommand): |
|
35 |
display_message = pyqtSignal(Enum, str) |
|
36 |
set_maximum = pyqtSignal(int) |
|
37 |
show_progress = pyqtSignal(int) |
|
38 |
|
|
39 |
def __init__(self): |
|
40 |
super(LoadCommand, self).__init__(None) |
|
41 |
|
|
42 |
def execute(self, params, symbol=True, text=True, line=True, unknown=True, update_items=True): |
|
43 |
"""load data form xml file for database""" |
|
44 |
from datetime import datetime |
|
45 |
from App import App |
|
46 |
from AppDocData import AppDocData |
|
47 |
from AppDocData import MessageType |
|
48 |
import concurrent.futures as futures |
|
49 |
|
|
50 |
# Yield successive n-sized |
|
51 |
# chunks from l. |
|
52 |
def divide_chunks(l, n): |
|
53 |
# looping till length l |
|
54 |
for i in range(0, len(l), n): |
|
55 |
yield l[i:i + n] |
|
56 |
|
|
57 |
def update_items(items): |
|
58 |
for item in items: |
|
59 |
# binding items |
|
60 |
item.owner |
|
61 |
for connector in item.connectors: |
|
62 |
connector.connectedItem |
|
63 |
|
|
64 |
return items |
|
65 |
|
|
66 |
app_doc_data = AppDocData.instance() |
|
67 |
try: |
|
68 |
drawing, scene = params[0], params[1] |
|
69 |
file_name = os.path.splitext(os.path.basename(drawing.file_path))[0] |
|
70 |
path = os.path.join(app_doc_data.getCurrentProject().getTempPath(), file_name + '.xml') |
|
71 |
configs = app_doc_data.getConfigs('Data Load', 'Xml First') |
|
72 |
if configs and int(configs[0].value) >= 1 and os.path.isfile(path): |
|
73 |
value = self.load_data_from_xml(drawing, scene, symbol, text, line, unknown) |
|
74 |
elif configs and int(configs[0].value) <= 1: |
|
75 |
value = self.load_data_from_database(drawing, scene, symbol, text, line, unknown) |
|
76 |
|
|
77 |
"""update items""" |
|
78 |
if update_items: |
|
79 |
_items = [_item for _item in scene.items() if hasattr(_item, 'owner') or hasattr(_item, 'connectors')] |
|
80 |
if _items: |
|
81 |
items = divide_chunks(_items, App.THREAD_MAX_WORKER if len(_items) > App.THREAD_MAX_WORKER else |
|
82 |
len(_items)) |
|
83 |
with futures.ThreadPoolExecutor(max_workers=App.THREAD_MAX_WORKER) as pool: |
|
84 |
future_items = {pool.submit(update_items, _items): _items for _items in items} |
|
85 |
for future in futures.as_completed(future_items): |
|
86 |
_items = future.result() |
|
87 |
value = value + len(_items) |
|
88 |
self.show_progress.emit(value) |
|
89 |
except Exception as ex: |
|
90 |
from AppDocData import MessageType |
|
91 |
|
|
92 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \ |
|
93 |
f"{sys.exc_info()[-1].tb_lineno}" |
|
94 |
self.display_message.emit(MessageType.Error, message) |
|
95 |
finally: |
|
96 |
app_doc_data.clearTempDBData() |
|
97 |
|
|
98 |
def load_data_from_xml(self, drawing, scene, symbol, text, line, unknown) -> int: |
|
99 |
def find_item(scene, uid): |
|
100 |
items = [item for item in scene.items() if hasattr(item, 'uid') and str(item.uid) == str(uid)] |
|
101 |
return items[0] if items else None |
|
102 |
|
|
103 |
import concurrent.futures as futures |
|
104 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree, parse |
|
105 |
from App import App |
|
106 |
from EngineeringRunItem import QEngineeringRunItem |
|
107 |
from QEngineeringTrimLineNoTextItem import QEngineeringTrimLineNoTextItem |
|
108 |
from EngineeringGraphicsLineItem import QEngineeringGraphicsLineItem |
|
109 |
|
|
110 |
app_doc_data = AppDocData.instance() |
|
111 |
value = 0 |
|
112 |
|
|
113 |
try: |
|
114 |
file_name = os.path.splitext(os.path.basename(drawing.file_path))[0] |
|
115 |
path = os.path.join(app_doc_data.getCurrentProject().getTempPath(), file_name + '.xml') |
|
116 |
scene.blockSignals(True) |
|
117 |
|
|
118 |
symbols = [] |
|
119 |
lines = [] |
|
120 |
|
|
121 |
xml = parse(path) |
|
122 |
root = xml.getroot() |
|
123 |
|
|
124 |
maxValue = 0 |
|
125 |
if symbol: |
|
126 |
maxValue = maxValue + len(list(root.iter('SYMBOL'))) - \ |
|
127 |
len(list(root.iterfind('LINENOS/LINE_NO/RUN/SYMBOL'))) - \ |
|
128 |
len(list(root.iterfind('TRIMLINENOS/TRIM_LINE_NO/RUN/SYMBOL'))) |
|
129 |
if text: |
|
130 |
maxValue = maxValue + len(list(root.iterfind('TEXTINFOS/ATTRIBUTE'))) |
|
131 |
maxValue = maxValue + len(list(root.iterfind('NOTES/ATTRIBUTE'))) |
|
132 |
maxValue = maxValue + len(list(root.iter('LINE_NO'))) |
|
133 |
maxValue = maxValue + len(list(root.iter('TRIM_LINE_NO'))) |
|
134 |
if line: |
|
135 |
maxValue = maxValue + len(list(root.iter('LINE'))) - \ |
|
136 |
len(list(root.iterfind('LINENOS/LINE_NO/RUN/LINE'))) - \ |
|
137 |
len(list(root.iterfind('TRIMLINENOS/TRIM_LINE_NO/RUN/LINE'))) |
|
138 |
maxValue = maxValue + len(list(root.iter('GRAPHICS_LINE'))) |
|
139 |
if unknown: |
|
140 |
maxValue = maxValue + len(list(root.iter('UNKNOWN'))) |
|
141 |
|
|
142 |
maxValue *= 2 |
|
143 |
self.set_maximum.emit(maxValue) if maxValue > 0 else None |
|
144 |
|
|
145 |
if symbol: |
|
146 |
for symbol in root.find('SYMBOLS').iter('SYMBOL'): |
|
147 |
item = SymbolSvgItem.fromXml(symbol) |
|
148 |
if item is not None: |
|
149 |
symbols.append(item) |
|
150 |
app_doc_data.symbols.append(item) |
|
151 |
item.addSvgItemToScene(scene) |
|
152 |
else: |
|
153 |
pt = [float(x) for x in symbol.find('LOCATION').text.split(',')] |
|
154 |
size = [float(x) for x in symbol.find('SIZE').text.split(',')] |
|
155 |
angle = float(symbol.find('ANGLE').text) |
|
156 |
item = QGraphicsBoundingBoxItem(pt[0], pt[1], size[0], size[1]) |
|
157 |
item.isSymbol = True |
|
158 |
item.angle = angle |
|
159 |
item.setPen(QPen(Qt.red, 5, Qt.SolidLine)) |
|
160 |
scene.addItem(item) |
|
161 |
|
|
162 |
value = value + 1 |
|
163 |
self.show_progress.emit(value) |
|
164 |
|
|
165 |
QApplication.processEvents() |
|
166 |
|
|
167 |
if text: |
|
168 |
# parse texts |
|
169 |
for text in root.find('TEXTINFOS').iter('ATTRIBUTE'): |
|
170 |
item = QEngineeringTextItem.fromXml(text) |
|
171 |
if item is not None: |
|
172 |
uid = text.find('UID') |
|
173 |
attributeValue = text.find('ATTRIBUTEVALUE') |
|
174 |
name = text.find('NAME').text |
|
175 |
item.addTextItemToScene(scene) |
|
176 |
# docData.texts.append(item) |
|
177 |
|
|
178 |
if name == 'TEXT': |
|
179 |
if uid is not None and attributeValue is not None: |
|
180 |
item.uid = uid.text |
|
181 |
item.attribute = attributeValue.text |
|
182 |
|
|
183 |
value = value + 1 |
|
184 |
self.show_progress.emit(value) |
|
185 |
|
|
186 |
QApplication.processEvents() |
|
187 |
|
|
188 |
# note |
|
189 |
for text in root.find('NOTES').iter('ATTRIBUTE'): |
|
190 |
item = QEngineeringTextItem.fromXml(text) |
|
191 |
if item is not None: |
|
192 |
uid = text.find('UID') |
|
193 |
attributeValue = text.find('ATTRIBUTEVALUE') |
|
194 |
name = text.find('NAME').text |
|
195 |
item.addTextItemToScene(scene) |
|
196 |
|
|
197 |
if name == 'NOTE': |
|
198 |
if uid is not None: |
|
199 |
item.uid = uid.text |
|
200 |
|
|
201 |
value = value + 1 |
|
202 |
self.show_progress.emit(value) |
|
203 |
|
|
204 |
QApplication.processEvents() |
|
205 |
|
|
206 |
if line: |
|
207 |
for line in root.find('LINEINFOS').iter('LINE'): |
|
208 |
item = QEngineeringLineItem.fromXml(line) |
|
209 |
if item: |
|
210 |
scene.addItem(item) |
|
211 |
lines.append(item) |
|
212 |
|
|
213 |
value = value + 1 |
|
214 |
self.show_progress.emit(value) |
|
215 |
|
|
216 |
for line in root.find('LINEINFOS').iter('GRAPHICS_LINE'): |
|
217 |
item = QEngineeringGraphicsLineItem.fromXml(line) |
|
218 |
if item: |
|
219 |
scene.addItem(item) |
|
220 |
|
|
221 |
value = value + 1 |
|
222 |
self.show_progress.emit(value) |
|
223 |
|
|
224 |
QApplication.processEvents() |
|
225 |
|
|
226 |
if unknown: |
|
227 |
for unknown in root.iter('UNKNOWN'): |
|
228 |
item = QEngineeringUnknownItem.fromXml(unknown) |
|
229 |
if item is not None: |
|
230 |
scene.addItem(item) |
|
231 |
|
|
232 |
value = value + 1 |
|
233 |
self.show_progress.emit(value) |
|
234 |
|
|
235 |
QApplication.processEvents() |
|
236 |
|
|
237 |
if text: |
|
238 |
for line_no_node in root.find('LINENOS').iter('LINE_NO'): |
|
239 |
line_no = QEngineeringLineNoTextItem.fromXml(line_no_node) |
|
240 |
if line_no is None: continue |
|
241 |
line_no.addTextItemToScene(scene) |
|
242 |
|
|
243 |
if type(line_no) is not QEngineeringLineNoTextItem: continue |
|
244 |
|
|
245 |
if symbol and line: |
|
246 |
runs_node = line_no_node.findall('RUN') |
|
247 |
if runs_node is None: continue |
|
248 |
|
|
249 |
for run_node in runs_node: |
|
250 |
line_run = QEngineeringRunItem() |
|
251 |
for child_node in run_node: |
|
252 |
uidElement = child_node.find('UID') |
|
253 |
if uidElement is not None: |
|
254 |
uid = uidElement.text |
|
255 |
run_item = find_item(scene, uid) |
|
256 |
if run_item is not None: |
|
257 |
run_item._owner = line_no |
|
258 |
line_run.items.append(run_item) |
|
259 |
line_run.owner = line_no |
|
260 |
line_no.runs.append(line_run) |
|
261 |
|
|
262 |
value = value + 1 |
|
263 |
self.show_progress.emit(value) |
|
264 |
|
|
265 |
QApplication.processEvents() |
|
266 |
|
|
267 |
for trimLineNo in root.iter('TRIM_LINE_NO'): |
|
268 |
line_no = QEngineeringTrimLineNoTextItem() |
|
269 |
line_no.uid = uuid.UUID(trimLineNo.find('UID').text) |
|
270 |
|
|
271 |
if symbol and line: |
|
272 |
runs_node = trimLineNo.findall('RUN') |
|
273 |
if runs_node is None: continue |
|
274 |
|
|
275 |
for run in runs_node: |
|
276 |
line_run = QEngineeringRunItem() |
|
277 |
for child in run: |
|
278 |
uidElement = child.find('UID') |
|
279 |
if uidElement is not None: |
|
280 |
uid = uidElement.text |
|
281 |
run_item = find_item(scene, uid) |
|
282 |
if run_item is not None: |
|
283 |
run_item.owner = line_no |
|
284 |
line_run.items.append(run_item) |
|
285 |
line_run.owner = line_no |
|
286 |
line_no.runs.append(line_run) |
|
287 |
|
|
288 |
app_doc_data.tracerLineNos.append(line_no) |
|
289 |
|
|
290 |
value = value + 1 |
|
291 |
self.show_progress.emit(value) |
|
292 |
|
|
293 |
QApplication.processEvents() |
|
294 |
|
|
295 |
if root.find('VENDORS') is not None: |
|
296 |
for vendor in root.find('VENDORS').iter('VENDOR'): |
|
297 |
item = QEngineeringVendorItem.fromXml(vendor) |
|
298 |
scene.addItem(item) |
|
299 |
|
|
300 |
# connect flow item to line |
|
301 |
for line in lines: |
|
302 |
line.update_arrow() |
|
303 |
app_doc_data.lines.append(line) |
|
304 |
# for flowMark in [item for item in symbols if type(item) is QEngineeringFlowMarkItem]: |
|
305 |
# for line in lines: |
|
306 |
# if flowMark.owner is line: |
|
307 |
# line._flowMark.append(flowMark) |
|
308 |
# flowMark.setParentItem(line) |
|
309 |
# up to here |
|
310 |
|
|
311 |
""" |
|
312 |
group_box = QGroupBox("Contact Details") |
|
313 |
number_label = QLabel("Telephone number"); |
|
314 |
number_edit = QTextEdit('hello\nthis is ....') |
|
315 |
layout = QFormLayout() |
|
316 |
layout.addRow(number_label, number_edit) |
|
317 |
group_box.setLayout(layout) |
|
318 |
|
|
319 |
proxy = QGraphicsProxyWidget() |
|
320 |
proxy.setWidget(group_box) |
|
321 |
scene.addItem(proxy) # (group_box, QGraphicsItem.ItemIgnoresTransformations) |
|
322 |
""" |
|
323 |
except Exception as ex: |
|
324 |
from AppDocData import MessageType |
|
325 |
|
|
326 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \ |
|
327 |
f"{sys.exc_info()[-1].tb_lineno}" |
|
328 |
self.display_message.emit(MessageType.Error, message) |
|
329 |
finally: |
|
330 |
scene.blockSignals(False) |
|
331 |
|
|
332 |
return value |
|
333 |
|
|
334 |
def load_data_from_database(self, drawing, scene, symbol, text, line, unknown) -> int: |
|
335 |
"""load drawing data from database""" |
|
336 |
from App import App |
|
337 |
from EngineeringRunItem import QEngineeringRunItem |
|
338 |
from QEngineeringTrimLineNoTextItem import QEngineeringTrimLineNoTextItem |
|
339 |
|
|
340 |
def find_item(scene, uid): |
|
341 |
items = [item for item in scene.items() if hasattr(item, 'uid') and str(item.uid) == str(uid)] |
|
342 |
return items[0] if items else None |
|
343 |
|
|
344 |
value = 0 |
|
345 |
app_doc_data = AppDocData.instance() |
|
346 |
try: |
|
347 |
symbols = [] |
|
348 |
lines = [] |
|
349 |
|
|
350 |
components = app_doc_data.get_components(drawing.UID) |
|
351 |
maxValue = len(components) * 2 |
|
352 |
self.set_maximum.emit(maxValue) if maxValue > 0 else None |
|
353 |
|
|
354 |
if symbol: |
|
355 |
""" parsing all symbols """ |
|
356 |
for symbol in [component for component in components if int(component['SymbolType_UID']) != -1]: |
|
357 |
item = SymbolSvgItem.from_database(symbol) |
|
358 |
if item is not None: |
|
359 |
symbols.append(item) |
|
360 |
app_doc_data.symbols.append(item) |
|
361 |
item.addSvgItemToScene(scene) |
|
362 |
else: |
|
363 |
pt = [float(symbol['X']), float(symbol['Y'])] |
|
364 |
size = [float(symbol['Width']), float(symbol['Height'])] |
|
365 |
angle = float(symbol['Rotation']) |
|
366 |
item = QGraphicsBoundingBoxItem(pt[0], pt[1], size[0], size[1]) |
|
367 |
item.isSymbol = True |
|
368 |
item.angle = angle |
|
369 |
item.setPen(QPen(Qt.red, 5, Qt.SolidLine)) |
|
370 |
scene.addItem(item) |
|
371 |
|
|
372 |
value = value + 1 |
|
373 |
self.show_progress.emit(value + 1) |
|
374 |
|
|
375 |
QApplication.processEvents() |
|
376 |
|
|
377 |
if text: |
|
378 |
# parse texts |
|
379 |
for text in [component for component in components if |
|
380 |
component['Name'] == 'Text' and component['SymbolType_UID'] == -1]: |
|
381 |
item = QEngineeringTextItem.from_database(text) |
|
382 |
if item is not None: |
|
383 |
item.uid = text['UID'] |
|
384 |
item.attribute = text['Value'] |
|
385 |
name = text['Name'] |
|
386 |
item.addTextItemToScene(scene) |
|
387 |
|
|
388 |
value = value + 1 |
|
389 |
self.show_progress.emit(value) |
|
390 |
|
|
391 |
QApplication.processEvents() |
|
392 |
|
|
393 |
# note |
|
394 |
for note in [component for component in components if |
|
395 |
component['Name'] == 'Note' and component['SymbolType_UID'] == -1]: |
|
396 |
item = QEngineeringTextItem.from_database(note) |
|
397 |
if item is not None: |
|
398 |
item.uid = note['UID'] |
|
399 |
attributeValue = note['Value'] |
|
400 |
name = note['Name'] |
|
401 |
item.addTextItemToScene(scene) |
|
402 |
|
|
403 |
value = value + 1 |
|
404 |
self.show_progress.emit(value) |
|
405 |
|
|
406 |
QApplication.processEvents() |
|
407 |
|
|
408 |
if line: |
|
409 |
for line in [component for component in components if |
|
410 |
component['Name'] == 'Line' and component['SymbolType_UID'] == -1]: |
|
411 |
item = QEngineeringLineItem.from_database(line) |
|
412 |
if item: |
|
413 |
scene.addItem(item) |
|
414 |
lines.append(item) |
|
415 |
|
|
416 |
value = value + 1 |
|
417 |
self.show_progress.emit(value) |
|
418 |
|
|
419 |
QApplication.processEvents() |
|
420 |
|
|
421 |
if unknown: |
|
422 |
for unknown in [component for component in components if |
|
423 |
component['Name'] == 'Unknown' and component['SymbolType_UID'] == -1]: |
|
424 |
item = QEngineeringUnknownItem.from_database(unknown) |
|
425 |
if item is not None: |
|
426 |
scene.addItem(item) |
|
427 |
|
|
428 |
value = value + 1 |
|
429 |
self.show_progress.emit(value) |
|
430 |
|
|
431 |
QApplication.processEvents() |
|
432 |
|
|
433 |
if text: |
|
434 |
for component in [component for component in components if |
|
435 |
component['Name'] == 'Line NO' and component['SymbolType_UID'] == -1]: |
|
436 |
line_no = QEngineeringLineNoTextItem.from_database(component) |
|
437 |
if type(line_no) is QEngineeringLineNoTextItem: |
|
438 |
line_no.addTextItemToScene(scene) |
|
439 |
|
|
440 |
if symbol and line: |
|
441 |
runs = app_doc_data.get_pipe_runs(str(line_no.uid)) |
|
442 |
if not runs: continue |
|
443 |
for run in runs: |
|
444 |
line_run = QEngineeringRunItem() |
|
445 |
run_items = app_doc_data.get_pipe_run_items(run['UID']) |
|
446 |
for record in run_items: |
|
447 |
uid = record['Components_UID'] |
|
448 |
run_item = find_item(scene, uid) |
|
449 |
if run_item is not None: |
|
450 |
run_item._owner = line_no |
|
451 |
line_run.items.append(run_item) |
|
452 |
line_run.owner = line_no |
|
453 |
line_no.runs.append(line_run) |
|
454 |
|
|
455 |
value = value + 1 |
|
456 |
self.show_progress.emit(value) |
|
457 |
|
|
458 |
QApplication.processEvents() |
|
459 |
|
|
460 |
for component in [component for component in components if |
|
461 |
component['Name'] == 'Trim Line NO' and component['SymbolType_UID'] == -1]: |
|
462 |
line_no = QEngineeringTrimLineNoTextItem() |
|
463 |
line_no.uid = uuid.UUID(component['UID']) |
|
464 |
|
|
465 |
if symbol and line: |
|
466 |
runs = app_doc_data.get_pipe_runs(str(line_no.uid)) |
|
467 |
if not runs: continue |
|
468 |
|
|
469 |
for run in runs: |
|
470 |
line_run = QEngineeringRunItem() |
|
471 |
run_items = app_doc_data.get_pipe_run_items(run['UID']) |
|
472 |
for record in run_items: |
|
473 |
uid = record['Components_UID'] |
|
474 |
run_item = find_item(scene, uid) |
|
475 |
if run_item is not None: |
|
476 |
run_item.owner = line_no |
|
477 |
line_run.items.append(run_item) |
|
478 |
line_run.owner = line_no |
|
479 |
line_no.runs.append(line_run) |
|
480 |
|
|
481 |
app_doc_data.tracerLineNos.append(line_no) |
|
482 |
|
|
483 |
value = value + 1 |
|
484 |
self.show_progress.emit(value) |
|
485 |
|
|
486 |
for component in [component for component in components if |
|
487 |
component['Name'] == 'VendorPackage' and component['SymbolType_UID'] == -1]: |
|
488 |
item = QEngineeringVendorItem.from_database(component) |
|
489 |
if item is not None: |
|
490 |
scene.addItem(item) |
|
491 |
|
|
492 |
# connect flow item to line |
|
493 |
for line in lines: |
|
494 |
line.update_arrow() |
|
495 |
app_doc_data.lines.append(line) |
|
496 |
# for flowMark in [item for item in symbols if type(item) is QEngineeringFlowMarkItem]: |
|
497 |
# for line in lines: |
|
498 |
# if flowMark.owner is line: |
|
499 |
# line._flowMark.append(flowMark) |
|
500 |
# flowMark.setParentItem(line) |
|
501 |
# up to here |
|
502 |
except Exception as ex: |
|
503 |
from AppDocData import MessageType |
|
504 |
|
|
505 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \ |
|
506 |
f"{sys.exc_info()[-1].tb_lineno}" |
|
507 |
self.addMessage.emit(MessageType.Error, message) |
|
508 |
finally: |
|
509 |
pass |
|
510 |
# scene.blockSignals(False) |
|
511 |
|
|
512 |
return value |
DTI_PID/DTI_PID/Commands/PenCommand.py | ||
---|---|---|
11 | 11 |
except ImportError: |
12 | 12 |
raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.") |
13 | 13 |
|
14 |
|
|
14 | 15 |
class PenCommand(AbstractCommand.AbstractCommand): |
15 | 16 |
def __init__(self, imageViewer): |
16 | 17 |
super(PenCommand, self).__init__(imageViewer) |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
153 | 153 |
self.packageComboBox.addItems(['Vendor Package', 'Equipment Package']) |
154 | 154 |
self.toolBar.insertWidget(self.actionValidate, self.packageComboBox) |
155 | 155 |
|
156 |
self._scene = QtImageViewerScene(self) |
|
157 |
|
|
156 | 158 |
self.graphicsView = QtImageViewer.QtImageViewer(self) |
157 | 159 |
self.graphicsView.setParent(self.centralwidget) |
158 | 160 |
self.graphicsView.useDefaultCommand() # USE DEFAULT COMMAND |
159 | 161 |
self.graphicsView.setMouseTracking(True) |
160 | 162 |
self.graphicsView.viewport().installEventFilter(self) |
161 |
self.graphicsView.setScene(app_doc_data.scene)
|
|
163 |
self.graphicsView.setScene(self._scene)
|
|
162 | 164 |
|
163 | 165 |
self._display_widget = QDisplayWidget() |
164 | 166 |
self._display_widget.radioButtonByGroup.toggled.connect(self.display_colors) |
... | ... | |
269 | 271 |
self.actionSymbol_Replace_Insert.triggered.connect(self.ReplaceInsertSymbolClicked) |
270 | 272 |
self.actionEditRecognizeLine.triggered.connect(self.on_recognize_line) |
271 | 273 |
self.pushButtonDetectSymbol.clicked.connect(self.show_detect_symbol_dialog) |
272 |
self.actionUndo.triggered.connect(app_doc_data.scene.undo_stack.undo)
|
|
273 |
self.actionRedo.triggered.connect(app_doc_data.scene.undo_stack.redo)
|
|
274 |
self.actionUndo.triggered.connect(self._scene.undo_stack.undo)
|
|
275 |
self.actionRedo.triggered.connect(self._scene.undo_stack.redo)
|
|
274 | 276 |
|
275 | 277 |
configs = app_doc_data.getAppConfigs('app', 'mode') |
276 | 278 |
if configs and 1 == len(configs) and 'advanced' == configs[0].value: |
... | ... | |
345 | 347 |
|
346 | 348 |
return title |
347 | 349 |
|
350 |
@property |
|
351 |
def scene(self): |
|
352 |
"""getter scene""" |
|
353 |
return self._scene |
|
354 |
|
|
348 | 355 |
def eventFilter(self, source, event): |
349 | 356 |
"""display mouse position of graphics view""" |
350 | 357 |
try: |
... | ... | |
1215 | 1222 |
area_list = app_doc_data.getAreaList() |
1216 | 1223 |
title_area_list = app_doc_data.getTitleBlockProperties() |
1217 | 1224 |
title_list = [] |
1218 |
for title_area in title_area_list: |
|
1219 |
area = Area(title_area[0]) |
|
1220 |
area.parse(title_area[2]) |
|
1221 |
title_list.append(area) |
|
1225 |
if title_area_list: |
|
1226 |
for title_area in title_area_list: |
|
1227 |
area = Area(title_area[0]) |
|
1228 |
area.parse(title_area[2]) |
|
1229 |
title_list.append(area) |
|
1222 | 1230 |
for area in area_list + title_list: |
1223 | 1231 |
pt = [item.sceneBoundingRect().center().x(), item.sceneBoundingRect().center().y()] |
1224 | 1232 |
if area.contains(pt): |
... | ... | |
1407 | 1415 |
def open_image_drawing(self, drawing): |
1408 | 1416 |
"""open and display image drawing file""" |
1409 | 1417 |
from Drawing import Drawing |
1418 |
from App import App |
|
1419 |
from LoadCommand import LoadCommand |
|
1420 |
import concurrent.futures as futures |
|
1421 |
|
|
1422 |
# Yield successive n-sized |
|
1423 |
# chunks from l. |
|
1424 |
def divide_chunks(l, n): |
|
1425 |
# looping till length l |
|
1426 |
for i in range(0, len(l), n): |
|
1427 |
yield l[i:i + n] |
|
1428 |
|
|
1429 |
def update_items(items): |
|
1430 |
for item in items: |
|
1431 |
# binding items |
|
1432 |
item.owner |
|
1433 |
for connector in item.connectors: |
|
1434 |
connector.connectedItem |
|
1435 |
|
|
1436 |
return items |
|
1410 | 1437 |
|
1411 | 1438 |
try: |
1412 | 1439 |
app_doc_data = AppDocData.instance() |
... | ... | |
1459 | 1486 |
|
1460 | 1487 |
SymbolSvgItem.DOCUMENTS.clear() |
1461 | 1488 |
|
1462 |
# Load data |
|
1489 |
# load data TODO: check below codes |
|
1490 |
cmd = LoadCommand() |
|
1491 |
cmd.display_message.connect(self.onAddMessage) |
|
1492 |
cmd.set_maximum.connect(self.progress.setMaximum) |
|
1493 |
cmd.show_progress.connect(self.progress.setValue) |
|
1494 |
cmd.execute((drawing, self.graphicsView.scene()), |
|
1495 |
symbol=True, text=True, line=True, unknown=True, update_items=True) |
|
1496 |
# up to here |
|
1497 |
|
|
1498 |
""""update item tree widget""" |
|
1499 |
line_no_items = [item for item in self.graphicsView.scene().items() |
|
1500 |
if type(item) is QEngineeringLineNoTextItem] |
|
1501 |
for line_no in line_no_items: |
|
1502 |
line_no_tree_item = self.itemTreeWidget.addTreeItem(self.itemTreeWidget.root, line_no) |
|
1503 |
for run in line_no.runs: |
|
1504 |
for run_item in run.items: |
|
1505 |
if issubclass(type(run_item), SymbolSvgItem): |
|
1506 |
self.init_add_tree_item(line_no_tree_item, run_item) |
|
1507 |
|
|
1508 |
line_no_items = [item for item in self.graphicsView.scene().items() |
|
1509 |
if type(item) is QEngineeringTrimLineNoTextItem] |
|
1510 |
for line_no in line_no_items: |
|
1511 |
line_no_tree_item = self.itemTreeWidget.addTreeItem(self.itemTreeWidget.root, line_no) |
|
1512 |
for run in line_no.runs: |
|
1513 |
for run_item in run.items: |
|
1514 |
if issubclass(type(run_item), SymbolSvgItem): |
|
1515 |
self.init_add_tree_item(line_no_tree_item, run_item) |
|
1516 |
|
|
1517 |
self.itemTreeWidget.update_item_count() |
|
1518 |
self.itemTreeWidget.expandAll() |
|
1519 |
"""up to here""" |
|
1520 |
|
|
1521 |
"""update scene""" |
|
1522 |
for item in self._scene.items(): |
|
1523 |
item.setVisible(True) |
|
1524 |
|
|
1525 |
self._scene.update(self._scene.sceneRect()) |
|
1526 |
|
|
1527 |
""" |
|
1463 | 1528 |
path = os.path.join(app_doc_data.getCurrentProject().getTempPath(), app_doc_data.imgName + '.xml') |
1464 | 1529 |
configs = app_doc_data.getConfigs('Data Load', 'Xml First') |
1465 | 1530 |
if configs and int(configs[0].value) >= 1 and os.path.isfile(path): |
1466 |
self.load_recognition_result_from_xml(path)
|
|
1531 |
self.load_recognition_result_from_xml(drawing)
|
|
1467 | 1532 |
elif configs and int(configs[0].value) <= 1: |
1468 | 1533 |
self.load_drawing(app_doc_data.activeDrawing) |
1534 |
""" |
|
1469 | 1535 |
|
1470 | 1536 |
self.display_number_of_items() |
1471 | 1537 |
# connect scene changed signal |
... | ... | |
1811 | 1877 |
else: |
1812 | 1878 |
detector.connectLineToLine(selected[0], items[-1], 5) |
1813 | 1879 |
|
1814 |
app_doc_data.scene.undo_stack.push(CreateCommand(app_doc_data.scene, items))
|
|
1880 |
self._scene.undo_stack.push(CreateCommand(self._scene, items))
|
|
1815 | 1881 |
finally: |
1816 | 1882 |
self.graphicsView.scene().removeItem(self.actionLine.tag._polyline) |
1817 | 1883 |
self.actionLine.tag.reset() |
... | ... | |
2018 | 2084 |
app_doc_data = AppDocData.instance() |
2019 | 2085 |
|
2020 | 2086 |
cmd = ReplaceCommand(app_doc_data.scene, old_symbol, svg) |
2021 |
app_doc_data.scene.undo_stack.push(cmd)
|
|
2087 |
self._scene.undo_stack.push(cmd)
|
|
2022 | 2088 |
return |
2023 | 2089 |
elif event.key() == Qt.Key_J: |
2024 | 2090 |
# insert and connect symbol item that is selected symbol in tree to selected symbol |
... | ... | |
2105 | 2171 |
|
2106 | 2172 |
try: |
2107 | 2173 |
self.onClearLog() |
2108 |
dlg = QRecognitionDialog(self, [drawing.file_path for drawing in checked_drawings.keys()])
|
|
2174 |
dlg = QRecognitionDialog(self, [drawing for drawing in checked_drawings.keys()]) |
|
2109 | 2175 |
dlg.exec_() |
2110 | 2176 |
|
2111 | 2177 |
if current_drawing and current_drawing in checked_drawings.keys() and dlg.isTreated: |
... | ... | |
2524 | 2590 |
2018.11.22 euisung fix note road |
2525 | 2591 |
''' |
2526 | 2592 |
|
2527 |
def load_recognition_result_from_xml(self, xmlPath):
|
|
2593 |
def load_recognition_result_from_xml(self, drawing):
|
|
2528 | 2594 |
# Yield successive n-sized |
2529 | 2595 |
# chunks from l. |
2530 | 2596 |
def divide_chunks(l, n): |
... | ... | |
2548 | 2614 |
from QEngineeringTrimLineNoTextItem import QEngineeringTrimLineNoTextItem |
2549 | 2615 |
from EngineeringGraphicsLineItem import QEngineeringGraphicsLineItem |
2550 | 2616 |
|
2551 |
docData = AppDocData.instance()
|
|
2617 |
app_doc_data = AppDocData.instance()
|
|
2552 | 2618 |
|
2553 | 2619 |
try: |
2620 |
file_name = os.path.splitext(os.path.basename(drawing.file_path))[0] |
|
2621 |
path = os.path.join(app_doc_data.getCurrentProject().getTempPath(), file_name + '.xml') |
|
2554 | 2622 |
self.graphicsView.scene().blockSignals(True) |
2555 | 2623 |
|
2556 | 2624 |
symbols = [] |
2557 | 2625 |
lines = [] |
2558 | 2626 |
|
2559 |
xml = parse(xmlPath)
|
|
2627 |
xml = parse(path)
|
|
2560 | 2628 |
root = xml.getroot() |
2561 | 2629 |
|
2562 | 2630 |
maxValue = 0 |
2563 |
maxValue = maxValue + len(list(root.iter('SYMBOL'))) - len(
|
|
2564 |
list(root.iterfind('LINENOS/LINE_NO/RUN/SYMBOL'))) - len(
|
|
2565 |
list(root.iterfind('TRIMLINENOS/TRIM_LINE_NO/RUN/SYMBOL'))) |
|
2631 |
maxValue = maxValue + len(list(root.iter('SYMBOL'))) - \
|
|
2632 |
len(list(root.iterfind('LINENOS/LINE_NO/RUN/SYMBOL'))) - \
|
|
2633 |
len(list(root.iterfind('TRIMLINENOS/TRIM_LINE_NO/RUN/SYMBOL')))
|
|
2566 | 2634 |
maxValue = maxValue + len(list(root.iterfind('TEXTINFOS/ATTRIBUTE'))) |
2567 | 2635 |
maxValue = maxValue + len(list(root.iterfind('NOTES/ATTRIBUTE'))) |
2568 | 2636 |
maxValue = maxValue + len(list(root.iter('LINE_NO'))) |
2569 |
maxValue = maxValue + len(list(root.iter('LINE'))) - len(
|
|
2570 |
list(root.iterfind('LINENOS/LINE_NO/RUN/LINE'))) - len(
|
|
2571 |
list(root.iterfind('TRIMLINENOS/TRIM_LINE_NO/RUN/LINE'))) |
|
2637 |
maxValue = maxValue + len(list(root.iter('LINE'))) - \
|
|
2638 |
len(list(root.iterfind('LINENOS/LINE_NO/RUN/LINE'))) - \
|
|
2639 |
len(list(root.iterfind('TRIMLINENOS/TRIM_LINE_NO/RUN/LINE')))
|
|
2572 | 2640 |
maxValue = maxValue + len(list(root.iter('GRAPHICS_LINE'))) |
2573 | 2641 |
maxValue = maxValue + len(list(root.iter('UNKNOWN'))) |
2574 | 2642 |
# maxValue = maxValue + len(list(root.iter('SIZETEXT'))) |
... | ... | |
2610 | 2678 |
if item is not None: |
2611 | 2679 |
item.transfer.onRemoved.connect(self.itemRemoved) |
2612 | 2680 |
symbols.append(item) |
2613 |
docData.symbols.append(item)
|
|
2681 |
app_doc_data.symbols.append(item)
|
|
2614 | 2682 |
item.addSvgItemToScene(self.graphicsView.scene()) |
2615 | 2683 |
else: |
2616 | 2684 |
pt = [float(x) for x in symbol.find('LOCATION').text.split(',')] |
... | ... | |
2758 | 2826 |
if issubclass(type(run_item), SymbolSvgItem): |
2759 | 2827 |
self.init_add_tree_item(line_no_tree_item, run_item) |
2760 | 2828 |
|
2761 |
docData.tracerLineNos.append(line_no)
|
|
2829 |
app_doc_data.tracerLineNos.append(line_no)
|
|
2762 | 2830 |
|
2763 | 2831 |
self.progress.setValue(self.progress.value() + 1) |
2764 | 2832 |
QApplication.processEvents() |
... | ... | |
2772 | 2840 |
# connect flow item to line |
2773 | 2841 |
for line in lines: |
2774 | 2842 |
line.update_arrow() |
2775 |
docData.lines.append(line)
|
|
2843 |
app_doc_data.lines.append(line)
|
|
2776 | 2844 |
# for flowMark in [item for item in symbols if type(item) is QEngineeringFlowMarkItem]: |
2777 | 2845 |
# for line in lines: |
2778 | 2846 |
# if flowMark.owner is line: |
DTI_PID/DTI_PID/QtImageViewerScene.py | ||
---|---|---|
48 | 48 |
return self._undo_stack |
49 | 49 |
|
50 | 50 |
def addItem(self, item): |
51 |
""" add given item to scene """ |
|
51 |
"""add given item to scene""" |
|
52 |
|
|
53 |
if hasattr(item, 'transfer'): |
|
54 |
item.transfer.onRemoved.connect(self.parent().itemRemoved) |
|
55 |
|
|
52 | 56 |
QGraphicsScene.addItem(self, item) |
53 | 57 |
self.contents_changed.emit() |
54 | 58 |
|
55 | 59 |
def removeItem(self, item): |
56 |
""" remove given item from scene """ |
|
60 |
"""remove given item from scene""" |
|
61 |
|
|
62 |
if hasattr(item, 'transfer') and item.transfer.receivers(item.transfer.onRemoved) > 0: |
|
63 |
item.transfer.onRemoved.disconnect(self.parent().itemRemoved) |
|
64 |
|
|
57 | 65 |
QGraphicsScene.removeItem(self, item) |
58 | 66 |
self.contents_changed.emit() |
59 | 67 |
|
DTI_PID/DTI_PID/RecognitionDialog.py | ||
---|---|---|
96 | 96 |
try: |
97 | 97 |
self.mutex.lock() |
98 | 98 |
if self.isSymbolChecked or self.isTrainingChecked: |
99 |
Worker.executeRecognition(self.path, self.listWidget, self.isLineChecked, self)
|
|
99 |
Worker.executeRecognition(self.drawings, self.listWidget, self.isLineChecked, self)
|
|
100 | 100 |
except Exception as ex: |
101 | 101 |
from App import App |
102 | 102 |
from AppDocData import MessageType |
... | ... | |
762 | 762 |
return (True, mergedOtherLine) |
763 | 763 |
|
764 | 764 |
@staticmethod |
765 |
def executeRecognition(path, listWidget, isLineChecked, worker):
|
|
765 |
def executeRecognition(drawings, listWidget, isLineChecked, worker):
|
|
766 | 766 |
"""recognize symbol, text, line from image p&id""" |
767 | 767 |
import re |
768 | 768 |
import timeit |
... | ... | |
778 | 778 |
|
779 | 779 |
try: |
780 | 780 |
app_doc_data = AppDocData.instance() |
781 |
drawings = app_doc_data.getDrawings() |
|
781 |
#drawings = app_doc_data.getDrawings()
|
|
782 | 782 |
project = app_doc_data.getCurrentProject() |
783 | 783 |
textDetector = TextDetector() |
784 | 784 |
|
785 | 785 |
worker.scene.clear() |
786 | 786 |
|
787 |
srcList = path |
|
788 |
|
|
789 | 787 |
Worker.initTargetSymbolDataList() |
790 | 788 |
|
791 |
for mainRes in srcList:
|
|
789 |
for drawing in drawings:
|
|
792 | 790 |
ocrCompletedSrc = [] |
793 | 791 |
searchedSymbolList = [] |
794 | 792 |
textInfoList = [] |
795 | 793 |
|
794 |
mainRes = drawing.file_path |
|
796 | 795 |
if not os.path.isfile(mainRes): |
797 | 796 |
item = QListWidgetItem('{} file is not found'.format(os.path.basename(mainRes))) |
798 | 797 |
item.setBackground(Qt.red) |
... | ... | |
804 | 803 |
app_doc_data.setImgFilePath(mainRes) |
805 | 804 |
app_doc_data.imgSrc = None |
806 | 805 |
matches = [drawing for drawing in drawings if app_doc_data.imgName == os.path.splitext(drawing.name)[0]] |
807 |
app_doc_data.activeDrawing = matches[0] if matches else Drawing(None, app_doc_data.imgName, None) |
|
806 |
app_doc_data.activeDrawing = drawing # matches[0] if matches else Drawing(None, app_doc_data.imgName, None)
|
|
808 | 807 |
app_doc_data.activeDrawing.set_pid_source(Image.open(mainRes)) |
809 | 808 |
|
810 | 809 |
# remove not drawing area |
... | ... | |
849 | 848 |
listWidget.addItem(f"Start recognition {datetime.now().strftime('%Y-%m-%d %H:%M:%S')} : {mainRes}") |
850 | 849 |
threadLock.acquire() |
851 | 850 |
|
852 |
worker.updateBatchProgress.emit(len(srcList), 1)
|
|
851 |
worker.updateBatchProgress.emit(len(drawings), 1)
|
|
853 | 852 |
|
854 | 853 |
if worker.isSymbolChecked: |
855 | 854 |
# calculate total count of symbol |
... | ... | |
963 | 962 |
# pool.submit(Worker.remove_detected_symbol_image, sym, appDocData.imgSrc) |
964 | 963 |
# pool.shutdown(wait = True) |
965 | 964 |
|
966 |
worker.updateBatchProgress.emit(len(srcList), 1)
|
|
965 |
worker.updateBatchProgress.emit(len(drawings), 1)
|
|
967 | 966 |
|
968 | 967 |
area = app_doc_data.getArea('Drawing') |
969 | 968 |
if area is not None: |
... | ... | |
1037 | 1036 |
otherTextInfoList = textDetector.otherTextInfoList.copy() if textDetector.otherTextInfoList is not None else None |
1038 | 1037 |
titleBlockTextInfoList = textDetector.titleBlockTextInfoList.copy() if textDetector.titleBlockTextInfoList is not None else None |
1039 | 1038 |
|
1040 |
app_doc_data.activeDrawing.width, app_doc_data.activeDrawing.height = app_doc_data.imgSrc.shape[
|
|
1041 |
::-1]
|
|
1039 |
app_doc_data.activeDrawing.width, app_doc_data.activeDrawing.height = \
|
|
1040 |
app_doc_data.imgSrc.shape[::-1]
|
|
1042 | 1041 |
|
1043 | 1042 |
app_doc_data.imgName = os.path.splitext(os.path.basename(mainRes))[0] |
1044 | 1043 |
else: |
1045 | 1044 |
import math |
1046 | 1045 |
from TextInfo import TextInfo |
1047 | 1046 |
|
1048 |
textItems = [item for item in worker.scene.items() if |
|
1049 |
issubclass(type(item), QEngineeringTextItem)] |
|
1047 |
textItems = [item for item in worker.scene.items() if issubclass(type(item), QEngineeringTextItem)] |
|
1050 | 1048 |
app_doc_data.texts.extend(textItems) |
1051 | 1049 |
app_doc_data.allItems.extend(textItems) |
1052 | 1050 |
|
... | ... | |
1059 | 1057 |
for textItem in textItems: |
1060 | 1058 |
textInfoList.append( |
1061 | 1059 |
TextInfo(textItem.text(), textItem.loc[0], textItem.loc[1], textItem.size[0], |
1062 |
textItem.size[1], \ |
|
1063 |
round(math.degrees(textItem.angle)))) |
|
1060 |
textItem.size[1], round(math.degrees(textItem.angle)))) |
|
1064 | 1061 |
|
1065 | 1062 |
textItem.owner = None |
1066 | 1063 |
worker.scene.removeItem(textItem) |
1067 | 1064 |
|
1068 |
worker.updateBatchProgress.emit(len(srcList), 2)
|
|
1065 |
worker.updateBatchProgress.emit(len(drawings), 2)
|
|
1069 | 1066 |
|
1070 | 1067 |
# check symbol validate |
1071 | 1068 |
#valid_sym = [] |
... | ... | |
1252 | 1249 |
# clear drawing |
1253 | 1250 |
app_doc_data.activeDrawing.image = None |
1254 | 1251 |
|
1255 |
worker.updateBatchProgress.emit(len(srcList), 1)
|
|
1252 |
worker.updateBatchProgress.emit(len(drawings), 1)
|
|
1256 | 1253 |
except Exception as ex: |
1257 | 1254 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1258 | 1255 |
sys.exc_info()[-1].tb_lineno) |
... | ... | |
2322 | 2319 |
2018.05.29 Jeongwoo Chnage parameter(graphicsView → parent) and Get graphicsView from parent |
2323 | 2320 |
''' |
2324 | 2321 |
|
2325 |
def __init__(self, parent, path): # Parent is MainWindow
|
|
2322 |
def __init__(self, parent, drawings): # Parent is MainWindow
|
|
2326 | 2323 |
from AppDocData import AppDocData |
2327 | 2324 |
|
2328 | 2325 |
QDialog.__init__(self, parent) |
2329 | 2326 |
|
2330 | 2327 |
self.parent = parent |
2331 | 2328 |
self._scene = QGraphicsScene() |
2332 |
self.path = path
|
|
2329 |
self.drawings = drawings
|
|
2333 | 2330 |
self.xmlPath = None |
2334 | 2331 |
self.ui = Recognition_UI.Ui_Recognition() |
2335 | 2332 |
self.ui.setupUi(self) |
... | ... | |
2355 | 2352 |
self.ui.lineCheckBox.setCheckState(Qt.Unchecked) |
2356 | 2353 |
self.ui.checkBoxText.setCheckState(Qt.Unchecked) |
2357 | 2354 |
|
2358 |
self.ui.progressBarBatch.setFormat('{}/{}'.format('0', str(len(self.path))))
|
|
2355 |
self.ui.progressBarBatch.setFormat('{}/{}'.format('0', str(len(self.drawings))))
|
|
2359 | 2356 |
|
2360 | 2357 |
def checkBoxChanged(self, checkState): |
2361 | 2358 |
''' |
... | ... | |
2478 | 2475 |
|
2479 | 2476 |
# 1 - create Worker and Thread inside the Form |
2480 | 2477 |
self.obj = Worker(self.mutex, self.cond) # no parent! |
2481 |
self.obj.path = self.path
|
|
2478 |
self.obj.drawings = self.drawings
|
|
2482 | 2479 |
self.obj.listWidget = self.ui.listWidget |
2483 | 2480 |
self.obj.scene = self._scene |
2484 | 2481 |
self.obj.scene._end = False # for waiting each drawing finished |
내보내기 Unified diff