-// -------------------------------------------------------------------------
-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( );
-}
-
-// -------------------------------------------------------------------------
-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
- )
-{
- if( aout == NULL )
- return( -1 );
- this->m_Blender->AddInputConnection( aout );
- this->_ConfigureBinaryImage( r, g, b );
- return( this->m_Blender->GetNumberOfInputs( ) - 1 );
-}
-
-// -------------------------------------------------------------------------
-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 );
- this->_ConfigureBinaryImage( r, g, b );
- return( this->m_Blender->GetNumberOfInputs( ) - 1 );
-}
-
-// -------------------------------------------------------------------------
-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->SetTableRange( 0, 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( );
-
- // 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_lines->InsertNextCell( 2 );
- cursor_lines->InsertCellPoint( 0 );
- cursor_lines->InsertCellPoint( 1 );
- cursor_lines->InsertNextCell( 2 );
- cursor_lines->InsertCellPoint( 2 );
- cursor_lines->InsertCellPoint( 3 );
-
- 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 );
- this->m_CursorActor->GetProperty( )->SetColor( 1, 1, 0 );
- this->m_CursorActor->GetProperty( )->SetLineWidth( 2 );
-
- // Plane intersections
- this->m_Axis1 = vtkSmartPointer< vtkPolyData >::New( );
- this->m_Axis1Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->m_Axis1Actor = vtkSmartPointer< vtkActor >::New( );
-
- 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_Axis1->SetPoints( h_points );
- this->m_Axis1->SetLines( h_lines );
- this->m_Axis1Mapper->SetInputData( this->m_Axis1 );
- this->m_Axis1Actor->SetMapper( this->m_Axis1Mapper );
-
- this->m_Axis2 = vtkSmartPointer< vtkPolyData >::New( );
- this->m_Axis2Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->m_Axis2Actor = vtkSmartPointer< vtkActor >::New( );
-
- 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_Axis2->SetPoints( v_points );
- this->m_Axis2->SetLines( v_lines );
- this->m_Axis2Mapper->SetInputData( this->m_Axis2 );
- this->m_Axis2Actor->SetMapper( this->m_Axis2Mapper );
-
- // Plane
- this->m_Plane = vtkSmartPointer< vtkPolyData >::New( );
- this->m_PlaneMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->m_PlaneActor = vtkSmartPointer< vtkActor >::New( );
-
- 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 );
-
- // Text actor
- this->m_TextActor = vtkSmartPointer< vtkTextActor >::New( );
- this->m_TextBuffer[ 0 ] = '\0';
- this->m_TextActor->SetTextScaleModeToNone( );
- vtkTextProperty* textprop = this->m_TextActor->GetTextProperty( );
- textprop->SetColor( 1, 1, 0 );
- 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 );
-}
-
-// -------------------------------------------------------------------------
-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( ) );
-}
-