]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/Workspace.h
...
[cpPlugins.git] / lib / cpPlugins / Interface / Workspace.h
index 92315d71fb8c0116b45d1c4199584fbccc425f01..fd9847b20a81b58215082a795e32bf6d0a81d8bb 100644 (file)
@@ -1,16 +1,13 @@
-#ifndef __CPPLUGINS__INTERFACE__WORKSPACE__H__
-#define __CPPLUGINS__INTERFACE__WORKSPACE__H__
+#ifndef __cpPlugins__Interface__Workspace__h__
+#define __cpPlugins__Interface__Workspace__h__
 
-#include <cpExtensions/DataStructures/Graph.h>
-#include <cpPlugins/Interface/Interface.h>
-#include <cpPlugins/Interface/DataObject.h>
-#include <cpPlugins/Interface/ProcessObject.h>
+#include <cpPlugins/Interface/Loader.h>
+#include <cpPlugins/Pipeline/DataObject.h>
+#include <cpPlugins/Pipeline/ProcessObject.h>
+#include <cpPlugins/Pipeline/Widget.h>
+#include <itkObject.h>
 
-#include <set>
-#include <string>
-
-// Some forward declarations
-class QWidget;
+class vtkRenderWindowInteractor;
 
 namespace cpPlugins
 {
@@ -18,116 +15,142 @@ namespace cpPlugins
   {
     /** \brief A complex pipeline
      */
-    class cpPlugins_Interface_EXPORT Workspace
+    class cpPlugins_EXPORT Workspace
+      : public itk::Object
     {
     public:
-      typedef cpPlugins::Interface::Interface     TPlugins;
-      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;
-      typedef std::pair< std::string, std::string > TExposedPort;
-      typedef std::map< std::string, TExposedPort > TExposedPorts;
-
-      // Graph type
-      typedef std::pair< std::string, std::string > TConnection;
-      typedef
-        cpExtensions::DataStructures::
-        Graph< TObject::Pointer, TConnection, std::string > TGraph;
+      typedef Workspace                       Self;
+      typedef itk::Object                     Superclass;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
 
-    public:
-      Workspace( );
-      virtual ~Workspace( );
+      typedef cpPlugins::Pipeline::DataObject    TDataObject;
+      typedef cpPlugins::Pipeline::ProcessObject TFilter;
+      typedef cpPlugins::Pipeline::Widget        TWidget;
+      typedef cpPlugins::Interface::Loader          TLoader;
 
-      // Plugins management
-      TPlugins* GetPlugins( );
-      const TPlugins* GetPlugins( ) const;
-      void SetPlugins( TPlugins* i );
+      typedef std::map< std::string, TFilter::Pointer > TFilters;
 
-      // Workspace IO
-      std::string LoadWorkspace( const std::string& fname );
-      std::string SaveWorkspace( const std::string& fname ) const;
+      /* TODO
+         typedef
+         std::map< std::string, std::pair< std::string, std::string > >
+         TExposedPorts;
+      */
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( Workspace, itk::Object );
 
-      // Graph management
-      TGraph* GetGraph( );
-      const TGraph* GetGraph( ) const;
+    public:
+      // Workspace IO
+      void Load( const std::string& fname );
+      void Save( const std::string& fname ) const;
 
+      // Memory management
       void Clear( );
-      void ClearConnections( );
 
       // 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 CreateFilter( const std::string& filter, const std::string& name );
+      bool HasWidget( const std::string& name ) const;
+      TFilter* CreateFilter(
+        const std::string& category, const std::string& filter,
+        const std::string& name
+        );
+      TFilter* CreateFilter(
+        const std::string& category, const std::string& filter
+        );
       bool RenameFilter(
         const std::string& old_name, const std::string& new_name
         );
-      void RemoveFilter( const std::string& 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& orig_filter, const std::string& dest_filter,
-        const std::string& output_name, const std::string& input_name
-        );
-      bool Connect( TData* input_object, const std::string& exposed_port );
-      void RemoveConnection(
-        const std::string& dest_filter, const std::string& input_name
+        const std::string& origin_filter,
+        const std::string& origin_output,
+        const std::string& destination_filter,
+        const std::string& destination_input
         );
-      void RemoveConnection( const std::string& exposed_port );
-      void RemoveConnections( const std::string& dest_filter );
-
-      // Graph reduction
-      bool Reduce( const std::string& name );
-      void ExposeInputPort(
-        const std::string& name,
-        const std::string& filter, const std::string& filter_input
+      bool Connect(
+        TDataObject* input,
+        const std::string& destination_filter,
+        const std::string& destination_input
         );
-      void ExposeOutputPort(
-        const std::string& name,
-        const std::string& filter, const std::string& filter_output
+      bool Disconnect(
+        const std::string& origin_filter,
+        const std::string& origin_output,
+        const std::string& destination_filter,
+        const std::string& destination_input
         );
-      void HideInputPort( const std::string& name );
-      void HideOutputPort( const std::string& name );
 
-      bool RenameExposedInputPort(
-        const std::string& old_name,
-        const std::string& new_name
-        );
-      bool RenameExposedOutputPort(
-        const std::string& old_name,
-        const std::string& new_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::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 );
+      */
 
-      const TExposedPorts& GetExposedInputPorts( ) const;
-      const TExposedPorts& GetExposedOutputPorts( ) const;
+      // Pipeline execution
+      void Update( );
+      void Update( const std::string& name );
 
-      TData* GetExposedInput( const std::string& name );
-      const TData* GetExposedInput( const std::string& name ) const;
-      TData* GetExposedOutput( const std::string& name );
-      const TData* GetExposedOutput( const std::string& name ) const;
+    protected:
+      Workspace( );
+      virtual ~Workspace( );
 
-      // Pipeline execution
-      std::string Execute( QWidget* p = NULL );
-      std::string Execute( const std::string& name, QWidget* p = NULL );
+    private:
+      // Purposely not implemented
+      Workspace( const Self& other );
+      Self& operator=( const Self& other );
 
     protected:
-      // Plugins interface
-      TPlugins* m_Plugins;
+      TLoader  m_Loader;
+      TFilters m_Filters;
+      bool     m_PrintExecution;
+
+      /* TODO
+         TExposedPorts m_ExposedInputs;
+         TExposedPorts m_ExposedOutputs;
+      */
 
-      // Processing graph
-      typename TGraph::Pointer m_Graph;
-      TExposedPorts m_ExposedInputPorts;
-      TExposedPorts m_ExposedOutputPorts;
+      std::set< vtkRenderWindowInteractor* > m_Interactors;
     };
 
   } // ecapseman
 
 } // ecapseman
 
-#endif // __CPPLUGINS__INTERFACE__WORKSPACE__H__
+#endif // __cpPlugins__Interface__Workspace__h__
 
 // eof - $RCSfile$