summaryrefslogtreecommitdiff
path: root/src/main/python/utils/graphics.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/python/utils/graphics.py')
-rw-r--r--src/main/python/utils/graphics.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/main/python/utils/graphics.py b/src/main/python/utils/graphics.py
index 9e1f690..aed7eed 100644
--- a/src/main/python/utils/graphics.py
+++ b/src/main/python/utils/graphics.py
@@ -1,15 +1,26 @@
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QGraphicsView
+
class customView(QGraphicsView):
- def __init__(self, scene, parent=None):
- super(customView, self).__init__(scene, parent)
+ def __init__(self, scene = None, parent=None):
+ if scene is not None:
+ super(customView, self).__init__(scene, parent)
+ else:
+ super(customView, self).__init__(parent)
self.zoom = 1
+ self.setDragMode(True)
def wheelEvent(self, QWheelEvent):
if Qt.ControlModifier:
- self.zoom += QWheelEvent.angleDelta().y()/2880
- self.scale(self.zoom, self.zoom)
+ temp = self.zoom
+ if QWheelEvent.source() == Qt.MouseEventNotSynthesized:
+ if self.zoom + QWheelEvent.angleDelta().y()/2880 > 0.1:
+ self.zoom += QWheelEvent.angleDelta().y()/2880
+ else:
+ if self.zoom + QWheelEvent.pixelDelta().y() > 0.1:
+ self.zoom += QWheelEvent.angleDelta().y()
+ self.scale(self.zoom / temp, self.zoom / temp)
QWheelEvent.accept()
else:
return super().wheelEvent(self, QWheelEvent) \ No newline at end of file