#ifndef __CPPLUGINS__WORKSPACE__H__ #define __CPPLUGINS__WORKSPACE__H__ #include #include #include #include #include #include // Some forward declarations class QWidget; class vtkRenderWindowInteractor; namespace cpExtensions { namespace QT { #ifdef cpPlugins_QT4 class SimpleMPRWidget; #else // cpPlugins_QT4 typedef char SimpleMPRWidget; #endif // cpPlugins_QT4 } } namespace cpPlugins { /** \brief A complex pipeline */ class cpPlugins_EXPORT Workspace { public: // Various types typedef std::set< std::string > TStringContainer; typedef std::pair< std::string, std::string > TExposedPort; typedef std::map< std::string, TExposedPort > TExposedPorts; // Graph type typedef std::pair< std::string, std::string > TConnection; typedef cpExtensions::DataStructures:: Graph< Object::Pointer, TConnection, std::string > TGraph; // Associated MPR typedef cpExtensions::QT::SimpleMPRWidget TMPRWidget; public: Workspace( ); virtual ~Workspace( ); // Plugins management Interface* GetInterface( ); const Interface* GetInterface( ) const; void SetInterface( Interface* i ); // Workspace IO std::string LoadWorkspace( const std::string& fname ); std::string SaveWorkspace( const std::string& fname ) const; // Graph management TGraph* GetGraph( ); const TGraph* GetGraph( ) const; void Clear( ); void ClearConnections( ); // Filter management ProcessObject* GetFilter( const std::string& name ); const ProcessObject* GetFilter( const std::string& name ) const; bool HasFilter( const std::string& name ) const; ProcessObject* CreateFilter( const std::string& category, const std::string& filter, const std::string& name ); bool RenameFilter( const std::string& old_name, const std::string& new_name ); void RemoveFilter( const std::string& name ); void SetParameter( const std::string& name, const std::string& value ); void SetPrintExecution( bool b ); void PrintExecutionOn( ); void PrintExecutionOff( ); // Widgets management vtkRenderWindowInteractor* GetSingleInteractor( ); const vtkRenderWindowInteractor* GetSingleInteractor( ) const; void SetSingleInteractor( vtkRenderWindowInteractor* interactor ); TMPRWidget* GetMPRViewer( ); const TMPRWidget* GetMPRViewer( ) const; void SetMPRViewer( TMPRWidget* wdg ); // Connection management bool Connect( const std::string& orig_filter, const std::string& dest_filter, const std::string& output_name, const std::string& input_name ); bool Connect( const OutputPort& port, const std::string& exposed_port ); void RemoveConnection( const std::string& dest_filter, const std::string& input_name ); void RemoveConnection( const std::string& exposed_port ); void RemoveConnections( const std::string& dest_filter ); // Graph reduction bool Reduce( const std::string& name ); void ExposeInputPort( const std::string& name, const std::string& filter, const std::string& filter_input ); void ExposeOutputPort( const std::string& name, const std::string& filter, const std::string& filter_output ); void HideInputPort( const std::string& name ); void HideOutputPort( const std::string& name ); bool RenameExposedInputPort( const std::string& old_name, const std::string& new_name ); bool RenameExposedOutputPort( const std::string& old_name, const std::string& new_name ); const TExposedPorts& GetExposedInputPorts( ) const; const TExposedPorts& GetExposedOutputPorts( ) const; OutputPort& GetExposedOutput( const std::string& name ); const OutputPort& GetExposedOutput( const std::string& name ) const; // Pipeline execution void Execute( ); void Execute( const std::string& name ); protected: // Plugins interface Interface* m_Interface; bool m_PrintExecution; // Processing graph TGraph::Pointer m_Graph; TExposedPorts m_ExposedInputPorts; TExposedPorts m_ExposedOutputPorts; vtkSmartPointer< vtkRenderWindowInteractor > m_SingleInteractor; TMPRWidget* m_MPRViewer; }; } // ecapseman #endif // __CPPLUGINS__WORKSPACE__H__ // eof - $RCSfile$