]> 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 <cpExtensions/DataStructures/Graph.h>
5 #include <cpPlugins/Interface/Interface.h>
6 #include <cpPlugins/Interface/DataObject.h>
7 #include <cpPlugins/Interface/ProcessObject.h>
8
9 #include <set>
10 #include <string>
11
12 // Some forward declarations
13 class QWidget;
14 class vtkRenderWindowInteractor;
15
16 namespace cpPlugins
17 {
18   namespace Interface
19   {
20     /** \brief A complex pipeline
21      */
22     class cpPlugins_Interface_EXPORT Workspace
23     {
24     public:
25       typedef cpPlugins::Interface::Interface     TPlugins;
26       typedef cpPlugins::Interface::Object        TObject;
27       typedef cpPlugins::Interface::ProcessObject TFilter;
28       typedef cpPlugins::Interface::DataObject    TData;
29       typedef TFilter::TParameters                TParameters;
30
31       // Various types
32       typedef std::set< std::string >               TStringContainer;
33       typedef std::pair< std::string, std::string > TExposedPort;
34       typedef std::map< std::string, TExposedPort > TExposedPorts;
35       typedef std::set< vtkRenderWindowInteractor* > TInteractors;
36
37       // Graph type
38       typedef std::pair< std::string, std::string > TConnection;
39       typedef
40         cpExtensions::DataStructures::
41         Graph< TObject::Pointer, TConnection, std::string > TGraph;
42
43     public:
44       Workspace( );
45       virtual ~Workspace( );
46
47       // Plugins management
48       TPlugins* GetPlugins( );
49       const TPlugins* GetPlugins( ) const;
50       void SetPlugins( TPlugins* i );
51
52       // Workspace IO
53       std::string LoadWorkspace( const std::string& fname );
54       std::string SaveWorkspace( const std::string& fname ) const;
55
56       // Graph management
57       TGraph* GetGraph( );
58       const TGraph* GetGraph( ) const;
59
60       void Clear( );
61       void ClearConnections( );
62
63       // Filter management
64       TFilter* GetFilter( const std::string& name );
65       const TFilter* GetFilter( const std::string& name ) const;
66       bool HasFilter( const std::string& name ) const;
67       bool CreateFilter( const std::string& filter, const std::string& name );
68       bool RenameFilter(
69         const std::string& old_name, const std::string& new_name
70         );
71       void RemoveFilter( const std::string& name );
72
73       // Widgets management
74       virtual const TInteractors& GetInteractors( ) const;
75       virtual void AddInteractor( vtkRenderWindowInteractor* interactor );
76
77       // Connection management
78       bool Connect(
79         const std::string& orig_filter, const std::string& dest_filter,
80         const std::string& output_name, const std::string& input_name
81         );
82       bool Connect( TData* input_object, const std::string& exposed_port );
83       void RemoveConnection(
84         const std::string& dest_filter, const std::string& input_name
85         );
86       void RemoveConnection( const std::string& exposed_port );
87       void RemoveConnections( const std::string& dest_filter );
88
89       // Graph reduction
90       bool Reduce( const std::string& name );
91       void ExposeInputPort(
92         const std::string& name,
93         const std::string& filter, const std::string& filter_input
94         );
95       void ExposeOutputPort(
96         const std::string& name,
97         const std::string& filter, const std::string& filter_output
98         );
99       void HideInputPort( const std::string& name );
100       void HideOutputPort( const std::string& name );
101
102       bool RenameExposedInputPort(
103         const std::string& old_name,
104         const std::string& new_name
105         );
106       bool RenameExposedOutputPort(
107         const std::string& old_name,
108         const std::string& new_name
109         );
110
111       const TExposedPorts& GetExposedInputPorts( ) const;
112       const TExposedPorts& GetExposedOutputPorts( ) const;
113
114       TData* GetExposedInput( const std::string& name );
115       const TData* GetExposedInput( const std::string& name ) const;
116       TData* GetExposedOutput( const std::string& name );
117       const TData* GetExposedOutput( const std::string& name ) const;
118
119       // Pipeline execution
120       std::string Execute( );
121       std::string Execute( const std::string& name );
122
123     protected:
124       // Plugins interface
125       TPlugins* m_Plugins;
126
127       // Processing graph
128       typename TGraph::Pointer m_Graph;
129       TExposedPorts m_ExposedInputPorts;
130       TExposedPorts m_ExposedOutputPorts;
131
132       TInteractors m_Interactors;
133     };
134
135   } // ecapseman
136
137 } // ecapseman
138
139 #endif // __CPPLUGINS__INTERFACE__WORKSPACE__H__
140
141 // eof - $RCSfile$