X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FVisualization%2FMPRActors.cxx;h=e26651b4dd24098b7df304e741041789419694b0;hb=e2fb8817731f6231d34941a208e46b36dad425b2;hp=eea3b64550154d4f11c77a276e9615924e57f4f7;hpb=dc72ea8ea52fc074566d9437048db24af6c0aaab;p=cpPlugins.git diff --git a/lib/cpExtensions/Visualization/MPRActors.cxx b/lib/cpExtensions/Visualization/MPRActors.cxx index eea3b64..e26651b 100644 --- a/lib/cpExtensions/Visualization/MPRActors.cxx +++ b/lib/cpExtensions/Visualization/MPRActors.cxx @@ -2,9 +2,11 @@ #include #include -#include +#include +#include #include -#include +#include +#include // ------------------------------------------------------------------------- cpExtensions::Visualization::MPRActors* @@ -15,410 +17,383 @@ New( ) } // ------------------------------------------------------------------------- -int cpExtensions::Visualization::MPRActors:: -AddInputConnection( vtkAlgorithmOutput* aout ) +cpExtensions::Visualization:: +ImageSliceActors* cpExtensions::Visualization::MPRActors:: +GetSliceActors( const int& i ) const { - 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 ); - } + if( i < 3 ) + return( this->Slices[ 0 ][ i ] ); else - { - // 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 ); - - } // fi + return( NULL ); } // ------------------------------------------------------------------------- -int cpExtensions::Visualization::MPRActors:: -AddInputData( vtkImageData* image ) +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 ]->SetInputData( image ); - 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 = 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 ]->SetInputConnection( aout ); + this->Slices[ i ][ j ]->SetAxis( j ); - } // fi + } // rof + + } // rof + this->_CreateBoundingBox( ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: -PushDataInto( vtkRenderer* x, vtkRenderer* y, vtkRenderer* z, vtkRenderer* w ) +SetInputImage( vtkImageData* data ) { - vtkRenderer* rends[] = { x, y, z }; - for( int i = 0; i < 3; ++i ) + for( int i = 0; i < 2; ++i ) { - if( rends[ i ] != NULL ) + for( int j = 0; j < 3; ++j ) { - 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( ) ); + this->Slices[ i ][ j ]->SetInputImage( data ); + this->Slices[ i ][ j ]->SetAxis( j ); - } // 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 + } // rof } // rof - if( w != NULL ) - w->AddActor( this->ImageOutlineActor ); + this->_CreateBoundingBox( ); } // ------------------------------------------------------------------------- -void cpExtensions::Visualization::MPRActors:: -PopDataFrom( - 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 ]->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 ]->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 ) ); +} - } // 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( ) ); +// ------------------------------------------------------------------------- +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 ) ); +} - } // fi +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRActors:: +Clear( ) +{ + 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( ); +} - } // rof - if( w != NULL ) - w->RemoveActor( this->ImageOutlineActor ); +// ------------------------------------------------------------------------- +vtkImageData* cpExtensions::Visualization::MPRActors:: +GetInputImage( ) +{ + return( this->Slices[ 0 ][ 0 ]->GetInputImage( ) ); +} + +// ------------------------------------------------------------------------- +const vtkImageData* cpExtensions::Visualization::MPRActors:: +GetInputImage( ) const +{ + return( this->Slices[ 0 ][ 0 ]->GetInputImage( ) ); +} + +// ------------------------------------------------------------------------- +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 ); } // ------------------------------------------------------------------------- @@ -430,6 +405,22 @@ MPRActors( ) 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 } // ------------------------------------------------------------------------- @@ -438,45 +429,14 @@ cpExtensions::Visualization::MPRActors:: { } -// ------------------------------------------------------------------------- -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 ]; @@ -494,7 +454,47 @@ _Update( unsigned int i ) 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$