Salome HOME
refs #1322: first implementation for center zoom under the pressed mouse roll in...
[modules/gui.git] / src / GraphicsView / GraphicsView_Viewer.cxx
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;