1 /****************************************************************************
2 * MeshLab                                                           o o     *
3 * A versatile mesh processing toolbox                             o     o   *
4 *                                                                _   O  _   *
5 * Copyright(C) 2005                                                \/)\/    *
6 * Visual Computing Lab                                            /\/|      *
7 * ISTI - Italian National Research Council                           |      *
8 *                                                                    \      *
9 * All rights reserved.                                                      *
10 *                                                                           *
11 * This program is free software; you can redistribute it and/or modify      *
12 * it under the terms of the GNU General Public License as published by      *
13 * the Free Software Foundation; either version 2 of the License, or         *
14 * (at your option) any later version.                                       *
15 *                                                                           *
16 * This program is distributed in the hope that it will be useful,           *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
19 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
20 * for more details.                                                         *
21 *                                                                           *
22 ****************************************************************************/
23 
24 #ifndef PLUGINMANAGER_H
25 #define PLUGINMANAGER_H
26 
27 #include "interfaces.h"
28 #include "xmlfilterinfo.h"
29 #include "scriptinterface.h"
30 #include "scriptsyntax.h"
31 
32 #include<QMap>
33 #include<QObject>
34 
35 class QScriptEngine;
36 /**
37 \brief This class provides the basic tools for managing all the plugins. It is used by both meshlab and meshlab server.
38 */
39 class PluginManager
40 {
41 private:
42 	QString scriptplugcode;
43 
44 public:
45     PluginManager();
46     ~PluginManager();
47     enum TypeIO{IMPORT,EXPORT};
48     void loadPlugins(RichParameterSet& defaultGlobal);
49     QString pluginsCode() const;
50 	MLXMLPluginInfo* loadXMLPlugin(const QString& filename);
51     //MLXMLPluginInfo* getXMLPluginInfo( const QString& plugname );
52     void deleteXMLPlugin(const QString& plugscriptname);
53 
meshIOPlugins()54     inline QVector<MeshIOInterface*>& meshIOPlugins()  {return meshIOPlug;}
meshFilterPlugins()55     inline QVector<MeshFilterInterface*>& meshFilterPlugins()  {return meshFilterPlug;}
meshRenderPlugins()56     inline QVector<MeshRenderInterface*>& meshRenderPlugins()  {return meshRenderPlug;}
meshDecoratePlugins()57     inline QVector<MeshDecorateInterface*>& meshDecoratePlugins()  {return meshDecoratePlug;}
meshEditFactoryPlugins()58     inline QVector<MeshEditInterfaceFactory*>& meshEditFactoryPlugins()  {return meshEditInterfacePlug;}
meshlabXMLfilterPlugins()59     inline QVector<MeshLabFilterInterface*>& meshlabXMLfilterPlugins()  {return meshlabXMLFilterPlug;}
60     void knownIOFormats();
61     static QString getDefaultPluginDirPath();
62     //static QString getLocalPluginDirPath();
63     static QString getBaseDirPath();
64 
65     QMap<QString,RichParameterSet> generateFilterParameterMap();
66 
67     MeshDecorateInterface* getDecoratorInterfaceByName(const QString& name);
68 
69     QDir pluginsDir;
70     QMap<QString, QAction*> actionFilterMap;
71     QMap<QString, MeshFilterInterface*> stringFilterMap;
72 
73     //QMap<QString, QAction*> xmlActionFilterMap;
74     QMap<QString,	MeshLabXMLFilterContainer> stringXMLFilterMap;
75     QMap<QString,MeshIOInterface*> allKnowInputFormats;
76     QMap<QString,MeshIOInterface*> allKnowOutputFormats;
77     QStringList inpFilters;
78     QStringList outFilters;
79     //QMap<QString, XMLFilterInfo*> filterXMLFileMap;
80 
81 
82     QVector<MeshIOInterface*> meshIOPlug;
83     QVector<MeshFilterInterface*> meshFilterPlug;
84     QVector<MeshRenderInterface*> meshRenderPlug;
85     QVector<MeshDecorateInterface*> meshDecoratePlug;
86     QVector<MeshEditInterfaceFactory*> meshEditInterfacePlug;
87     //only useful for an easy destruction of the MLXMLPluginInfos
88     QVector<MLXMLPluginInfo*> xmlpluginfo;
89     QVector<MeshLabFilterInterface*> meshlabXMLFilterPlug;
90     QVector<QAction *> editActionList;
91     QVector<QAction *> decoratorActionList;
92     // Used for unique destruction - this "owns" all IO, Filter, Render, and Decorate plugins
93     QVector<MeshCommonInterface *> ownerPlug;
94 
95     QStringList pluginsLoaded;
96 
97     static QString osDependentFileBaseName(const QString& plname);
98     static QString osIndependentPluginName(const QString& plname);
99     //highlight and autocomplete
100     /*QStringList pluginnamespaces;
101     QStringList filterscriptnames;*/
102     QList<LibraryElementInfo> libinfolist;
103 };
104 
105 #endif // PLUGINMANAGER_H
106