#include #include #include #include // ------------------------------------------------------------------------- cpExtensions::Visualization::MPRObjects* cpExtensions::Visualization::MPRObjects:: New( ) { return( new Self( ) ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRObjects:: SetRenderWindows( vtkRenderWindow* wx, vtkRenderWindow* wy, vtkRenderWindow* wz, vtkRenderWindow* w3D ) { this->m_Windows[ 0 ] = wx; this->m_Windows[ 1 ] = wy; this->m_Windows[ 2 ] = wz; this->m_Windows[ 3 ] = w3D; // Prepare 2D renderers for( int i = 0; i < 4; ++i ) { if( this->m_Windows[ i ] == NULL ) { this->m_Renderers[ i ] = NULL; continue; } // fi // 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 ] ); } // 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->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:: 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->PushActorsInto( this->m_Windows[ 0 ], this->m_Windows[ 1 ], this->m_Windows[ 2 ], this->m_Windows[ 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 ) { // TODO: this->m_Styles[ i ] = NULL; continue; } // fi ImageSliceActors* actors = this->m_MPRActors->GetSliceActors( i ); if( actors == NULL ) { // TODO: this->m_Styles[ i ] = NULL; continue; } // 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 ) { 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( ) ); */ } // rof // Finish interactor linking // TODO: this->m_MPRActors->LinkInteractors( ); // Restart rendering this->ResetCameras( ); this->RenderAll( ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRObjects:: ResetCamera( const int& id ) { if( id < 4 ) if( this->m_Windows[ id ] != NULL ) this->m_Renderers[ id ]->ResetCamera( ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRObjects:: ResetCameras( ) { for( int i = 0; i < 4; ++i ) if( this->m_Windows[ i ] != NULL ) this->m_Renderers[ i ]->ResetCamera( ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRObjects:: Render( const int& id ) { if( id < 4 ) if( this->m_Windows[ id ] != NULL ) this->m_Windows[ id ]->Render( ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRObjects:: RenderAll( ) { for( int i = 0; i < 4; ++i ) if( this->m_Windows[ i ] != NULL ) this->m_Windows[ i ]->Render( ); } // ------------------------------------------------------------------------- vtkRenderer* cpExtensions::Visualization::MPRObjects:: GetXRenderer( ) { return( this->m_Renderers[ 0 ] ); } // ------------------------------------------------------------------------- vtkRenderer* cpExtensions::Visualization::MPRObjects:: GetYRenderer( ) { return( this->m_Renderers[ 1 ] ); } // ------------------------------------------------------------------------- vtkRenderer* cpExtensions::Visualization::MPRObjects:: GetZRenderer( ) { return( this->m_Renderers[ 2 ] ); } // ------------------------------------------------------------------------- vtkRenderer* cpExtensions::Visualization::MPRObjects:: Get3DRenderer( ) { return( this->m_Renderers[ 3 ] ); } // ------------------------------------------------------------------------- const vtkRenderer* cpExtensions::Visualization::MPRObjects:: GetXRenderer( ) const { return( this->m_Renderers[ 0 ] ); } // ------------------------------------------------------------------------- const vtkRenderer* cpExtensions::Visualization::MPRObjects:: GetYRenderer( ) const { return( this->m_Renderers[ 1 ] ); } // ------------------------------------------------------------------------- const vtkRenderer* cpExtensions::Visualization::MPRObjects:: GetZRenderer( ) const { return( this->m_Renderers[ 2 ] ); } // ------------------------------------------------------------------------- const vtkRenderer* cpExtensions::Visualization::MPRObjects:: 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( ) : vtkObject( ) { // Prepare actors this->m_MPRActors = vtkSmartPointer< TMPRActors >::New( ); } // ------------------------------------------------------------------------- cpExtensions::Visualization::MPRObjects:: ~MPRObjects( ) { } // eof - $RCSfile$