1 #ifndef __CPPLUGINS__INTERFACE__WORKSPACE__H__
2 #define __CPPLUGINS__INTERFACE__WORKSPACE__H__
4 #include <cpExtensions/DataStructures/Graph.h>
5 #include <cpPlugins/Interface/Interface.h>
6 #include <cpPlugins/Interface/DataObject.h>
7 #include <cpPlugins/Interface/ProcessObject.h>
12 // Some forward declarations
14 class vtkRenderWindowInteractor;
20 /** \brief A complex pipeline
22 class cpPlugins_Interface_EXPORT Workspace
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;
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;
38 typedef std::pair< std::string, std::string > TConnection;
40 cpExtensions::DataStructures::
41 Graph< TObject::Pointer, TConnection, std::string > TGraph;
45 virtual ~Workspace( );
48 TPlugins* GetPlugins( );
49 const TPlugins* GetPlugins( ) const;
50 void SetPlugins( TPlugins* i );
53 std::string LoadWorkspace( const std::string& fname );
54 std::string SaveWorkspace( const std::string& fname ) const;
58 const TGraph* GetGraph( ) const;
61 void ClearConnections( );
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 );
69 const std::string& old_name, const std::string& new_name
71 void RemoveFilter( const std::string& name );
74 virtual const TInteractors& GetInteractors( ) const;
75 virtual void AddInteractor( vtkRenderWindowInteractor* interactor );
77 // Connection management
79 const std::string& orig_filter, const std::string& dest_filter,
80 const std::string& output_name, const std::string& input_name
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
86 void RemoveConnection( const std::string& exposed_port );
87 void RemoveConnections( const std::string& dest_filter );
90 bool Reduce( const std::string& name );
92 const std::string& name,
93 const std::string& filter, const std::string& filter_input
95 void ExposeOutputPort(
96 const std::string& name,
97 const std::string& filter, const std::string& filter_output
99 void HideInputPort( const std::string& name );
100 void HideOutputPort( const std::string& name );
102 bool RenameExposedInputPort(
103 const std::string& old_name,
104 const std::string& new_name
106 bool RenameExposedOutputPort(
107 const std::string& old_name,
108 const std::string& new_name
111 const TExposedPorts& GetExposedInputPorts( ) const;
112 const TExposedPorts& GetExposedOutputPorts( ) const;
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;
119 // Pipeline execution
120 std::string Execute( );
121 std::string Execute( const std::string& name );
128 typename TGraph::Pointer m_Graph;
129 TExposedPorts m_ExposedInputPorts;
130 TExposedPorts m_ExposedOutputPorts;
132 TInteractors m_Interactors;
139 #endif // __CPPLUGINS__INTERFACE__WORKSPACE__H__