개정판 42e5fdf3
return to default command when user click mouse right button
DTI_PID/DTI_PID/Commands/AreaOcrCommand.py | ||
---|---|---|
21 | 21 |
|
22 | 22 |
class AreaOcrCommand(AbstractCommand.AbstractCommand): |
23 | 23 |
onSuccess = pyqtSignal(float, float, float, float) |
24 |
onRejected = pyqtSignal(AbstractCommand.AbstractCommand) |
|
24 | 25 |
|
25 | 26 |
def __init__(self, imageViewer): |
26 | 27 |
super(AreaOcrCommand, self).__init__(imageViewer) |
... | ... | |
57 | 58 |
self.onSuccess.emit(rect.left(), rect.top(), rect.width(), rect.height()) |
58 | 59 |
else: |
59 | 60 |
QMessageBox.about(self.imageViewer, "알림", "부적절한 이미지입니다.\n이미지를 확인해주세요.") |
61 |
elif event.button() == Qt.RightButton: |
|
62 |
self.onRejected.emit(self) |
|
60 | 63 |
finally: |
61 | 64 |
self.imageViewer.setDragMode(QGraphicsView.NoDrag) |
62 | 65 |
pass |
DTI_PID/DTI_PID/Commands/AreaZoomCommand.py | ||
---|---|---|
12 | 12 |
raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.") |
13 | 13 |
|
14 | 14 |
class AreaZoomCommand(AbstractCommand.AbstractCommand): |
15 |
onRejected = pyqtSignal(AbstractCommand.AbstractCommand) |
|
16 |
|
|
15 | 17 |
''' |
16 | 18 |
@history 2018.06.27 Jeongwoo Add variables [startPoint, endPoint] |
17 | 19 |
''' |
... | ... | |
29 | 31 |
def execute(self, param): |
30 | 32 |
event = param[1] |
31 | 33 |
scenePos = param[2] |
34 |
|
|
35 |
self.isTreated = False |
|
32 | 36 |
if 'mousePressEvent' == param[0]: |
33 | 37 |
if self.imageViewer.canZoom: |
34 | 38 |
if event.button() == Qt.LeftButton: |
... | ... | |
51 | 55 |
self.endPoint.x() - self.startPoint.x(), |
52 | 56 |
self.endPoint.y() - self.startPoint.y())) |
53 | 57 |
self.imageViewer.updateViewer() |
58 |
elif event.button() == Qt.RightButton: |
|
59 |
self.onRejected.emit(self) |
|
54 | 60 |
finally: |
55 | 61 |
self.imageViewer.setDragMode(QGraphicsView.NoDrag) |
56 | 62 |
pass |
57 |
self.isTreated = False |
|
58 | 63 |
|
59 | 64 |
def undo(self): |
60 | 65 |
pass |
DTI_PID/DTI_PID/Commands/PlaceLineCommand.py | ||
---|---|---|
73 | 73 |
pass |
74 | 74 |
elif 'mouseReleaseEvent' == param[0] and event.button() == Qt.RightButton and self._polyline is not None: |
75 | 75 |
self.onSuccess.emit() |
76 |
elif 'mouseReleaseEvent' == param[0] and event.button() == Qt.RightButton and self._polyline is None: |
|
77 |
self.onRejected.emit(self) |
|
76 | 78 |
elif 'mouseMoveEvent' == param[0] and self._polyline is not None: |
77 | 79 |
self._polyline.onMouseMoved(event, param[2]) |
78 | 80 |
elif 'keyPressEvent' == param[0]: |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
137 | 137 |
self.actionLineRecognition.triggered.connect(self.recognizeLine) |
138 | 138 |
self.actionArea.triggered.connect(self.areaConfiguration) |
139 | 139 |
self.actionConfiguration.triggered.connect(self.configuration) |
140 |
self.actionOCR.triggered.connect(self.areaOcr)
|
|
140 |
self.actionOCR.triggered.connect(self.onAreaOcr)
|
|
141 | 141 |
self.actionGenerateOutput.triggered.connect(self.generateOutput) |
142 | 142 |
self.pushButtonCreateSymbol.clicked.connect(self.createSymbol) |
143 | 143 |
self.pushButtonClearLog.clicked.connect(self.onClearLog) |
... | ... | |
151 | 151 |
self.actionViewSymbol.triggered.connect(self.onViewSymbol) |
152 | 152 |
self.actionViewLine.triggered.connect(self.onViewLine) |
153 | 153 |
self.actionViewUnknown.triggered.connect(self.onViewUnknown) |
154 |
self.actionZoom.triggered.connect(self.areaZoom)
|
|
154 |
self.actionZoom.triggered.connect(self.onAreaZoom)
|
|
155 | 155 |
self.actionFitWindow.triggered.connect(self.fitWindow) |
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())) |
... | ... | |
268 | 268 |
@brief Area Zoom |
269 | 269 |
@author Jeongwoo |
270 | 270 |
@date 2018.06.27 |
271 |
@history connect command's rejected signal |
|
271 | 272 |
''' |
272 |
def areaZoom(self, action):
|
|
273 |
def onAreaZoom(self, action):
|
|
273 | 274 |
if self.actionZoom.isChecked(): |
274 |
self.graphicsView.command = AreaZoomCommand.AreaZoomCommand(self.graphicsView) |
|
275 |
cmd = AreaZoomCommand.AreaZoomCommand(self.graphicsView) |
|
276 |
cmd.onRejected.connect(self.onCommandRejected) |
|
277 |
self.graphicsView.command = cmd |
|
275 | 278 |
|
276 | 279 |
''' |
277 | 280 |
@brief Fit Window |
... | ... | |
385 | 388 |
@history 2018.05.02 Jeongwoo Change graphicsView.command by actionOCR checked state |
386 | 389 |
Show MessageBox when imageviewer doesn't have image |
387 | 390 |
''' |
388 |
def areaOcr(self):
|
|
391 |
def onAreaOcr(self):
|
|
389 | 392 |
if not self.graphicsView.hasImage(): |
390 | 393 |
self.actionOCR.setChecked(False) |
391 | 394 |
self.showImageSelectionMessageBox() |
... | ... | |
394 | 397 |
if self.actionOCR.isChecked(): |
395 | 398 |
cmd = AreaOcrCommand.AreaOcrCommand(self.graphicsView) |
396 | 399 |
cmd.onSuccess.connect(self.onRecognizeText) |
400 |
cmd.onRejected.connect(self.onCommandRejected) |
|
397 | 401 |
self.graphicsView.command = cmd |
398 | 402 |
else: |
399 | 403 |
self.graphicsView.useDefaultCommand() |
... | ... | |
734 | 738 |
''' |
735 | 739 |
def onCommandRejected(self, cmd): |
736 | 740 |
try: |
737 |
if cmd is self.actionLine.tag:
|
|
741 |
if type(cmd) is PlaceLineCommand.PlaceLineCommand:
|
|
738 | 742 |
self.graphicsView.scene.removeItem(self.actionLine.tag._polyline) |
739 | 743 |
self.graphicsView.scene.update() |
740 | 744 |
self.actionLine.tag.reset() |
741 | 745 |
|
742 | 746 |
self.actionLine.setChecked(False) |
747 |
elif type(cmd) is AreaZoomCommand.AreaZoomCommand: |
|
748 |
self.actionZoom.setChecked(False) |
|
749 |
elif type(cmd) is AreaOcrCommand.AreaOcrCommand: |
|
750 |
self.actionOCR.setChecked(False) |
|
743 | 751 |
finally: |
744 | 752 |
self.graphicsView.useDefaultCommand() |
745 | 753 |
|
내보내기 Unified diff