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