X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FVisualization%2FMPRObjects.cxx;h=a32824c455926d3f674f3f6d310afa629668af2c;hb=4f6c47b5d9994cd1bbb601bfe8bc087a0a619e72;hp=96e646a78f11bbf46c2e44991edb084c2934c266;hpb=96914c02e23847c9d4ecdd085da689e61abb58f8;p=cpPlugins.git diff --git a/lib/cpExtensions/Visualization/MPRObjects.cxx b/lib/cpExtensions/Visualization/MPRObjects.cxx index 96e646a..a32824c 100644 --- a/lib/cpExtensions/Visualization/MPRObjects.cxx +++ b/lib/cpExtensions/Visualization/MPRObjects.cxx @@ -1,5 +1,9 @@ #include +#include +#include +#include + // ------------------------------------------------------------------------- cpExtensions::Visualization::MPRObjects* cpExtensions::Visualization::MPRObjects:: @@ -20,7 +24,7 @@ SetRenderWindows( this->m_Windows[ 2 ] = wz; this->m_Windows[ 3 ] = w3D; - // Prepare renderers + // Prepare 2D renderers for( int i = 0; i < 4; ++i ) { if( this->m_Windows[ i ] == NULL ) @@ -30,29 +34,89 @@ SetRenderWindows( } // fi - // Renderers + // 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 ] ); - // Image styles (just for 2D windows) - if( i < 3 ) + } // rof + + // Create 3D renderer + if( this->m_Windows[ 3 ] != NULL ) + this->m_Renderers[ 3 ]->SetBackground( 0.2, 0.2, 0.2 ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +SetImage( vtkImageData* image ) +{ + this->m_MPRActors->AddInputData( image ); + this->m_MPRActors->PushDataInto( + this->m_Renderers[ 0 ], + this->m_Renderers[ 1 ], + this->m_Renderers[ 2 ], + this->m_Renderers[ 3 ] + ); + + // First rendering + this->m_MPRActors->ResetSlices( ); + this->ResetCameras( ); + this->RenderAll( ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +AddAuxiliaryImage( vtkImageData* image ) +{ + // Try to add new image + int id = this->m_MPRActors->AddInputData( image ); + if( id < 0 ) + return; + + // Push everything on renderers + this->m_MPRActors->PushDataInto( + this->m_Renderers[ 0 ], + this->m_Renderers[ 1 ], + this->m_Renderers[ 2 ], + this->m_Renderers[ 3 ] + ); + + // Rendering + this->RenderAll( ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +ActivateInteractors( ) +{ + // Prepare renderers + for( int i = 0; i < 3; ++i ) + { + // Check prerrequisites + if( this->m_Windows[ i ] == NULL || this->m_Renderers[ i ] == NULL ) { - this->m_Styles[ i ] = vtkSmartPointer< TStyle >::New( ); - this->m_Styles[ i ]->Configure( - this->m_MPRActors->GetSliceActors( i ), this->m_MPRActors - ); + this->m_Styles[ i ] = NULL; + continue; - this->m_Styles[ i ]-> - SetInteractor( this->m_Windows[ i ]->GetInteractor( ), i ); - this->m_Styles[ i ]->SetModeToNavigation( ); + } // fi + + ImageSliceActors* actors = this->m_MPRActors->GetSliceActors( i ); + if( actors == NULL ) + { + this->m_Styles[ i ] = NULL; + continue; } // fi + 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 - if( this->m_Windows[ 3 ] != NULL ) - this->m_Renderers[ 3 ]->SetBackground( 0.2, 0.2, 0.2 ); + // Synch 2D and 3D renderers for( int i = 0; i < 3; ++i ) { for( int j = 0; j < 3; ++j ) @@ -71,29 +135,11 @@ SetRenderWindows( AssociateInteractor( this->m_Windows[ 3 ]->GetInteractor( ) ); } // rof -} - -// ------------------------------------------------------------------------- -void cpExtensions::Visualization::MPRObjects:: -SetImage( vtkImageData* image ) -{ - this->m_MPRActors->AddInputData( image ); - this->m_MPRActors->PushDataInto( - this->m_Renderers[ 0 ], - this->m_Renderers[ 1 ], - this->m_Renderers[ 2 ], - this->m_Renderers[ 3 ] - ); - // Correct cameras positions - /* TODO - vtkCamera* zCam = this->m_Renderers[ 2 ]->GetActiveCamera( ); - zCam->SetViewUp( 0, -1, 0 ); - zCam->SetPosition( 0, 0, -1 ); - zCam->SetFocalPoint( 0, 0, 0 ); - */ + // Finish interactor linking + this->m_MPRActors->LinkInteractors( ); - // First rendering + // Restart rendering this->ResetCameras( ); this->RenderAll( ); } @@ -190,6 +236,22 @@ Get3DRenderer( ) const return( this->m_Renderers[ 3 ] ); } +// ------------------------------------------------------------------------- +cpExtensions::Visualization::MPRObjects:: +TMPRActors* cpExtensions::Visualization::MPRObjects:: +GetMPRActors( ) +{ + return( this->m_MPRActors ); +} + +// ------------------------------------------------------------------------- +const cpExtensions::Visualization::MPRObjects:: +TMPRActors* cpExtensions::Visualization::MPRObjects:: +GetMPRActors( ) const +{ + return( this->m_MPRActors ); +} + // ------------------------------------------------------------------------- cpExtensions::Visualization::MPRObjects:: MPRObjects( )