From 45d36b7a599110e43d675b4e983475d38ddf31ef Mon Sep 17 00:00:00 2001 From: pkv Date: Tue, 22 Nov 2005 08:29:55 +0000 Subject: [PATCH] fix for GVIEW10589 --- src/SVTK/SVTK_InteractorStyle.cxx | 87 ++++++++++++++++++++++++------- src/SVTK/SVTK_InteractorStyle.h | 51 ++++++++++++++++-- 2 files changed, 116 insertions(+), 22 deletions(-) diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index 4d836bb21..58a95e2f2 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -115,7 +115,8 @@ SVTK_InteractorStyle mySelectionEvent(new SVTK_SelectionEvent()), myPicker(vtkPicker::New()), myLastHighlitedActor(NULL), - myLastPreHighlitedActor(NULL) + myLastPreHighlitedActor(NULL), + myInteractorStyleController(SVTK_InteractorStyleController::New()) { myPicker->Delete(); @@ -132,10 +133,10 @@ SVTK_InteractorStyle EventCallbackCommand->SetCallback( SVTK_InteractorStyle::ProcessEvents ); // set default values of properties. user may edit them in preferences. - mySpeedIncrement = 10; mySMDecreaseSpeedBtn = 1; mySMIncreaseSpeedBtn = 2; mySMDominantCombinedSwitchBtn = 9; + myInteractorStyleController->Delete(); } //---------------------------------------------------------------------------- @@ -1222,10 +1223,12 @@ void SVTK_InteractorStyle ::onSpaceMouseButton( int button ) { - if( mySMDecreaseSpeedBtn == button ) - --mySpeedIncrement; - if( mySMIncreaseSpeedBtn == button ) - ++mySpeedIncrement; + if( mySMDecreaseSpeedBtn == button ) { + Controller()->IncrementDecrease(); + } + if( mySMIncreaseSpeedBtn == button ) { + Controller()->IncrementIncrease(); + } if( mySMDominantCombinedSwitchBtn == button ) DominantCombinedSwitch(); } @@ -1249,6 +1252,7 @@ SVTK_InteractorStyle if ( clientData ) { vtkObject* anObject = reinterpret_cast( clientData ); SVTK_InteractorStyle* self = dynamic_cast( anObject ); + int aSpeedIncrement=self->Controller()->IncrementCurrent(); if ( self ) { switch ( event ) { case SVTK::SpaceMouseMoveEvent : @@ -1258,43 +1262,43 @@ SVTK_InteractorStyle self->onSpaceMouseButton( *((int*)callData) ); return; case SVTK::PanLeftEvent: - self->IncrementalPan( -self->mySpeedIncrement, 0 ); + self->IncrementalPan(-aSpeedIncrement, 0); return; case SVTK::PanRightEvent: - self->IncrementalPan( self->mySpeedIncrement, 0 ); + self->IncrementalPan(aSpeedIncrement, 0); return; case SVTK::PanUpEvent: - self->IncrementalPan( 0, self->mySpeedIncrement ); + self->IncrementalPan(0, aSpeedIncrement); return; case SVTK::PanDownEvent: - self->IncrementalPan( 0, -self->mySpeedIncrement ); + self->IncrementalPan(0, -aSpeedIncrement); return; case SVTK::ZoomInEvent: - self->IncrementalZoom( self->mySpeedIncrement ); + self->IncrementalZoom(aSpeedIncrement); return; case SVTK::ZoomOutEvent: - self->IncrementalZoom( -self->mySpeedIncrement ); + self->IncrementalZoom(-aSpeedIncrement); return; case SVTK::RotateLeftEvent: - self->IncrementalRotate( -self->mySpeedIncrement, 0 ); + self->IncrementalRotate(-aSpeedIncrement, 0); return; case SVTK::RotateRightEvent: - self->IncrementalRotate( self->mySpeedIncrement, 0 ); + self->IncrementalRotate(aSpeedIncrement, 0); return; case SVTK::RotateUpEvent: - self->IncrementalRotate( 0, -self->mySpeedIncrement ); + self->IncrementalRotate(0, -aSpeedIncrement); return; case SVTK::RotateDownEvent: - self->IncrementalRotate( 0, self->mySpeedIncrement ); + self->IncrementalRotate(0, aSpeedIncrement); return; case SVTK::PlusSpeedIncrementEvent: - ++(self->mySpeedIncrement); + self->Controller()->IncrementIncrease(); return; case SVTK::MinusSpeedIncrementEvent: - --(self->mySpeedIncrement); + self->Controller()->IncrementDecrease(); return; case SVTK::SetSpeedIncrementEvent: - self->mySpeedIncrement = *((int*)callData); + self->Controller()->SetIncrementStartValue(*((int*)callData)); return; case SVTK::SetSMDecreaseSpeedEvent: @@ -1332,3 +1336,48 @@ SVTK_InteractorStyle void SVTK_InteractorStyle::OnChar() { } +//---------------------------------------------------------------------------- +void SVTK_InteractorStyle::SetController(SVTK_InteractorStyleController* theController) +{ + myInteractorStyleController=theController; +} +//---------------------------------------------------------------------------- +SVTK_InteractorStyleController* SVTK_InteractorStyle::Controller() +{ + return myInteractorStyleController.GetPointer(); +} + +vtkStandardNewMacro(SVTK_InteractorStyleController); +//---------------------------------------------------------------------------- +SVTK_InteractorStyleController::SVTK_InteractorStyleController() +{ + myIncrement=10; +} +//---------------------------------------------------------------------------- +SVTK_InteractorStyleController::~SVTK_InteractorStyleController() +{ +} +//---------------------------------------------------------------------------- +void SVTK_InteractorStyleController::SetIncrementStartValue(const int theValue) +{ + myIncrement=theValue; +} +//---------------------------------------------------------------------------- +int SVTK_InteractorStyleController::IncrementCurrent()const +{ + return myIncrement; +} +//---------------------------------------------------------------------------- +int SVTK_InteractorStyleController::IncrementIncrease() +{ + ++myIncrement; + return myIncrement; +} +//---------------------------------------------------------------------------- +int SVTK_InteractorStyleController::IncrementDecrease() +{ + if (myIncrement>1){ + --myIncrement; + } + return myIncrement; +} diff --git a/src/SVTK/SVTK_InteractorStyle.h b/src/SVTK/SVTK_InteractorStyle.h index be7663d7f..3fb6216f4 100644 --- a/src/SVTK/SVTK_InteractorStyle.h +++ b/src/SVTK/SVTK_InteractorStyle.h @@ -43,6 +43,43 @@ #include +#include +// +//------------------------------------------- +//! Control the value of increment in SALOME way. +/*! + This class controls of value of increment, + for pan/rotate/zoom operations in SALOME way +*/ +class SVTK_InteractorStyleController : public vtkObject{ + public: + vtkTypeMacro(SVTK_InteractorStyleController, vtkObject); + static SVTK_InteractorStyleController* New(); + + //! Set start value of increment + void SetIncrementStartValue(const int ); + + //! Get current value of increment + int IncrementCurrent()const; + + //! Increace the increment value by add 1 + virtual int IncrementIncrease(); + + //! Decreace the increment value by subtract 1 + virtual int IncrementDecrease(); + + protected: + SVTK_InteractorStyleController(); + virtual ~SVTK_InteractorStyleController(); + protected: + int myIncrement; + + private: + SVTK_InteractorStyleController(const SVTK_InteractorStyleController&); //Not implemented + void operator=(const SVTK_InteractorStyleController&); //Not implemented +}; +//------------------------------------------- + class vtkCell; class vtkPicker; @@ -73,6 +110,8 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle typedef boost::shared_ptr PSelectionEvent; + + //! Generate special #SVTK_SelectionEvent virtual SVTK_SelectionEvent* @@ -143,6 +182,12 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle void OnChar(); + //! To set current increment controller + void SetController(SVTK_InteractorStyleController*); + + //! To get current increment controller + SVTK_InteractorStyleController* Controller(); + protected: SVTK_InteractorStyle(); ~SVTK_InteractorStyle(); @@ -230,9 +275,9 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle vtkSmartPointer myLastHighlitedActor; vtkSmartPointer myLastPreHighlitedActor; - //! "Increment" for pan/rotate/zoom operations - int mySpeedIncrement; - + //! "Increment" controller for pan/rotate/zoom operations + vtkSmartPointer myInteractorStyleController; + // SpaceMouse short cuts int mySMDecreaseSpeedBtn; int mySMIncreaseSpeedBtn; -- 2.39.2