]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/Workspace.h
debug finished
[cpPlugins.git] / lib / cpPlugins / Interface / Workspace.h
index 863d84e7d9c597ebf224efe761a6c854ff27bd76..2925a06485e354637d6ce03ab91c0c7e68d63ae2 100644 (file)
-#ifndef __CPPLUGINS__INTERFACE__WORKSPACE__H__
-#define __CPPLUGINS__INTERFACE__WORKSPACE__H__
+#ifndef __cpPlugins__Interface__Workspace__h__
+#define __cpPlugins__Interface__Workspace__h__
 
-#include <cpPlugins/Interface/Interface.h>
-#include <cpPlugins/Interface/DataObject.h>
-#include <cpPlugins/Interface/ProcessObject.h>
+#include <cpPlugins/Interface/Plugins.h>
+#include <cpPlugins/BaseObjects/DataObject.h>
+#include <cpPlugins/BaseObjects/ProcessObject.h>
+#include <cpPlugins/BaseObjects/Widget.h>
+#include <itkObject.h>
 
-#include <map>
-#include <set>
-#include <string>
+class vtkRenderWindowInteractor;
 
 namespace cpPlugins
 {
   namespace Interface
   {
-    /**
+    /** \brief A complex pipeline
      */
-    class cpPlugins_Interface_EXPORT Workspace
+    class cpPlugins_EXPORT Workspace
+      : public itk::Object
     {
     public:
-      typedef cpPlugins::Interface::Interface     TInterface;
-      typedef cpPlugins::Interface::Object        TObject;
-      typedef cpPlugins::Interface::ProcessObject TFilter;
-      typedef cpPlugins::Interface::DataObject    TData;
-      typedef TFilter::TParameters                TParameters;
-
-      // Various types
-      typedef std::set< std::string > TStringContainer;
-
-      // Graph types
-      typedef std::map< std::string, TObject::Pointer > TVertices;
-      typedef std::pair< std::string, std::string >     TConnection;
-      typedef std::vector< TConnection >                TConnections;
-      typedef std::map< std::string, TConnections >     TAdjMatrixRow;
-      typedef std::map< std::string, TAdjMatrixRow >    TAdjMatrix;
+      typedef Workspace                       Self;
+      typedef itk::Object                     Superclass;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
 
-    public:
-      Workspace( );
-      virtual ~Workspace( );
+      typedef cpPlugins::BaseObjects::DataObject    TDataObject;
+      typedef cpPlugins::BaseObjects::ProcessObject TFilter;
+      typedef cpPlugins::BaseObjects::Widget        TWidget;
+      typedef cpPlugins::Interface::Plugins         TPlugins;
+
+      typedef std::map< std::string, TFilter::Pointer > TFilters;
+
+      /* TODO
+         typedef
+         std::map< std::string, std::pair< std::string, std::string > >
+         TExposedPorts;
+      */
 
-      // Plugins management
-      bool LoadPluginsPath( const std::string& path, bool r = false );
-      bool LoadPlugins( const std::string& fname );
-      const TStringContainer& GetLoadedPlugins( ) const;
-      void GetLoadedPluginCategories( TStringContainer& categories ) const;
-      void GetLoadedPluginFilters( TStringContainer& filters ) const;
-      const TStringContainer& GetLoadedPluginFilters(
-        const std::string& category
-        ) const;
+    public:
+      cpPluginsNewMacro( Self );
+      itkTypeMacro( Workspace, itk::Object );
 
+    public:
       // Workspace IO
-      std::string LoadWorkspace( const std::string& fname );
-      std::string SaveWorkspace( const std::string& fname ) const;
+      void Load( const std::string& fname );
+      void Save( const std::string& fname ) const;
+
+      // Memory management
+      void Clear( );
+
+      // Filter management
+      std::vector< std::string > GetFiltersNames( ) const;
+      TFilter* GetFilter( const std::string& name );
+      const TFilter* GetFilter( const std::string& name ) const;
+      TWidget* GetWidget( const std::string& name );
+      const TWidget* GetWidget( const std::string& name ) const;
+      bool HasFilter( const std::string& name ) const;
+      bool HasWidget( const std::string& name ) const;
+      TFilter* CreateFilter(
+        const std::string& category, const std::string& filter
+        );
+      bool RenameFilter(
+        const std::string& old_name, const std::string& new_name
+        );
+      bool RemoveFilter( const std::string& name );
+
+      void SetPrintExecution( bool b );
+      void PrintExecutionOn( );
+      void PrintExecutionOff( );
 
-      // Graph management
-      bool CreateFilter( const std::string& filter, const std::string& name );
+      // Interactors
+      void AddInteractor( vtkRenderWindowInteractor* iren );
+
+      // Connection management
+      bool Connect(
+        const std::string& origin_filter,
+        const std::string& origin_output,
+        const std::string& destination_filter,
+        const std::string& destination_input
+        );
       bool Connect(
-        const std::string& orig_filter, const std::string& dest_filter,
-        const std::string& output_name,
-        const std::string& input_name
+        TDataObject* input,
+        const std::string& destination_filter,
+        const std::string& destination_input
+        );
+      bool Disconnect(
+        const std::string& origin_filter,
+        const std::string& origin_output,
+        const std::string& destination_filter,
+        const std::string& destination_input
         );
-      TParameters* GetParameters( const std::string& name );
-      const TParameters* GetParameters( const std::string& name ) const;
 
-      // Graph reduction
-      bool Reduce( const std::string& name );
+      /* TODO
+         std::vector< std::pair< std::string, std::string > > GetConnections(
+         const std::string& origin, const std::string& destination
+         ) const;
+         void Connect(
+         const std::string& orig_filter, const std::string& dest_filter,
+         const std::string& output_name, const std::string& input_name
+         );
+         void Connect(
+         cpPlugins::BaseObjects::DataObject* output,
+         const std::string& dest_filter, const std::string& input_name
+         );
+         void Connect(
+         cpPlugins::BaseObjects::DataObject* output,
+         const std::string& exposed_input_name
+         );
+         void Disconnect(
+         const std::string& orig_filter, const std::string& dest_filter,
+         const std::string& output_name, const std::string& input_name
+         );
+         void Disconnect(
+         const std::string& dest_filter, const std::string& input_name
+         );
+         void Disconnect( const std::string& dest_filter );
+      */
 
       // Pipeline execution
-      std::string Execute( );
-      std::string Execute( const std::string& name );
+      void Update( );
+      void Update( const std::string& name );
 
     protected:
-      void _UpdateLoadedPluginsInformation( );
+      Workspace( );
+      virtual ~Workspace( );
+
+    private:
+      // Purposely not implemented
+      Workspace( const Self& other );
+      Self& operator=( const Self& other );
 
     protected:
-      // Plugins interface
-      TInterface       m_Interface;
-      std::string      m_LastLoadedPlugin;
-      TStringContainer m_LoadedPlugins;
-      std::map< std::string, TStringContainer > m_LoadedFilters;
-
-      // Processing graph
-      TVertices  m_Vertices;
-      TAdjMatrix m_AdjMatrix;
+      TPlugins::Pointer m_Plugins;
+      TFilters m_Filters;
+      bool     m_PrintExecution;
+
+      /* TODO
+         TExposedPorts m_ExposedInputs;
+         TExposedPorts m_ExposedOutputs;
+      */
+
+      std::set< vtkRenderWindowInteractor* > m_Interactors;
     };
 
   } // ecapseman
 
 } // ecapseman
 
-#endif // __CPPLUGINS__INTERFACE__WORKSPACE__H__
+#endif // __cpPlugins__Interface__Workspace__h__
 
 // eof - $RCSfile$