]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/Workspace.h
yet another refactoring
[cpPlugins.git] / lib / cpPlugins / Interface / Workspace.h
diff --git a/lib/cpPlugins/Interface/Workspace.h b/lib/cpPlugins/Interface/Workspace.h
new file mode 100644 (file)
index 0000000..745bd98
--- /dev/null
@@ -0,0 +1,152 @@
+#ifndef __cpPlugins__Interface__Workspace__h__
+#define __cpPlugins__Interface__Workspace__h__
+
+#include <cpPlugins/Interface/Loader.h>
+#include <cpPlugins/Pipeline/DataObject.h>
+#include <cpPlugins/Pipeline/ProcessObject.h>
+#include <cpPlugins/Pipeline/Widget.h>
+#include <itkObject.h>
+
+class vtkRenderWindowInteractor;
+
+namespace cpPlugins
+{
+  namespace Interface
+  {
+    /** \brief A complex pipeline
+     */
+    class cpPlugins_EXPORT Workspace
+      : public itk::Object
+    {
+    public:
+      typedef Workspace                       Self;
+      typedef itk::Object                     Superclass;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
+
+      typedef cpPlugins::Pipeline::DataObject    TDataObject;
+      typedef cpPlugins::Pipeline::ProcessObject TFilter;
+      typedef cpPlugins::Pipeline::Widget        TWidget;
+      typedef cpPlugins::Interface::Loader          TLoader;
+
+      typedef std::map< std::string, TFilter::Pointer > TFilters;
+
+      /* TODO
+         typedef
+         std::map< std::string, std::pair< std::string, std::string > >
+         TExposedPorts;
+      */
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( Workspace, itk::Object );
+
+    public:
+      // Workspace IO
+      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( );
+
+      // 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(
+        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
+        );
+
+      /* 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::Pipeline::DataObject* output,
+         const std::string& dest_filter, const std::string& input_name
+         );
+         void Connect(
+         cpPlugins::Pipeline::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
+      void Update( );
+      void Update( const std::string& name );
+
+    protected:
+      Workspace( );
+      virtual ~Workspace( );
+
+    private:
+      // Purposely not implemented
+      Workspace( const Self& other );
+      Self& operator=( const Self& other );
+
+    protected:
+      TLoader  m_Loader;
+      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__
+
+// eof - $RCSfile$