From: asv Date: Fri, 26 Aug 2005 07:05:36 +0000 (+0000) Subject: Selection (picking) with 'P' key press implemented. X-Git-Tag: BR-D5-38-2003_D2005-12-09~98 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1d266c04ecd852308ee6efe6f7061988a2c8cc88;p=modules%2Fvisu.git Selection (picking) with 'P' key press implemented. --- diff --git a/src/VVTK/VVTK_InteractorStyle.cxx b/src/VVTK/VVTK_InteractorStyle.cxx index adde9624..da7b4bcf 100644 --- a/src/VVTK/VVTK_InteractorStyle.cxx +++ b/src/VVTK/VVTK_InteractorStyle.cxx @@ -30,6 +30,7 @@ #include "VVTK_InteractorStyle.h" #include +#include #include //---------------------------------------------------------------------------- @@ -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); + } +} diff --git a/src/VVTK/VVTK_InteractorStyle.h b/src/VVTK/VVTK_InteractorStyle.h index eef18a84..2a958377 100644 --- a/src/VVTK/VVTK_InteractorStyle.h +++ b/src/VVTK/VVTK_InteractorStyle.h @@ -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