+#include <cpPlugins/Extensions/Visualization/MPRActors.h>
+
+#include <vtkImageData.h>
+#include <vtkOutlineSource.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkProperty.h>
+#include <vtkRenderer.h>
+
+// -------------------------------------------------------------------------
+cpPlugins::Extensions::Visualization::MPRActors*
+cpPlugins::Extensions::Visualization::MPRActors::
+New( )
+{
+ return( new Self( ) );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Extensions::Visualization::
+ImageSliceActors* cpPlugins::Extensions::Visualization::MPRActors::
+GetSliceActors( const int& i ) const
+{
+ if( i < 3 )
+ return( this->Slices[ i ] );
+ else
+ return( NULL );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+SetInputData( vtkImageData* image )
+{
+ if( image == NULL )
+ return;
+
+ this->Image = image;
+
+ this->ImageToWindowLevel->SetInputData( this->Image );
+ this->ResetWindowLevel( );
+ this->ImageToWindowLevel->Update( );
+
+ for( int i = 0; i < 3; ++i )
+ {
+ Slices[ i ]->SetInputConnection(
+ this->ImageToWindowLevel->GetOutputPort( ), i
+ );
+ Slices[ i ]->UpdateText( this->GetWindow( ), this->GetLevel( ) );
+
+ } // rof
+
+ // Create 3D outline
+ vtkSmartPointer< vtkOutlineSource > img_ol =
+ vtkSmartPointer< vtkOutlineSource >::New( );
+ img_ol->SetBounds( this->Image->GetBounds( ) );
+
+ vtkSmartPointer< vtkPolyDataMapper > img_ol_mapper =
+ vtkSmartPointer< vtkPolyDataMapper >::New( );
+ img_ol_mapper->SetInputConnection( img_ol->GetOutputPort( ) );
+ this->ImageOutlineActor->SetMapper( img_ol_mapper );
+ this->ImageOutlineActor->GetProperty( )->SetColor( 1, 1, 1 );
+ this->ImageOutlineActor->GetProperty( )->SetLineWidth( 1 );
+
+ this->ImageOutlineActorIndex = this->GetNumberOfItems( );
+ this->AddItem( this->ImageOutlineActor );
+
+ /*
+ // Cursor radius
+ double spac[ 3 ];
+ image->GetSpacing( spac );
+ double radius = spac[ 0 ];
+ radius = ( spac[ 1 ] < radius )? spac[ 1 ]: radius;
+ radius = ( spac[ 2 ] < radius )? spac[ 2 ]: radius;
+ radius *= double( 6 );
+ this->Cursor->SetRadius( radius );
+ this->CursorMapper->Modified( );
+ this->CursorActor->Modified( );
+
+ // Plane actors
+ for( int a = 0; a < 3; ++a )
+ {
+ // Configure actors
+ this->Planes[ a ].Configure( this->ImageToWindowLevel->GetOutputPort( ), a );
+ this->Planes[ a ].ConfigureRegion( this->Region->GetOutputPort( ) );
+ this->Planes[ a ].UpdateText( this->GetWindow( ), this->GetLevel( ) );
+
+ // Add them to renderer
+ vtkRenderer* ren = this->Interactors[ a ]->GetRenderWindow( )->
+ GetRenderers( )->GetFirstRenderer( );
+ if( ren == NULL )
+ vtkErrorMacro( "At least one interactor doesn't have a valid renderer" );
+ ren->AddActor( this->Planes[ a ].ImageActor );
+ ren->AddActor( this->Planes[ a ].TextActor );
+
+ for( int i = 0; i < 3; ++i )
+ this->Interactors[ a ]->GetRenderWindow( )->
+ GetRenderers( )->GetFirstRenderer( )->
+ AddActor( this->Planes[ i ].PlaneActor );
+
+ } // rof
+ */
+ // Keep track into collection
+/*
+ this->XPlaneIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 0 ].ImageActor.GetPointer( ) );
+ this->XTextIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 0 ].TextActor.GetPointer( ) );
+ this->XBoundsIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 0 ].PlaneActor.GetPointer( ) );
+
+ this->YPlaneIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 1 ].ImageActor.GetPointer( ) );
+ this->YTextIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 1 ].TextActor.GetPointer( ) );
+ this->YBoundsIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 1 ].PlaneActor.GetPointer( ) );
+
+ this->ZPlaneIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 2 ].ImageActor.GetPointer( ) );
+ this->ZTextIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 2 ].TextActor.GetPointer( ) );
+ this->ZBoundsIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 2 ].PlaneActor.GetPointer( ) );
+*/
+ // Initialize slice visualization
+ this->ResetSlices( );
+
+ /*
+ #error CONTOUR_WIDGET <- ACA VOY
+ static vtkSmartPointer<vtkOrientedGlyphContourRepresentation> contourRep =
+ vtkSmartPointer<vtkOrientedGlyphContourRepresentation>::New();
+ static vtkSmartPointer<vtkContourWidget> contourWidget =
+ vtkSmartPointer<vtkContourWidget>::New();
+ contourWidget->SetInteractor( zi );
+ contourWidget->SetRepresentation( contourRep );
+ contourWidget->On( );
+ */
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+SetSegmentationData( vtkImageData* segmentation )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+PushDataInto( vtkRenderer* x, vtkRenderer* y, vtkRenderer* z, vtkRenderer* w )
+{
+ vtkRenderer* rends[] = { x, y, z };
+ for( int i = 0; i < 3; ++i )
+ {
+ if( rends[ i ] != NULL )
+ {
+ rends[ i ]->AddActor( this->Slices[ i ]->GetImageActor( ) );
+ rends[ i ]->AddActor( this->Slices[ i ]->GetTextActor( ) );
+ for( int j = 0; j < 3; ++j )
+ rends[ i ]->AddActor( this->Slices[ j ]->GetPlaneActor( ) );
+ if( this->Segmentation != NULL )
+ rends[ i ]->AddActor( this->Slices[ i ]->GetSegmentationActor( ) );
+ if( w != NULL )
+ w->AddActor( this->Slices[ i ]->GetPlaneActor( ) );
+
+ } // fi
+
+ } // rof
+
+ if( w != NULL )
+ {
+ w->AddActor( this->ImageOutlineActor );
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+PopDataFrom( vtkRenderer* x, vtkRenderer* y, vtkRenderer* z, vtkRenderer* w )
+{
+}
+
+// -------------------------------------------------------------------------
+double cpPlugins::Extensions::Visualization::MPRActors::
+GetMinWindow( ) const
+{
+ return( double( 0 ) );
+}
+
+// -------------------------------------------------------------------------
+double cpPlugins::Extensions::Visualization::MPRActors::
+GetMaxWindow( ) const
+{
+ if( this->Image == NULL )
+ return( double( 0 ) );
+
+ double range[ 2 ];
+ this->Image->GetScalarRange( range );
+ return( range[ 1 ] - range[ 0 ] );
+}
+
+// -------------------------------------------------------------------------
+double cpPlugins::Extensions::Visualization::MPRActors::
+GetMinLevel( ) const
+{
+ if( this->Image == NULL )
+ return( double( 0 ) );
+
+ double range[ 2 ];
+ this->Image->GetScalarRange( range );
+ return( range[ 0 ] );
+}
+
+// -------------------------------------------------------------------------
+double cpPlugins::Extensions::Visualization::MPRActors::
+GetMaxLevel( ) const
+{
+ if( this->Image == NULL )
+ return( double( 0 ) );
+
+ double range[ 2 ];
+ this->Image->GetScalarRange( range );
+ return( range[ 1 ] );
+}
+
+// -------------------------------------------------------------------------
+double cpPlugins::Extensions::Visualization::MPRActors::
+GetWindow( ) const
+{
+ if( this->Image != NULL )
+ return( this->ImageToWindowLevel->GetWindow( ) );
+ else
+ return( 0 );
+}
+
+// -------------------------------------------------------------------------
+double cpPlugins::Extensions::Visualization::MPRActors::
+GetLevel( ) const
+{
+ if( this->Image != NULL )
+ return( this->ImageToWindowLevel->GetLevel( ) );
+ else
+ return( 0 );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+SetWindow( const double& w )
+{
+ if( this->Image != NULL )
+ this->ImageToWindowLevel->SetWindow( w );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+SetLevel( const double& l )
+{
+ if( this->Image != NULL )
+ this->ImageToWindowLevel->SetLevel( l );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+SetWindowLevel( const double& w, const double& l )
+{
+ this->ImageToWindowLevel->SetWindow( w );
+ this->ImageToWindowLevel->SetLevel( l );
+ for( int i = 0; i < 3; ++i )
+ this->Slices[ i ]->UpdateText( w, l );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+ResetWindowLevel( )
+{
+ double range[ 2 ];
+ this->Image->GetScalarRange( range );
+ this->SetWindowLevel(
+ range[ 1 ] - range[ 0 ],
+ ( ( range[ 1 ] + range[ 0 ] ) / double( 2 ) ) + range[ 0 ]
+ );
+}
+
+// -------------------------------------------------------------------------
+vtkPlane* cpPlugins::Extensions::Visualization::MPRActors::
+GetSlicePlane( const int& axis ) const
+{
+}
+
+// -------------------------------------------------------------------------
+int cpPlugins::Extensions::Visualization::MPRActors::
+GetSliceNumberMinValue( const int& axis ) const
+{
+}
+
+// -------------------------------------------------------------------------
+int cpPlugins::Extensions::Visualization::MPRActors::
+GetSliceNumberMaxValue( const int& axis ) const
+{
+}
+
+// -------------------------------------------------------------------------
+int cpPlugins::Extensions::Visualization::MPRActors::
+GetSlice( const int& axis ) const
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+SetSlice( const int& axis, const int& slice )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+SetSlice( const int& axis, const double& slice )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+ResetSlices( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+GetImageBounds( double bounds[ 6 ] ) const
+{
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Extensions::Visualization::MPRActors::
+MPRActors( )
+ : Superclass( ),
+ Image( NULL ),
+ Segmentation( NULL )
+{
+ this->ImageToWindowLevel =
+ vtkSmartPointer< vtkImageMapToWindowLevelColors >::New( );
+ this->SegmentationToColors = vtkSmartPointer< vtkImageMapToColors >::New( );
+ this->ImageOutlineActor = vtkSmartPointer< vtkActor >::New( );
+ this->Slices[ 0 ] = vtkSmartPointer< TSlice >::New( );
+ this->Slices[ 1 ] = vtkSmartPointer< TSlice >::New( );
+ this->Slices[ 2 ] = vtkSmartPointer< TSlice >::New( );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Extensions::Visualization::MPRActors::
+~MPRActors( )
+{
+}
+
+// eof - $RCSfile$