개정판 6ce13b5a
issue #663: fix scene attach
Change-Id: I1771416b22015193f6e41c2e3b86eaedb6f3ac56
DTI_PID/DTI_PID/RecognitionDialog.py | ||
---|---|---|
27 | 27 |
from QEngineeringOPCItem import QEngineeringOPCItem |
28 | 28 |
from LineDetector import LineDetector |
29 | 29 |
from symbol import Symbol |
30 |
from Drawing import Drawing |
|
30 | 31 | |
31 | 32 |
from MainWindow import MainWindow |
32 | 33 | |
... | ... | |
79 | 80 |
updateBatchProgress = pyqtSignal(int, int) |
80 | 81 |
displayLog = pyqtSignal(MessageType, str) |
81 | 82 |
add_detected_items_to_scene = pyqtSignal(QGraphicsScene) |
83 |
add_predata_to_scene = pyqtSignal(Drawing, QGraphicsScene, bool, bool, bool, bool, bool) |
|
82 | 84 | |
83 | 85 |
def __init__(self, mutex, cond): |
84 | 86 |
super(Worker, self).__init__() |
... | ... | |
760 | 762 |
# cv2.destroyAllWindows() |
761 | 763 |
return (True, mergedOtherLine) |
762 | 764 | |
763 |
def load_equipment_package(self, drawing): |
|
764 |
from LoadCommand import LoadCommand |
|
765 | ||
766 |
try: |
|
767 |
"""load equipment package""" |
|
768 |
cmd = LoadCommand() |
|
769 |
cmd.execute((drawing, self.scene), symbol=False, text=False, line=False, unknown=False, |
|
770 |
package=True ,update=False) |
|
771 |
"""up to here""" |
|
772 |
except Exception as ex: |
|
773 |
from App import App |
|
774 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
775 |
sys.exc_info()[-1].tb_lineno) |
|
776 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
777 | ||
778 | 765 |
@staticmethod |
779 | 766 |
def executeRecognition(drawings, listWidget, isLineChecked, worker): |
780 | 767 |
"""recognize symbol, text, line from image p&id""" |
781 | 768 |
import re |
782 | 769 |
import timeit |
783 | 770 |
from TextDetector import TextDetector |
784 |
from Drawing import Drawing |
|
785 | 771 |
from datetime import datetime |
786 | 772 | |
787 | 773 |
global ocrCompletedSrc |
... | ... | |
821 | 807 |
app_doc_data.activeDrawing.set_pid_source(Image.open(mainRes)) |
822 | 808 | |
823 | 809 |
# Load equipment package |
824 |
worker.load_equipment_package(app_doc_data.activeDrawing) |
|
810 |
worker.add_predata_to_scene.emit(app_doc_data.activeDrawing, worker.scene, False, False, False, False, True) |
|
811 |
worker.cond.wait(worker.mutex) |
|
825 | 812 | |
826 | 813 |
# remove not drawing area |
827 | 814 |
configs = app_doc_data.getConfigs('{} Equipment Desc Area'.format(app_doc_data.imgName)) |
... | ... | |
1058 | 1045 | |
1059 | 1046 |
app_doc_data.imgName = os.path.splitext(os.path.basename(mainRes))[0] |
1060 | 1047 |
else: |
1061 |
from LoadCommand import LoadCommand |
|
1062 | 1048 |
import math |
1063 | 1049 |
from TextInfo import TextInfo |
1064 | 1050 | |
1065 | 1051 |
"""load texts""" |
1066 |
cmd = LoadCommand()
|
|
1067 |
cmd.execute((drawing, worker.scene), symbol=False, text=True, line=False, unknown=False,
|
|
1068 |
package=False, update=False)
|
|
1052 |
text_scene = QGraphicsScene()
|
|
1053 |
worker.add_predata_to_scene.emit(app_doc_data.activeDrawing, text_scene, False, True, False, False, False)
|
|
1054 |
worker.cond.wait(worker.mutex)
|
|
1069 | 1055 |
"""up to here""" |
1070 |
textItems = [item for item in worker.scene.items() if issubclass(type(item), QEngineeringTextItem)]
|
|
1056 |
textItems = [item for item in text_scene.items() if issubclass(type(item), QEngineeringTextItem)]
|
|
1071 | 1057 |
app_doc_data.texts.extend(textItems) |
1072 | 1058 |
app_doc_data.allItems.extend(textItems) |
1073 | 1059 | |
... | ... | |
1082 | 1068 |
TextInfo(textItem.text(), textItem.loc[0], textItem.loc[1], textItem.size[0], |
1083 | 1069 |
textItem.size[1], round(math.degrees(textItem.angle)))) |
1084 | 1070 | |
1085 |
textItem.owner = None |
|
1086 |
worker.scene.removeItem(textItem) |
|
1071 |
#textItem.owner = None
|
|
1072 |
#worker.scene.removeItem(textItem)
|
|
1087 | 1073 | |
1088 | 1074 |
worker.updateBatchProgress.emit(len(drawings), 2) |
1089 | 1075 | |
... | ... | |
2529 | 2515 |
self.obj.displayLog.connect(App.mainWnd().addMessage) |
2530 | 2516 |
self.obj.displayTitle.connect(self.displayTitle) |
2531 | 2517 |
self.obj.add_detected_items_to_scene.connect(self.add_detected_items_to_scene) |
2518 |
self.obj.add_predata_to_scene.connect(self.add_predata_to_scene) |
|
2532 | 2519 | |
2533 | 2520 |
# 4 - Connect Thread started signal to Worker operational slot method |
2534 | 2521 |
self.thread.started.connect(self.obj.procCounter) |
... | ... | |
2607 | 2594 |
finally: |
2608 | 2595 |
loop.quit() |
2609 | 2596 | |
2597 |
def add_predata_to_scene(self, drawing, scene, symbol, text, line, unknown, package) -> None: |
|
2598 |
""" add predata to scene """ |
|
2599 |
from LoadCommand import LoadCommand |
|
2600 | ||
2601 |
try: |
|
2602 |
cmd = LoadCommand() |
|
2603 |
cmd.execute((drawing, scene), symbol=symbol, text=text, line=line, unknown=unknown, |
|
2604 |
package=package ,update=False) |
|
2605 |
except Exception as ex: |
|
2606 |
from App import App |
|
2607 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
2608 |
sys.exc_info()[-1].tb_lineno) |
|
2609 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
2610 |
finally: |
|
2611 |
self.cond.wakeAll() |
|
2612 | ||
2610 | 2613 |
def add_detected_items_to_scene(self, scene) -> None: |
2611 | 2614 |
"""add detected items to scene""" |
2612 | 2615 |
from SaveWorkCommand import SaveWorkCommand |
내보내기 Unified diff