]> Creatis software - cpPlugins.git/commitdiff
MPR-OpenGL integration: not yet finished, just one step to go. IT DOES NOT COMPILE.
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 19 Nov 2015 22:41:14 +0000 (17:41 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 19 Nov 2015 22:41:14 +0000 (17:41 -0500)
appli/ImageMPR/ImageMPR.cxx
appli/examples/example_View2DImage.cxx
appli/examples/example_ViewImageThreshold.cxx
lib/cpExtensions/Visualization/ImageBlender.cxx
lib/cpExtensions/Visualization/ImageSliceActors.cxx
lib/cpExtensions/Visualization/ImageSliceActors.h
lib/cpExtensions/Visualization/MPRActors.cxx
lib/cpExtensions/Visualization/MPRActors.h
lib/cpExtensions/Visualization/MPRObjects.cxx
lib/cpExtensions/Visualization/MPRObjects.h
lib/cpPlugins/Interface/BaseMPRWidget.cxx

index cf6a1f6b7934f353350ee9ee89f47c200e765157..ce1f2fc769c7f39232d3902adbb18353cb367936 100644 (file)
@@ -75,7 +75,6 @@ UpdateActualFilter( )
     return;
 
   // Show outputs
-#error ACA VOY
   for( auto oIt = outputs.begin( ); oIt != outputs.end( ); ++oIt )
     std::cout << *oIt << std::endl;
   
index ef6e36fac045352aea548c81d9c2b34f6b38a857..be654b2217e23599f24766f5e7638361ba68739b 100644 (file)
@@ -95,7 +95,7 @@ int main( int argc, char* argv[] )
   } // fi
 
   // Begin interaction
-  image_actors->ResetCamera( );
+  renderer->ResetCamera( );
   window->Render( );
   interactor->Start( );
 
index 3d3bc077bfac580a2d86ed21f21a2d9da3d36340..85796afd3b4553689011883107d34d0675767e61 100644 (file)
@@ -155,7 +155,7 @@ int main( int argc, char* argv[] )
   image_actors->PushActorsInto( window );
 
   // Begin interaction
-  image_actors->ResetCamera( );
+  renderer->ResetCamera( );
   window->Render( );
   interactor->Start( );
 
index ee808e5aa51a87f84c6b03a52f770452f8989a00..88d85672ed784661db555924e380ecb1b348abd1 100644 (file)
@@ -84,7 +84,9 @@ RequestData(
     } // rof
 
   } // rof
-  this->Superclass::RequestData( request, inputVector, outputVector );
+  return(
+    this->Superclass::RequestData( request, inputVector, outputVector )
+    );
 }
 
 // -------------------------------------------------------------------------
index b444328be321e2946c54807f4a59345da8f312fd..1c032d2817b628a0ddf61d46da39096e99712834 100644 (file)
@@ -45,7 +45,6 @@ SetAxis( int axis )
   this->m_ImageActor->Modified( );
   this->m_BlenderActor->Modified( );
   this->Modified( );
-  this->ResetCamera( );
 }
 
 // -------------------------------------------------------------------------
@@ -337,8 +336,7 @@ PushActorsInto( vtkRenderWindow* window, bool force_style )
     } // fi
 
   } // fi
-  this->ResetCamera( );
-  rwi->Render( );
+  renderer->ResetCamera( );
 }
 
 // -------------------------------------------------------------------------
@@ -356,8 +354,6 @@ PopActorsFrom( vtkRenderWindow* window )
     renderer->RemoveViewProp( this->m_TextActor );
     renderer->RemoveViewProp( this->m_Axis1Actor );
     renderer->RemoveViewProp( this->m_Axis2Actor );
-    if( rwi != NULL )
-      rwi->Render( );
 
   } // fi
 }
@@ -1021,47 +1017,47 @@ UpdateText( const double& w, const double& l )
 }
 
 // -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-Render( const double& t )
+cpExtensions::Visualization::ImageSliceActors::
+ImageSliceActors( )
+  : Superclass( ),
+    m_Window( NULL ),
+    m_Interpolate( false )
 {
-  if( this->m_Window != NULL )
-  {
-    vtkRenderer* renderer =
-      this->m_Window->GetRenderers( )->GetFirstRenderer( );
-    if( renderer != NULL )
-      renderer->SetAllocatedRenderTime( t );
-    this->m_Window->Render( );
+  this->Clear( );
+  this->_ConfigureStyle( );
+}
 
-  } // fi
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::ImageSliceActors::
+~ImageSliceActors( )
+{
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-ResetCamera( )
+_Render( )
 {
   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( ),
-    m_Window( NULL ),
-    m_Interpolate( false )
-{
-  this->Clear( );
-  this->_ConfigureStyle( );
+  if( renderer == NULL )
+    return;
+  renderer->SetAllocatedRenderTime( 1e-3 );
+  this->m_Window->Render( );
 }
 
 // -------------------------------------------------------------------------
-cpExtensions::Visualization::ImageSliceActors::
-~ImageSliceActors( )
+void cpExtensions::Visualization::ImageSliceActors::
+_ResetCamera( )
 {
+  if( this->m_Window == NULL )
+    return;
+  vtkRenderer* renderer =
+    this->m_Window->GetRenderers( )->GetFirstRenderer( );
+  if( renderer == NULL )
+    return;
+  renderer->ResetCamera( );
 }
 
 // -------------------------------------------------------------------------
@@ -1160,7 +1156,7 @@ _MouseMoveCommand(
     // Just show the pixel information
     actors->SetCursor( pos );
     actors->UpdateText( pos );
-    actors->Render( 1e-3 );
+    actors->_Render( );
   }
   else if( btn == TStyle::ButtonID_Left )
   {
@@ -1168,12 +1164,12 @@ _MouseMoveCommand(
     {
       // 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
   }
@@ -1198,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( );
@@ -1247,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( );
@@ -1277,8 +1269,8 @@ _KeyCommand( void* data, const char& key )
   {
   case 'r': case 'R':
   {
-    actors->ResetCamera( );
-    actors->Render( 1e-3 );
+    actors->_ResetCamera( );
+    actors->_Render( );
 
     // Associate objects
     auto i = actors->m_RenderCommands.begin( );
@@ -1289,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( );
@@ -1312,7 +1304,7 @@ _EnterCommand( void* data )
 
   actors->ResetCursor( );
   actors->m_CursorActor->VisibilityOn( );
-  actors->Render( 1e-3 );
+  actors->_Render( );
 }
 
 // -------------------------------------------------------------------------
@@ -1325,7 +1317,7 @@ _LeaveCommand( void* data )
 
   actors->ResetCursor( );
   actors->m_CursorActor->VisibilityOff( );
-  actors->Render( 1e-3 );
+  actors->_Render( );
 }
 
 // eof - $RCSfile$
index c8d739f9a8185925b322965e4a34962aa1bcd59a..396d2ae5280e7ce5fe3472612f45505db1db0aa7 100644 (file)
@@ -135,13 +135,12 @@ namespace cpExtensions
       void UpdateText( double pos[ 3 ] );
       void UpdateText( const double& w, const double& l );
 
-      void Render( const double& t );
-      void ResetCamera( );
-
     protected:
       ImageSliceActors( );
       virtual ~ImageSliceActors( );
 
+      void _Render( );
+      void _ResetCamera( );
       void _ConfigureStyle( );
       void _ConfigureInputImage( );
       void _ConfigureBinaryImage(
index b04194484b71dcbaf4b3d2eb670cf308b480f82a..25151abac3a4a2ea9f40b8700ec41667ed354030 100644 (file)
@@ -28,39 +28,83 @@ GetSliceActors( const int& i ) const
 }
 
 // -------------------------------------------------------------------------
-int cpExtensions::Visualization::MPRActors::
-AddInputConnection( vtkAlgorithmOutput* aout )
+void cpExtensions::Visualization::MPRActors::
+SetInputConnection( vtkAlgorithmOutput* aout )
 {
-  for( unsigned int i = 0; i < 2; ++i )
-  {
-    for( unsigned int j = 0; j < 3; ++j )
-    {
-      this->Slices[ i ][ j ]->SetInputConnection( aout );
-      this->Slices[ i ][ j ]->SetAxis( j );
+  this->Slices[ 0 ][ 0 ]->SetInputConnection( aout );
+  this->Slices[ 0 ][ 1 ]->SetInputConnection( aout );
+  this->Slices[ 0 ][ 2 ]->SetInputConnection( aout );
+  this->Slices[ 1 ][ 0 ]->SetInputConnection( aout );
+  this->Slices[ 1 ][ 1 ]->SetInputConnection( aout );
+  this->Slices[ 1 ][ 2 ]->SetInputConnection( aout );
+}
 
-    } // rof
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+SetInputImage( vtkImageData* data )
+{
+    this->Slices[ 0 ][ 0 ]->SetInputImage( data );
+    this->Slices[ 0 ][ 1 ]->SetInputImage( data );
+    this->Slices[ 0 ][ 2 ]->SetInputImage( data );
+    this->Slices[ 1 ][ 0 ]->SetInputImage( data );
+    this->Slices[ 1 ][ 1 ]->SetInputImage( data );
+    this->Slices[ 1 ][ 2 ]->SetInputImage( data );
+}
 
-  } // rof
-  this->_CreateBoundingBox( );
-  return( 0 );
+// -------------------------------------------------------------------------
+int cpExtensions::Visualization::MPRActors::
+AddBinaryConnection(
+  vtkAlgorithmOutput* aout,
+  const double& r, const double& g, const double& b
+  )
+{
+  this->Slices[ 0 ][ 0 ]->AddBinaryConnection( aout, r, g, b );
+  this->Slices[ 0 ][ 1 ]->AddBinaryConnection( aout, r, g, b );
+  this->Slices[ 0 ][ 2 ]->AddBinaryConnection( aout, r, g, b );
+  this->Slices[ 1 ][ 0 ]->AddBinaryConnection( aout, r, g, b );
+  this->Slices[ 1 ][ 1 ]->AddBinaryConnection( aout, r, g, b );
+  return( this->Slices[ 1 ][ 2 ]->AddBinaryConnection( aout, r, g, b ) );
 }
 
 // -------------------------------------------------------------------------
 int cpExtensions::Visualization::MPRActors::
-AddInputData( vtkImageData* new_image )
+AddBinaryImage(
+  vtkImageData* data,
+  const double& r, const double& g, const double& b
+  )
 {
-  for( unsigned int i = 0; i < 2; ++i )
-  {
-    for( unsigned int j = 0; j < 3; ++j )
-    {
-      this->Slices[ i ][ j ]->SetInputImage( new_image );
-      this->Slices[ i ][ j ]->SetAxis( j );
+  this->Slices[ 0 ][ 0 ]->AddBinaryImage( data, r, g, b );
+  this->Slices[ 0 ][ 1 ]->AddBinaryImage( data, r, g, b );
+  this->Slices[ 0 ][ 2 ]->AddBinaryImage( data, r, g, b );
+  this->Slices[ 1 ][ 0 ]->AddBinaryImage( data, r, g, b );
+  this->Slices[ 1 ][ 1 ]->AddBinaryImage( data, r, g, b );
+  return( this->Slices[ 1 ][ 2 ]->AddBinaryImage( data, r, g, b ) );
+}
 
-    } // rof
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+Clear( )
+{
+  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( );
+}
 
-  } // rof
-  this->_CreateBoundingBox( );
-  return( 0 );
+// -------------------------------------------------------------------------
+vtkImageData* cpExtensions::Visualization::MPRActors::
+GetInputImage( )
+{
+  return( this->Slices[ 0 ][ 0 ]->GetInputImage( ) );
+}
+
+// -------------------------------------------------------------------------
+const vtkImageData* cpExtensions::Visualization::MPRActors::
+GetInputImage( ) const
+{
+  return( this->Slices[ 0 ][ 0 ]->GetInputImage( ) );
 }
 
 // -------------------------------------------------------------------------
@@ -70,10 +114,38 @@ GetNumberOfImages( ) const
   return( this->Slices[ 0 ][ 0 ]->GetNumberOfImages( ) );
 }
 
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+SetInterpolate( bool v )
+{
+  this->Slices[ 0 ][ 0 ]->SetInterpolate( v );
+  this->Slices[ 0 ][ 1 ]->SetInterpolate( v );
+  this->Slices[ 0 ][ 2 ]->SetInterpolate( v );
+  this->Slices[ 1 ][ 0 ]->SetInterpolate( v );
+  this->Slices[ 1 ][ 1 ]->SetInterpolate( v );
+  this->Slices[ 1 ][ 2 ]->SetInterpolate( v );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+InterpolateOn( )
+{
+  this->SetInterpolate( true );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+InterpolateOff( )
+{
+  this->SetInterpolate( false );
+}
+
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRActors::
 PushActorsInto(
-  vtkRenderWindow* x, vtkRenderWindow* y, vtkRenderWindow* z,
+  vtkRenderWindow* x,
+  vtkRenderWindow* y,
+  vtkRenderWindow* z,
   vtkRenderWindow* w
   )
 {
@@ -87,13 +159,15 @@ PushActorsInto(
   vtkRenderer* wren =
     ( w != NULL )? w->GetRenderers( )->GetFirstRenderer( ): NULL;
   if( wren != NULL )
-    wren->AddActor( this->ImageOutlineActor );
+    wren->AddViewProp( this->ImageOutlineActor );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRActors::
 PopActorsFrom(
-  vtkRenderWindow* x, vtkRenderWindow* y, vtkRenderWindow* z,
+  vtkRenderWindow* x,
+  vtkRenderWindow* y,
+  vtkRenderWindow* z,
   vtkRenderWindow* w
   )
 {
@@ -107,14 +181,35 @@ PopActorsFrom(
   vtkRenderer* wren =
     ( w != NULL )? w->GetRenderers( )->GetFirstRenderer( ): NULL;
   if( wren != NULL )
-    wren->RemoveActor( this->ImageOutlineActor );
+    wren->RemoveViewProp( 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( );
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::MPRActors::
+GetMinWindow( ) const
+{
+  return( this->Slices[ 0 ][ 0 ]->GetMinWindow( ) );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::MPRActors::
+GetMaxWindow( ) const
+{
+  return( this->Slices[ 0 ][ 0 ]->GetMaxWindow( ) );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::MPRActors::
+GetMinLevel( ) const
+{
+  return( this->Slices[ 0 ][ 0 ]->GetMinLevel( ) );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::MPRActors::
+GetMaxLevel( ) const
+{
+  return( this->Slices[ 0 ][ 0 ]->GetMaxLevel( ) );
 }
 
 // -------------------------------------------------------------------------
@@ -132,79 +227,105 @@ GetLevel( )
 }
 
 // -------------------------------------------------------------------------
-int cpExtensions::Visualization::MPRActors::
-GetSliceNumberMinValue( const int& axis ) const
+void cpExtensions::Visualization::MPRActors::
+SetWindow( double w )
 {
-  return( this->Slices[ 0 ][ axis ]->GetSliceNumberMinValue( ) );
+  this->Slices[ 0 ][ 0 ]->SetWindow( w );
+  this->Slices[ 0 ][ 1 ]->SetWindow( w );
+  this->Slices[ 0 ][ 2 ]->SetWindow( w );
+  this->Slices[ 1 ][ 0 ]->SetWindow( w );
+  this->Slices[ 1 ][ 1 ]->SetWindow( w );
+  this->Slices[ 1 ][ 2 ]->SetWindow( w );
 }
 
 // -------------------------------------------------------------------------
-int cpExtensions::Visualization::MPRActors::
-GetSliceNumberMaxValue( const int& axis ) const
+void cpExtensions::Visualization::MPRActors::
+SetLevel( double l )
 {
-  return( this->Slices[ 0 ][ axis ]->GetSliceNumberMaxValue( ) );
+  this->Slices[ 0 ][ 0 ]->SetLevel( l );
+  this->Slices[ 0 ][ 1 ]->SetLevel( l );
+  this->Slices[ 0 ][ 2 ]->SetLevel( l );
+  this->Slices[ 1 ][ 0 ]->SetLevel( l );
+  this->Slices[ 1 ][ 1 ]->SetLevel( l );
+  this->Slices[ 1 ][ 2 ]->SetLevel( l );
 }
 
 // -------------------------------------------------------------------------
-int cpExtensions::Visualization::MPRActors::
-GetSlice( const int& axis ) const
+void cpExtensions::Visualization::MPRActors::
+SetWindowLevel( double w, double l )
 {
-  return( this->Slices[ 0 ][ axis ]->GetSliceNumber( ) );
+  this->Slices[ 0 ][ 0 ]->SetWindowLevel( w, l );
+  this->Slices[ 0 ][ 1 ]->SetWindowLevel( w, l );
+  this->Slices[ 0 ][ 2 ]->SetWindowLevel( w, l );
+  this->Slices[ 1 ][ 0 ]->SetWindowLevel( w, l );
+  this->Slices[ 1 ][ 1 ]->SetWindowLevel( w, l );
+  this->Slices[ 1 ][ 2 ]->SetWindowLevel( w, l );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRActors::
-SetSlice( const int& axis, const int& slice )
+ResetWindowLevel( )
 {
-  vtkImageData* image =
-    dynamic_cast< vtkImageData* >( this->Slices[ 0 ][ 0 ]->GetInputImage( ) );
-  if( image == NULL )
-    return;
+  this->Slices[ 0 ][ 0 ]->ResetWindowLevel( );
+  this->Slices[ 0 ][ 1 ]->ResetWindowLevel( );
+  this->Slices[ 0 ][ 2 ]->ResetWindowLevel( );
+  this->Slices[ 1 ][ 0 ]->ResetWindowLevel( );
+  this->Slices[ 1 ][ 1 ]->ResetWindowLevel( );
+  this->Slices[ 1 ][ 2 ]->ResetWindowLevel( );
+}
 
-  // Get image data extent
-  int ext[ 6 ];
-  image->GetExtent( ext );
+// -------------------------------------------------------------------------
+int cpExtensions::Visualization::MPRActors::
+GetSliceNumber( const int& axis ) const
+{
+  if( axis < 3 )
+    return( this->Slices[ 0 ][ axis ]->GetSliceNumber( ) );
+  else
+    return( -1 );
+}
 
-  // Check if the slice is valid
-  int real = slice;
-  if( slice < ext[ axis << 1 ] )
-    real = ext[ axis << 1 ];
-  if( ext[ ( axis << 1 ) + 1 ] < slice )
-    real = ext[ ( axis << 1 ) + 1 ];
+// -------------------------------------------------------------------------
+int cpExtensions::Visualization::MPRActors::
+GetSliceNumberMinValue( const int& axis ) const
+{
+  if( axis < 3 )
+    return( this->Slices[ 0 ][ axis ]->GetSliceNumberMinValue( ) );
+  else
+    return( -1 );
+}
 
-  // Change slice
-  this->Slices[ 0 ][ axis ]->SetSliceNumber( real );
-  this->Slices[ 1 ][ axis ]->SetSliceNumber( real );
-  this->Modified( );
+// -------------------------------------------------------------------------
+int cpExtensions::Visualization::MPRActors::
+GetSliceNumberMaxValue( const int& axis ) const
+{
+  if( axis < 3 )
+    return( this->Slices[ 0 ][ axis ]->GetSliceNumberMaxValue( ) );
+  else
+    return( -1 );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRActors::
-SetSlice( const int& axis, const double& slice )
+SetSliceNumber( const int& axis, const int& slice )
 {
-  vtkImageData* image =
-    dynamic_cast< vtkImageData* >( this->Slices[ 0 ][ 0 ]->GetInputImage( ) );
-  if( image == NULL )
-    return;
-
-  double x[ 3 ] = { double( 0 ) };
-  double pcoords[ 3 ];
-  int ijk[ 3 ];
+  if( axis < 3 )
+  {
+    this->Slices[ 0 ][ axis ]->SetSliceNumber( slice );
+    this->Slices[ 1 ][ axis ]->SetSliceNumber( slice );
 
-  x[ axis ] = slice;
-  image->ComputeStructuredCoordinates( x, ijk, pcoords );
-  this->SetSlice( axis, ijk[ axis ] );
+  } // fi
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRActors::
-ResetSlices( )
+SetSlice( const int& axis, double* pos )
 {
-  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( )
-        );
+  if( axis < 3 )
+  {
+    this->Slices[ 0 ][ axis ]->SetSlice( pos );
+    this->Slices[ 1 ][ axis ]->SetSlice( pos );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
@@ -275,17 +396,8 @@ _SlicesCommand( double* pos, int axis, void* 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->Slices[ 1 ][ j ]->SetSlice( pos );
-      actors->Slices[ 0 ][ j ]->Render( 1e-3 );
-      actors->Slices[ 1 ][ j ]->Render( 1e-3 );
-
-    } // fi
-
-  } // rof
+      actors->SetSlice( j, pos );
 }
 
 // -------------------------------------------------------------------------
@@ -295,20 +407,7 @@ _WindowLevelCommand( double window, double level, void* data )
   MPRActors* actors = reinterpret_cast< MPRActors* >( data );
   if( actors == NULL )
     return;
-
-  actors->Slices[ 0 ][ 0 ]->SetWindowLevel( window, level );
-  actors->Slices[ 0 ][ 1 ]->SetWindowLevel( window, level );
-  actors->Slices[ 0 ][ 2 ]->SetWindowLevel( window, level );
-  actors->Slices[ 1 ][ 0 ]->SetWindowLevel( window, level );
-  actors->Slices[ 1 ][ 1 ]->SetWindowLevel( window, level );
-  actors->Slices[ 1 ][ 2 ]->SetWindowLevel( window, level );
-
-  actors->Slices[ 0 ][ 0 ]->Render( 1e-3 );
-  actors->Slices[ 0 ][ 1 ]->Render( 1e-3 );
-  actors->Slices[ 0 ][ 2 ]->Render( 1e-3 );
-  actors->Slices[ 1 ][ 0 ]->Render( 1e-3 );
-  actors->Slices[ 1 ][ 1 ]->Render( 1e-3 );
-  actors->Slices[ 1 ][ 2 ]->Render( 1e-3 );
+  actors->SetWindowLevel( window, level );
 }
 
 // -------------------------------------------------------------------------
@@ -318,12 +417,6 @@ _RenderCommand( void* data )
   MPRActors* actors = reinterpret_cast< MPRActors* >( data );
   if( actors == NULL )
     return;
-  actors->Slices[ 0 ][ 0 ]->Render( 1e-3 );
-  actors->Slices[ 0 ][ 1 ]->Render( 1e-3 );
-  actors->Slices[ 0 ][ 2 ]->Render( 1e-3 );
-  actors->Slices[ 1 ][ 0 ]->Render( 1e-3 );
-  actors->Slices[ 1 ][ 1 ]->Render( 1e-3 );
-  actors->Slices[ 1 ][ 2 ]->Render( 1e-3 );
 }
 
 // eof - $RCSfile$
index 5eb3a202003712441265a4aada24d5990166d98f..34f373c9d4b690a2b148b80011ece8b2d367a304 100644 (file)
@@ -38,10 +38,27 @@ namespace cpExtensions
 
       ImageSliceActors* GetSliceActors( const int& i ) const;
 
-      int AddInputConnection( vtkAlgorithmOutput* aout );
-      int AddInputData( vtkImageData* new_image );
+      void SetInputConnection( vtkAlgorithmOutput* aout );
+      void SetInputImage( vtkImageData* data );
+      int AddBinaryConnection(
+        vtkAlgorithmOutput* aout,
+        const double& r, const double& g, const double& b
+        );
+      int AddBinaryImage(
+        vtkImageData* data,
+        const double& r, const double& g, const double& b
+        );
+      void Clear( );
+
+      vtkImageData* GetInputImage( );
+      const vtkImageData* GetInputImage( ) const;
+
       unsigned int GetNumberOfImages( ) const;
 
+      void SetInterpolate( bool v );
+      void InterpolateOn( );
+      void InterpolateOff( );
+
       void PushActorsInto(
         vtkRenderWindow* x,
         vtkRenderWindow* y,
@@ -55,16 +72,23 @@ namespace cpExtensions
         vtkRenderWindow* w
         );
 
+      double GetMinWindow( ) const;
+      double GetMaxWindow( ) const;
+      double GetMinLevel( ) const;
+      double GetMaxLevel( ) const;
       double GetWindow( );
       double GetLevel( );
+      void SetWindow( double w );
+      void SetLevel( double l );
+      void SetWindowLevel( double w, double l );
+      void ResetWindowLevel( );
 
       // Slice access
+      int GetSliceNumber( const int& axis ) const;
       int GetSliceNumberMinValue( const int& axis ) const;
       int GetSliceNumberMaxValue( const int& axis ) const;
-      int GetSlice( const int& axis ) const;
-      void SetSlice( const int& axis, const int& slice );
-      void SetSlice( const int& axis, const double& slice );
-      void ResetSlices( );
+      void SetSliceNumber( const int& axis, const int& slice );
+      void SetSlice( const int& axis, double* pos );
 
     protected:
       MPRActors( );
index a0c1f3eb64ace2ef98f0a279faa828ed1c1201f7..ccc3dc4680374ea4e0e1f0c0512cac79cad91381 100644 (file)
@@ -15,35 +15,290 @@ New( )
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRObjects::
 SetRenderWindows(
-  vtkRenderWindow* wx, vtkRenderWindow* wy,
-  vtkRenderWindow* wz, vtkRenderWindow* w3D
+  vtkRenderWindow* x, vtkRenderWindow* y,
+  vtkRenderWindow* z, vtkRenderWindow* w
   )
 {
-  this->m_Windows[ 0 ] = wx;
-  this->m_Windows[ 1 ] = wy;
-  this->m_Windows[ 2 ] = wz;
-  this->m_Windows[ 3 ] = w3D;
+  this->m_Windows[ 0 ] = x;
+  this->m_Windows[ 1 ] = y;
+  this->m_Windows[ 2 ] = z;
+  this->m_Windows[ 3 ] = w;
 
   // Prepare 2D renderers
   for( int i = 0; i < 4; ++i )
   {
-    if( this->m_Windows[ i ] == NULL )
+    // Create renderer, if render window exists
+    if( this->m_Windows[ i ] != NULL )
     {
+      this->m_Renderers[ i ] = vtkSmartPointer< vtkRenderer >::New( );
+      this->m_Renderers[ i ]->SetBackground( 0.3, 0.3, 0.3 );
+      this->m_Windows[ i ]->AddRenderer( this->m_Renderers[ i ] );
+    }
+    else
       this->m_Renderers[ i ] = NULL;
-      continue;
+
+  } // rof
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+SetInputConnection( vtkAlgorithmOutput* aout )
+{
+  this->m_MPRActors->SetInputConnection( aout );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+SetInputImage( vtkImageData* data )
+{
+  this->m_MPRActors->SetInputImage( data );
+}
+
+// -------------------------------------------------------------------------
+int cpExtensions::Visualization::MPRObjects::
+AddBinaryConnection(
+  vtkAlgorithmOutput* aout,
+  const double& r, const double& g, const double& b
+  )
+{
+  return( this->m_MPRActors->AddBinaryConnection( aout, r, g, b ) );
+}
+
+// -------------------------------------------------------------------------
+int cpExtensions::Visualization::MPRObjects::
+AddBinaryImage(
+  vtkImageData* data,
+  const double& r, const double& g, const double& b
+  )
+{
+  return( this->m_MPRActors->AddBinaryImage( data, r, g, b ) );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+Clear( )
+{
+  this->m_MPRActors->Clear( );
+}
+
+// -------------------------------------------------------------------------
+vtkImageData* cpExtensions::Visualization::MPRObjects::
+GetInputImage( )
+{
+  return( this->m_MPRActors->GetInputImage( ) );
+}
+
+// -------------------------------------------------------------------------
+const vtkImageData* cpExtensions::Visualization::MPRObjects::
+GetInputImage( ) const
+{
+  return( this->m_MPRActors->GetInputImage( ) );
+}
+
+// -------------------------------------------------------------------------
+unsigned int cpExtensions::Visualization::MPRObjects::
+GetNumberOfImages( ) const
+{
+  return( this->m_MPRActors->GetNumberOfImages( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+SetInterpolate( bool v )
+{
+  this->m_MPRActors->SetInterpolate( v );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+InterpolateOn( )
+{
+  this->m_MPRActors->InterpolateOn( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+InterpolateOff( )
+{
+  this->m_MPRActors->InterpolateOff( );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::MPRObjects::
+GetMinWindow( ) const
+{
+  return( this->m_MPRActors->GetMinWindow( ) );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::MPRObjects::
+GetMaxWindow( ) const
+{
+  return( this->m_MPRActors->GetMaxWindow( ) );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::MPRObjects::
+GetMinLevel( ) const
+{
+  return( this->m_MPRActors->GetMinLevel( ) );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::MPRObjects::
+GetMaxLevel( ) const
+{
+  return( this->m_MPRActors->GetMaxLevel( ) );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::MPRObjects::
+GetWindow( ) const
+{
+  return( this->m_MPRActors->GetWindow( ) );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::MPRObjects::
+GetLevel( ) const
+{
+  return( this->m_MPRActors->GetLevel( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+SetWindow( double w )
+{
+  this->m_MPRActors->SetWindow( w );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+SetLevel( double l )
+{
+  this->m_MPRActors->SetLevel( l );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+SetWindowLevel( double w, double l )
+{
+  this->m_MPRActors->SetWindowLevel( w, l );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+ResetWindowLevel( )
+{
+  this->m_MPRActors->ResetWindowLevel( );
+}
+
+// -------------------------------------------------------------------------
+int cpExtensions::Visualization::MPRObjects::
+GetSliceNumber( const int& axis ) const
+{
+  return( this->m_MPRActors->GetSliceNumber( axis ) );
+}
+
+// -------------------------------------------------------------------------
+int cpExtensions::Visualization::MPRObjects::
+GetSliceNumberMinValue( const int& axis ) const
+{
+  return( this->m_MPRActors->GetSliceNumberMinValue( axis ) );
+}
+
+// -------------------------------------------------------------------------
+int cpExtensions::Visualization::MPRObjects::
+GetSliceNumberMaxValue( const int& axis ) const
+{
+  return( this->m_MPRActors->GetSliceNumberMaxValue( axis ) );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+SetSliceNumber( const int& axis, const int& slice )
+{
+  this->m_MPRActors->SetSliceNumber( axis, slice );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+SetSlice( const int& axis, double* pos )
+{
+  this->m_MPRActors->SetSlice( axis, pos );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+Render( const double& t )
+{
+  this->Render( 0, t );
+  this->Render( 1, t );
+  this->Render( 2, t );
+  this->Render( 3, t );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+Render( const int& axis, const double& t )
+{
+  if( axis < 4 )
+  {
+    if( this->m_Windows[ axis ].GetPointer( ) != NULL )
+    {
+      if( this->m_Renderers[ axis ].GetPointer( ) != NULL )
+        this->m_Renderers[ axis ]->SetAllocatedRenderTime( t );
+      this->m_Windows[ axis ]->Render( );
 
     } // fi
 
-    // Create renderer, if render window exists
-    this->m_Renderers[ i ] = vtkSmartPointer< vtkRenderer >::New( );
-    this->m_Renderers[ i ]->SetBackground( 0.1, 0.3, 0.8 );
-    this->m_Windows[ i ]->AddRenderer( this->m_Renderers[ i ] );
+  } // fi
+}
 
-  } // rof
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+ResetCamera( const int& axis )
+{
+  if( axis < 4 )
+    if( this->m_Renderers[ axis ].GetPointer( ) != NULL )
+      this->m_Renderers[ axis ]->ResetCamera( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+ResetCameras( )
+{
+  this->ResetCamera( 0 );
+  this->ResetCamera( 1 );
+  this->ResetCamera( 2 );
+  this->ResetCamera( 3 );
+}
+
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::MPRObjects::
+MPRObjects( )
+  : vtkObject( )
+{
+  this->m_MPRActors = vtkSmartPointer< MPRActors >::New( );
+}
 
-  // Create 3D renderer
-  if( this->m_Windows[ 3 ] != NULL )
-    this->m_Renderers[ 3 ]->SetBackground( 0.2, 0.2, 0.2 );
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::MPRObjects::
+~MPRObjects( )
+{
+}
+
+
+
+
+/*
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+SetRenderWindows(
+  vtkRenderWindow* wx, vtkRenderWindow* wy,
+  vtkRenderWindow* wz, vtkRenderWindow* w3D
+  )
+{
 }
 
 // -------------------------------------------------------------------------
@@ -241,5 +496,6 @@ cpExtensions::Visualization::MPRObjects::
 ~MPRObjects( )
 {
 }
+*/
 
 // eof - $RCSfile$
index c21fca66f55e2fc36614e1442e502ad0c6af86a7..a1ed436206578245922369eedadfbaadaf260ea4 100644 (file)
@@ -8,6 +8,13 @@
 #include <vtkRenderer.h>
 #include <vtkRenderWindow.h>
 
+// -------------------------------------------------------------------------
+#define cpExtensions_MPRObjects_Renderer( DIR )                         \
+  inline vtkRenderer* Get##DIR##Renderer( )                             \
+  { return( this->m_Renderers[ Self::MPRDirections_##DIR ] ); }         \
+  inline const vtkRenderer* Get##DIR##Renderer( ) const                 \
+  { return( this->m_Renderers[ Self::MPRDirections_##DIR ] ); }
+
 namespace cpExtensions
 {
   namespace Visualization
@@ -33,39 +40,73 @@ namespace cpExtensions
       typedef MPRActors::TEnterCommand            TEnterCommand;
       typedef MPRActors::TLeaveCommand            TLeaveCommand;
 
+      enum MPRDirections
+      {
+        MPRDirections_X = 0,
+        MPRDirections_Y = 1,
+        MPRDirections_Z = 2,
+        MPRDirections_W = 3
+      };
+
     public:
       vtkTypeMacro( MPRObjects, vtkObject );
 
+      cpExtensions_MPRObjects_Renderer( X );
+      cpExtensions_MPRObjects_Renderer( Y );
+      cpExtensions_MPRObjects_Renderer( Z );
+      cpExtensions_MPRObjects_Renderer( W );
+
     public:
       // Creation
       static MPRObjects* New( );
 
+      // Association
       void SetRenderWindows(
-        vtkRenderWindow* wx, vtkRenderWindow* wy,
-        vtkRenderWindow* wz, vtkRenderWindow* w3D
+        vtkRenderWindow* x, vtkRenderWindow* y,
+        vtkRenderWindow* z, vtkRenderWindow* w
+        );
+
+      void SetInputConnection( vtkAlgorithmOutput* aout );
+      void SetInputImage( vtkImageData* data );
+      int AddBinaryConnection(
+        vtkAlgorithmOutput* aout,
+        const double& r, const double& g, const double& b
         );
-      void AddImage( vtkImageData* image );
+      int AddBinaryImage(
+        vtkImageData* data,
+        const double& r, const double& g, const double& b
+        );
+      void Clear( );
+
+      vtkImageData* GetInputImage( );
+      const vtkImageData* GetInputImage( ) const;
       unsigned int GetNumberOfImages( ) const;
-      void ClearAll( );
 
-      void ResetCamera( const int& id );
-      void ResetCameras( );
-      void Render( const int& id, const double& t );
-      void RenderAll( const double& t );
-      vtkRenderer* GetXRenderer( );
-      vtkRenderer* GetYRenderer( );
-      vtkRenderer* GetZRenderer( );
-      vtkRenderer* Get3DRenderer( );
-      const vtkRenderer* GetXRenderer( ) const;
-      const vtkRenderer* GetYRenderer( ) const;
-      const vtkRenderer* GetZRenderer( ) const;
-      const vtkRenderer* Get3DRenderer( ) const;
-
-      MPRActors* GetMPRActors( );
-      const MPRActors* GetMPRActors( ) const;
+      void SetInterpolate( bool v );
+      void InterpolateOn( );
+      void InterpolateOff( );
 
+      double GetMinWindow( ) const;
+      double GetMaxWindow( ) const;
+      double GetMinLevel( ) const;
+      double GetMaxLevel( ) const;
       double GetWindow( ) const;
       double GetLevel( ) const;
+      void SetWindow( double w );
+      void SetLevel( double l );
+      void SetWindowLevel( double w, double l );
+      void ResetWindowLevel( );
+
+      int GetSliceNumber( const int& axis ) const;
+      int GetSliceNumberMinValue( const int& axis ) const;
+      int GetSliceNumberMaxValue( const int& axis ) const;
+      void SetSliceNumber( const int& axis, const int& slice );
+      void SetSlice( const int& axis, double* pos );
+
+      void Render( const double& t );
+      void Render( const int& axis, const double& t );
+      void ResetCamera( const int& axis );
+      void ResetCameras( );
 
     protected:
       MPRObjects( );
index 1bf778f1b7cbf729351060892fd26ddce6ecbd2a..ee6e5869075359e551bb07fdd31df17dcef3b850 100644 (file)
@@ -143,7 +143,7 @@ DeleteData( const std::string& name )
 void cpPlugins::Interface::BaseMPRWidget::
 DeleteAllData( )
 {
-  this->m_MPRObjects->ClearAll( );
+  this->m_MPRObjects->Clear( );
   this->m_Data.clear( );
   this->m_Tree.clear( );
   this->m_UI->LoadedData->clear( );
@@ -180,7 +180,8 @@ ShowData( const std::string& name )
 
   if( iIt->second.Tag == Data::IMAGE )
   {
-    this->m_MPRObjects->AddImage( iIt->second.Image );
+    // TODO: this->m_MPRObjects->AddImage( iIt->second.Image );
+#error ACA VOY
   }
   else if( iIt->second.Tag == Data::MESH )
   {