]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Workspace.h
itk-based LevelSet filters wrapped
[cpPlugins.git] / lib / cpPlugins / Interface / Workspace.h
1 #ifndef __cpPlugins__Interface__Workspace__h__
2 #define __cpPlugins__Interface__Workspace__h__
3
4 #include <cpPlugins/Interface/Plugins.h>
5 #include <cpPlugins/BaseObjects/DataObject.h>
6 #include <cpPlugins/BaseObjects/ProcessObject.h>
7 #include <cpPlugins/BaseObjects/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::BaseObjects::DataObject    TDataObject;
28       typedef cpPlugins::BaseObjects::ProcessObject TFilter;
29       typedef cpPlugins::BaseObjects::Widget        TWidget;
30       typedef cpPlugins::Interface::Plugins         TPlugins;
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         );
63       bool RenameFilter(
64         const std::string& old_name, const std::string& new_name
65         );
66       bool RemoveFilter( const std::string& name );
67
68       void SetPrintExecution( bool b );
69       void PrintExecutionOn( );
70       void PrintExecutionOff( );
71
72       // Interactors
73       void AddInteractor( vtkRenderWindowInteractor* iren );
74
75       // Exposed ports
76       /* TODO
77          const TExposedPorts& GetExposedInputs( ) const;
78          const TExposedPorts& GetExposedOutputs( ) const;
79          cpPlugins::BaseObjects::DataObject* GetExposedOutput(
80          const std::string& name
81          );
82          const cpPlugins::BaseObjects::DataObject* GetExposedOutput(
83          const std::string& name
84          ) const;
85          bool ExposeInput(
86          const std::string& name,
87          const std::string& filter, const std::string& filter_input
88          );
89          bool ExposeOutput(
90          const std::string& name,
91          const std::string& filter, const std::string& filter_output
92          );
93          void HideInput( const std::string& name );
94          void HideOutput( const std::string& name );
95          bool RenameExposedInput(
96          const std::string& old_name,
97          const std::string& new_name
98          );
99          bool RenameExposedOutput(
100          const std::string& old_name,
101          const std::string& new_name
102          );
103       */
104
105       // Connection management
106       bool Connect(
107         const std::string& origin_filter,
108         const std::string& origin_output,
109         const std::string& destination_filter,
110         const std::string& destination_input
111         );
112       bool Connect(
113         TDataObject* input,
114         const std::string& destination_filter,
115         const std::string& destination_input
116         );
117       bool Disconnect(
118         const std::string& origin_filter,
119         const std::string& origin_output,
120         const std::string& destination_filter,
121         const std::string& destination_input
122         );
123
124       /* TODO
125          std::vector< std::pair< std::string, std::string > > GetConnections(
126          const std::string& origin, const std::string& destination
127          ) const;
128          void Connect(
129          const std::string& orig_filter, const std::string& dest_filter,
130          const std::string& output_name, const std::string& input_name
131          );
132          void Connect(
133          cpPlugins::BaseObjects::DataObject* output,
134          const std::string& dest_filter, const std::string& input_name
135          );
136          void Connect(
137          cpPlugins::BaseObjects::DataObject* output,
138          const std::string& exposed_input_name
139          );
140          void Disconnect(
141          const std::string& orig_filter, const std::string& dest_filter,
142          const std::string& output_name, const std::string& input_name
143          );
144          void Disconnect(
145          const std::string& dest_filter, const std::string& input_name
146          );
147          void Disconnect( const std::string& dest_filter );
148       */
149
150       // Pipeline execution
151       void Update( );
152       void Update( const std::string& name );
153
154     protected:
155       Workspace( );
156       virtual ~Workspace( );
157
158     private:
159       // Purposely not implemented
160       Workspace( const Self& other );
161       Self& operator=( const Self& other );
162
163     protected:
164       TPlugins::Pointer m_Plugins;
165       TFilters m_Filters;
166       bool     m_PrintExecution;
167
168       /* TODO
169          TExposedPorts m_ExposedInputs;
170          TExposedPorts m_ExposedOutputs;
171       */
172
173       std::set< vtkRenderWindowInteractor* > m_Interactors;
174     };
175
176   } // ecapseman
177
178 } // ecapseman
179
180 #endif // __cpPlugins__Interface__Workspace__h__
181
182 // eof - $RCSfile$