X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=lib%2FcpPlugins%2FInterface%2FPlugins.h;h=f93f3770c9fe809592d11c2605caf55dc22a5ceb;hb=00b54bc0344d74f31df8b93f7c28a07cfc8d6873;hp=847b7e830fd84d351948ba9ff78c1279ce440086;hpb=0bb74f9a32de4ce1559973ebf72fda495aa2c587;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/Plugins.h b/lib/cpPlugins/Interface/Plugins.h index 847b7e8..f93f377 100644 --- a/lib/cpPlugins/Interface/Plugins.h +++ b/lib/cpPlugins/Interface/Plugins.h @@ -1,25 +1,30 @@ #ifndef __CPPLUGINS__INTERFACE__PLUGINS__H__ #define __CPPLUGINS__INTERFACE__PLUGINS__H__ -#include +#include +#include +#include #include #include #include +#include -#include -#include -#include -#include - -class QObject; -class QMenu; +// Some forward declarations +class vtkRenderWindowInteractor; +#ifdef cpPlugins_Interface_QT4 class QWidget; +#else +typedef char QWidget; +#endif // cpPlugins_Interface_QT4 namespace cpPlugins { namespace Interface { + // Some forward declarations + class BaseApplication; + /** */ class cpPlugins_Interface_EXPORT Plugins @@ -28,75 +33,141 @@ namespace cpPlugins typedef cpPlugins::Interface::Interface TInterface; typedef cpPlugins::Interface::ProcessObject TProcessObject; typedef cpPlugins::Interface::DataObject TDataObject; - typedef cpPlugins::Interface::Image TImage; - typedef cpPlugins::Interface::Mesh TMesh; typedef TProcessObject::TParameters TParameters; - typedef std::set< std::string > TOrderedStringContainer; - typedef std::map< std::string, std::set< std::string > > TFilters; + typedef std::set< std::string > TStringContainer; public: - Plugins( QWidget* widget = NULL ); + Plugins( ); virtual ~Plugins( ); + // Qt oriented methods QWidget* GetWidget( ); const QWidget* GetWidget( ) const; void SetWidget( QWidget* widget ); void BlockWidget( ); void UnblockWidget( ); void DialogLoadPlugins( ); - void AssociatePluginsToMenu( - QMenu* menu, QObject* obj, const char* slot - ); + // Connection to main application + BaseApplication* GetApplication( ); + const BaseApplication* GetApplication( ) const; + void SetApplication( BaseApplication* a ); + + // Plugins management + bool LoadPluginsPath( const std::string& path, bool r = false ); bool LoadPlugins( const std::string& fname ); bool LoadPluginsConfigurationFile( const std::string& fname ); + const TStringContainer& GetLoadedPlugins( ) const; + void GetLoadedCategories( TStringContainer& categories ) const; + void GetLoadedFilters( TStringContainer& filters ) const; + const TStringContainer& GetLoadedFilters( + const std::string& category + ) const; + + // Interactors + void AddInteractor( vtkRenderWindowInteractor* interactor ); + void RemoveInteractor( vtkRenderWindowInteractor* interactor ); + void ClearInteractors( ); + + // Data IO + bool HasImageReader( ) const; + bool HasDicomSeriesReader( ) const; + bool HasMeshReader( ) const; + bool HasImageWriter( ) const; + bool HasMeshWriter( ) const; + + std::string ReadImage( + const std::string& fname, const std::string& parent + ); + std::string ReadImage( + const std::vector< std::string >& fnames, const std::string& parent + ); + std::string ReadImage( const std::string& parent ); + std::string ReadDicomSeries( const std::string& parent ); + std::string ReadMesh( + const std::string& fname, const std::string& parent + ); + std::string ReadMesh( const std::string& parent ); - TParameters* GetImageReaderParameters( ); - TParameters* GetMeshReaderParameters( ); - TParameters* GetImageWriterParameters( ); - TParameters* GetMeshWriterParameters( ); + bool WriteDataObject( + const std::string& fname, const std::string& name + ); + bool WriteDataObject( const std::string& name ); - const TParameters* GetImageReaderParameters( ) const; - const TParameters* GetMeshReaderParameters( ) const; - const TParameters* GetImageWriterParameters( ) const; - const TParameters* GetMeshWriterParameters( ) const; + // Data objects + void ClearDataObjects( ); + void DeleteDataObject( const std::string& name ); + void GetDataObjects( TStringContainer& names ); + std::string GetParent( const std::string& name ) const; + void GetChildren( + TStringContainer& names, const std::string& name + ) const; + void GetRoots( TStringContainer& names ) const; - // Data IO - bool ReadImage( TImage::Pointer& image, bool exec_qt = false ); - bool ReadDicomSeries( TImage::Pointer& image ); - bool ReadMesh( TMesh::Pointer& mesh, bool exec_qt = false ); + template< class T > + inline T* GetData( const std::string& name ); - bool WriteImage( TImage* image, bool exec_qt = false ); - bool WriteMesh( TMesh* mesh, bool exec_qt = false ); + template< class T > + inline const T* GetData( const std::string& name ) const; // Filter acces - bool CreateFilter( - TProcessObject::Pointer& filter, const std::string& name + bool ActivateFilter( const std::string& name ); + void DeactivateFilter( ); + bool HasActiveFilter( ) const; + bool IsActiveFilterInteractive( ) const; + void GetActiveFilterInputsNames( TStringContainer& names ) const; + void GetActiveFilterOutputsNames( TStringContainer& names ) const; + bool ConnectInputInActiveFilter( + const std::string& object_name, const std::string& input_name + ); + bool SetOutputNameInActiveFilter( + const std::string& new_object_name, const std::string& output_name + ); + TParameters* GetActiveFilterParameters( ); + const TParameters* GetActiveFilterParameters( ) const; + TProcessObject::DialogResult ConfigureActiveFilter( ); + bool UpdateActiveFilter( + TStringContainer& outputs, + const std::string& parent ); protected: - void _Update( ); + void _UpdateLoadedPluginsInformation( ); + bool _ActivateIOFilter( const std::string& filter ); + std::string _ReadData( const std::string& parent ); + bool _WriteData( const std::string& name ); + bool _InsertNewData( TDataObject* dobj, const std::string& parent ); protected: - QWidget* m_Widget; - - TInterface m_Interface; - TOrderedStringContainer m_LoadedPlugins; - std::string m_LastLoadedPlugin; - - TProcessObject::Pointer m_ImageReader; - TProcessObject::Pointer m_ImageWriter; - TProcessObject::Pointer m_MeshReader; - TProcessObject::Pointer m_MeshWriter; - TProcessObject::Pointer m_DicomSeriesReader; - TFilters m_Filters; + // MVC objects + QWidget* m_Widget; + BaseApplication* m_Application; + + // Plugins interface + TInterface m_Interface; + TStringContainer m_LoadedPlugins; + std::string m_LastLoadedPlugin; + std::map< std::string, TStringContainer > m_LoadedFilters; + + // Loaded filters + std::map< std::string, TProcessObject::Pointer > m_IOFilters; + TProcessObject::Pointer m_ActiveFilter; + + // Loaded data objects + typedef std::pair< std::string, TDataObject::Pointer > _TTreeNode; + std::map< std::string, _TTreeNode > m_DataObjects; + + // Associated interactors + std::set< vtkRenderWindowInteractor* > m_Interactors; }; } // ecapseman } // ecapseman +#include + #endif // __CPPLUGINS__INTERFACE__PLUGINS__H__ // eof - $RCSfile$