// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-SetInputConnection( vtkAlgorithmOutput* aout, int axis )
+AddInputConnection( vtkAlgorithmOutput* aout, int axis )
{
- this->SliceMapper->SetInputConnection( aout );
- this->SliceMapper->SetOrientation( axis );
- this->SliceMapper->Update( );
- this->SetSliceNumber( this->SliceMapper->GetSliceNumber( ) );
- this->ImageActor->SetMapper( this->SliceMapper );
- this->ImageActor->Modified( );
+ unsigned int nImages = this->SliceMappers.size( );
+
+ vtkSmartPointer< vtkImageSliceMapper > mapper =
+ vtkSmartPointer< vtkImageSliceMapper >::New( );
+ this->SliceMappers.push_back( mapper );
+ mapper->SetInputConnection( aout );
+ mapper->SetOrientation(
+ ( nImages == 0 )? axis: this->SliceMappers[ 0 ]->GetOrientation( )
+ );
+ mapper->Update( );
+
+ this->SetSliceNumber( this->SliceMappers[ 0 ]->GetSliceNumber( ) );
+
+ vtkSmartPointer< vtkImageActor > actor =
+ vtkSmartPointer< vtkImageActor >::New( );
+ this->ImageActors.push_back( actor );
+ actor->SetMapper( mapper );
+ actor->Modified( );
+
+ if( nImages == 0 )
+ {
+ this->AddItem( this->TextActor );
+ this->AddItem( this->PlaneActor );
+
+ } // fi
+ this->AddItem( actor );
this->Modified( );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-SetInputData( vtkImageData* data, int axis )
+AddInputData( vtkImageData* data, int axis )
{
- this->SliceMapper->SetInputData( data );
- this->SliceMapper->SetOrientation( axis );
- this->SliceMapper->Update( );
- this->SetSliceNumber( this->SliceMapper->GetSliceNumber( ) );
- this->ImageActor->SetMapper( this->SliceMapper );
- this->ImageActor->Modified( );
+ unsigned int nImages = this->SliceMappers.size( );
+
+ vtkSmartPointer< vtkImageSliceMapper > mapper =
+ vtkSmartPointer< vtkImageSliceMapper >::New( );
+ this->SliceMappers.push_back( mapper );
+ mapper->SetInputData( data );
+ mapper->SetOrientation(
+ ( nImages == 0 )? axis: this->SliceMappers[ 0 ]->GetOrientation( )
+ );
+ mapper->Update( );
+
+ this->SetSliceNumber( this->SliceMappers[ 0 ]->GetSliceNumber( ) );
+
+ vtkSmartPointer< vtkImageActor > actor =
+ vtkSmartPointer< vtkImageActor >::New( );
+ this->ImageActors.push_back( actor );
+ actor->SetMapper( mapper );
+ actor->Modified( );
+
+ if( nImages == 0 )
+ {
+ this->AddItem( this->TextActor );
+ this->AddItem( this->PlaneActor );
+
+ } // fi
+ this->AddItem( actor );
this->Modified( );
}
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+Clear( )
+{
+ // Unbind from container
+ this->RemoveAllItems( );
+
+ // Delete all images
+ this->SliceMappers.clear( );
+ this->ImageActors.clear( );
+
+ // Reconfigure unique objects
+ this->PlaneSource = vtkSmartPointer< vtkPolyData >::New( );
+ this->PlaneMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
+ this->TextActor = vtkSmartPointer< vtkTextActor >::New( );
+ this->PlaneActor = vtkSmartPointer< vtkActor >::New( );
+ this->TextBuffer[ 0 ] = '\0';
+
+ // Unique objects configuration
+ 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->PlaneSource->SetPoints( plane_points );
+ this->PlaneSource->SetLines( plane_lines );
+
+ this->PlaneMapper->SetInputData( this->PlaneSource );
+ this->PlaneActor->SetMapper( this->PlaneMapper );
+
+ this->TextActor->SetTextScaleModeToNone( );
+ vtkTextProperty* textprop = this->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->TextActor->GetPositionCoordinate( );
+ coord->SetCoordinateSystemToNormalizedViewport( );
+ coord->SetValue( 0.01, 0.01 );
+}
+
+// -------------------------------------------------------------------------
+unsigned int cpExtensions::Visualization::ImageSliceActors::
+GetNumberOfImageActors( ) const
+{
+ return( this->ImageActors.size( ) );
+}
+
+// -------------------------------------------------------------------------
+vtkImageActor* cpExtensions::Visualization::ImageSliceActors::
+GetImageActor( unsigned int id )
+{
+ if( id < this->ImageActors.size( ) )
+ return( this->ImageActors[ id ] );
+ else
+ return( NULL );
+}
+
+// -------------------------------------------------------------------------
+const vtkImageActor* cpExtensions::Visualization::ImageSliceActors::
+GetImageActor( unsigned int id ) const
+{
+ if( id < this->ImageActors.size( ) )
+ return( this->ImageActors[ id ] );
+ else
+ return( NULL );
+}
+
+// -------------------------------------------------------------------------
+vtkTextActor* cpExtensions::Visualization::ImageSliceActors::
+GetTextActor( )
+{
+ return( this->TextActor );
+}
+
+// -------------------------------------------------------------------------
+const vtkTextActor* cpExtensions::Visualization::ImageSliceActors::
+GetTextActor( ) const
+{
+ return( this->TextActor );
+}
+
+// -------------------------------------------------------------------------
+vtkActor* cpExtensions::Visualization::ImageSliceActors::
+GetPlaneActor( )
+{
+ return( this->PlaneActor );
+}
+
+// -------------------------------------------------------------------------
+const vtkActor* cpExtensions::Visualization::ImageSliceActors::
+GetPlaneActor( ) const
+{
+ return( this->PlaneActor );
+}
+
// -------------------------------------------------------------------------
double* cpExtensions::Visualization::ImageSliceActors::
GetDisplayBounds( ) const
{
- return( this->ImageActor->GetDisplayBounds( ) );
+ if( this->ImageActors.size( ) > 0 )
+ return( this->ImageActors[ 0 ]->GetDisplayBounds( ) );
+ else
+ return( NULL );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
GetDisplayBounds( double bounds[ 6 ] ) const
{
- this->ImageActor->GetDisplayBounds( bounds );
+ if( this->ImageActors.size( ) > 0 )
+ this->ImageActors[ 0 ]->GetDisplayBounds( bounds );
}
// -------------------------------------------------------------------------
int cpExtensions::Visualization::ImageSliceActors::
GetAxis( ) const
{
- return( this->SliceMapper->GetOrientation( ) );
+ if( this->SliceMappers.size( ) > 0 )
+ return( this->SliceMappers[ 0 ]->GetOrientation( ) );
+ else
+ return( -1 );
}
// -------------------------------------------------------------------------
int cpExtensions::Visualization::ImageSliceActors::
GetSliceNumber( ) const
{
- return( this->SliceMapper->GetSliceNumber( ) );
+ if( this->SliceMappers.size( ) > 0 )
+ return( this->SliceMappers[ 0 ]->GetSliceNumber( ) );
+ else
+ return( -1 );
}
// -------------------------------------------------------------------------
int cpExtensions::Visualization::ImageSliceActors::
GetSliceNumberMinValue( ) const
{
- return( this->SliceMapper->GetSliceNumberMinValue( ) );
+ if( this->SliceMappers.size( ) > 0 )
+ return( this->SliceMappers[ 0 ]->GetSliceNumberMinValue( ) );
+ else
+ return( -1 );
}
// -------------------------------------------------------------------------
int cpExtensions::Visualization::ImageSliceActors::
GetSliceNumberMaxValue( ) const
{
- return( this->SliceMapper->GetSliceNumberMaxValue( ) );
+ if( this->SliceMappers.size( ) > 0 )
+ return( this->SliceMappers[ 0 ]->GetSliceNumberMaxValue( ) );
+ else
+ return( -1 );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
SetSliceNumber( const int& slice )
{
- this->SliceMapper->SetSliceNumber( slice );
- this->SliceMapper->Update( );
+ unsigned int nImages = this->SliceMappers.size( );
+ if( nImages == 0 )
+ return;
+
+ // Change visualization extent
+ for( unsigned int i = 0; i < nImages; ++i )
+ {
+ this->SliceMappers[ i ]->SetSliceNumber( slice );
+ this->SliceMappers[ i ]->Modified( );
+ this->ImageActors[ i ]->Modified( );
+ this->SliceMappers[ i ]->Update( );
+
+ } // rof
// Compute plane
- vtkAlgorithm* algo = this->SliceMapper->GetInputAlgorithm( );
+ vtkAlgorithm* algo = this->SliceMappers[ 0 ]->GetInputAlgorithm( );
vtkInformation* info = algo->GetOutputInformation( 0 );
int ext[ 6 ];
double ori[ 3 ], spac[ 3 ], pos[ 3 ];
info->Get( vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT( ), ext );
info->Get( vtkDataObject::ORIGIN( ), ori );
info->Get( vtkDataObject::SPACING( ), spac );
- this->SliceMapper->GetSlicePlane( )->GetOrigin( pos );
+ this->SliceMappers[ 0 ]->GetSlicePlane( )->GetOrigin( pos );
// Prevent obscuring voxels by offsetting the plane geometry
double xbnds[ ] =
} // fi
- int axis = this->SliceMapper->GetOrientation( );
+ int axis = this->SliceMappers[ 0 ]->GetOrientation( );
this->PlaneActor->GetProperty( )->SetRepresentationToWireframe( );
this->PlaneActor->GetProperty( )->SetLineWidth( 2 );
vtkPoints* plane_points = this->PlaneSource->GetPoints( );
void cpExtensions::Visualization::ImageSliceActors::
UpdateText( )
{
- char axis;
- int axId = this->SliceMapper->GetOrientation( );
- if ( axId == 0 ) axis = 'X';
- else if( axId == 1 ) axis = 'Y';
- else if( axId == 2 ) axis = 'Z';
-
- std::sprintf(
- this->TextBuffer, "Axis: %c (%d)",
- axis, this->SliceMapper->GetSliceNumber( )
- );
+ if( this->SliceMappers.size( ) > 0 )
+ {
+ char axis;
+ int axId = this->SliceMappers[ 0 ]->GetOrientation( );
+ if ( axId == 0 ) axis = 'X';
+ else if( axId == 1 ) axis = 'Y';
+ else if( axId == 2 ) axis = 'Z';
+
+ std::sprintf(
+ this->TextBuffer, "Axis: %c (%d)",
+ axis, this->SliceMappers[ 0 ]->GetSliceNumber( )
+ );
+ }
+ else
+ this->TextBuffer[ 0 ] = '\0';
this->TextActor->SetInput( this->TextBuffer );
this->TextActor->Modified( );
this->Modified( );
ImageSliceActors( )
: Superclass( )
{
- this->SliceMapper = vtkSmartPointer< vtkImageSliceMapper >::New( );
- this->PlaneSource = vtkSmartPointer< vtkPolyData >::New( );
- this->PlaneMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->ImageActor = vtkSmartPointer< vtkImageActor >::New( );
- this->TextActor = vtkSmartPointer< vtkTextActor >::New( );
- this->PlaneActor = vtkSmartPointer< vtkActor >::New( );
-
- this->ImageActorIndex = this->GetNumberOfItems( );
- this->TextActorIndex = this->ImageActorIndex + 1;
- this->PlaneActorIndex = this->ImageActorIndex + 2;
- this->AddItem( this->ImageActor );
- this->AddItem( this->TextActor );
- this->AddItem( this->PlaneActor );
-
- // Configuration
- 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->PlaneSource->SetPoints( plane_points );
- this->PlaneSource->SetLines( plane_lines );
-
- this->PlaneMapper->SetInputData( this->PlaneSource );
- this->PlaneActor->SetMapper( this->PlaneMapper );
-
- this->TextActor->SetTextScaleModeToNone( );
- vtkTextProperty* textprop = this->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->TextActor->GetPositionCoordinate( );
- coord->SetCoordinateSystemToNormalizedViewport( );
- coord->SetValue( 0.01, 0.01 );
+ this->Clear( );
}
// -------------------------------------------------------------------------
#include <cpExtensions/cpExtensions_Export.h>
+#include <vector>
+
#include <vtkActor.h>
#include <vtkImageActor.h>
#include <vtkImageSliceMapper.h>
#include <vtkSmartPointer.h>
#include <vtkTextActor.h>
-// -------------------------------------------------------------------------
-#define cpPlugins_ImageSliceActors( name, type ) \
- inline type* Get##name##Actor( ) const \
- { \
- return( \
- dynamic_cast< type* >( \
- const_cast< Self* >( this )-> \
- GetItemAsObject( this->name##ActorIndex ) \
- ) \
- ); \
- }
-
// -------------------------------------------------------------------------
class vtkAlgorithmOutput;
class vtkImageData;
public:
vtkTypeMacro( ImageSliceActors, vtkPropCollection );
- cpPlugins_ImageSliceActors( Image, vtkImageActor );
- cpPlugins_ImageSliceActors( Text, vtkTextActor );
- cpPlugins_ImageSliceActors( Plane, vtkActor );
-
public:
// Creation
static ImageSliceActors* New( );
- void SetInputConnection( vtkAlgorithmOutput* aout, int axis );
- void SetInputData( vtkImageData* data, int axis );
+ void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 0 );
+ void AddInputData( vtkImageData* data, int axis = 0 );
+ void Clear( );
+
+ unsigned int GetNumberOfImageActors( ) const;
+ vtkImageActor* GetImageActor( unsigned int id );
+ const vtkImageActor* GetImageActor( unsigned int id ) const;
+ vtkTextActor* GetTextActor( );
+ const vtkTextActor* GetTextActor( ) const;
+ vtkActor* GetPlaneActor( );
+ const vtkActor* GetPlaneActor( ) const;
double* GetDisplayBounds( ) const;
void GetDisplayBounds( double bounds[ 6 ] ) const;
Self& operator=( const Self& );
protected:
- vtkSmartPointer< vtkImageSliceMapper > SliceMapper;
- vtkSmartPointer< vtkPolyData > PlaneSource;
- vtkSmartPointer< vtkPolyDataMapper > PlaneMapper;
- char TextBuffer[ 1024 ];
-
- vtkSmartPointer< vtkImageActor > ImageActor;
- vtkSmartPointer< vtkTextActor > TextActor;
- vtkSmartPointer< vtkActor > PlaneActor;
-
- unsigned int ImageActorIndex;
- unsigned int TextActorIndex;
- unsigned int PlaneActorIndex;
+ // Multiple actors
+ std::vector< vtkSmartPointer< vtkImageSliceMapper > > SliceMappers;
+ std::vector< vtkSmartPointer< vtkImageActor > > ImageActors;
+
+ // Unique objects
+ vtkSmartPointer< vtkPolyData > PlaneSource;
+ vtkSmartPointer< vtkPolyDataMapper > PlaneMapper;
+ char TextBuffer[ 1024 ];
+ vtkSmartPointer< vtkTextActor > TextActor;
+ vtkSmartPointer< vtkActor > PlaneActor;
};
} // ecapseman
#include <cpExtensions/Visualization/MPRActors.h>
+#include <vtkAlgorithmOutput.h>
#include <vtkImageData.h>
#include <vtkInformation.h>
-#include <vtkOutlineSource.h>
-#include <vtkPolyDataMapper.h>
-#include <vtkProperty.h>
#include <vtkRenderer.h>
#include <vtkWindowLevelLookupTable.h>
}
// -------------------------------------------------------------------------
-cpExtensions::Visualization::
-ImageSliceActors* cpExtensions::Visualization::MPRActors::
-GetSliceActors( const int& i ) const
+int cpExtensions::Visualization::MPRActors::
+AddInputConnection( vtkAlgorithmOutput* aout )
{
- if( i < 3 )
- return( this->Slices[ 0 ][ i ] );
+ int N = this->ImageMaps.size( );
+ if( N == 0 )
+ {
+ this->ImageMaps.push_back(
+ vtkSmartPointer< vtkImageMapToColors >::New( )
+ );
+ this->ImageMaps[ 0 ]->SetInputConnection( aout );
+ this->SetLookupTableToWindowLevel( 0 );
+ this->_Update( 0 );
+ return( 0 );
+ }
else
- return( NULL );
-}
+ {
+ // Check if the image share the same space
+ vtkImageData* ref_image = this->_Image( 0 );
+ vtkImageData* new_image =
+ vtkImageData::SafeDownCast(
+ aout->GetProducer( )->GetOutputInformation( 0 )->
+ Get( vtkDataObject::DATA_OBJECT( ) )
+ );
+ int ref_ext[ 6 ], new_ext[ 6 ];
+ ref_image->GetExtent( ref_ext );
+ new_image->GetExtent( new_ext );
+ if(
+ ref_ext[ 0 ] == new_ext[ 0 ] && ref_ext[ 1 ] == new_ext[ 1 ] &&
+ ref_ext[ 2 ] == new_ext[ 2 ] && ref_ext[ 3 ] == new_ext[ 3 ] &&
+ ref_ext[ 4 ] == new_ext[ 4 ] && ref_ext[ 5 ] == new_ext[ 5 ]
+ )
+ {
+ this->ImageMaps.push_back(
+ vtkSmartPointer< vtkImageMapToColors >::New( )
+ );
+ this->ImageMaps[ N ]->SetInputConnection( aout );
+ this->SetLookupTableToWindowLevel( N );
+ this->_Update( N );
+ return( N );
+ }
+ else
+ return( -1 );
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::MPRActors::
-SetInputConnection( vtkAlgorithmOutput* aout )
-{
- this->ImageMapToColors->SetInputConnection( aout );
- this->SetLookupTableToWindowLevel( );
- this->_UpdateSlices( );
+ } // fi
}
// -------------------------------------------------------------------------
-void cpExtensions::Visualization::MPRActors::
-SetInputData( vtkImageData* image )
+int cpExtensions::Visualization::MPRActors::
+AddInputData( vtkImageData* image )
{
- this->ImageMapToColors->SetInputData( image );
- this->SetLookupTableToWindowLevel( );
- this->_UpdateSlices( );
+ int N = this->ImageMaps.size( );
+ if( N == 0 )
+ {
+ this->ImageMaps.push_back(
+ vtkSmartPointer< vtkImageMapToColors >::New( )
+ );
+ this->ImageMaps[ 0 ]->SetInputData( image );
+ this->SetLookupTableToWindowLevel( 0 );
+ this->_Update( 0 );
+ return( 0 );
+ }
+ else
+ {
+ // Check if the image share the same space
+ vtkImageData* ref_image = this->_Image( 0 );
+ vtkImageData* new_image = image;
+ int ref_ext[ 6 ], new_ext[ 6 ];
+ ref_image->GetExtent( ref_ext );
+ new_image->GetExtent( new_ext );
+ if(
+ ref_ext[ 0 ] == new_ext[ 0 ] && ref_ext[ 1 ] == new_ext[ 1 ] &&
+ ref_ext[ 2 ] == new_ext[ 2 ] && ref_ext[ 3 ] == new_ext[ 3 ] &&
+ ref_ext[ 4 ] == new_ext[ 4 ] && ref_ext[ 5 ] == new_ext[ 5 ]
+ )
+ {
+ this->ImageMaps.push_back(
+ vtkSmartPointer< vtkImageMapToColors >::New( )
+ );
+ this->ImageMaps[ N ]->SetInputData( image );
+ this->SetLookupTableToWindowLevel( N );
+ this->_Update( N );
+ return( N );
+ }
+ else
+ return( -1 );
+
+ } // fi
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
-PushDataInto(
- vtkRenderer* x, vtkRenderer* y, vtkRenderer* z, vtkRenderer* w
- )
+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[ 0 ][ i ]->GetImageActor( ) );
+ for(
+ unsigned int k = 0;
+ k < this->Slices[ 0 ][ i ]->GetNumberOfImageActors( );
+ ++k
+ )
+ rends[ i ]->AddActor( this->Slices[ 0 ][ i ]->GetImageActor( k ) );
rends[ i ]->AddActor( this->Slices[ 0 ][ i ]->GetTextActor( ) );
for( int j = 0; j < 3; ++j )
rends[ i ]->AddActor( this->Slices[ 0 ][ j ]->GetPlaneActor( ) );
} // fi
if( w != NULL )
{
- w->AddActor( this->Slices[ 1 ][ i ]->GetImageActor( ) );
+ for(
+ unsigned int k = 0;
+ k < this->Slices[ 1 ][ i ]->GetNumberOfImageActors( );
+ ++k
+ )
+ w->AddActor( this->Slices[ 1 ][ i ]->GetImageActor( k ) );
w->AddActor( this->Slices[ 1 ][ i ]->GetPlaneActor( ) );
} // fi
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
-PopDataFrom( vtkRenderer* x, vtkRenderer* y, vtkRenderer* z, vtkRenderer* w )
+PopDataFrom(
+ 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 ]->RemoveActor( this->Slices[ 0 ][ i ]->GetImageActor( ) );
+ for(
+ unsigned int k = 0;
+ k < this->Slices[ 0 ][ i ]->GetNumberOfImageActors( );
+ ++k
+ )
+ rends[ i ]->RemoveActor( this->Slices[ 0 ][ i ]->GetImageActor( k ) );
rends[ i ]->RemoveActor( this->Slices[ 0 ][ i ]->GetTextActor( ) );
for( int j = 0; j < 3; ++j )
rends[ i ]->RemoveActor( this->Slices[ 0 ][ j ]->GetPlaneActor( ) );
- if( w != NULL )
- {
- w->RemoveActor( this->Slices[ 1 ][ i ]->GetImageActor( ) );
- w->RemoveActor( this->Slices[ 1 ][ i ]->GetPlaneActor( ) );
- } // fi
+ } // fi
+ if( w != NULL )
+ {
+ for(
+ unsigned int k = 0;
+ k < this->Slices[ 1 ][ i ]->GetNumberOfImageActors( );
+ ++k
+ )
+ w->RemoveActor( this->Slices[ 1 ][ i ]->GetImageActor( k ) );
+ w->RemoveActor( this->Slices[ 1 ][ i ]->GetPlaneActor( ) );
} // fi
} // rof
-
if( w != NULL )
w->RemoveActor( this->ImageOutlineActor );
}
-// -------------------------------------------------------------------------
-vtkScalarsToColors* cpExtensions::Visualization::MPRActors::
-GetLookupTable( ) const
-{
- return( this->ImageMapToColors->GetLookupTable( ) );
-}
-
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
-SetLookupTable( vtkScalarsToColors* lut )
+SetLookupTable( unsigned int i, vtkScalarsToColors* lut )
{
- this->ImageMapToColors->SetLookupTable( lut );
- this->ImageMapToColors->Update( );
- this->Modified( );
+ if( i < this->ImageMaps.size( ) )
+ {
+ this->ImageMaps[ i ]->SetLookupTable( lut );
+ this->ImageMaps[ i ]->Update( );
+ this->Modified( );
+
+ } // fi
}
// -------------------------------------------------------------------------
-vtkWindowLevelLookupTable* cpExtensions::Visualization::MPRActors::
-GetLookupTableAsWindowLevel( ) const
+vtkScalarsToColors* cpExtensions::Visualization::MPRActors::
+GetLookupTable( unsigned int i ) const
{
- return(
- dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( ) )
- );
+ if( i < this->ImageMaps.size( ) )
+ return( this->ImageMaps[ i ]->GetLookupTable( ) );
+ else
+ return( NULL );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
-SetLookupTableToWindowLevel( )
+SetLookupTableToWindowLevel( unsigned int i )
{
// Check if the input has been configured
- vtkImageData* image = this->_InputImage( );
+ vtkImageData* image = this->_Image( i );
if( image == NULL )
return;
lut->SetTableRange( r );
lut->Build( );
- this->SetLookupTable( lut );
+ this->SetLookupTable( i, lut );
}
// -------------------------------------------------------------------------
double cpExtensions::Visualization::MPRActors::
-GetMinWindow( ) const
+GetMinWindow( unsigned int i ) const
{
- return( double( 0 ) );
+ return( 0 );
}
// -------------------------------------------------------------------------
double cpExtensions::Visualization::MPRActors::
-GetMaxWindow( ) const
+GetMaxWindow( unsigned int i ) const
{
// Check if the input has been configured
- vtkImageData* image = this->_InputImage( );
+ vtkImageData* image = this->_Image( i );
if( image == NULL )
return( double( 0 ) );
// -------------------------------------------------------------------------
double cpExtensions::Visualization::MPRActors::
-GetMinLevel( ) const
+GetMinLevel( unsigned int i ) const
{
// Check if the input has been configured
- vtkImageData* image = this->_InputImage( );
+ vtkImageData* image = this->_Image( i );
if( image == NULL )
return( double( 0 ) );
// -------------------------------------------------------------------------
double cpExtensions::Visualization::MPRActors::
-GetMaxLevel( ) const
+GetMaxLevel( unsigned int i ) const
{
// Check if the input has been configured
- vtkImageData* image = this->_InputImage( );
+ vtkImageData* image = this->_Image( i );
if( image == NULL )
return( double( 0 ) );
// -------------------------------------------------------------------------
double cpExtensions::Visualization::MPRActors::
-GetWindow( ) const
+GetWindow( unsigned int i ) const
{
- vtkWindowLevelLookupTable* lut = this->GetLookupTableAsWindowLevel( );
+ vtkWindowLevelLookupTable* lut =
+ dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
if( lut != NULL )
return( lut->GetWindow( ) );
else
// -------------------------------------------------------------------------
double cpExtensions::Visualization::MPRActors::
-GetLevel( ) const
+GetLevel( unsigned int i ) const
{
- vtkWindowLevelLookupTable* lut = this->GetLookupTableAsWindowLevel( );
+ vtkWindowLevelLookupTable* lut =
+ dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
if( lut != NULL )
return( lut->GetLevel( ) );
else
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
-SetWindow( const double& w )
+SetWindow( unsigned int i, const double& w )
{
- vtkWindowLevelLookupTable* lut = this->GetLookupTableAsWindowLevel( );
+ vtkWindowLevelLookupTable* lut =
+ dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
if( lut != NULL )
{
lut->SetWindow( w );
lut->Build( );
- this->ImageMapToColors->Modified( );
+ this->ImageMaps[ i ]->Modified( );
this->Modified( );
} // fi
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
-SetLevel( const double& l )
+SetLevel( unsigned int i, const double& l )
{
- vtkWindowLevelLookupTable* lut = this->GetLookupTableAsWindowLevel( );
+ vtkWindowLevelLookupTable* lut =
+ dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
if( lut != NULL )
{
lut->SetLevel( l );
lut->Build( );
- this->ImageMapToColors->Modified( );
+ this->ImageMaps[ i ]->Modified( );
this->Modified( );
} // fi
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
-SetWindowLevel( const double& w, const double& l )
+ResetWindowLevel( unsigned int i )
{
- vtkWindowLevelLookupTable* lut = this->GetLookupTableAsWindowLevel( );
- if( lut != NULL )
- {
- lut->SetWindow( l );
- lut->SetLevel( l );
- lut->Build( );
- this->ImageMapToColors->Modified( );
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::MPRActors::
-ResetWindowLevel( )
-{
- vtkImageData* image = this->_InputImage( );
- vtkWindowLevelLookupTable* lut = this->GetLookupTableAsWindowLevel( );
+ vtkImageData* image = this->_Image( i );
+ vtkWindowLevelLookupTable* lut =
+ dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
if( image != NULL && lut != NULL )
{
double r[ 2 ];
image->GetScalarRange( r );
lut->SetTableRange( r );
lut->Build( );
- this->ImageMapToColors->Modified( );
+ this->ImageMaps[ i ]->Modified( );
this->Modified( );
} // fi
void cpExtensions::Visualization::MPRActors::
SetSlice( const int& axis, const int& slice )
{
- vtkImageData* image = this->_InputImage( );
+ vtkImageData* image = this->_Image( 0 );
if( image == NULL )
return;
void cpExtensions::Visualization::MPRActors::
SetSlice( const int& axis, const double& slice )
{
- vtkImageData* image = this->_InputImage( );
+ vtkImageData* image = this->_Image( 0 );
if( image == NULL )
return;
// TODO
}
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::MPRActors::
-GetImageBounds( double bounds[ 6 ] ) const
-{
- vtkImageData* image = this->_InputImage( );
- if( image != NULL )
- image->GetBounds( bounds );
-}
-
// -------------------------------------------------------------------------
cpExtensions::Visualization::MPRActors::
MPRActors( )
: Superclass( )
{
- this->ImageMapToColors = vtkSmartPointer< vtkImageMapToColors >::New( );
this->ImageOutlineActor = vtkSmartPointer< vtkActor >::New( );
- this->Slices[ 0 ][ 0 ] = vtkSmartPointer< _TSlice >::New( );
- this->Slices[ 0 ][ 1 ] = vtkSmartPointer< _TSlice >::New( );
- this->Slices[ 0 ][ 2 ] = vtkSmartPointer< _TSlice >::New( );
- this->Slices[ 1 ][ 0 ] = vtkSmartPointer< _TSlice >::New( );
- this->Slices[ 1 ][ 1 ] = vtkSmartPointer< _TSlice >::New( );
- this->Slices[ 1 ][ 2 ] = vtkSmartPointer< _TSlice >::New( );
+ for( unsigned int i = 0; i < 2; ++i )
+ for( unsigned int j = 0; j < 3; ++j )
+ this->Slices[ i ][ j ] = vtkSmartPointer< ImageSliceActors >::New( );
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
vtkImageData* cpExtensions::Visualization::MPRActors::
-_InputImage( ) const
+_Image( unsigned int i ) const
{
- vtkAlgorithm* algo = this->ImageMapToColors->GetInputAlgorithm( );
- vtkInformation* info = algo->GetOutputInformation( 0 );
- return(
- vtkImageData::SafeDownCast( info->Get( vtkDataObject::DATA_OBJECT( ) ) )
- );
+ if( i < this->ImageMaps.size( ) )
+ {
+ vtkAlgorithm* algo = this->ImageMaps[ i ]->GetInputAlgorithm( );
+ vtkInformation* info = algo->GetOutputInformation( 0 );
+ return(
+ vtkImageData::SafeDownCast( info->Get( vtkDataObject::DATA_OBJECT( ) ) )
+ );
+ }
+ else
+ return( NULL );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
-_UpdateSlices( )
+_Update( unsigned int i )
{
+ /*
// Check if the input has been configured
vtkImageData* image = this->_InputImage( );
if( image == NULL )
{
for( int i = 0; i < 3; ++i )
{
- this->Slices[ j ][ i ]->SetInputConnection(
+ this->Slices[ j ][ i ]->AddInputConnection(
this->ImageMapToColors->GetOutputPort( ), i
);
this->Slices[ j ][ i ]->UpdateText( );
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( );
*/
}
#ifndef __CPEXTENSIONS__VISUALIZATION__MPRACTORS__H__
#define __CPEXTENSIONS__VISUALIZATION__MPRACTORS__H__
+#include <vector>
+
#include <cpExtensions/cpExtensions_Export.h>
#include <cpExtensions/Visualization/ImageSliceActors.h>
+#include <vtkSmartPointer.h>
#include <vtkActor.h>
#include <vtkImageMapToColors.h>
class vtkImageData;
class vtkRenderer;
class vtkScalarsToColors;
-class vtkWindowLevelLookupTable;
// -------------------------------------------------------------------------
namespace cpExtensions
public:
vtkTypeMacro( MPRActors, vtkPropCollection );
- cpPlugins_ImageSliceActors( ImageOutline, vtkImageActor );
-
public:
// Creation
static MPRActors* New( );
- ImageSliceActors* GetSliceActors( const int& i ) const;
- void SetInputConnection( vtkAlgorithmOutput* aout );
- void SetInputData( vtkImageData* image );
+ // TODO: ImageSliceActors* GetSliceActors( const int& i ) const;
+
+ int AddInputConnection( vtkAlgorithmOutput* aout );
+ int AddInputData( vtkImageData* image );
+
+ /*
+ void SetInputConnection( vtkAlgorithmOutput* aout );
+ void SetInputData( vtkImageData* image );
+ */
void PushDataInto(
vtkRenderer* x,
);
// Lookup table methods
- vtkScalarsToColors* GetLookupTable( ) const;
- void SetLookupTable( vtkScalarsToColors* lut );
+ void SetLookupTable( unsigned int i, vtkScalarsToColors* lut );
+ vtkScalarsToColors* GetLookupTable( unsigned int i ) const;
// Grayscale window/level lookup
- vtkWindowLevelLookupTable* GetLookupTableAsWindowLevel( ) const;
- void SetLookupTableToWindowLevel( );
- double GetMinWindow( ) const;
- double GetMaxWindow( ) const;
- double GetMinLevel( ) const;
- double GetMaxLevel( ) const;
- double GetWindow( ) const;
- double GetLevel( ) const;
- void SetWindow( const double& w );
- void SetLevel( const double& l );
- void SetWindowLevel( const double& w, const double& l );
- void ResetWindowLevel( );
+ void SetLookupTableToWindowLevel( unsigned int i );
+ double GetMinWindow( unsigned int i ) const;
+ double GetMaxWindow( unsigned int i ) const;
+ double GetMinLevel( unsigned int i ) const;
+ double GetMaxLevel( unsigned int i ) const;
+ double GetWindow( unsigned int i ) const;
+ double GetLevel( unsigned int i ) const;
+ void SetWindow( unsigned int i, const double& w );
+ void SetLevel( unsigned int i, const double& l );
+ void ResetWindowLevel( unsigned int i );
// Slice access
int GetSliceNumberMinValue( const int& axis ) const;
void SetSlice( const int& axis, const double& slice );
void ResetSlices( );
- // General accessors
- void GetImageBounds( double bounds[ 6 ] ) const;
-
protected:
MPRActors( );
virtual ~MPRActors( );
- vtkImageData* _InputImage( ) const;
- void _UpdateSlices( );
+ vtkImageData* _Image( unsigned int i ) const;
+ void _Update( unsigned int i );
private:
// Purposely not implemented
Self& operator=( const Self& );
protected:
- vtkSmartPointer< vtkImageMapToColors > ImageMapToColors;
- vtkSmartPointer< vtkActor > ImageOutlineActor;
-
- typedef
- cpExtensions::Visualization::ImageSliceActors
- _TSlice;
- vtkSmartPointer< _TSlice > Slices[ 2 ][ 3 ];
-
- unsigned int ImageOutlineActorIndex;
+ std::vector< vtkSmartPointer< vtkImageMapToColors > > ImageMaps;
+ vtkSmartPointer< vtkActor > ImageOutlineActor;
+ vtkSmartPointer< ImageSliceActors > Slices[ 2 ][ 3 ];
};
} // ecapseman