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
19 class SimpleMPRWidget;
25 /** \brief A complex pipeline
27 class cpPlugins_EXPORT Workspace
31 typedef std::set< std::string > TStringContainer;
32 typedef std::pair< std::string, std::string > TExposedPort;
33 typedef std::map< std::string, TExposedPort > TExposedPorts;
36 typedef std::pair< std::string, std::string > TConnection;
38 cpExtensions::DataStructures::
39 Graph< Object::Pointer, TConnection, std::string > TGraph;
42 typedef cpExtensions::QT::SimpleMPRWidget TMPRWidget;
46 virtual ~Workspace( );
49 Interface* GetInterface( );
50 const Interface* GetInterface( ) const;
51 void SetInterface( Interface* i );
54 std::string LoadWorkspace( const std::string& fname );
55 std::string SaveWorkspace( const std::string& fname ) const;
59 const TGraph* GetGraph( ) const;
62 void ClearConnections( );
65 ProcessObject* GetFilter( const std::string& name );
66 const ProcessObject* GetFilter( const std::string& name ) const;
67 DataObject* GetOutput(
68 const std::string& filter, const std::string& output
70 const DataObject* GetOutput(
71 const std::string& filter, const std::string& output
73 bool HasFilter( const std::string& name ) const;
74 ProcessObject* CreateFilter(
75 const std::string& category,
76 const std::string& filter,
77 const std::string& name
80 const std::string& old_name, const std::string& new_name
82 bool RemoveFilter( const std::string& name );
83 void SetParameter( const std::string& name, const std::string& value );
85 void SetPrintExecution( bool b );
86 void PrintExecutionOn( );
87 void PrintExecutionOff( );
90 vtkRenderWindowInteractor* GetSingleInteractor( );
91 const vtkRenderWindowInteractor* GetSingleInteractor( ) const;
92 void SetSingleInteractor( vtkRenderWindowInteractor* interactor );
94 TMPRWidget* GetMPRViewer( );
95 const TMPRWidget* GetMPRViewer( ) const;
96 void SetMPRViewer( TMPRWidget* wdg );
98 // Connection management
100 const std::string& orig_filter, const std::string& dest_filter,
101 const std::string& output_name, const std::string& input_name
103 bool Connect( const OutputPort& port, const std::string& exposed_port );
106 const std::string& orig_filter, const std::string& dest_filter,
107 const std::string& output_name, const std::string& input_name
110 void RemoveConnection(
111 const std::string& dest_filter, const std::string& input_name
113 void RemoveConnection( const std::string& exposed_port );
114 void RemoveConnections( const std::string& dest_filter );
118 bool Reduce( const std::string& name );
119 void ExposeInputPort(
120 const std::string& name,
121 const std::string& filter, const std::string& filter_input
123 void ExposeOutputPort(
124 const std::string& name,
125 const std::string& filter, const std::string& filter_output
127 void HideInputPort( const std::string& name );
128 void HideOutputPort( const std::string& name );
130 bool RenameExposedInputPort(
131 const std::string& old_name,
132 const std::string& new_name
134 bool RenameExposedOutputPort(
135 const std::string& old_name,
136 const std::string& new_name
139 const TExposedPorts& GetExposedInputPorts( ) const;
140 const TExposedPorts& GetExposedOutputPorts( ) const;
142 OutputPort& GetExposedOutput( const std::string& name );
143 const OutputPort& GetExposedOutput( const std::string& name ) const;
145 // Pipeline execution
147 void Execute( const std::string& name );
151 Interface* m_Interface;
152 bool m_PrintExecution;
155 TGraph::Pointer m_Graph;
156 TExposedPorts m_ExposedInputPorts;
157 TExposedPorts m_ExposedOutputPorts;
159 vtkSmartPointer< vtkRenderWindowInteractor > m_SingleInteractor;
160 TMPRWidget* m_MPRViewer;
165 #endif // __CPPLUGINS__WORKSPACE__H__