]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Plugins.h
Merge ssh://git.creatis.insa-lyon.fr/cpPlugins
[cpPlugins.git] / lib / cpPlugins / Interface / Plugins.h
1 #ifndef __CPPLUGINS__INTERFACE__PLUGINS__H__
2 #define __CPPLUGINS__INTERFACE__PLUGINS__H__
3
4 #include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
5
6 #include <map>
7 #include <set>
8 #include <string>
9
10 #include <cpPlugins/Interface/Interface.h>
11 #include <cpPlugins/Interface/ProcessObject.h>
12 #include <cpPlugins/Interface/Image.h>
13 #include <cpPlugins/Interface/Mesh.h>
14
15 class QObject;
16 class QMenu;
17 class QWidget;
18 class vtkRenderWindowInteractor;
19
20 namespace cpPlugins
21 {
22   namespace Interface
23   {
24     class BasePluginsApplication;
25
26     /**
27      */
28     class cpPlugins_Interface_EXPORT Plugins
29     {
30     public:
31       typedef cpPlugins::Interface::Interface     TInterface;
32       typedef cpPlugins::Interface::ProcessObject TProcessObject;
33       typedef cpPlugins::Interface::DataObject    TDataObject;
34       typedef cpPlugins::Interface::Image         TImage;
35       typedef cpPlugins::Interface::Mesh          TMesh;
36       typedef TProcessObject::TParameters         TParameters;
37
38       typedef std::set< std::string >           TOrderedStringContainer;
39       typedef std::map< std::string, std::set< std::string > > TFilters;
40       typedef std::pair< std::string, TDataObject::Pointer >  TTreeNode;
41       typedef std::map< std::string, TTreeNode >                  TTree;
42
43     public:
44       Plugins( QWidget* widget = NULL );
45       virtual ~Plugins( );
46
47       QWidget* GetWidget( );
48       const QWidget* GetWidget( ) const;
49       void SetWidget( QWidget* widget );
50       void BlockWidget( );
51       void UnblockWidget( );
52       void DialogLoadPlugins( );
53       void AssociatePluginsToMenu(
54         QMenu* menu, QObject* obj, const char* slot
55         );
56
57       BasePluginsApplication* GetApplication( );
58       const BasePluginsApplication* GetApplication( ) const;
59       void SetApplication( BasePluginsApplication* a );
60
61       bool LoadPlugins( );
62       bool LoadPlugins( const std::string& fname );
63       bool LoadPluginsConfigurationFile( const std::string& fname );
64
65       // Interactors
66       void AddInteractor( vtkRenderWindowInteractor* interactor );
67       void RemoveInteractor( vtkRenderWindowInteractor* interactor );
68       void ClearInteractors( );
69
70       // Data IO
71       bool HasImageReader( ) const;
72       bool HasDicomSeriesReader( ) const;
73       bool HasMeshReader( ) const;
74       bool HasImageWriter( ) const;
75       bool HasMeshWriter( ) const;
76
77       std::string ReadImage(
78         const std::string& fname, const std::string& parent
79         );
80       std::string ReadImage(
81         const std::vector< std::string >& fnames, const std::string& parent
82         );
83       std::string ReadImage( const std::string& parent );
84       std::string ReadDicomSeries( const std::string& parent );
85       std::string ReadMesh(
86         const std::string& fname, const std::string& parent
87         );
88       std::string ReadMesh( const std::string& parent );
89
90       bool WriteImage( const std::string& fname, const std::string& name );
91       bool WriteImage( const std::string& name );
92       bool WriteMesh( const std::string& fname, const std::string& name );
93       bool WriteMesh( const std::string& name );
94
95       // Data objects
96       void ClearDataObjects( );
97       void DeleteDataObject( const std::string& name );
98       std::string GetParent( const std::string& name ) const;
99       const TTree& GetDataObjects( ) const;
100       TDataObject* GetDataObject( const std::string& name );
101       const TDataObject* GetDataObject( const std::string& name ) const;
102       TImage* GetImage( const std::string& name );
103       const TImage* GetImage( const std::string& name ) const;
104       TMesh* GetMesh( const std::string& name );
105       const TMesh* GetMesh( const std::string& name ) const;
106
107       // Filter acces
108       bool ActivateFilter( const std::string& name );
109       void DeactivateFilter( );
110       bool HasActiveFilter( ) const;
111       bool IsActiveFilterInteractive( ) const;
112       unsigned int GetNumberOfInputsInActiveFilter( ) const;
113       unsigned int GetNumberOfOutputsInActiveFilter( ) const;
114       std::vector< std::string > GetActiveFilterInputsNames( ) const;
115       std::vector< std::string > GetActiveFilterOutputsNames( ) const;
116       void ConnectInputInActiveFilter(
117         const std::string& object_name, const std::string& input
118         );
119       void SetOutputNameInActiveFilter(
120         const std::string& new_name, const std::string& output
121         );
122       TParameters* GetActiveFilterParameters( );
123       const TParameters* GetActiveFilterParameters( ) const;
124       TProcessObject::DialogResult ConfigureActiveFilter( );
125       std::string UpdateActiveFilter( std::vector< std::string >& outputs );
126
127     protected:
128       void _UpdateLoadedPluginsInformation( );
129       bool _InsertNewData( TDataObject* dobj, const std::string& parent );
130
131     protected:
132       QWidget* m_Widget;
133       BasePluginsApplication* m_Application;
134
135       TInterface              m_Interface;
136       TOrderedStringContainer m_LoadedPlugins;
137       std::string             m_LastLoadedPlugin;
138
139       TProcessObject::Pointer              m_ImageReader;
140       TProcessObject::Pointer              m_ImageWriter;
141       TProcessObject::Pointer              m_MeshReader;
142       TProcessObject::Pointer              m_MeshWriter;
143       TProcessObject::Pointer              m_DicomSeriesReader;
144       TProcessObject::Pointer              m_ActiveFilter;
145       std::map< std::string, std::string > m_ActiveFilterOutputs;
146       TFilters m_Filters;
147
148       // Loaded objects
149       TTree m_Objects;
150
151       // Associated interactors
152       std::set< vtkRenderWindowInteractor* > m_Interactors;
153     };
154
155   } // ecapseman
156
157 } // ecapseman
158
159 #endif // __CPPLUGINS__INTERFACE__PLUGINS__H__
160
161 // eof - $RCSfile$