Commit 6b1d302f authored by Elvis Stansvik's avatar Elvis Stansvik
Browse files

Fix mouse wheel zooming in PyQt interactor

* Use angleDelta() if delta() does not exist (PyQt5)
* Only zoom if cumulative delta is greater/less than +/- 15 degrees
parent 3ecb4cd9
Pipeline #6467 passed with stage
......@@ -186,6 +186,7 @@ class QVTKRenderWindowInteractor(QWidget):
self.__saveY = 0
self.__saveModifiers = Qt.NoModifier
self.__saveButtons = Qt.NoButton
self.__wheelDelta = 0
# do special handling of some keywords:
# stereo, rw
......@@ -426,10 +427,17 @@ class QVTKRenderWindowInteractor(QWidget):
self._Iren.KeyReleaseEvent()
def wheelEvent(self, ev):
if ev.delta() >= 0:
self._Iren.MouseWheelForwardEvent()
if hasattr(ev, 'delta'):
self.__wheelDelta += ev.delta()
else:
self.__wheelDelta += ev.angleDelta().y()
if self.__wheelDelta >= 120:
self._Iren.MouseWheelForwardEvent()
self.__wheelDelta = 0
elif self.__wheelDelta <= -120:
self._Iren.MouseWheelBackwardEvent()
self.__wheelDelta = 0
def GetRenderWindow(self):
return self._RenderWindow
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment