1 |
1 |
import os.path
|
|
2 |
"""
|
|
3 |
This is OriginalPointCommand module
|
|
4 |
"""
|
|
5 |
|
|
6 |
import sys
|
2 |
7 |
import AbstractCommand
|
3 |
8 |
try:
|
4 |
|
from PyQt5.QtCore import Qt, QPoint, QPointF, QRectF, pyqtSignal, QT_VERSION_STR
|
|
9 |
from PyQt5.QtCore import Qt, QPointF, QRectF, pyqtSignal
|
5 |
10 |
from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QColor, QPen, QBrush, QTransform, QCursor
|
6 |
11 |
from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QMessageBox, QGraphicsEllipseItem
|
7 |
12 |
except ImportError:
|
8 |
13 |
try:
|
9 |
14 |
from PyQt4.QtCore import Qt, QPoint, QPointF, QRectF, pyqtSignal, QT_VERSION_STR
|
10 |
|
from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog, QColor, QPen, QBrush, QCursor
|
11 |
|
from PyQt4.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QMessageBox, QGraphicsEllipseItem
|
|
15 |
from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap
|
|
16 |
from PyQt4.QtGui import QPainterPath, QFileDialog, QColor, QPen, QBrush, QCursor
|
|
17 |
from PyQt4.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog
|
|
18 |
from PyQt4.QtWidgets import QMessageBox, QGraphicsEllipseItem
|
12 |
19 |
except ImportError:
|
13 |
20 |
raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.")
|
14 |
21 |
|
15 |
|
import sys
|
16 |
|
|
17 |
22 |
class OriginalPointCommand(AbstractCommand.AbstractCommand):
|
|
23 |
"""
|
|
24 |
OriginalPointCommand class
|
|
25 |
"""
|
18 |
26 |
onSuccess = pyqtSignal()
|
19 |
27 |
|
20 |
28 |
'''
|
... | ... | |
22 |
30 |
'''
|
23 |
31 |
def __init__(self, imageViewer, originalPointLineEdit):
|
24 |
32 |
super(OriginalPointCommand, self).__init__(imageViewer)
|
25 |
|
self.name = 'OriginalPoint'
|
|
33 |
self.name = 'OriginalPoint'
|
26 |
34 |
self.originalPointLineEdit = originalPointLineEdit
|
27 |
35 |
self.isSelected = False
|
28 |
36 |
self.imageViewer.setCursor(QCursor(Qt.CrossCursor))
|
... | ... | |
51 |
59 |
if event.button() == Qt.LeftButton:
|
52 |
60 |
if not self.isSelected:
|
53 |
61 |
if self.isOnImage(newScenePos.x(), newScenePos.y()):
|
54 |
|
OriginalPointCommand.drawCircle(self.imageViewer, newScenePos.x(), newScenePos.y())
|
|
62 |
origin = OriginalPointCommand.drawCircle(self.imageViewer, newScenePos.x(), newScenePos.y())
|
55 |
63 |
self.isSelected = True
|
56 |
64 |
self.originalPointLineEdit.setText("{},{}".format(newScenePos.x(), newScenePos.y()))
|
57 |
65 |
self.imageViewer.isOriginalPointSelected = True
|
58 |
|
self.onSuccess.emit()
|
|
66 |
self.onSuccess.emit(origin)
|
59 |
67 |
else:
|
60 |
68 |
QMessageBox.about(self.imageViewer, "알림", "심볼 내부를 선택해주세요.")
|
61 |
69 |
|
... | ... | |
74 |
82 |
@history 2018.06.11 Jeongwoo Shorten method to add Ellipse
|
75 |
83 |
2018.06.12 Jeongwoo Modify RectF's coords
|
76 |
84 |
humkyung 2018.08.28 draw guide lines for origin point
|
|
85 |
humkyung 2018.10.02 return origin point
|
77 |
86 |
'''
|
78 |
87 |
@staticmethod
|
79 |
88 |
def drawCircle(imageViewer, x, y):
|
... | ... | |
96 |
105 |
|
97 |
106 |
imageViewer.scene.addItem(origin)
|
98 |
107 |
|
|
108 |
return origin
|
|
109 |
|
99 |
110 |
'''
|
100 |
111 |
@history 2018.06.12 Jeongwoo Add conditions for selecting ellipse item
|
101 |
112 |
'''
|