#include #ifdef cpExtensions_QT4 #include #include // ------------------------------------------------------------------------- cpExtensions::QT::SimpleMPRWidget:: SimpleMPRWidget( QWidget* parent ) : QWidget( parent ), m_UI( new Ui::SimpleMPRWidget ) { this->m_UI->setupUi( this ); // Configure VTK widgets this->m_VTK[ 0 ] = this->m_UI->VTK01; this->m_VTK[ 1 ] = this->m_UI->VTK00; this->m_VTK[ 2 ] = this->m_UI->VTK10; this->m_VTK[ 3 ] = this->m_UI->VTK11; for( unsigned int i = 0; i < 4; ++i ) { this->m_Renderers[ i ] = vtkSmartPointer< vtkRenderer >::New( ); this->m_VTK[ i ]->GetRenderWindow( )-> AddRenderer( this->m_Renderers[ i ] ); } // rof // Connect slots QObject::connect( this->m_UI->TopSplitter, SIGNAL( splitterMoved( int, int ) ), this, SLOT( _SyncBottom( int, int ) ) ); QObject::connect( this->m_UI->BottomSplitter, SIGNAL( splitterMoved( int, int ) ), this, SLOT( _SyncTop( int, int ) ) ); } // ------------------------------------------------------------------------- cpExtensions::QT::SimpleMPRWidget:: ~SimpleMPRWidget( ) { delete this->m_UI; } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: Clear( ) { for( unsigned int i = 0; i < 4; ++i ) this->m_Renderers[ i ]->RemoveAllViewProps( ); for( unsigned int i = 0; i < 3; ++i ) { if( this->m_2DSlices[ i ].GetPointer( ) != NULL ) this->m_2DSlices[ i ]->Clear( ); if( this->m_3DSlices[ i ].GetPointer( ) != NULL ) this->m_3DSlices[ i ]->Clear( ); } // rof this->m_PolyDatas.clear( ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: SetMainImage( vtkImageData* image ) { for( unsigned int i = 0; i < 3; ++i ) { this->m_2DSlices[ i ] = vtkSmartPointer< TActors >::New( ); this->m_2DSlices[ i ]->SetInputData( image, i ); this->m_2DSlices[ i ]->PushInto( this->m_Renderers[ i ] ); this->m_VTK[ i ]->GetRenderWindow( )->GetInteractor( )-> SetInteractorStyle( this->m_2DSlices[ i ]->GetStyle( ) ); this->m_3DSlices[ i ] = vtkSmartPointer< TActors >::New( ); this->m_3DSlices[ i ]->SetInputData( image, i ); this->m_3DSlices[ i ]->PushInto( this->m_Renderers[ 3 ] ); this->m_3DSlices[ i ]->SetStyle( dynamic_cast< vtkInteractorStyle* >( this->m_Renderers[ 3 ]->GetRenderWindow( )-> GetInteractor( )->GetInteractorStyle( ) ) ); } // rof for( unsigned int i = 0; i < 3; ++i ) { for( unsigned int j = 0; j < 3; ++j ) { if( i != j ) this->m_2DSlices[ i ]->AssociateSlice( this->m_2DSlices[ j ] ); this->m_2DSlices[ i ]->AssociateSlice( this->m_3DSlices[ j ] ); } // rof } // rof for( unsigned int i = 0; i < 3; ++i ) { this->m_2DSlices[ i ]->GetStyle( )-> SetCurrentRenderer( this->m_Renderers[ i ] ); this->m_Renderers[ i ]->ResetCamera( ); this->m_VTK[ i ]->GetRenderWindow( )->Render( ); } // rof this->m_Renderers[ 3 ]->ResetCamera( ); this->m_VTK[ 3 ]->GetRenderWindow( )->Render( ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: AddMesh( vtkPolyData* mesh ) { PolyDataActor a; a.Configure( mesh ); this->m_PolyDatas[ mesh ] = a; this->m_Renderers[ 3 ]->AddViewProp( a.Actor ); bool has_main_image = false; for( unsigned int i = 0; i < 3; ++i ) { if( this->m_2DSlices[ i ].GetPointer( ) != NULL ) { if( this->m_2DSlices[ i ]->GetInputData( ) != NULL ) { has_main_image = true; this->m_2DSlices[ i ]->AddMesh( mesh ); this->m_2DSlices[ i ]->Render( ); } // fi } // fi } // rof if( !has_main_image ) this->m_Renderers[ 3 ]->ResetCamera( ); this->m_VTK[ 3 ]->GetRenderWindow( )->Render( ); } // ------------------------------------------------------------------------- vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget:: GetInteractor( unsigned int i ) { if( i < 4 ) return( this->m_VTK[ i ]->GetRenderWindow( )->GetInteractor( ) ); else return( NULL ); } // ------------------------------------------------------------------------- vtkRenderer* cpExtensions::QT::SimpleMPRWidget:: GetRenderer( unsigned int i ) { if( i < 4 ) return( this->m_Renderers[ i ] ); else return( NULL ); } // ------------------------------------------------------------------------- std::vector< std::pair< vtkImageActor*, vtkRenderer* > > cpExtensions::QT::SimpleMPRWidget:: GetMainImageActors( ) { std::vector< std::pair< vtkImageActor*, vtkRenderer* > > actors; for( unsigned int i = 0; i < 3; ++i ) { actors.push_back( std::pair< vtkImageActor*, vtkRenderer* >( this->m_2DSlices[ i ]->GetImageActor( ), this->m_Renderers[ i ] ) ); actors.push_back( std::pair< vtkImageActor*, vtkRenderer* >( this->m_3DSlices[ i ]->GetImageActor( ), this->m_Renderers[ 3 ] ) ); } // rof return( actors ); } // ------------------------------------------------------------------------- vtkActor* cpExtensions::QT::SimpleMPRWidget:: GetActor( vtkPolyData* mesh ) { auto i = this->m_PolyDatas.find( mesh ); if( i != this->m_PolyDatas.end( ) ) return( i->second.Actor.GetPointer( ) ); else return( NULL ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: _SyncBottom( int a, int b ) { this->m_UI->BottomSplitter->setSizes( this->m_UI->TopSplitter->sizes( ) ); } // ------------------------------------------------------------------------- void cpExtensions::QT::SimpleMPRWidget:: _SyncTop( int a, int b ) { this->m_UI->TopSplitter->setSizes( this->m_UI->BottomSplitter->sizes( ) ); } #endif // cpExtensions_QT4 // eof - $RCSfile$