-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-AddSlicesCommand( TSlicesCommand command, void* data )
-{
- if( command != NULL )
- {
- this->m_SlicesCommands[ command ] = data;
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-AddWindowLevelCommand( TWindowLevelCommand command, void* data )
-{
- if( command != NULL )
- {
- this->m_WindowLevelCommands[ command ] = data;
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-AddRenderCommand( TVoidCommand command, void* data )
-{
- if( command != NULL )
- {
- this->m_RenderCommands[ command ] = data;
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-RemoveSlicesCommand( TSlicesCommand command )
-{
- auto i = this->m_SlicesCommands.find( command );
- if( i != this->m_SlicesCommands.end( ) )
- {
- this->m_SlicesCommands.erase( i );
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-RemoveWindowLevelCommand( TWindowLevelCommand command )
-{
- auto i = this->m_WindowLevelCommands.find( command );
- if( i != this->m_WindowLevelCommands.end( ) )
- {
- this->m_WindowLevelCommands.erase( i );
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-RemoveRenderCommand( TVoidCommand command )
-{
- auto i = this->m_RenderCommands.find( command );
- if( i != this->m_RenderCommands.end( ) )
- {
- this->m_RenderCommands.erase( i );
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-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( );
-
- // Reconfigure unique objects
- this->m_Cursor = vtkSmartPointer< vtkPolyData >::New( );
- this->m_CursorMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->m_CursorActor = vtkSmartPointer< vtkActor >::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* slice )
-{
- this->m_AssociatedSlices.push_back( slice );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-vtkInteractorStyle* cpExtensions::Visualization::ImageSliceActors::
-GetStyle( )
-{
- return( this->m_Style.GetPointer( ) );
-}
-
-// -------------------------------------------------------------------------
-const vtkInteractorStyle* cpExtensions::Visualization::ImageSliceActors::
-GetStyle( ) const
-{
- return( this->m_Style.GetPointer( ) );
-}
-