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->PushDataInto(
55 this->m_Renderers[ 0 ],
56 this->m_Renderers[ 1 ],
57 this->m_Renderers[ 2 ],
58 this->m_Renderers[ 3 ]
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->PushDataInto(
78 this->m_Renderers[ 0 ],
79 this->m_Renderers[ 1 ],
80 this->m_Renderers[ 2 ],
81 this->m_Renderers[ 3 ]
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 this->m_Styles[ i ] = NULL;
103 ImageSliceActors* actors = this->m_MPRActors->GetSliceActors( i );
106 this->m_Styles[ i ] = NULL;
111 this->m_Styles[ i ] = vtkSmartPointer< TStyle >::New( );
112 this->m_Styles[ i ]->Configure( actors, this->m_MPRActors );
113 this->m_Styles[ i ]->
114 SetInteractor( this->m_Windows[ i ]->GetInteractor( ), i );
115 this->m_Styles[ i ]->SetModeToNavigation( );
119 // Synch 2D and 3D renderers
120 for( int i = 0; i < 3; ++i )
122 for( int j = 0; j < 3; ++j )
125 this->m_Windows[ i ] != NULL &&
126 this->m_Windows[ j ] != NULL &&
129 this->m_Styles[ i ]->
130 AssociateInteractor( this->m_Windows[ j ]->GetInteractor( ) );
133 if( this->m_Windows[ 3 ] != NULL )
134 this->m_Styles[ i ]->
135 AssociateInteractor( this->m_Windows[ 3 ]->GetInteractor( ) );
139 // Finish interactor linking
140 this->m_MPRActors->LinkInteractors( );
143 this->ResetCameras( );
147 // -------------------------------------------------------------------------
148 void cpExtensions::Visualization::MPRObjects::
149 ResetCamera( const int& id )
152 if( this->m_Windows[ id ] != NULL )
153 this->m_Renderers[ id ]->ResetCamera( );
156 // -------------------------------------------------------------------------
157 void cpExtensions::Visualization::MPRObjects::
160 for( int i = 0; i < 4; ++i )
161 if( this->m_Windows[ i ] != NULL )
162 this->m_Renderers[ i ]->ResetCamera( );
165 // -------------------------------------------------------------------------
166 void cpExtensions::Visualization::MPRObjects::
167 Render( const int& id )
170 if( this->m_Windows[ id ] != NULL )
171 this->m_Windows[ id ]->Render( );
174 // -------------------------------------------------------------------------
175 void cpExtensions::Visualization::MPRObjects::
178 for( int i = 0; i < 4; ++i )
179 if( this->m_Windows[ i ] != NULL )
180 this->m_Windows[ i ]->Render( );
183 // -------------------------------------------------------------------------
184 vtkRenderer* cpExtensions::Visualization::MPRObjects::
187 return( this->m_Renderers[ 0 ] );
190 // -------------------------------------------------------------------------
191 vtkRenderer* cpExtensions::Visualization::MPRObjects::
194 return( this->m_Renderers[ 1 ] );
197 // -------------------------------------------------------------------------
198 vtkRenderer* cpExtensions::Visualization::MPRObjects::
201 return( this->m_Renderers[ 2 ] );
204 // -------------------------------------------------------------------------
205 vtkRenderer* cpExtensions::Visualization::MPRObjects::
208 return( this->m_Renderers[ 3 ] );
211 // -------------------------------------------------------------------------
212 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
213 GetXRenderer( ) const
215 return( this->m_Renderers[ 0 ] );
218 // -------------------------------------------------------------------------
219 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
220 GetYRenderer( ) const
222 return( this->m_Renderers[ 1 ] );
225 // -------------------------------------------------------------------------
226 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
227 GetZRenderer( ) const
229 return( this->m_Renderers[ 2 ] );
232 // -------------------------------------------------------------------------
233 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
234 Get3DRenderer( ) const
236 return( this->m_Renderers[ 3 ] );
239 // -------------------------------------------------------------------------
240 cpExtensions::Visualization::MPRObjects::
245 this->m_MPRActors = vtkSmartPointer< TMPRActors >::New( );
248 // -------------------------------------------------------------------------
249 cpExtensions::Visualization::MPRObjects::