]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
0020938: EDF 1450 GEOM: center of zoom V6_2_0a2
authorvsr <vsr@opencascade.com>
Wed, 15 Dec 2010 14:53:37 +0000 (14:53 +0000)
committervsr <vsr@opencascade.com>
Wed, 15 Dec 2010 14:53:37 +0000 (14:53 +0000)
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/SVTK/SVTK_InteractorStyle.cxx
src/SVTK/SVTK_InteractorStyle.h
src/SVTK/SVTK_RenderWindowInteractor.cxx

index a8977bc2ef23b6578ea400d5df3d3a11a9f37e24..dd2952d1c7d65f4cffbafef06eaf0df290ebbb12 100755 (executable)
@@ -334,9 +334,13 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e )
     case QEvent::Wheel:
       {
         QWheelEvent* aEvent = (QWheelEvent*) e;
-        double aDelta = aEvent->delta();
-        double aScale = (aDelta < 0) ? 100./(-aDelta) : aDelta/100.;
-        myViewPort->getView()->SetZoom(aScale);
+       myViewPort->startZoomAtPoint( aEvent->x(), aEvent->y() );
+       double delta = (double)( aEvent->delta() ) / ( 15 * 8 );
+       int x  = aEvent->x();
+       int y  = aEvent->y();
+       int x1 = (int)( aEvent->x() + width()*delta/100 );
+       int y1 = (int)( aEvent->y() + height()*delta/100 );
+       myViewPort->zoom( x, y, x1, y1 );
       }
       return true;
 
index ec679bdcb1e093efaa15bdffd82f80ea3e019eee..483a3fbbb975546ce26708be487e4bf16498c9d3 100644 (file)
@@ -430,6 +430,26 @@ void SVTK_InteractorStyle::OnRightButtonUp()
                          x, y );
 }
 
+/*!
+  To handle mouse wheel forward event (reimplemented from #vtkInteractorStyle)
+*/
+void SVTK_InteractorStyle::OnMouseWheelForward()
+{
+  int x, y;
+  GetEventPosition( this->Interactor, x, y );
+  myOtherPoint = QPoint(x, y);
+}
+
+/*!
+  To handle mouse wheel backward event (reimplemented from #vtkInteractorStyle)
+*/
+void SVTK_InteractorStyle::OnMouseWheelBackward()
+{
+  int x, y;
+  GetEventPosition( this->Interactor, x, y );
+  myOtherPoint = QPoint(x, y);
+}
+
 /*!
   To handle mouse move event
 */
index 4eac463ce4c7e77e0f6844cf30bb31b8df89b27d..88f523509f83fec9417e8604d02a8e6ac4244a9f 100644 (file)
@@ -201,6 +201,12 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle
   //! To handle right mouse button up event (reimplemented from #vtkInteractorStyle)
   virtual void OnRightButtonUp();
 
+  //! To handle mouse wheel forward event (reimplemented from #vtkInteractorStyle)
+  virtual void OnMouseWheelForward();
+
+  //! To handle mouse wheel backward event (reimplemented from #vtkInteractorStyle)
+  virtual void OnMouseWheelBackward();
+
   //! To handle keyboard event (reimplemented from #vtkInteractorStyle)
   virtual void OnChar();
 
index eef4ade04e6daf74aa0fec284246eb5f546ad941..4835c94e0345b40a6c6b42f02184974b2b3c81e9 100644 (file)
@@ -320,6 +320,14 @@ QVTK_RenderWindowInteractor
 {
   activateWindow();
   setFocus();
+  GetDevice()->SetEventInformationFlipY(event->x(), 
+                                        event->y(),
+                                        event->modifiers() & Qt::ControlModifier,
+                                        event->modifiers() & Qt::ShiftModifier);
+  if ( event->delta()>0)
+    GetDevice()->MouseWheelForwardEvent();
+  else
+    GetDevice()->MouseWheelBackwardEvent();
 }