개정판 95e16526
Hand/Crop merge 처리중
DTI_PID/DTI_PID/Commands/CropCommand.py | ||
---|---|---|
20 | 20 |
@brief crop image by rectangle selected by user |
21 | 21 |
''' |
22 | 22 |
def execute(self, param): |
23 |
if 'mousePressEvent' == param[0]: |
|
23 |
event = param[1] |
|
24 |
scenePos = param[2] |
|
25 |
if 'mousePressEvent' == param[0] and event.button() == Qt.LeftButton: |
|
24 | 26 |
self.imageViewer.setDragMode(QGraphicsView.RubberBandDrag) |
25 |
elif 'mouseReleaseEvent' == param[0]: |
|
27 |
self.imageViewer.leftMouseButtonPressed.emit(scenePos.x(), scenePos.y()) |
|
28 |
#QGraphicsView.mousePressEvent(self.imageViewer, event) |
|
29 |
elif 'mouseReleaseEvent' == param[0] and event.button() == Qt.LeftButton: |
|
26 | 30 |
try: |
27 | 31 |
viewBBox = self.imageViewer.zoomStack[-1] if len(self.imageViewer.zoomStack) else self.imageViewer.sceneRect() |
28 | 32 |
selectionBBox = self.imageViewer.scene.selectionArea().boundingRect().intersected(viewBBox) |
29 | 33 |
if selectionBBox.isValid(): |
30 | 34 |
croppedImage = self.imageViewer.image().copy(selectionBBox.toAlignedRect()) |
31 | 35 |
self.imageViewer.setImage(croppedImage) |
36 |
self.imageViewer.setDragMode(QGraphicsView.NoDrag) |
|
32 | 37 |
finally: |
38 |
self.imageViewer.leftMouseButtonReleased.emit(scenePos.x(), scenePos.y()) |
|
39 |
#QGraphicsView.mouseReleaseEvent(self.imageViewer, event) |
|
33 | 40 |
pass |
34 | 41 | |
35 | 42 |
def undo(self): |
DTI_PID/DTI_PID/Commands/EraserCommand.py | ||
---|---|---|
21 | 21 |
''' |
22 | 22 |
def execute(self, param): |
23 | 23 |
print(param[0]) |
24 |
event = param[1] |
|
24 | 25 |
if 'mousePressEvent' == param[0]: |
25 | 26 |
self.drawPixel(param[2]) |
27 |
QGraphicsView.mousePressEvent(self.imageViewer, event) |
|
26 | 28 |
elif 'mouseReleaseEvent' == param[0]: |
27 | 29 |
try: |
28 | 30 |
self.imageViewer.setDragMode(QGraphicsView.NoDrag) |
29 | 31 |
finally: |
32 |
QGraphicsView.mouseReleaseEvent(self.imageViewer, event) |
|
30 | 33 |
pass |
31 | 34 |
elif 'mouseMoveEvent' == param[0]: |
32 |
self.drawPixel(param[2]) |
|
35 |
if event.buttons() == Qt.LeftButton: |
|
36 |
self.drawPixel(param[2]) |
|
37 |
#self.imageViewer.super(QtImageViewer, self).mouseMoveEvent(event) |
|
33 | 38 |
elif 'mouseRightMoveEvent' == param[0]: |
34 | 39 |
pass |
35 | 40 |
DTI_PID/DTI_PID/Commands/HandCommand.py | ||
---|---|---|
20 | 20 |
@brief pan image by left click and drag |
21 | 21 |
''' |
22 | 22 |
def execute(self, param): |
23 |
if 'mousePressEvent' == param[0]: |
|
23 |
event = param[1] |
|
24 |
scenePos = param[2] |
|
25 |
if 'mousePressEvent' == param[0] and event.button() == Qt.LeftButton: |
|
24 | 26 |
if self.imageViewer.canPan: |
25 | 27 |
self.imageViewer.setDragMode(QGraphicsView.ScrollHandDrag) |
26 |
elif 'mouseReleaseEvent' == param[0]: |
|
28 | ||
29 |
self.imageViewer.leftMouseButtonPressed.emit(scenePos.x(), scenePos.y()) |
|
30 |
#QGraphicsView.mousePressEvent(self.imageViewer, event) |
|
31 |
elif 'mouseReleaseEvent' == param[0] and event.button() == Qt.LeftButton: |
|
27 | 32 |
try: |
28 | 33 |
self.imageViewer.setDragMode(QGraphicsView.NoDrag) |
29 | 34 |
finally: |
35 |
self.imageViewer.leftMouseButtonReleased.emit(scenePos.x(), scenePos.y()) |
|
36 |
#QGraphicsView.mouseReleaseEvent(self.imageViewer, event) |
|
30 | 37 |
pass |
31 | 38 | |
32 | 39 |
def undo(self): |
DTI_PID/DTI_PID/Commands/PenCommand.py | ||
---|---|---|
21 | 21 |
''' |
22 | 22 |
def execute(self, param): |
23 | 23 |
print(param[0]) |
24 |
event = param[1] |
|
24 | 25 |
if 'mousePressEvent' == param[0]: |
25 | 26 |
self.drawPixel(param[2]) |
27 |
QGraphicsView.mousePressEvent(self.imageViewer, event) |
|
26 | 28 |
elif 'mouseReleaseEvent' == param[0]: |
27 | 29 |
try: |
28 | 30 |
self.imageViewer.setDragMode(QGraphicsView.NoDrag) |
29 | 31 |
finally: |
32 |
QGraphicsView.mouseReleaseEvent(self.imageViewer, event) |
|
30 | 33 |
pass |
31 | 34 |
elif 'mouseMoveEvent' == param[0]: |
32 |
self.drawPixel(param[2]) |
|
35 |
if event.buttons() == Qt.LeftButton: |
|
36 |
self.drawPixel(param[2]) |
|
37 |
#self.imageViewer.super(QtImageViewer, self).mouseMoveEvent(event) |
|
33 | 38 |
elif 'mouseRightMoveEvent' == param[0]: |
34 | 39 |
pass |
35 | 40 |
DTI_PID/DTI_PID/Commands/ZoomCommand.py | ||
---|---|---|
20 | 20 |
@brief pan image by left click and drag |
21 | 21 |
''' |
22 | 22 |
def execute(self, param): |
23 |
event = param[1] |
|
23 | 24 |
if 'mousePressEvent' == param[0]: |
24 | 25 |
if self.imageViewer.canZoom: |
25 |
self.zoomImage(True, param[1]) |
|
26 |
if (event.button() == Qt.RightButton): |
|
27 |
self.zoomImage(False, event.pos()) |
|
28 |
else: |
|
29 |
self.zoomImage(True, event.pos()) |
|
30 |
QGraphicsView.mousePressEvent(self.imageViewer, event) |
|
26 | 31 |
elif 'mouseReleaseEvent' == param[0]: |
27 | 32 |
try: |
28 | 33 |
self.imageViewer.setDragMode(QGraphicsView.NoDrag) |
29 | 34 |
finally: |
35 |
QGraphicsView.mouseReleaseEvent(self.imageViewer, event) |
|
30 | 36 |
pass |
31 |
elif 'mouseRightPressEvent': |
|
32 |
if self.imageViewer.canZoom: |
|
33 |
self.zoomImage(False, param[1]) |
|
34 | 37 | |
35 | 38 |
def undo(self): |
36 | 39 |
pass |
DTI_PID/DTI_PID/DTI_PID.pyproj | ||
---|---|---|
4 | 4 |
<SchemaVersion>2.0</SchemaVersion> |
5 | 5 |
<ProjectGuid>7c2e55a3-2b16-4b4f-867f-f16e2ef6f2f0</ProjectGuid> |
6 | 6 |
<ProjectHome>.</ProjectHome> |
7 |
<StartupFile>DTI_PID.py</StartupFile>
|
|
7 |
<StartupFile>SymbolGenerator.py</StartupFile>
|
|
8 | 8 |
<SearchPath> |
9 | 9 |
</SearchPath> |
10 | 10 |
<WorkingDirectory>.</WorkingDirectory> |
DTI_PID/DTI_PID/QtImageViewer.py | ||
---|---|---|
200 | 200 |
self.scene.update() |
201 | 201 |
return |
202 | 202 | |
203 |
super(QtImageViewer, self).mouseMoveEvent(event) |
|
204 | ||
205 | 203 |
def mousePressEvent(self, event): |
206 | 204 |
""" Start mouse pan or zoom mode. |
207 | 205 |
""" |
... | ... | |
223 | 221 |
self.command.execute(['mouseRightPressEvent', event.pos(), scenePos]) |
224 | 222 |
self.rightMouseButtonPressed.emit(scenePos.x(), scenePos.y()) |
225 | 223 |
''' |
226 |
QGraphicsView.mousePressEvent(self, event) |
|
227 | 224 | |
228 | 225 |
def mouseReleaseEvent(self, event): |
229 | 226 |
""" Stop mouse pan or zoom mode (apply zoom if valid). |
내보내기 Unified diff