]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/Visualization/MPRObjects.cxx
Getting ready for interactive initialization.
[cpPlugins.git] / lib / cpExtensions / Visualization / MPRObjects.cxx
index 96e646a78f11bbf46c2e44991edb084c2934c266..a0c1f3eb64ace2ef98f0a279faa828ed1c1201f7 100644 (file)
@@ -1,5 +1,9 @@
 #include <cpExtensions/Visualization/MPRObjects.h>
 
+#include <cmath>
+#include <vtkImageData.h>
+#include <vtkLookupTable.h>
+
 // -------------------------------------------------------------------------
 cpExtensions::Visualization::MPRObjects*
 cpExtensions::Visualization::MPRObjects::
@@ -20,7 +24,7 @@ SetRenderWindows(
   this->m_Windows[ 2 ] = wz;
   this->m_Windows[ 3 ] = w3D;
 
-  // Prepare renderers
+  // Prepare 2D renderers
   for( int i = 0; i < 4; ++i )
   {
     if( this->m_Windows[ i ] == NULL )
@@ -30,72 +34,59 @@ SetRenderWindows(
 
     } // fi
 
-    // Renderers
+    // 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 ] );
 
-    // Image styles (just for 2D windows)
-    if( i < 3 )
-    {
-      this->m_Styles[ i ] = vtkSmartPointer< TStyle >::New( );
-      this->m_Styles[ i ]->Configure(
-        this->m_MPRActors->GetSliceActors( i ), this->m_MPRActors
-        );
-
-      this->m_Styles[ i ]->
-        SetInteractor( this->m_Windows[ i ]->GetInteractor( ), i );
-      this->m_Styles[ i ]->SetModeToNavigation( );
-
-    } // fi
-
   } // rof
+
+  // Create 3D renderer
   if( this->m_Windows[ 3 ] != NULL )
     this->m_Renderers[ 3 ]->SetBackground( 0.2, 0.2, 0.2 );
-
-  for( int i = 0; i < 3; ++i )
-  {
-    for( int j = 0; j < 3; ++j )
-    {
-      if(
-        this->m_Windows[ i ] != NULL &&
-        this->m_Windows[ j ] != NULL &&
-        i != j
-        )
-        this->m_Styles[ i ]->
-          AssociateInteractor( this->m_Windows[ j ]->GetInteractor( ) );
-
-    } // rof
-    if( this->m_Windows[ 3 ] != NULL )
-      this->m_Styles[ i ]->
-        AssociateInteractor( this->m_Windows[ 3 ]->GetInteractor( ) );
-
-  } // rof
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRObjects::
-SetImage( vtkImageData* image )
+AddImage( vtkImageData* image )
 {
   this->m_MPRActors->AddInputData( image );
-  this->m_MPRActors->PushDataInto(
-    this->m_Renderers[ 0 ],
-    this->m_Renderers[ 1 ],
-    this->m_Renderers[ 2 ],
-    this->m_Renderers[ 3 ]
+  this->m_MPRActors->PushActorsInto(
+    this->m_Windows[ 0 ],
+    this->m_Windows[ 1 ],
+    this->m_Windows[ 2 ],
+    this->m_Windows[ 3 ]
     );
 
-  // Correct cameras positions
-  /* TODO
-     vtkCamera* zCam = this->m_Renderers[ 2 ]->GetActiveCamera( );
-     zCam->SetViewUp( 0, -1, 0 );
-     zCam->SetPosition( 0, 0, -1 );
-     zCam->SetFocalPoint( 0, 0, 0 );
-  */
-
   // First rendering
+  if( this->m_MPRActors->GetNumberOfImages( ) == 1 )
+  {
+    this->m_MPRActors->ResetSlices( );
+    this->ResetCameras( );
+
+  } // fi
+  this->RenderAll( 1e-3 );
+}
+
+// -------------------------------------------------------------------------
+unsigned int cpExtensions::Visualization::MPRObjects::
+GetNumberOfImages( ) const
+{
+  return( this->m_MPRActors->GetNumberOfImages( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+ClearAll( )
+{
+  this->m_MPRActors->PopActorsFrom(
+    this->m_Windows[ 0 ],
+    this->m_Windows[ 1 ],
+    this->m_Windows[ 2 ],
+    this->m_Windows[ 3 ]
+    );
   this->ResetCameras( );
-  this->RenderAll( );
+  this->RenderAll( 1e-3 );
 }
 
 // -------------------------------------------------------------------------
@@ -118,20 +109,36 @@ ResetCameras( )
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRObjects::
-Render( const int& id )
+Render( const int& id, const double& t )
 {
   if( id < 4 )
+  {
     if( this->m_Windows[ id ] != NULL )
+    {
+      if( this->m_Renderers[ id ] != NULL )
+        this->m_Renderers[ id ]->SetAllocatedRenderTime( t );
       this->m_Windows[ id ]->Render( );
+      
+    } // fi
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRObjects::
-RenderAll( )
+RenderAll( const double& t )
 {
   for( int i = 0; i < 4; ++i )
+  {
     if( this->m_Windows[ i ] != NULL )
+    {
+      if( this->m_Renderers[ i ] != NULL )
+        this->m_Renderers[ i ]->SetAllocatedRenderTime( t );
       this->m_Windows[ i ]->Render( );
+
+    } // fi
+
+  } // rof
 }
 
 // -------------------------------------------------------------------------
@@ -190,13 +197,43 @@ Get3DRenderer( ) const
   return( this->m_Renderers[ 3 ] );
 }
 
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::
+MPRActors* cpExtensions::Visualization::MPRObjects::
+GetMPRActors( )
+{
+  return( this->m_MPRActors );
+}
+
+// -------------------------------------------------------------------------
+const cpExtensions::Visualization::
+MPRActors* cpExtensions::Visualization::MPRObjects::
+GetMPRActors( ) const
+{
+  return( this->m_MPRActors );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::MPRObjects::
+GetWindow( ) const
+{
+  return( this->m_MPRActors->GetWindow( ) );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::MPRObjects::
+GetLevel( ) const
+{
+  return( this->m_MPRActors->GetLevel( ) );
+}
+
 // -------------------------------------------------------------------------
 cpExtensions::Visualization::MPRObjects::
 MPRObjects( )
   : vtkObject( )
 {
   // Prepare actors
-  this->m_MPRActors = vtkSmartPointer< TMPRActors >::New( );
+  this->m_MPRActors = vtkSmartPointer< MPRActors >::New( );
 }
 
 // -------------------------------------------------------------------------