-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-SetAxis( int axis )
-{
- this->m_ImageMapper->SetOrientation( axis );
- this->m_BlenderMapper->SetOrientation( axis );
- this->m_ImageMapper->Update( );
- this->m_BlenderMapper->Update( );
- this->SetSliceNumber( this->GetSliceNumberMinValue( ) );
- this->m_ImageActor->Modified( );
- this->m_BlenderActor->Modified( );
- this->Modified( );
- this->ResetCamera( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-SetInputConnection( vtkAlgorithmOutput* aout )
-{
- // Get input vtkImageData
- if( aout == NULL )
- return;
-
- // Create mapper and actors
- this->m_ImageMapper->SetInputConnection( aout );
- this->_ConfigureInputImage( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-SetInputImage( vtkImageData* data )
-{
- // Get input vtkImageData
- if( data == NULL )
- return;
-
- // Create mapper and actors
- this->m_ImageMapper->SetInputData( data );
- this->_ConfigureInputImage( );
-}
-
-// -------------------------------------------------------------------------
-int cpExtensions::Visualization::ImageSliceActors::
-AddBinaryConnection(
- vtkAlgorithmOutput* aout,
- const double& r, const double& g, const double& b
- )
-{
-}
-
-// -------------------------------------------------------------------------
-int cpExtensions::Visualization::ImageSliceActors::
-AddBinaryImage(
- vtkImageData* data,
- const double& r, const double& g, const double& b
- )
-{
- if( data == NULL )
- return( -1 );
-
- this->m_Blender->AddInputData( data );
-
- unsigned int nValues = this->m_BlenderLUT->GetNumberOfTableValues( );
- this->m_BlenderLUT->SetNumberOfTableValues( nValues + 1 );
- this->m_BlenderLUT->SetTableValue( nValues, r, g, b, 0.5 );
- this->m_BlenderLUT->Build( );
-
- this->m_BlenderLUT->Modified( );
- this->m_Blender->Modified( );
- this->m_Blender->Update( );
-
- this->m_BlenderMapper->Modified( );
- this->m_BlenderActor->Modified( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-Clear( )
-{
- // Unbind from container
- this->RemoveAllItems( );
-
- // Filters and mappers
- this->m_ImageMapper = vtkSmartPointer< vtkImageSliceMapper >::New( );
- this->m_ImageActor = vtkSmartPointer< vtkImageActor >::New( );
- this->m_Blender = vtkSmartPointer< TBlender >::New( );
- this->m_BlenderMapper = vtkSmartPointer< vtkImageSliceMapper >::New( );
- this->m_BlenderLUT = vtkSmartPointer< vtkLookupTable >::New( );
- this->m_BlenderActor = vtkSmartPointer< vtkImageActor >::New( );
-
- this->m_ImageActor->SetMapper( this->m_ImageMapper );
- this->m_BlenderMapper->
- SetInputConnection( this->m_Blender->GetOutputPort( ) );
-
- this->m_BlenderLUT->SetNumberOfTableValues( 1 );
- this->m_BlenderLUT->SetTableValue( 0, 0, 0, 0, 0 );
- this->m_BlenderLUT->Build( );
-
- this->m_BlenderActor->SetMapper( this->m_BlenderMapper );
- this->m_BlenderActor->GetProperty( )->SetLookupTable( this->m_BlenderLUT );
- this->m_BlenderActor->GetProperty( )->UseLookupTableScalarRangeOn( );
-
- // Remove associated objects
- this->m_AssociatedSlices.clear( );
-
- // White cursor
- /*
- 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 = vtkSmartPointer< vtkPolyData >::New( );
- this->m_CursorMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->m_CursorActor = vtkSmartPointer< vtkActor >::New( );
-
- 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< vtkPolyDataMapper > m_CursorMapper;
- vtkSmartPointer< vtkActor > m_CursorActor;
-
- vtkSmartPointer< vtkPolyData > m_HorizontalLine;
- vtkSmartPointer< vtkPolyDataMapper > m_HorizontalLineMapper;
- vtkSmartPointer< vtkActor > m_HorizontalLineActor;
-
- vtkSmartPointer< vtkPolyData > m_VerticalLine;
- vtkSmartPointer< vtkPolyDataMapper > m_VerticalLineMapper;
- vtkSmartPointer< vtkActor > m_VerticalLineActor;
-
- vtkSmartPointer< vtkPolyData > m_Plane;
- vtkSmartPointer< vtkPolyDataMapper > m_PlaneMapper;
- vtkSmartPointer< vtkActor > m_PlaneActor;
-
- char m_TextBuffer[ 1024 ];
- vtkSmartPointer< vtkTextActor > m_TextActor;
- */
-
-
-
-
-
- /*
- // Reset values
- this->m_VisibleExtent[ 0 ] =
- this->m_VisibleExtent[ 2 ] =
- this->m_VisibleExtent[ 4 ] = -1;
- this->m_VisibleExtent[ 1 ] =
- this->m_VisibleExtent[ 3 ] =
- this->m_VisibleExtent[ 5 ] = 0;
- this->m_VisibleBounds[ 0 ] =
- this->m_VisibleBounds[ 2 ] =
- this->m_VisibleBounds[ 4 ] = double( 0 );
- this->m_VisibleBounds[ 1 ] =
- this->m_VisibleBounds[ 3 ] =
- this->m_VisibleBounds[ 5 ] = double( 0 );
-
- // Delete all images
- this->m_ImageActor = NULL;
- this->m_ImageMapper = NULL;
-
- // Reconfigure unique objects
- this->m_Cursor = vtkSmartPointer< vtkPolyData >::New( );
- this->m_CursorMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->m_CursorActor = vtkSmartPointer< vtkActor >::New( );
- this->m_HorizontalLine = vtkSmartPointer< vtkPolyData >::New( );
- this->m_HorizontalLineMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->m_HorizontalLineActor = vtkSmartPointer< vtkActor >::New( );
- this->m_VerticalLine = vtkSmartPointer< vtkPolyData >::New( );
- this->m_VerticalLineMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->m_VerticalLineActor = 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 > h_points =
- vtkSmartPointer< vtkPoints >::New( );
- vtkSmartPointer< vtkCellArray > h_lines =
- vtkSmartPointer< vtkCellArray >::New( );
- h_points->InsertNextPoint( 0, 0, 0 );
- h_points->InsertNextPoint( 0, 0, 0 );
- h_lines->InsertNextCell( 2 );
- h_lines->InsertCellPoint( 0 );
- h_lines->InsertCellPoint( 1 );
- this->m_HorizontalLine->SetPoints( h_points );
- this->m_HorizontalLine->SetLines( h_lines );
- this->m_HorizontalLineMapper->SetInputData( this->m_HorizontalLine );
- this->m_HorizontalLineActor->SetMapper( this->m_HorizontalLineMapper );
-
- vtkSmartPointer< vtkPoints > v_points =
- vtkSmartPointer< vtkPoints >::New( );
- vtkSmartPointer< vtkCellArray > v_lines =
- vtkSmartPointer< vtkCellArray >::New( );
- v_points->InsertNextPoint( 0, 0, 0 );
- v_points->InsertNextPoint( 0, 0, 0 );
- v_lines->InsertNextCell( 2 );
- v_lines->InsertCellPoint( 0 );
- v_lines->InsertCellPoint( 1 );
- this->m_VerticalLine->SetPoints( v_points );
- this->m_VerticalLine->SetLines( v_lines );
- this->m_VerticalLineMapper->SetInputData( this->m_VerticalLine );
- this->m_VerticalLineActor->SetMapper( this->m_VerticalLineMapper );
-
- 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_HorizontalLineActor );
- this->AddItem( this->m_VerticalLineActor );
- 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( ) );
-}
-