개정판 ce795f07
use rubber band for selecting area
DTI_PID/DTI_PID/Commands/AreaOcrCommand.py | ||
---|---|---|
1 | 1 |
import os.path |
2 | 2 |
import AbstractCommand |
3 | 3 |
try: |
4 |
from PyQt5.QtCore import Qt, QPoint, QPointF, QRectF, pyqtSignal, QT_VERSION_STR, QBuffer, QRect, QRegExp
|
|
5 |
from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QPainter, QColor, QPen, QBrush, QCursor, QTransform, QFont, QRegExpValidator, QValidator
|
|
6 |
from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QMessageBox
|
|
4 |
from PyQt5.QtCore import *
|
|
5 |
from PyQt5.QtGui import *
|
|
6 |
from PyQt5.QtWidgets import *
|
|
7 | 7 |
except ImportError: |
8 | 8 |
try: |
9 | 9 |
from PyQt4.QtCore import Qt, QPoint, QPointF, QRectF, pyqtSignal, QT_VERSION_STR, QBuffer, QRect, QRegExp |
... | ... | |
59 | 59 |
elif 'mouseReleaseEvent' == param[0]: |
60 | 60 |
QGraphicsView.mouseReleaseEvent(self.imageViewer, event) |
61 | 61 |
try: |
62 |
if self.imageViewer.canZoom and event.button() == Qt.LeftButton and self._shape is not None:
|
|
62 |
if self.imageViewer.canZoom and event.button() == Qt.LeftButton: |
|
63 | 63 |
self._rubberBand.hide() |
64 | 64 |
topLeft = self.imageViewer.mapToScene(self._rubberBand.geometry().topLeft()) |
65 | 65 |
bottomRight = self.imageViewer.mapToScene(self._rubberBand.geometry().bottomRight()) |
DTI_PID/DTI_PID/QtImageViewer.py | ||
---|---|---|
173 | 173 |
self._pixmapHandle.setPixmap(pixmap) |
174 | 174 |
else: |
175 | 175 |
self._pixmapHandle = self.scene.addPixmap(pixmap) |
176 |
self._pixmapHandle.setFlags(QGraphicsItem.ItemClipsChildrenToShape) |
|
176 | 177 | |
177 | 178 |
self.setSceneRect(QRectF(pixmap.rect())) # Set scene size to image size. |
178 | 179 |
self.updateViewer() |
내보내기 Unified diff