X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FVisualization%2FMPRActors.cxx;h=e26651b4dd24098b7df304e741041789419694b0;hb=e2fb8817731f6231d34941a208e46b36dad425b2;hp=b7ebc2455ed796e0a74f56b6da10945ca12d066d;hpb=2361f4f97631e09d88d8a5510a369817dcaa19db;p=cpPlugins.git diff --git a/lib/cpExtensions/Visualization/MPRActors.cxx b/lib/cpExtensions/Visualization/MPRActors.cxx index b7ebc24..e26651b 100644 --- a/lib/cpExtensions/Visualization/MPRActors.cxx +++ b/lib/cpExtensions/Visualization/MPRActors.cxx @@ -1,12 +1,12 @@ #include +#include #include -#include #include -#include #include #include -#include +#include +#include // ------------------------------------------------------------------------- cpExtensions::Visualization::MPRActors* @@ -22,7 +22,7 @@ ImageSliceActors* cpExtensions::Visualization::MPRActors:: GetSliceActors( const int& i ) const { if( i < 3 ) - return( this->Slices[ i ] ); + return( this->Slices[ 0 ][ i ] ); else return( NULL ); } @@ -31,339 +31,369 @@ GetSliceActors( const int& i ) const void cpExtensions::Visualization::MPRActors:: SetInputConnection( vtkAlgorithmOutput* aout ) { - this->ImageMapToColors->SetInputConnection( aout ); - this->SetLookupTableToWindowLevel( ); - this->_UpdateSlices( ); -} + for( int i = 0; i < 2; ++i ) + { + for( int j = 0; j < 3; ++j ) + { + this->Slices[ i ][ j ]->SetInputConnection( aout ); + this->Slices[ i ][ j ]->SetAxis( j ); -// ------------------------------------------------------------------------- -void cpExtensions::Visualization::MPRActors:: -SetInputData( vtkImageData* image ) -{ - this->ImageMapToColors->SetInputData( image ); - this->SetLookupTableToWindowLevel( ); - this->_UpdateSlices( ); + } // 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 ) { - rends[ i ]->AddActor( this->Slices[ i ]->GetImageActor( ) ); - rends[ i ]->AddActor( this->Slices[ i ]->GetTextActor( ) ); - for( int j = 0; j < 3; ++j ) - rends[ i ]->AddActor( this->Slices[ j ]->GetPlaneActor( ) ); - if( w != NULL ) - { - w->AddActor( this->Slices[ i ]->GetImageActor( ) ); - w->AddActor( this->Slices[ i ]->GetPlaneActor( ) ); + this->Slices[ i ][ j ]->SetInputImage( data ); + this->Slices[ i ][ j ]->SetAxis( j ); - } // fi - - } // fi + } // rof } // rof + this->_CreateBoundingBox( ); +} - if( w != NULL ) - { - w->AddActor( this->ImageOutlineActor ); +// ------------------------------------------------------------------------- +int cpExtensions::Visualization::MPRActors:: +AddBinaryConnection( + vtkAlgorithmOutput* aout, + const double& r, const double& g, const double& b + ) +{ + 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 +// ------------------------------------------------------------------------- +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 ) - { - rends[ i ]->RemoveActor( this->Slices[ i ]->GetImageActor( ) ); - rends[ i ]->RemoveActor( this->Slices[ i ]->GetTextActor( ) ); - for( int j = 0; j < 3; ++j ) - rends[ i ]->RemoveActor( this->Slices[ j ]->GetPlaneActor( ) ); - if( w != NULL ) - { - w->RemoveActor( this->Slices[ i ]->GetImageActor( ) ); - w->RemoveActor( this->Slices[ i ]->GetPlaneActor( ) ); - - } // fi - - } // fi + 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 +// ------------------------------------------------------------------------- +vtkImageData* cpExtensions::Visualization::MPRActors:: +GetInputImage( ) +{ + return( this->Slices[ 0 ][ 0 ]->GetInputImage( ) ); +} - if( w != NULL ) - { - w->RemoveActor( this->ImageOutlineActor ); +// ------------------------------------------------------------------------- +const vtkImageData* cpExtensions::Visualization::MPRActors:: +GetInputImage( ) const +{ + return( this->Slices[ 0 ][ 0 ]->GetInputImage( ) ); +} - } // fi +// ------------------------------------------------------------------------- +unsigned int cpExtensions::Visualization::MPRActors:: +GetNumberOfImages( ) const +{ + return( this->Slices[ 0 ][ 0 ]->GetNumberOfImages( ) ); } // ------------------------------------------------------------------------- -vtkScalarsToColors* cpExtensions::Visualization::MPRActors:: -GetLookupTable( ) const +void cpExtensions::Visualization::MPRActors:: +SetInterpolate( bool v ) { - return( this->ImageMapToColors->GetLookupTable( ) ); + 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:: -SetLookupTable( vtkScalarsToColors* lut ) +InterpolateOn( ) { - this->ImageMapToColors->SetLookupTable( lut ); - this->ImageMapToColors->Update( ); - this->Modified( ); + this->SetInterpolate( true ); } // ------------------------------------------------------------------------- -vtkWindowLevelLookupTable* cpExtensions::Visualization::MPRActors:: -GetLookupTableAsWindowLevel( ) const +void cpExtensions::Visualization::MPRActors:: +InterpolateOff( ) { - return( - dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( ) ) - ); + this->SetInterpolate( false ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: -SetLookupTableToWindowLevel( ) +PushActorsInto( + vtkRenderWindow* x, + vtkRenderWindow* y, + vtkRenderWindow* z, + vtkRenderWindow* w + ) { - // Check if the input has been configured - vtkImageData* image = this->_InputImage( ); - 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( lut ); + } // fi } // ------------------------------------------------------------------------- double cpExtensions::Visualization::MPRActors:: GetMinWindow( ) const { - return( double( 0 ) ); + return( this->Slices[ 0 ][ 0 ]->GetMinWindow( ) ); } // ------------------------------------------------------------------------- double cpExtensions::Visualization::MPRActors:: GetMaxWindow( ) const { - // Check if the input has been configured - vtkImageData* image = this->_InputImage( ); - 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( ) const { - // Check if the input has been configured - vtkImageData* image = this->_InputImage( ); - 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( ) const { - // Check if the input has been configured - vtkImageData* image = this->_InputImage( ); - 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( ) const +GetWindow( ) { - vtkWindowLevelLookupTable* lut = this->GetLookupTableAsWindowLevel( ); - if( lut != NULL ) - return( lut->GetWindow( ) ); - else - return( double( 0 ) ); + return( this->Slices[ 0 ][ 0 ]->GetWindow( ) ); } // ------------------------------------------------------------------------- double cpExtensions::Visualization::MPRActors:: -GetLevel( ) const +GetLevel( ) { - vtkWindowLevelLookupTable* lut = this->GetLookupTableAsWindowLevel( ); - if( lut != NULL ) - return( lut->GetLevel( ) ); - else - return( double( 0 ) ); + return( this->Slices[ 0 ][ 0 ]->GetLevel( ) ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: -SetWindow( const double& w ) +SetWindow( double w ) { - vtkWindowLevelLookupTable* lut = this->GetLookupTableAsWindowLevel( ); - if( lut != NULL ) - { - lut->SetWindow( w ); - lut->Build( ); - this->ImageMapToColors->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( const double& l ) +SetLevel( double l ) { - vtkWindowLevelLookupTable* lut = this->GetLookupTableAsWindowLevel( ); - if( lut != NULL ) - { - lut->SetLevel( l ); - lut->Build( ); - this->ImageMapToColors->Modified( ); - this->Modified( ); - - } // fi + 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( const double& w, const double& l ) +SetWindowLevel( double w, double l ) { - vtkWindowLevelLookupTable* lut = this->GetLookupTableAsWindowLevel( ); - if( lut != NULL ) - { - lut->SetWindow( l ); - lut->SetLevel( l ); - lut->Build( ); - this->ImageMapToColors->Modified( ); - this->Modified( ); - - } // fi + 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( ) { - vtkImageData* image = this->_InputImage( ); - vtkWindowLevelLookupTable* lut = this->GetLookupTableAsWindowLevel( ); - if( image != NULL && lut != NULL ) - { - double r[ 2 ]; - image->GetScalarRange( r ); - lut->SetTableRange( r ); - lut->Build( ); - this->ImageMapToColors->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[ 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[ 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[ 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->_InputImage( ); - 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[ 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->_InputImage( ); - 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:: -ResetSlices( ) +ResetCamera( const int& axis ) { - // TODO + if( axis < 3 ) + this->Slices[ 0 ][ axis ]->ResetCamera( ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: -GetImageBounds( double bounds[ 6 ] ) const +ResetCameras( ) { - vtkImageData* image = this->_InputImage( ); - if( image != NULL ) - image->GetBounds( bounds ); + this->ResetCamera( 0 ); + this->ResetCamera( 1 ); + this->ResetCamera( 2 ); } // ------------------------------------------------------------------------- @@ -371,11 +401,26 @@ cpExtensions::Visualization::MPRActors:: MPRActors( ) : Superclass( ) { - this->ImageMapToColors = vtkSmartPointer< vtkImageMapToColors >::New( ); this->ImageOutlineActor = vtkSmartPointer< vtkActor >::New( ); - this->Slices[ 0 ] = vtkSmartPointer< _TSlice >::New( ); - this->Slices[ 1 ] = vtkSmartPointer< _TSlice >::New( ); - this->Slices[ 2 ] = vtkSmartPointer< _TSlice >::New( ); + 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 } // ------------------------------------------------------------------------- @@ -384,35 +429,14 @@ cpExtensions::Visualization::MPRActors:: { } -// ------------------------------------------------------------------------- -vtkImageData* cpExtensions::Visualization::MPRActors:: -_InputImage( ) const -{ - vtkAlgorithm* algo = this->ImageMapToColors->GetInputAlgorithm( ); - vtkInformation* info = algo->GetOutputInformation( 0 ); - return( - vtkImageData::SafeDownCast( info->Get( vtkDataObject::DATA_OBJECT( ) ) ) - ); -} - // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: -_UpdateSlices( ) +_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 i = 0; i < 3; ++i ) - { - this->Slices[ i ]->SetInputConnection( - this->ImageMapToColors->GetOutputPort( ), i - ); - this->Slices[ i ]->UpdateText( ); - - } // rof // Create 3D outline double bb[ 6 ]; @@ -429,80 +453,48 @@ _UpdateSlices( ) 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 ) +// ------------------------------------------------------------------------- +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 ) { - // 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 ); + actors->SetSlice( j, pos ); + actors->SetAxesCursor( j, pos ); + actors->Render( j ); - } // 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 contourRep = - vtkSmartPointer::New(); - static vtkSmartPointer contourWidget = - vtkSmartPointer::New(); - contourWidget->SetInteractor( zi ); - contourWidget->SetRepresentation( contourRep ); - contourWidget->On( ); - */ + } // 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$