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 );
83 void SetPrintExecution( bool b );
84 void PrintExecutionOn( );
85 void PrintExecutionOff( );
88 vtkRenderWindowInteractor* GetSingleInteractor( );
89 const vtkRenderWindowInteractor* GetSingleInteractor( ) const;
90 void SetSingleInteractor( vtkRenderWindowInteractor* interactor );
92 TMPRWidget* GetMPRViewer( );
93 const TMPRWidget* GetMPRViewer( ) const;
94 void SetMPRViewer( TMPRWidget* wdg );
96 // Connection management
98 const std::string& orig_filter, const std::string& dest_filter,
99 const std::string& output_name, const std::string& input_name
101 bool Connect( const OutputPort& port, const std::string& exposed_port );
102 void RemoveConnection(
103 const std::string& dest_filter, const std::string& input_name
105 void RemoveConnection( const std::string& exposed_port );
106 void RemoveConnections( const std::string& dest_filter );
109 bool Reduce( const std::string& name );
110 void ExposeInputPort(
111 const std::string& name,
112 const std::string& filter, const std::string& filter_input
114 void ExposeOutputPort(
115 const std::string& name,
116 const std::string& filter, const std::string& filter_output
118 void HideInputPort( const std::string& name );
119 void HideOutputPort( const std::string& name );
121 bool RenameExposedInputPort(
122 const std::string& old_name,
123 const std::string& new_name
125 bool RenameExposedOutputPort(
126 const std::string& old_name,
127 const std::string& new_name
130 const TExposedPorts& GetExposedInputPorts( ) const;
131 const TExposedPorts& GetExposedOutputPorts( ) const;
133 OutputPort& GetExposedOutput( const std::string& name );
134 const OutputPort& GetExposedOutput( const std::string& name ) const;
136 // Pipeline execution
138 void Execute( const std::string& name );
142 Interface* m_Interface;
145 TGraph::Pointer m_Graph;
146 TExposedPorts m_ExposedInputPorts;
147 TExposedPorts m_ExposedOutputPorts;
149 vtkSmartPointer< vtkRenderWindowInteractor > m_SingleInteractor;
150 TMPRWidget* m_MPRViewer;
155 #endif // __CPPLUGINS__WORKSPACE__H__