1 #include <cpExtensions/QT/SimpleMPRWidget.h>
3 #ifdef cpExtensions_QT4
5 #include <cpExtensions/ui_SimpleMPRWidget.h>
6 #include <vtkRenderWindow.h>
9 #include <vtkProperty.h>
10 #include <vtkRendererCollection.h>
11 double cpExtensions::QT::SimpleMPRWidget::
25 // -------------------------------------------------------------------------
26 cpExtensions::QT::SimpleMPRWidget::
27 SimpleMPRWidget( QWidget* parent )
29 m_UI( new Ui::SimpleMPRWidget )
35 this->m_UI->setupUi( this );
37 // Configure VTK widgets
38 this->m_VTK[ 0 ] = this->m_UI->VTK01;
39 this->m_VTK[ 1 ] = this->m_UI->VTK00;
40 this->m_VTK[ 2 ] = this->m_UI->VTK10;
41 this->m_VTK[ 3 ] = this->m_UI->VTK11;
43 for( unsigned int i = 0; i < 4; ++i )
45 this->m_Renderers[ i ] = vtkSmartPointer< vtkRenderer >::New( );
46 this->m_VTK[ i ]->GetRenderWindow( )->AddRenderer( this->m_Renderers[ i ] );
51 this->m_MPRObjects = vtkSmartPointer< TMPRObjects >::New( );
52 this->m_MPRObjects->SetRenderWindows(
53 this->m_VTK[ 0 ]->GetRenderWindow( ),
54 this->m_VTK[ 1 ]->GetRenderWindow( ),
55 this->m_VTK[ 2 ]->GetRenderWindow( ),
56 this->m_VTK[ 3 ]->GetRenderWindow( )
62 this->m_UI->TopSplitter, SIGNAL( splitterMoved( int, int ) ),
63 this, SLOT( _SyncBottom( int, int ) )
66 this->m_UI->BottomSplitter, SIGNAL( splitterMoved( int, int ) ),
67 this, SLOT( _SyncTop( int, int ) )
71 // -------------------------------------------------------------------------
72 cpExtensions::QT::SimpleMPRWidget::
78 // -------------------------------------------------------------------------
79 void cpExtensions::QT::SimpleMPRWidget::
80 SetMainImage( vtkImageData* image )
82 for( unsigned int i = 0; i < 3; ++i )
84 this->m_2DSlices[ i ] = vtkSmartPointer< TActors >::New( );
85 this->m_2DSlices[ i ]->SetInputData( image, i );
86 this->m_2DSlices[ i ]->PushInto( this->m_Renderers[ i ] );
87 this->m_VTK[ i ]->GetRenderWindow( )->GetInteractor( )->
88 SetInteractorStyle( this->m_2DSlices[ i ]->GetStyle( ) );
90 this->m_3DSlices[ i ] = vtkSmartPointer< TActors >::New( );
91 this->m_3DSlices[ i ]->SetInputData( image, i );
92 this->m_3DSlices[ i ]->PushInto( this->m_Renderers[ 3 ] );
93 this->m_3DSlices[ i ]->SetStyle(
94 dynamic_cast< vtkInteractorStyle* >(
95 this->m_Renderers[ 3 ]->GetRenderWindow( )->
96 GetInteractor( )->GetInteractorStyle( )
102 for( unsigned int i = 0; i < 3; ++i )
104 for( unsigned int j = 0; j < 3; ++j )
107 this->m_2DSlices[ i ]->AssociateSlice( this->m_2DSlices[ j ] );
108 this->m_2DSlices[ i ]->AssociateSlice( this->m_3DSlices[ j ] );
113 for( unsigned int i = 0; i < 3; ++i )
115 this->m_2DSlices[ i ]->GetStyle( )->
116 SetCurrentRenderer( this->m_Renderers[ i ] );
117 this->m_Renderers[ i ]->ResetCamera( );
118 this->m_VTK[ i ]->GetRenderWindow( )->Render( );
121 this->m_Renderers[ 3 ]->ResetCamera( );
122 this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
125 // -------------------------------------------------------------------------
126 void cpExtensions::QT::SimpleMPRWidget::
127 _SyncBottom( int a, int b )
129 this->m_UI->BottomSplitter->setSizes( this->m_UI->TopSplitter->sizes( ) );
132 // -------------------------------------------------------------------------
133 void cpExtensions::QT::SimpleMPRWidget::
134 _SyncTop( int a, int b )
136 this->m_UI->TopSplitter->setSizes( this->m_UI->BottomSplitter->sizes( ) );
139 #endif // cpExtensions_QT4