]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/Visualization/MPRActors.cxx
...
[cpPlugins.git] / lib / cpExtensions / Visualization / MPRActors.cxx
index 25151abac3a4a2ea9f40b8700ec41667ed354030..e26651b4dd24098b7df304e741041789419694b0 100644 (file)
@@ -31,24 +31,34 @@ GetSliceActors( const int& i ) const
 void cpExtensions::Visualization::MPRActors::
 SetInputConnection( vtkAlgorithmOutput* aout )
 {
-  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 );
+  for( int i = 0; i < 2; ++i )
+  {
+    for( int j = 0; j < 3; ++j )
+    {
+      this->Slices[ i ][ j ]->SetInputConnection( aout );
+      this->Slices[ i ][ j ]->SetAxis( j );
+
+    } // rof
+
+  } // rof
+  this->_CreateBoundingBox( );
 }
 
 // -------------------------------------------------------------------------
 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 );
+  for( int i = 0; i < 2; ++i )
+  {
+    for( int j = 0; j < 3; ++j )
+    {
+      this->Slices[ i ][ j ]->SetInputImage( data );
+      this->Slices[ i ][ j ]->SetAxis( j );
+
+    } // rof
+
+  } // rof
+  this->_CreateBoundingBox( );
 }
 
 // -------------------------------------------------------------------------
@@ -159,7 +169,13 @@ PushActorsInto(
   vtkRenderer* wren =
     ( w != NULL )? w->GetRenderers( )->GetFirstRenderer( ): NULL;
   if( wren != NULL )
+  {
     wren->AddViewProp( this->ImageOutlineActor );
+    wren->AddViewProp( this->Slices[ 1 ][ 0 ]->GetPlaneActor( ) );
+    wren->AddViewProp( this->Slices[ 1 ][ 1 ]->GetPlaneActor( ) );
+    wren->AddViewProp( this->Slices[ 1 ][ 2 ]->GetPlaneActor( ) );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
@@ -181,7 +197,13 @@ PopActorsFrom(
   vtkRenderer* wren =
     ( w != NULL )? w->GetRenderers( )->GetFirstRenderer( ): NULL;
   if( wren != NULL )
+  {
     wren->RemoveViewProp( this->ImageOutlineActor );
+    wren->RemoveViewProp( this->Slices[ 1 ][ 0 ]->GetPlaneActor( ) );
+    wren->RemoveViewProp( this->Slices[ 1 ][ 1 ]->GetPlaneActor( ) );
+    wren->RemoveViewProp( this->Slices[ 1 ][ 2 ]->GetPlaneActor( ) );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
@@ -328,6 +350,52 @@ SetSlice( const int& axis, double* pos )
   } // fi
 }
 
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+SetAxesCursor( const int& axis, double* pos )
+{
+  if( axis < 3 )
+    this->Slices[ 0 ][ axis ]->SetAxesCursor( pos );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+Render( const int& axis )
+{
+  if( axis < 3 )
+  {
+    this->Slices[ 0 ][ axis ]->Render( );
+    this->Slices[ 1 ][ axis ]->Render( );
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+Render( )
+{
+  this->Render( 0 );
+  this->Render( 1 );
+  this->Render( 2 );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+ResetCamera( const int& axis )
+{
+  if( axis < 3 )
+    this->Slices[ 0 ][ axis ]->ResetCamera( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+ResetCameras( )
+{
+  this->ResetCamera( 0 );
+  this->ResetCamera( 1 );
+  this->ResetCamera( 2 );
+}
+
 // -------------------------------------------------------------------------
 cpExtensions::Visualization::MPRActors::
 MPRActors( )
@@ -396,8 +464,16 @@ _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->SetSlice( j, pos );
+      actors->SetAxesCursor( j, pos );
+      actors->Render( j );
+
+    } // fi
+
+  } // rof
 }
 
 // -------------------------------------------------------------------------
@@ -408,6 +484,7 @@ _WindowLevelCommand( double window, double level, void* data )
   if( actors == NULL )
     return;
   actors->SetWindowLevel( window, level );
+  actors->Render( );
 }
 
 // -------------------------------------------------------------------------
@@ -417,6 +494,7 @@ _RenderCommand( void* data )
   MPRActors* actors = reinterpret_cast< MPRActors* >( data );
   if( actors == NULL )
     return;
+  actors->Render( );
 }
 
 // eof - $RCSfile$