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 // TODO: #ifdef cpPlugins_QT4
20 class SimpleMPRWidget;
21 // TODO: #else // cpPlugins_QT4
22 // TODO: typedef char SimpleMPRWidget;
23 // TODO: #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 DataObject* GetOutput(
72 const std::string& filter, const std::string& output
74 const DataObject* GetOutput(
75 const std::string& filter, const std::string& output
77 bool HasFilter( const std::string& name ) const;
78 ProcessObject* CreateFilter(
79 const std::string& category,
80 const std::string& filter,
81 const std::string& name
84 const std::string& old_name, const std::string& new_name
86 void RemoveFilter( const std::string& name );
87 void SetParameter( const std::string& name, const std::string& value );
89 void SetPrintExecution( bool b );
90 void PrintExecutionOn( );
91 void PrintExecutionOff( );
94 vtkRenderWindowInteractor* GetSingleInteractor( );
95 const vtkRenderWindowInteractor* GetSingleInteractor( ) const;
96 void SetSingleInteractor( vtkRenderWindowInteractor* interactor );
98 TMPRWidget* GetMPRViewer( );
99 const TMPRWidget* GetMPRViewer( ) const;
100 void SetMPRViewer( TMPRWidget* wdg );
102 // Connection management
104 const std::string& orig_filter, const std::string& dest_filter,
105 const std::string& output_name, const std::string& input_name
107 bool Connect( const OutputPort& port, const std::string& exposed_port );
108 void RemoveConnection(
109 const std::string& dest_filter, const std::string& input_name
111 void RemoveConnection( const std::string& exposed_port );
112 void RemoveConnections( const std::string& dest_filter );
115 bool Reduce( const std::string& name );
116 void ExposeInputPort(
117 const std::string& name,
118 const std::string& filter, const std::string& filter_input
120 void ExposeOutputPort(
121 const std::string& name,
122 const std::string& filter, const std::string& filter_output
124 void HideInputPort( const std::string& name );
125 void HideOutputPort( const std::string& name );
127 bool RenameExposedInputPort(
128 const std::string& old_name,
129 const std::string& new_name
131 bool RenameExposedOutputPort(
132 const std::string& old_name,
133 const std::string& new_name
136 const TExposedPorts& GetExposedInputPorts( ) const;
137 const TExposedPorts& GetExposedOutputPorts( ) const;
139 OutputPort& GetExposedOutput( const std::string& name );
140 const OutputPort& GetExposedOutput( const std::string& name ) const;
142 // Pipeline execution
144 void Execute( const std::string& name );
148 Interface* m_Interface;
149 bool m_PrintExecution;
152 TGraph::Pointer m_Graph;
153 TExposedPorts m_ExposedInputPorts;
154 TExposedPorts m_ExposedOutputPorts;
156 vtkSmartPointer< vtkRenderWindowInteractor > m_SingleInteractor;
157 TMPRWidget* m_MPRViewer;
162 #endif // __CPPLUGINS__WORKSPACE__H__