]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
refs #1322: first implementation for center zoom under the pressed mouse roll in...
authorasl <asl@opencascade.com>
Wed, 6 Sep 2017 13:10:26 +0000 (16:10 +0300)
committerasl <asl@opencascade.com>
Wed, 6 Sep 2017 13:10:26 +0000 (16:10 +0300)
src/GraphicsView/GraphicsView_ViewPort.h
src/GraphicsView/GraphicsView_Viewer.cxx

index 4b5acfc2eaf637505d4c54aefd2b98bd53dedb31..303f6f8f44ac3020055dd3372cc01a48effb851f 100644 (file)
@@ -55,7 +55,9 @@ public:
     DraggingByMiddleButton = 0x0010,
     ImmediateContextMenu   = 0x0020,
     ImmediateSelection     = 0x0040,
-    Sketching              = 0x0080
+    Sketching              = 0x0080,
+
+    GlobalWheelScaling     = 0x0100
   };
   Q_DECLARE_FLAGS( InteractionFlags, InteractionFlag )
 
index ddb9b18ee76eb74250d1793f2bfc1c5766c09611..4202a633211c8a5d0b7a74d3e51ce38389b88a3c 100644 (file)
@@ -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;