From: nds Date: Mon, 6 Aug 2007 13:29:55 +0000 (+0000) Subject: Corrections for VTK viewer: popup menu, rubersband X-Git-Tag: qt4_porting_delivery_220807~49 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=af45ff9033c5272cda764a408bf8649e0561f2cd;p=modules%2Fgui.git Corrections for VTK viewer: popup menu, rubersband --- diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index a08315798..e9032bdcd 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -41,6 +41,7 @@ #include "VTKViewer_Algorithm.h" #include "SVTK_Functor.h" +#include "SUIT_Tools.h" #include "SALOME_Actor.h" #include @@ -1503,7 +1504,7 @@ SVTK_InteractorStyle } myRectBand->hide(); - QRect aRect(myPoint, myOtherPoint); + QRect aRect = SUIT_Tools::makeRect(myPoint.x(), myPoint.y(), myOtherPoint.x(), myOtherPoint.y()); myRectBand->setGeometry( aRect ); myRectBand->setVisible( aRect.isValid() ); } diff --git a/src/SVTK/SVTK_InteractorStyle.h b/src/SVTK/SVTK_InteractorStyle.h index 8d355d79e..60dbf4fe6 100644 --- a/src/SVTK/SVTK_InteractorStyle.h +++ b/src/SVTK/SVTK_InteractorStyle.h @@ -228,6 +228,8 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle SVTK_Selector* GetSelector(); + int CurrentState() const { return State; } + protected: SVTK_InteractorStyle(); ~SVTK_InteractorStyle(); diff --git a/src/SVTK/SVTK_RenderWindowInteractor.cxx b/src/SVTK/SVTK_RenderWindowInteractor.cxx index 92a8ec0d5..be0ea28c7 100644 --- a/src/SVTK/SVTK_RenderWindowInteractor.cxx +++ b/src/SVTK/SVTK_RenderWindowInteractor.cxx @@ -711,8 +711,22 @@ void SVTK_RenderWindowInteractor ::mouseReleaseEvent( QMouseEvent *event ) { + bool aRightBtn = event->button() == Qt::RightButton; + bool isOperation = false; + if( aRightBtn && GetInteractorStyle()) { + SVTK_InteractorStyle* style = dynamic_cast( GetInteractorStyle() ); + if ( style ) + isOperation = style->CurrentState() != VTK_INTERACTOR_STYLE_CAMERA_NONE; + } + QVTK_RenderWindowInteractor::mouseReleaseEvent(event); + if ( aRightBtn && !isOperation && !( event->modifiers() & Qt::ControlModifier ) && + !( event->modifiers() & Qt::ShiftModifier ) ) { + QContextMenuEvent aEvent( QContextMenuEvent::Mouse, + event->pos(), event->globalPos() ); + emit contextMenuRequested( &aEvent ); + } if(GENERATE_SUIT_EVENTS) emit MouseButtonReleased( event ); } @@ -776,13 +790,3 @@ SVTK_RenderWindowInteractor emit KeyReleased( event ); } -/*! - Custom context menu event handler -*/ -void -SVTK_RenderWindowInteractor -::contextMenuEvent( QContextMenuEvent* event ) -{ - if( !( event->modifiers() & Qt::KeyboardModifierMask ) ) - emit contextMenuRequested( event ); -} diff --git a/src/SVTK/SVTK_RenderWindowInteractor.h b/src/SVTK/SVTK_RenderWindowInteractor.h index 965a2a751..51aa1ec59 100644 --- a/src/SVTK/SVTK_RenderWindowInteractor.h +++ b/src/SVTK/SVTK_RenderWindowInteractor.h @@ -221,7 +221,6 @@ class SVTK_EXPORT SVTK_RenderWindowInteractor: public QVTK_RenderWindowInteracto virtual void wheelEvent( QWheelEvent* ); virtual void keyPressEvent( QKeyEvent* ); virtual void keyReleaseEvent( QKeyEvent* ); - virtual void contextMenuEvent( QContextMenuEvent * e ); void SetRenderer(SVTK_Renderer *theRenderer);