From: asl Date: Wed, 6 Sep 2017 13:10:26 +0000 (+0300) Subject: refs #1322: first implementation for center zoom under the pressed mouse roll in... X-Git-Tag: v2.1.1__salome84~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=deed458b64e6ed4a7373ab0b5b4a4b5ea10fbd74;p=modules%2Fgui.git refs #1322: first implementation for center zoom under the pressed mouse roll in the georeferenced view --- diff --git a/src/GraphicsView/GraphicsView_ViewPort.h b/src/GraphicsView/GraphicsView_ViewPort.h index 4b5acfc2e..303f6f8f4 100644 --- a/src/GraphicsView/GraphicsView_ViewPort.h +++ b/src/GraphicsView/GraphicsView_ViewPort.h @@ -55,7 +55,9 @@ public: DraggingByMiddleButton = 0x0010, ImmediateContextMenu = 0x0020, ImmediateSelection = 0x0040, - Sketching = 0x0080 + Sketching = 0x0080, + + GlobalWheelScaling = 0x0100 }; Q_DECLARE_FLAGS( InteractionFlags, InteractionFlag ) diff --git a/src/GraphicsView/GraphicsView_Viewer.cxx b/src/GraphicsView/GraphicsView_Viewer.cxx index ddb9b18ee..4202a6332 100644 --- a/src/GraphicsView/GraphicsView_Viewer.cxx +++ b/src/GraphicsView/GraphicsView_Viewer.cxx @@ -521,6 +521,16 @@ void GraphicsView_Viewer::handleWheel( QGraphicsSceneWheelEvent* e ) { if( GraphicsView_ViewPort* aViewPort = getActiveViewPort() ) { + if( aViewPort->hasInteractionFlag( GraphicsView_ViewPort::GlobalWheelScaling ) ) + { + const double d = 1.05; + double q = pow( d, e->delta()/120 ); + QGraphicsView::ViewportAnchor old_anchor = aViewPort->transformationAnchor(); + aViewPort->setTransformationAnchor( QGraphicsView::AnchorUnderMouse ); + aViewPort->scale( q, q ); + aViewPort->setTransformationAnchor( old_anchor ); + } + if( aViewPort->hasInteractionFlag( GraphicsView_ViewPort::WheelScaling ) ) { bool anIsScaleUp = e->delta() > 0;