From: mpa Date: Wed, 11 Jun 2014 07:06:57 +0000 (+0400) Subject: add zoom action when wheel is spinning X-Git-Tag: V7_5_0a1~50^2~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fc81102714b298bd8cf042153f5d2b85c683f2ea;p=modules%2Fgeom.git add zoom action when wheel is spinning --- diff --git a/src/DependencyTree/DependencyTree_View.cxx b/src/DependencyTree/DependencyTree_View.cxx index 24d9abae3..884446e6e 100644 --- a/src/DependencyTree/DependencyTree_View.cxx +++ b/src/DependencyTree/DependencyTree_View.cxx @@ -36,6 +36,7 @@ // Qt includes #include #include +#include DependencyTree_View::DependencyTree_View( QWidget* theParent ) :GraphicsView_ViewPort( theParent ), @@ -156,6 +157,23 @@ void DependencyTree_View::mouseMoveEvent( QMouseEvent *event ) } } +//================================================================================= +// function : wheelEvent() +// purpose : add zoom action when wheel is spinning +//================================================================================= +void DependencyTree_View::wheelEvent( QWheelEvent* event ) +{ + int inc = 10; // zoom coefficient + double cx = width() / 2; + double cy = height() / 2; + if( event->delta() > 0 ) + zoom( cx, cy, cx + inc, cy + inc ); + else + zoom( cx, cy, cx - inc, cy - inc ); + + QGraphicsView::wheelEvent( event ); +} + //================================================================================= // function : getViewName() // purpose : return the name of current view diff --git a/src/DependencyTree/DependencyTree_View.h b/src/DependencyTree/DependencyTree_View.h index 29d16bae5..6c606d401 100644 --- a/src/DependencyTree/DependencyTree_View.h +++ b/src/DependencyTree/DependencyTree_View.h @@ -54,7 +54,8 @@ public: void init( GraphicsView_ViewFrame* ); void updateModel( bool = true, bool = true ); - void mouseMoveEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent* event); + void wheelEvent( QWheelEvent* event ); QString getViewName() const; int getStudyId() const;