From: Leonardo Florez-Valencia <florez-l@javeriana.edu.co>
Date: Sat, 26 Sep 2015 09:17:41 +0000 (+0200)
Subject: MPR objects now support multiple images.
X-Git-Tag: v0.1~362^2
X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=c59ebadd7683100c1ee12bc13064efa592222528;p=cpPlugins.git

MPR objects now support multiple images.
---

diff --git a/appli/examples/example_MPR.cxx b/appli/examples/example_MPR.cxx
index 502302c..9f6e113 100644
--- a/appli/examples/example_MPR.cxx
+++ b/appli/examples/example_MPR.cxx
@@ -53,9 +53,9 @@ public:
       else if( title == "Z" )
         this->Actors->SetSlice( 2, int( rep->GetValue( ) ) );
       else if( title == "Window" )
-        this->Actors->SetWindow( rep->GetValue( ) );
+        this->Actors->SetWindow( 0, rep->GetValue( ) );
       else if( title == "Level" )
-        this->Actors->SetLevel( rep->GetValue( ) );
+        this->Actors->SetLevel( 0, rep->GetValue( ) );
     }
   SliderCallback( )
     : vtkCommand( )
@@ -178,7 +178,7 @@ int main( int argc, char* argv[] )
   // Actors
   vtkSmartPointer< TMPRActors > mpr_actors =
     vtkSmartPointer< TMPRActors >::New( );
-  mpr_actors->SetInputData( image );
+  mpr_actors->AddInputData( image );
   mpr_actors->PushDataInto( NULL, NULL, NULL, renderer );
 
   // Callbacks
@@ -208,16 +208,16 @@ int main( int argc, char* argv[] )
     0.500, 0.15, 0.690, 0.15, cb
     );
   Slider w_slider(
-    mpr_actors->GetMinWindow( ),
-    mpr_actors->GetMaxWindow( ),
-    mpr_actors->GetWindow( ),
+    mpr_actors->GetMinWindow( 0 ),
+    mpr_actors->GetMaxWindow( 0 ),
+    mpr_actors->GetWindow( 0 ),
     "Window", interactor,
     0.100, 0.05, 0.290, 0.05, cb
     );
   Slider l_slider(
-    mpr_actors->GetMinWindow( ),
-    mpr_actors->GetMaxWindow( ),
-    mpr_actors->GetWindow( ),
+    mpr_actors->GetMinWindow( 0 ),
+    mpr_actors->GetMaxWindow( 0 ),
+    mpr_actors->GetWindow( 0 ),
     "Level", interactor,
     0.300, 0.05, 0.490, 0.05, cb
     );
diff --git a/lib/cpExtensions/Visualization/ImageInteractorStyle.cxx b/lib/cpExtensions/Visualization/ImageInteractorStyle.cxx
index 9dec032..ab3fee3 100644
--- a/lib/cpExtensions/Visualization/ImageInteractorStyle.cxx
+++ b/lib/cpExtensions/Visualization/ImageInteractorStyle.cxx
@@ -42,7 +42,7 @@ Configure( ImageSliceActors* slice_actors, MPRActors* mpr_actors )
   this->m_SliceActors = slice_actors;
   this->m_MPRActors = mpr_actors;
   this->SetModeToNavigation( );
-  this->PropPicker->AddPickList( slice_actors->GetImageActor( ) );
+  this->PropPicker->AddPickList( slice_actors->GetImageActor( 0 ) );
   this->Modified( );
 }
 
@@ -363,7 +363,7 @@ OnChar( )
   {
     if( this->m_MPRActors != NULL )
     {
-      this->m_MPRActors->ResetWindowLevel( );
+      this->m_MPRActors->ResetWindowLevel( 0 );
       this->Interactor->Render( );
       this->_RenderAssociateInteractors( );
 
@@ -404,17 +404,18 @@ WindowLevel( )
 
     double w = this->WindowLevelInitial[ 0 ] * ( double( 1 ) + sw );
     double l = this->WindowLevelInitial[ 1 ] * ( double( 1 ) + sl );
-    double minw = this->m_MPRActors->GetMinWindow( );
-    double maxw = this->m_MPRActors->GetMaxWindow( );
-    double minl = this->m_MPRActors->GetMinLevel( );
-    double maxl = this->m_MPRActors->GetMaxLevel( );
+    double minw = this->m_MPRActors->GetMinWindow( 0 );
+    double maxw = this->m_MPRActors->GetMaxWindow( 0 );
+    double minl = this->m_MPRActors->GetMinLevel( 0 );
+    double maxl = this->m_MPRActors->GetMaxLevel( 0 );
 
     if( w < minw ) w = minw;
     if( maxw < w ) w = maxw;
     if( l < minl ) l = minl;
     if( maxl < l ) l = maxl;
 
-    this->m_MPRActors->SetWindowLevel( w, l );
+    this->m_MPRActors->SetWindow( 0, w );
+    this->m_MPRActors->SetLevel( 0, l );
     this->Interactor->Render( );
     this->_RenderAssociateInteractors( );
   }
@@ -435,8 +436,8 @@ StartWindowLevel( )
   {
     this->StartState( VTKIS_WINDOW_LEVEL );
 
-    this->WindowLevelInitial[ 0 ] = this->m_MPRActors->GetWindow( );
-    this->WindowLevelInitial[ 1 ] = this->m_MPRActors->GetLevel( );
+    this->WindowLevelInitial[ 0 ] = this->m_MPRActors->GetWindow( 0 );
+    this->WindowLevelInitial[ 1 ] = this->m_MPRActors->GetLevel( 0 );
   }
   else if( this->Mode == Self::DeformationMode )
   {
diff --git a/lib/cpExtensions/Visualization/MPRActors.cxx b/lib/cpExtensions/Visualization/MPRActors.cxx
index eea3b64..4be6864 100644
--- a/lib/cpExtensions/Visualization/MPRActors.cxx
+++ b/lib/cpExtensions/Visualization/MPRActors.cxx
@@ -14,6 +14,17 @@ New( )
   return( new Self( ) );
 }
 
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::
+ImageSliceActors* cpExtensions::Visualization::MPRActors::
+GetSliceActors( const int& i ) const
+{
+  if( i < 3 )
+    return( this->Slices[ 0 ][ i ] );
+  else
+    return( NULL );
+}
+
 // -------------------------------------------------------------------------
 int cpExtensions::Visualization::MPRActors::
 AddInputConnection( vtkAlgorithmOutput* aout )
diff --git a/lib/cpExtensions/Visualization/MPRActors.h b/lib/cpExtensions/Visualization/MPRActors.h
index 2566c1d..72389be 100644
--- a/lib/cpExtensions/Visualization/MPRActors.h
+++ b/lib/cpExtensions/Visualization/MPRActors.h
@@ -36,7 +36,7 @@ namespace cpExtensions
       // Creation
       static MPRActors* New( );
 
-      // TODO: ImageSliceActors* GetSliceActors( const int& i ) const;
+      ImageSliceActors* GetSliceActors( const int& i ) const;
 
       int AddInputConnection( vtkAlgorithmOutput* aout );
       int AddInputData( vtkImageData* image );
diff --git a/lib/cpExtensions/Visualization/MPRObjects.cxx b/lib/cpExtensions/Visualization/MPRObjects.cxx
index 9c14323..96e646a 100644
--- a/lib/cpExtensions/Visualization/MPRObjects.cxx
+++ b/lib/cpExtensions/Visualization/MPRObjects.cxx
@@ -77,7 +77,7 @@ SetRenderWindows(
 void cpExtensions::Visualization::MPRObjects::
 SetImage( vtkImageData* image )
 {
-  this->m_MPRActors->SetInputData( image );
+  this->m_MPRActors->AddInputData( image );
   this->m_MPRActors->PushDataInto(
     this->m_Renderers[ 0 ],
     this->m_Renderers[ 1 ],