]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/BaseMPRWidget.h
Getting ready for interactive initialization.
[cpPlugins.git] / lib / cpPlugins / Interface / BaseMPRWidget.h
index 9ed62ceb7ede51cc041dc0a89cba61f14889c2cb..0807a87e1fa697b7b93fcd16d9ec3325d90a5305 100644 (file)
@@ -12,6 +12,7 @@
 #include <QWidget>
 
 #include <vtkSmartPointer.h>
+#include <vtkImageData.h>
 #include <vtkPolyDataMapper.h>
 #include <vtkPolyDataNormals.h>
 #include <vtkQuadricLODActor.h>
@@ -60,30 +61,56 @@ namespace cpPlugins
       explicit BaseMPRWidget( QWidget* parent = 0 );
       virtual ~BaseMPRWidget( );
 
+      // Data management
+      bool AddImage(
+        vtkImageData* image,
+        const std::string& name,
+        const std::string& parent = ""
+        );
+      bool AddMesh(
+        vtkPolyData* mesh,
+        const std::string& name,
+        const std::string& parent
+        );
+      void DeleteData( const std::string& name );
+      void DeleteAllData( );
+
       // Some visualization accessors
-      bool ShowImage(
+      void SetDataColor(
+        const std::string& name,
+        const double& r,
+        const double& g,
+        const double& b
+        );
+      void ShowData( const std::string& name );
+
+      vtkRenderWindowInteractor* GetInteractor( unsigned int i );
+
+      /*
+        bool ShowImage(
         vtkImageData* image,
         const std::string& name,
         const std::string& parent = ""
         );
-      bool ShowImage(
+        bool ShowImage(
         vtkImageData* image,
         const std::string& name,
         const std::string& parent,
         const double& r, const double& g, const double& b
         );
-      bool ShowMesh(
+        bool ShowMesh(
         vtkPolyData* mesh,
         const std::string& name,
         const std::string& parent
         );
-      bool ShowMesh(
+        bool ShowMesh(
         vtkPolyData* mesh,
         const std::string& name,
         const std::string& parent,
         const double& r, const double& g, const double& b
         );
-      void ClearAll( );
+        void ClearAll( );
+      */
 
       // Visual objects accessors
       std::string GetSelectedData( ) const;
@@ -94,8 +121,10 @@ namespace cpPlugins
         const std::string& name,
         const std::string& parent
         );
-      
-      void _Add3DActor( vtkProp3D* prop );
+
+      /* TODO
+         void _Add3DActor( vtkProp3D* prop );
+      */
 
     private slots:
       void _SyncBottom( int a, int b );
@@ -104,22 +133,67 @@ namespace cpPlugins
     protected:
       Ui::BaseMPRWidget*             m_UI;
       vtkSmartPointer< TMPRObjects > m_MPRObjects;
+      QVTKWidget*                    m_VTK[ 4 ];
 
       struct PolyDataActor
       {
+        vtkSmartPointer< vtkPolyData >        Mesh;
         vtkSmartPointer< vtkPolyDataNormals > Normals;
         vtkSmartPointer< vtkStripper >        Stripper;
         vtkSmartPointer< vtkPolyDataMapper >  Mapper;
         vtkSmartPointer< vtkQuadricLODActor > Actor;
 
-        PolyDataActor( vtkPolyData* pd );
+        void Configure( vtkPolyData* pd );
       };
 
-      std::map< std::string, vtkImageData* >  m_Images;
-      std::map< std::string, PolyDataActor* > m_Meshes;
-      std::map< std::string, std::string >    m_Tree;
+      struct Data
+      {
+        enum { IMAGE, MESH } Tag;
+        union
+        {
+          vtkImageData* Image;
+          PolyDataActor Mesh;
+        };
+
+        Data( ) { }
+        virtual ~Data( ) { }
+
+        inline Data& operator=( const Data& data )
+          {
+            this->Tag = data.Tag;
+            if( this->Tag == Data::IMAGE )
+              this->Image = data.Image;
+            else if( this->Tag == Data::MESH )
+              this->Mesh = data.Mesh;
+            return( *this );
+          }
+
+        inline vtkImageData* GetImage( )
+          {
+            if( this->Tag == Data::IMAGE )
+              return( this->Image );
+            else
+              return( NULL );
+          }
+        inline vtkPolyData* GetMesh( )
+          {
+            if( this->Tag == Data::MESH )
+              return( this->Mesh.Mesh.GetPointer( ) );
+            else
+              return( NULL );
+          }
+        inline vtkProp* GetMeshActor( )
+          {
+            if( this->Tag == Data::MESH )
+              return( this->Mesh.Actor.GetPointer( ) );
+            else
+              return( NULL );
+          }
+      };
 
-      QVTKWidget* m_VTK[ 4 ];
+      std::string m_MainImage;
+      std::map< std::string, Data >        m_Data;
+      std::map< std::string, std::string > m_Tree;
     };
 
   } // ecapseman