]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/Workspace.h
...
[cpPlugins.git] / lib / cpPlugins / Interface / Workspace.h
index 75ef769d9f53dfe9f58b2c7658c6d72d5c158795..428f13a72148727478c2cb4f1f0e156e142b94fd 100644 (file)
-#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/Plugins.h>
+#include <cpPlugins/BaseObjects/DataObject.h>
+#include <cpPlugins/BaseObjects/ProcessObject.h>
+#include <cpPlugins/BaseObjects/Widget.h>
+#include <itkObject.h>
 
-#include <set>
-#include <string>
-
-// Some forward declarations
-class QWidget;
 class vtkRenderWindowInteractor;
 
 namespace cpPlugins
 {
   namespace Interface
   {
-    // Some forward declarations
-#ifdef cpPlugins_Interface_QT4
-    class SimpleMPRWidget;
-#else // cpPlugins_Interface_QT4
-    typedef char SimpleMPRWidget;
-#endif // cpPlugins_Interface_QT4
-
     /** \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 Workspace                       Self;
+      typedef itk::Object                     Superclass;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
+
+      typedef cpPlugins::BaseObjects::ProcessObject TProcess;
+      typedef cpPlugins::BaseObjects::Widget        TWidget;
+      typedef cpPlugins::Interface::Plugins         TInterface;
+
+      typedef std::map< std::string, TProcess::Pointer > TFilters;
       typedef
-        cpExtensions::DataStructures::
-        Graph< TObject::Pointer, TConnection, std::string > TGraph;
+        std::map< std::string, std::pair< std::string, std::string > >
+        TExposedPorts;
 
     public:
-      Workspace( );
-      virtual ~Workspace( );
-
-      // Plugins management
-      TPlugins* GetPlugins( );
-      const TPlugins* GetPlugins( ) const;
-      void SetPlugins( TPlugins* i );
+      itkNewMacro( Self );
+      itkTypeMacro( Workspace, itk::Object );
 
+    public:
       // Workspace IO
-      std::string LoadWorkspace( const std::string& fname );
-      std::string SaveWorkspace( const std::string& fname ) const;
-
-      // Graph management
-      TGraph* GetGraph( );
-      const TGraph* GetGraph( ) const;
+      void Load( const std::string& fname );
+      void Save( const std::string& fname ) const;
 
+      // Memory management
       void Clear( );
-      void ClearConnections( );
 
       // Filter management
-      TFilter* GetFilter( const std::string& name );
-      const TFilter* GetFilter( const std::string& name ) const;
+      std::vector< std::string > GetFiltersNames( ) const;
+      TProcess* GetFilter(
+        const std::string& name
+        );
+      const TProcess* 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;
-      TFilter* CreateFilter(
-        const std::string& filter, const std::string& name
+      bool HasWidget( const std::string& name ) const;
+      TProcess* CreateFilter(
+        const std::string& category,
+        const std::string& filter,
+        const std::string& name
         );
       bool RenameFilter(
         const std::string& old_name, const std::string& new_name
         );
-      void RemoveFilter( const std::string& name );
+      bool RemoveFilter( const std::string& name );
 
-      // Widgets management
-      vtkRenderWindowInteractor* GetSingleInteractor( );
-      const vtkRenderWindowInteractor* GetSingleInteractor( ) const;
-      void SetSingleInteractor( vtkRenderWindowInteractor* interactor );
+      void SetPrintExecution( bool b );
+      void PrintExecutionOn( );
+      void PrintExecutionOff( );
 
-      SimpleMPRWidget* GetMPRViewer( );
-      const SimpleMPRWidget* GetMPRViewer( ) const;
-      void SetMPRViewer( SimpleMPRWidget* wdg );
+      // 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(
-        const OutputProcessObjectPort& port, const std::string& exposed_port
+      // Exposed ports
+      const TExposedPorts& GetExposedInputs( ) const;
+      const TExposedPorts& GetExposedOutputs( ) const;
+      cpPlugins::BaseObjects::DataObject* GetExposedOutput(
+        const std::string& name
         );
-      void RemoveConnection(
-        const std::string& dest_filter, const std::string& input_name
-        );
-      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 cpPlugins::BaseObjects::DataObject* GetExposedOutput(
+        const std::string& name
+        ) const;
+      bool ExposeInput(
         const std::string& name,
         const std::string& filter, const std::string& filter_input
         );
-      void ExposeOutputPort(
+      bool ExposeOutput(
         const std::string& name,
         const std::string& filter, const std::string& filter_output
         );
-      void HideInputPort( const std::string& name );
-      void HideOutputPort( const std::string& name );
-
-      bool RenameExposedInputPort(
+      void HideInput( const std::string& name );
+      void HideOutput( const std::string& name );
+      bool RenameExposedInput(
         const std::string& old_name,
         const std::string& new_name
         );
-      bool RenameExposedOutputPort(
+      bool RenameExposedOutput(
         const std::string& old_name,
         const std::string& new_name
         );
 
-      const TExposedPorts& GetExposedInputPorts( ) const;
-      const TExposedPorts& GetExposedOutputPorts( ) const;
-
-      OutputProcessObjectPort& GetExposedOutput( const std::string& name );
-      const OutputProcessObjectPort& GetExposedOutput( const std::string& name ) const;
+      // Connection management
+      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 Execute( );
+      void Execute( const std::string& name );
+
+    protected:
+      Workspace( );
+      virtual ~Workspace( );
+
+    private:
+      // Purposely not implemented
+      Workspace( const Self& other );
+      Self& operator=( const Self& other );
 
     protected:
-      // Plugins interface
-      TPlugins* m_Plugins;
+      TFilters m_Filters;
+      bool     m_PrintExecution;
 
-      // Processing graph
-      TGraph::Pointer m_Graph;
-      TExposedPorts m_ExposedInputPorts;
-      TExposedPorts m_ExposedOutputPorts;
+      TExposedPorts m_ExposedInputs;
+      TExposedPorts m_ExposedOutputs;
 
-      vtkSmartPointer< vtkRenderWindowInteractor > m_SingleInteractor;
-      SimpleMPRWidget*                             m_MPRViewer;
+      std::set< vtkRenderWindowInteractor* > m_Interactors;
     };
 
   } // ecapseman
 
 } // ecapseman
 
-#endif // __CPPLUGINS__INTERFACE__WORKSPACE__H__
+#endif // __cpPlugins__Interface__Workspace__h__
 
 // eof - $RCSfile$