]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Selection (picking) with 'P' key press implemented.
authorasv <asv@opencascade.com>
Fri, 26 Aug 2005 07:05:36 +0000 (07:05 +0000)
committerasv <asv@opencascade.com>
Fri, 26 Aug 2005 07:05:36 +0000 (07:05 +0000)
src/VVTK/VVTK_InteractorStyle.cxx
src/VVTK/VVTK_InteractorStyle.h

index adde9624c46c36bb29f0d4367dc0eced6950c43a..da7b4bcf7eb4597b1618d0f67ed4c4aa91c70bbd 100644 (file)
@@ -30,6 +30,7 @@
 #include "VVTK_InteractorStyle.h"
 
 #include <vtkObjectFactory.h>
+#include <vtkRenderWindowInteractor.h>
 #include <vtkCommand.h>
 
 //----------------------------------------------------------------------------
@@ -37,9 +38,11 @@ vtkStandardNewMacro(VVTK_InteractorStyle);
 //----------------------------------------------------------------------------
 
 VVTK_InteractorStyle
-::VVTK_InteractorStyle() 
+::VVTK_InteractorStyle()
+  : myPickingKey( 'P' ),
+    myIsMidButtonDown( false ),
+    myIsLeftButtonDown( false )
 {
-  printf ( "\n--- VVTK_InteractorStyle created  ---\n" );
 }
 
 //----------------------------------------------------------------------------
@@ -146,3 +149,23 @@ VVTK_InteractorStyle
   if ( myIsLeftButtonDown )
     OnLeftButtonDown( ctrl, shift, x, y );
 }
+
+//----------------------------------------------------------------------------
+void  
+VVTK_InteractorStyle
+::OnKeyDown()
+{
+  char key = Interactor->GetKeyCode();
+  if ( key == myPickingKey ) {
+    int x, y;
+    Interactor->GetEventPosition( x, y ); // current mouse position (from last mouse move event or any other event)
+    FindPokedRenderer( x, y ); // calls SetCurrentRenderer
+
+    myOtherPoint = myPoint = QPoint(x, y);
+    //printf ( "--- myPoint[ %d, %d ], myOtherPoint[ %d, %d ] ---\n", myPoint.x(), myPoint.y(), myOtherPoint.x(), myOtherPoint.y() );
+
+    startOperation(VTK_INTERACTOR_STYLE_CAMERA_SELECT);
+    onFinishOperation();
+    startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
+  }
+}
index eef18a848e8bd80cfa980ebad8a8a83b9b0911ab..2a958377d66345eb1a344f1d13c838e599ec8ce7 100644 (file)
@@ -43,6 +43,8 @@ class VVTK_EXPORT VVTK_InteractorStyle : public SVTK_InteractorStyle
   static VVTK_InteractorStyle *New();
   vtkTypeMacro(VVTK_InteractorStyle, vtkInteractorStyle);
 
+  void setPickingKey( char key ) { myPickingKey = key; }
+
  protected:
   VVTK_InteractorStyle();
   ~VVTK_InteractorStyle();
@@ -54,10 +56,13 @@ class VVTK_EXPORT VVTK_InteractorStyle : public SVTK_InteractorStyle
   virtual void OnMiddleButtonDown(int ctrl, int shift, int x, int y);
   virtual void OnLeftButtonUp(int ctrl, int shift, int x, int y);
   virtual void OnMiddleButtonUp(int ctrl, int shift, int x, int y);
+  virtual void OnKeyDown();
 
  private:
   bool myIsMidButtonDown;
   bool myIsLeftButtonDown;
+
+  char myPickingKey;
 };
 
 #endif