-void cpExtensions::Visualization::ImageSliceActors::
-AddInputConnection( vtkAlgorithmOutput* aout, int axis )
-{
- vtkSmartPointer< vtkImageSliceMapper > mapper =
- vtkSmartPointer< vtkImageSliceMapper >::New( );
- this->SliceMappers.push_back( mapper );
- mapper->SetInputConnection( aout );
- this->_ConfigureNewInput( axis );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-AddInputData( vtkImageData* data, int axis )
-{
- vtkSmartPointer< vtkImageSliceMapper > mapper =
- vtkSmartPointer< vtkImageSliceMapper >::New( );
- this->SliceMappers.push_back( mapper );
- mapper->SetInputData( data );
- this->_ConfigureNewInput( axis );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-Clear( )
-{
- // Unbind from container
- this->RemoveAllItems( );
-
- // Delete all images
- this->SliceMappers.clear( );
- this->ImageActors.clear( );
- this->AssociatedActors.clear( );
-
- // Reconfigure unique objects
- this->Cursor = vtkSmartPointer< vtkPolyData >::New( );
- this->CursorMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->CursorActor = vtkSmartPointer< vtkActor >::New( );
- this->PlaneFunction = vtkSmartPointer< vtkPlane >::New( );
- this->PlaneSource = vtkSmartPointer< vtkPolyData >::New( );
- this->PlaneMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->TextActor = vtkSmartPointer< vtkTextActor >::New( );
- this->PlaneActor = vtkSmartPointer< vtkActor >::New( );
- this->TextBuffer[ 0 ] = '\0';
-
- // Unique objects configuration
- vtkSmartPointer< vtkPoints > cursor_points =
- vtkSmartPointer< vtkPoints >::New( );
- vtkSmartPointer< vtkCellArray > cursor_lines =
- vtkSmartPointer< vtkCellArray >::New( );
- cursor_points->InsertNextPoint( 0, 0, 0 );
- cursor_points->InsertNextPoint( 0, 0, 0 );
- cursor_points->InsertNextPoint( 0, 0, 0 );
- cursor_points->InsertNextPoint( 0, 0, 0 );
- cursor_lines->InsertNextCell( 2 );
- cursor_lines->InsertCellPoint( 0 );
- cursor_lines->InsertCellPoint( 1 );
- cursor_lines->InsertNextCell( 2 );
- cursor_lines->InsertCellPoint( 2 );
- cursor_lines->InsertCellPoint( 3 );
- this->Cursor->SetPoints( cursor_points );
- this->Cursor->SetLines( cursor_lines );
- this->CursorMapper->SetInputData( this->Cursor );
- this->CursorActor->SetMapper( this->CursorMapper );
-
- vtkSmartPointer< vtkPoints > plane_points =
- vtkSmartPointer< vtkPoints >::New( );
- vtkSmartPointer< vtkCellArray > plane_lines =
- vtkSmartPointer< vtkCellArray >::New( );
-
- plane_points->InsertNextPoint( 0, 0, 0 );
- plane_points->InsertNextPoint( 0, 1, 0 );
- plane_points->InsertNextPoint( 1, 1, 0 );
- plane_points->InsertNextPoint( 1, 0, 0 );
- plane_lines->InsertNextCell( 5 );
- plane_lines->InsertCellPoint( 0 );
- plane_lines->InsertCellPoint( 1 );
- plane_lines->InsertCellPoint( 2 );
- plane_lines->InsertCellPoint( 3 );
- plane_lines->InsertCellPoint( 0 );
- this->PlaneSource->SetPoints( plane_points );
- this->PlaneSource->SetLines( plane_lines );
-
- this->PlaneMapper->SetInputData( this->PlaneSource );
- this->PlaneActor->SetMapper( this->PlaneMapper );
-
- this->TextActor->SetTextScaleModeToNone( );
- vtkTextProperty* textprop = this->TextActor->GetTextProperty( );
- textprop->SetColor( 1, 1, 1 );
- textprop->SetFontFamilyToCourier( );
- textprop->SetFontSize( 18 );
- textprop->BoldOff( );
- textprop->ItalicOff( );
- textprop->ShadowOff( );
- textprop->SetJustificationToLeft( );
- textprop->SetVerticalJustificationToBottom( );
- vtkCoordinate* coord = this->TextActor->GetPositionCoordinate( );
- coord->SetCoordinateSystemToNormalizedViewport( );
- coord->SetValue( 0.01, 0.01 );
-}
-
-// -------------------------------------------------------------------------
-vtkInteractorStyle* cpExtensions::Visualization::ImageSliceActors::
-GetStyle( )
-{
- return( this->Style.GetPointer( ) );
-}
-
-// -------------------------------------------------------------------------
-const vtkInteractorStyle* cpExtensions::Visualization::ImageSliceActors::
-GetStyle( ) const
-{
- return( this->Style.GetPointer( ) );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-PushActorsInto( vtkRenderWindow* window )
-{
- vtkRenderWindowInteractor* rwi = window->GetInteractor( );
- vtkRenderer* renderer = window->GetRenderers( )->GetFirstRenderer( );
-
- // Update style
- if( rwi != NULL )
- {
- if( rwi->GetInteractorStyle( ) != this->Style.GetPointer( ) )
- rwi->SetInteractorStyle( this->Style );
-
- } // fi
-
- if( renderer != NULL )
- {
- // Configure camera
- vtkCamera* camera = renderer->GetActiveCamera( );
- if( camera == NULL )
- return;
-
- // Parallel projections are better when displaying 2D images
- int axis = this->GetAxis( );
- camera->ParallelProjectionOn( );
- camera->SetFocalPoint( double( 0 ), double( 0 ), double( 0 ) );
- if( axis == 0 )
- {
- camera->SetPosition( double( 1 ), double( 0 ), double( 0 ) );
- camera->SetViewUp ( double( 0 ), double( 1 ), double( 0 ) );
- }
- else if( axis == 1 )
- {
- camera->SetPosition( double( 0 ), double( 1 ), double( 0 ) );
- camera->SetViewUp ( double( 0 ), double( 0 ), double( -1 ) );
- }
- else // if( axis == 2 )
- {
- camera->SetPosition( double( 0 ), double( 0 ), double( 1 ) );
- camera->SetViewUp ( double( 0 ), double( 1 ), double( 0 ) );
-
- } // fi
- renderer->ResetCamera( );
-
- // Update actors
- unsigned int N = this->GetNumberOfImageActors( );
- for( unsigned int n = 0; n < N; ++n )
- renderer->AddActor( this->GetImageActor( n ) );
- renderer->AddActor( this->CursorActor );
- renderer->AddActor( this->PlaneActor );
- renderer->AddActor( this->TextActor );
- renderer->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-PopActorsFrom( vtkRenderWindow* window )
-{
- /*
- unsigned int N = this->GetNumberOfImageActors( );
- for( unsigned int n = 0; n < N; ++n )
- renderer->RemoveActor( this->GetImageActor( n ) );
- renderer->RemoveActor( this->GetTextActor( ) );
- renderer->RemoveActor( this->GetPlaneActor( ) );
- renderer->Modified( );
- */
-}
-
-// -------------------------------------------------------------------------
-unsigned int cpExtensions::Visualization::ImageSliceActors::
-GetNumberOfImageActors( ) const
-{
- return( this->ImageActors.size( ) );
-}
-
-// -------------------------------------------------------------------------
-vtkImageActor* cpExtensions::Visualization::ImageSliceActors::
-GetImageActor( unsigned int id )
-{
- if( id < this->ImageActors.size( ) )
- return( this->ImageActors[ id ] );
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-const vtkImageActor* cpExtensions::Visualization::ImageSliceActors::
-GetImageActor( unsigned int id ) const