]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Workspace.h
...
[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::ProcessObject TFilter;
28       typedef cpPlugins::BaseObjects::Widget        TWidget;
29       typedef cpPlugins::Interface::Plugins         TPlugins;
30
31       typedef std::map< std::string, TFilter::Pointer > TFilters;
32
33       /* TODO
34          typedef
35          std::map< std::string, std::pair< std::string, std::string > >
36          TExposedPorts;
37       */
38
39     public:
40       itkNewMacro( Self );
41       itkTypeMacro( Workspace, itk::Object );
42
43     public:
44       // Workspace IO
45       void Load( const std::string& fname );
46       void Save( const std::string& fname ) const;
47
48       // Memory management
49       void Clear( );
50
51       // Filter management
52       std::vector< std::string > GetFiltersNames( ) const;
53       TFilter* GetFilter( const std::string& name );
54       const TFilter* GetFilter( const std::string& name ) const;
55       TWidget* GetWidget( const std::string& name );
56       const TWidget* GetWidget( const std::string& name ) const;
57       bool HasFilter( const std::string& name ) const;
58       bool HasWidget( const std::string& name ) const;
59       TFilter* CreateFilter(
60         const std::string& category, const std::string& filter
61         );
62       bool RenameFilter(
63         const std::string& old_name, const std::string& new_name
64         );
65       bool RemoveFilter( const std::string& name );
66
67       void SetPrintExecution( bool b );
68       void PrintExecutionOn( );
69       void PrintExecutionOff( );
70
71       // Interactors
72       void AddInteractor( vtkRenderWindowInteractor* iren );
73
74       // Exposed ports
75       /* TODO
76          const TExposedPorts& GetExposedInputs( ) const;
77          const TExposedPorts& GetExposedOutputs( ) const;
78          cpPlugins::BaseObjects::DataObject* GetExposedOutput(
79          const std::string& name
80          );
81          const cpPlugins::BaseObjects::DataObject* GetExposedOutput(
82          const std::string& name
83          ) const;
84          bool ExposeInput(
85          const std::string& name,
86          const std::string& filter, const std::string& filter_input
87          );
88          bool ExposeOutput(
89          const std::string& name,
90          const std::string& filter, const std::string& filter_output
91          );
92          void HideInput( const std::string& name );
93          void HideOutput( const std::string& name );
94          bool RenameExposedInput(
95          const std::string& old_name,
96          const std::string& new_name
97          );
98          bool RenameExposedOutput(
99          const std::string& old_name,
100          const std::string& new_name
101          );
102       */
103
104       // Connection management
105       bool Connect(
106         const std::string& origin_filter,
107         const std::string& origin_output,
108         const std::string& destination_filter,
109         const std::string& destination_input
110         );
111       bool Disconnect(
112         const std::string& origin_filter,
113         const std::string& origin_output,
114         const std::string& destination_filter,
115         const std::string& destination_input
116         );
117
118       /* TODO
119          std::vector< std::pair< std::string, std::string > > GetConnections(
120          const std::string& origin, const std::string& destination
121          ) const;
122          void Connect(
123          const std::string& orig_filter, const std::string& dest_filter,
124          const std::string& output_name, const std::string& input_name
125          );
126          void Connect(
127          cpPlugins::BaseObjects::DataObject* output,
128          const std::string& dest_filter, const std::string& input_name
129          );
130          void Connect(
131          cpPlugins::BaseObjects::DataObject* output,
132          const std::string& exposed_input_name
133          );
134          void Disconnect(
135          const std::string& orig_filter, const std::string& dest_filter,
136          const std::string& output_name, const std::string& input_name
137          );
138          void Disconnect(
139          const std::string& dest_filter, const std::string& input_name
140          );
141          void Disconnect( const std::string& dest_filter );
142       */
143
144       // Pipeline execution
145       void Update( );
146       void Update( const std::string& name );
147
148     protected:
149       Workspace( );
150       virtual ~Workspace( );
151
152     private:
153       // Purposely not implemented
154       Workspace( const Self& other );
155       Self& operator=( const Self& other );
156
157     protected:
158       TPlugins::Pointer m_Plugins;
159       TFilters m_Filters;
160       bool     m_PrintExecution;
161
162       /* TODO
163          TExposedPorts m_ExposedInputs;
164          TExposedPorts m_ExposedOutputs;
165       */
166
167       std::set< vtkRenderWindowInteractor* > m_Interactors;
168     };
169
170   } // ecapseman
171
172 } // ecapseman
173
174 #endif // __cpPlugins__Interface__Workspace__h__
175
176 // eof - $RCSfile$