From c2dbeb99b240e204a45850e6f1cb7289b4cc00c4 Mon Sep 17 00:00:00 2001 From: apo Date: Tue, 6 Sep 2005 08:29:07 +0000 Subject: [PATCH] To implement configure event --- src/SVTK/SVTK_InteractorStyle.cxx | 65 +++++++++++++----------- src/SVTK/SVTK_InteractorStyle.h | 1 + src/SVTK/SVTK_RenderWindowInteractor.cxx | 8 +-- src/SVTK/SVTK_Renderer.cxx | 8 +++ 4 files changed, 49 insertions(+), 33 deletions(-) diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index 4ab604861..7f642941e 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -272,6 +272,15 @@ SVTK_InteractorStyle } +//---------------------------------------------------------------------------- +void +SVTK_InteractorStyle +::OnConfigure() +{ + GetCurrentRenderer()->InvokeEvent(vtkCommand::ConfigureEvent,NULL); +} + + //---------------------------------------------------------------------------- void SVTK_InteractorStyle @@ -1312,92 +1321,90 @@ SVTK_InteractorStyle void* clientData, void* callData ) { - if ( event < vtkCommand::UserEvent ) - vtkInteractorStyle::ProcessEvents( object, event, clientData, callData ); - - else if ( clientData ) { + if ( clientData ) { vtkObject* anObject = reinterpret_cast( clientData ); SVTK_InteractorStyle* self = dynamic_cast( anObject ); if ( self ) { switch ( event ) { case SVTK::SpaceMouseMoveEvent : self->onSpaceMouseMove( (double*)callData ); - break; + return; case SVTK::SpaceMouseButtonEvent : self->onSpaceMouseButton( *((int*)callData) ); - break; + return; case SVTK::PanLeftEvent: self->IncrementalPan( -self->mySpeedIncrement, 0 ); - break; + return; case SVTK::PanRightEvent: self->IncrementalPan( self->mySpeedIncrement, 0 ); - break; + return; case SVTK::PanUpEvent: self->IncrementalPan( 0, self->mySpeedIncrement ); - break; + return; case SVTK::PanDownEvent: self->IncrementalPan( 0, -self->mySpeedIncrement ); - break; + return; case SVTK::ZoomInEvent: self->IncrementalZoom( self->mySpeedIncrement ); - break; + return; case SVTK::ZoomOutEvent: self->IncrementalZoom( -self->mySpeedIncrement ); - break; + return; case SVTK::RotateLeftEvent: self->IncrementalRotate( -self->mySpeedIncrement, 0 ); - break; + return; case SVTK::RotateRightEvent: self->IncrementalRotate( self->mySpeedIncrement, 0 ); - break; + return; case SVTK::RotateUpEvent: self->IncrementalRotate( 0, -self->mySpeedIncrement ); - break; + return; case SVTK::RotateDownEvent: self->IncrementalRotate( 0, self->mySpeedIncrement ); - break; + return; case SVTK::PlusSpeedIncrementEvent: ++(self->mySpeedIncrement); - break; + return; case SVTK::MinusSpeedIncrementEvent: --(self->mySpeedIncrement); - break; + return; case SVTK::SetSpeedIncrementEvent: self->mySpeedIncrement = *((int*)callData); - break; + return; case SVTK::SetSpaceMouseF1Event: self->mySpaceMouseBtns[0] = *((int*)callData); - break; + return; case SVTK::SetSpaceMouseF2Event: self->mySpaceMouseBtns[1] = *((int*)callData); - break; + return; case SVTK::SetSpaceMouseF3Event: self->mySpaceMouseBtns[2] = *((int*)callData); - break; + return; case SVTK::SetSpaceMouseF4Event: self->mySpaceMouseBtns[3] = *((int*)callData); - break; + return; case SVTK::SetSpaceMouseF5Event: self->mySpaceMouseBtns[4] = *((int*)callData); - break; + return; case SVTK::StartZoom: self->startZoom(); - break; + return; case SVTK::StartPan: self->startPan(); - break; + return; case SVTK::StartRotate: self->startRotate(); - break; + return; case SVTK::StartGlobalPan: self->startGlobalPan(); - break; + return; case SVTK::StartFitArea: self->startFitArea(); - break; + return; } } } + vtkInteractorStyle::ProcessEvents( object, event, clientData, callData ); } diff --git a/src/SVTK/SVTK_InteractorStyle.h b/src/SVTK/SVTK_InteractorStyle.h index fc93a577d..c8fd0dd5f 100644 --- a/src/SVTK/SVTK_InteractorStyle.h +++ b/src/SVTK/SVTK_InteractorStyle.h @@ -94,6 +94,7 @@ class SVTK_EXPORT SVTK_InteractorStyle : virtual void OnTimer(); // VTK events + virtual void OnConfigure(); virtual void OnMouseMove(); virtual void OnLeftButtonDown(); virtual void OnLeftButtonUp(); diff --git a/src/SVTK/SVTK_RenderWindowInteractor.cxx b/src/SVTK/SVTK_RenderWindowInteractor.cxx index d90c71479..98ce10b3e 100644 --- a/src/SVTK/SVTK_RenderWindowInteractor.cxx +++ b/src/SVTK/SVTK_RenderWindowInteractor.cxx @@ -198,7 +198,6 @@ QVTK_RenderWindowInteractor #endif GetRenderWindow()->SetWindowId((void*)winId()); myInteractor->Enable(); - myInteractor->ConfigureEvent(); } //---------------------------------------------------------------------------- @@ -215,10 +214,11 @@ QVTK_RenderWindowInteractor ::paintEvent( QPaintEvent* theEvent ) { if(myInteractor->GetEnabled()){ - if(!myInteractor->GetInitialized()) + if(!myInteractor->GetInitialized()){ myInteractor->Initialize(); - else - myInteractor->Render(); + myInteractor->ConfigureEvent(); + } + myInteractor->Render(); } } diff --git a/src/SVTK/SVTK_Renderer.cxx b/src/SVTK/SVTK_Renderer.cxx index 5f18d28ee..e342545c3 100644 --- a/src/SVTK/SVTK_Renderer.cxx +++ b/src/SVTK/SVTK_Renderer.cxx @@ -76,6 +76,9 @@ SVTK_Renderer this->AddObserver(vtkCommand::ResetCameraEvent, myEventCallbackCommand.GetPointer(), myPriority); + this->AddObserver(vtkCommand::ConfigureEvent, + myEventCallbackCommand.GetPointer(), + myPriority); } SVTK_Renderer @@ -92,6 +95,11 @@ SVTK_Renderer { SVTK_Renderer* self = reinterpret_cast(theClientData); + switch(theEvent){ + case vtkCommand::ConfigureEvent: + self->onResetView(); + break; + } switch(theEvent){ case vtkCommand::ResetCameraEvent: self->onFitAll(); -- 2.39.2