#include #include // ------------------------------------------------------------------------- cpExtensions::Visualization::MPRWithDifferentWindows:: MPRWithDifferentWindows( vtkRenderWindow* xWin, vtkRenderWindow* yWin, vtkRenderWindow* zWin, vtkRenderWindow* auxWin ) { this->m_Windows[ 0 ] = xWin; this->m_Windows[ 1 ] = yWin; this->m_Windows[ 2 ] = zWin; this->m_Windows[ 3 ] = auxWin; // Prepare actors this->m_MPRActors = vtkSmartPointer< TMPRActors >::New( ); // Prepare renderers for( int i = 0; i < 4; ++i ) { if( this->m_Windows[ i ] == NULL ) { this->m_Renderers[ i ] = NULL; continue; } // fi // Renderers 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 ) { this->m_Styles[ i ] = vtkSmartPointer< TStyle >::New( ); this->m_Styles[ i ]->Configure( this->m_MPRActors->GetSliceActors( i ), this->m_MPRActors ); this->m_Styles[ i ]-> SetInteractor( this->m_Windows[ i ]->GetInteractor( ), i ); this->m_Styles[ i ]->SetModeToNavigation( ); } // fi } // rof if( this->m_Windows[ 3 ] != NULL ) this->m_Renderers[ 3 ]->SetBackground( 0.2, 0.2, 0.2 ); for( int i = 0; i < 3; ++i ) { for( int j = 0; j < 3; ++j ) { if( this->m_Windows[ i ] != NULL && this->m_Windows[ j ] != NULL && i != j ) this->m_Styles[ i ]-> AssociateInteractor( this->m_Windows[ j ]->GetInteractor( ) ); } // rof if( this->m_Windows[ 3 ] != NULL ) this->m_Styles[ i ]-> AssociateInteractor( this->m_Windows[ 3 ]->GetInteractor( ) ); } // rof } // ------------------------------------------------------------------------- cpExtensions::Visualization::MPRWithDifferentWindows:: ~MPRWithDifferentWindows( ) { } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRWithDifferentWindows:: SetImage( vtkImageData* image ) { this->m_MPRActors->SetInputData( 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 ); */ // First rendering this->ResetCameras( ); this->RenderAll( ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRWithDifferentWindows:: SetModeToNavigation( ) { for( unsigned int i = 0; i < 3; ++i ) { if( this->m_Styles[ i ].GetPointer( ) != NULL ) this->m_Styles[ i ]->SetModeToNavigation( ); } // rof } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRWithDifferentWindows:: SetModeToDeformation( ) { for( unsigned int i = 0; i < 3; ++i ) { if( this->m_Styles[ i ].GetPointer( ) != NULL ) this->m_Styles[ i ]->SetModeToDeformation( ); } // rof } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRWithDifferentWindows:: ResetCamera( const int& id ) { if( id < 4 ) if( this->m_Windows[ id ] != NULL ) this->m_Renderers[ id ]->ResetCamera( ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRWithDifferentWindows:: ResetCameras( ) { for( int i = 0; i < 4; ++i ) if( this->m_Windows[ i ] != NULL ) this->m_Renderers[ i ]->ResetCamera( ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRWithDifferentWindows:: Render( const int& id ) { if( id < 4 ) if( this->m_Windows[ id ] != NULL ) this->m_Windows[ id ]->Render( ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRWithDifferentWindows:: RenderAll( ) { for( int i = 0; i < 4; ++i ) if( this->m_Windows[ i ] != NULL ) this->m_Windows[ i ]->Render( ); } // ------------------------------------------------------------------------- vtkRenderer* cpExtensions::Visualization::MPRWithDifferentWindows:: GetRenderer( const int& id ) const { if( id < 4 ) return( this->m_Renderers[ id ] ); else return( NULL ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRWithDifferentWindows:: Add3DActor( vtkProp3D* prop ) { if( this->m_Renderers[ 3 ] != NULL ) { this->m_Renderers[ 3 ]->AddActor( prop ); this->ResetCamera( 3 ); this->Render( 3 ); } // fi } // eof - $RCSfile$