From 0dac6962abb32532e5e715bfb7eec3dbeef541ea Mon Sep 17 00:00:00 2001 From: manuels Date: Sun, 3 Jul 2022 20:27:36 +0200 Subject: [PATCH] Add suport for mouse event modifiers in occt_widget --- README.md | 4 ++-- cq_editor/widgets/occt_widget.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9e3ad17b..9c325544 100644 --- a/README.md +++ b/README.md @@ -74,8 +74,8 @@ Note that `show_object` works for `Shape` and `TopoDS_Shape` objects too. In ord The following mouse controls can be used to alter the view of the 3D object, and should be familiar to CAD users, even if the mouse buttons used may differ. * _Left Mouse Button_ + _Drag_ = Rotate -* _Middle Mouse Button_ + _Drag_ = Pan -* _Right Mouse Button_ + _Drag_ = Zoom +* _Middle Mouse Button_ + _Drag_ (or _Left Mouse Button_ + _Ctrl_) = Pan +* _Right Mouse Button_ + _Drag_ (or _Left Mouse Button_ + _Shift_) = Zoom * _Mouse Wheel_ = Zoom ### Debugging Objects diff --git a/cq_editor/widgets/occt_widget.py b/cq_editor/widgets/occt_widget.py index 172755ea..4303c0dc 100755 --- a/cq_editor/widgets/occt_widget.py +++ b/cq_editor/widgets/occt_widget.py @@ -87,14 +87,14 @@ def mouseMoveEvent(self,event): pos = event.pos() x,y = pos.x(),pos.y() - if event.buttons() == Qt.LeftButton: + if event.buttons() == Qt.LeftButton and event.modifiers() not in (Qt.ShiftModifier, Qt.ControlModifier): self.view.Rotation(x,y) - elif event.buttons() == Qt.MiddleButton: + elif event.buttons() == Qt.MiddleButton or (event.buttons() == Qt.LeftButton and event.modifiers() == Qt.ControlModifier): self.view.Pan(x - self.old_pos.x(), self.old_pos.y() - y, theToStart=True) - elif event.buttons() == Qt.RightButton: + elif event.buttons() == Qt.RightButton or (event.buttons() == Qt.LeftButton and event.modifiers() == Qt.ShiftModifier): self.view.ZoomAtPoint(self.old_pos.x(), y, x, self.old_pos.y())