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* x, vtkRenderWindow* y,
19 vtkRenderWindow* z, vtkRenderWindow* w
22 this->m_Windows[ 0 ] = x;
23 this->m_Windows[ 1 ] = y;
24 this->m_Windows[ 2 ] = z;
25 this->m_Windows[ 3 ] = w;
27 // Prepare 2D renderers
28 for( int i = 0; i < 4; ++i )
30 // Create renderer, if render window exists
31 if( this->m_Windows[ i ] != NULL )
33 this->m_Renderers[ i ] = vtkSmartPointer< vtkRenderer >::New( );
34 this->m_Renderers[ i ]->SetBackground( 0.3, 0.3, 0.3 );
35 this->m_Windows[ i ]->AddRenderer( this->m_Renderers[ i ] );
38 this->m_Renderers[ i ] = NULL;
43 // -------------------------------------------------------------------------
44 void cpExtensions::Visualization::MPRObjects::
45 SetInputConnection( vtkAlgorithmOutput* aout )
47 this->m_MPRActors->SetInputConnection( aout );
50 // -------------------------------------------------------------------------
51 void cpExtensions::Visualization::MPRObjects::
52 SetInputImage( vtkImageData* data )
54 this->m_MPRActors->SetInputImage( data );
57 // -------------------------------------------------------------------------
58 int cpExtensions::Visualization::MPRObjects::
60 vtkAlgorithmOutput* aout,
61 const double& r, const double& g, const double& b
64 return( this->m_MPRActors->AddBinaryConnection( aout, r, g, b ) );
67 // -------------------------------------------------------------------------
68 int cpExtensions::Visualization::MPRObjects::
71 const double& r, const double& g, const double& b
74 return( this->m_MPRActors->AddBinaryImage( data, r, g, b ) );
77 // -------------------------------------------------------------------------
78 void cpExtensions::Visualization::MPRObjects::
81 this->m_MPRActors->Clear( );
84 // -------------------------------------------------------------------------
85 vtkImageData* cpExtensions::Visualization::MPRObjects::
88 return( this->m_MPRActors->GetInputImage( ) );
91 // -------------------------------------------------------------------------
92 const vtkImageData* cpExtensions::Visualization::MPRObjects::
93 GetInputImage( ) const
95 return( this->m_MPRActors->GetInputImage( ) );
98 // -------------------------------------------------------------------------
99 unsigned int cpExtensions::Visualization::MPRObjects::
100 GetNumberOfImages( ) const
102 return( this->m_MPRActors->GetNumberOfImages( ) );
105 // -------------------------------------------------------------------------
106 void cpExtensions::Visualization::MPRObjects::
107 SetInterpolate( bool v )
109 this->m_MPRActors->SetInterpolate( v );
112 // -------------------------------------------------------------------------
113 void cpExtensions::Visualization::MPRObjects::
116 this->m_MPRActors->InterpolateOn( );
119 // -------------------------------------------------------------------------
120 void cpExtensions::Visualization::MPRObjects::
123 this->m_MPRActors->InterpolateOff( );
126 // -------------------------------------------------------------------------
127 double cpExtensions::Visualization::MPRObjects::
128 GetMinWindow( ) const
130 return( this->m_MPRActors->GetMinWindow( ) );
133 // -------------------------------------------------------------------------
134 double cpExtensions::Visualization::MPRObjects::
135 GetMaxWindow( ) const
137 return( this->m_MPRActors->GetMaxWindow( ) );
140 // -------------------------------------------------------------------------
141 double cpExtensions::Visualization::MPRObjects::
144 return( this->m_MPRActors->GetMinLevel( ) );
147 // -------------------------------------------------------------------------
148 double cpExtensions::Visualization::MPRObjects::
151 return( this->m_MPRActors->GetMaxLevel( ) );
154 // -------------------------------------------------------------------------
155 double cpExtensions::Visualization::MPRObjects::
158 return( this->m_MPRActors->GetWindow( ) );
161 // -------------------------------------------------------------------------
162 double cpExtensions::Visualization::MPRObjects::
165 return( this->m_MPRActors->GetLevel( ) );
168 // -------------------------------------------------------------------------
169 void cpExtensions::Visualization::MPRObjects::
170 SetWindow( double w )
172 this->m_MPRActors->SetWindow( w );
175 // -------------------------------------------------------------------------
176 void cpExtensions::Visualization::MPRObjects::
179 this->m_MPRActors->SetLevel( l );
182 // -------------------------------------------------------------------------
183 void cpExtensions::Visualization::MPRObjects::
184 SetWindowLevel( double w, double l )
186 this->m_MPRActors->SetWindowLevel( w, l );
189 // -------------------------------------------------------------------------
190 void cpExtensions::Visualization::MPRObjects::
193 this->m_MPRActors->ResetWindowLevel( );
196 // -------------------------------------------------------------------------
197 int cpExtensions::Visualization::MPRObjects::
198 GetSliceNumber( const int& axis ) const
200 return( this->m_MPRActors->GetSliceNumber( axis ) );
203 // -------------------------------------------------------------------------
204 int cpExtensions::Visualization::MPRObjects::
205 GetSliceNumberMinValue( const int& axis ) const
207 return( this->m_MPRActors->GetSliceNumberMinValue( axis ) );
210 // -------------------------------------------------------------------------
211 int cpExtensions::Visualization::MPRObjects::
212 GetSliceNumberMaxValue( const int& axis ) const
214 return( this->m_MPRActors->GetSliceNumberMaxValue( axis ) );
217 // -------------------------------------------------------------------------
218 void cpExtensions::Visualization::MPRObjects::
219 SetSliceNumber( const int& axis, const int& slice )
221 this->m_MPRActors->SetSliceNumber( axis, slice );
224 // -------------------------------------------------------------------------
225 void cpExtensions::Visualization::MPRObjects::
226 SetSlice( const int& axis, double* pos )
228 this->m_MPRActors->SetSlice( axis, pos );
231 // -------------------------------------------------------------------------
232 void cpExtensions::Visualization::MPRObjects::
233 Render( const double& t )
235 this->Render( 0, t );
236 this->Render( 1, t );
237 this->Render( 2, t );
238 this->Render( 3, t );
241 // -------------------------------------------------------------------------
242 void cpExtensions::Visualization::MPRObjects::
243 Render( const int& axis, const double& t )
247 if( this->m_Windows[ axis ].GetPointer( ) != NULL )
249 if( this->m_Renderers[ axis ].GetPointer( ) != NULL )
250 this->m_Renderers[ axis ]->SetAllocatedRenderTime( t );
251 this->m_Windows[ axis ]->Render( );
258 // -------------------------------------------------------------------------
259 void cpExtensions::Visualization::MPRObjects::
260 ResetCamera( const int& axis )
263 if( this->m_Renderers[ axis ].GetPointer( ) != NULL )
264 this->m_Renderers[ axis ]->ResetCamera( );
267 // -------------------------------------------------------------------------
268 void cpExtensions::Visualization::MPRObjects::
271 this->ResetCamera( 0 );
272 this->ResetCamera( 1 );
273 this->ResetCamera( 2 );
274 this->ResetCamera( 3 );
277 // -------------------------------------------------------------------------
278 cpExtensions::Visualization::MPRObjects::
282 this->m_MPRActors = vtkSmartPointer< MPRActors >::New( );
285 // -------------------------------------------------------------------------
286 cpExtensions::Visualization::MPRObjects::
295 // -------------------------------------------------------------------------
296 void cpExtensions::Visualization::MPRObjects::
298 vtkRenderWindow* wx, vtkRenderWindow* wy,
299 vtkRenderWindow* wz, vtkRenderWindow* w3D
304 // -------------------------------------------------------------------------
305 void cpExtensions::Visualization::MPRObjects::
306 AddImage( vtkImageData* image )
308 this->m_MPRActors->AddInputData( image );
309 this->m_MPRActors->PushActorsInto(
310 this->m_Windows[ 0 ],
311 this->m_Windows[ 1 ],
312 this->m_Windows[ 2 ],
317 if( this->m_MPRActors->GetNumberOfImages( ) == 1 )
319 this->m_MPRActors->ResetSlices( );
320 this->ResetCameras( );
323 this->RenderAll( 1e-3 );
326 // -------------------------------------------------------------------------
327 unsigned int cpExtensions::Visualization::MPRObjects::
328 GetNumberOfImages( ) const
330 return( this->m_MPRActors->GetNumberOfImages( ) );
333 // -------------------------------------------------------------------------
334 void cpExtensions::Visualization::MPRObjects::
337 this->m_MPRActors->PopActorsFrom(
338 this->m_Windows[ 0 ],
339 this->m_Windows[ 1 ],
340 this->m_Windows[ 2 ],
343 this->ResetCameras( );
344 this->RenderAll( 1e-3 );
347 // -------------------------------------------------------------------------
348 void cpExtensions::Visualization::MPRObjects::
349 ResetCamera( const int& id )
352 if( this->m_Windows[ id ] != NULL )
353 this->m_Renderers[ id ]->ResetCamera( );
356 // -------------------------------------------------------------------------
357 void cpExtensions::Visualization::MPRObjects::
360 for( int i = 0; i < 4; ++i )
361 if( this->m_Windows[ i ] != NULL )
362 this->m_Renderers[ i ]->ResetCamera( );
365 // -------------------------------------------------------------------------
366 void cpExtensions::Visualization::MPRObjects::
367 Render( const int& id, const double& t )
371 if( this->m_Windows[ id ] != NULL )
373 if( this->m_Renderers[ id ] != NULL )
374 this->m_Renderers[ id ]->SetAllocatedRenderTime( t );
375 this->m_Windows[ id ]->Render( );
382 // -------------------------------------------------------------------------
383 void cpExtensions::Visualization::MPRObjects::
384 RenderAll( const double& t )
386 for( int i = 0; i < 4; ++i )
388 if( this->m_Windows[ i ] != NULL )
390 if( this->m_Renderers[ i ] != NULL )
391 this->m_Renderers[ i ]->SetAllocatedRenderTime( t );
392 this->m_Windows[ i ]->Render( );
399 // -------------------------------------------------------------------------
400 vtkRenderer* cpExtensions::Visualization::MPRObjects::
403 return( this->m_Renderers[ 0 ] );
406 // -------------------------------------------------------------------------
407 vtkRenderer* cpExtensions::Visualization::MPRObjects::
410 return( this->m_Renderers[ 1 ] );
413 // -------------------------------------------------------------------------
414 vtkRenderer* cpExtensions::Visualization::MPRObjects::
417 return( this->m_Renderers[ 2 ] );
420 // -------------------------------------------------------------------------
421 vtkRenderer* cpExtensions::Visualization::MPRObjects::
424 return( this->m_Renderers[ 3 ] );
427 // -------------------------------------------------------------------------
428 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
429 GetXRenderer( ) const
431 return( this->m_Renderers[ 0 ] );
434 // -------------------------------------------------------------------------
435 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
436 GetYRenderer( ) const
438 return( this->m_Renderers[ 1 ] );
441 // -------------------------------------------------------------------------
442 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
443 GetZRenderer( ) const
445 return( this->m_Renderers[ 2 ] );
448 // -------------------------------------------------------------------------
449 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
450 Get3DRenderer( ) const
452 return( this->m_Renderers[ 3 ] );
455 // -------------------------------------------------------------------------
456 cpExtensions::Visualization::
457 MPRActors* cpExtensions::Visualization::MPRObjects::
460 return( this->m_MPRActors );
463 // -------------------------------------------------------------------------
464 const cpExtensions::Visualization::
465 MPRActors* cpExtensions::Visualization::MPRObjects::
466 GetMPRActors( ) const
468 return( this->m_MPRActors );
471 // -------------------------------------------------------------------------
472 double cpExtensions::Visualization::MPRObjects::
475 return( this->m_MPRActors->GetWindow( ) );
478 // -------------------------------------------------------------------------
479 double cpExtensions::Visualization::MPRObjects::
482 return( this->m_MPRActors->GetLevel( ) );
485 // -------------------------------------------------------------------------
486 cpExtensions::Visualization::MPRObjects::
491 this->m_MPRActors = vtkSmartPointer< MPRActors >::New( );
494 // -------------------------------------------------------------------------
495 cpExtensions::Visualization::MPRObjects::