]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/Visualization/ImageSliceActors.cxx
Double click widget integrated with segmentation and deformation filters.
[cpPlugins.git] / lib / cpExtensions / Visualization / ImageSliceActors.cxx
index 676f297427dad8219cf368b31d4ce1ada91c795e..ee4947e834d4394463a547de1e958d4752e66f58 100644 (file)
@@ -1,23 +1,18 @@
 #include <cpExtensions/Visualization/ImageSliceActors.h>
 
-#include <cmath>
 #include <sstream>
 
 #include <vtkAlgorithmOutput.h>
 #include <vtkCamera.h>
 #include <vtkCellArray.h>
 #include <vtkImageData.h>
-#include <vtkInformation.h>
-#include <vtkPlane.h>
 #include <vtkPoints.h>
 #include <vtkProperty.h>
 #include <vtkRenderer.h>
 #include <vtkRendererCollection.h>
 #include <vtkRenderWindow.h>
 #include <vtkRenderWindowInteractor.h>
-#include <vtkStreamingDemandDrivenPipeline.h>
 #include <vtkTextProperty.h>
-#include <vtkWindowLevelLookupTable.h>
 
 // -------------------------------------------------------------------------
 cpExtensions::Visualization::ImageSliceActors*
@@ -27,107 +22,163 @@ New( )
   return( new Self( ) );
 }
 
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::
+ImageBlender* cpExtensions::Visualization::ImageSliceActors::
+GetBlender( )
+{
+  return( this->m_ImageBlender );
+}
+
+// -------------------------------------------------------------------------
+const cpExtensions::Visualization::
+ImageBlender* cpExtensions::Visualization::ImageSliceActors::
+GetBlender( ) const
+{
+  return( this->m_ImageBlender );
+}
+
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-AddCursorCommand( TCursorCommand command, void* data )
+SetBlender( ImageBlender* blender )
 {
-  this->m_CursorCommands.push_back(
-    std::pair< TCursorCommand, void* >( command, data )
+  this->m_ImageBlender = blender;
+
+  // Create mapper and actors
+  this->m_ImageMapper = vtkSmartPointer< vtkImageSliceMapper >::New( );
+  this->m_ImageMapper->SetInputConnection(
+    this->m_ImageBlender->GetOutputPort( )
     );
+  this->m_ImageMapper->SetOrientation( 0 );
+  this->m_ImageMapper->Update( );
+
+  // Create actor
+  this->m_ImageActor = vtkSmartPointer< vtkImageActor >::New( );
+  this->m_ImageActor->SetMapper( this->m_ImageMapper );
+  this->m_ImageActor->SetInterpolate( this->m_Interpolate );
+  this->m_ImageActor->Modified( );
+
+  if( this->m_Style.GetPointer( ) != NULL )
+    this->m_Style->AssociateImageActor( this->m_ImageActor );
+  this->AddItem( this->m_ImageActor );
+
+  this->SetSliceNumber( this->GetSliceNumberMinValue( ) );
+  this->ResetCursor( );
   this->Modified( );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-AddInputConnection( vtkAlgorithmOutput* aout, int axis )
+SetAxis( int axis )
+{
+  this->m_ImageMapper->SetOrientation( axis );
+  this->m_ImageMapper->Update( );
+  this->SetSliceNumber( this->GetSliceNumberMinValue( ) );
+  this->m_ImageActor->Modified( );
+  this->Modified( );
+  this->ResetCamera( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+AddInputConnection( vtkAlgorithmOutput* aout )
 {
   // Get input vtkImageData
   if( aout == NULL )
     return;
-  vtkAlgorithm* producer = aout->GetProducer( );
-  vtkImageData* data = dynamic_cast< vtkImageData* >(
-    producer->GetOutputDataObject( aout->GetIndex( ) )
-    );
-  if( data == NULL )
-    return;
 
-  // Try to infere if input comes from a color mapping filter
-  vtkImageMapToColors* new_map =
-    dynamic_cast< vtkImageMapToColors* >( producer );
-  if( new_map == NULL )
+  if( this->m_ImageBlender.GetPointer( ) == NULL )
   {
-    // Configure LUT, if possible (NULL is returned if not)
-    this->_ConfigureNewLUT( data );
-    new_map = *( this->m_ImageMaps.rbegin( ) );
-    if( new_map != NULL )
+    // Try to infere if input comes from a color mapping filter
+    vtkAlgorithm* producer = aout->GetProducer( );
+    vtkSmartPointer< ImageBlender > blender =
+      dynamic_cast< ImageBlender* >( producer );
+    if( blender.GetPointer( ) == NULL )
     {
-      new_map->SetInputConnection( aout );
-      new_map->Update( );
+      // Ok, create a new blender with default window level
+      vtkImageData* data = dynamic_cast< vtkImageData* >(
+        producer->GetOutputDataObject( aout->GetIndex( ) )
+        );
+      double r[ 2 ];
+      data->GetScalarRange( r );
+
+      blender = vtkSmartPointer< ImageBlender >::New( );
+      blender->AddInputConnection( aout );
+      blender->SetWindow( r[ 1 ] - r[ 0 ] );
+      blender->SetLevel( ( r[ 1 ] + r[ 0 ] ) / double( 2 ) );
 
     } // fi
+    this->SetBlender( blender );
   }
   else
-    this->m_ImageMaps.push_back( new_map );
-  
-  // Create mapper and actors
-  vtkSmartPointer< vtkImageSliceMapper > mapper =
-    vtkSmartPointer< vtkImageSliceMapper >::New( );
-  if( new_map != NULL )
-    mapper->SetInputConnection( new_map->GetOutputPort( ) );
-  else
-    mapper->SetInputConnection( aout );
-  this->m_SliceMappers.push_back( mapper );
-  this->_ConfigureNewInput( axis );
+    this->m_ImageBlender->AddInputConnection( aout );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-AddInputData( vtkImageData* data, int axis )
+AddInputData( vtkImageData* data )
 {
-  // Configure LUT, if possible (NULL is returned if not)
-  this->_ConfigureNewLUT( data );
-  vtkImageMapToColors* new_map = *( this->m_ImageMaps.rbegin( ) );
-  if( new_map != NULL )
-  {
-    new_map->SetInputData( data );
-    new_map->Update( );
-
-  } // fi
+  // Get input vtkImageData
+  if( data == NULL )
+    return;
 
-  // Create mapper and actors
-  vtkSmartPointer< vtkImageSliceMapper > mapper =
-    vtkSmartPointer< vtkImageSliceMapper >::New( );
-  if( new_map != NULL )
-    mapper->SetInputConnection( new_map->GetOutputPort( ) );
+  if( this->m_ImageBlender.GetPointer( ) == NULL )
+  {
+    // Create a new blender with default window level
+    double r[ 2 ];
+    data->GetScalarRange( r );
+
+    vtkSmartPointer< ImageBlender > blender =
+      vtkSmartPointer< ImageBlender >::New( );
+    blender->AddInputData( data );
+    blender->SetWindow( r[ 1 ] - r[ 0 ] );
+    blender->SetLevel( ( r[ 1 ] + r[ 0 ] ) / double( 2 ) );
+    this->SetBlender( blender );
+  }
   else
-    mapper->SetInputData( data );
-  this->m_SliceMappers.push_back( mapper );
-  this->_ConfigureNewInput( axis );
+    this->m_ImageBlender->AddInputData( data );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
 Clear( )
 {
+  // Reset values
+  this->m_VisibleExtent[ 0 ] =
+    this->m_VisibleExtent[ 2 ] =
+    this->m_VisibleExtent[ 4 ] = -1;
+  this->m_VisibleExtent[ 1 ] =
+    this->m_VisibleExtent[ 3 ] =
+    this->m_VisibleExtent[ 5 ] = 0;
+  this->m_VisibleBounds[ 0 ] =
+    this->m_VisibleBounds[ 2 ] =
+    this->m_VisibleBounds[ 4 ] = double( 0 );
+  this->m_VisibleBounds[ 1 ] =
+    this->m_VisibleBounds[ 3 ] =
+    this->m_VisibleBounds[ 5 ] = double( 0 );
+
   // Unbind from container
   this->RemoveAllItems( );
 
   // Delete all images
-  this->m_ImageMaps.clear( );
-  this->m_SliceMappers.clear( );
-  this->m_ImageActors.clear( );
-  this->m_AssociatedSlices.clear( );
-  this->m_AssociatedActors.clear( );
+  this->m_ImageActor   = NULL;
+  this->m_ImageMapper  = NULL;
+  this->m_ImageBlender = NULL;
 
   // Reconfigure unique objects
-  this->m_Cursor        = vtkSmartPointer< vtkPolyData >::New( );
-  this->m_CursorMapper  = vtkSmartPointer< vtkPolyDataMapper >::New( );
-  this->m_CursorActor   = vtkSmartPointer< vtkActor >::New( );
-  this->m_PlaneFunction = vtkSmartPointer< vtkPlane >::New( );
-  this->m_Plane         = vtkSmartPointer< vtkPolyData >::New( );
-  this->m_PlaneMapper   = vtkSmartPointer< vtkPolyDataMapper >::New( );
-  this->m_TextActor     = vtkSmartPointer< vtkTextActor >::New( );
-  this->m_PlaneActor    = vtkSmartPointer< vtkActor >::New( );
+  this->m_Cursor               = vtkSmartPointer< vtkPolyData >::New( );
+  this->m_CursorMapper         = vtkSmartPointer< vtkPolyDataMapper >::New( );
+  this->m_CursorActor          = vtkSmartPointer< vtkActor >::New( );
+  this->m_HorizontalLine       = vtkSmartPointer< vtkPolyData >::New( );
+  this->m_HorizontalLineMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
+  this->m_HorizontalLineActor  = vtkSmartPointer< vtkActor >::New( );
+  this->m_VerticalLine         = vtkSmartPointer< vtkPolyData >::New( );
+  this->m_VerticalLineMapper   = vtkSmartPointer< vtkPolyDataMapper >::New( );
+  this->m_VerticalLineActor    = vtkSmartPointer< vtkActor >::New( );
+  this->m_Plane                = vtkSmartPointer< vtkPolyData >::New( );
+  this->m_PlaneMapper          = vtkSmartPointer< vtkPolyDataMapper >::New( );
+  this->m_TextActor            = vtkSmartPointer< vtkTextActor >::New( );
+  this->m_PlaneActor           = vtkSmartPointer< vtkActor >::New( );
   this->m_TextBuffer[ 0 ] = '\0';
 
   // Unique objects configuration
@@ -160,6 +211,34 @@ Clear( )
   this->m_CursorMapper->SetInputData( this->m_Cursor );
   this->m_CursorActor->SetMapper( this->m_CursorMapper );
 
+  vtkSmartPointer< vtkPoints > h_points =
+    vtkSmartPointer< vtkPoints >::New( );
+  vtkSmartPointer< vtkCellArray > h_lines =
+    vtkSmartPointer< vtkCellArray >::New( );
+  h_points->InsertNextPoint( 0, 0, 0 );
+  h_points->InsertNextPoint( 0, 0, 0 );
+  h_lines->InsertNextCell( 2 );
+  h_lines->InsertCellPoint( 0 );
+  h_lines->InsertCellPoint( 1 );
+  this->m_HorizontalLine->SetPoints( h_points );
+  this->m_HorizontalLine->SetLines( h_lines );
+  this->m_HorizontalLineMapper->SetInputData( this->m_HorizontalLine );
+  this->m_HorizontalLineActor->SetMapper( this->m_HorizontalLineMapper );
+
+  vtkSmartPointer< vtkPoints > v_points =
+    vtkSmartPointer< vtkPoints >::New( );
+  vtkSmartPointer< vtkCellArray > v_lines =
+    vtkSmartPointer< vtkCellArray >::New( );
+  v_points->InsertNextPoint( 0, 0, 0 );
+  v_points->InsertNextPoint( 0, 0, 0 );
+  v_lines->InsertNextCell( 2 );
+  v_lines->InsertCellPoint( 0 );
+  v_lines->InsertCellPoint( 1 );
+  this->m_VerticalLine->SetPoints( v_points );
+  this->m_VerticalLine->SetLines( v_lines );
+  this->m_VerticalLineMapper->SetInputData( this->m_VerticalLine );
+  this->m_VerticalLineActor->SetMapper( this->m_VerticalLineMapper );
+
   vtkSmartPointer< vtkPoints > plane_points =
     vtkSmartPointer< vtkPoints >::New( );
   vtkSmartPointer< vtkCellArray > plane_lines =
@@ -197,24 +276,17 @@ Clear( )
 
   // Update actor collection
   this->AddItem( this->m_CursorActor );
+  this->AddItem( this->m_HorizontalLineActor );
+  this->AddItem( this->m_VerticalLineActor );
   this->AddItem( this->m_TextActor );
   this->AddItem( this->m_PlaneActor );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-AssociateSlice( Self* other )
-{
-  this->m_AssociatedSlices.push_back( other );
-  this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-SetSlicesCommand( TCursorCommand cmd, void* data )
+AssociateSlice( Self* slice )
 {
-  this->SlicesCommand = cmd;
-  this->SlicesData = data;
+  this->m_AssociatedSlices.push_back( slice );
   this->Modified( );
 }
 
@@ -232,35 +304,60 @@ GetStyle( ) const
   return( this->m_Style.GetPointer( ) );
 }
 
+// -------------------------------------------------------------------------
+vtkImageData* cpExtensions::Visualization::ImageSliceActors::
+GetInputImage( unsigned int id )
+{
+  if( this->m_ImageBlender.GetPointer( ) != NULL )
+    return(
+      dynamic_cast< vtkImageData* >( this->m_ImageBlender->GetInput( id ) )
+      );
+  else
+    return( NULL );
+}
+
+// -------------------------------------------------------------------------
+const vtkImageData* cpExtensions::Visualization::ImageSliceActors::
+GetInputImage( unsigned int id ) const
+{
+  if( this->m_ImageBlender.GetPointer( ) != NULL )
+    return(
+      dynamic_cast< const vtkImageData* >(
+        this->m_ImageBlender->GetInput( )
+        )
+      );
+  else
+    return( NULL );
+}
+
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
 PushActorsInto( vtkRenderWindow* window, bool force_style )
 {
+  this->m_Window = window;
   if( window == NULL )
     return;
   vtkRenderWindowInteractor* rwi = window->GetInteractor( );
   vtkRenderer* renderer = window->GetRenderers( )->GetFirstRenderer( );
   if( rwi == NULL || renderer == NULL )
     return;
-  
+
   // Update style
-  if( force_style )
-  {
-    this->_ConfigureStyle( );
+  if( this->m_Style.GetPointer( ) != NULL && force_style )
     rwi->SetInteractorStyle( this->m_Style );
 
-  } // fi
-
   // Update actors
-# error USE vtkActorCollection interface
-  /* TODO
-     for( unsigned int n = 0; n < this->GetNumberOfImageActors( ); ++n )
-     renderer->AddActor( this->GetImageActor( n ) );
-     renderer->AddActor( this->m_CursorActor );
-     renderer->AddActor( this->m_PlaneActor );
-     renderer->AddActor( this->m_TextActor );
-     renderer->Modified( );
-  */
+  vtkProp* prop;
+  this->InitTraversal( );
+  while( prop = this->GetNextProp( ) )
+    renderer->AddViewProp( prop );
+  renderer->Modified( );
+  if( !force_style )
+  {
+    renderer->RemoveViewProp( this->m_CursorActor );
+    renderer->RemoveViewProp( this->m_TextActor );
+
+  } // fi
 
   // Configure camera
   vtkCamera* camera = renderer->GetActiveCamera( );
@@ -273,22 +370,22 @@ PushActorsInto( vtkRenderWindow* window, bool force_style )
     if( axis == 0 )
     {
       camera->SetPosition( double( 1 ), double( 0 ), double( 0 ) );
-      camera->SetViewUp  ( double( 0 ), double( 1 ), double( 0 ) );
+      camera->SetViewUp  ( double( 0 ), double( 0 ), double( 1 ) );
     }
     else if( axis == 1 )
     {
-      camera->SetPosition( double( 0 ), double( 1 ), double(  0 ) );
-      camera->SetViewUp  ( double( 0 ), double( 0 ), double( -1 ) );
+      camera->SetPosition( double( 0 ), double( -1 ), double( 0 ) );
+      camera->SetViewUp  ( double( 0 ), double(  0 ), double( 1 ) );
     }
     else // if( axis == 2 )
     {
-      camera->SetPosition( double( 0 ), double( 0 ), double( 1 ) );
-      camera->SetViewUp  ( double( 0 ), double( 1 ), double( 0 ) );
+      camera->SetPosition( double( 0 ), double(  0 ), double( 1 ) );
+      camera->SetViewUp  ( double( 0 ), double( -1 ), double( 0 ) );
 
     } // fi
 
   } // fi
-  renderer->ResetCamera( );
+  this->ResetCamera( );
   rwi->Render( );
 }
 
@@ -302,46 +399,29 @@ PopActorsFrom( vtkRenderWindow* window )
   if( renderer != NULL )
   {
     // Update actors
-# error USE vtkActorCollection interface
-    /* TODO
-       for( unsigned int n = 0; n < this->GetNumberOfImageActors( ); ++n )
-       renderer->RemoveActor( this->GetImageActor( n ) );
-       renderer->RemoveActor( this->m_CursorActor );
-       renderer->RemoveActor( this->m_PlaneActor );
-       renderer->RemoveActor( this->m_TextActor );
-       renderer->Modified( );
-    */
+    vtkProp* prop;
+    this->InitTraversal( );
+    while( prop = this->GetNextProp( ) )
+      renderer->RemoveViewProp( prop );
+    renderer->Modified( );
 
   } // fi
   if( rwi != NULL )
     rwi->Render( );
 }
 
-// -------------------------------------------------------------------------
-unsigned int cpExtensions::Visualization::ImageSliceActors::
-GetNumberOfImageActors( ) const
-{
-  return( this->m_ImageActors.size( ) );
-}
-
 // -------------------------------------------------------------------------
 vtkImageActor* cpExtensions::Visualization::ImageSliceActors::
-GetImageActor( unsigned int id )
+GetImageActor( )
 {
-  if( id < this->m_ImageActors.size( ) )
-    return( this->m_ImageActors[ id ] );
-  else
-    return( NULL );
+  return( this->m_ImageActor );
 }
 
 // -------------------------------------------------------------------------
 const vtkImageActor* cpExtensions::Visualization::ImageSliceActors::
-GetImageActor( unsigned int id ) const
+GetImageActor( ) const
 {
-  if( id < this->m_ImageActors.size( ) )
-    return( this->m_ImageActors[ id ] );
-  else
-    return( NULL );
+  return( this->m_ImageActor );
 }
 
 // -------------------------------------------------------------------------
@@ -376,40 +456,30 @@ GetPlaneActor( ) const
 vtkPlane* cpExtensions::Visualization::ImageSliceActors::
 GetPlaneFunction( )
 {
-  return( this->m_PlaneFunction );
+  if( this->m_ImageMapper.GetPointer( ) != NULL )
+    return( this->m_ImageMapper->GetSlicePlane( ) );
+  else
+    return( NULL );
 }
 
 // -------------------------------------------------------------------------
 const vtkPlane* cpExtensions::Visualization::ImageSliceActors::
 GetPlaneFunction( ) const
 {
-  return( this->m_PlaneFunction );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-AddActor( vtkAlgorithm* algorithm, vtkActor* actor )
-{
-  this->m_AssociatedActors.push_back( TAssociatedActor( algorithm, actor ) );
-  this->AddItem( actor );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-AddActor( vtkActor* actor )
-{
-  this->AddActor( NULL, actor );
+  if( this->m_ImageMapper.GetPointer( ) != NULL )
+    return( this->m_ImageMapper->GetSlicePlane( ) );
+  else
+    return( NULL );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
 SetInterpolate( bool v )
 {
-  if( this->Interpolate != v )
+  if( this->m_Interpolate != v )
   {
-    for( unsigned int i = 0; i < this->m_ImageActors.size( ); ++i )
-      this->m_ImageActors[ i ]->SetInterpolate( v );
-    this->Interpolate = v;
+    this->m_ImageActor->SetInterpolate( v );
+    this->m_Interpolate = v;
     this->Modified( );
 
   } // fi
@@ -433,8 +503,8 @@ InterpolateOff( )
 double* cpExtensions::Visualization::ImageSliceActors::
 GetDisplayBounds( ) const
 {
-  if( this->m_ImageActors.size( ) > 0 )
-    return( this->m_ImageActors[ 0 ]->GetDisplayBounds( ) );
+  if( this->m_ImageActor.GetPointer( ) != NULL )
+    return( this->m_ImageActor->GetDisplayBounds( ) );
   else
     return( NULL );
 }
@@ -443,38 +513,54 @@ GetDisplayBounds( ) const
 void cpExtensions::Visualization::ImageSliceActors::
 GetDisplayBounds( double bounds[ 6 ] ) const
 {
-  if( this->m_ImageActors.size( ) == 0 )
+  if( this->m_ImageActor.GetPointer( ) == NULL )
   {
     bounds[ 0 ] = bounds[ 2 ] = bounds[ 4 ] = double( -1 );
     bounds[ 1 ] = bounds[ 3 ] = bounds[ 5 ] = double( -1 );
   }
   else
-    this->m_ImageActors[ 0 ]->GetDisplayBounds( bounds );
+    this->m_ImageActor->GetDisplayBounds( bounds );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
 ResetCursor( )
 {
-  vtkPoints* points = this->m_Cursor->GetPoints( );
-  points->SetPoint( 0, 0, 0, 0 );
-  points->SetPoint( 1, 0, 0, 0 );
-  points->SetPoint( 2, 0, 0, 0 );
-  points->SetPoint( 3, 0, 0, 0 );
-  points->SetPoint( 4, 0, 0, 0 );
-  points->SetPoint( 5, 0, 0, 0 );
-  points->SetPoint( 6, 0, 0, 0 );
-  points->SetPoint( 7, 0, 0, 0 );
-  this->m_Cursor->Modified( );
-  this->m_CursorMapper->Modified( );
-  this->m_CursorActor->Modified( );
+  if( this->m_ImageMapper.GetPointer( ) != NULL )
+  {
+    double bounds[ 6 ];
+    this->m_ImageMapper->GetInput( )->GetBounds( bounds );
+    double pos[] =
+      {
+        this->m_VisibleBounds[ 0 ],
+        this->m_VisibleBounds[ 2 ],
+        this->m_VisibleBounds[ 4 ]
+      };
+    this->SetCursor( pos );
+  }
+  else
+  {
+    vtkPoints* points = this->m_Cursor->GetPoints( );
+    points->SetPoint( 0, 0, 0, 0 );
+    points->SetPoint( 1, 0, 0, 0 );
+    points->SetPoint( 2, 0, 0, 0 );
+    points->SetPoint( 3, 0, 0, 0 );
+    points->SetPoint( 4, 0, 0, 0 );
+    points->SetPoint( 5, 0, 0, 0 );
+    points->SetPoint( 6, 0, 0, 0 );
+    points->SetPoint( 7, 0, 0, 0 );
+    this->m_Cursor->Modified( );
+    this->m_CursorMapper->Modified( );
+    this->m_CursorActor->Modified( );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
 SetCursor( double pos[ 3 ] )
 {
-  if( this->m_SliceMappers.size( ) == 0 )
+  if( this->m_ImageMapper.GetPointer( ) == NULL )
     return;
 
   // Get ordered axes
@@ -485,9 +571,8 @@ SetCursor( double pos[ 3 ] )
   int ma1 = a1 << 1;
   int ma2 = a2 << 1;
 
-  double bounds[ 6 ];
-  this->m_SliceMappers[ 0 ]->GetInput( )->GetBounds( bounds );
-
+  // Update cross
+  double* bounds = this->m_VisibleBounds;
   double
     p0[ 3 ], p1[ 3 ], p2[ 3 ], p3[ 3 ],
     p4[ 3 ], p5[ 3 ], p6[ 3 ], p7[ 3 ];
@@ -516,45 +601,51 @@ SetCursor( double pos[ 3 ] )
 }
 
 // -------------------------------------------------------------------------
-vtkImageMapToColors* cpExtensions::Visualization::ImageSliceActors::
-GetImageMap( unsigned int id )
+double cpExtensions::Visualization::ImageSliceActors::
+GetMinWindow( ) const
 {
-  if( id < this->m_ImageMaps.size( ) )
-    return( this->m_ImageMaps[ id ].GetPointer( ) );
+  if( this->m_ImageBlender.GetPointer( ) != NULL )
+    return( this->m_ImageBlender->GetMinWindow( ) );
   else
-    return( NULL );
+    return( double( 0 ) );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::ImageSliceActors::
+GetMaxWindow( ) const
+{
+  if( this->m_ImageBlender.GetPointer( ) != NULL )
+    return( this->m_ImageBlender->GetMaxWindow( ) );
+  else
+    return( double( 0 ) );
 }
 
 // -------------------------------------------------------------------------
-const vtkImageMapToColors* cpExtensions::Visualization::ImageSliceActors::
-GetImageMap( unsigned int id ) const
+double cpExtensions::Visualization::ImageSliceActors::
+GetMinLevel( ) const
 {
-  if( id < this->m_ImageMaps.size( ) )
-    return( this->m_ImageMaps[ id ].GetPointer( ) );
+  if( this->m_ImageBlender.GetPointer( ) != NULL )
+    return( this->m_ImageBlender->GetMinLevel( ) );
   else
-    return( NULL );
+    return( double( 0 ) );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::ImageSliceActors::
+GetMaxLevel( ) const
+{
+  if( this->m_ImageBlender.GetPointer( ) != NULL )
+    return( this->m_ImageBlender->GetMaxLevel( ) );
+  else
+    return( double( 0 ) );
 }
 
 // -------------------------------------------------------------------------
 double cpExtensions::Visualization::ImageSliceActors::
 GetWindow( ) const
 {
-  if( this->m_ImageMaps.size( ) > 0 )
-  {
-    if( this->m_ImageMaps[ 0 ].GetPointer( ) != NULL )
-    {
-      vtkWindowLevelLookupTable* lut =
-        dynamic_cast< vtkWindowLevelLookupTable* >(
-          this->m_ImageMaps[ 0 ]->GetLookupTable( )
-          );
-      if( lut != NULL )
-        return( lut->GetWindow( ) );
-      else
-        return( double( 0 ) );
-    }
-    else
-      return( double( 0 ) );
-  }
+  if( this->m_ImageBlender.GetPointer( ) != NULL )
+    return( this->m_ImageBlender->GetWindow( ) );
   else
     return( double( 0 ) );
 }
@@ -563,22 +654,8 @@ GetWindow( ) const
 double cpExtensions::Visualization::ImageSliceActors::
 GetLevel( ) const
 {
-  if( this->m_ImageMaps.size( ) > 0 )
-  {
-    if( this->m_ImageMaps[ 0 ].GetPointer( ) != NULL )
-    {
-      vtkWindowLevelLookupTable* lut =
-        dynamic_cast< vtkWindowLevelLookupTable* >(
-          this->m_ImageMaps[ 0 ]->GetLookupTable( )
-          );
-      if( lut != NULL )
-        return( lut->GetLevel( ) );
-      else
-        return( double( 0 ) );
-    }
-    else
-      return( double( 0 ) );
-  }
+  if( this->m_ImageBlender.GetPointer( ) != NULL )
+    return( this->m_ImageBlender->GetLevel( ) );
   else
     return( double( 0 ) );
 }
@@ -587,30 +664,10 @@ GetLevel( ) const
 void cpExtensions::Visualization::ImageSliceActors::
 SetWindow( double w )
 {
-  if( this->m_ImageMaps.size( ) > 0 )
+  if( this->m_ImageBlender.GetPointer( ) != NULL )
   {
-    if( this->m_ImageMaps[ 0 ].GetPointer( ) != NULL )
-    {
-      vtkWindowLevelLookupTable* lut =
-        dynamic_cast< vtkWindowLevelLookupTable* >(
-          this->m_ImageMaps[ 0 ]->GetLookupTable( )
-          );
-      if( lut != NULL )
-      {
-        /* TODO: Min and Max values are assigned 0!!!
-           if( w < this->MinWindow )
-           w = this->MinWindow;
-           if( w > this->MaxWindow )
-           w = this->MaxWindow;
-        */
-        lut->SetWindow( w );
-        lut->Build( );
-        this->m_ImageMaps[ 0 ]->Modified( );
-        this->Modified( );
-
-      } // fi
-
-    } // fi
+    this->m_ImageBlender->SetWindow( w );
+    this->Modified( );
 
   } // fi
 }
@@ -619,30 +676,10 @@ SetWindow( double w )
 void cpExtensions::Visualization::ImageSliceActors::
 SetLevel( double l )
 {
-  if( this->m_ImageMaps.size( ) > 0 )
+  if( this->m_ImageBlender.GetPointer( ) != NULL )
   {
-    if( this->m_ImageMaps[ 0 ].GetPointer( ) != NULL )
-    {
-      vtkWindowLevelLookupTable* lut =
-        dynamic_cast< vtkWindowLevelLookupTable* >(
-          this->m_ImageMaps[ 0 ]->GetLookupTable( )
-          );
-      if( lut != NULL )
-      {
-        /* TODO: Min and Max values are assigned 0!!!
-           if( l < this->MinLevel )
-           l = this->MinLevel;
-           if( l > this->MaxLevel )
-           l = this->MaxLevel;
-        */
-        lut->SetLevel( l );
-        lut->Build( );
-        this->m_ImageMaps[ 0 ]->Modified( );
-        this->Modified( );
-
-      } // fi
-
-    } // fi
+    this->m_ImageBlender->SetLevel( l );
+    this->Modified( );
 
   } // fi
 }
@@ -651,39 +688,11 @@ SetLevel( double l )
 void cpExtensions::Visualization::ImageSliceActors::
 SetWindowLevel( double w, double l )
 {
-  if( this->m_ImageMaps.size( ) > 0 )
+  if( this->m_ImageBlender.GetPointer( ) != NULL )
   {
-    if( this->m_ImageMaps[ 0 ].GetPointer( ) != NULL )
-    {
-      vtkWindowLevelLookupTable* lut =
-        dynamic_cast< vtkWindowLevelLookupTable* >(
-          this->m_ImageMaps[ 0 ]->GetLookupTable( )
-          );
-      if( lut != NULL )
-      {
-        /* TODO: Min and Max values are assigned 0!!!
-           std::cout << this->MinWindow << " " << this->MaxWindow << std::endl;
-           std::cout << this->MinLevel << " " << this->MaxLevel << std::endl;
-           std::cout << w << " " << l << " <-> " << std::ends;
-           if( w < this->MinWindow )
-           w = this->MinWindow;
-           if( w > this->MaxWindow )
-           w = this->MaxWindow;
-           if( l < this->MinLevel )
-           l = this->MinLevel;
-           if( l > this->MaxLevel )
-           l = this->MaxLevel;
-           std::cout << w << " " << l << std::endl;
-        */
-        lut->SetWindow( w );
-        lut->SetLevel( l );
-        lut->Build( );
-        this->m_ImageMaps[ 0 ]->Modified( );
-        this->Modified( );
-
-      } // fi
-
-    } // fi
+    this->m_ImageBlender->SetWindowLevel( w, l );
+    this->UpdateText( w, l );
+    this->Modified( );
 
   } // fi
 }
@@ -692,91 +701,16 @@ SetWindowLevel( double w, double l )
 void cpExtensions::Visualization::ImageSliceActors::
 ResetWindowLevel( )
 {
-  this->SetWindowLevel(
-    this->MaxWindow,
-    ( this->MaxLevel + this->MinLevel ) / double( 2 )
-    );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-SetLookupTable( unsigned int id, vtkLookupTable* lut )
-{
-  if( id < this->m_ImageMaps.size( ) && id > 0 )
-  {
-    if( this->m_ImageMaps[ id ].GetPointer( ) != NULL )
-    {
-      this->m_ImageMaps[ id ]->SetLookupTable( lut );
-      this->m_ImageMaps[ id ]->Modified( );
-      this->Modified( );
-
-    } // fi
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-SetLookupTableAsColor( unsigned int id, double r, double g, double b )
-{
-  static const double _0 = double( 0 );
-  static const double _2 = double( 2 );
-  static const double _4 = double( 4 );
-  static const double _6 = double( 6 );
-  static const double _OPACITY = double( 0.6 );
-
-  // Check ID consistency
-  if( id == 0 || id >= this->m_ImageMaps.size( ) )
-    return;
-
-  // Get image scalar range
-  vtkAlgorithmOutput* aout = this->m_ImageMaps[ id ]->GetOutputPort( );
-  vtkImageData* image = dynamic_cast< vtkImageData* >(
-    aout->GetProducer( )->GetOutputDataObject( aout->GetIndex( ) )
-    );
-  double range[ 2 ];
-  image->GetScalarRange( range );
-
-  // Get HSV from display color
-  double cmax = ( r > g )? r: g; cmax = ( b > cmax )? b: cmax;
-  double cmin = ( r < g )? r: g; cmin = ( b < cmin )? b: cmin;
-  double d = cmax - cmin;
-
-  double saturation = ( std::fabs( cmax ) > _0 )? d / cmax: _0;
-  double value = cmax;
-  double hue = _0;
-  if( d > _0 )
-  {
-    if( r == cmax )
-      hue = std::fmod( ( g - b ) / d, _6 );
-    else if( g == cmax )
-      hue = ( ( b - r ) / d ) + _2;
-    else if( b == cmax )
-      hue = ( ( r - g ) / d ) + _4;
-    hue /= _6;
-
-  } // fi
-
-  // Define new lookup table
-  vtkSmartPointer< vtkLookupTable > lut =
-    vtkSmartPointer< vtkLookupTable >::New( );
-  lut->SetScaleToLinear( );
-  lut->SetNanColor( _0, _0, _0, _0 );
-  lut->SetTableRange( range[ 0 ], range[ 1 ] );
-  lut->SetAlphaRange( _0, _OPACITY );
-  lut->SetHueRange( _0, hue );
-  lut->SetSaturationRange( _0, saturation );
-  lut->SetValueRange( _0, value );
-  lut->Build( );
-  this->SetLookupTable( id, lut );
+  std::cerr << "ACA Resetear" << std::endl;
+  std::exit( 1 );
 }
 
 // -------------------------------------------------------------------------
 int cpExtensions::Visualization::ImageSliceActors::
 GetAxis( ) const
 {
-  if( this->m_SliceMappers.size( ) > 0 )
-    return( this->m_SliceMappers[ 0 ]->GetOrientation( ) );
+  if( this->m_ImageMapper.GetPointer( ) != NULL )
+    return( this->m_ImageMapper->GetOrientation( ) );
   else
     return( -1 );
 }
@@ -785,8 +719,8 @@ GetAxis( ) const
 int cpExtensions::Visualization::ImageSliceActors::
 GetSliceNumber( ) const
 {
-  if( this->m_SliceMappers.size( ) > 0 )
-    return( this->m_SliceMappers[ 0 ]->GetSliceNumber( ) );
+  if( this->m_ImageMapper.GetPointer( ) != NULL )
+    return( this->m_ImageMapper->GetSliceNumber( ) );
   else
     return( -1 );
 }
@@ -795,8 +729,8 @@ GetSliceNumber( ) const
 int cpExtensions::Visualization::ImageSliceActors::
 GetSliceNumberMinValue( ) const
 {
-  if( this->m_SliceMappers.size( ) > 0 )
-    return( this->m_SliceMappers[ 0 ]->GetSliceNumberMinValue( ) );
+  if( this->m_ImageMapper.GetPointer( ) != NULL )
+    return( this->m_ImageMapper->GetSliceNumberMinValue( ) );
   else
     return( -1 );
 }
@@ -805,8 +739,8 @@ GetSliceNumberMinValue( ) const
 int cpExtensions::Visualization::ImageSliceActors::
 GetSliceNumberMaxValue( ) const
 {
-  if( this->m_SliceMappers.size( ) > 0 )
-    return( this->m_SliceMappers[ 0 ]->GetSliceNumberMaxValue( ) );
+  if( this->m_ImageMapper.GetPointer( ) != NULL )
+    return( this->m_ImageMapper->GetSliceNumberMaxValue( ) );
   else
     return( -1 );
 }
@@ -815,153 +749,124 @@ GetSliceNumberMaxValue( ) const
 void cpExtensions::Visualization::ImageSliceActors::
 SetSliceNumber( const int& slice )
 {
-  unsigned int nImages = this->m_SliceMappers.size( );
-  if( nImages == 0 )
+  if( this->m_ImageMapper.GetPointer( ) == NULL )
     return;
 
-  // Change visualization extent
-  for( unsigned int i = 0; i < nImages; ++i )
-  {
-    this->m_SliceMappers[ i ]->SetSliceNumber( slice );
-    this->m_SliceMappers[ i ]->Modified( );
-    this->m_ImageActors[ i ]->Modified( );
-    this->m_SliceMappers[ i ]->Update( );
-
-  } // rof
-
-  // Compute plane
-  vtkAlgorithm* algo = this->m_SliceMappers[ 0 ]->GetInputAlgorithm( );
-  vtkInformation* info = algo->GetOutputInformation( 0 );
-  int ext[ 6 ];
-  double ori[ 3 ], spac[ 3 ], pos[ 3 ];
-  info->Get( vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT( ), ext );
-  info->Get( vtkDataObject::ORIGIN( ), ori );
-  info->Get( vtkDataObject::SPACING( ), spac );
-  this->m_SliceMappers[ 0 ]->GetSlicePlane( )->GetOrigin( pos );
-
-  // Prevent obscuring voxels by offsetting the plane geometry
-  double xbnds[ ] =
-    {
-      ori[ 0 ] + ( spac[ 0 ] * double( ext[ 0 ] ) ),
-      ori[ 0 ] + ( spac[ 0 ] * double( ext[ 1 ] ) )
-    };
-  double ybnds[ ] =
-    {
-      ori[ 1 ] + ( spac[ 1 ] * double( ext[ 2 ] ) ),
-      ori[ 1 ] + ( spac[ 1 ] * double( ext[ 3 ] ) )
-    };
-  double zbnds[ ] =
-    {
-      ori[ 2 ] + ( spac[ 2 ] * double( ext[ 4 ] ) ),
-      ori[ 2 ] + ( spac[ 2 ] * double( ext[ 5 ] ) )
-    };
+  int axis = this->GetAxis( );
+  double prev_pos = this->m_VisibleBounds[ axis << 1 ];
 
-  if( spac[ 0 ] < double( 0 ) )
-  {
-    double t = xbnds[ 0 ];
-    xbnds[ 0 ] = xbnds[ 1 ];
-    xbnds[ 1 ] = t;
+  // Update mappers and display bounds
+  this->m_ImageMapper->SetSliceNumber( slice );
+  this->m_ImageMapper->Modified( );
+  this->m_ImageActor->Modified( );
+  this->m_ImageMapper->Update( );
 
-  } // fi
-  if( spac[ 1 ] < double( 0 ) )
-  {
-    double t = ybnds[ 0 ];
-    ybnds[ 0 ] = ybnds[ 1 ];
-    ybnds[ 1 ] = t;
+  // Update display extent (this isn't done automatically)
+  this->m_ImageMapper->GetInput( )->GetExtent( this->m_VisibleExtent );
+  this->m_VisibleExtent[ axis << 1 ] = slice;
+  this->m_VisibleExtent[ ( axis << 1 ) + 1 ] = slice;
+  this->m_ImageActor->SetDisplayExtent( this->m_VisibleExtent );
 
-  } // fi
-  if( spac[ 2 ] < double( 0 ) )
-  {
-    double t = zbnds[ 0 ];
-    zbnds[ 0 ] = zbnds[ 1 ];
-    zbnds[ 1 ] = t;
+  // Prepare plane data
+  this->m_ImageMapper->GetBounds( this->m_VisibleBounds );
+  double x0[][ 3 ] =
+    {
+      {
+        this->m_VisibleBounds[ 0 ],
+        this->m_VisibleBounds[ 2 ],
+        this->m_VisibleBounds[ 4 ]
+      },
+      {
+        this->m_VisibleBounds[ 1 ],
+        this->m_VisibleBounds[ 3 ],
+        this->m_VisibleBounds[ 5 ]
+      }
+    };
+  double p0[ 2 ][ 3 ];
 
-  } // fi
+  vtkPlane* plane = this->m_ImageMapper->GetSlicePlane( );
+  plane->GeneralizedProjectPoint( x0[ 0 ], p0[ 0 ] );
+  plane->GeneralizedProjectPoint( x0[ 1 ], p0[ 1 ] );
 
-  // Plane function origin
-  this->m_PlaneFunction->SetOrigin( pos );
+  this->m_VisibleBounds[ 0 ] = p0[ 0 ][ 0 ];
+  this->m_VisibleBounds[ 1 ] = p0[ 1 ][ 0 ];
+  this->m_VisibleBounds[ 2 ] = p0[ 0 ][ 1 ];
+  this->m_VisibleBounds[ 3 ] = p0[ 1 ][ 1 ];
+  this->m_VisibleBounds[ 4 ] = p0[ 0 ][ 2 ];
+  this->m_VisibleBounds[ 5 ] = p0[ 1 ][ 2 ];
+  double* bnds = this->m_VisibleBounds;
 
   // Configure visualization and implicit plane orientation
-  int axis = this->m_SliceMappers[ 0 ]->GetOrientation( );
   this->m_PlaneActor->GetProperty( )->SetRepresentationToWireframe( );
-  this->m_PlaneActor->GetProperty( )->SetLineWidth( 2 );
+  this->m_PlaneActor->GetProperty( )->SetLineWidth( 3 );
   vtkPoints* plane_points = this->m_Plane->GetPoints( );
-  if( axis == 0 ) // YZ, x-normal
+  plane_points->SetPoint( 0, bnds[ 0 ], bnds[ 2 ], bnds[ 4 ] );
+  plane_points->SetPoint( 2, bnds[ 1 ], bnds[ 3 ], bnds[ 5 ] );
+  if( axis == 0 || axis == 2 ) // YZ, x-normal
   {
-    this->m_PlaneFunction->SetNormal( 1, 0, 0 );
-    plane_points->SetPoint( 0, pos[ 0 ], ybnds[ 0 ], zbnds[ 0 ] );
-    plane_points->SetPoint( 1, pos[ 0 ], ybnds[ 1 ], zbnds[ 0 ] );
-    plane_points->SetPoint( 2, pos[ 0 ], ybnds[ 1 ], zbnds[ 1 ] );
-    plane_points->SetPoint( 3, pos[ 0 ], ybnds[ 0 ], zbnds[ 1 ] );
-    this->m_PlaneActor->GetProperty( )->SetColor( 1, 0, 0 );
+    plane_points->SetPoint( 1, bnds[ 1 ], bnds[ 2 ], bnds[ 5 ] );
+    plane_points->SetPoint( 3, bnds[ 0 ], bnds[ 3 ], bnds[ 4 ] );
+    if( axis == 0 )
+      this->m_PlaneActor->GetProperty( )->SetColor( 1, 0, 0 );
+    else
+      this->m_PlaneActor->GetProperty( )->SetColor( 0, 0, 1 );
   }
   else if( axis == 1 ) // ZX, y-normal
   {
-    this->m_PlaneFunction->SetNormal( 0, 1, 0 );
-    plane_points->SetPoint( 0, xbnds[ 0 ], pos[ 1 ], zbnds[ 0 ] );
-    plane_points->SetPoint( 1, xbnds[ 0 ], pos[ 1 ], zbnds[ 1 ] );
-    plane_points->SetPoint( 2, xbnds[ 1 ], pos[ 1 ], zbnds[ 1 ] );
-    plane_points->SetPoint( 3, xbnds[ 1 ], pos[ 1 ], zbnds[ 0 ] );
+    plane_points->SetPoint( 1, bnds[ 0 ], bnds[ 2 ], bnds[ 5 ] );
+    plane_points->SetPoint( 3, bnds[ 1 ], bnds[ 3 ], bnds[ 4 ] );
     this->m_PlaneActor->GetProperty( )->SetColor( 0, 1, 0 );
-  }
-  else // XY, z-normal
-  {
-    this->m_PlaneFunction->SetNormal( 0, 0, 1 );
-    plane_points->SetPoint( 0, xbnds[ 0 ], ybnds[ 0 ], pos[ 2 ] );
-    plane_points->SetPoint( 1, xbnds[ 1 ], ybnds[ 0 ], pos[ 2 ] );
-    plane_points->SetPoint( 2, xbnds[ 1 ], ybnds[ 1 ], pos[ 2 ] );
-    plane_points->SetPoint( 3, xbnds[ 0 ], ybnds[ 1 ], pos[ 2 ] );
-    this->m_PlaneActor->GetProperty( )->SetColor( 0, 0, 1 );
 
   } // fi
-  this->m_PlaneFunction->Modified( );
   this->m_Plane->Modified( );
   this->m_PlaneMapper->Modified( );
   this->m_PlaneActor->Modified( );
 
-  // Prepare other actors to update
+  // Update text
+  this->UpdateText( );
+
+  // Update lines from associated slices
   /* TODO
-     for( unsigned int i = 0; i < this->OtherActors.size( ); ++i )
+     auto sIt = this->m_AssociatedSlices.begin( );
+     for( ; sIt != this->m_AssociatedSlices.end( ); ++sIt )
      {
-     if( this->OtherActors[ i ].first.GetPointer( ) != NULL )
-     {
-     this->OtherActors[ i ].first->Modified( );
-     this->OtherActors[ i ].first->Update( );
-
-     } // fi
-
-     if( this->OtherActors[ i ].second.GetPointer( ) != NULL )
+     Self* slice = *sIt;
+     for( unsigned int id = 0; id < slice->m_AssociatedSlices.size( ); ++id )
      {
-     this->OtherActors[ i ].second->GetMapper( )->Modified( );
-     this->OtherActors[ i ].second->Modified( );
+     std::cout << id << std::endl;
+     if( slice->m_AssociatedSlices[ id ] != this )
+     continue;
 
-     } // fi
+     std::cout << "id : " << id << std::endl;
 
      } // rof
 
-     if( this->m_UpdateCommand != NULL )
-     this->m_UpdateCommand( this->m_UpdateData );
+     } // rof
   */
 
-  // Update text
-  this->UpdateText( );
-
-  // Associated slices
-  for( unsigned int i = 0; i < this->m_AssociatedSlices.size( ); ++i )
-    if( this->m_AssociatedSlices[ i ]->GetAxis( ) == this->GetAxis( ) )
-      this->m_AssociatedSlices[ i ]->SetSliceNumber( slice );
+  // Update camera position
+  if( this->m_Window == NULL )
+    return;
+  vtkRenderer* renderer =
+    this->m_Window->GetRenderers( )->GetFirstRenderer( );
+  if( renderer == NULL )
+    return;
+  vtkCamera* camera = renderer->GetActiveCamera( );
+  if( camera == NULL )
+    return;
+  double cam_pos[ 3 ];
+  camera->GetPosition( cam_pos );
+  cam_pos[ axis ] += this->m_VisibleBounds[ axis << 1 ] - prev_pos;
+  camera->SetPosition( cam_pos );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
 SetSlice( double* pos )
 {
-  vtkImageData* image;
-  if( this->m_ImageMaps[ 0 ] != NULL )
-    image =
-      dynamic_cast< vtkImageData* >( this->m_ImageMaps[ 0 ]->GetInput( ) );
-  else
-    image = this->m_SliceMappers[ 0 ]->GetInput( );
+  vtkImageData* image = this->GetInputImage( 0 );
+  if( image == NULL )
+    return;
 
   int ijk[ 3 ];
   double pcoords[ 3 ];
@@ -973,17 +878,17 @@ SetSlice( double* pos )
 void cpExtensions::Visualization::ImageSliceActors::
 UpdateText( )
 {
-  if( this->m_SliceMappers.size( ) > 0 )
+  if( this->m_ImageMapper.GetPointer( ) != NULL )
   {
     char axis;
-    int axId = this->m_SliceMappers[ 0 ]->GetOrientation( );
+    int axId = this->m_ImageMapper->GetOrientation( );
     if     ( axId == 0 ) axis = 'X';
     else if( axId == 1 ) axis = 'Y';
     else if( axId == 2 ) axis = 'Z';
 
     std::sprintf(
       this->m_TextBuffer, "Axis: %c (%d)",
-      axis, this->m_SliceMappers[ 0 ]->GetSliceNumber( )
+      axis, this->m_ImageMapper->GetSliceNumber( )
       );
   }
   else
@@ -997,23 +902,16 @@ UpdateText( )
 void cpExtensions::Visualization::ImageSliceActors::
 UpdateText( double pos[ 3 ] )
 {
-  /* TODO
-  if( this->m_SliceMappers.size( ) > 0 )
+  if( this->m_ImageMapper.GetPointer( ) != NULL )
   {
     char axis;
-    int axId = this->m_SliceMappers[ 0 ]->GetOrientation( );
+    int axId = this->m_ImageMapper->GetOrientation( );
     if     ( axId == 0 ) axis = 'X';
     else if( axId == 1 ) axis = 'Y';
     else if( axId == 2 ) axis = 'Z';
     int slice = this->GetSliceNumber( );
 
-    vtkImageData* image;
-    if( this->m_ImageMaps[ 0 ] != NULL )
-      image =
-        dynamic_cast< vtkImageData* >( this->m_ImageMaps[ 0 ]->GetInput( ) );
-    else
-      image = this->m_SliceMappers[ 0 ]->GetInput( );
-
+    vtkImageData* image = this->GetInputImage( 0 );
     int ijk[ 3 ];
     double pcoords[ 3 ];
     image->ComputeStructuredCoordinates( pos, ijk, pcoords );
@@ -1054,24 +952,23 @@ UpdateText( double pos[ 3 ] )
   this->m_TextActor->SetInput( this->m_TextBuffer );
   this->m_TextActor->Modified( );
   this->Modified( );
-  */
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
 UpdateText( const double& w, const double& l )
 {
-  if( this->m_SliceMappers.size( ) > 0 )
+  if( this->m_ImageMapper.GetPointer( ) != NULL )
   {
     char axis;
-    int axId = this->m_SliceMappers[ 0 ]->GetOrientation( );
+    int axId = this->m_ImageMapper->GetOrientation( );
     if     ( axId == 0 ) axis = 'X';
     else if( axId == 1 ) axis = 'Y';
     else if( axId == 2 ) axis = 'Z';
 
     std::sprintf(
       this->m_TextBuffer, "Axis: %c (%d)\nW/L (%.2f/%.2f)",
-      axis, this->m_SliceMappers[ 0 ]->GetSliceNumber( ), w, l
+      axis, this->m_ImageMapper->GetSliceNumber( ), w, l
       );
   }
   else
@@ -1081,15 +978,42 @@ UpdateText( const double& w, const double& l )
   this->Modified( );
 }
 
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+Render( const double& t )
+{
+  if( this->m_Window != NULL )
+  {
+    vtkRenderer* renderer =
+      this->m_Window->GetRenderers( )->GetFirstRenderer( );
+    if( renderer != NULL )
+      renderer->SetAllocatedRenderTime( t );
+    this->m_Window->Render( );
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+ResetCamera( )
+{
+  if( this->m_Window == NULL )
+    return;
+  vtkRenderer* renderer =
+    this->m_Window->GetRenderers( )->GetFirstRenderer( );
+  if( renderer != NULL )
+    renderer->ResetCamera( this->m_VisibleBounds );
+}
+
 // -------------------------------------------------------------------------
 cpExtensions::Visualization::ImageSliceActors::
 ImageSliceActors( )
   : Superclass( ),
-    Interpolate( false )
+    m_Window( NULL ),
+    m_Interpolate( false )
 {
   this->Clear( );
-
-  this->SlicesCommand = NULL;
+  this->_ConfigureStyle( );
 }
 
 // -------------------------------------------------------------------------
@@ -1103,91 +1027,19 @@ void cpExtensions::Visualization::ImageSliceActors::
 _ConfigureStyle( )
 {
   // Connect this view with a controller
-  this->m_Style = vtkSmartPointer< ImageInteractorStyle >::New( );
+  this->m_Style = vtkSmartPointer< TStyle >::New( );
   this->m_Style->AddMouseMoveCommand( Self::_MouseMoveCommand, this );
   this->m_Style->AddMouseClickCommand( Self::_MouseClickCommand, this );
-  this->m_Style->AddMouseDoubleClickCommand(
-    Self::_MouseDoubleClickCommand, this
-    );
   this->m_Style->AddMouseWheelCommand( Self::_MouseWheelCommand, this );
   this->m_Style->AddKeyCommand( Self::_KeyCommand, this );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-_ConfigureNewLUT( vtkImageData* data )
-{
-  // Does the new LUT is a window-level one?
-  unsigned int nImgs = this->m_ImageMaps.size( );
-  unsigned int nCmps = data->GetNumberOfScalarComponents( );
-
-  if( nCmps > 1 )
-  {
-    this->m_ImageMaps.push_back( NULL );
-    return;
-
-  } // fi
-
-  // Create LUT filter
-  this->m_ImageMaps.push_back( vtkSmartPointer< vtkImageMapToColors >::New( ) );
-  if( nImgs == 0 )
-  {
-    double range[ 2 ];
-    data->GetScalarRange( range );
-    vtkSmartPointer< vtkWindowLevelLookupTable > lut =
-      vtkSmartPointer< vtkWindowLevelLookupTable >::New( );
-    lut->SetScaleToLinear( );
-    lut->SetTableRange( range );
-    lut->SetWindow( range[ 1 ] - range[ 0 ] );
-    lut->SetLevel( ( range[ 1 ] + range[ 0 ] ) / double( 2 ) );
-    lut->Build( );
-    this->m_ImageMaps[ 0 ]->SetLookupTable( lut );
-
-    this->MinWindow = double( 0 );
-    this->MaxWindow = range[ 1 ] - range[ 0 ];
-    this->MinLevel = range[ 0 ];
-    this->MaxLevel = range[ 1 ];
-  }
-  else
-    this->SetLookupTableAsColor( nImgs, 1, 0, 0 );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-_ConfigureNewInput( int axis )
-{
-  unsigned int nImages = this->m_ImageActors.size( );
-
-  // Configure mapper
-  vtkImageSliceMapper* mapper = this->m_SliceMappers[ nImages ];
-  if( nImages == 0 )
-    mapper->SetOrientation( axis );
-  else
-    mapper->SetOrientation( this->m_SliceMappers[ 0 ]->GetOrientation( ) );
-  mapper->Update( );
-
-  // Create actor
-  vtkSmartPointer< vtkImageActor > actor =
-    vtkSmartPointer< vtkImageActor >::New( );
-  this->m_ImageActors.push_back( actor );
-  actor->SetMapper( mapper );
-  actor->SetInterpolate( this->Interpolate );
-  actor->Modified( );
-
-  if( nImages == 0 )
-    this->m_Style->AssociateImageActor( actor );
-  this->AddItem( actor );
-
-  if( nImages > 1 )
-    this->SetSliceNumber( this->GetSliceNumber( ) );
-  this->Modified( );
+  this->m_Style->AddEnterCommand( Self::_EnterCommand, this );
+  this->m_Style->AddLeaveCommand( Self::_LeaveCommand, this );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
 _MouseMoveCommand(
-  void* data,
-  const ImageInteractorStyle::ButtonID& btn, double* pos,
+  void* data, const TStyle::ButtonID& btn, int* idx, double* pos,
   bool alt, bool ctr, bool sft
   )
 {
@@ -1195,40 +1047,53 @@ _MouseMoveCommand(
   if( actors == NULL )
     return;
 
-  if( btn == ImageInteractorStyle::ButtonID_None )
+  if( btn == TStyle::ButtonID_None )
   {
+    // Just show the pixel information
+    actors->SetCursor( pos );
     actors->UpdateText( pos );
+    actors->Render( 1e-3 );
   }
-  else if( btn == ImageInteractorStyle::ButtonID_Left )
-  {
-    if( !alt && ctr && !sft && actors->SlicesCommand != NULL )
-      actors->SlicesCommand( pos, actors->GetAxis( ), actors->SlicesData );
-  }
-  else if( btn == ImageInteractorStyle::ButtonID_Middle )
+  else if( btn == TStyle::ButtonID_Left )
   {
+    if( !alt && ctr && !sft )
+    {
+      // Interactively move slices
+      auto i = actors->m_SlicesCommands.begin( );
+      for( ; i != actors->m_SlicesCommands.end( ); ++i )
+        i->first( pos, actors->GetAxis( ), i->second );
+      actors->Render( 1e-3 );
+
+    } // fi
   }
-  else if( btn == ImageInteractorStyle::ButtonID_Right )
+  else if( btn == TStyle::ButtonID_Right )
   {
     if( !alt && !ctr && sft )
     {
+      // Change image window level
       double bounds[ 6 ];
-      actors->m_SliceMappers[ 0 ]->GetBounds( bounds );
+      actors->m_ImageMapper->GetBounds( bounds );
 
       int a0 = actors->GetAxis( );
       int a1 = ( a0 + 1 ) % 3;
       int a2 = ( a0 + 2 ) % 3;
-      double dx = pos[ a1 ] - actors->StartWindowLevelPos[ a1 ];
-      double dy = pos[ a2 ] - actors->StartWindowLevelPos[ a2 ];
+      double dx = pos[ a1 ] - actors->m_StartWindowLevelPos[ a1 ];
+      double dy = pos[ a2 ] - actors->m_StartWindowLevelPos[ a2 ];
       dx /= bounds[ ( a1 << 1 ) + 1 ] - bounds[ a1 << 1 ];
       dy /= bounds[ ( a2 << 1 ) + 1 ] - bounds[ a2 << 1 ];
 
-      dx *= actors->StartWindowLevel[ 0 ];
-      dy *= actors->StartWindowLevel[ 1 ];
-      actors->SetWindowLevel(
-        actors->StartWindowLevel[ 0 ] + dx,
-        actors->StartWindowLevel[ 1 ] + dy
-        );
-
+      dx *= actors->m_StartWindowLevel[ 0 ];
+      dy *= actors->m_StartWindowLevel[ 1 ];
+      dx += actors->m_StartWindowLevel[ 0 ];
+      dy += actors->m_StartWindowLevel[ 1 ];
+      actors->SetWindowLevel( dx, dy );
+      actors->Render( 1e-3 );
+
+      // Associate objects
+      auto i = actors->m_WindowLevelCommands.begin( );
+      for( ; i != actors->m_WindowLevelCommands.end( ); ++i )
+        i->first( dx, dy, i->second );
+      
     } // fi
 
   } // fi
@@ -1237,8 +1102,7 @@ _MouseMoveCommand(
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
 _MouseClickCommand(
-  void* data,
-  const ImageInteractorStyle::ButtonID& btn, double* pos,
+  void* data, const TStyle::ButtonID& btn, int* idx, double* pos,
   bool alt, bool ctr, bool sft
   )
 {
@@ -1246,18 +1110,17 @@ _MouseClickCommand(
   if( actors == NULL )
     return;
 
-  actors->StartWindowLevelPos[ 0 ] = pos[ 0 ];
-  actors->StartWindowLevelPos[ 1 ] = pos[ 1 ];
-  actors->StartWindowLevelPos[ 2 ] = pos[ 2 ];
-  actors->StartWindowLevel[ 0 ] = actors->GetWindow( );
-  actors->StartWindowLevel[ 1 ] = actors->GetLevel( );
+  actors->m_StartWindowLevelPos[ 0 ] = pos[ 0 ];
+  actors->m_StartWindowLevelPos[ 1 ] = pos[ 1 ];
+  actors->m_StartWindowLevelPos[ 2 ] = pos[ 2 ];
+  actors->m_StartWindowLevel[ 0 ] = actors->GetWindow( );
+  actors->m_StartWindowLevel[ 1 ] = actors->GetLevel( );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-_MouseDoubleClickCommand(
-  void* data,
-  const ImageInteractorStyle::ButtonID& btn, double* pos,
+_MouseWheelCommand(
+  void* data, const int& dir,
   bool alt, bool ctr, bool sft
   )
 {
@@ -1265,59 +1128,93 @@ _MouseDoubleClickCommand(
   if( actors == NULL )
     return;
 
-  if( btn == ImageInteractorStyle::ButtonID_Left )
+  if( !alt && !ctr )
   {
-    if( !alt && !ctr && !sft )
-      actors->SetCursor( pos );
-    else if( !alt && ctr && !sft && actors->SlicesCommand != NULL )
+    int slice = actors->GetSliceNumber( ) + ( dir * ( ( sft )? 10: 1 ) );
+    if( slice < actors->GetSliceNumberMinValue( ) )
+      slice = actors->GetSliceNumberMinValue( );
+    if( slice > actors->GetSliceNumberMaxValue( ) )
+      slice = actors->GetSliceNumberMaxValue( );
+    actors->SetSliceNumber( slice );
+
+    auto a = actors->m_AssociatedSlices.begin( );
+    for( ; a != actors->m_AssociatedSlices.end( ); ++a )
     {
-      actors->SlicesCommand( pos, actors->GetAxis( ), actors->SlicesData );
-      for( unsigned int i = 0; i < actors->m_CursorCommands.size( ); ++i )
-        actors->m_CursorCommands[ i ].first(
-          pos,
-          actors->GetAxis( ),
-          actors->m_CursorCommands[ i ].second
-          );
+      ( *a )->SetSliceNumber( slice );
+      ( *a )->Render( 1e-3 );
+
+    } // rof
+    actors->Render( 1e-3 );
+    
+    // Associate objects
+    auto i = actors->m_RenderCommands.begin( );
+    for( ; i != actors->m_RenderCommands.end( ); ++i )
+      i->first( i->second );
 
-    } // fi
-  }
-  else if( btn == ImageInteractorStyle::ButtonID_Middle )
-  {
-  }
-  else if( btn == ImageInteractorStyle::ButtonID_Right )
-  {
   } // fi
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-_MouseWheelCommand(
-  void* data,
-  const int& dir, bool alt, bool ctr, bool sft
-  )
+_KeyCommand( void* data, const char& key )
 {
   ImageSliceActors* actors = reinterpret_cast< ImageSliceActors* >( data );
   if( actors == NULL )
     return;
 
-  if( !alt && !ctr && !sft )
+  switch( key )
   {
-    actors->SetSliceNumber( actors->GetSliceNumber( ) + dir );
+  case 'r': case 'R':
+  {
+    actors->ResetCamera( );
+    actors->Render( 1e-3 );
+
+    // Associate objects
+    auto i = actors->m_RenderCommands.begin( );
+    for( ; i != actors->m_RenderCommands.end( ); ++i )
+      i->first( i->second );
   }
-  else if( !alt && !ctr && sft )
+  break;
+  case 'w': case 'W':
   {
-    actors->SetSliceNumber( actors->GetSliceNumber( ) + ( dir * 10 ) );
+    actors->ResetWindowLevel( );
+    actors->Render( 1e-3 );
 
-  } // fi
+    // Associate objects
+    auto i = actors->m_RenderCommands.begin( );
+    for( ; i != actors->m_RenderCommands.end( ); ++i )
+      i->first( i->second );
+  }
+  break;
+  default:
+    break;
+  } // hctiws
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-_KeyCommand(
-  void* data,
-  const char& key
-  )
+_EnterCommand( void* data )
+{
+  ImageSliceActors* actors = reinterpret_cast< ImageSliceActors* >( data );
+  if( actors == NULL )
+    return;
+
+  actors->ResetCursor( );
+  actors->m_CursorActor->VisibilityOn( );
+  actors->Render( 1e-3 );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+_LeaveCommand( void* data )
 {
+  ImageSliceActors* actors = reinterpret_cast< ImageSliceActors* >( data );
+  if( actors == NULL )
+    return;
+
+  actors->ResetCursor( );
+  actors->m_CursorActor->VisibilityOff( );
+  actors->Render( 1e-3 );
 }
 
 // eof - $RCSfile$