mySelectionEvent(new SVTK_SelectionEvent()),
myPicker(vtkPicker::New()),
myLastHighlitedActor(NULL),
- myLastPreHighlitedActor(NULL)
+ myLastPreHighlitedActor(NULL),
+ myInteractorStyleController(SVTK_InteractorStyleController::New())
{
myPicker->Delete();
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();
}
//----------------------------------------------------------------------------
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();
}
if ( clientData ) {
vtkObject* anObject = reinterpret_cast<vtkObject*>( clientData );
SVTK_InteractorStyle* self = dynamic_cast<SVTK_InteractorStyle*>( anObject );
+ int aSpeedIncrement=self->Controller()->IncrementCurrent();
if ( self ) {
switch ( event ) {
case SVTK::SpaceMouseMoveEvent :
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:
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;
+}
#include <map>
+#include <vtkObject.h>
+//
+//-------------------------------------------
+//! 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;
typedef boost::shared_ptr<SVTK_SelectionEvent> PSelectionEvent;
+
+
//! Generate special #SVTK_SelectionEvent
virtual
SVTK_SelectionEvent*
void
OnChar();
+ //! To set current increment controller
+ void SetController(SVTK_InteractorStyleController*);
+
+ //! To get current increment controller
+ SVTK_InteractorStyleController* Controller();
+
protected:
SVTK_InteractorStyle();
~SVTK_InteractorStyle();
vtkSmartPointer<SALOME_Actor> myLastHighlitedActor;
vtkSmartPointer<SALOME_Actor> myLastPreHighlitedActor;
- //! "Increment" for pan/rotate/zoom operations
- int mySpeedIncrement;
-
+ //! "Increment" controller for pan/rotate/zoom operations
+ vtkSmartPointer<SVTK_InteractorStyleController> myInteractorStyleController;
+
// SpaceMouse short cuts
int mySMDecreaseSpeedBtn;
int mySMIncreaseSpeedBtn;