]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/Visualization/ImageSliceActors.cxx
...
[cpPlugins.git] / lib / cpExtensions / Visualization / ImageSliceActors.cxx
index c1f85232105c4dc0bb9c64901adfaa86e75f9d48..024fbe09c9bc94051ac6652bc19092f7de7a2424 100644 (file)
 #include <vtkRenderWindowInteractor.h>
 #include <vtkTextProperty.h>
 
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::ImageSliceActors::
+m_PlaneColors[ 3 ][ 3 ] =
+{
+  { 1, 0, 0 },
+  { 0, 1, 0 },
+  { 0, 0, 1 }
+};
+
 // -------------------------------------------------------------------------
 cpExtensions::Visualization::ImageSliceActors*
 cpExtensions::Visualization::ImageSliceActors::
@@ -36,7 +45,6 @@ SetAxis( int axis )
   this->m_ImageActor->Modified( );
   this->m_BlenderActor->Modified( );
   this->Modified( );
-  this->ResetCamera( );
 }
 
 // -------------------------------------------------------------------------
@@ -72,6 +80,11 @@ AddBinaryConnection(
   const double& r, const double& g, const double& b
   )
 {
+  if( aout == NULL )
+    return( -1 );
+  this->m_Blender->AddInputConnection( aout );
+  this->_ConfigureBinaryImage( r, g, b );
+  return( this->m_Blender->GetNumberOfInputs( ) - 1 );
 }
 
 // -------------------------------------------------------------------------
@@ -83,20 +96,9 @@ AddBinaryImage(
 {
   if( data == NULL )
     return( -1 );
-
   this->m_Blender->AddInputData( data );
-
-  unsigned int nValues = this->m_BlenderLUT->GetNumberOfTableValues( );
-  this->m_BlenderLUT->SetNumberOfTableValues( nValues + 1 );
-  this->m_BlenderLUT->SetTableValue( nValues, r, g, b, 0.5 );
-  this->m_BlenderLUT->Build( );
-
-  this->m_BlenderLUT->Modified( );
-  this->m_Blender->Modified( );
-  this->m_Blender->Update( );
-
-  this->m_BlenderMapper->Modified( );
-  this->m_BlenderActor->Modified( );
+  this->_ConfigureBinaryImage( r, g, b );
+  return( this->m_Blender->GetNumberOfInputs( ) - 1 );
 }
 
 // -------------------------------------------------------------------------
@@ -119,6 +121,7 @@ Clear( )
     SetInputConnection( this->m_Blender->GetOutputPort( ) );
 
   this->m_BlenderLUT->SetNumberOfTableValues( 1 );
+  this->m_BlenderLUT->SetTableRange( 0, 1 );
   this->m_BlenderLUT->SetTableValue( 0, 0, 0, 0, 0 );
   this->m_BlenderLUT->Build( );
 
@@ -126,11 +129,7 @@ Clear( )
   this->m_BlenderActor->GetProperty( )->SetLookupTable( this->m_BlenderLUT );
   this->m_BlenderActor->GetProperty( )->UseLookupTableScalarRangeOn( );
 
-  // Remove associated objects
-  this->m_AssociatedSlices.clear( );
-
   // White cursor
-  /*
   vtkSmartPointer< vtkPoints > cursor_points =
     vtkSmartPointer< vtkPoints >::New( );
   vtkSmartPointer< vtkCellArray > cursor_lines =
@@ -139,22 +138,12 @@ Clear( )
   cursor_points->InsertNextPoint( 0, 0, 0 );
   cursor_points->InsertNextPoint( 0, 0, 0 );
   cursor_points->InsertNextPoint( 0, 0, 0 );
-  cursor_points->InsertNextPoint( 0, 0, 0 );
-  cursor_points->InsertNextPoint( 0, 0, 0 );
-  cursor_points->InsertNextPoint( 0, 0, 0 );
-  cursor_points->InsertNextPoint( 0, 0, 0 );
   cursor_lines->InsertNextCell( 2 );
   cursor_lines->InsertCellPoint( 0 );
   cursor_lines->InsertCellPoint( 1 );
   cursor_lines->InsertNextCell( 2 );
   cursor_lines->InsertCellPoint( 2 );
   cursor_lines->InsertCellPoint( 3 );
-  cursor_lines->InsertNextCell( 2 );
-  cursor_lines->InsertCellPoint( 4 );
-  cursor_lines->InsertCellPoint( 5 );
-  cursor_lines->InsertNextCell( 2 );
-  cursor_lines->InsertCellPoint( 6 );
-  cursor_lines->InsertCellPoint( 7 );
 
   this->m_Cursor = vtkSmartPointer< vtkPolyData >::New( );
   this->m_CursorMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
@@ -164,96 +153,13 @@ Clear( )
   this->m_Cursor->SetLines( cursor_lines );
   this->m_CursorMapper->SetInputData( this->m_Cursor );
   this->m_CursorActor->SetMapper( this->m_CursorMapper );
-  */
-
-  /*
-    vtkSmartPointer< vtkPolyDataMapper > m_CursorMapper;
-    vtkSmartPointer< vtkActor >          m_CursorActor;
-
-    vtkSmartPointer< vtkPolyData >       m_HorizontalLine;
-    vtkSmartPointer< vtkPolyDataMapper > m_HorizontalLineMapper;
-    vtkSmartPointer< vtkActor >          m_HorizontalLineActor;
-
-    vtkSmartPointer< vtkPolyData >       m_VerticalLine;
-    vtkSmartPointer< vtkPolyDataMapper > m_VerticalLineMapper;
-    vtkSmartPointer< vtkActor >          m_VerticalLineActor;
-
-    vtkSmartPointer< vtkPolyData >       m_Plane;
-    vtkSmartPointer< vtkPolyDataMapper > m_PlaneMapper;
-    vtkSmartPointer< vtkActor >          m_PlaneActor;
-
-    char                                 m_TextBuffer[ 1024 ];
-    vtkSmartPointer< vtkTextActor >      m_TextActor;
-  */
-
-
-
-
-
-  /*
-  // 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 );
-
-  // Delete all images
-  this->m_ImageActor  = NULL;
-  this->m_ImageMapper = NULL;
-
-  // Reconfigure unique objects
-  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';
+  this->m_CursorActor->GetProperty( )->SetColor( 1, 1, 0 );
+  this->m_CursorActor->GetProperty( )->SetLineWidth( 2 );
 
-  // Unique objects configuration
-  vtkSmartPointer< vtkPoints > cursor_points =
-    vtkSmartPointer< vtkPoints >::New( );
-  vtkSmartPointer< vtkCellArray > cursor_lines =
-    vtkSmartPointer< vtkCellArray >::New( );
-  cursor_points->InsertNextPoint( 0, 0, 0 );
-  cursor_points->InsertNextPoint( 0, 0, 0 );
-  cursor_points->InsertNextPoint( 0, 0, 0 );
-  cursor_points->InsertNextPoint( 0, 0, 0 );
-  cursor_points->InsertNextPoint( 0, 0, 0 );
-  cursor_points->InsertNextPoint( 0, 0, 0 );
-  cursor_points->InsertNextPoint( 0, 0, 0 );
-  cursor_points->InsertNextPoint( 0, 0, 0 );
-  cursor_lines->InsertNextCell( 2 );
-  cursor_lines->InsertCellPoint( 0 );
-  cursor_lines->InsertCellPoint( 1 );
-  cursor_lines->InsertNextCell( 2 );
-  cursor_lines->InsertCellPoint( 2 );
-  cursor_lines->InsertCellPoint( 3 );
-  cursor_lines->InsertNextCell( 2 );
-  cursor_lines->InsertCellPoint( 4 );
-  cursor_lines->InsertCellPoint( 5 );
-  cursor_lines->InsertNextCell( 2 );
-  cursor_lines->InsertCellPoint( 6 );
-  cursor_lines->InsertCellPoint( 7 );
-  this->m_Cursor->SetPoints( cursor_points );
-  this->m_Cursor->SetLines( cursor_lines );
-  this->m_CursorMapper->SetInputData( this->m_Cursor );
-  this->m_CursorActor->SetMapper( this->m_CursorMapper );
+  // Plane intersections
+  this->m_Axis1       = vtkSmartPointer< vtkPolyData >::New( );
+  this->m_Axis1Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
+  this->m_Axis1Actor  = vtkSmartPointer< vtkActor >::New( );
 
   vtkSmartPointer< vtkPoints > h_points =
     vtkSmartPointer< vtkPoints >::New( );
@@ -264,10 +170,14 @@ Clear( )
   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 );
+  this->m_Axis1->SetPoints( h_points );
+  this->m_Axis1->SetLines( h_lines );
+  this->m_Axis1Mapper->SetInputData( this->m_Axis1 );
+  this->m_Axis1Actor->SetMapper( this->m_Axis1Mapper );
+
+  this->m_Axis2       = vtkSmartPointer< vtkPolyData >::New( );
+  this->m_Axis2Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
+  this->m_Axis2Actor  = vtkSmartPointer< vtkActor >::New( );
 
   vtkSmartPointer< vtkPoints > v_points =
     vtkSmartPointer< vtkPoints >::New( );
@@ -278,16 +188,20 @@ Clear( )
   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 );
+  this->m_Axis2->SetPoints( v_points );
+  this->m_Axis2->SetLines( v_lines );
+  this->m_Axis2Mapper->SetInputData( this->m_Axis2 );
+  this->m_Axis2Actor->SetMapper( this->m_Axis2Mapper );
+
+  // Plane
+  this->m_Plane       = vtkSmartPointer< vtkPolyData >::New( );
+  this->m_PlaneMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
+  this->m_PlaneActor  = vtkSmartPointer< vtkActor >::New( );
 
   vtkSmartPointer< vtkPoints > plane_points =
     vtkSmartPointer< vtkPoints >::New( );
   vtkSmartPointer< vtkCellArray > plane_lines =
     vtkSmartPointer< vtkCellArray >::New( );
-
   plane_points->InsertNextPoint( 0, 0, 0 );
   plane_points->InsertNextPoint( 0, 1, 0 );
   plane_points->InsertNextPoint( 1, 1, 0 );
@@ -304,9 +218,12 @@ Clear( )
   this->m_PlaneMapper->SetInputData( this->m_Plane );
   this->m_PlaneActor->SetMapper( this->m_PlaneMapper );
 
+  // Text actor
+  this->m_TextActor = vtkSmartPointer< vtkTextActor >::New( );
+  this->m_TextBuffer[ 0 ] = '\0';
   this->m_TextActor->SetTextScaleModeToNone( );
   vtkTextProperty* textprop = this->m_TextActor->GetTextProperty( );
-  textprop->SetColor( 1, 1, 1 );
+  textprop->SetColor( 1, 1, 0 );
   textprop->SetFontFamilyToCourier( );
   textprop->SetFontSize( 18 );
   textprop->BoldOff( );
@@ -317,14 +234,6 @@ Clear( )
   vtkCoordinate* coord = this->m_TextActor->GetPositionCoordinate( );
   coord->SetCoordinateSystemToNormalizedViewport( );
   coord->SetValue( 0.01, 0.01 );
-
-  // 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 );
-  */
 }
 
 // -------------------------------------------------------------------------
@@ -390,13 +299,11 @@ PushActorsInto( vtkRenderWindow* window, bool force_style )
   renderer->AddViewProp( this->m_BlenderActor );
   if( force_style )
   {
-    /* TODO
-       renderer->AddViewProp( this->m_CursorActor );
-       renderer->AddViewProp( this->m_HorizontalLineActor );
-       renderer->AddViewProp( this->m_VerticalLineActor );
-       renderer->AddViewProp( this->m_PlaneActor );
-       renderer->AddViewProp( this->m_TextActor );
-    */
+    renderer->AddViewProp( this->m_CursorActor );
+    renderer->AddViewProp( this->m_PlaneActor );
+    renderer->AddViewProp( this->m_TextActor );
+    renderer->AddViewProp( this->m_Axis1Actor );
+    renderer->AddViewProp( this->m_Axis2Actor );
 
   } // fi
 
@@ -420,37 +327,39 @@ PushActorsInto( vtkRenderWindow* window, bool force_style )
     }
     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
-  this->ResetCamera( );
-  rwi->Render( );
+  renderer->ResetCamera( );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
 PopActorsFrom( vtkRenderWindow* window )
 {
-  /* TODO
-     vtkRenderWindowInteractor* rwi = window->GetInteractor( );
-     vtkRenderer* renderer = window->GetRenderers( )->GetFirstRenderer( );
+  vtkRenderWindowInteractor* rwi = window->GetInteractor( );
+  vtkRenderer* renderer = window->GetRenderers( )->GetFirstRenderer( );
+  if( renderer != NULL )
+  {
+    renderer->RemoveViewProp( this->m_ImageActor );
+    renderer->RemoveViewProp( this->m_BlenderActor );
+    renderer->RemoveViewProp( this->m_CursorActor );
+    renderer->RemoveViewProp( this->m_PlaneActor );
+    renderer->RemoveViewProp( this->m_TextActor );
+    renderer->RemoveViewProp( this->m_Axis1Actor );
+    renderer->RemoveViewProp( this->m_Axis2Actor );
 
-     if( renderer != NULL )
-     {
-     // Update actors
-     vtkProp* prop;
-     this->InitTraversal( );
-     while( prop = this->GetNextProp( ) )
-     renderer->RemoveViewProp( prop );
-     renderer->Modified( );
+  } // fi
+}
 
-     } // fi
-     if( rwi != NULL )
-     rwi->Render( );
-  */
+// -------------------------------------------------------------------------
+unsigned int cpExtensions::Visualization::ImageSliceActors::
+GetNumberOfImages( ) const
+{
+  return( this->m_Blender->GetNumberOfInputs( ) );
 }
 
 // -------------------------------------------------------------------------
@@ -573,7 +482,7 @@ GetDisplayBounds( double bounds[ 6 ] ) const
 {
   if( this->m_ImageActor.GetPointer( ) == NULL )
   {
-    bounds[ 0 ] = bounds[ 2 ] = bounds[ 4 ] = double( -1 );
+    bounds[ 0 ] = bounds[ 2 ] = bounds[ 4 ] = double(  0 );
     bounds[ 1 ] = bounds[ 3 ] = bounds[ 5 ] = double( -1 );
   }
   else
@@ -584,11 +493,8 @@ GetDisplayBounds( double bounds[ 6 ] ) const
 void cpExtensions::Visualization::ImageSliceActors::
 ResetCursor( )
 {
-  /* TODO
   if( this->m_ImageMapper.GetPointer( ) != NULL )
   {
-    double bounds[ 6 ];
-    this->m_ImageMapper->GetInput( )->GetBounds( bounds );
     double pos[] =
       {
         this->m_VisibleBounds[ 0 ],
@@ -604,23 +510,17 @@ ResetCursor( )
     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_ImageMapper.GetPointer( ) == NULL )
     return;
 
@@ -634,32 +534,101 @@ SetCursor( double pos[ 3 ] )
 
   // Update cross
   double* bounds = this->m_VisibleBounds;
-  double
-    p0[ 3 ], p1[ 3 ], p2[ 3 ], p3[ 3 ],
-    p4[ 3 ], p5[ 3 ], p6[ 3 ], p7[ 3 ];
+  double p0[ 3 ], p1[ 3 ], p2[ 3 ], p3[ 3 ];
 
-  p0[ a2 ] = p1[ a2 ] = p4[ a2 ] = p5[ a2 ] = pos[ a2 ];
-  p2[ a1 ] = p3[ a1 ] = p6[ a1 ] = p7[ a1 ] = pos[ a1 ];
+  p0[ a2 ] = p1[ a2 ] = pos[ a2 ];
+  p2[ a1 ] = p3[ a1 ] = pos[ a1 ];
   p0[ a0 ] = p1[ a0 ] = p2[ a0 ] = p3[ a0 ] = bounds[ ma0 ];
-  p4[ a0 ] = p5[ a0 ] = p6[ a0 ] = p7[ a0 ] = bounds[ ma0 + 1 ];
-  p0[ a1 ] = p4[ a1 ] = bounds[ ma1 ];
-  p1[ a1 ] = p5[ a1 ] = bounds[ ma1 + 1 ];
-  p2[ a2 ] = p6[ a2 ] = bounds[ ma2 ];
-  p3[ a2 ] = p7[ a2 ] = bounds[ ma2 + 1 ];
+  p0[ a1 ] = bounds[ ma1 ];
+  p1[ a1 ] = bounds[ ma1 + 1 ];
+  p2[ a2 ] = bounds[ ma2 ];
+  p3[ a2 ] = bounds[ ma2 + 1 ];
 
   vtkPoints* points = this->m_Cursor->GetPoints( );
   points->SetPoint( 0, p0 );
   points->SetPoint( 1, p1 );
   points->SetPoint( 2, p2 );
   points->SetPoint( 3, p3 );
-  points->SetPoint( 4, p4 );
-  points->SetPoint( 5, p5 );
-  points->SetPoint( 6, p6 );
-  points->SetPoint( 7, p7 );
   this->m_Cursor->Modified( );
   this->m_CursorMapper->Modified( );
   this->m_CursorActor->Modified( );
-  */
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+ResetAxesCursor( )
+{
+  if( this->m_ImageMapper.GetPointer( ) != NULL )
+  {
+    double pos[] =
+      {
+        this->m_VisibleBounds[ 0 ],
+        this->m_VisibleBounds[ 2 ],
+        this->m_VisibleBounds[ 4 ]
+      };
+    this->SetAxesCursor( pos );
+  }
+  else
+  {
+    vtkPoints* points = this->m_Axis1->GetPoints( );
+    points->SetPoint( 0, 0, 0, 0 );
+    points->SetPoint( 1, 0, 0, 0 );
+    this->m_Axis1->Modified( );
+    this->m_Axis1Mapper->Modified( );
+    this->m_Axis1Actor->Modified( );
+
+    points = this->m_Axis2->GetPoints( );
+    points->SetPoint( 0, 0, 0, 0 );
+    points->SetPoint( 1, 0, 0, 0 );
+    this->m_Axis2->Modified( );
+    this->m_Axis2Mapper->Modified( );
+    this->m_Axis2Actor->Modified( );
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+SetAxesCursor( double pos[ 3 ] )
+{
+  if( this->m_ImageMapper.GetPointer( ) == NULL )
+    return;
+
+  // Get ordered axes
+  int a0 = this->GetAxis( );
+  int a1 = ( a0 + 1 ) % 3;
+  int a2 = ( a0 + 2 ) % 3;
+  int ma0 = a0 << 1;
+  int ma1 = a1 << 1;
+  int ma2 = a2 << 1;
+
+  // Update cross
+  double* bounds = this->m_VisibleBounds;
+  double p0[ 3 ], p1[ 3 ], p2[ 3 ], p3[ 3 ];
+
+  p0[ a2 ] = p1[ a2 ] = pos[ a2 ];
+  p2[ a1 ] = p3[ a1 ] = pos[ a1 ];
+  p0[ a0 ] = p1[ a0 ] = p2[ a0 ] = p3[ a0 ] = bounds[ ma0 ];
+  p0[ a1 ] = bounds[ ma1 ];
+  p1[ a1 ] = bounds[ ma1 + 1 ];
+  p2[ a2 ] = bounds[ ma2 ];
+  p3[ a2 ] = bounds[ ma2 + 1 ];
+
+  vtkPoints* points1 = this->m_Axis1->GetPoints( );
+  points1->SetPoint( 0, p2 );
+  points1->SetPoint( 1, p3 );
+
+  vtkPoints* points2 = this->m_Axis2->GetPoints( );
+  points2->SetPoint( 0, p0 );
+  points2->SetPoint( 1, p1 );
+
+  this->m_Axis1->Modified( );
+  this->m_Axis1Mapper->Modified( );
+  this->m_Axis1Actor->Modified( );
+
+  this->m_Axis2->Modified( );
+  this->m_Axis2Mapper->Modified( );
+  this->m_Axis2Actor->Modified( );
 }
 
 // -------------------------------------------------------------------------
@@ -744,6 +713,7 @@ SetWindowLevel( double w, double l )
   b        = ( b > this->m_WLRange[ 3 ] )? this->m_WLRange[ 3 ]: b;
   this->m_ImageActor->GetProperty( )->SetColorWindow( a );
   this->m_ImageActor->GetProperty( )->SetColorLevel( b );
+  this->UpdateText( a, b );
 }
 
 // -------------------------------------------------------------------------
@@ -850,7 +820,6 @@ SetSliceNumber( const int& slice )
   double* bnds = this->m_VisibleBounds;
 
   // Configure visualization and implicit plane orientation
-  /*
   this->m_PlaneActor->GetProperty( )->SetRepresentationToWireframe( );
   this->m_PlaneActor->GetProperty( )->SetLineWidth( 3 );
   vtkPoints* plane_points = this->m_Plane->GetPoints( );
@@ -860,44 +829,36 @@ SetSliceNumber( const int& slice )
   {
     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
   {
     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 );
 
   } // fi
+
+  // Set plane colors
+  this->m_PlaneActor->GetProperty( )->
+    SetColor( this->m_PlaneColors[ axis ] );
+  this->m_Axis1Actor->GetProperty( )->
+    SetColor( this->m_PlaneColors[ ( axis + 1 ) % 3 ] );
+  this->m_Axis2Actor->GetProperty( )->
+    SetColor( this->m_PlaneColors[ ( axis + 2 ) % 3 ] );
+
   this->m_Plane->Modified( );
   this->m_PlaneMapper->Modified( );
   this->m_PlaneActor->Modified( );
 
-  // Update text
-  this->UpdateText( );
-  */
-
-  // Update lines from associated slices
-  /* TODO
-     auto sIt = this->m_AssociatedSlices.begin( );
-     for( ; sIt != this->m_AssociatedSlices.end( ); ++sIt )
-     {
-     Self* slice = *sIt;
-     for( unsigned int id = 0; id < slice->m_AssociatedSlices.size( ); ++id )
-     {
-     std::cout << id << std::endl;
-     if( slice->m_AssociatedSlices[ id ] != this )
-     continue;
-
-     std::cout << "id : " << id << std::endl;
+  this->m_Axis1->Modified( );
+  this->m_Axis1Mapper->Modified( );
+  this->m_Axis1Actor->Modified( );
 
-     } // rof
+  this->m_Axis2->Modified( );
+  this->m_Axis2Mapper->Modified( );
+  this->m_Axis2Actor->Modified( );
 
-     } // rof
-  */
+  // Update text
+  this->UpdateText( );
 
   // Update camera position
   if( this->m_Window == NULL )
@@ -933,7 +894,6 @@ SetSlice( double* pos )
 void cpExtensions::Visualization::ImageSliceActors::
 UpdateText( )
 {
-  /* TODO
   if( this->m_ImageMapper.GetPointer( ) != NULL )
   {
     char axis;
@@ -942,24 +902,29 @@ UpdateText( )
     else if( axId == 1 ) axis = 'Y';
     else if( axId == 2 ) axis = 'Z';
 
+#if defined(WIN32)
+    sprintf_s(
+      this->m_TextBuffer, 1024, "Axis: %c (%d)",
+      axis, this->m_ImageMapper->GetSliceNumber( )
+      );
+#else // defined(WIN32)
     std::sprintf(
       this->m_TextBuffer, "Axis: %c (%d)",
       axis, this->m_ImageMapper->GetSliceNumber( )
       );
+#endif // defined(WIN32)
   }
   else
     this->m_TextBuffer[ 0 ] = '\0';
   this->m_TextActor->SetInput( this->m_TextBuffer );
   this->m_TextActor->Modified( );
   this->Modified( );
-  */
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
 UpdateText( double pos[ 3 ] )
 {
-  /* TODO
   if( this->m_ImageMapper.GetPointer( ) != NULL )
   {
     char axis;
@@ -998,11 +963,18 @@ UpdateText( double pos[ 3 ] )
             ijk[ 0 ], ijk[ 1 ], ijk[ 2 ], n
             );
       str << ")";
+
+#if defined(WIN32)
+      sprintf_s(
+        this->m_TextBuffer, 1024, "Axis: %c (%d)\nPixel %s",
+        axis, slice, str.str( ).c_str( )
+        );
+#else // defined(WIN32)
       std::sprintf(
         this->m_TextBuffer, "Axis: %c (%d)\nPixel %s",
         axis, slice, str.str( ).c_str( )
         );
-
+#endif // defined(WIN32)
     } // fi
   }
   else
@@ -1010,14 +982,12 @@ 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 )
 {
-  /* TODO
   if( this->m_ImageMapper.GetPointer( ) != NULL )
   {
     char axis;
@@ -1026,32 +996,37 @@ UpdateText( const double& w, const double& l )
     else if( axId == 1 ) axis = 'Y';
     else if( axId == 2 ) axis = 'Z';
 
+#if defined(WIN32)
+    sprintf_s(
+      this->m_TextBuffer, 1024, "Axis: %c (%d)\nW/L (%.2f/%.2f)",
+      axis, this->m_ImageMapper->GetSliceNumber( ), w, l
+      );
+#else // defined(WIN32)
     std::sprintf(
       this->m_TextBuffer, "Axis: %c (%d)\nW/L (%.2f/%.2f)",
       axis, this->m_ImageMapper->GetSliceNumber( ), w, l
       );
+#endif // defined(WIN32)
   }
   else
     this->m_TextBuffer[ 0 ] = '\0';
   this->m_TextActor->SetInput( this->m_TextBuffer );
   this->m_TextActor->Modified( );
   this->Modified( );
-*/
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-Render( const double& t )
+Render( )
 {
-  if( this->m_Window != NULL )
-  {
-    vtkRenderer* renderer =
-      this->m_Window->GetRenderers( )->GetFirstRenderer( );
-    if( renderer != NULL )
-      renderer->SetAllocatedRenderTime( t );
-    this->m_Window->Render( );
-
-  } // fi
+  if( this->m_Window == NULL )
+    return;
+  vtkRenderer* renderer =
+    this->m_Window->GetRenderers( )->GetFirstRenderer( );
+  if( renderer == NULL )
+    return;
+  renderer->SetAllocatedRenderTime( 1e-3 );
+  this->m_Window->Render( );
 }
 
 // -------------------------------------------------------------------------
@@ -1062,8 +1037,9 @@ ResetCamera( )
     return;
   vtkRenderer* renderer =
     this->m_Window->GetRenderers( )->GetFirstRenderer( );
-  if( renderer != NULL )
-    renderer->ResetCamera( this->m_VisibleBounds );
+  if( renderer == NULL )
+    return;
+  renderer->ResetCamera( );
 }
 
 // -------------------------------------------------------------------------
@@ -1089,6 +1065,7 @@ _ConfigureStyle( )
 {
   // Connect this view with a controller
   this->m_Style = vtkSmartPointer< TStyle >::New( );
+  this->m_Style->SetAssociatedObject( this );
   this->m_Style->AddMouseMoveCommand( Self::_MouseMoveCommand, this );
   this->m_Style->AddMouseClickCommand( Self::_MouseClickCommand, this );
   this->m_Style->AddMouseWheelCommand( Self::_MouseWheelCommand, this );
@@ -1116,6 +1093,10 @@ _ConfigureInputImage( )
   this->ResetCursor( );
   this->Modified( );
 
+  // Reset cursors
+  this->ResetCursor( );
+  this->ResetAxesCursor( );
+
   // Update window/level ranges
   vtkImageData* data = this->GetInputImage( );
   if( data != NULL )
@@ -1141,6 +1122,24 @@ _ConfigureInputImage( )
   } // fi
 }
 
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+_ConfigureBinaryImage( const double& r, const double& g, const double& b )
+{
+  unsigned int nValues = this->m_BlenderLUT->GetNumberOfTableValues( );
+  this->m_BlenderLUT->SetNumberOfTableValues( nValues + 1 );
+  this->m_BlenderLUT->SetTableRange( 0, nValues );
+  this->m_BlenderLUT->SetTableValue( nValues, r, g, b, 0.5 );
+  this->m_BlenderLUT->Build( );
+
+  this->m_BlenderLUT->Modified( );
+  this->m_Blender->Modified( );
+  this->m_Blender->Update( );
+
+  this->m_BlenderMapper->Modified( );
+  this->m_BlenderActor->Modified( );
+}
+
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
 _MouseMoveCommand(
@@ -1157,17 +1156,20 @@ _MouseMoveCommand(
     // Just show the pixel information
     actors->SetCursor( pos );
     actors->UpdateText( pos );
-    actors->Render( 1e-3 );
+    actors->Render( );
   }
   else if( btn == TStyle::ButtonID_Left )
   {
     if( !alt && ctr && !sft )
     {
+      // Show axes in current renderer
+      actors->SetAxesCursor( pos );
+      actors->Render( );
+
       // 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
   }
@@ -1192,7 +1194,7 @@ _MouseMoveCommand(
       dx += actors->m_StartWindowLevel[ 0 ];
       dy += actors->m_StartWindowLevel[ 1 ];
       actors->SetWindowLevel( dx, dy );
-      actors->Render( 1e-3 );
+      actors->Render( );
 
       // Associate objects
       auto i = actors->m_WindowLevelCommands.begin( );
@@ -1241,15 +1243,11 @@ _MouseWheelCommand(
     if( slice > actors->GetSliceNumberMaxValue( ) )
       slice = actors->GetSliceNumberMaxValue( );
     actors->SetSliceNumber( slice );
+    actors->Render( );
 
     auto a = actors->m_AssociatedSlices.begin( );
     for( ; a != actors->m_AssociatedSlices.end( ); ++a )
-    {
       ( *a )->SetSliceNumber( slice );
-      ( *a )->Render( 1e-3 );
-
-    } // rof
-    actors->Render( 1e-3 );
 
     // Associate objects
     auto i = actors->m_RenderCommands.begin( );
@@ -1272,7 +1270,7 @@ _KeyCommand( void* data, const char& key )
   case 'r': case 'R':
   {
     actors->ResetCamera( );
-    actors->Render( 1e-3 );
+    actors->Render( );
 
     // Associate objects
     auto i = actors->m_RenderCommands.begin( );
@@ -1283,7 +1281,7 @@ _KeyCommand( void* data, const char& key )
   case 'w': case 'W':
   {
     actors->ResetWindowLevel( );
-    actors->Render( 1e-3 );
+    actors->Render( );
 
     // Associate objects
     auto i = actors->m_RenderCommands.begin( );
@@ -1305,8 +1303,8 @@ _EnterCommand( void* data )
     return;
 
   actors->ResetCursor( );
-  // TODO: actors->m_CursorActor->VisibilityOn( );
-  actors->Render( 1e-3 );
+  actors->m_CursorActor->VisibilityOn( );
+  actors->Render( );
 }
 
 // -------------------------------------------------------------------------
@@ -1318,8 +1316,8 @@ _LeaveCommand( void* data )
     return;
 
   actors->ResetCursor( );
-  // TODO: actors->m_CursorActor->VisibilityOff( );
-  actors->Render( 1e-3 );
+  actors->m_CursorActor->VisibilityOff( );
+  actors->Render( );
 }
 
 // eof - $RCSfile$