X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FVisualization%2FMPRObjects.cxx;h=0727f2223489628be5ba0f3a14aec0fbea026907;hb=e2fb8817731f6231d34941a208e46b36dad425b2;hp=0e522491b933349501a6286a1fd75682f8799e45;hpb=a4bc3b8e36e91e45f37a3b7eecb5789c635aa5c0;p=cpPlugins.git diff --git a/lib/cpExtensions/Visualization/MPRObjects.cxx b/lib/cpExtensions/Visualization/MPRObjects.cxx index 0e52249..0727f22 100644 --- a/lib/cpExtensions/Visualization/MPRObjects.cxx +++ b/lib/cpExtensions/Visualization/MPRObjects.cxx @@ -15,139 +15,351 @@ New( ) // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRObjects:: SetRenderWindows( - vtkRenderWindow* wx, vtkRenderWindow* wy, - vtkRenderWindow* wz, vtkRenderWindow* w3D + vtkRenderWindow* x, vtkRenderWindow* y, + vtkRenderWindow* z, vtkRenderWindow* w ) { - this->m_Windows[ 0 ] = wx; - this->m_Windows[ 1 ] = wy; - this->m_Windows[ 2 ] = wz; - this->m_Windows[ 3 ] = w3D; + this->m_Windows[ 0 ] = x; + this->m_Windows[ 1 ] = y; + this->m_Windows[ 2 ] = z; + this->m_Windows[ 3 ] = w; // Prepare 2D renderers for( int i = 0; i < 4; ++i ) { - if( this->m_Windows[ i ] == NULL ) + // Create renderer, if render window exists + if( this->m_Windows[ i ] != NULL ) { + this->m_Renderers[ i ] = vtkSmartPointer< vtkRenderer >::New( ); + this->m_Renderers[ i ]->SetBackground( 0.3, 0.3, 0.3 ); + this->m_Windows[ i ]->AddRenderer( this->m_Renderers[ i ] ); + } + else this->m_Renderers[ i ] = NULL; - continue; - } // fi + } // rof +} - // Create renderer, if render window exists - this->m_Renderers[ i ] = vtkSmartPointer< vtkRenderer >::New( ); - this->m_Renderers[ i ]->SetBackground( 0.1, 0.3, 0.8 ); - this->m_Windows[ i ]->AddRenderer( this->m_Renderers[ i ] ); +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +SetInputConnection( vtkAlgorithmOutput* aout ) +{ + this->m_MPRActors->SetInputConnection( aout ); +} - } // rof +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +SetInputImage( vtkImageData* data ) +{ + this->m_MPRActors->SetInputImage( data ); +} - // Create 3D renderer - if( this->m_Windows[ 3 ] != NULL ) - this->m_Renderers[ 3 ]->SetBackground( 0.2, 0.2, 0.2 ); +// ------------------------------------------------------------------------- +int cpExtensions::Visualization::MPRObjects:: +AddBinaryConnection( + vtkAlgorithmOutput* aout, + const double& r, const double& g, const double& b + ) +{ + return( this->m_MPRActors->AddBinaryConnection( aout, r, g, b ) ); +} + +// ------------------------------------------------------------------------- +int cpExtensions::Visualization::MPRObjects:: +AddBinaryImage( + vtkImageData* data, + const double& r, const double& g, const double& b + ) +{ + return( this->m_MPRActors->AddBinaryImage( data, r, g, b ) ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRObjects:: -SetImage( vtkImageData* image ) +Show( ) { - this->m_MPRActors->AddInputData( image ); this->m_MPRActors->PushActorsInto( this->m_Windows[ 0 ], this->m_Windows[ 1 ], this->m_Windows[ 2 ], this->m_Windows[ 3 ] ); +} - // First rendering - this->m_MPRActors->ResetSlices( ); - this->ResetCameras( ); - this->RenderAll( ); +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +Hide( ) +{ } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRObjects:: -AddAuxiliaryImage( vtkImageData* image ) +Clear( ) { - // Try to add new image - int id = this->m_MPRActors->AddInputData( image ); - if( id < 0 ) - return; + this->m_MPRActors->Clear( ); +} - // Push everything on renderers - this->m_MPRActors->PushActorsInto( - this->m_Windows[ 0 ], - this->m_Windows[ 1 ], - this->m_Windows[ 2 ], - this->m_Windows[ 3 ] - ); +// ------------------------------------------------------------------------- +vtkImageData* cpExtensions::Visualization::MPRObjects:: +GetInputImage( ) +{ + return( this->m_MPRActors->GetInputImage( ) ); +} + +// ------------------------------------------------------------------------- +const vtkImageData* cpExtensions::Visualization::MPRObjects:: +GetInputImage( ) const +{ + return( this->m_MPRActors->GetInputImage( ) ); +} + +// ------------------------------------------------------------------------- +unsigned int cpExtensions::Visualization::MPRObjects:: +GetNumberOfImages( ) const +{ + return( this->m_MPRActors->GetNumberOfImages( ) ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +SetInterpolate( bool v ) +{ + this->m_MPRActors->SetInterpolate( v ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +InterpolateOn( ) +{ + this->m_MPRActors->InterpolateOn( ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +InterpolateOff( ) +{ + this->m_MPRActors->InterpolateOff( ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::Visualization::MPRObjects:: +GetMinWindow( ) const +{ + return( this->m_MPRActors->GetMinWindow( ) ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::Visualization::MPRObjects:: +GetMaxWindow( ) const +{ + return( this->m_MPRActors->GetMaxWindow( ) ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::Visualization::MPRObjects:: +GetMinLevel( ) const +{ + return( this->m_MPRActors->GetMinLevel( ) ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::Visualization::MPRObjects:: +GetMaxLevel( ) const +{ + return( this->m_MPRActors->GetMaxLevel( ) ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::Visualization::MPRObjects:: +GetWindow( ) const +{ + return( this->m_MPRActors->GetWindow( ) ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::Visualization::MPRObjects:: +GetLevel( ) const +{ + return( this->m_MPRActors->GetLevel( ) ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +SetWindow( double w ) +{ + this->m_MPRActors->SetWindow( w ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +SetLevel( double l ) +{ + this->m_MPRActors->SetLevel( l ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +SetWindowLevel( double w, double l ) +{ + this->m_MPRActors->SetWindowLevel( w, l ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +ResetWindowLevel( ) +{ + this->m_MPRActors->ResetWindowLevel( ); +} + +// ------------------------------------------------------------------------- +int cpExtensions::Visualization::MPRObjects:: +GetSliceNumber( const int& axis ) const +{ + return( this->m_MPRActors->GetSliceNumber( axis ) ); +} + +// ------------------------------------------------------------------------- +int cpExtensions::Visualization::MPRObjects:: +GetSliceNumberMinValue( const int& axis ) const +{ + return( this->m_MPRActors->GetSliceNumberMinValue( axis ) ); +} - // Rendering - this->RenderAll( ); +// ------------------------------------------------------------------------- +int cpExtensions::Visualization::MPRObjects:: +GetSliceNumberMaxValue( const int& axis ) const +{ + return( this->m_MPRActors->GetSliceNumberMaxValue( axis ) ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRObjects:: -ActivateInteractors( ) +SetSliceNumber( const int& axis, const int& slice ) { - // Prepare renderers - for( int i = 0; i < 3; ++i ) + this->m_MPRActors->SetSliceNumber( axis, slice ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +SetSlice( const int& axis, double* pos ) +{ + this->m_MPRActors->SetSlice( axis, pos ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +Render( const double& t ) +{ + this->Render( 0, t ); + this->Render( 1, t ); + this->Render( 2, t ); + this->Render( 3, t ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +Render( const int& axis, const double& t ) +{ + if( axis < 4 ) { - // Check prerrequisites - if( this->m_Windows[ i ] == NULL || this->m_Renderers[ i ] == NULL ) + if( this->m_Windows[ axis ].GetPointer( ) != NULL ) { - // TODO: this->m_Styles[ i ] = NULL; - continue; + if( this->m_Renderers[ axis ].GetPointer( ) != NULL ) + this->m_Renderers[ axis ]->SetAllocatedRenderTime( t ); + this->m_Windows[ axis ]->Render( ); } // fi - ImageSliceActors* actors = this->m_MPRActors->GetSliceActors( i ); - if( actors == NULL ) - { - // TODO: this->m_Styles[ i ] = NULL; - continue; + } // fi +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +ResetCamera( const int& axis ) +{ + if( axis < 4 ) + if( this->m_Renderers[ axis ].GetPointer( ) != NULL ) + this->m_Renderers[ axis ]->ResetCamera( ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +ResetCameras( ) +{ + this->ResetCamera( 0 ); + this->ResetCamera( 1 ); + this->ResetCamera( 2 ); + this->ResetCamera( 3 ); +} + +// ------------------------------------------------------------------------- +cpExtensions::Visualization::MPRObjects:: +MPRObjects( ) + : vtkObject( ) +{ + this->m_MPRActors = vtkSmartPointer< MPRActors >::New( ); +} + +// ------------------------------------------------------------------------- +cpExtensions::Visualization::MPRObjects:: +~MPRObjects( ) +{ +} - } // fi - /* TODO - this->m_Styles[ i ] = vtkSmartPointer< TStyle >::New( ); - this->m_Styles[ i ]->Configure( actors, this->m_MPRActors ); - this->m_Styles[ i ]-> - SetInteractor( this->m_Windows[ i ]->GetInteractor( ), i ); - this->m_Styles[ i ]->SetModeToNavigation( ); - */ - } // rof - // Synch 2D and 3D renderers - for( int i = 0; i < 3; ++i ) +/* +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +SetRenderWindows( + vtkRenderWindow* wx, vtkRenderWindow* wy, + vtkRenderWindow* wz, vtkRenderWindow* w3D + ) +{ +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +AddImage( vtkImageData* image ) +{ + this->m_MPRActors->AddInputData( image ); + this->m_MPRActors->PushActorsInto( + this->m_Windows[ 0 ], + this->m_Windows[ 1 ], + this->m_Windows[ 2 ], + this->m_Windows[ 3 ] + ); + + // First rendering + if( this->m_MPRActors->GetNumberOfImages( ) == 1 ) { - for( int j = 0; j < 3; ++j ) - { - /* TODO - if( - this->m_Windows[ i ] != NULL && - this->m_Windows[ j ] != NULL && - i != j - ) - this->m_Styles[ i ]-> - AssociateInteractor( this->m_Windows[ j ]->GetInteractor( ) ); - */ - - } // rof - /* TODO - if( this->m_Windows[ 3 ] != NULL ) - this->m_Styles[ i ]-> - AssociateInteractor( this->m_Windows[ 3 ]->GetInteractor( ) ); - */ + this->m_MPRActors->ResetSlices( ); + this->ResetCameras( ); - } // rof + } // fi + this->RenderAll( 1e-3 ); +} - // Finish interactor linking - // TODO: this->m_MPRActors->LinkInteractors( ); +// ------------------------------------------------------------------------- +unsigned int cpExtensions::Visualization::MPRObjects:: +GetNumberOfImages( ) const +{ + return( this->m_MPRActors->GetNumberOfImages( ) ); +} - // Restart rendering +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +ClearAll( ) +{ + this->m_MPRActors->PopActorsFrom( + this->m_Windows[ 0 ], + this->m_Windows[ 1 ], + this->m_Windows[ 2 ], + this->m_Windows[ 3 ] + ); this->ResetCameras( ); - this->RenderAll( ); + this->RenderAll( 1e-3 ); } // ------------------------------------------------------------------------- @@ -170,20 +382,36 @@ ResetCameras( ) // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRObjects:: -Render( const int& id ) +Render( const int& id, const double& t ) { if( id < 4 ) + { if( this->m_Windows[ id ] != NULL ) + { + if( this->m_Renderers[ id ] != NULL ) + this->m_Renderers[ id ]->SetAllocatedRenderTime( t ); this->m_Windows[ id ]->Render( ); + + } // fi + + } // fi } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRObjects:: -RenderAll( ) +RenderAll( const double& t ) { for( int i = 0; i < 4; ++i ) + { if( this->m_Windows[ i ] != NULL ) + { + if( this->m_Renderers[ i ] != NULL ) + this->m_Renderers[ i ]->SetAllocatedRenderTime( t ); this->m_Windows[ i ]->Render( ); + + } // fi + + } // rof } // ------------------------------------------------------------------------- @@ -243,28 +471,42 @@ Get3DRenderer( ) const } // ------------------------------------------------------------------------- -cpExtensions::Visualization::MPRObjects:: -TMPRActors* cpExtensions::Visualization::MPRObjects:: +cpExtensions::Visualization:: +MPRActors* cpExtensions::Visualization::MPRObjects:: GetMPRActors( ) { return( this->m_MPRActors ); } // ------------------------------------------------------------------------- -const cpExtensions::Visualization::MPRObjects:: -TMPRActors* cpExtensions::Visualization::MPRObjects:: +const cpExtensions::Visualization:: +MPRActors* cpExtensions::Visualization::MPRObjects:: GetMPRActors( ) const { return( this->m_MPRActors ); } +// ------------------------------------------------------------------------- +double cpExtensions::Visualization::MPRObjects:: +GetWindow( ) const +{ + return( this->m_MPRActors->GetWindow( ) ); +} + +// ------------------------------------------------------------------------- +double cpExtensions::Visualization::MPRObjects:: +GetLevel( ) const +{ + return( this->m_MPRActors->GetLevel( ) ); +} + // ------------------------------------------------------------------------- cpExtensions::Visualization::MPRObjects:: MPRObjects( ) : vtkObject( ) { // Prepare actors - this->m_MPRActors = vtkSmartPointer< TMPRActors >::New( ); + this->m_MPRActors = vtkSmartPointer< MPRActors >::New( ); } // ------------------------------------------------------------------------- @@ -272,5 +514,6 @@ cpExtensions::Visualization::MPRObjects:: ~MPRObjects( ) { } +*/ // eof - $RCSfile$