]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/QT/SimpleMPRWidget.cxx
Visual properties dialog finished.
[cpPlugins.git] / lib / cpExtensions / QT / SimpleMPRWidget.cxx
index 836bd7bdd7c9cb6765b856169925e43031d5c656..a020fb9e3d7e0c80207922e3827ae2016e131279 100644 (file)
@@ -3,6 +3,7 @@
 #ifdef cpExtensions_QT4
 
 #include <cpExtensions/ui_SimpleMPRWidget.h>
+#include <vtkRenderer.h>
 #include <vtkRenderWindow.h>
 
 // -------------------------------------------------------------------------
@@ -42,6 +43,7 @@ SimpleMPRWidget( QWidget* parent )
 cpExtensions::QT::SimpleMPRWidget::
 ~SimpleMPRWidget( )
 {
+  this->Clear( );
   delete this->m_UI;
 }
 
@@ -59,12 +61,12 @@ Clear( )
       this->m_3DSlices[ i ]->Clear( );
 
   } // rof
-  this->m_PolyDatas.clear( );
+  this->m_NamedActors.clear( );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::QT::SimpleMPRWidget::
-SetMainImage( vtkImageData* image )
+SetMainImage( vtkImageData* image, const std::string& name )
 {
   this->Clear( );
   for( unsigned int i = 0; i < 3; ++i )
@@ -85,13 +87,20 @@ SetMainImage( vtkImageData* image )
         )
       );
 
+    this->m_NamedActors[ name ].insert(
+      this->m_2DSlices[ i ]->GetImageActor( )
+      );
+    this->m_NamedActors[ name ].insert(
+      this->m_3DSlices[ i ]->GetImageActor( )
+      );
+
   } // rof
   this->_AssociateSlices( );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::QT::SimpleMPRWidget::
-SetMainActor( vtkImageActor* actor )
+SetMainActor( vtkImageActor* actor, const std::string& name )
 {
   this->Clear( );
   vtkImageData* image = NULL;
@@ -119,13 +128,20 @@ SetMainActor( vtkImageActor* actor )
         )
       );
 
+    this->m_NamedActors[ name ].insert(
+      this->m_2DSlices[ i ]->GetImageActor( )
+      );
+    this->m_NamedActors[ name ].insert(
+      this->m_3DSlices[ i ]->GetImageActor( )
+      );
+
   } // rof
   this->_AssociateSlices( );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::QT::SimpleMPRWidget::
-AddImage( vtkImageData* image )
+AddImage( vtkImageData* image, const std::string& name )
 {
   std::cerr << "SimpleMPR: adding image" << std::endl;
   std::exit( 1 );
@@ -133,7 +149,7 @@ AddImage( vtkImageData* image )
 
 // -------------------------------------------------------------------------
 void cpExtensions::QT::SimpleMPRWidget::
-AddImageActor( vtkImageActor* actor )
+AddImageActor( vtkImageActor* actor, const std::string& name )
 {
   unsigned int i = 0;
   bool cont = true;
@@ -155,12 +171,12 @@ AddImageActor( vtkImageActor* actor )
 
   // Add if no actors were found
   if( cont )
-    this->SetMainActor( actor );
+    this->SetMainActor( actor, name );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::QT::SimpleMPRWidget::
-AddMesh( vtkPolyData* mesh )
+AddMesh( vtkPolyData* mesh, const std::string& name )
 {
   std::cerr << "SimpleMPR: adding mesh" << std::endl;
   std::exit( 1 );
@@ -194,29 +210,43 @@ AddMesh( vtkPolyData* mesh )
 
 // -------------------------------------------------------------------------
 void cpExtensions::QT::SimpleMPRWidget::
-AddMeshActor( vtkProp3D* actor )
+AddMeshActor( vtkProp3D* actor, const std::string& name )
 {
   if( actor != NULL )
   {
     this->m_Renderers[ 3 ]->AddViewProp( actor );
     this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
+    this->m_NamedActors[ name ].insert( actor );
 
   } // fi
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::QT::SimpleMPRWidget::
-AddActor( vtkProp* actor )
+AddActor( vtkProp* actor, const std::string& name )
 {
   auto ia = dynamic_cast< vtkImageActor* >( actor );
   if( ia == NULL )
   {
     auto ma = dynamic_cast< vtkActor* >( actor );
     if( ma != NULL )
-      this->AddMeshActor( ma );
+      this->AddMeshActor( ma, name );
   }
   else
-    this->AddImageActor( ia );
+    this->AddImageActor( ia, name );
+}
+
+// -------------------------------------------------------------------------
+const cpExtensions::QT::SimpleMPRWidget::
+TActors& cpExtensions::QT::SimpleMPRWidget::
+GetActors( const std::string& name ) const
+{
+  static const TActors empty;
+  auto i = this->m_NamedActors.find( name );
+  if( i != this->m_NamedActors.end( ) )
+    return( i->second );
+  else
+    return( empty );
 }
 
 // -------------------------------------------------------------------------