-void cpExtensions::Visualization::ImageSliceActors::
-AddCursorCommand( TCursorCommand command, void* data )
-{
- this->m_CursorCommands.push_back(
- std::pair< TCursorCommand, void* >( command, data )
- );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-AddInputConnection( vtkAlgorithmOutput* aout, int axis )
-{
- // Get input vtkImageData
- if( aout == NULL )
- return;
- vtkAlgorithm* producer = aout->GetProducer( );
- vtkImageData* data = dynamic_cast< vtkImageData* >(
- producer->GetOutputDataObject( aout->GetIndex( ) )
- );
- if( data == NULL )
- return;
-
- // Try to infere if input comes from a color mapping filter
- vtkImageMapToColors* new_map =
- dynamic_cast< vtkImageMapToColors* >( producer );
- if( new_map == NULL )
- {
- // Configure LUT, if possible (NULL is returned if not)
- this->_ConfigureNewLUT( data );
- new_map = *( this->m_ImageMaps.rbegin( ) );
- if( new_map != NULL )
- {
- new_map->SetInputConnection( aout );
- new_map->Update( );
-
- } // fi
- }
- else
- this->m_ImageMaps.push_back( new_map );
-
- // Create mapper and actors
- vtkSmartPointer< vtkImageSliceMapper > mapper =
- vtkSmartPointer< vtkImageSliceMapper >::New( );
- if( new_map != NULL )
- mapper->SetInputConnection( new_map->GetOutputPort( ) );
- else
- mapper->SetInputConnection( aout );
- this->m_SliceMappers.push_back( mapper );
- this->_ConfigureNewInput( axis );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-AddInputData( vtkImageData* data, int axis )
-{
- // Configure LUT, if possible (NULL is returned if not)
- this->_ConfigureNewLUT( data );
- vtkImageMapToColors* new_map = *( this->m_ImageMaps.rbegin( ) );
- if( new_map != NULL )
- {
- new_map->SetInputData( data );
- new_map->Update( );
-
- } // fi
-
- // Create mapper and actors
- vtkSmartPointer< vtkImageSliceMapper > mapper =
- vtkSmartPointer< vtkImageSliceMapper >::New( );
- if( new_map != NULL )
- mapper->SetInputConnection( new_map->GetOutputPort( ) );
- else
- mapper->SetInputData( data );
- this->m_SliceMappers.push_back( mapper );
- this->_ConfigureNewInput( axis );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-Clear( )
-{
- // Unbind from container
- this->RemoveAllItems( );
-
- // Delete all images
- this->m_ImageMaps.clear( );
- this->m_SliceMappers.clear( );
- this->m_ImageActors.clear( );
- this->m_AssociatedSlices.clear( );
- this->m_AssociatedActors.clear( );
-
- // Reconfigure unique objects
- this->m_Cursor = vtkSmartPointer< vtkPolyData >::New( );
- this->m_CursorMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->m_CursorActor = vtkSmartPointer< vtkActor >::New( );
- this->m_PlaneFunction = vtkSmartPointer< vtkPlane >::New( );
- this->m_Plane = vtkSmartPointer< vtkPolyData >::New( );
- this->m_PlaneMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->m_TextActor = vtkSmartPointer< vtkTextActor >::New( );
- this->m_PlaneActor = vtkSmartPointer< vtkActor >::New( );
- this->m_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_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 );
- cursor_lines->InsertNextCell( 2 );
- cursor_lines->InsertCellPoint( 4 );
- cursor_lines->InsertCellPoint( 5 );
- cursor_lines->InsertNextCell( 2 );
- cursor_lines->InsertCellPoint( 6 );
- cursor_lines->InsertCellPoint( 7 );
- this->m_Cursor->SetPoints( cursor_points );
- this->m_Cursor->SetLines( cursor_lines );
- this->m_CursorMapper->SetInputData( this->m_Cursor );
- this->m_CursorActor->SetMapper( this->m_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->m_Plane->SetPoints( plane_points );
- this->m_Plane->SetLines( plane_lines );
-
- this->m_PlaneMapper->SetInputData( this->m_Plane );
- this->m_PlaneActor->SetMapper( this->m_PlaneMapper );
-
- this->m_TextActor->SetTextScaleModeToNone( );
- vtkTextProperty* textprop = this->m_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->m_TextActor->GetPositionCoordinate( );
- coord->SetCoordinateSystemToNormalizedViewport( );
- coord->SetValue( 0.01, 0.01 );
-
- // Update actor collection
- this->AddItem( this->m_CursorActor );
- this->AddItem( this->m_TextActor );
- this->AddItem( this->m_PlaneActor );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-AssociateSlice( Self* other )
-{
- this->m_AssociatedSlices.push_back( other );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-SetSlicesCommand( TCursorCommand cmd, void* data )
-{
- this->SlicesCommand = cmd;
- this->SlicesData = data;
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-vtkInteractorStyle* cpExtensions::Visualization::ImageSliceActors::
-GetStyle( )
-{
- return( this->m_Style.GetPointer( ) );
-}
-
-// -------------------------------------------------------------------------
-const vtkInteractorStyle* cpExtensions::Visualization::ImageSliceActors::
-GetStyle( ) const
-{
- return( this->m_Style.GetPointer( ) );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-PushActorsInto( vtkRenderWindow* window, bool force_style )
-{
- if( window == NULL )
- return;
- vtkRenderWindowInteractor* rwi = window->GetInteractor( );
- vtkRenderer* renderer = window->GetRenderers( )->GetFirstRenderer( );
- if( rwi == NULL || renderer == NULL )
- return;
-
- // Update style
- if( force_style )
- {
- this->_ConfigureStyle( );
- rwi->SetInteractorStyle( this->m_Style );
-
- } // fi
-
- // Update actors
-# error USE vtkActorCollection interface
- /* TODO
- for( unsigned int n = 0; n < this->GetNumberOfImageActors( ); ++n )
- renderer->AddActor( this->GetImageActor( n ) );
- renderer->AddActor( this->m_CursorActor );
- renderer->AddActor( this->m_PlaneActor );
- renderer->AddActor( this->m_TextActor );
- renderer->Modified( );
- */
-
- // Configure camera
- vtkCamera* camera = renderer->GetActiveCamera( );
- if( camera != NULL && force_style )
- {
- // 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
-
- } // fi
- renderer->ResetCamera( );
- rwi->Render( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-PopActorsFrom( vtkRenderWindow* window )