]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Corrections for VTK viewer: popup menu, rubersband
authornds <nds@opencascade.com>
Mon, 6 Aug 2007 13:29:55 +0000 (13:29 +0000)
committernds <nds@opencascade.com>
Mon, 6 Aug 2007 13:29:55 +0000 (13:29 +0000)
src/SVTK/SVTK_InteractorStyle.cxx
src/SVTK/SVTK_InteractorStyle.h
src/SVTK/SVTK_RenderWindowInteractor.cxx
src/SVTK/SVTK_RenderWindowInteractor.h

index a08315798341c767cca134f69f0c9da368445e2f..e9032bdcdbf7d7d4939cb50d9f2570a932b842a9 100644 (file)
@@ -41,6 +41,7 @@
 #include "VTKViewer_Algorithm.h"
 #include "SVTK_Functor.h"
 
+#include "SUIT_Tools.h"
 #include "SALOME_Actor.h"
 
 #include <vtkObjectFactory.h>
@@ -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() );
 }
index 8d355d79e6eb8ce7cc0f757755a6f311d49342cd..60dbf4fe6ca0e86802b47e377765428c70c75007 100644 (file)
@@ -228,6 +228,8 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle
   
   SVTK_Selector* GetSelector();
 
+  int   CurrentState() const { return State; }
+
   protected:
   SVTK_InteractorStyle();
   ~SVTK_InteractorStyle();
index 92a8ec0d5f8dc66aad5f36dc0288b909e3f1dbf9..be0ea28c7cd75bdddab3352d80068e68c7a44471 100644 (file)
@@ -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<SVTK_InteractorStyle*>( 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 );
-}
index 965a2a75194e3222b0e6fce988470454845c6d7e..51aa1ec5999cb752c57df896fe3fee3f570bce66 100644 (file)
@@ -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);