+ motionVector[1] + viewPoint[1],
+ motionVector[2] + viewPoint[2]);
+}
+
+void SVTK_InteractorStyle::IncrementalPan( const int incrX, const int incrY )
+{
+ this->PanXY( incrX, incrY, 0, 0 );
+}
+
+void SVTK_InteractorStyle::IncrementalZoom( const int incr )
+{
+ this->DollyXY( incr, incr );
+}
+
+void SVTK_InteractorStyle::IncrementalRotate( const int incrX, const int incrY )
+{
+ this->RotateXY( incrX, -incrY );
+}
+
+/*!
+ Redefined in order to add an observer (callback) for custorm event (space mouse event)
+*/
+void SVTK_InteractorStyle::SetInteractor( vtkRenderWindowInteractor* theInteractor )
+{
+ // register EventCallbackCommand as observer of standard events (keypress, mousemove, etc)
+ Superclass::SetInteractor( theInteractor );
+
+ myInteractor = dynamic_cast<SVTK_GenericRenderWindowInteractor*>(theInteractor);
+
+ 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 );
+ theInteractor->AddObserver( SVTK::PanLeftEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::PanRightEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::PanUpEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::PanDownEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::ZoomInEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::ZoomOutEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::RotateLeftEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::RotateRightEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::RotateUpEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::RotateDownEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::PlusSpeedIncrementEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::MinusSpeedIncrementEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::SetSpeedIncrementEvent, 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 );
+ theInteractor->AddObserver( SVTK::StartRotate, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::StartGlobalPan, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::StartFitArea, EventCallbackCommand, Priority );
+
+ theInteractor->AddObserver( SVTK::SetRotateGravity, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::StartPointSelection, EventCallbackCommand, Priority );
+
+ theInteractor->AddObserver( SVTK::ChangeRotationPoint, EventCallbackCommand, Priority );
+
+ theInteractor->AddObserver( SVTK::SetFocalPointGravity, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::StartFocalPointSelection, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::SetFocalPointSelected, EventCallbackCommand, Priority );
+ }
+}
+
+/*!
+ To implement cached rendering
+*/
+void SVTK_InteractorStyle::OnTimer()
+{
+ //vtkInteractorStyle::OnTimer();
+ this->Interactor->Render();
+ // check if bounding box was changed
+ if ( GetCurrentRenderer() )
+ {
+ double aCurrBBCenter[3];
+ if ( ComputeBBCenter(GetCurrentRenderer(),aCurrBBCenter) )
+ {
+ if ( !myBBFirstCheck )
+ {
+ if ( fabs(aCurrBBCenter[0]-myBBCenter[0]) > 1e-38 ||
+ fabs(aCurrBBCenter[1]-myBBCenter[1]) > 1e-38 ||
+ fabs(aCurrBBCenter[2]-myBBCenter[2]) > 1e-38 ) {
+ // bounding box was changed => send SVTK::RotationPointChanged event
+ // invoke event for update coordinates in SVTK_SetRotationPointDlg
+ InvokeEvent(SVTK::BBCenterChanged,(void*)aCurrBBCenter);
+ for ( int i =0; i < 3; i++) myBBCenter[i] = aCurrBBCenter[i];
+ }
+ }
+ else
+ {
+ for ( int i =0; i < 3; i++) myBBCenter[i] = aCurrBBCenter[i];
+ myBBFirstCheck = false;
+ }
+ }
+ }
+}
+
+/*!
+ To invoke #vtkRenderWindowInteractor::CreateTimer
+*/
+void SVTK_InteractorStyle::Render()
+{
+ this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
+}
+
+void SVTK_InteractorStyle::onSpaceMouseMove( double* data )
+{
+ // 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)
+ FindPokedRenderer( x, y ); // calls SetCurrentRenderer
+
+ IncrementalZoom( (int)data[2] ); // 1. push toward / pull backward = zoom out / zoom in
+ IncrementalPan( (int)data[0], (int)data[1] );// 2. pull up / push down = pan up / down, 3. move left / right = pan left / right
+ IncrementalRotate( 0, (int)data[4] ); // 4. twist the control = rotate around Y axis
+ IncrementalRotate( (int)data[3], 0 ); // 5. tilt the control forward/backward = rotate around X axis (Z axis of local coordinate system of space mouse)
+}
+
+void SVTK_InteractorStyle::onSpaceMouseButton( int button )
+{
+ if( mySMDecreaseSpeedBtn == button ) {
+ ControllerIncrement()->Decrease();
+ }
+ if( mySMIncreaseSpeedBtn == button ) {
+ ControllerIncrement()->Increase();
+ }
+ if( mySMDominantCombinedSwitchBtn == button )
+ DominantCombinedSwitch();
+}
+
+void SVTK_InteractorStyle::DominantCombinedSwitch()
+{
+ printf( "\n--DominantCombinedSwitch() NOT IMPLEMENTED--\n" );
+}
+
+/*!
+ Draws rectangle by starting and current points
+*/
+void SVTK_InteractorStyle::drawRect()
+{
+ if ( !myRectBand )
+ myRectBand = new QtxRectRubberBand( GetRenderWidget() );
+
+ myRectBand->setUpdatesEnabled ( false );
+ QRect aRect = SUIT_Tools::makeRect(myPoint.x(), myPoint.y(), myOtherPoint.x(), myOtherPoint.y());
+ myRectBand->initGeometry( aRect );
+
+ if ( !myRectBand->isVisible() )
+ myRectBand->show();
+
+ myRectBand->setUpdatesEnabled ( true );
+}
+
+/*!
+ \brief Delete rubber band on the end on the dragging operation.
+*/
+void SVTK_InteractorStyle::endDrawRect()
+{
+ if ( myRectBand ) {
+ myRectBand->clearGeometry();
+ myRectBand->hide();