]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Plugins.h
UML-code sync
[cpPlugins.git] / lib / cpPlugins / Interface / Plugins.h
1 #ifndef __CPPLUGINS__INTERFACE__PLUGINS__H__
2 #define __CPPLUGINS__INTERFACE__PLUGINS__H__
3
4 #include <cpPlugins/Interface/Interface.h>
5 #include <cpPlugins/Interface/DataObject.h>
6 #include <cpPlugins/Interface/ProcessObject.h>
7
8 #include <map>
9 #include <set>
10 #include <string>
11 #include <vector>
12
13 // Some forward declarations
14 class vtkRenderWindowInteractor;
15 #ifdef cpPlugins_Interface_QT4
16 class QWidget;
17 #else
18 typedef char QWidget;
19 #endif // cpPlugins_Interface_QT4
20
21 namespace cpPlugins
22 {
23   namespace Interface
24   {
25     // Some forward declarations
26     class BaseApplication;
27
28     /**
29      */
30     class cpPlugins_Interface_EXPORT Plugins
31     {
32     public:
33       typedef cpPlugins::Interface::Interface     TInterface;
34       typedef cpPlugins::Interface::ProcessObject TProcessObject;
35       typedef cpPlugins::Interface::DataObject    TDataObject;
36       typedef TProcessObject::TParameters         TParameters;
37
38       typedef std::set< std::string > TStringContainer;
39
40     public:
41       Plugins( );
42       virtual ~Plugins( );
43
44       // Qt oriented methods
45       QWidget* GetWidget( );
46       const QWidget* GetWidget( ) const;
47       void SetWidget( QWidget* widget );
48       void BlockWidget( );
49       void UnblockWidget( );
50       void DialogLoadPlugins( );
51
52       // Connection to main application
53       BaseApplication* GetApplication( );
54       const BaseApplication* GetApplication( ) const;
55       void SetApplication( BaseApplication* a );
56
57       // Plugins management
58       bool LoadPlugins( );
59       bool LoadPlugins( const std::string& fname );
60       bool LoadPluginsConfigurationFile( const std::string& fname );
61       const TStringContainer& GetLoadedPlugins( ) const;
62       void GetLoadedFilters( TStringContainer& filters ) const;
63       const TStringContainer& GetLoadedFilters(
64         const std::string& plugin
65         ) const;
66
67       // Interactors
68       void AddInteractor( vtkRenderWindowInteractor* interactor );
69       void RemoveInteractor( vtkRenderWindowInteractor* interactor );
70       void ClearInteractors( );
71
72       // Data IO
73       bool HasImageReader( ) const;
74       bool HasDicomSeriesReader( ) const;
75       bool HasMeshReader( ) const;
76       bool HasImageWriter( ) const;
77       bool HasMeshWriter( ) const;
78
79       std::string ReadImage(
80         const std::string& fname, const std::string& parent
81         );
82       std::string ReadImage(
83         const std::vector< std::string >& fnames, const std::string& parent
84         );
85       std::string ReadImage( const std::string& parent );
86       std::string ReadDicomSeries( const std::string& parent );
87       std::string ReadMesh(
88         const std::string& fname, const std::string& parent
89         );
90       std::string ReadMesh( const std::string& parent );
91
92       std::string WriteDataObject(
93         const std::string& fname, const std::string& name
94         );
95       std::string WriteDataObject( const std::string& name );
96
97       // Data objects
98       void ClearDataObjects( );
99       void DeleteDataObject( const std::string& name );
100       void GetDataObjects( TStringContainer& names );
101       std::string GetParent( const std::string& name ) const;
102       void GetChildren(
103         TStringContainer& names, const std::string& name
104         ) const;
105       void GetRoots( TStringContainer& names ) const;
106
107       template< class T >
108         inline T* GetData( const std::string& name );
109
110       template< class T >
111         inline const T* GetData( const std::string& name ) const;
112
113       // Filter acces
114       bool ActivateFilter( const std::string& name );
115       void DeactivateFilter( );
116       bool HasActiveFilter( ) const;
117       bool IsActiveFilterInteractive( ) const;
118       void GetActiveFilterInputsNames( TStringContainer& names ) const;
119       void GetActiveFilterOutputsNames( TStringContainer& names ) const;
120       bool ConnectInputInActiveFilter(
121         const std::string& object_name, const std::string& input_name
122         );
123       bool SetOutputNameInActiveFilter(
124         const std::string& new_object_name, const std::string& output_name
125         );
126       TParameters* GetActiveFilterParameters( );
127       const TParameters* GetActiveFilterParameters( ) const;
128       TProcessObject::DialogResult ConfigureActiveFilter( );
129       std::string UpdateActiveFilter( );
130
131     protected:
132       void _UpdateLoadedPluginsInformation( );
133       bool _InsertNewData( TDataObject* dobj, const std::string& parent );
134
135     protected:
136       // MVC objects
137       QWidget*         m_Widget;
138       BaseApplication* m_Application;
139
140       // Plugins interface
141       TInterface*                               m_Interface;
142       TStringContainer                          m_LoadedPlugins;
143       std::string                               m_LastLoadedPlugin;
144       std::map< std::string, TStringContainer > m_LoadedFilters;
145
146       // Loaded filters
147       std::map< std::string, TProcessObject::Pointer > m_IOFilters;
148       TProcessObject::Pointer                       m_ActiveFilter;
149       std::map< std::string, std::string >   m_ActiveFilterOutputs;
150
151       // Loaded data objects
152       typedef std::pair< std::string, TDataObject::Pointer >  _TTreeNode;
153       std::map< std::string, _TTreeNode > m_DataObjects;
154
155       // Associated interactors
156       std::set< vtkRenderWindowInteractor* > m_Interactors;
157     };
158
159   } // ecapseman
160
161 } // ecapseman
162
163 #include <cpPlugins/Interface/Plugins.hxx>
164
165 #endif // __CPPLUGINS__INTERFACE__PLUGINS__H__
166
167 // eof - $RCSfile$