X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FVisualization%2FMPRActors.cxx;h=e26651b4dd24098b7df304e741041789419694b0;hb=dbc5b32e13cf4a299ce29a5666a8e0a2ff5e62a8;hp=a02c8bc28d52ad37ff20848e333a3a5d4f1606a8;hpb=91f750d8a54e87cdd626566aad3d80940ae041fd;p=cpPlugins.git diff --git a/lib/cpExtensions/Visualization/MPRActors.cxx b/lib/cpExtensions/Visualization/MPRActors.cxx index a02c8bc..e26651b 100644 --- a/lib/cpExtensions/Visualization/MPRActors.cxx +++ b/lib/cpExtensions/Visualization/MPRActors.cxx @@ -28,369 +28,372 @@ GetSliceActors( const int& i ) const } // ------------------------------------------------------------------------- -int cpExtensions::Visualization::MPRActors:: -AddInputConnection( vtkAlgorithmOutput* aout ) +void cpExtensions::Visualization::MPRActors:: +SetInputConnection( vtkAlgorithmOutput* aout ) { - int N = this->Slices[ 0 ][ 0 ]->GetNumberOfImageActors( ); - if( N == 0 ) + for( int i = 0; i < 2; ++i ) { - this->Slices[ 0 ][ 0 ]->AddInputConnection( aout, 0 ); - vtkImageMapToColors* imap = this->Slices[ 0 ][ 0 ]->GetImageMap( 0 ); - for( unsigned int i = 0; i < 2; ++i ) - for( unsigned int j = 0; j < 3; ++j ) - if( i != 0 || j != 0 ) - this->Slices[ i ][ j ]->AddInputConnection( - ( ( imap != NULL )? imap->GetOutputPort( ): aout ), j - ); - - // Create bounding box - vtkImageData* new_image = dynamic_cast< vtkImageData* >( - aout->GetProducer( )->GetOutputDataObject( aout->GetIndex( ) ) - ); - - // Create 3D outline - double bb[ 6 ]; - new_image->GetBounds( bb ); + for( int j = 0; j < 3; ++j ) + { + this->Slices[ i ][ j ]->SetInputConnection( aout ); + this->Slices[ i ][ j ]->SetAxis( j ); - vtkSmartPointer< vtkOutlineSource > img_ol = - vtkSmartPointer< vtkOutlineSource >::New( ); - img_ol->SetBounds( bb ); + } // rof - 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 ); + } // rof + this->_CreateBoundingBox( ); +} - this->AddItem( this->ImageOutlineActor ); - } - else +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRActors:: +SetInputImage( vtkImageData* data ) +{ + for( int i = 0; i < 2; ++i ) { - // Check if the image share the same space - vtkImageData* new_image = dynamic_cast< vtkImageData* >( - aout->GetProducer( )->GetOutputDataObject( aout->GetIndex( ) ) - ); - if( new_image != NULL ) + for( int j = 0; j < 3; ++j ) { - vtkAlgorithmOutput* ref_aout = - this->Slices[ 0 ][ 0 ]->GetImageMap( 0 )->GetOutputPort( ); - vtkImageData* ref_image = dynamic_cast< vtkImageData* >( - ref_aout->GetProducer( )->GetOutputDataObject( ref_aout->GetIndex( ) ) - ); - if( ref_image != NULL ) - { - 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->Slices[ 0 ][ 0 ]->AddInputConnection( aout, 0 ); - vtkImageMapToColors* imap = this->Slices[ 0 ][ 0 ]->GetImageMap( N ); - for( unsigned int i = 0; i < 2; ++i ) - for( unsigned int j = 0; j < 3; ++j ) - if( i != 0 || j != 0 ) - this->Slices[ i ][ j ]->AddInputConnection( - ( ( imap != NULL )? imap->GetOutputPort( ): aout ), j - ); - } - else - N = -1; - } - else - N = -1; - } - else - N = -1; + this->Slices[ i ][ j ]->SetInputImage( data ); + this->Slices[ i ][ j ]->SetAxis( j ); - } // fi - return( N ); + } // rof + + } // rof + this->_CreateBoundingBox( ); } // ------------------------------------------------------------------------- int cpExtensions::Visualization::MPRActors:: -AddInputData( vtkImageData* new_image ) +AddBinaryConnection( + vtkAlgorithmOutput* aout, + const double& r, const double& g, const double& b + ) { - int N = this->Slices[ 0 ][ 0 ]->GetNumberOfImageActors( ); - if( N == 0 ) - { - this->Slices[ 0 ][ 0 ]->AddInputData( new_image, 0 ); - vtkImageMapToColors* imap = this->Slices[ 0 ][ 0 ]->GetImageMap( 0 ); - for( unsigned int i = 0; i < 2; ++i ) - for( unsigned int j = 0; j < 3; ++j ) - if( i != 0 || j != 0 ) - { - if( imap != NULL ) - this->Slices[ i ][ j ]->AddInputConnection( - imap->GetOutputPort( ), j - ); - else - this->Slices[ i ][ j ]->AddInputData( new_image, j ); - - } // fi - - // Create 3D outline - double bb[ 6 ]; - new_image->GetBounds( bb ); - - vtkSmartPointer< vtkOutlineSource > img_ol = - vtkSmartPointer< vtkOutlineSource >::New( ); - img_ol->SetBounds( bb ); - - 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->AddItem( this->ImageOutlineActor ); - } - else - { - // Check if the image share the same space - vtkAlgorithmOutput* ref_aout = - this->Slices[ 0 ][ 0 ]->GetImageMap( 0 )->GetOutputPort( ); - vtkImageData* ref_image = dynamic_cast< vtkImageData* >( - ref_aout->GetProducer( )->GetOutputDataObject( ref_aout->GetIndex( ) ) - ); - if( ref_image != NULL ) - { - 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->Slices[ 0 ][ 0 ]->AddInputData( new_image, 0 ); - vtkImageMapToColors* imap = this->Slices[ 0 ][ 0 ]->GetImageMap( N ); - for( unsigned int i = 0; i < 2; ++i ) - for( unsigned int j = 0; j < 3; ++j ) - if( i != 0 || j != 0 ) - { - if( imap != NULL ) - this->Slices[ i ][ j ]->AddInputConnection( - imap->GetOutputPort( ), j - ); - else - this->Slices[ i ][ j ]->AddInputData( new_image, j ); - - } // fi - } - else - N = -1; - } - else - N = -1; + 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 - return( N ); +// ------------------------------------------------------------------------- +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:: +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( ); +} + +// ------------------------------------------------------------------------- +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 ]->GetNumberOfImageActors( ) ); + return( this->Slices[ 0 ][ 0 ]->GetNumberOfImages( ) ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRActors:: +SetInterpolate( bool v ) +{ + 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 ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRActors:: +InterpolateOn( ) +{ + this->SetInterpolate( true ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRActors:: +InterpolateOff( ) +{ + this->SetInterpolate( false ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: PushActorsInto( - vtkRenderWindow* x, vtkRenderWindow* y, vtkRenderWindow* z, + vtkRenderWindow* x, + vtkRenderWindow* y, + vtkRenderWindow* z, vtkRenderWindow* w ) { 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; - vtkRenderer* rends[ ] = - { - ( x != NULL )? x->GetRenderers( )->GetFirstRenderer( ): NULL, - ( y != NULL )? y->GetRenderers( )->GetFirstRenderer( ): NULL, - ( z != NULL )? z->GetRenderers( )->GetFirstRenderer( ): NULL - }; - for( int i = 0; i < 3; ++i ) - { - if( rends[ i ] != NULL ) - for( int j = 0; j < 3; ++j ) - if( i != j ) - rends[ i ]->AddActor( this->Slices[ 0 ][ j ]->GetPlaneActor( ) ); - if( wren != NULL ) - { - for( - unsigned int k = 0; - k < this->Slices[ 1 ][ i ]->GetNumberOfImageActors( ); - ++k - ) - wren->AddActor( this->Slices[ 1 ][ i ]->GetImageActor( k ) ); - wren->AddActor( this->Slices[ 1 ][ i ]->GetPlaneActor( ) ); - - } // fi - - } // rof if( wren != NULL ) - wren->AddActor( this->ImageOutlineActor ); - - for( unsigned int j = 0; j < 3; ++j ) { - ImageInteractorStyle* st = - dynamic_cast< ImageInteractorStyle* >( this->Slices[ 0 ][ j ]->GetStyle( ) ); - if( w != NULL ) - st->AssociateInteractor( w->GetInteractor( ) ); - for( unsigned int l = 0; l < 3; ++l ) - if( j != l ) - st->AssociateInteractor( - this->Slices[ 0 ][ l ]->GetStyle( )->GetInteractor( ) - ); + 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( ) ); - } // rof + } // fi } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: PopActorsFrom( - vtkRenderWindow* x, vtkRenderWindow* y, vtkRenderWindow* z, + 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; - vtkRenderer* rends[ ] = - { - ( x != NULL )? x->GetRenderers( )->GetFirstRenderer( ): NULL, - ( y != NULL )? y->GetRenderers( )->GetFirstRenderer( ): NULL, - ( z != NULL )? z->GetRenderers( )->GetFirstRenderer( ): NULL - }; - for( int i = 0; i < 3; ++i ) + if( wren != NULL ) { - if( rends[ i ] != NULL ) - for( int j = 0; j < 3; ++j ) - if( i != j ) - rends[ i ]->RemoveActor( this->Slices[ 0 ][ j ]->GetPlaneActor( ) ); - if( wren != NULL ) - { - for( - unsigned int k = 0; - k < this->Slices[ 1 ][ i ]->GetNumberOfImageActors( ); - ++k - ) - wren->RemoveActor( this->Slices[ 1 ][ i ]->GetImageActor( k ) ); - wren->RemoveActor( this->Slices[ 1 ][ i ]->GetPlaneActor( ) ); + 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( ) ); - } // fi + } // fi +} - } // rof - if( wren != NULL ) - wren->RemoveActor( this->ImageOutlineActor ); +// ------------------------------------------------------------------------- +double cpExtensions::Visualization::MPRActors:: +GetMinWindow( ) const +{ + return( this->Slices[ 0 ][ 0 ]->GetMinWindow( ) ); +} - 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( ); +// ------------------------------------------------------------------------- +double cpExtensions::Visualization::MPRActors:: +GetMaxWindow( ) const +{ + return( this->Slices[ 0 ][ 0 ]->GetMaxWindow( ) ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::Visualization::MPRActors:: +GetMinLevel( ) const +{ + return( this->Slices[ 0 ][ 0 ]->GetMinLevel( ) ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::Visualization::MPRActors:: +GetMaxLevel( ) const +{ + return( this->Slices[ 0 ][ 0 ]->GetMaxLevel( ) ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::Visualization::MPRActors:: +GetWindow( ) +{ + return( this->Slices[ 0 ][ 0 ]->GetWindow( ) ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::Visualization::MPRActors:: +GetLevel( ) +{ + return( this->Slices[ 0 ][ 0 ]->GetLevel( ) ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRActors:: +SetWindow( double w ) +{ + 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:: -SetLookupTableAsColor( unsigned int i, double r, double g, double b ) +SetLevel( double l ) { - this->Slices[ 0 ][ 0 ]->SetLookupTableAsColor( 0, r, g, b ); - this->Slices[ 0 ][ 1 ]->Modified( ); - this->Slices[ 0 ][ 2 ]->Modified( ); - this->Slices[ 1 ][ 0 ]->Modified( ); - this->Slices[ 1 ][ 1 ]->Modified( ); - this->Slices[ 1 ][ 2 ]->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 ); +} + +// ------------------------------------------------------------------------- +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( ) +{ + 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( ); } // ------------------------------------------------------------------------- int cpExtensions::Visualization::MPRActors:: -GetSliceNumberMinValue( const int& axis ) const +GetSliceNumber( const int& axis ) const { - return( this->Slices[ 0 ][ axis ]->GetSliceNumberMinValue( ) ); + if( axis < 3 ) + return( this->Slices[ 0 ][ axis ]->GetSliceNumber( ) ); + else + return( -1 ); } // ------------------------------------------------------------------------- int cpExtensions::Visualization::MPRActors:: -GetSliceNumberMaxValue( const int& axis ) const +GetSliceNumberMinValue( const int& axis ) const { - return( this->Slices[ 0 ][ axis ]->GetSliceNumberMaxValue( ) ); + if( axis < 3 ) + return( this->Slices[ 0 ][ axis ]->GetSliceNumberMinValue( ) ); + else + return( -1 ); } // ------------------------------------------------------------------------- int cpExtensions::Visualization::MPRActors:: -GetSlice( const int& axis ) const +GetSliceNumberMaxValue( const int& axis ) const { - return( this->Slices[ 0 ][ axis ]->GetSliceNumber( ) ); + if( axis < 3 ) + return( this->Slices[ 0 ][ axis ]->GetSliceNumberMaxValue( ) ); + else + return( -1 ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: -SetSlice( const int& axis, const int& slice ) +SetSliceNumber( const int& axis, const int& slice ) { - vtkImageData* image = this->_Image( 0 ); - if( image == NULL ) - return; + if( axis < 3 ) + { + this->Slices[ 0 ][ axis ]->SetSliceNumber( slice ); + this->Slices[ 1 ][ axis ]->SetSliceNumber( slice ); - // Get image data extent - int ext[ 6 ]; - image->GetExtent( ext ); + } // fi +} - // 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 ]; +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRActors:: +SetSlice( const int& axis, double* pos ) +{ + if( axis < 3 ) + { + this->Slices[ 0 ][ axis ]->SetSlice( pos ); + this->Slices[ 1 ][ axis ]->SetSlice( pos ); - // Change slice - this->Slices[ 0 ][ axis ]->SetSliceNumber( real ); - this->Slices[ 1 ][ axis ]->SetSliceNumber( real ); - this->Modified( ); + } // fi } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: -SetSlice( const int& axis, const double& slice ) +SetAxesCursor( const int& axis, double* pos ) { - vtkImageData* image = this->_Image( 0 ); - if( image == NULL ) - return; + if( axis < 3 ) + this->Slices[ 0 ][ axis ]->SetAxesCursor( pos ); +} - double x[ 3 ] = { double( 0 ) }; - double pcoords[ 3 ]; - int ijk[ 3 ]; +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRActors:: +Render( const int& axis ) +{ + if( axis < 3 ) + { + this->Slices[ 0 ][ axis ]->Render( ); + this->Slices[ 1 ][ axis ]->Render( ); - x[ axis ] = slice; - image->ComputeStructuredCoordinates( x, ijk, pcoords ); - this->SetSlice( axis, ijk[ axis ] ); + } // fi } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: -ResetSlices( ) +Render( ) { - for( unsigned int i = 0; i < 2; ++i ) - for( unsigned int j = 0; j < 3; ++j ) - this->Slices[ i ][ j ]->SetSliceNumber( - this->Slices[ i ][ j ]->GetSliceNumberMinValue( ) - ); + 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:: +ResetCameras( ) +{ + this->ResetCamera( 0 ); + this->ResetCamera( 1 ); + this->ResetCamera( 2 ); } // ------------------------------------------------------------------------- @@ -407,9 +410,17 @@ MPRActors( ) this->Slices[ 0 ][ 1 ]->AssociateSlice( this->Slices[ 1 ][ 1 ] ); this->Slices[ 0 ][ 2 ]->AssociateSlice( this->Slices[ 1 ][ 2 ] ); - this->Slices[ 0 ][ 0 ]->SetSlicesCommand( Self::_SetSlices, this ); - this->Slices[ 0 ][ 1 ]->SetSlicesCommand( Self::_SetSlices, this ); - this->Slices[ 0 ][ 2 ]->SetSlicesCommand( Self::_SetSlices, this ); + 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 } // ------------------------------------------------------------------------- @@ -418,94 +429,72 @@ 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->_Image( i ); + vtkImageData* image = + dynamic_cast< vtkImageData* >( this->Slices[ 0 ][ 0 ]->GetInputImage( ) ); if( image == NULL ) return; - this->ImageMaps[ i ]->Update( ); - - for( int j = 0; j < 2; ++j ) - { - for( int k = 0; k < 3; ++k ) - { - this->Slices[ j ][ k ]->AddInputConnection( - this->ImageMaps[ i ]->GetOutputPort( ), k - ); - this->Slices[ j ][ k ]->UpdateText( ); - // Add all of slice's props - this->Slices[ j ][ k ]->InitTraversal( ); - vtkProp* prop = this->Slices[ j ][ k ]->GetNextProp( ); - while( prop != NULL ) - { - this->AddItem( prop ); - prop = this->Slices[ j ][ k ]->GetNextProp( ); + // Create 3D outline + double bb[ 6 ]; + image->GetBounds( bb ); - } // elihw + vtkSmartPointer< vtkOutlineSource > img_ol = + vtkSmartPointer< vtkOutlineSource >::New( ); + img_ol->SetBounds( bb ); - } // rof + 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 ); - } // rof + this->AddItem( this->ImageOutlineActor ); +} - if( i == 0 ) +// ------------------------------------------------------------------------- +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 ) { - // Create 3D outline - double bb[ 6 ]; - image->GetBounds( bb ); - - vtkSmartPointer< vtkOutlineSource > img_ol = - vtkSmartPointer< vtkOutlineSource >::New( ); - img_ol->SetBounds( bb ); + if( actors->Slices[ 0 ][ j ]->GetAxis( ) != axis ) + { + actors->SetSlice( j, pos ); + actors->SetAxesCursor( j, pos ); + actors->Render( j ); - 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 ); + } // fi - this->AddItem( this->ImageOutlineActor ); + } // rof +} - } // fi - */ +// ------------------------------------------------------------------------- +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:: -_SetSlices( double* pos, int axis, void* data ) +_RenderCommand( 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->Slices[ 0 ][ j ]->SetSlice( pos ); - actors->Modified( ); + actors->Render( ); } // eof - $RCSfile$