1 #include <cpExtensions/Visualization/MPRObjects.h>
4 #include <vtkImageData.h>
5 #include <vtkLookupTable.h>
7 // -------------------------------------------------------------------------
8 cpExtensions::Visualization::MPRObjects*
9 cpExtensions::Visualization::MPRObjects::
12 return( new Self( ) );
15 // -------------------------------------------------------------------------
16 void cpExtensions::Visualization::MPRObjects::
18 vtkRenderWindow* wx, vtkRenderWindow* wy,
19 vtkRenderWindow* wz, vtkRenderWindow* w3D
22 this->m_Windows[ 0 ] = wx;
23 this->m_Windows[ 1 ] = wy;
24 this->m_Windows[ 2 ] = wz;
25 this->m_Windows[ 3 ] = w3D;
27 // Prepare 2D renderers
28 for( int i = 0; i < 4; ++i )
30 if( this->m_Windows[ i ] == NULL )
32 this->m_Renderers[ i ] = NULL;
37 // Create renderer, if render window exists
38 this->m_Renderers[ i ] = vtkSmartPointer< vtkRenderer >::New( );
39 this->m_Renderers[ i ]->SetBackground( 0.1, 0.3, 0.8 );
40 this->m_Windows[ i ]->AddRenderer( this->m_Renderers[ i ] );
45 if( this->m_Windows[ 3 ] != NULL )
46 this->m_Renderers[ 3 ]->SetBackground( 0.2, 0.2, 0.2 );
49 // -------------------------------------------------------------------------
50 void cpExtensions::Visualization::MPRObjects::
51 SetImage( vtkImageData* image )
53 this->m_MPRActors->AddInputData( image );
54 this->m_MPRActors->PushActorsInto(
62 this->m_MPRActors->ResetSlices( );
63 this->ResetCameras( );
67 // -------------------------------------------------------------------------
68 void cpExtensions::Visualization::MPRObjects::
69 AddAuxiliaryImage( vtkImageData* image )
71 // Try to add new image
72 int id = this->m_MPRActors->AddInputData( image );
76 // Push everything on renderers
77 this->m_MPRActors->PushActorsInto(
88 // -------------------------------------------------------------------------
89 void cpExtensions::Visualization::MPRObjects::
90 ActivateInteractors( )
93 for( int i = 0; i < 3; ++i )
95 // Check prerrequisites
96 if( this->m_Windows[ i ] == NULL || this->m_Renderers[ i ] == NULL )
98 // TODO: this->m_Styles[ i ] = NULL;
103 ImageSliceActors* actors = this->m_MPRActors->GetSliceActors( i );
106 // TODO: this->m_Styles[ i ] = NULL;
112 this->m_Styles[ i ] = vtkSmartPointer< TStyle >::New( );
113 this->m_Styles[ i ]->Configure( actors, this->m_MPRActors );
114 this->m_Styles[ i ]->
115 SetInteractor( this->m_Windows[ i ]->GetInteractor( ), i );
116 this->m_Styles[ i ]->SetModeToNavigation( );
121 // Synch 2D and 3D renderers
122 for( int i = 0; i < 3; ++i )
124 for( int j = 0; j < 3; ++j )
128 this->m_Windows[ i ] != NULL &&
129 this->m_Windows[ j ] != NULL &&
132 this->m_Styles[ i ]->
133 AssociateInteractor( this->m_Windows[ j ]->GetInteractor( ) );
138 if( this->m_Windows[ 3 ] != NULL )
139 this->m_Styles[ i ]->
140 AssociateInteractor( this->m_Windows[ 3 ]->GetInteractor( ) );
145 // Finish interactor linking
146 // TODO: this->m_MPRActors->LinkInteractors( );
149 this->ResetCameras( );
153 // -------------------------------------------------------------------------
154 void cpExtensions::Visualization::MPRObjects::
155 ResetCamera( const int& id )
158 if( this->m_Windows[ id ] != NULL )
159 this->m_Renderers[ id ]->ResetCamera( );
162 // -------------------------------------------------------------------------
163 void cpExtensions::Visualization::MPRObjects::
166 for( int i = 0; i < 4; ++i )
167 if( this->m_Windows[ i ] != NULL )
168 this->m_Renderers[ i ]->ResetCamera( );
171 // -------------------------------------------------------------------------
172 void cpExtensions::Visualization::MPRObjects::
173 Render( const int& id )
176 if( this->m_Windows[ id ] != NULL )
177 this->m_Windows[ id ]->Render( );
180 // -------------------------------------------------------------------------
181 void cpExtensions::Visualization::MPRObjects::
184 for( int i = 0; i < 4; ++i )
185 if( this->m_Windows[ i ] != NULL )
186 this->m_Windows[ i ]->Render( );
189 // -------------------------------------------------------------------------
190 vtkRenderer* cpExtensions::Visualization::MPRObjects::
193 return( this->m_Renderers[ 0 ] );
196 // -------------------------------------------------------------------------
197 vtkRenderer* cpExtensions::Visualization::MPRObjects::
200 return( this->m_Renderers[ 1 ] );
203 // -------------------------------------------------------------------------
204 vtkRenderer* cpExtensions::Visualization::MPRObjects::
207 return( this->m_Renderers[ 2 ] );
210 // -------------------------------------------------------------------------
211 vtkRenderer* cpExtensions::Visualization::MPRObjects::
214 return( this->m_Renderers[ 3 ] );
217 // -------------------------------------------------------------------------
218 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
219 GetXRenderer( ) const
221 return( this->m_Renderers[ 0 ] );
224 // -------------------------------------------------------------------------
225 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
226 GetYRenderer( ) const
228 return( this->m_Renderers[ 1 ] );
231 // -------------------------------------------------------------------------
232 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
233 GetZRenderer( ) const
235 return( this->m_Renderers[ 2 ] );
238 // -------------------------------------------------------------------------
239 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
240 Get3DRenderer( ) const
242 return( this->m_Renderers[ 3 ] );
245 // -------------------------------------------------------------------------
246 cpExtensions::Visualization::MPRObjects::
247 TMPRActors* cpExtensions::Visualization::MPRObjects::
250 return( this->m_MPRActors );
253 // -------------------------------------------------------------------------
254 const cpExtensions::Visualization::MPRObjects::
255 TMPRActors* cpExtensions::Visualization::MPRObjects::
256 GetMPRActors( ) const
258 return( this->m_MPRActors );
261 // -------------------------------------------------------------------------
262 cpExtensions::Visualization::MPRObjects::
267 this->m_MPRActors = vtkSmartPointer< TMPRActors >::New( );
270 // -------------------------------------------------------------------------
271 cpExtensions::Visualization::MPRObjects::