]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Workspace.h
PolyLineParametricPath basic visualization and plugin added.
[cpPlugins.git] / lib / cpPlugins / Workspace.h
1 #ifndef __CPPLUGINS__WORKSPACE__H__
2 #define __CPPLUGINS__WORKSPACE__H__
3
4 #include <cpExtensions/DataStructures/Graph.h>
5 #include <cpPlugins/Interface.h>
6 #include <cpPlugins/DataObject.h>
7 #include <cpPlugins/ProcessObject.h>
8
9 #include <set>
10 #include <string>
11
12 // Some forward declarations
13 class QWidget;
14 class vtkRenderWindowInteractor;
15 namespace cpExtensions
16 {
17   namespace QT
18   {
19 #ifdef cpPlugins_QT4
20     class SimpleMPRWidget;
21 #else // cpPlugins_QT4
22     typedef char SimpleMPRWidget;
23 #endif // cpPlugins_QT4
24   }
25 }
26
27 namespace cpPlugins
28 {
29   /** \brief A complex pipeline
30    */
31   class cpPlugins_EXPORT Workspace
32   {
33   public:
34     // Various types
35     typedef std::set< std::string >               TStringContainer;
36     typedef std::pair< std::string, std::string > TExposedPort;
37     typedef std::map< std::string, TExposedPort > TExposedPorts;
38
39     // Graph type
40     typedef std::pair< std::string, std::string > TConnection;
41     typedef
42       cpExtensions::DataStructures::
43       Graph< Object::Pointer, TConnection, std::string > TGraph;
44
45     // Associated MPR
46     typedef cpExtensions::QT::SimpleMPRWidget TMPRWidget;
47
48   public:
49     Workspace( );
50     virtual ~Workspace( );
51
52     // Plugins management
53     Interface* GetInterface( );
54     const Interface* GetInterface( ) const;
55     void SetInterface( Interface* i );
56
57     // Workspace IO
58     std::string LoadWorkspace( const std::string& fname );
59     std::string SaveWorkspace( const std::string& fname ) const;
60
61     // Graph management
62     TGraph* GetGraph( );
63     const TGraph* GetGraph( ) const;
64
65     void Clear( );
66     void ClearConnections( );
67
68     // Filter management
69     ProcessObject* GetFilter( const std::string& name );
70     const ProcessObject* GetFilter( const std::string& name ) const;
71     bool HasFilter( const std::string& name ) const;
72     ProcessObject* CreateFilter(
73       const std::string& category,
74       const std::string& filter,
75       const std::string& name
76       );
77     bool RenameFilter(
78       const std::string& old_name, const std::string& new_name
79       );
80     void RemoveFilter( const std::string& name );
81
82     // Widgets management
83     vtkRenderWindowInteractor* GetSingleInteractor( );
84     const vtkRenderWindowInteractor* GetSingleInteractor( ) const;
85     void SetSingleInteractor( vtkRenderWindowInteractor* interactor );
86
87     TMPRWidget* GetMPRViewer( );
88     const TMPRWidget* GetMPRViewer( ) const;
89     void SetMPRViewer( TMPRWidget* wdg );
90
91     // Connection management
92     bool Connect(
93       const std::string& orig_filter, const std::string& dest_filter,
94       const std::string& output_name, const std::string& input_name
95       );
96     bool Connect( const OutputPort& port, const std::string& exposed_port );
97     void RemoveConnection(
98       const std::string& dest_filter, const std::string& input_name
99       );
100     void RemoveConnection( const std::string& exposed_port );
101     void RemoveConnections( const std::string& dest_filter );
102
103     // Graph reduction
104     bool Reduce( const std::string& name );
105     void ExposeInputPort(
106       const std::string& name,
107       const std::string& filter, const std::string& filter_input
108       );
109     void ExposeOutputPort(
110       const std::string& name,
111       const std::string& filter, const std::string& filter_output
112       );
113     void HideInputPort( const std::string& name );
114     void HideOutputPort( const std::string& name );
115
116     bool RenameExposedInputPort(
117       const std::string& old_name,
118       const std::string& new_name
119       );
120     bool RenameExposedOutputPort(
121       const std::string& old_name,
122       const std::string& new_name
123       );
124
125     const TExposedPorts& GetExposedInputPorts( ) const;
126     const TExposedPorts& GetExposedOutputPorts( ) const;
127
128     OutputPort& GetExposedOutput( const std::string& name );
129     const OutputPort& GetExposedOutput( const std::string& name ) const;
130
131     // Pipeline execution
132     std::string Execute( );
133     std::string Execute( const std::string& name );
134
135   protected:
136     // Plugins interface
137     Interface* m_Interface;
138
139     // Processing graph
140     TGraph::Pointer m_Graph;
141     TExposedPorts m_ExposedInputPorts;
142     TExposedPorts m_ExposedOutputPorts;
143
144     vtkSmartPointer< vtkRenderWindowInteractor > m_SingleInteractor;
145     TMPRWidget*                                  m_MPRViewer;
146   };
147
148 } // ecapseman
149
150 #endif // __CPPLUGINS__WORKSPACE__H__
151
152 // eof - $RCSfile$