]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Workspace.h
fd9847b20a81b58215082a795e32bf6d0a81d8bb
[cpPlugins.git] / lib / cpPlugins / Interface / Workspace.h
1 #ifndef __cpPlugins__Interface__Workspace__h__
2 #define __cpPlugins__Interface__Workspace__h__
3
4 #include <cpPlugins/Interface/Loader.h>
5 #include <cpPlugins/Pipeline/DataObject.h>
6 #include <cpPlugins/Pipeline/ProcessObject.h>
7 #include <cpPlugins/Pipeline/Widget.h>
8 #include <itkObject.h>
9
10 class vtkRenderWindowInteractor;
11
12 namespace cpPlugins
13 {
14   namespace Interface
15   {
16     /** \brief A complex pipeline
17      */
18     class cpPlugins_EXPORT Workspace
19       : public itk::Object
20     {
21     public:
22       typedef Workspace                       Self;
23       typedef itk::Object                     Superclass;
24       typedef itk::SmartPointer< Self >       Pointer;
25       typedef itk::SmartPointer< const Self > ConstPointer;
26
27       typedef cpPlugins::Pipeline::DataObject    TDataObject;
28       typedef cpPlugins::Pipeline::ProcessObject TFilter;
29       typedef cpPlugins::Pipeline::Widget        TWidget;
30       typedef cpPlugins::Interface::Loader          TLoader;
31
32       typedef std::map< std::string, TFilter::Pointer > TFilters;
33
34       /* TODO
35          typedef
36          std::map< std::string, std::pair< std::string, std::string > >
37          TExposedPorts;
38       */
39
40     public:
41       itkNewMacro( Self );
42       itkTypeMacro( Workspace, itk::Object );
43
44     public:
45       // Workspace IO
46       void Load( const std::string& fname );
47       void Save( const std::string& fname ) const;
48
49       // Memory management
50       void Clear( );
51
52       // Filter management
53       std::vector< std::string > GetFiltersNames( ) const;
54       TFilter* GetFilter( const std::string& name );
55       const TFilter* GetFilter( const std::string& name ) const;
56       TWidget* GetWidget( const std::string& name );
57       const TWidget* GetWidget( const std::string& name ) const;
58       bool HasFilter( const std::string& name ) const;
59       bool HasWidget( const std::string& name ) const;
60       TFilter* CreateFilter(
61         const std::string& category, const std::string& filter,
62         const std::string& name
63         );
64       TFilter* CreateFilter(
65         const std::string& category, const std::string& filter
66         );
67       bool RenameFilter(
68         const std::string& old_name, const std::string& new_name
69         );
70       bool RemoveFilter( const std::string& name );
71
72       void SetPrintExecution( bool b );
73       void PrintExecutionOn( );
74       void PrintExecutionOff( );
75
76       // Interactors
77       void AddInteractor( vtkRenderWindowInteractor* iren );
78
79       // Connection management
80       bool Connect(
81         const std::string& origin_filter,
82         const std::string& origin_output,
83         const std::string& destination_filter,
84         const std::string& destination_input
85         );
86       bool Connect(
87         TDataObject* input,
88         const std::string& destination_filter,
89         const std::string& destination_input
90         );
91       bool Disconnect(
92         const std::string& origin_filter,
93         const std::string& origin_output,
94         const std::string& destination_filter,
95         const std::string& destination_input
96         );
97
98       /* TODO
99          std::vector< std::pair< std::string, std::string > > GetConnections(
100          const std::string& origin, const std::string& destination
101          ) const;
102          void Connect(
103          const std::string& orig_filter, const std::string& dest_filter,
104          const std::string& output_name, const std::string& input_name
105          );
106          void Connect(
107          cpPlugins::Pipeline::DataObject* output,
108          const std::string& dest_filter, const std::string& input_name
109          );
110          void Connect(
111          cpPlugins::Pipeline::DataObject* output,
112          const std::string& exposed_input_name
113          );
114          void Disconnect(
115          const std::string& orig_filter, const std::string& dest_filter,
116          const std::string& output_name, const std::string& input_name
117          );
118          void Disconnect(
119          const std::string& dest_filter, const std::string& input_name
120          );
121          void Disconnect( const std::string& dest_filter );
122       */
123
124       // Pipeline execution
125       void Update( );
126       void Update( const std::string& name );
127
128     protected:
129       Workspace( );
130       virtual ~Workspace( );
131
132     private:
133       // Purposely not implemented
134       Workspace( const Self& other );
135       Self& operator=( const Self& other );
136
137     protected:
138       TLoader  m_Loader;
139       TFilters m_Filters;
140       bool     m_PrintExecution;
141
142       /* TODO
143          TExposedPorts m_ExposedInputs;
144          TExposedPorts m_ExposedOutputs;
145       */
146
147       std::set< vtkRenderWindowInteractor* > m_Interactors;
148     };
149
150   } // ecapseman
151
152 } // ecapseman
153
154 #endif // __cpPlugins__Interface__Workspace__h__
155
156 // eof - $RCSfile$