#include #include #include #include // ------------------------------------------------------------------------- cpExtensions::Interaction::ImageSliceStyle:: Self* cpExtensions::Interaction::ImageSliceStyle:: New( ) { return( new Self( ) ); } // ------------------------------------------------------------------------- cpExtensions::Visualization::ImageViewerActors* cpExtensions::Interaction::ImageSliceStyle:: GetActors( ) { return( this->m_Actors ); } // ------------------------------------------------------------------------- const cpExtensions::Visualization::ImageViewerActors* cpExtensions::Interaction::ImageSliceStyle:: GetActors( ) const { return( this->m_Actors ); } // ------------------------------------------------------------------------- void cpExtensions::Interaction::ImageSliceStyle:: SetActors( cpExtensions::Visualization::ImageViewerActors* actors ) { this->m_Actors = actors; if( actors != NULL ) { this->m_PropPicker = vtkSmartPointer< vtkPropPicker >::New( ); this->m_PropPicker->PickFromListOn( ); this->m_PropPicker->GetPickList( )->RemoveAllItems( ); this->m_PropPicker-> AddPickList( this->m_Actors->GetWindowLevelImageActor( ) ); } else this->m_PropPicker = NULL; } // ------------------------------------------------------------------------- void cpExtensions::Interaction::ImageSliceStyle:: OnMouseMove( ) { this->Superclass::OnMouseMove( ); if( this->m_Actors.GetPointer( ) == NULL ) return; // Slice synch static int idx[ 2 ]; static double pos[ 3 ]; if( this->_PickPosition( idx, pos ) ) { if( this->Interactor->GetControlKey( ) == 1 && this->GetButtonID( ) == Self::ButtonID_Left ) { this->m_Actors->SetSuperCursor( pos, this->m_Actors->GetOrientation( ) == 2 ); this->InvokeEvent( vtkCommand::UserEvent + 1, pos ); } else this->m_Actors->SetCursor( pos, this->m_Actors->GetOrientation( ) == 2 ); } else this->m_Actors->HideViewerActors( ); this->Interactor->Render( ); } // ------------------------------------------------------------------------- void cpExtensions::Interaction::ImageSliceStyle:: OnMouseWheelForward( ) { static int s = 0; if( this->m_Actors.GetPointer( ) == NULL ) return; s = this->m_Actors->GetSliceNumber( ); s += ( this->Interactor->GetShiftKey( ) == 1 )? 10: 1; this->m_Actors->SetSliceNumber( s ); s = this->m_Actors->GetSliceNumber( ); this->InvokeEvent( vtkCommand::UserEvent + 2, &s ); this->Interactor->Render( ); this->OnMouseMove( ); } // ------------------------------------------------------------------------- void cpExtensions::Interaction::ImageSliceStyle:: OnMouseWheelBackward( ) { static int s = 0; if( this->m_Actors.GetPointer( ) == NULL ) return; s = this->m_Actors->GetSliceNumber( ); s -= ( this->Interactor->GetShiftKey( ) == 1 )? 10: 1; this->m_Actors->SetSliceNumber( s ); s = this->m_Actors->GetSliceNumber( ); this->InvokeEvent( vtkCommand::UserEvent + 2, &s ); this->Interactor->Render( ); this->OnMouseMove( ); } // ------------------------------------------------------------------------- void cpExtensions::Interaction::ImageSliceStyle:: OnChar( ) { } // ------------------------------------------------------------------------- cpExtensions::Interaction::ImageSliceStyle:: ImageSliceStyle( ) : Superclass( ) { } // ------------------------------------------------------------------------- cpExtensions::Interaction::ImageSliceStyle:: ~ImageSliceStyle( ) { } // ------------------------------------------------------------------------- bool cpExtensions::Interaction::ImageSliceStyle:: _PickPosition( int idx[ 2 ], double pos[ 3 ] ) { if( this->Interactor == NULL || this->CurrentRenderer == NULL || this->m_PropPicker.GetPointer( ) == NULL ) return( false ); // Find the renderer where the event has been raised idx[ 0 ] = this->Interactor->GetEventPosition( )[ 0 ]; idx[ 1 ] = this->Interactor->GetEventPosition( )[ 1 ]; this->FindPokedRenderer( double( idx[ 0 ] ), double( idx[ 1 ] ) ); // Pick a 3D position int r = this->m_PropPicker->Pick( double( idx[ 0 ] ), double( idx[ 1 ] ), double( 0 ), this->CurrentRenderer ); if( r == 0 ) return( false ); this->m_PropPicker->GetPickPosition( pos ); return( true ); } // eof - $RCSfile$