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 bool CreateFilter( const std::string& filter, const std::string& name );
75 const std::string& old_name, const std::string& new_name
77 void RemoveFilter( const std::string& name );
80 vtkRenderWindowInteractor* GetSingleInteractor( );
81 const vtkRenderWindowInteractor* GetSingleInteractor( ) const;
82 void SetSingleInteractor( vtkRenderWindowInteractor* interactor );
84 SimpleMPRWidget* GetMPRViewer( );
85 const SimpleMPRWidget* GetMPRViewer( ) const;
86 void SetMPRViewer( SimpleMPRWidget* wdg );
88 // Connection management
90 const std::string& orig_filter, const std::string& dest_filter,
91 const std::string& output_name, const std::string& input_name
93 bool Connect( TData* input_object, const std::string& exposed_port );
94 void RemoveConnection(
95 const std::string& dest_filter, const std::string& input_name
97 void RemoveConnection( const std::string& exposed_port );
98 void RemoveConnections( const std::string& dest_filter );
101 bool Reduce( const std::string& name );
102 void ExposeInputPort(
103 const std::string& name,
104 const std::string& filter, const std::string& filter_input
106 void ExposeOutputPort(
107 const std::string& name,
108 const std::string& filter, const std::string& filter_output
110 void HideInputPort( const std::string& name );
111 void HideOutputPort( const std::string& name );
113 bool RenameExposedInputPort(
114 const std::string& old_name,
115 const std::string& new_name
117 bool RenameExposedOutputPort(
118 const std::string& old_name,
119 const std::string& new_name
122 const TExposedPorts& GetExposedInputPorts( ) const;
123 const TExposedPorts& GetExposedOutputPorts( ) const;
125 TData* GetExposedInput( const std::string& name );
126 const TData* GetExposedInput( const std::string& name ) const;
127 TData* GetExposedOutput( const std::string& name );
128 const TData* GetExposedOutput( const std::string& name ) const;
130 // Pipeline execution
131 std::string Execute( );
132 std::string Execute( const std::string& name );
139 TGraph::Pointer m_Graph;
140 TExposedPorts m_ExposedInputPorts;
141 TExposedPorts m_ExposedOutputPorts;
143 vtkSmartPointer< vtkRenderWindowInteractor > m_SingleInteractor;
144 SimpleMPRWidget* m_MPRViewer;
151 #endif // __CPPLUGINS__INTERFACE__WORKSPACE__H__