1 #include <cpExtensions/Visualization/MPRObjects.h>
5 #include <vtkImageData.h>
6 #include <vtkLookupTable.h>
8 // -------------------------------------------------------------------------
9 cpExtensions::Visualization::MPRObjects*
10 cpExtensions::Visualization::MPRObjects::
13 return( new Self( ) );
16 // -------------------------------------------------------------------------
17 void cpExtensions::Visualization::MPRObjects::
19 vtkRenderWindow* x, vtkRenderWindow* y,
20 vtkRenderWindow* z, vtkRenderWindow* w
23 this->m_Windows[ 0 ] = x;
24 this->m_Windows[ 1 ] = y;
25 this->m_Windows[ 2 ] = z;
26 this->m_Windows[ 3 ] = w;
28 // Prepare 2D renderers
29 for( int i = 0; i < 4; ++i )
31 // Create renderer, if render window exists
32 if( this->m_Windows[ i ] != NULL )
34 this->m_Renderers[ i ] = vtkSmartPointer< vtkRenderer >::New( );
35 this->m_Renderers[ i ]->SetBackground( 0.3, 0.3, 0.3 );
36 this->m_Windows[ i ]->AddRenderer( this->m_Renderers[ i ] );
39 this->m_Renderers[ i ] = NULL;
44 // -------------------------------------------------------------------------
45 void cpExtensions::Visualization::MPRObjects::
46 SetInputConnection( vtkAlgorithmOutput* aout )
48 this->m_MPRActors->SetInputConnection( aout );
51 // -------------------------------------------------------------------------
52 void cpExtensions::Visualization::MPRObjects::
53 SetInputImage( vtkImageData* data )
55 this->m_MPRActors->SetInputImage( data );
58 // -------------------------------------------------------------------------
59 int cpExtensions::Visualization::MPRObjects::
61 vtkAlgorithmOutput* aout,
62 const double& r, const double& g, const double& b
65 return( this->m_MPRActors->AddBinaryConnection( aout, r, g, b ) );
68 // -------------------------------------------------------------------------
69 int cpExtensions::Visualization::MPRObjects::
72 const double& r, const double& g, const double& b
75 return( this->m_MPRActors->AddBinaryImage( data, r, g, b ) );
78 // -------------------------------------------------------------------------
79 void cpExtensions::Visualization::MPRObjects::
82 this->m_MPRActors->PushActorsInto(
90 // -------------------------------------------------------------------------
91 void cpExtensions::Visualization::MPRObjects::
94 this->m_MPRActors->PopActorsFrom(
102 // -------------------------------------------------------------------------
103 void cpExtensions::Visualization::MPRObjects::
106 this->m_MPRActors->Clear( );
109 // -------------------------------------------------------------------------
110 vtkImageData* cpExtensions::Visualization::MPRObjects::
113 return( this->m_MPRActors->GetInputImage( ) );
116 // -------------------------------------------------------------------------
117 const vtkImageData* cpExtensions::Visualization::MPRObjects::
118 GetInputImage( ) const
120 return( this->m_MPRActors->GetInputImage( ) );
123 // -------------------------------------------------------------------------
124 unsigned int cpExtensions::Visualization::MPRObjects::
125 GetNumberOfImages( ) const
127 return( this->m_MPRActors->GetNumberOfImages( ) );
130 // -------------------------------------------------------------------------
131 void cpExtensions::Visualization::MPRObjects::
132 SetInterpolate( bool v )
134 this->m_MPRActors->SetInterpolate( v );
137 // -------------------------------------------------------------------------
138 void cpExtensions::Visualization::MPRObjects::
141 this->m_MPRActors->InterpolateOn( );
144 // -------------------------------------------------------------------------
145 void cpExtensions::Visualization::MPRObjects::
148 this->m_MPRActors->InterpolateOff( );
151 // -------------------------------------------------------------------------
152 double cpExtensions::Visualization::MPRObjects::
153 GetMinWindow( ) const
155 return( this->m_MPRActors->GetMinWindow( ) );
158 // -------------------------------------------------------------------------
159 double cpExtensions::Visualization::MPRObjects::
160 GetMaxWindow( ) const
162 return( this->m_MPRActors->GetMaxWindow( ) );
165 // -------------------------------------------------------------------------
166 double cpExtensions::Visualization::MPRObjects::
169 return( this->m_MPRActors->GetMinLevel( ) );
172 // -------------------------------------------------------------------------
173 double cpExtensions::Visualization::MPRObjects::
176 return( this->m_MPRActors->GetMaxLevel( ) );
179 // -------------------------------------------------------------------------
180 double cpExtensions::Visualization::MPRObjects::
183 return( this->m_MPRActors->GetWindow( ) );
186 // -------------------------------------------------------------------------
187 double cpExtensions::Visualization::MPRObjects::
190 return( this->m_MPRActors->GetLevel( ) );
193 // -------------------------------------------------------------------------
194 void cpExtensions::Visualization::MPRObjects::
195 SetWindow( double w )
197 this->m_MPRActors->SetWindow( w );
200 // -------------------------------------------------------------------------
201 void cpExtensions::Visualization::MPRObjects::
204 this->m_MPRActors->SetLevel( l );
207 // -------------------------------------------------------------------------
208 void cpExtensions::Visualization::MPRObjects::
209 SetWindowLevel( double w, double l )
211 this->m_MPRActors->SetWindowLevel( w, l );
214 // -------------------------------------------------------------------------
215 void cpExtensions::Visualization::MPRObjects::
218 this->m_MPRActors->ResetWindowLevel( );
221 // -------------------------------------------------------------------------
222 int cpExtensions::Visualization::MPRObjects::
223 GetSliceNumber( const int& axis ) const
225 return( this->m_MPRActors->GetSliceNumber( axis ) );
228 // -------------------------------------------------------------------------
229 int cpExtensions::Visualization::MPRObjects::
230 GetSliceNumberMinValue( const int& axis ) const
232 return( this->m_MPRActors->GetSliceNumberMinValue( axis ) );
235 // -------------------------------------------------------------------------
236 int cpExtensions::Visualization::MPRObjects::
237 GetSliceNumberMaxValue( const int& axis ) const
239 return( this->m_MPRActors->GetSliceNumberMaxValue( axis ) );
242 // -------------------------------------------------------------------------
243 void cpExtensions::Visualization::MPRObjects::
244 SetSliceNumber( const int& axis, const int& slice )
246 this->m_MPRActors->SetSliceNumber( axis, slice );
249 // -------------------------------------------------------------------------
250 void cpExtensions::Visualization::MPRObjects::
251 SetSlice( const int& axis, double* pos )
253 this->m_MPRActors->SetSlice( axis, pos );
256 // -------------------------------------------------------------------------
257 void cpExtensions::Visualization::MPRObjects::
258 Render( const double& t )
260 this->Render( 0, t );
261 this->Render( 1, t );
262 this->Render( 2, t );
263 this->Render( 3, t );
266 // -------------------------------------------------------------------------
267 void cpExtensions::Visualization::MPRObjects::
268 Render( const int& axis, const double& t )
272 if( this->m_Windows[ axis ].GetPointer( ) != NULL )
274 if( this->m_Renderers[ axis ].GetPointer( ) != NULL )
275 this->m_Renderers[ axis ]->SetAllocatedRenderTime( t );
276 this->m_Windows[ axis ]->Render( );
283 // -------------------------------------------------------------------------
284 void cpExtensions::Visualization::MPRObjects::
285 ResetCamera( const int& axis )
288 if( this->m_Renderers[ axis ].GetPointer( ) != NULL )
289 this->m_Renderers[ axis ]->ResetCamera( );
292 // -------------------------------------------------------------------------
293 void cpExtensions::Visualization::MPRObjects::
296 this->ResetCamera( 0 );
297 this->ResetCamera( 1 );
298 this->ResetCamera( 2 );
299 this->ResetCamera( 3 );
302 // -------------------------------------------------------------------------
303 cpExtensions::Visualization::MPRObjects::
307 this->m_MPRActors = vtkSmartPointer< MPRActors >::New( );
310 // -------------------------------------------------------------------------
311 cpExtensions::Visualization::MPRObjects::
320 // -------------------------------------------------------------------------
321 void cpExtensions::Visualization::MPRObjects::
323 vtkRenderWindow* wx, vtkRenderWindow* wy,
324 vtkRenderWindow* wz, vtkRenderWindow* w3D
329 // -------------------------------------------------------------------------
330 void cpExtensions::Visualization::MPRObjects::
331 AddImage( vtkImageData* image )
333 this->m_MPRActors->AddInputData( image );
334 this->m_MPRActors->PushActorsInto(
335 this->m_Windows[ 0 ],
336 this->m_Windows[ 1 ],
337 this->m_Windows[ 2 ],
342 if( this->m_MPRActors->GetNumberOfImages( ) == 1 )
344 this->m_MPRActors->ResetSlices( );
345 this->ResetCameras( );
348 this->RenderAll( 1e-3 );
351 // -------------------------------------------------------------------------
352 unsigned int cpExtensions::Visualization::MPRObjects::
353 GetNumberOfImages( ) const
355 return( this->m_MPRActors->GetNumberOfImages( ) );
358 // -------------------------------------------------------------------------
359 void cpExtensions::Visualization::MPRObjects::
362 this->m_MPRActors->PopActorsFrom(
363 this->m_Windows[ 0 ],
364 this->m_Windows[ 1 ],
365 this->m_Windows[ 2 ],
368 this->ResetCameras( );
369 this->RenderAll( 1e-3 );
372 // -------------------------------------------------------------------------
373 void cpExtensions::Visualization::MPRObjects::
374 ResetCamera( const int& id )
377 if( this->m_Windows[ id ] != NULL )
378 this->m_Renderers[ id ]->ResetCamera( );
381 // -------------------------------------------------------------------------
382 void cpExtensions::Visualization::MPRObjects::
385 for( int i = 0; i < 4; ++i )
386 if( this->m_Windows[ i ] != NULL )
387 this->m_Renderers[ i ]->ResetCamera( );
390 // -------------------------------------------------------------------------
391 void cpExtensions::Visualization::MPRObjects::
392 Render( const int& id, const double& t )
396 if( this->m_Windows[ id ] != NULL )
398 if( this->m_Renderers[ id ] != NULL )
399 this->m_Renderers[ id ]->SetAllocatedRenderTime( t );
400 this->m_Windows[ id ]->Render( );
407 // -------------------------------------------------------------------------
408 void cpExtensions::Visualization::MPRObjects::
409 RenderAll( const double& t )
411 for( int i = 0; i < 4; ++i )
413 if( this->m_Windows[ i ] != NULL )
415 if( this->m_Renderers[ i ] != NULL )
416 this->m_Renderers[ i ]->SetAllocatedRenderTime( t );
417 this->m_Windows[ i ]->Render( );
424 // -------------------------------------------------------------------------
425 vtkRenderer* cpExtensions::Visualization::MPRObjects::
428 return( this->m_Renderers[ 0 ] );
431 // -------------------------------------------------------------------------
432 vtkRenderer* cpExtensions::Visualization::MPRObjects::
435 return( this->m_Renderers[ 1 ] );
438 // -------------------------------------------------------------------------
439 vtkRenderer* cpExtensions::Visualization::MPRObjects::
442 return( this->m_Renderers[ 2 ] );
445 // -------------------------------------------------------------------------
446 vtkRenderer* cpExtensions::Visualization::MPRObjects::
449 return( this->m_Renderers[ 3 ] );
452 // -------------------------------------------------------------------------
453 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
454 GetXRenderer( ) const
456 return( this->m_Renderers[ 0 ] );
459 // -------------------------------------------------------------------------
460 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
461 GetYRenderer( ) const
463 return( this->m_Renderers[ 1 ] );
466 // -------------------------------------------------------------------------
467 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
468 GetZRenderer( ) const
470 return( this->m_Renderers[ 2 ] );
473 // -------------------------------------------------------------------------
474 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
475 Get3DRenderer( ) const
477 return( this->m_Renderers[ 3 ] );
480 // -------------------------------------------------------------------------
481 cpExtensions::Visualization::
482 MPRActors* cpExtensions::Visualization::MPRObjects::
485 return( this->m_MPRActors );
488 // -------------------------------------------------------------------------
489 const cpExtensions::Visualization::
490 MPRActors* cpExtensions::Visualization::MPRObjects::
491 GetMPRActors( ) const
493 return( this->m_MPRActors );
496 // -------------------------------------------------------------------------
497 double cpExtensions::Visualization::MPRObjects::
500 return( this->m_MPRActors->GetWindow( ) );
503 // -------------------------------------------------------------------------
504 double cpExtensions::Visualization::MPRObjects::
507 return( this->m_MPRActors->GetLevel( ) );
510 // -------------------------------------------------------------------------
511 cpExtensions::Visualization::MPRObjects::
516 this->m_MPRActors = vtkSmartPointer< MPRActors >::New( );
519 // -------------------------------------------------------------------------
520 cpExtensions::Visualization::MPRObjects::