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 // Some forward declarations
21 #ifdef cpPlugins_Interface_QT4
22 class SimpleMPRWidget;
23 #else // cpPlugins_Interface_QT4
24 typedef char SimpleMPRWidget;
25 #endif // cpPlugins_Interface_QT4
27 /** \brief A complex pipeline
29 class cpPlugins_Interface_EXPORT Workspace
32 typedef cpPlugins::Interface::Interface TPlugins;
33 typedef cpPlugins::Interface::Object TObject;
34 typedef cpPlugins::Interface::ProcessObject TFilter;
35 typedef cpPlugins::Interface::DataObject TData;
36 typedef TFilter::TParameters TParameters;
39 typedef std::set< std::string > TStringContainer;
40 typedef std::pair< std::string, std::string > TExposedPort;
41 typedef std::map< std::string, TExposedPort > TExposedPorts;
44 typedef std::pair< std::string, std::string > TConnection;
46 cpExtensions::DataStructures::
47 Graph< TObject::Pointer, TConnection, std::string > TGraph;
51 virtual ~Workspace( );
54 TPlugins* GetPlugins( );
55 const TPlugins* GetPlugins( ) const;
56 void SetPlugins( TPlugins* i );
59 std::string LoadWorkspace( const std::string& fname );
60 std::string SaveWorkspace( const std::string& fname ) const;
64 const TGraph* GetGraph( ) const;
67 void ClearConnections( );
70 TFilter* GetFilter( const std::string& name );
71 const TFilter* GetFilter( const std::string& name ) const;
72 bool HasFilter( const std::string& name ) const;
73 TFilter* CreateFilter(
74 const std::string& filter, const std::string& name
77 const std::string& old_name, const std::string& new_name
79 void RemoveFilter( const std::string& name );
82 vtkRenderWindowInteractor* GetSingleInteractor( );
83 const vtkRenderWindowInteractor* GetSingleInteractor( ) const;
84 void SetSingleInteractor( vtkRenderWindowInteractor* interactor );
86 SimpleMPRWidget* GetMPRViewer( );
87 const SimpleMPRWidget* GetMPRViewer( ) const;
88 void SetMPRViewer( SimpleMPRWidget* wdg );
90 // Connection management
92 const std::string& orig_filter, const std::string& dest_filter,
93 const std::string& output_name, const std::string& input_name
96 TData::Pointer* input_object, 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 TData* GetExposedInput( const std::string& name );
130 const TData* GetExposedInput( const std::string& name ) const;
131 TData* GetExposedOutput( const std::string& name );
132 const TData* GetExposedOutput( const std::string& name ) const;
134 // Pipeline execution
135 std::string Execute( );
136 std::string Execute( const std::string& name );
143 TGraph::Pointer m_Graph;
144 TExposedPorts m_ExposedInputPorts;
145 TExposedPorts m_ExposedOutputPorts;
147 vtkSmartPointer< vtkRenderWindowInteractor > m_SingleInteractor;
148 SimpleMPRWidget* m_MPRViewer;
155 #endif // __CPPLUGINS__INTERFACE__WORKSPACE__H__