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 );
81 void SetParameter( const std::string& name, const std::string& value );
84 vtkRenderWindowInteractor* GetSingleInteractor( );
85 const vtkRenderWindowInteractor* GetSingleInteractor( ) const;
86 void SetSingleInteractor( vtkRenderWindowInteractor* interactor );
88 TMPRWidget* GetMPRViewer( );
89 const TMPRWidget* GetMPRViewer( ) const;
90 void SetMPRViewer( TMPRWidget* wdg );
92 // Connection management
94 const std::string& orig_filter, const std::string& dest_filter,
95 const std::string& output_name, const std::string& input_name
97 bool Connect( const OutputPort& port, const std::string& exposed_port );
98 void RemoveConnection(
99 const std::string& dest_filter, const std::string& input_name
101 void RemoveConnection( const std::string& exposed_port );
102 void RemoveConnections( const std::string& dest_filter );
105 bool Reduce( const std::string& name );
106 void ExposeInputPort(
107 const std::string& name,
108 const std::string& filter, const std::string& filter_input
110 void ExposeOutputPort(
111 const std::string& name,
112 const std::string& filter, const std::string& filter_output
114 void HideInputPort( const std::string& name );
115 void HideOutputPort( const std::string& name );
117 bool RenameExposedInputPort(
118 const std::string& old_name,
119 const std::string& new_name
121 bool RenameExposedOutputPort(
122 const std::string& old_name,
123 const std::string& new_name
126 const TExposedPorts& GetExposedInputPorts( ) const;
127 const TExposedPorts& GetExposedOutputPorts( ) const;
129 OutputPort& GetExposedOutput( const std::string& name );
130 const OutputPort& GetExposedOutput( const std::string& name ) const;
132 // Pipeline execution
134 void Execute( const std::string& name );
138 Interface* m_Interface;
141 TGraph::Pointer m_Graph;
142 TExposedPorts m_ExposedInputPorts;
143 TExposedPorts m_ExposedOutputPorts;
145 vtkSmartPointer< vtkRenderWindowInteractor > m_SingleInteractor;
146 TMPRWidget* m_MPRViewer;
151 #endif // __CPPLUGINS__WORKSPACE__H__