simplePlugin.h 3.16 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
2
3
#ifndef _SIMPLEPLUGIN_H_
#define _SIMPLEPLUGIN_H_

4
#include "plugins/plugin.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
5

6
7
class SimplePlugin : public QObject, public Plugin
{
Pierre Kraemer's avatar
Pierre Kraemer committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
	Q_OBJECT
public:
	SimplePlugin();
	~SimplePlugin();

	void cb_updateMatrix(View* view){}

	void cb_redraw(Scene* scene){}

	void cb_initGL(Scene* scene){}

	void updateGL(){}
	void updateGL(Scene* scene){}



	bool cb_keyPress(Scene* scene, int event) {return false;}

	bool cb_keyRelease(Scene* scene, int event) {return false;}

	bool cb_mousePress(Scene* scene, int button, int x, int y) {return false;}

	bool cb_mouseRelease(Scene* scene, int button, int x, int y) {return false;}

	bool cb_mouseClick(Scene* scene, int button, int x, int y) {return false;}

	bool cb_mouseMove(Scene* scene, int buttons, int x, int y) {return false;}

	bool cb_wheelEvent(Scene* scene, int delta, int x, int y) {return false;}


	void cb_recievedMap(CGoGN::GenericMap* map){}

	void cb_removingMap(CGoGN::GenericMap* map){}



	QString getName() {return m_name;}

	QString getPluginFilePath() {return m_pluginPathFile;}

	void addDependantPlugin(Plugin* dependant);
	void deleteDependantLink(Plugin* dependantPlugin);

	bool hasDependantPlugins(){ return !l_dependantPlugins.isEmpty(); }

	QStringList getDependantPluginNames();



	bool isWaitingForScene(){return false;}
	void recieveScene(Scene* scene){}

	void setWindow(Window* window);

	void setName(QString name);

	void setPluginFilePath(QString path);


	bool activate(bool initializing);
	virtual	bool activate() =0;
	virtual	void disable() =0;

	void deleteLinkWith(Scene* scene);


	Plugin* addDependencie(QString dependencie);
	void suppressDependencieLink(Plugin* dependencie);
	void suppressAllDependencieLinks();
	void suppressDependantLink(Plugin* dependant);
	void suppressAllDependantLinks();

	void unloadDependantPlugins();

	bool hasManualLinkWith(Scene* scene){return false;}

	bool addMap(CGoGN::GenericMap* map);
	CGoGN::GenericMap* takeMap(CGoGN::GenericMap* map);
	QList<CGoGN::GenericMap*> workingMaps(){return l_map;}
	void setMapNumber(int n){if(n>=l_map.size() || n==UNLIMITED_MAP_NUMBER) m_mapNumber=n;}
	int remainingMapNumber(){return (m_mapNumber!=UNLIMITED_MAP_NUMBER)?(m_mapNumber-l_map.size()):(m_mapNumber);}


	enum {UNLIMITED_NUMBER_OF_SCENES=-1};
protected:

	template<typename T>
	T* getDependencie(QString dependencie){ return( (T*)(this->addDependencie(dependencie)) ); }


	bool addWidgetInDockTab(QWidget* newTabWidget, QString tabText);
	void removeTabInDock(QWidget* tabWidget);

	bool addReferencedMap(QString map_name, CGoGN::GenericMap* map);
	template<typename T>
	bool addNewReferencedMap(QString map_name, T* &map){
		if(m_window){
			bool r= m_window->addNewReferencedMap<T>(map_name, map);
			if(r) l_map.push_back(map);
			return r;
		}
		else{
			System::Error::code= System::Error::BAD_LINK_PLUGIN_WINDOW_f(m_name);
			return false;
		}
	}
	template<typename T>
	T* getReferencedMap(QString map_name){
		if(m_window){
			return m_window->getReferencedMap<T>(map_name);
		}
		else{
			System::Error::code= System::Error::BAD_LINK_PLUGIN_WINDOW_f(m_name);
			return NULL;
		}
	}


	QList<QAction*> l_action;

	QAction* addMenuAction(QString menuPath, const char* method);
	void deleteMenuActions();

};