]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
fix for GVIEW10589
authorpkv <pkv@opencascade.com>
Tue, 22 Nov 2005 08:29:55 +0000 (08:29 +0000)
committerpkv <pkv@opencascade.com>
Tue, 22 Nov 2005 08:29:55 +0000 (08:29 +0000)
src/SVTK/SVTK_InteractorStyle.cxx
src/SVTK/SVTK_InteractorStyle.h

index 4d836bb21969b9ba9e342e48d28a8f8ffca9fc12..58a95e2f22d1f6d751b01e380619994066fc03ee 100644 (file)
@@ -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<vtkObject*>( clientData );
     SVTK_InteractorStyle* self = dynamic_cast<SVTK_InteractorStyle*>( 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;
+}
index be7663d7fff23dde87de849fd84bca94c07b5379..3fb6216f41ede408b548b5d9fccf49e3094cee0a 100644 (file)
 
 #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;
 
@@ -73,6 +110,8 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle
 
   typedef boost::shared_ptr<SVTK_SelectionEvent> 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<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;