]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
To customize SpaceMause interaction
authorapo <apo@opencascade.com>
Wed, 5 Oct 2005 14:03:33 +0000 (14:03 +0000)
committerapo <apo@opencascade.com>
Wed, 5 Oct 2005 14:03:33 +0000 (14:03 +0000)
(introduce magnification functionality)

src/SVTK/SVTK_Event.h
src/SVTK/SVTK_InteractorStyle.cxx
src/SVTK/SVTK_InteractorStyle.h

index 460b7d3f5cf9ac84dc6e4ff63926083f02189950..f4c1c42eccc98a236c7b7d57f63002561809c92e 100644 (file)
 //
 //
 //
-//  File   : SVTK_SpaceMouseEvent.h
+//  File   : 
 //  Author : Alexander SLADKOV
 //  Module : SALOME
 //  $Header$
 
-#ifndef SVTK_SpaceMouseEvent_h
-#define SVTK_SpaceMouseEvent_h
+#ifndef SVTK_Event_h
+#define SVTK_Event_h
 
 #include <vtkCommand.h>
 
@@ -51,11 +51,9 @@ namespace SVTK
     MinusSpeedIncrementEvent,
     SetSpeedIncrementEvent,
 
-    SetSpaceMouseF1Event,
-    SetSpaceMouseF2Event,
-    SetSpaceMouseF3Event,
-    SetSpaceMouseF4Event,
-    SetSpaceMouseF5Event,
+    SetSMDecreaseSpeedEvent,
+    SetSMIncreaseSpeedEvent,
+    SetSMDominantCombinedSwitchEvent,
 
     StartZoom,
     StartPan,
index ff4bb77fb53b88ac68c3a48f5337bed3a3848f26..52da7f3b76db5e02605aaf17b772d40b633d21d7 100644 (file)
@@ -117,11 +117,9 @@ SVTK_InteractorStyle
 
   // set default values of properties.  user may edit them in preferences.
   mySpeedIncrement = 10;
-  mySpaceMouseBtns[0] = 1;
-  mySpaceMouseBtns[1] = 2;
-  mySpaceMouseBtns[2] = 10;
-  mySpaceMouseBtns[3] = 11;
-  mySpaceMouseBtns[4] = 9;
+  mySMDecreaseSpeedBtn = 1;
+  mySMIncreaseSpeedBtn = 2;
+  mySMDominantCombinedSwitchBtn = 9;
 }
 
 //----------------------------------------------------------------------------
@@ -1145,11 +1143,11 @@ SVTK_InteractorStyle
 ::SetInteractor( vtkRenderWindowInteractor* theInteractor )
 {
   // register EventCallbackCommand as observer of standard events (keypress, mousemove, etc)
-  vtkInteractorStyle::SetInteractor( theInteractor );
+  Superclass::SetInteractor( theInteractor );
  
   myInteractor = dynamic_cast<SVTK_GenericRenderWindowInteractor*>(theInteractor);
 
-  if ( myInteractor.GetPointer() ) { 
+  if(theInteractor) { 
     // register EventCallbackCommand as observer of custorm event (3d space mouse event)
     theInteractor->AddObserver( SVTK::SpaceMouseMoveEvent, EventCallbackCommand, Priority );
     theInteractor->AddObserver( SVTK::SpaceMouseButtonEvent, EventCallbackCommand, Priority );
@@ -1167,11 +1165,9 @@ SVTK_InteractorStyle
     theInteractor->AddObserver( SVTK::MinusSpeedIncrementEvent, EventCallbackCommand, Priority );
     theInteractor->AddObserver( SVTK::SetSpeedIncrementEvent, EventCallbackCommand, Priority );
 
-    theInteractor->AddObserver( SVTK::SetSpaceMouseF1Event, EventCallbackCommand, Priority );
-    theInteractor->AddObserver( SVTK::SetSpaceMouseF2Event, EventCallbackCommand, Priority );
-    theInteractor->AddObserver( SVTK::SetSpaceMouseF3Event, EventCallbackCommand, Priority );
-    theInteractor->AddObserver( SVTK::SetSpaceMouseF4Event, EventCallbackCommand, Priority );
-    theInteractor->AddObserver( SVTK::SetSpaceMouseF5Event, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::SetSMDecreaseSpeedEvent, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::SetSMIncreaseSpeedEvent, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::SetSMDominantCombinedSwitchEvent, EventCallbackCommand, Priority );
 
     theInteractor->AddObserver( SVTK::StartZoom, EventCallbackCommand, Priority );
     theInteractor->AddObserver( SVTK::StartPan, EventCallbackCommand, Priority );
@@ -1204,9 +1200,6 @@ void
 SVTK_InteractorStyle
 ::onSpaceMouseMove( double* data )
 {
-  //  printf( "x=%+5.0lf y=%+5.0lf z=%+5.0lf a=%+5.0lf b=%+5.0lf c=%+5.0lf\n",
-  //     data[0], data[1], data[2], data[3], data[4], data[5] );
-  
   // general things, do SetCurrentRenderer() within FindPokedRenderer() 
   int x, y;
   GetEventPosition( this->Interactor, x, y ); // current mouse position (from last mouse move event or any other event)
@@ -1222,27 +1215,12 @@ void
 SVTK_InteractorStyle
 ::onSpaceMouseButton( int button )
 {
-  if ( mySpaceMouseBtns[0] == button )    --mySpeedIncrement;
-  if ( mySpaceMouseBtns[1] == button )    ++mySpeedIncrement;
-  if ( mySpaceMouseBtns[2] == button )    DecreaseGaussPointMagnification();
-  if ( mySpaceMouseBtns[3] == button )    IncreaseGaussPointMagnification();
-  if ( mySpaceMouseBtns[4] == button )    DominantCombinedSwitch();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_InteractorStyle
-::DecreaseGaussPointMagnification()
-{
-  printf( "\n--DecreaseGaussPointMagnification() NOT IMPLEMENTED--\n" );
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_InteractorStyle
-::IncreaseGaussPointMagnification()
-{
-  printf( "\n--IncreaseGaussPointMagnification() NOT IMPLEMENTED--\n" );
+  if( mySMDecreaseSpeedBtn == button )    
+    --mySpeedIncrement;
+  if( mySMIncreaseSpeedBtn == button )    
+    ++mySpeedIncrement;
+  if( mySMDominantCombinedSwitchBtn == button )    
+    DominantCombinedSwitch();
 }
 
 //----------------------------------------------------------------------------
@@ -1312,20 +1290,14 @@ SVTK_InteractorStyle
        self->mySpeedIncrement = *((int*)callData);
        return;
 
-      case SVTK::SetSpaceMouseF1Event:
-       self->mySpaceMouseBtns[0] = *((int*)callData);
-       return;
-      case SVTK::SetSpaceMouseF2Event:
-       self->mySpaceMouseBtns[1] = *((int*)callData);
+      case SVTK::SetSMDecreaseSpeedEvent:
+       self->mySMDecreaseSpeedBtn = *((int*)callData);
        return;
-      case SVTK::SetSpaceMouseF3Event:
-       self->mySpaceMouseBtns[2] = *((int*)callData);
+      case SVTK::SetSMIncreaseSpeedEvent:
+       self->mySMIncreaseSpeedBtn = *((int*)callData);
        return;
-      case SVTK::SetSpaceMouseF4Event:
-       self->mySpaceMouseBtns[3] = *((int*)callData);
-       return;
-      case SVTK::SetSpaceMouseF5Event:
-       self->mySpaceMouseBtns[4] = *((int*)callData);
+      case SVTK::SetSMDominantCombinedSwitchEvent:
+       self->mySMDominantCombinedSwitchBtn = *((int*)callData);
        return;
 
       case SVTK::StartZoom:
@@ -1346,5 +1318,6 @@ SVTK_InteractorStyle
       }
     }
   }
-  vtkInteractorStyle::ProcessEvents( object, event, clientData, callData );
+
+  Superclass::ProcessEvents( object, event, clientData, callData );
 }
index 8355df58e72bb4a4f37b675d48716ffbe2ea3bdb..e229a12c84b245cb13f24ae880b9bcb304084b29 100644 (file)
@@ -167,8 +167,12 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle
   IncrementalRotate( const int incrX, const int incrY );
 
   // custom event handling function (to handle 3d space mouse events)
-  static void ProcessEvents( vtkObject* object, unsigned long event,
-                            void* clientData, void* callData );
+  static 
+  void
+  ProcessEvents(vtkObject* object, 
+               unsigned long event,
+               void* clientData, 
+               void* callData );
 
   float MotionFactor;
   float RadianToDegree;                 // constant: for conv from deg to rad
@@ -192,10 +196,8 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle
   void setCursor(const int operation);
 
   void onSpaceMouseMove( double* data );
-  void onSpaceMouseButton( int button );
+  virtual void onSpaceMouseButton( int button );
 
-  void DecreaseGaussPointMagnification();
-  void IncreaseGaussPointMagnification();
   void DominantCombinedSwitch();
   
  protected:
@@ -212,13 +214,13 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle
   bool                      myShiftState;
   int                       ForcedState;
 
-  int                       mySpeedIncrement; // "increment" for pan/rotate/zoom operations
-  int                       mySpaceMouseBtns[5];  // space_mouse_button assigned for functions 1..5 :
-  // [1] Decrease Speed Increment
-  // [2] Increase Speed Increment
-  // [3] Decrease Gauss Point Magnification
-  // [4] Increase Gauss Point Magnification
-  // [5] Dominant Combined Switch
+  // "increment" for pan/rotate/zoom operations
+  int                       mySpeedIncrement; 
+  
+  // SpaceMouse short cuts
+  int                       mySMDecreaseSpeedBtn;
+  int                       mySMIncreaseSpeedBtn;
+  int                       mySMDominantCombinedSwitchBtn;
   
   QWidget* myRenderWidget;
   vtkSmartPointer<SVTK_GenericRenderWindowInteractor> myInteractor;