From deed458b64e6ed4a7373ab0b5b4a4b5ea10fbd74 Mon Sep 17 00:00:00 2001 From: asl Date: Wed, 6 Sep 2017 16:10:26 +0300 Subject: [PATCH] refs #1322: first implementation for center zoom under the pressed mouse roll in the georeferenced view --- src/GraphicsView/GraphicsView_ViewPort.h | 4 +++- src/GraphicsView/GraphicsView_Viewer.cxx | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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; -- 2.39.2