개정판 18e32014
fixed issue #563:
- don't update line type according to connected items
DTI_PID/DTI_PID/ConnectAttrDialog.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 | ||
3 |
from PyQt5.QtCore import * |
|
4 |
from PyQt5.QtGui import * |
|
5 |
from PyQt5.QtWidgets import * |
|
6 |
import ConnectAttr_UI |
|
7 |
import sys |
|
8 |
import os |
|
9 |
import cv2 |
|
10 |
from AppDocData import * |
|
11 |
from LineDetector import LineDetector |
|
12 |
from EngineeringLineItem import QEngineeringLineItem |
|
13 |
from QEngineeringLineNoTextItem import QEngineeringLineNoTextItem |
|
14 |
from QEngineeringFlowArrowItem import QEngineeringFlowArrowItem |
|
15 |
from SymbolSvgItem import SymbolSvgItem |
|
16 |
from EngineeringTextItem import QEngineeringTextItem |
|
17 |
from QGraphicsBoundingBoxItem import QGraphicsBoundingBoxItem |
|
18 | ||
19 |
''' |
|
20 |
''' |
|
21 |
class Worker(QObject): |
|
22 |
from PyQt5.QtCore import QThread |
|
23 |
from PyQt5.QtWidgets import QApplication, QLabel, QWidget, QGridLayout, QListWidget |
|
24 |
from QtImageViewer import QtImageViewer |
|
25 |
import sys |
|
26 | ||
27 |
''' |
|
28 |
''' |
|
29 |
finished = pyqtSignal() |
|
30 |
intReady = pyqtSignal(int) |
|
31 |
displayMessage = pyqtSignal(str) |
|
32 |
updateProgress = pyqtSignal(int) |
|
33 | ||
34 |
''' |
|
35 |
@brief execute connecting attributes |
|
36 |
@author humkyung |
|
37 |
@date 2018.06.17 |
|
38 |
''' |
|
39 |
#pyqtSlot() |
|
40 |
def procCounter(self): # A slot takes no params |
|
41 |
from LineNoTracer import connectAttrImpl |
|
42 | ||
43 |
try: |
|
44 |
connectAttrImpl(self) |
|
45 |
except Exception as ex: |
|
46 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
47 | ||
48 |
''' |
|
49 |
''' |
|
50 |
class QConnectAttrDialog(QDialog): |
|
51 |
''' |
|
52 |
''' |
|
53 |
def __init__(self, parent, graphicsView): #Parent is MainWindow |
|
54 |
import ConnectAttr_UI |
|
55 | ||
56 |
QDialog.__init__(self, parent) |
|
57 | ||
58 |
self.parent = parent |
|
59 |
self.graphicsView = graphicsView |
|
60 |
self.ui = ConnectAttr_UI.Ui_ConnectAttr() |
|
61 |
self.ui.setupUi(self) |
|
62 |
self.ui.buttonBox.setEnabled(True) |
|
63 |
self.ui.listWidget.model().rowsInserted.connect(self.rowInserted) ## connect to func rowInserted(self, item) |
|
64 |
self.isAccepted = False |
|
65 |
|
|
66 |
self.ui.buttonBox.setEnabled(False) |
|
67 |
self.ui.progressBar.setValue(0) |
|
68 |
self.startThread() |
|
69 | ||
70 |
''' |
|
71 |
@brief QListWidget Row Inserted Listener |
|
72 |
Whenever row inserted, scroll to bottom |
|
73 |
@author Jeongwoo |
|
74 |
@date 18.04.12 |
|
75 |
''' |
|
76 |
def rowInserted(self, item): |
|
77 |
self.ui.listWidget.scrollToBottom() |
|
78 | ||
79 |
''' |
|
80 |
@brief add item to list widget |
|
81 |
@author humkyung |
|
82 |
@date 2018.06.17 |
|
83 |
''' |
|
84 |
def addListItem(self, msg): |
|
85 |
self.ui.listWidget.addItem(msg) |
|
86 | ||
87 |
def accept(self): |
|
88 |
self.isAccepted = True |
|
89 |
QDialog.accept(self) |
|
90 | ||
91 |
''' |
|
92 |
@brief update progressbar with given value |
|
93 |
@author humkyung |
|
94 |
@date 2018.06.17 |
|
95 |
@history humkyung 2018.06.27 reset value if maxValue is -1 |
|
96 |
''' |
|
97 |
def updateProgress(self, maxValue): |
|
98 |
if maxValue != -1: |
|
99 |
self.ui.progressBar.setMaximum(maxValue) |
|
100 |
self.ui.progressBar.setValue(self.ui.progressBar.value() + 1) |
|
101 |
else: |
|
102 |
self.ui.progressBar.setValue(0) |
|
103 | ||
104 |
''' |
|
105 |
@brief start thread |
|
106 |
@author humkyung |
|
107 |
@date 2018.06.17 |
|
108 |
''' |
|
109 |
def startThread(self): |
|
110 |
import timeit |
|
111 |
from LineNoTracer import connectAttrImpl |
|
112 | ||
113 |
self.ui.buttonBox.setDisabled(True) |
|
114 | ||
115 |
# 1 - create Worker and Thread inside the Form |
|
116 |
self.obj = Worker() # no parent! |
|
117 |
self.obj.graphicsView = self.graphicsView |
|
118 |
self.thread = QThread() # no parent! |
|
119 | ||
120 |
# 2 - Move the Worker object to the Thread object |
|
121 |
self.obj.moveToThread(self.thread) |
|
122 | ||
123 |
# 3 - Connect Worker Signals to the Thread slots |
|
124 |
self.obj.finished.connect(self.thread.quit) |
|
125 |
self.obj.displayMessage.connect(self.addListItem) |
|
126 |
self.obj.updateProgress.connect(self.updateProgress) |
|
127 | ||
128 |
# 4 - Connect Thread started signal to Worker operational slot method |
|
129 |
self.thread.started.connect(self.obj.procCounter) |
|
130 |
|
|
131 |
# 5 - Thread finished signal will close the app if you want! |
|
132 |
self.thread.finished.connect(self.dlgExit) |
|
133 | ||
134 |
# 6 - Start the thread |
|
135 |
self.thread.start() |
|
136 | ||
137 |
self.tmStart = timeit.default_timer() |
|
138 | ||
139 |
''' |
|
140 |
@brief set buttonbox's enabled flag |
|
141 |
@author humkyung |
|
142 |
@date 2018.06.17 |
|
143 |
@history humkyung 2018.06.17 add flow mark for pipe run |
|
144 |
humkyung 2018.08.16 don't update line type according to connected items |
|
145 |
''' |
|
146 |
def dlgExit(self): |
|
147 |
import timeit |
|
148 | ||
149 |
try: |
|
150 |
# update line type |
|
151 |
#lines = [item for item in self.graphicsView.scene.items() if type(item) is QEngineeringLineItem] |
|
152 |
#for line in lines: |
|
153 |
# line.updateLineType() |
|
154 |
# up to here |
|
155 | ||
156 |
self.ui.progressBar.setValue(self.ui.progressBar.maximum()) |
|
157 |
self.ui.buttonBox.setEnabled(True) |
|
158 |
except Exception as ex: |
|
159 |
from App import App |
|
160 | ||
161 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
162 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
163 |
finally: |
|
164 |
self.tmStop = timeit.default_timer() |
|
165 |
seconds = self.tmStop - self.tmStart |
|
166 |
self.ui.listWidget.addItem("\nRunning Time : {} min".format(str(round(seconds/60, 1))) + "\n") |
DTI_PID/DTI_PID/DTI_PID.pyproj | ||
---|---|---|
67 | 67 |
<Compile Include="QcImageViewer.py"> |
68 | 68 |
<SubType>Code</SubType> |
69 | 69 |
</Compile> |
70 |
<Compile Include="QConnectAttrDialog.py" />
|
|
70 |
<Compile Include="ConnectAttrDialog.py" /> |
|
71 | 71 |
<Compile Include="SymbolTreeWidget.py" /> |
72 | 72 |
<Compile Include="QEquipmentDataListDialog.py" /> |
73 | 73 |
<Compile Include="QInstrumentDataListDialog.py" /> |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
156 | 156 |
self.actionpdf_to_image.triggered.connect(self.onConvertPDFToImage) |
157 | 157 |
self.graphicsView.scene.changed.connect(lambda: self.resultTreeWidget.sceneChanged(self.graphicsView.scene.items())) |
158 | 158 |
self.graphicsView.scene.selectionChanged.connect(self.onSelectionChanged) |
159 |
self.actionInitialize.triggered.connect(self.initializeScene)
|
|
159 |
self.actionInitialize.triggered.connect(self.onInitializeScene)
|
|
160 | 160 |
self.resultPropertyTableWidget.cellDoubleClicked.connect(self.cellDoubleClickedEvent) |
161 | 161 |
self.actionSave.triggered.connect(self.actionSaveCliked) |
162 | 162 |
self.addMessage.connect(self.onAddMessage) |
... | ... | |
324 | 324 |
@brief Initialize scene and ResultTreeWidget |
325 | 325 |
@author Jeongwoo |
326 | 326 |
@date 2018.06.14 |
327 |
@history humkyung 2018.08.16 ask to delete recognized items before remove |
|
327 | 328 |
''' |
328 |
def initializeScene(self, action):
|
|
329 |
def onInitializeScene(self, action):
|
|
329 | 330 |
if not self.graphicsView.hasImage(): |
330 | 331 |
self.actionEquipment.setChecked(False) |
331 | 332 |
self.showImageSelectionMessageBox() |
332 | 333 |
return |
333 | 334 | |
334 |
items = self.graphicsView.scene.items() |
|
335 |
for item in items: |
|
336 |
if type(item) is not QGraphicsPixmapItem: |
|
337 |
self.graphicsView.scene.removeItem(item) |
|
338 |
|
|
339 |
if self.path is not None: |
|
340 |
baseName = os.path.basename(self.path) |
|
341 |
self.resultTreeWidget.setCurrentPID(baseName) |
|
335 |
msg = QMessageBox() |
|
336 |
msg.setIcon(QMessageBox.Critical) |
|
337 |
msg.setText("선택한 인식한 항목들을 삭제하시겠습니까?\n삭제된 항목들은 복구할 수 없습니다.") |
|
338 |
msg.setWindowTitle("항목 삭제") |
|
339 |
msg.setStandardButtons(QMessageBox.Ok|QMessageBox.Cancel) |
|
340 |
if QMessageBox.Ok == msg.exec_(): |
|
341 |
items = self.graphicsView.scene.items() |
|
342 |
for item in items: |
|
343 |
if type(item) is not QGraphicsPixmapItem: |
|
344 |
self.graphicsView.scene.removeItem(item) |
|
345 |
|
|
346 |
if self.path is not None: |
|
347 |
baseName = os.path.basename(self.path) |
|
348 |
self.resultTreeWidget.setCurrentPID(baseName) |
|
342 | 349 | |
343 | 350 |
''' |
344 | 351 |
@brief Manage Checkable Action statement |
... | ... | |
810 | 817 |
''' |
811 | 818 |
def recognizeLine(self, MainWindow): |
812 | 819 |
from LineNoTracer import LineNoTracer |
813 |
from QConnectAttrDialog import QConnectAttrDialog
|
|
820 |
from ConnectAttrDialog import QConnectAttrDialog |
|
814 | 821 | |
815 | 822 |
if not self.graphicsView.hasImage(): |
816 | 823 |
self.showImageSelectionMessageBox() |
DTI_PID/DTI_PID/QConnectAttrDialog.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
from PyQt5.QtCore import * |
|
3 |
from PyQt5.QtGui import * |
|
4 |
from PyQt5.QtWidgets import * |
|
5 |
import ConnectAttr_UI |
|
6 |
import sys |
|
7 |
import os |
|
8 |
import cv2 |
|
9 |
from AppDocData import AppDocData |
|
10 |
from LineDetector import LineDetector |
|
11 |
from EngineeringLineItem import QEngineeringLineItem |
|
12 |
from QEngineeringLineNoTextItem import QEngineeringLineNoTextItem |
|
13 |
from QEngineeringFlowArrowItem import QEngineeringFlowArrowItem |
|
14 |
from SymbolSvgItem import SymbolSvgItem |
|
15 |
from EngineeringTextItem import QEngineeringTextItem |
|
16 |
from QGraphicsBoundingBoxItem import QGraphicsBoundingBoxItem |
|
17 | ||
18 |
''' |
|
19 |
''' |
|
20 |
class Worker(QObject): |
|
21 |
from PyQt5.QtCore import QThread |
|
22 |
from PyQt5.QtWidgets import QApplication, QLabel, QWidget, QGridLayout, QListWidget |
|
23 |
from QtImageViewer import QtImageViewer |
|
24 |
import sys |
|
25 | ||
26 |
''' |
|
27 |
''' |
|
28 |
finished = pyqtSignal() |
|
29 |
intReady = pyqtSignal(int) |
|
30 |
displayMessage = pyqtSignal(str) |
|
31 |
updateProgress = pyqtSignal(int) |
|
32 | ||
33 |
''' |
|
34 |
@brief execute connecting attributes |
|
35 |
@author humkyung |
|
36 |
@date 2018.06.17 |
|
37 |
''' |
|
38 |
#pyqtSlot() |
|
39 |
def procCounter(self): # A slot takes no params |
|
40 |
from LineNoTracer import connectAttrImpl |
|
41 | ||
42 |
try: |
|
43 |
connectAttrImpl(self) |
|
44 |
except Exception as ex: |
|
45 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
46 | ||
47 |
''' |
|
48 |
''' |
|
49 |
class QConnectAttrDialog(QDialog): |
|
50 |
''' |
|
51 |
''' |
|
52 |
def __init__(self, parent, graphicsView): #Parent is MainWindow |
|
53 |
import ConnectAttr_UI |
|
54 | ||
55 |
QDialog.__init__(self, parent) |
|
56 | ||
57 |
self.parent = parent |
|
58 |
self.graphicsView = graphicsView |
|
59 |
self.ui = ConnectAttr_UI.Ui_ConnectAttr() |
|
60 |
self.ui.setupUi(self) |
|
61 |
self.ui.buttonBox.setEnabled(True) |
|
62 |
self.ui.listWidget.model().rowsInserted.connect(self.rowInserted) ## connect to func rowInserted(self, item) |
|
63 |
self.isAccepted = False |
|
64 |
|
|
65 |
self.ui.buttonBox.setEnabled(False) |
|
66 |
self.ui.progressBar.setValue(0) |
|
67 |
self.startThread() |
|
68 | ||
69 |
''' |
|
70 |
@brief QListWidget Row Inserted Listener |
|
71 |
Whenever row inserted, scroll to bottom |
|
72 |
@author Jeongwoo |
|
73 |
@date 18.04.12 |
|
74 |
''' |
|
75 |
def rowInserted(self, item): |
|
76 |
self.ui.listWidget.scrollToBottom() |
|
77 | ||
78 |
''' |
|
79 |
@brief add item to list widget |
|
80 |
@author humkyung |
|
81 |
@date 2018.06.17 |
|
82 |
''' |
|
83 |
def addListItem(self, msg): |
|
84 |
self.ui.listWidget.addItem(msg) |
|
85 | ||
86 |
def accept(self): |
|
87 |
self.isAccepted = True |
|
88 |
QDialog.accept(self) |
|
89 | ||
90 |
''' |
|
91 |
@brief update progressbar with given value |
|
92 |
@author humkyung |
|
93 |
@date 2018.06.17 |
|
94 |
@history humkyung 2018.06.27 reset value if maxValue is -1 |
|
95 |
''' |
|
96 |
def updateProgress(self, maxValue): |
|
97 |
if maxValue != -1: |
|
98 |
self.ui.progressBar.setMaximum(maxValue) |
|
99 |
self.ui.progressBar.setValue(self.ui.progressBar.value() + 1) |
|
100 |
else: |
|
101 |
self.ui.progressBar.setValue(0) |
|
102 | ||
103 |
''' |
|
104 |
@brief start thread |
|
105 |
@author humkyung |
|
106 |
@date 2018.06.17 |
|
107 |
''' |
|
108 |
def startThread(self): |
|
109 |
import timeit |
|
110 |
from LineNoTracer import connectAttrImpl |
|
111 | ||
112 |
self.ui.buttonBox.setDisabled(True) |
|
113 | ||
114 |
# 1 - create Worker and Thread inside the Form |
|
115 |
self.obj = Worker() # no parent! |
|
116 |
self.obj.graphicsView = self.graphicsView |
|
117 |
self.thread = QThread() # no parent! |
|
118 | ||
119 |
# 2 - Move the Worker object to the Thread object |
|
120 |
self.obj.moveToThread(self.thread) |
|
121 | ||
122 |
# 3 - Connect Worker Signals to the Thread slots |
|
123 |
self.obj.finished.connect(self.thread.quit) |
|
124 |
self.obj.displayMessage.connect(self.addListItem) |
|
125 |
self.obj.updateProgress.connect(self.updateProgress) |
|
126 | ||
127 |
# 4 - Connect Thread started signal to Worker operational slot method |
|
128 |
self.thread.started.connect(self.obj.procCounter) |
|
129 |
|
|
130 |
# 5 - Thread finished signal will close the app if you want! |
|
131 |
self.thread.finished.connect(self.dlgExit) |
|
132 | ||
133 |
# 6 - Start the thread |
|
134 |
self.thread.start() |
|
135 | ||
136 |
self.tmStart = timeit.default_timer() |
|
137 | ||
138 |
''' |
|
139 |
@brief set buttonbox's enabled flag |
|
140 |
@author humkyung |
|
141 |
@date 2018.06.17 |
|
142 |
@history humkyung 2018.06.17 add flow mark for pipe run |
|
143 |
''' |
|
144 |
def dlgExit(self): |
|
145 |
import timeit |
|
146 | ||
147 |
try: |
|
148 |
# update line type |
|
149 |
lines = [item for item in self.graphicsView.scene.items() if type(item) is QEngineeringLineItem] |
|
150 |
for line in lines: |
|
151 |
line.updateLineType() |
|
152 |
# up to here |
|
153 | ||
154 |
self.ui.progressBar.setValue(self.ui.progressBar.maximum()) |
|
155 |
self.ui.buttonBox.setEnabled(True) |
|
156 |
except Exception as ex: |
|
157 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
158 |
finally: |
|
159 |
self.tmStop = timeit.default_timer() |
|
160 |
seconds = self.tmStop - self.tmStart |
|
161 |
self.ui.listWidget.addItem("\nRunning Time : {} min".format(str(round(seconds/60, 1))) + "\n") |
DTI_PID/DTI_PID/SmartFEED.nsi | ||
---|---|---|
702 | 702 |
SetOutPath "$INSTDIR" |
703 | 703 |
File "dist\SmartFEED\pywintypes36.dll" |
704 | 704 |
File "dist\SmartFEED\QcImageViewer.py" |
705 |
File "dist\SmartFEED\QConnectAttrDialog.py"
|
|
705 |
File "dist\SmartFEED\ConnectAttrDialog.py" |
|
706 | 706 |
File "dist\SmartFEED\QEquipmentDataListDialog.py" |
707 | 707 |
File "dist\SmartFEED\QInstrumentDataListDialog.py" |
708 | 708 |
File "dist\SmartFEED\QLineDataListDialog.py" |
... | ... | |
3082 | 3082 |
Delete "$INSTDIR\QLineDataListDialog.py" |
3083 | 3083 |
Delete "$INSTDIR\QInstrumentDataListDialog.py" |
3084 | 3084 |
Delete "$INSTDIR\QEquipmentDataListDialog.py" |
3085 |
Delete "$INSTDIR\QConnectAttrDialog.py"
|
|
3085 |
Delete "$INSTDIR\ConnectAttrDialog.py" |
|
3086 | 3086 |
Delete "$INSTDIR\QcImageViewer.py" |
3087 | 3087 |
Delete "$INSTDIR\pywintypes36.dll" |
3088 | 3088 |
Delete "$INSTDIR\pytz\zoneinfo\Zulu" |
내보내기 Unified diff