1 #ifndef __CPPLUGINS__WORKSPACE__H__
2 #define __CPPLUGINS__WORKSPACE__H__
4 #include <cpExtensions/DataStructures/Graph.h>
5 #include <cpPlugins/Interface.h>
6 #include <cpPlugins/DataObject.h>
7 #include <cpPlugins/ProcessObject.h>
12 // Some forward declarations
14 class vtkRenderWindowInteractor;
15 namespace cpExtensions
20 class SimpleMPRWidget;
21 #else // cpPlugins_QT4
22 typedef char SimpleMPRWidget;
23 #endif // cpPlugins_QT4
29 /** \brief A complex pipeline
31 class cpPlugins_EXPORT Workspace
35 typedef std::set< std::string > TStringContainer;
36 typedef std::pair< std::string, std::string > TExposedPort;
37 typedef std::map< std::string, TExposedPort > TExposedPorts;
40 typedef std::pair< std::string, std::string > TConnection;
42 cpExtensions::DataStructures::
43 Graph< Object::Pointer, TConnection, std::string > TGraph;
46 typedef cpExtensions::QT::SimpleMPRWidget TMPRWidget;
50 virtual ~Workspace( );
53 Interface* GetInterface( );
54 const Interface* GetInterface( ) const;
55 void SetInterface( Interface* i );
58 std::string LoadWorkspace( const std::string& fname );
59 std::string SaveWorkspace( const std::string& fname ) const;
63 const TGraph* GetGraph( ) const;
66 void ClearConnections( );
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
78 const std::string& old_name, const std::string& new_name
80 void RemoveFilter( const std::string& name );
83 vtkRenderWindowInteractor* GetSingleInteractor( );
84 const vtkRenderWindowInteractor* GetSingleInteractor( ) const;
85 void SetSingleInteractor( vtkRenderWindowInteractor* interactor );
87 TMPRWidget* GetMPRViewer( );
88 const TMPRWidget* GetMPRViewer( ) const;
89 void SetMPRViewer( TMPRWidget* wdg );
91 // Connection management
93 const std::string& orig_filter, const std::string& dest_filter,
94 const std::string& output_name, const std::string& input_name
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
100 void RemoveConnection( const std::string& exposed_port );
101 void RemoveConnections( const std::string& dest_filter );
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
109 void ExposeOutputPort(
110 const std::string& name,
111 const std::string& filter, const std::string& filter_output
113 void HideInputPort( const std::string& name );
114 void HideOutputPort( const std::string& name );
116 bool RenameExposedInputPort(
117 const std::string& old_name,
118 const std::string& new_name
120 bool RenameExposedOutputPort(
121 const std::string& old_name,
122 const std::string& new_name
125 const TExposedPorts& GetExposedInputPorts( ) const;
126 const TExposedPorts& GetExposedOutputPorts( ) const;
128 OutputPort& GetExposedOutput( const std::string& name );
129 const OutputPort& GetExposedOutput( const std::string& name ) const;
131 // Pipeline execution
132 std::string Execute( );
133 std::string Execute( const std::string& name );
137 Interface* m_Interface;
140 TGraph::Pointer m_Graph;
141 TExposedPorts m_ExposedInputPorts;
142 TExposedPorts m_ExposedOutputPorts;
144 vtkSmartPointer< vtkRenderWindowInteractor > m_SingleInteractor;
145 TMPRWidget* m_MPRViewer;
150 #endif // __CPPLUGINS__WORKSPACE__H__