]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/Visualization/MPRActors.cxx
merge async example
[cpPlugins.git] / lib / cpExtensions / Visualization / MPRActors.cxx
index eea3b64550154d4f11c77a276e9615924e57f4f7..a02c8bc28d52ad37ff20848e333a3a5d4f1606a8 100644 (file)
@@ -2,9 +2,11 @@
 
 #include <vtkAlgorithmOutput.h>
 #include <vtkImageData.h>
-#include <vtkInformation.h>
+#include <vtkOutlineSource.h>
+#include <vtkProperty.h>
 #include <vtkRenderer.h>
-#include <vtkWindowLevelLookupTable.h>
+#include <vtkRendererCollection.h>
+#include <vtkRenderWindow.h>
 
 // -------------------------------------------------------------------------
 cpExtensions::Visualization::MPRActors*
@@ -14,341 +16,307 @@ New( )
   return( new Self( ) );
 }
 
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::
+ImageSliceActors* cpExtensions::Visualization::MPRActors::
+GetSliceActors( const int& i ) const
+{
+  if( i < 3 )
+    return( this->Slices[ 0 ][ i ] );
+  else
+    return( NULL );
+}
+
 // -------------------------------------------------------------------------
 int cpExtensions::Visualization::MPRActors::
 AddInputConnection( vtkAlgorithmOutput* aout )
 {
-  int N = this->ImageMaps.size( );
+  int N = this->Slices[ 0 ][ 0 ]->GetNumberOfImageActors( );
   if( N == 0 )
   {
-    this->ImageMaps.push_back(
-      vtkSmartPointer< vtkImageMapToColors >::New( )
+    this->Slices[ 0 ][ 0 ]->AddInputConnection( aout, 0 );
+    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
+            );
+
+    // Create bounding box
+    vtkImageData* new_image = dynamic_cast< vtkImageData* >(
+      aout->GetProducer( )->GetOutputDataObject( aout->GetIndex( ) )
       );
-    this->ImageMaps[ 0 ]->SetInputConnection( aout );
-    this->SetLookupTableToWindowLevel( 0 );
-    this->_Update( 0 );
-    return( 0 );
+
+    // Create 3D outline
+    double bb[ 6 ];
+    new_image->GetBounds( bb );
+
+    vtkSmartPointer< vtkOutlineSource > img_ol =
+      vtkSmartPointer< vtkOutlineSource >::New( );
+    img_ol->SetBounds( bb );
+
+    vtkSmartPointer< vtkPolyDataMapper > img_ol_mapper =
+      vtkSmartPointer< vtkPolyDataMapper >::New( );
+    img_ol_mapper->SetInputConnection( img_ol->GetOutputPort( ) );
+    this->ImageOutlineActor->SetMapper( img_ol_mapper );
+    this->ImageOutlineActor->GetProperty( )->SetColor( 1, 1, 1 );
+    this->ImageOutlineActor->GetProperty( )->SetLineWidth( 1 );
+
+    this->AddItem( this->ImageOutlineActor );
   }
   else
   {
     // Check if the image share the same space
-    vtkImageData* ref_image = this->_Image( 0 );
-    vtkImageData* new_image =
-      vtkImageData::SafeDownCast(
-        aout->GetProducer( )->GetOutputInformation( 0 )->
-        Get( vtkDataObject::DATA_OBJECT( ) )
-        );
-    int ref_ext[ 6 ], new_ext[ 6 ];
-    ref_image->GetExtent( ref_ext );
-    new_image->GetExtent( new_ext );
-    if(
-      ref_ext[ 0 ] == new_ext[ 0 ] && ref_ext[ 1 ] == new_ext[ 1 ] &&
-      ref_ext[ 2 ] == new_ext[ 2 ] && ref_ext[ 3 ] == new_ext[ 3 ] &&
-      ref_ext[ 4 ] == new_ext[ 4 ] && ref_ext[ 5 ] == new_ext[ 5 ]
-      )
+    vtkImageData* new_image = dynamic_cast< vtkImageData* >(
+      aout->GetProducer( )->GetOutputDataObject( aout->GetIndex( ) )
+      );
+    if( new_image != NULL )
     {
-      this->ImageMaps.push_back(
-        vtkSmartPointer< vtkImageMapToColors >::New( )
+      vtkAlgorithmOutput* ref_aout =
+        this->Slices[ 0 ][ 0 ]->GetImageMap( 0 )->GetOutputPort( );
+      vtkImageData* ref_image = dynamic_cast< vtkImageData* >(
+        ref_aout->GetProducer( )->GetOutputDataObject( ref_aout->GetIndex( ) )
         );
-      this->ImageMaps[ N ]->SetInputConnection( aout );
-      this->SetLookupTableToWindowLevel( N );
-      this->_Update( N );
-      return( N );
+      if( ref_image != NULL )
+      {
+        int ref_ext[ 6 ], new_ext[ 6 ];
+        ref_image->GetExtent( ref_ext );
+        new_image->GetExtent( new_ext );
+        if(
+          ref_ext[ 0 ] == new_ext[ 0 ] && ref_ext[ 1 ] == new_ext[ 1 ] &&
+          ref_ext[ 2 ] == new_ext[ 2 ] && ref_ext[ 3 ] == new_ext[ 3 ] &&
+          ref_ext[ 4 ] == new_ext[ 4 ] && ref_ext[ 5 ] == new_ext[ 5 ]
+          )
+        {
+          this->Slices[ 0 ][ 0 ]->AddInputConnection( aout, 0 );
+          vtkImageMapToColors* imap = this->Slices[ 0 ][ 0 ]->GetImageMap( N );
+          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
+                  );
+        }
+        else
+          N = -1;
+      }
+      else
+        N = -1;
     }
     else
-      return( -1 );
+      N = -1;
 
   } // fi
+  return( N );
 }
 
 // -------------------------------------------------------------------------
 int cpExtensions::Visualization::MPRActors::
-AddInputData( vtkImageData* image )
+AddInputData( vtkImageData* new_image )
 {
-  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 ]->SetInputData( image );
-    this->SetLookupTableToWindowLevel( 0 );
-    this->_Update( 0 );
-    return( 0 );
+    this->Slices[ 0 ][ 0 ]->AddInputData( new_image, 0 );
+    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
+              );
+          else
+            this->Slices[ i ][ j ]->AddInputData( new_image, j );
+
+        } // fi
+
+    // Create 3D outline
+    double bb[ 6 ];
+    new_image->GetBounds( bb );
+
+    vtkSmartPointer< vtkOutlineSource > img_ol =
+      vtkSmartPointer< vtkOutlineSource >::New( );
+    img_ol->SetBounds( bb );
+
+    vtkSmartPointer< vtkPolyDataMapper > img_ol_mapper =
+      vtkSmartPointer< vtkPolyDataMapper >::New( );
+    img_ol_mapper->SetInputConnection( img_ol->GetOutputPort( ) );
+    this->ImageOutlineActor->SetMapper( img_ol_mapper );
+    this->ImageOutlineActor->GetProperty( )->SetColor( 1, 1, 1 );
+    this->ImageOutlineActor->GetProperty( )->SetLineWidth( 1 );
+
+    this->AddItem( this->ImageOutlineActor );
   }
   else
   {
     // Check if the image share the same space
-    vtkImageData* ref_image = this->_Image( 0 );
-    vtkImageData* new_image = image;
-    int ref_ext[ 6 ], new_ext[ 6 ];
-    ref_image->GetExtent( ref_ext );
-    new_image->GetExtent( new_ext );
-    if(
-      ref_ext[ 0 ] == new_ext[ 0 ] && ref_ext[ 1 ] == new_ext[ 1 ] &&
-      ref_ext[ 2 ] == new_ext[ 2 ] && ref_ext[ 3 ] == new_ext[ 3 ] &&
-      ref_ext[ 4 ] == new_ext[ 4 ] && ref_ext[ 5 ] == new_ext[ 5 ]
-      )
+    vtkAlgorithmOutput* ref_aout =
+      this->Slices[ 0 ][ 0 ]->GetImageMap( 0 )->GetOutputPort( );
+    vtkImageData* ref_image = dynamic_cast< vtkImageData* >(
+      ref_aout->GetProducer( )->GetOutputDataObject( ref_aout->GetIndex( ) )
+      );
+    if( ref_image != NULL )
     {
-      this->ImageMaps.push_back(
-        vtkSmartPointer< vtkImageMapToColors >::New( )
-        );
-      this->ImageMaps[ N ]->SetInputData( image );
-      this->SetLookupTableToWindowLevel( N );
-      this->_Update( N );
-      return( N );
+      int ref_ext[ 6 ], new_ext[ 6 ];
+      ref_image->GetExtent( ref_ext );
+      new_image->GetExtent( new_ext );
+      if(
+        ref_ext[ 0 ] == new_ext[ 0 ] && ref_ext[ 1 ] == new_ext[ 1 ] &&
+        ref_ext[ 2 ] == new_ext[ 2 ] && ref_ext[ 3 ] == new_ext[ 3 ] &&
+        ref_ext[ 4 ] == new_ext[ 4 ] && ref_ext[ 5 ] == new_ext[ 5 ]
+        )
+      {
+        this->Slices[ 0 ][ 0 ]->AddInputData( new_image, 0 );
+        vtkImageMapToColors* imap = this->Slices[ 0 ][ 0 ]->GetImageMap( N );
+        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
+                  );
+              else
+                this->Slices[ i ][ j ]->AddInputData( new_image, j );
+
+            } // fi
+      }
+      else
+        N = -1;
     }
     else
-      return( -1 );
+      N = -1;
 
   } // fi
+  return( N );
+}
+
+// -------------------------------------------------------------------------
+unsigned int cpExtensions::Visualization::MPRActors::
+GetNumberOfImages( ) const
+{
+  return( this->Slices[ 0 ][ 0 ]->GetNumberOfImageActors( ) );
 }
 
 // -------------------------------------------------------------------------
 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 );
+
+  for( unsigned int j = 0; j < 3; ++j )
+  {
+    ImageInteractorStyle* st =
+      dynamic_cast< ImageInteractorStyle* >( this->Slices[ 0 ][ j ]->GetStyle( ) );
+    if( w != NULL )
+      st->AssociateInteractor( w->GetInteractor( ) );
+    for( unsigned int l = 0; l < 3; ++l )
+      if( j != l )
+        st->AssociateInteractor(
+          this->Slices[ 0 ][ l ]->GetStyle( )->GetInteractor( )
+          );
+
+  } // rof
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRActors::
-PopDataFrom(
-  vtkRenderer* x,
-  vtkRenderer* y,
-  vtkRenderer* z,
-  vtkRenderer* w
+PopActorsFrom(
+  vtkRenderWindow* x, vtkRenderWindow* y, vtkRenderWindow* z,
+  vtkRenderWindow* w
   )
 {
-  vtkRenderer* rends[] = { x, y, z };
+  this->Slices[ 0 ][ 0 ]->PopActorsFrom( x );
+  this->Slices[ 0 ][ 1 ]->PopActorsFrom( y );
+  this->Slices[ 0 ][ 2 ]->PopActorsFrom( z );
+
+  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 ]->RemoveActor( this->Slices[ 0 ][ i ]->GetImageActor( k ) );
-      rends[ i ]->RemoveActor( this->Slices[ 0 ][ i ]->GetTextActor( ) );
       for( int j = 0; j < 3; ++j )
-        rends[ i ]->RemoveActor( this->Slices[ 0 ][ j ]->GetPlaneActor( ) );
-
-    } // fi
-    if( w != NULL )
+        if( i != j )
+          rends[ i ]->RemoveActor( this->Slices[ 0 ][ j ]->GetPlaneActor( ) );
+    if( wren != NULL )
     {
       for(
         unsigned int k = 0;
         k < this->Slices[ 1 ][ i ]->GetNumberOfImageActors( );
         ++k
         )
-        w->RemoveActor( this->Slices[ 1 ][ i ]->GetImageActor( k ) );
-      w->RemoveActor( this->Slices[ 1 ][ i ]->GetPlaneActor( ) );
+        wren->RemoveActor( this->Slices[ 1 ][ i ]->GetImageActor( k ) );
+      wren->RemoveActor( this->Slices[ 1 ][ i ]->GetPlaneActor( ) );
 
     } // fi
 
   } // rof
-  if( w != NULL )
-    w->RemoveActor( this->ImageOutlineActor );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::MPRActors::
-SetLookupTable( unsigned int i, vtkScalarsToColors* lut )
-{
-  if( i < this->ImageMaps.size( ) )
-  {
-    this->ImageMaps[ i ]->SetLookupTable( lut );
-    this->ImageMaps[ i ]->Update( );
-    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 )
-    return;
-
-  double r[ 2 ];
-  image->GetScalarRange( r );
-
-  vtkSmartPointer< vtkWindowLevelLookupTable > lut =
-    vtkSmartPointer< vtkWindowLevelLookupTable >::New( );
-  lut->SetScaleToLinear( );
-  lut->SetTableRange( r );
-  lut->Build( );
-
-  this->SetLookupTable( i, lut );
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::Visualization::MPRActors::
-GetMinWindow( unsigned int i ) const
-{
-  return( 0 );
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::Visualization::MPRActors::
-GetMaxWindow( unsigned int i ) const
-{
-  // Check if the input has been configured
-  vtkImageData* image = this->_Image( i );
-  if( image == NULL )
-    return( double( 0 ) );
-
-  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 )
-    return( double( 0 ) );
-
-  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 )
-    return( double( 0 ) );
-
-  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 )
-  {
-    lut->SetWindow( w );
-    lut->Build( );
-    this->ImageMaps[ i ]->Modified( );
-    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 )
-  {
-    lut->SetLevel( l );
-    lut->Build( );
-    this->ImageMaps[ i ]->Modified( );
-    this->Modified( );
-
-  } // fi
+  if( wren != NULL )
+    wren->RemoveActor( this->ImageOutlineActor );
+
+  this->Slices[ 0 ][ 0 ]->Clear( );
+  this->Slices[ 0 ][ 1 ]->Clear( );
+  this->Slices[ 0 ][ 2 ]->Clear( );
+  this->Slices[ 1 ][ 0 ]->Clear( );
+  this->Slices[ 1 ][ 1 ]->Clear( );
+  this->Slices[ 1 ][ 2 ]->Clear( );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRActors::
-ResetWindowLevel( unsigned int i )
+SetLookupTableAsColor( unsigned int i, double r, double g, double b )
 {
-  vtkImageData* image = this->_Image( i );
-  vtkWindowLevelLookupTable* lut =
-    dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
-  if( image != NULL && lut != NULL )
-  {
-    double r[ 2 ];
-    image->GetScalarRange( r );
-    lut->SetTableRange( r );
-    lut->Build( );
-    this->ImageMaps[ i ]->Modified( );
-    this->Modified( );
-
-  } // fi
+  this->Slices[ 0 ][ 0 ]->SetLookupTableAsColor( 0, r, g, b );
+  this->Slices[ 0 ][ 1 ]->Modified( );
+  this->Slices[ 0 ][ 2 ]->Modified( );
+  this->Slices[ 1 ][ 0 ]->Modified( );
+  this->Slices[ 1 ][ 1 ]->Modified( );
+  this->Slices[ 1 ][ 2 ]->Modified( );
+  this->Modified( );
 }
 
 // -------------------------------------------------------------------------
@@ -418,7 +386,11 @@ SetSlice( const int& axis, const double& slice )
 void cpExtensions::Visualization::MPRActors::
 ResetSlices( )
 {
-  // TODO
+  for( unsigned int i = 0; i < 2; ++i )
+    for( unsigned int j = 0; j < 3; ++j )
+      this->Slices[ i ][ j ]->SetSliceNumber(
+        this->Slices[ i ][ j ]->GetSliceNumberMinValue( )
+        );
 }
 
 // -------------------------------------------------------------------------
@@ -430,6 +402,14 @@ MPRActors( )
   for( unsigned int i = 0; i < 2; ++i )
     for( unsigned int j = 0; j < 3; ++j )
       this->Slices[ i ][ j ] = vtkSmartPointer< ImageSliceActors >::New( );
+
+  this->Slices[ 0 ][ 0 ]->AssociateSlice( this->Slices[ 1 ][ 0 ] );
+  this->Slices[ 0 ][ 1 ]->AssociateSlice( this->Slices[ 1 ][ 1 ] );
+  this->Slices[ 0 ][ 2 ]->AssociateSlice( this->Slices[ 1 ][ 2 ] );
+
+  this->Slices[ 0 ][ 0 ]->SetSlicesCommand( Self::_SetSlices, this );
+  this->Slices[ 0 ][ 1 ]->SetSlicesCommand( Self::_SetSlices, this );
+  this->Slices[ 0 ][ 2 ]->SetSlicesCommand( Self::_SetSlices, this );
 }
 
 // -------------------------------------------------------------------------
@@ -442,16 +422,20 @@ cpExtensions::Visualization::MPRActors::
 vtkImageData* cpExtensions::Visualization::MPRActors::
 _Image( unsigned int i ) const
 {
+  /*
   if( i < this->ImageMaps.size( ) )
   {
     vtkAlgorithm* algo = this->ImageMaps[ i ]->GetInputAlgorithm( );
     vtkInformation* info = algo->GetOutputInformation( 0 );
     return(
-      vtkImageData::SafeDownCast( info->Get( vtkDataObject::DATA_OBJECT( ) ) )
+      vtkImageData::SafeDownCast(
+        info->Get( vtkDataObject::DATA_OBJECT( ) )
+        )
       );
   }
   else
-    return( NULL );
+  */
+  return( NULL );
 }
 
 // -------------------------------------------------------------------------
@@ -460,41 +444,68 @@ _Update( unsigned int i )
 {
   /*
   // Check if the input has been configured
-  vtkImageData* image = this->_InputImage( );
+  vtkImageData* image = this->_Image( i );
   if( image == NULL )
     return;
-  this->ImageMapToColors->Update( );
+  this->ImageMaps[ i ]->Update( );
 
   for( int j = 0; j < 2; ++j )
   {
-    for( int i = 0; i < 3; ++i )
+    for( int k = 0; k < 3; ++k )
     {
-      this->Slices[ j ][ i ]->AddInputConnection(
-        this->ImageMapToColors->GetOutputPort( ), i
+      this->Slices[ j ][ k ]->AddInputConnection(
+        this->ImageMaps[ i ]->GetOutputPort( ), k
         );
-      this->Slices[ j ][ i ]->UpdateText( );
+      this->Slices[ j ][ k ]->UpdateText( );
+
+      // Add all of slice's props
+      this->Slices[ j ][ k ]->InitTraversal( );
+      vtkProp* prop = this->Slices[ j ][ k ]->GetNextProp( );
+      while( prop != NULL )
+      {
+        this->AddItem( prop );
+        prop = this->Slices[ j ][ k ]->GetNextProp( );
+
+      } // elihw
 
     } // rof
 
   } // rof
 
-  // Create 3D outline
-  double bb[ 6 ];
-  image->GetBounds( bb );
+  if( i == 0 )
+  {
+    // Create 3D outline
+    double bb[ 6 ];
+    image->GetBounds( bb );
+
+    vtkSmartPointer< vtkOutlineSource > img_ol =
+      vtkSmartPointer< vtkOutlineSource >::New( );
+    img_ol->SetBounds( bb );
 
-  vtkSmartPointer< vtkOutlineSource > img_ol =
-    vtkSmartPointer< vtkOutlineSource >::New( );
-  img_ol->SetBounds( bb );
+    vtkSmartPointer< vtkPolyDataMapper > img_ol_mapper =
+      vtkSmartPointer< vtkPolyDataMapper >::New( );
+    img_ol_mapper->SetInputConnection( img_ol->GetOutputPort( ) );
+    this->ImageOutlineActor->SetMapper( img_ol_mapper );
+    this->ImageOutlineActor->GetProperty( )->SetColor( 1, 1, 1 );
+    this->ImageOutlineActor->GetProperty( )->SetLineWidth( 1 );
 
-  vtkSmartPointer< vtkPolyDataMapper > img_ol_mapper =
-    vtkSmartPointer< vtkPolyDataMapper >::New( );
-  img_ol_mapper->SetInputConnection( img_ol->GetOutputPort( ) );
-  this->ImageOutlineActor->SetMapper( img_ol_mapper );
-  this->ImageOutlineActor->GetProperty( )->SetColor( 1, 1, 1 );
-  this->ImageOutlineActor->GetProperty( )->SetLineWidth( 1 );
+    this->AddItem( this->ImageOutlineActor );
 
-  this->AddItem( this->ImageOutlineActor );
+  } // fi
   */
 }
 
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+_SetSlices( double* pos, int axis, void* data )
+{
+  MPRActors* actors = reinterpret_cast< MPRActors* >( data );
+  if( actors == NULL )
+    return;
+  for( unsigned int j = 0; j < 3; ++j )
+    if( actors->Slices[ 0 ][ j ]->GetAxis( ) != axis )
+      actors->Slices[ 0 ][ j ]->SetSlice( pos );
+  actors->Modified( );
+}
+
 // eof - $RCSfile$