]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/Visualization/ImageSliceActors.cxx
...
[cpPlugins.git] / lib / cpExtensions / Visualization / ImageSliceActors.cxx
index 1c032d2817b628a0ddf61d46da39096e99712834..024fbe09c9bc94051ac6652bc19092f7de7a2424 100644 (file)
@@ -84,7 +84,7 @@ AddBinaryConnection(
     return( -1 );
   this->m_Blender->AddInputConnection( aout );
   this->_ConfigureBinaryImage( r, g, b );
-  return( this->m_Blender->GetNumberOfInputPorts( ) - 1 );
+  return( this->m_Blender->GetNumberOfInputs( ) - 1 );
 }
 
 // -------------------------------------------------------------------------
@@ -98,7 +98,7 @@ AddBinaryImage(
     return( -1 );
   this->m_Blender->AddInputData( data );
   this->_ConfigureBinaryImage( r, g, b );
-  return( this->m_Blender->GetNumberOfInputPorts( ) - 1 );
+  return( this->m_Blender->GetNumberOfInputs( ) - 1 );
 }
 
 // -------------------------------------------------------------------------
@@ -129,9 +129,6 @@ 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( );
@@ -330,8 +327,8 @@ 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
 
@@ -362,7 +359,7 @@ PopActorsFrom( vtkRenderWindow* window )
 unsigned int cpExtensions::Visualization::ImageSliceActors::
 GetNumberOfImages( ) const
 {
-  return( this->m_Blender->GetNumberOfInputPorts( ) );
+  return( this->m_Blender->GetNumberOfInputs( ) );
 }
 
 // -------------------------------------------------------------------------
@@ -863,25 +860,6 @@ SetSliceNumber( const int& slice )
   // 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;
-
-     } // rof
-
-     } // rof
-  */
-
   // Update camera position
   if( this->m_Window == NULL )
     return;
@@ -924,10 +902,17 @@ 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';
@@ -978,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
@@ -1004,10 +996,17 @@ 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';
@@ -1016,26 +1015,9 @@ UpdateText( const double& w, const double& l )
   this->Modified( );
 }
 
-// -------------------------------------------------------------------------
-cpExtensions::Visualization::ImageSliceActors::
-ImageSliceActors( )
-  : Superclass( ),
-    m_Window( NULL ),
-    m_Interpolate( false )
-{
-  this->Clear( );
-  this->_ConfigureStyle( );
-}
-
-// -------------------------------------------------------------------------
-cpExtensions::Visualization::ImageSliceActors::
-~ImageSliceActors( )
-{
-}
-
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-_Render( )
+Render( )
 {
   if( this->m_Window == NULL )
     return;
@@ -1049,7 +1031,7 @@ _Render( )
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-_ResetCamera( )
+ResetCamera( )
 {
   if( this->m_Window == NULL )
     return;
@@ -1060,12 +1042,30 @@ _ResetCamera( )
   renderer->ResetCamera( );
 }
 
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::ImageSliceActors::
+ImageSliceActors( )
+  : Superclass( ),
+    m_Window( NULL ),
+    m_Interpolate( false )
+{
+  this->Clear( );
+  this->_ConfigureStyle( );
+}
+
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::ImageSliceActors::
+~ImageSliceActors( )
+{
+}
+
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
 _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 );
@@ -1156,7 +1156,7 @@ _MouseMoveCommand(
     // Just show the pixel information
     actors->SetCursor( pos );
     actors->UpdateText( pos );
-    actors->_Render( );
+    actors->Render( );
   }
   else if( btn == TStyle::ButtonID_Left )
   {
@@ -1164,7 +1164,7 @@ _MouseMoveCommand(
     {
       // Show axes in current renderer
       actors->SetAxesCursor( pos );
-      actors->_Render( );
+      actors->Render( );
 
       // Interactively move slices
       auto i = actors->m_SlicesCommands.begin( );
@@ -1194,7 +1194,7 @@ _MouseMoveCommand(
       dx += actors->m_StartWindowLevel[ 0 ];
       dy += actors->m_StartWindowLevel[ 1 ];
       actors->SetWindowLevel( dx, dy );
-      actors->_Render( );
+      actors->Render( );
 
       // Associate objects
       auto i = actors->m_WindowLevelCommands.begin( );
@@ -1243,7 +1243,7 @@ _MouseWheelCommand(
     if( slice > actors->GetSliceNumberMaxValue( ) )
       slice = actors->GetSliceNumberMaxValue( );
     actors->SetSliceNumber( slice );
-    actors->_Render( );
+    actors->Render( );
 
     auto a = actors->m_AssociatedSlices.begin( );
     for( ; a != actors->m_AssociatedSlices.end( ); ++a )
@@ -1269,8 +1269,8 @@ _KeyCommand( void* data, const char& key )
   {
   case 'r': case 'R':
   {
-    actors->_ResetCamera( );
-    actors->_Render( );
+    actors->ResetCamera( );
+    actors->Render( );
 
     // Associate objects
     auto i = actors->m_RenderCommands.begin( );
@@ -1281,7 +1281,7 @@ _KeyCommand( void* data, const char& key )
   case 'w': case 'W':
   {
     actors->ResetWindowLevel( );
-    actors->_Render( );
+    actors->Render( );
 
     // Associate objects
     auto i = actors->m_RenderCommands.begin( );
@@ -1304,7 +1304,7 @@ _EnterCommand( void* data )
 
   actors->ResetCursor( );
   actors->m_CursorActor->VisibilityOn( );
-  actors->_Render( );
+  actors->Render( );
 }
 
 // -------------------------------------------------------------------------
@@ -1317,7 +1317,7 @@ _LeaveCommand( void* data )
 
   actors->ResetCursor( );
   actors->m_CursorActor->VisibilityOff( );
-  actors->_Render( );
+  actors->Render( );
 }
 
 // eof - $RCSfile$