From: apo Date: Wed, 5 Oct 2005 14:03:33 +0000 (+0000) Subject: To customize SpaceMause interaction X-Git-Tag: BR-D5-38-2003_D2005-12-10~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e2fb3ef6ae9ad81bff9a3f4c49877514956f6b74;p=modules%2Fgui.git To customize SpaceMause interaction (introduce magnification functionality) --- diff --git a/src/SVTK/SVTK_Event.h b/src/SVTK/SVTK_Event.h index 460b7d3f5..f4c1c42ec 100644 --- a/src/SVTK/SVTK_Event.h +++ b/src/SVTK/SVTK_Event.h @@ -21,13 +21,13 @@ // // // -// 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 @@ -51,11 +51,9 @@ namespace SVTK MinusSpeedIncrementEvent, SetSpeedIncrementEvent, - SetSpaceMouseF1Event, - SetSpaceMouseF2Event, - SetSpaceMouseF3Event, - SetSpaceMouseF4Event, - SetSpaceMouseF5Event, + SetSMDecreaseSpeedEvent, + SetSMIncreaseSpeedEvent, + SetSMDominantCombinedSwitchEvent, StartZoom, StartPan, diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index ff4bb77fb..52da7f3b7 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -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(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 ); } diff --git a/src/SVTK/SVTK_InteractorStyle.h b/src/SVTK/SVTK_InteractorStyle.h index 8355df58e..e229a12c8 100644 --- a/src/SVTK/SVTK_InteractorStyle.h +++ b/src/SVTK/SVTK_InteractorStyle.h @@ -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 myInteractor;