]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/Visualization/MPRActors.cxx
Intermediary commit
[cpPlugins.git] / lib / cpExtensions / Visualization / MPRActors.cxx
index bc758c4c42a10a3a5e9e88b33d917f4377ed1578..72bf719729b46078d34948f7aacf5477e859a71c 100644 (file)
@@ -1,15 +1,9 @@
 #include <cpExtensions/Visualization/MPRActors.h>
 
-#include <cmath>
-
-#include <vtkAlgorithmOutput.h>
 #include <vtkImageData.h>
-#include <vtkInformation.h>
-#include <vtkLookupTable.h>
-#include <vtkOutlineSource.h>
-#include <vtkProperty.h>
 #include <vtkRenderer.h>
-#include <vtkWindowLevelLookupTable.h>
+#include <vtkRendererCollection.h>
+#include <vtkRenderWindow.h>
 
 // -------------------------------------------------------------------------
 cpExtensions::Visualization::MPRActors*
@@ -32,22 +26,26 @@ GetSliceActors( const int& i ) const
 
 // -------------------------------------------------------------------------
 int cpExtensions::Visualization::MPRActors::
-AddInputConnection( vtkAlgorithmOutput* aout )
+AddInputConnection(
+  vtkAlgorithmOutput* aout, ImageSliceActors::LUTType lut
+  )
 {
-  int N = this->ImageMaps.size( );
+  int N = this->Slices[ 0 ][ 0 ]->GetNumberOfImageActors( );
   if( N == 0 )
   {
-    this->ImageMaps.push_back(
-      vtkSmartPointer< vtkImageMapToColors >::New( )
-      );
-    this->ImageMaps[ 0 ]->SetInputConnection( aout );
-    this->SetLookupTableToWindowLevel( 0 );
-    this->_Update( 0 );
-    this->ResetWindowLevel( 0 );
-    return( 0 );
+    this->Slices[ 0 ][ 0 ]->AddInputConnection( aout, 0, lut );
+    vtkImageMapToColors* imap = this->Slices[ 0 ][ 0 ]->GetImageMap( 0 );
+    for( unsigned int i = 0; i < 2; ++i )
+      for( unsigned int j = 0; j < 3; ++j )
+        if( i != 0 || j != 0 )
+          this->Slices[ i ][ j ]->AddInputConnection(
+            ( ( imap != NULL )? imap->GetOutputPort( ): aout ), j,
+            ImageSliceActors::LUTType_None
+            );
   }
   else
   {
+    /*
     // Check if the image share the same space
     vtkImageData* ref_image = this->_Image( 0 );
     vtkImageData* new_image =
@@ -75,15 +73,43 @@ AddInputConnection( vtkAlgorithmOutput* aout )
       return( N );
     }
     else
-      return( -1 );
+    N = -1;
+  */
 
   } // fi
+  return( N );
 }
 
 // -------------------------------------------------------------------------
 int cpExtensions::Visualization::MPRActors::
-AddInputData( vtkImageData* image )
+AddInputData( vtkImageData* image, ImageSliceActors::LUTType lut )
 {
+  int N = this->Slices[ 0 ][ 0 ]->GetNumberOfImageActors( );
+  if( N == 0 )
+  {
+    this->Slices[ 0 ][ 0 ]->AddInputData( image, 0, lut );
+    vtkImageMapToColors* imap = this->Slices[ 0 ][ 0 ]->GetImageMap( 0 );
+    for( unsigned int i = 0; i < 2; ++i )
+      for( unsigned int j = 0; j < 3; ++j )
+        if( i != 0 || j != 0 )
+        {
+          if( imap != NULL )
+            this->Slices[ i ][ j ]->AddInputConnection(
+              imap->GetOutputPort( ), j,
+              ImageSliceActors::LUTType_None
+              );
+          else
+            this->Slices[ i ][ j ]->AddInputData(
+              image, j,
+              ImageSliceActors::LUTType_None
+              );
+        } // fi
+  }
+  else
+  {
+  } // fi
+  return( N );
+  /*
   int N = this->ImageMaps.size( );
   if( N == 0 )
   {
@@ -124,43 +150,49 @@ AddInputData( vtkImageData* image )
       return( -1 );
 
   } // fi
+  */
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRActors::
-PushDataInto( vtkRenderer* x, vtkRenderer* y, vtkRenderer* z, vtkRenderer* w )
+PushActorsInto(
+  vtkRenderWindow* x, vtkRenderWindow* y, vtkRenderWindow* z,
+  vtkRenderWindow* w
+  )
 {
-  vtkRenderer* rends[] = { x, y, z };
+  this->Slices[ 0 ][ 0 ]->PushActorsInto( x, true );
+  this->Slices[ 0 ][ 1 ]->PushActorsInto( y, true );
+  this->Slices[ 0 ][ 2 ]->PushActorsInto( z, true );
+
+  vtkRenderer* wren =
+    ( w != NULL )? w->GetRenderers( )->GetFirstRenderer( ): NULL;
+  vtkRenderer* rends[ ] =
+    {
+      ( x != NULL )? x->GetRenderers( )->GetFirstRenderer( ): NULL,
+      ( y != NULL )? y->GetRenderers( )->GetFirstRenderer( ): NULL,
+      ( z != NULL )? z->GetRenderers( )->GetFirstRenderer( ): NULL
+    };
   for( int i = 0; i < 3; ++i )
   {
     if( rends[ i ] != NULL )
-    {
-      for(
-        unsigned int k = 0;
-        k < this->Slices[ 0 ][ i ]->GetNumberOfImageActors( );
-        ++k
-        )
-        rends[ i ]->AddActor( this->Slices[ 0 ][ i ]->GetImageActor( k ) );
-      rends[ i ]->AddActor( this->Slices[ 0 ][ i ]->GetTextActor( ) );
       for( int j = 0; j < 3; ++j )
-        rends[ i ]->AddActor( this->Slices[ 0 ][ j ]->GetPlaneActor( ) );
-
-    } // fi
-    if( w != NULL )
+        if( i != j )
+          rends[ i ]->AddActor( this->Slices[ 0 ][ j ]->GetPlaneActor( ) );
+    if( wren != NULL )
     {
       for(
         unsigned int k = 0;
         k < this->Slices[ 1 ][ i ]->GetNumberOfImageActors( );
         ++k
         )
-        w->AddActor( this->Slices[ 1 ][ i ]->GetImageActor( k ) );
-      w->AddActor( this->Slices[ 1 ][ i ]->GetPlaneActor( ) );
+        wren->AddActor( this->Slices[ 1 ][ i ]->GetImageActor( k ) );
+      wren->AddActor( this->Slices[ 1 ][ i ]->GetPlaneActor( ) );
 
     } // fi
 
   } // rof
-  if( w != NULL )
-    w->AddActor( this->ImageOutlineActor );
+  if( wren != NULL )
+    wren->AddActor( this->ImageOutlineActor );
 }
 
 // -------------------------------------------------------------------------
@@ -172,6 +204,7 @@ PopDataFrom(
   vtkRenderer* w
   )
 {
+  /*
   vtkRenderer* rends[] = { x, y, z };
   for( int i = 0; i < 3; ++i )
   {
@@ -203,9 +236,11 @@ PopDataFrom(
   } // rof
   if( w != NULL )
     w->RemoveActor( this->ImageOutlineActor );
+  */
 }
 
 // -------------------------------------------------------------------------
+  /*
 void cpExtensions::Visualization::MPRActors::
 LinkInteractors( )
 {
@@ -213,11 +248,13 @@ LinkInteractors( )
   this->_Update( 1 );
   this->_Update( 2 );
 }
+  */
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRActors::
 SetLookupTable( unsigned int i, vtkScalarsToColors* lut )
 {
+  /*
   if( i < this->ImageMaps.size( ) )
   {
     this->ImageMaps[ i ]->SetLookupTable( lut );
@@ -225,22 +262,26 @@ SetLookupTable( unsigned int i, vtkScalarsToColors* lut )
     this->Modified( );
 
   } // fi
+  */
 }
 
 // -------------------------------------------------------------------------
 vtkScalarsToColors* cpExtensions::Visualization::MPRActors::
 GetLookupTable( unsigned int i ) const
 {
+  /*
   if( i < this->ImageMaps.size( ) )
     return( this->ImageMaps[ i ]->GetLookupTable( ) );
   else
     return( NULL );
+    */
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRActors::
 SetLookupTableToWindowLevel( unsigned int i )
 {
+  /*
   // Check if the input has been configured
   vtkImageData* image = this->_Image( i );
   if( image == NULL )
@@ -256,6 +297,7 @@ SetLookupTableToWindowLevel( unsigned int i )
   lut->Build( );
 
   this->SetLookupTable( i, lut );
+  */
 }
 
 // -------------------------------------------------------------------------
@@ -269,6 +311,7 @@ GetMinWindow( unsigned int i ) const
 double cpExtensions::Visualization::MPRActors::
 GetMaxWindow( unsigned int i ) const
 {
+  /*
   // Check if the input has been configured
   vtkImageData* image = this->_Image( i );
   if( image == NULL )
@@ -277,12 +320,14 @@ GetMaxWindow( unsigned int i ) const
   double r[ 2 ];
   image->GetScalarRange( r );
   return( r[ 1 ] - r[ 0 ] );
+  */
 }
 
 // -------------------------------------------------------------------------
 double cpExtensions::Visualization::MPRActors::
 GetMinLevel( unsigned int i ) const
 {
+  /*
   // Check if the input has been configured
   vtkImageData* image = this->_Image( i );
   if( image == NULL )
@@ -291,12 +336,14 @@ GetMinLevel( unsigned int i ) const
   double r[ 2 ];
   image->GetScalarRange( r );
   return( r[ 0 ] );
+  */
 }
 
 // -------------------------------------------------------------------------
 double cpExtensions::Visualization::MPRActors::
 GetMaxLevel( unsigned int i ) const
 {
+  /*
   // Check if the input has been configured
   vtkImageData* image = this->_Image( i );
   if( image == NULL )
@@ -305,36 +352,42 @@ GetMaxLevel( unsigned int i ) const
   double r[ 2 ];
   image->GetScalarRange( r );
   return( r[ 1 ] );
+  */
 }
 
 // -------------------------------------------------------------------------
 double cpExtensions::Visualization::MPRActors::
 GetWindow( unsigned int i ) const
 {
+  /*
   vtkWindowLevelLookupTable* lut =
     dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
   if( lut != NULL )
     return( lut->GetWindow( ) );
   else
     return( double( 0 ) );
+  */
 }
 
 // -------------------------------------------------------------------------
 double cpExtensions::Visualization::MPRActors::
 GetLevel( unsigned int i ) const
 {
+  /*
   vtkWindowLevelLookupTable* lut =
     dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
   if( lut != NULL )
     return( lut->GetLevel( ) );
   else
     return( double( 0 ) );
+  */
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRActors::
 SetWindow( unsigned int i, const double& w )
 {
+  /*
   vtkWindowLevelLookupTable* lut =
     dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
   if( lut != NULL )
@@ -345,12 +398,14 @@ SetWindow( unsigned int i, const double& w )
     this->Modified( );
 
   } // fi
+  */
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRActors::
 SetLevel( unsigned int i, const double& l )
 {
+  /*
   vtkWindowLevelLookupTable* lut =
     dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
   if( lut != NULL )
@@ -361,12 +416,14 @@ SetLevel( unsigned int i, const double& l )
     this->Modified( );
 
   } // fi
+  */
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRActors::
 SetWindowLevel( unsigned int i, const double& w, const double& l )
 {
+  /*
   vtkWindowLevelLookupTable* lut =
     dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
   if( lut != NULL )
@@ -382,12 +439,14 @@ SetWindowLevel( unsigned int i, const double& w, const double& l )
     this->Modified( );
 
   } // fi
+  */
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRActors::
 ResetWindowLevel( unsigned int i )
 {
+  /*
   vtkImageData* image = this->_Image( i );
   vtkWindowLevelLookupTable* lut =
     dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
@@ -403,6 +462,7 @@ ResetWindowLevel( unsigned int i )
     this->Modified( );
 
   } // fi
+  */
 }
 
 // -------------------------------------------------------------------------
@@ -411,6 +471,7 @@ SetLookupTableToColor(
   unsigned int i, const double& r, const double& g, const double& b
   )
 {
+  /*
   static const double _0 = double( 0 );
   static const double _1 = double( 1 );
   static const double _2 = double( 2 );
@@ -443,17 +504,13 @@ SetLookupTableToColor(
     else if( b == cmax )
       hue = ( ( r - g ) / d ) + _4;
     hue *= _1 / _6;
-    
+
   } // fi
 
   // Define new lookup table
   vtkSmartPointer< vtkLookupTable > lut =
     vtkSmartPointer< vtkLookupTable >::New( );
   lut->SetScaleToLinear( );
-  /*
-    lut->SetAboveRangeColor( _0, _0, _0, _0 );
-    lut->SetBelowRangeColor( _0, _0, _0, _0 );
-  */
   lut->SetNanColor( _0, _0, _0, _0 );
   lut->SetTableRange( range[ 0 ], range[ 1 ] );
   lut->SetAlphaRange( _0, _OPACITY );
@@ -463,6 +520,7 @@ SetLookupTableToColor(
   lut->Build( );
 
   this->SetLookupTable( i, lut );
+  */
 }
 
 // -------------------------------------------------------------------------
@@ -560,6 +618,7 @@ cpExtensions::Visualization::MPRActors::
 vtkImageData* cpExtensions::Visualization::MPRActors::
 _Image( unsigned int i ) const
 {
+  /*
   if( i < this->ImageMaps.size( ) )
   {
     vtkAlgorithm* algo = this->ImageMaps[ i ]->GetInputAlgorithm( );
@@ -571,13 +630,15 @@ _Image( unsigned int i ) const
       );
   }
   else
-    return( NULL );
+  */
+  return( NULL );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRActors::
 _Update( unsigned int i )
 {
+  /*
   // Check if the input has been configured
   vtkImageData* image = this->_Image( i );
   if( image == NULL )
@@ -627,6 +688,7 @@ _Update( unsigned int i )
     this->AddItem( this->ImageOutlineActor );
 
   } // fi
+  */
 }
 
 // eof - $RCSfile$