]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/Plugins.h
Cast image filter added. ROI filter modified.
[cpPlugins.git] / lib / cpPlugins / Interface / Plugins.h
index 8eb4d3c451945efd4ab43111cca74ba13a50ce9b..3bffe02cf3592e5a230621b111090390d7c8397a 100644 (file)
-#ifndef __CPPLUGINS__INTERFACE__PLUGINS__H__
-#define __CPPLUGINS__INTERFACE__PLUGINS__H__
-
-#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
+#ifndef __cpPlugins__Interface__Plugins__h__
+#define __cpPlugins__Interface__Plugins__h__
 
+#include <cpPlugins/Config.h>
+#include <cpPlugins/BaseObjects/ProcessObject.h>
+#include <itkObject.h>
 #include <map>
 #include <set>
 #include <string>
 
-#include <cpPlugins/Interface/Interface.h>
-#include <cpPlugins/Interface/ProcessObject.h>
-#include <cpPlugins/Interface/Image.h>
-#include <cpPlugins/Interface/Mesh.h>
-
-class QObject;
-class QMenu;
-class QWidget;
-class vtkRenderWindowInteractor;
-
 namespace cpPlugins
 {
   namespace Interface
   {
-    class BasePluginsApplication;
-
     /**
      */
-    class cpPlugins_Interface_EXPORT Plugins
+    class cpPlugins_EXPORT Plugins
+      : public itk::Object
     {
     public:
-      typedef cpPlugins::Interface::Interface     TInterface;
-      typedef cpPlugins::Interface::ProcessObject TProcessObject;
-      typedef cpPlugins::Interface::DataObject    TDataObject;
-      typedef cpPlugins::Interface::Image         TImage;
-      typedef cpPlugins::Interface::Mesh          TMesh;
-      typedef TProcessObject::TParameters         TParameters;
-
-      typedef std::set< std::string >           TOrderedStringContainer;
-      typedef std::map< std::string, std::set< std::string > > TFilters;
-      typedef std::pair< std::string, TDataObject::Pointer >  TTreeNode;
-      typedef std::map< std::string, TTreeNode >                  TTree;
+      typedef Plugins                         Self;
+      typedef itk::Object                     Superclass;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
+
+      typedef std::pair< void*, void* >           THandlers;
+      typedef std::pair< std::string, THandlers > TLibData;
+      typedef std::map< std::string, TLibData >   TLibraries;
+      typedef std::map< std::string, TLibraries > TFilters;
 
     public:
-      Plugins( QWidget* widget = NULL );
-      virtual ~Plugins( );
+      itkTypeMacro( Plugins, itk::Object );
 
-      QWidget* GetWidget( );
-      const QWidget* GetWidget( ) const;
-      void SetWidget( QWidget* widget );
-      void BlockWidget( );
-      void UnblockWidget( );
-      void DialogLoadPlugins( );
-      void AssociatePluginsToMenu(
-        QMenu* menu, QObject* obj, const char* slot
-        );
-
-      BasePluginsApplication* GetApplication( );
-      const BasePluginsApplication* GetApplication( ) const;
-      void SetApplication( BasePluginsApplication* a );
-
-      bool LoadPlugins( );
-      bool LoadPlugins( const std::string& fname );
-      bool LoadPluginsConfigurationFile( const std::string& fname );
-
-      // Interactors
-      void AddInteractor( vtkRenderWindowInteractor* interactor );
-      void RemoveInteractor( vtkRenderWindowInteractor* interactor );
-      void ClearInteractors( );
-
-      // Data IO
-      bool HasImageReader( ) const;
-      bool HasDicomSeriesReader( ) const;
-      bool HasMeshReader( ) const;
-      bool HasImageWriter( ) const;
-      bool HasMeshWriter( ) const;
-
-      std::string ReadImage(
-        const std::string& fname, const std::string& parent
-        );
-      std::string ReadImage(
-        const std::vector< std::string >& fnames, const std::string& parent
-        );
-      std::string ReadImage( const std::string& parent );
-      std::string ReadDicomSeries( const std::string& parent );
-      std::string ReadMesh(
-        const std::string& fname, const std::string& parent
-        );
-      std::string ReadMesh( const std::string& parent );
-
-      bool WriteImage( const std::string& fname, const std::string& name );
-      bool WriteImage( const std::string& name );
-      bool WriteMesh( const std::string& fname, const std::string& name );
-      bool WriteMesh( const std::string& name );
-
-      // Data objects
-      void ClearDataObjects( );
-      void DeleteDataObject( const std::string& name );
-      std::string GetParent( const std::string& name ) const;
-      const TTree& GetDataObjects( ) const;
-      TDataObject* GetDataObject( const std::string& name );
-      const TDataObject* GetDataObject( const std::string& name ) const;
-      TImage* GetImage( const std::string& name );
-      const TImage* GetImage( const std::string& name ) const;
-      TMesh* GetMesh( const std::string& name );
-      const TMesh* GetMesh( const std::string& name ) const;
-
-      // Filter acces
-      bool ActivateFilter( const std::string& name );
-      void DeactivateFilter( );
-      bool HasActiveFilter( ) const;
-      bool IsActiveFilterInteractive( ) const;
-      unsigned int GetNumberOfInputsInActiveFilter( ) const;
-      unsigned int GetNumberOfOutputsInActiveFilter( ) const;
-      std::vector< std::string > GetActiveFilterInputsNames( ) const;
-      std::vector< std::string > GetActiveFilterOutputsNames( ) const;
-      void ConnectInputInActiveFilter(
-        const std::string& object_name, const std::string& input
-        );
-      void SetOutputNameInActiveFilter(
-        const std::string& new_name, const std::string& output
-        );
-      TParameters* GetActiveFilterParameters( );
-      const TParameters* GetActiveFilterParameters( ) const;
-      TProcessObject::DialogResult ConfigureActiveFilter( );
-      std::string UpdateActiveFilter( std::vector< std::string >& outputs );
+    public:
+      static Pointer New( );
+      virtual itk::LightObject::Pointer CreateAnother( ) const cpPlugins_OVERRIDE;
+      Pointer Clone( ) const;
+
+      const TFilters& GetFilters( ) const;
+
+      void LoadPluginsFile( const std::string& libname );
+      void LoadPluginsDirectory( const std::string& dir );
+      void GuessPlugins( );
+      void GuessEnvironment( const std::string& dir );
+      bool SaveEnvironment( const std::string& dir );
+
+      cpPlugins::BaseObjects::ProcessObject::Pointer
+      CreateFilter( const std::string& category, const std::string& name );
 
     protected:
-      void _UpdateLoadedPluginsInformation( );
-      bool _InsertNewData( TDataObject* dobj, const std::string& parent );
+      Plugins( );
+      virtual ~Plugins( );
+      virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const cpPlugins_OVERRIDE;
+
+      void _ReadPluginsPathsVariable( );
+
+    private:
+      // Purposely not implemented
+      Plugins( const Self& other );
+      Self& operator=( const Self& other );
 
     protected:
-      QWidget* m_Widget;
-      BasePluginsApplication* m_Application;
-
-      TInterface              m_Interface;
-      TOrderedStringContainer m_LoadedPlugins;
-      std::string             m_LastLoadedPlugin;
-
-      TProcessObject::Pointer              m_ImageReader;
-      TProcessObject::Pointer              m_ImageWriter;
-      TProcessObject::Pointer              m_MeshReader;
-      TProcessObject::Pointer              m_MeshWriter;
-      TProcessObject::Pointer              m_DicomSeriesReader;
-      TProcessObject::Pointer              m_ActiveFilter;
-      std::map< std::string, std::string > m_ActiveFilterOutputs;
-      TFilters m_Filters;
-
-      // Loaded objects
-      TTree m_Objects;
-
-      // Associated interactors
-      std::set< vtkRenderWindowInteractor* > m_Interactors;
+      static Pointer          m_Singleton;
+      std::set< std::string > m_PluginsPaths;
+      TFilters                m_Filters;
     };
 
   } // ecapseman
 
 } // ecapseman
 
-#endif // __CPPLUGINS__INTERFACE__PLUGINS__H__
+#endif // __cpPlugins__Interface__Plugins__h__
 
 // eof - $RCSfile$