#include <vtkAlgorithmOutput.h>
#include <vtkImageData.h>
-#include <vtkInformation.h>
+#include <vtkOutlineSource.h>
+#include <vtkProperty.h>
#include <vtkRenderer.h>
-#include <vtkWindowLevelLookupTable.h>
+#include <vtkRendererCollection.h>
+#include <vtkRenderWindow.h>
// -------------------------------------------------------------------------
cpExtensions::Visualization::MPRActors*
}
// -------------------------------------------------------------------------
-int cpExtensions::Visualization::MPRActors::
-AddInputConnection( vtkAlgorithmOutput* aout )
+void cpExtensions::Visualization::MPRActors::
+SetInputConnection( vtkAlgorithmOutput* aout )
{
- 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
+ for( int i = 0; i < 2; ++i )
{
- // 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 ]
- )
+ for( int j = 0; j < 3; ++j )
{
- this->ImageMaps.push_back(
- vtkSmartPointer< vtkImageMapToColors >::New( )
- );
- this->ImageMaps[ N ]->SetInputConnection( aout );
- this->SetLookupTableToWindowLevel( N );
- this->_Update( N );
- return( N );
- }
- else
- return( -1 );
+ this->Slices[ i ][ j ]->SetInputConnection( aout );
+ this->Slices[ i ][ j ]->SetAxis( j );
- } // fi
+ } // rof
+
+ } // rof
+ this->_CreateBoundingBox( );
}
// -------------------------------------------------------------------------
-int cpExtensions::Visualization::MPRActors::
-AddInputData( vtkImageData* image )
+void cpExtensions::Visualization::MPRActors::
+SetInputImage( vtkImageData* data )
{
- int N = this->ImageMaps.size( );
- if( N == 0 )
+ for( int i = 0; i < 2; ++i )
{
- 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 ]
- )
+ for( int j = 0; j < 3; ++j )
{
- this->ImageMaps.push_back(
- vtkSmartPointer< vtkImageMapToColors >::New( )
- );
- this->ImageMaps[ N ]->SetInputData( image );
- this->SetLookupTableToWindowLevel( N );
- this->_Update( N );
- return( N );
- }
- else
- return( -1 );
+ this->Slices[ i ][ j ]->SetInputImage( data );
+ this->Slices[ i ][ j ]->SetAxis( j );
- } // fi
+ } // rof
+
+ } // rof
+ this->_CreateBoundingBox( );
}
// -------------------------------------------------------------------------
-void cpExtensions::Visualization::MPRActors::
-PushDataInto( vtkRenderer* x, vtkRenderer* y, vtkRenderer* z, vtkRenderer* w )
+int cpExtensions::Visualization::MPRActors::
+AddBinaryConnection(
+ vtkAlgorithmOutput* aout,
+ const double& r, const double& g, const double& b
+ )
{
- vtkRenderer* rends[] = { x, y, z };
- for( int i = 0; i < 3; ++i )
- {
- if( rends[ i ] != NULL )
- {
- 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 )
- {
- 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
+ this->Slices[ 0 ][ 0 ]->AddBinaryConnection( aout, r, g, b );
+ this->Slices[ 0 ][ 1 ]->AddBinaryConnection( aout, r, g, b );
+ this->Slices[ 0 ][ 2 ]->AddBinaryConnection( aout, r, g, b );
+ this->Slices[ 1 ][ 0 ]->AddBinaryConnection( aout, r, g, b );
+ this->Slices[ 1 ][ 1 ]->AddBinaryConnection( aout, r, g, b );
+ return( this->Slices[ 1 ][ 2 ]->AddBinaryConnection( aout, r, g, b ) );
+}
- } // rof
- if( w != NULL )
- w->AddActor( this->ImageOutlineActor );
+// -------------------------------------------------------------------------
+int cpExtensions::Visualization::MPRActors::
+AddBinaryImage(
+ vtkImageData* data,
+ const double& r, const double& g, const double& b
+ )
+{
+ this->Slices[ 0 ][ 0 ]->AddBinaryImage( data, r, g, b );
+ this->Slices[ 0 ][ 1 ]->AddBinaryImage( data, r, g, b );
+ this->Slices[ 0 ][ 2 ]->AddBinaryImage( data, r, g, b );
+ this->Slices[ 1 ][ 0 ]->AddBinaryImage( data, r, g, b );
+ this->Slices[ 1 ][ 1 ]->AddBinaryImage( data, r, g, b );
+ return( this->Slices[ 1 ][ 2 ]->AddBinaryImage( data, r, g, b ) );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
-PopDataFrom(
- vtkRenderer* x,
- vtkRenderer* y,
- vtkRenderer* z,
- vtkRenderer* w
- )
+Clear( )
{
- vtkRenderer* rends[] = { x, y, z };
- for( int i = 0; i < 3; ++i )
- {
- if( rends[ i ] != NULL )
- {
- 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( ) );
+ this->Slices[ 0 ][ 0 ]->Clear( );
+ this->Slices[ 0 ][ 1 ]->Clear( );
+ this->Slices[ 0 ][ 2 ]->Clear( );
+ this->Slices[ 1 ][ 0 ]->Clear( );
+ this->Slices[ 1 ][ 1 ]->Clear( );
+ this->Slices[ 1 ][ 2 ]->Clear( );
+}
- } // 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( ) );
+// -------------------------------------------------------------------------
+vtkImageData* cpExtensions::Visualization::MPRActors::
+GetInputImage( )
+{
+ return( this->Slices[ 0 ][ 0 ]->GetInputImage( ) );
+}
- } // fi
+// -------------------------------------------------------------------------
+const vtkImageData* cpExtensions::Visualization::MPRActors::
+GetInputImage( ) const
+{
+ return( this->Slices[ 0 ][ 0 ]->GetInputImage( ) );
+}
- } // rof
- if( w != NULL )
- w->RemoveActor( this->ImageOutlineActor );
+// -------------------------------------------------------------------------
+unsigned int cpExtensions::Visualization::MPRActors::
+GetNumberOfImages( ) const
+{
+ return( this->Slices[ 0 ][ 0 ]->GetNumberOfImages( ) );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
-SetLookupTable( unsigned int i, vtkScalarsToColors* lut )
+SetInterpolate( bool v )
{
- if( i < this->ImageMaps.size( ) )
- {
- this->ImageMaps[ i ]->SetLookupTable( lut );
- this->ImageMaps[ i ]->Update( );
- this->Modified( );
+ this->Slices[ 0 ][ 0 ]->SetInterpolate( v );
+ this->Slices[ 0 ][ 1 ]->SetInterpolate( v );
+ this->Slices[ 0 ][ 2 ]->SetInterpolate( v );
+ this->Slices[ 1 ][ 0 ]->SetInterpolate( v );
+ this->Slices[ 1 ][ 1 ]->SetInterpolate( v );
+ this->Slices[ 1 ][ 2 ]->SetInterpolate( v );
+}
- } // fi
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+InterpolateOn( )
+{
+ this->SetInterpolate( true );
}
// -------------------------------------------------------------------------
-vtkScalarsToColors* cpExtensions::Visualization::MPRActors::
-GetLookupTable( unsigned int i ) const
+void cpExtensions::Visualization::MPRActors::
+InterpolateOff( )
{
- if( i < this->ImageMaps.size( ) )
- return( this->ImageMaps[ i ]->GetLookupTable( ) );
- else
- return( NULL );
+ this->SetInterpolate( false );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
-SetLookupTableToWindowLevel( unsigned int i )
+PushActorsInto(
+ vtkRenderWindow* x,
+ vtkRenderWindow* y,
+ vtkRenderWindow* z,
+ vtkRenderWindow* w
+ )
{
- // Check if the input has been configured
- vtkImageData* image = this->_Image( i );
- if( image == NULL )
- return;
+ this->Slices[ 0 ][ 0 ]->PushActorsInto( x, true );
+ this->Slices[ 0 ][ 1 ]->PushActorsInto( y, true );
+ this->Slices[ 0 ][ 2 ]->PushActorsInto( z, true );
+ this->Slices[ 1 ][ 0 ]->PushActorsInto( w, false );
+ this->Slices[ 1 ][ 1 ]->PushActorsInto( w, false );
+ this->Slices[ 1 ][ 2 ]->PushActorsInto( w, false );
+
+ vtkRenderer* wren =
+ ( w != NULL )? w->GetRenderers( )->GetFirstRenderer( ): NULL;
+ if( wren != NULL )
+ {
+ wren->AddViewProp( this->ImageOutlineActor );
+ wren->AddViewProp( this->Slices[ 1 ][ 0 ]->GetPlaneActor( ) );
+ wren->AddViewProp( this->Slices[ 1 ][ 1 ]->GetPlaneActor( ) );
+ wren->AddViewProp( this->Slices[ 1 ][ 2 ]->GetPlaneActor( ) );
- double r[ 2 ];
- image->GetScalarRange( r );
+ } // fi
+}
- vtkSmartPointer< vtkWindowLevelLookupTable > lut =
- vtkSmartPointer< vtkWindowLevelLookupTable >::New( );
- lut->SetScaleToLinear( );
- lut->SetTableRange( r );
- lut->Build( );
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+PopActorsFrom(
+ vtkRenderWindow* x,
+ vtkRenderWindow* y,
+ vtkRenderWindow* z,
+ vtkRenderWindow* w
+ )
+{
+ this->Slices[ 0 ][ 0 ]->PopActorsFrom( x );
+ this->Slices[ 0 ][ 1 ]->PopActorsFrom( y );
+ this->Slices[ 0 ][ 2 ]->PopActorsFrom( z );
+ this->Slices[ 1 ][ 0 ]->PopActorsFrom( w );
+ this->Slices[ 1 ][ 1 ]->PopActorsFrom( w );
+ this->Slices[ 1 ][ 2 ]->PopActorsFrom( w );
+
+ vtkRenderer* wren =
+ ( w != NULL )? w->GetRenderers( )->GetFirstRenderer( ): NULL;
+ if( wren != NULL )
+ {
+ wren->RemoveViewProp( this->ImageOutlineActor );
+ wren->RemoveViewProp( this->Slices[ 1 ][ 0 ]->GetPlaneActor( ) );
+ wren->RemoveViewProp( this->Slices[ 1 ][ 1 ]->GetPlaneActor( ) );
+ wren->RemoveViewProp( this->Slices[ 1 ][ 2 ]->GetPlaneActor( ) );
- this->SetLookupTable( i, lut );
+ } // fi
}
// -------------------------------------------------------------------------
double cpExtensions::Visualization::MPRActors::
-GetMinWindow( unsigned int i ) const
+GetMinWindow( ) const
{
- return( 0 );
+ return( this->Slices[ 0 ][ 0 ]->GetMinWindow( ) );
}
// -------------------------------------------------------------------------
double cpExtensions::Visualization::MPRActors::
-GetMaxWindow( unsigned int i ) const
+GetMaxWindow( ) const
{
- // Check if the input has been configured
- vtkImageData* image = this->_Image( i );
- if( image == NULL )
- return( double( 0 ) );
-
- double r[ 2 ];
- image->GetScalarRange( r );
- return( r[ 1 ] - r[ 0 ] );
+ return( this->Slices[ 0 ][ 0 ]->GetMaxWindow( ) );
}
// -------------------------------------------------------------------------
double cpExtensions::Visualization::MPRActors::
-GetMinLevel( unsigned int i ) const
+GetMinLevel( ) const
{
- // Check if the input has been configured
- vtkImageData* image = this->_Image( i );
- if( image == NULL )
- return( double( 0 ) );
-
- double r[ 2 ];
- image->GetScalarRange( r );
- return( r[ 0 ] );
+ return( this->Slices[ 0 ][ 0 ]->GetMinLevel( ) );
}
// -------------------------------------------------------------------------
double cpExtensions::Visualization::MPRActors::
-GetMaxLevel( unsigned int i ) const
+GetMaxLevel( ) const
{
- // Check if the input has been configured
- vtkImageData* image = this->_Image( i );
- if( image == NULL )
- return( double( 0 ) );
-
- double r[ 2 ];
- image->GetScalarRange( r );
- return( r[ 1 ] );
+ return( this->Slices[ 0 ][ 0 ]->GetMaxLevel( ) );
}
// -------------------------------------------------------------------------
double cpExtensions::Visualization::MPRActors::
-GetWindow( unsigned int i ) const
+GetWindow( )
{
- vtkWindowLevelLookupTable* lut =
- dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
- if( lut != NULL )
- return( lut->GetWindow( ) );
- else
- return( double( 0 ) );
+ return( this->Slices[ 0 ][ 0 ]->GetWindow( ) );
}
// -------------------------------------------------------------------------
double cpExtensions::Visualization::MPRActors::
-GetLevel( unsigned int i ) const
+GetLevel( )
{
- vtkWindowLevelLookupTable* lut =
- dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
- if( lut != NULL )
- return( lut->GetLevel( ) );
- else
- return( double( 0 ) );
+ return( this->Slices[ 0 ][ 0 ]->GetLevel( ) );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
-SetWindow( unsigned int i, const double& w )
+SetWindow( double w )
{
- vtkWindowLevelLookupTable* lut =
- dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
- if( lut != NULL )
- {
- lut->SetWindow( w );
- lut->Build( );
- this->ImageMaps[ i ]->Modified( );
- this->Modified( );
-
- } // fi
+ this->Slices[ 0 ][ 0 ]->SetWindow( w );
+ this->Slices[ 0 ][ 1 ]->SetWindow( w );
+ this->Slices[ 0 ][ 2 ]->SetWindow( w );
+ this->Slices[ 1 ][ 0 ]->SetWindow( w );
+ this->Slices[ 1 ][ 1 ]->SetWindow( w );
+ this->Slices[ 1 ][ 2 ]->SetWindow( w );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
-SetLevel( unsigned int i, const double& l )
+SetLevel( double l )
{
- vtkWindowLevelLookupTable* lut =
- dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
- if( lut != NULL )
- {
- lut->SetLevel( l );
- lut->Build( );
- this->ImageMaps[ i ]->Modified( );
- this->Modified( );
+ this->Slices[ 0 ][ 0 ]->SetLevel( l );
+ this->Slices[ 0 ][ 1 ]->SetLevel( l );
+ this->Slices[ 0 ][ 2 ]->SetLevel( l );
+ this->Slices[ 1 ][ 0 ]->SetLevel( l );
+ this->Slices[ 1 ][ 1 ]->SetLevel( l );
+ this->Slices[ 1 ][ 2 ]->SetLevel( l );
+}
- } // fi
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+SetWindowLevel( double w, double l )
+{
+ this->Slices[ 0 ][ 0 ]->SetWindowLevel( w, l );
+ this->Slices[ 0 ][ 1 ]->SetWindowLevel( w, l );
+ this->Slices[ 0 ][ 2 ]->SetWindowLevel( w, l );
+ this->Slices[ 1 ][ 0 ]->SetWindowLevel( w, l );
+ this->Slices[ 1 ][ 1 ]->SetWindowLevel( w, l );
+ this->Slices[ 1 ][ 2 ]->SetWindowLevel( w, l );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
-ResetWindowLevel( unsigned int i )
+ResetWindowLevel( )
{
- 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->ImageMaps[ i ]->Modified( );
- this->Modified( );
+ this->Slices[ 0 ][ 0 ]->ResetWindowLevel( );
+ this->Slices[ 0 ][ 1 ]->ResetWindowLevel( );
+ this->Slices[ 0 ][ 2 ]->ResetWindowLevel( );
+ this->Slices[ 1 ][ 0 ]->ResetWindowLevel( );
+ this->Slices[ 1 ][ 1 ]->ResetWindowLevel( );
+ this->Slices[ 1 ][ 2 ]->ResetWindowLevel( );
+}
- } // fi
+// -------------------------------------------------------------------------
+int cpExtensions::Visualization::MPRActors::
+GetSliceNumber( const int& axis ) const
+{
+ if( axis < 3 )
+ return( this->Slices[ 0 ][ axis ]->GetSliceNumber( ) );
+ else
+ return( -1 );
}
// -------------------------------------------------------------------------
int cpExtensions::Visualization::MPRActors::
GetSliceNumberMinValue( const int& axis ) const
{
- return( this->Slices[ 0 ][ axis ]->GetSliceNumberMinValue( ) );
+ if( axis < 3 )
+ return( this->Slices[ 0 ][ axis ]->GetSliceNumberMinValue( ) );
+ else
+ return( -1 );
}
// -------------------------------------------------------------------------
int cpExtensions::Visualization::MPRActors::
GetSliceNumberMaxValue( const int& axis ) const
{
- return( this->Slices[ 0 ][ axis ]->GetSliceNumberMaxValue( ) );
+ if( axis < 3 )
+ return( this->Slices[ 0 ][ axis ]->GetSliceNumberMaxValue( ) );
+ else
+ return( -1 );
}
// -------------------------------------------------------------------------
-int cpExtensions::Visualization::MPRActors::
-GetSlice( const int& axis ) const
+void cpExtensions::Visualization::MPRActors::
+SetSliceNumber( const int& axis, const int& slice )
{
- return( this->Slices[ 0 ][ axis ]->GetSliceNumber( ) );
+ if( axis < 3 )
+ {
+ this->Slices[ 0 ][ axis ]->SetSliceNumber( slice );
+ this->Slices[ 1 ][ axis ]->SetSliceNumber( slice );
+
+ } // fi
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
-SetSlice( const int& axis, const int& slice )
+SetSlice( const int& axis, double* pos )
{
- vtkImageData* image = this->_Image( 0 );
- if( image == NULL )
- return;
-
- // Get image data extent
- int ext[ 6 ];
- image->GetExtent( ext );
+ if( axis < 3 )
+ {
+ this->Slices[ 0 ][ axis ]->SetSlice( pos );
+ this->Slices[ 1 ][ axis ]->SetSlice( pos );
- // Check if the slice is valid
- int real = slice;
- if( slice < ext[ axis << 1 ] )
- real = ext[ axis << 1 ];
- if( ext[ ( axis << 1 ) + 1 ] < slice )
- real = ext[ ( axis << 1 ) + 1 ];
+ } // fi
+}
- // Change slice
- this->Slices[ 0 ][ axis ]->SetSliceNumber( real );
- this->Slices[ 1 ][ axis ]->SetSliceNumber( real );
- this->Modified( );
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+SetAxesCursor( const int& axis, double* pos )
+{
+ if( axis < 3 )
+ this->Slices[ 0 ][ axis ]->SetAxesCursor( pos );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
-SetSlice( const int& axis, const double& slice )
+Render( const int& axis )
{
- vtkImageData* image = this->_Image( 0 );
- if( image == NULL )
- return;
+ if( axis < 3 )
+ {
+ this->Slices[ 0 ][ axis ]->Render( );
+ this->Slices[ 1 ][ axis ]->Render( );
- double x[ 3 ] = { double( 0 ) };
- double pcoords[ 3 ];
- int ijk[ 3 ];
+ } // fi
+}
- x[ axis ] = slice;
- image->ComputeStructuredCoordinates( x, ijk, pcoords );
- this->SetSlice( axis, ijk[ axis ] );
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+Render( )
+{
+ this->Render( 0 );
+ this->Render( 1 );
+ this->Render( 2 );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+ResetCamera( const int& axis )
+{
+ if( axis < 3 )
+ this->Slices[ 0 ][ axis ]->ResetCamera( );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
-ResetSlices( )
+ResetCameras( )
{
- // TODO
+ this->ResetCamera( 0 );
+ this->ResetCamera( 1 );
+ this->ResetCamera( 2 );
}
// -------------------------------------------------------------------------
for( unsigned int i = 0; i < 2; ++i )
for( unsigned int j = 0; j < 3; ++j )
this->Slices[ i ][ j ] = vtkSmartPointer< ImageSliceActors >::New( );
+
+ this->Slices[ 0 ][ 0 ]->AssociateSlice( this->Slices[ 1 ][ 0 ] );
+ this->Slices[ 0 ][ 1 ]->AssociateSlice( this->Slices[ 1 ][ 1 ] );
+ this->Slices[ 0 ][ 2 ]->AssociateSlice( this->Slices[ 1 ][ 2 ] );
+
+ for( unsigned int i = 0; i < 3; ++ i )
+ {
+ this->Slices[ 0 ][ i ]->AddRenderCommand(
+ Self::_RenderCommand, this
+ );
+ this->Slices[ 0 ][ i ]->AddWindowLevelCommand(
+ Self::_WindowLevelCommand, this
+ );
+ this->Slices[ 0 ][ i ]->AddSlicesCommand( Self::_SlicesCommand, this );
+
+ } // rof
}
// -------------------------------------------------------------------------
{
}
-// -------------------------------------------------------------------------
-vtkImageData* cpExtensions::Visualization::MPRActors::
-_Image( unsigned int i ) const
-{
- 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::
-_Update( unsigned int i )
+_CreateBoundingBox( )
{
- /*
- // Check if the input has been configured
- vtkImageData* image = this->_InputImage( );
+ vtkImageData* image =
+ dynamic_cast< vtkImageData* >( this->Slices[ 0 ][ 0 ]->GetInputImage( ) );
if( image == NULL )
return;
- this->ImageMapToColors->Update( );
-
- for( int j = 0; j < 2; ++j )
- {
- for( int i = 0; i < 3; ++i )
- {
- this->Slices[ j ][ i ]->AddInputConnection(
- this->ImageMapToColors->GetOutputPort( ), i
- );
- this->Slices[ j ][ i ]->UpdateText( );
-
- } // rof
-
- } // rof
// Create 3D outline
double bb[ 6 ];
this->ImageOutlineActor->GetProperty( )->SetLineWidth( 1 );
this->AddItem( this->ImageOutlineActor );
- */
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+_SlicesCommand( double* pos, int axis, void* data )
+{
+ MPRActors* actors = reinterpret_cast< MPRActors* >( data );
+ if( actors == NULL )
+ return;
+ for( unsigned int j = 0; j < 3; ++j )
+ {
+ if( actors->Slices[ 0 ][ j ]->GetAxis( ) != axis )
+ {
+ actors->SetSlice( j, pos );
+ actors->SetAxesCursor( j, pos );
+ actors->Render( j );
+
+ } // fi
+
+ } // rof
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+_WindowLevelCommand( double window, double level, void* data )
+{
+ MPRActors* actors = reinterpret_cast< MPRActors* >( data );
+ if( actors == NULL )
+ return;
+ actors->SetWindowLevel( window, level );
+ actors->Render( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+_RenderCommand( void* data )
+{
+ MPRActors* actors = reinterpret_cast< MPRActors* >( data );
+ if( actors == NULL )
+ return;
+ actors->Render( );
}
// eof - $RCSfile$