From: vsr Date: Wed, 15 Dec 2010 14:53:37 +0000 (+0000) Subject: 0020938: EDF 1450 GEOM: center of zoom X-Git-Tag: V6_2_0a2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=55d2d2728c9334c41bef85f95f9b2f6171ab50cd;p=modules%2Fgui.git 0020938: EDF 1450 GEOM: center of zoom --- diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index a8977bc2e..dd2952d1c 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -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; diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index ec679bdcb..483a3fbbb 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -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 */ diff --git a/src/SVTK/SVTK_InteractorStyle.h b/src/SVTK/SVTK_InteractorStyle.h index 4eac463ce..88f523509 100644 --- a/src/SVTK/SVTK_InteractorStyle.h +++ b/src/SVTK/SVTK_InteractorStyle.h @@ -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(); diff --git a/src/SVTK/SVTK_RenderWindowInteractor.cxx b/src/SVTK/SVTK_RenderWindowInteractor.cxx index eef4ade04..4835c94e0 100644 --- a/src/SVTK/SVTK_RenderWindowInteractor.cxx +++ b/src/SVTK/SVTK_RenderWindowInteractor.cxx @@ -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(); }