plugin.h 3.03 KB
Newer Older
1
2
3
#ifndef _PLUGIN_H_
#define _PLUGIN_H_

Pierre Kraemer's avatar
Pierre Kraemer committed
4
5
#include <QtPlugin>
#include <QAction>
6

7
#include "types.h"
8

Pierre Kraemer's avatar
Pierre Kraemer committed
9
10
11
12
13
14
namespace CGoGN
{

namespace SCHNApps
{

15
16
class Window;

Pierre Kraemer's avatar
Pierre Kraemer committed
17
class Plugin : public QObject
18
{
19
20
	Q_OBJECT

21
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
22
	Plugin();
Pierre Kraemer's avatar
Pierre Kraemer committed
23
24
	virtual ~Plugin();

25
26
	const QString& getName() const { return m_name; }

27
public slots:
28
	QString getName() { return m_name; }
Pierre Kraemer's avatar
Pierre Kraemer committed
29
30
31
32
33
34
35
36
	void setName(const QString& name) { m_name = name; }

	const QString& getFilePath() { return m_filePath; }
	void setFilePath(const QString& f) { m_filePath = f; }

	Window* getWindow() { return m_window; }
	void setWindow(Window* w) { m_window = w; }

Pierre Kraemer's avatar
Pierre Kraemer committed
37
38
	bool isUsed() const { return !l_views.empty(); }

39
	bool getProvidesRendering() { return b_providesRendering; }
40
	void setProvidesRendering(bool b) {	b_providesRendering = b; }
41

42
public:
43
44
45
	virtual bool enable() = 0;
	virtual void disable() = 0;

46
	virtual void redraw(View* view) = 0;
Pierre Kraemer's avatar
Pierre Kraemer committed
47

48
49
50
51
52
53
	virtual void keyPress(View* view, QKeyEvent* event) = 0;
	virtual void keyRelease(View* view, QKeyEvent* event) = 0;
	virtual void mousePress(View* view, QMouseEvent* event) = 0;
	virtual void mouseRelease(View* view, QMouseEvent* event) = 0;
	virtual void mouseMove(View* view, QMouseEvent* event) = 0;
	virtual void wheelEvent(View* view, QWheelEvent* event) = 0;
54

Pierre Kraemer's avatar
Pierre Kraemer committed
55
	/*********************************************************
Pierre Kraemer's avatar
Pierre Kraemer committed
56
	 * MANAGE LINKED VIEWS
Pierre Kraemer's avatar
Pierre Kraemer committed
57
58
	 *********************************************************/

59
	void linkView(View* view);
Pierre Kraemer's avatar
Pierre Kraemer committed
60
	void unlinkView(View* view);
61
62
	const QList<View*>& getLinkedViews() const { return l_views; }
	bool isLinkedToView(View* view) const { return l_views.contains(view); }
Pierre Kraemer's avatar
Pierre Kraemer committed
63

64
65
66
67
68
69
	/*********************************************************
	 * MANAGE SHADERS
	 *********************************************************/

	void registerShader(Utils::GLSLShader* shader);
	void unregisterShader(Utils::GLSLShader* shader);
70
	const QList<Utils::GLSLShader*> getShaders() const { return l_shaders; }
71

Pierre Kraemer's avatar
Pierre Kraemer committed
72
73
74
	/*********************************************************
	 * MANAGE DOCK TABS
	 *********************************************************/
Pierre Kraemer's avatar
Pierre Kraemer committed
75

Pierre Kraemer's avatar
Pierre Kraemer committed
76
77
	bool addTabInDock(QWidget* tabWidget, const QString& tabText);
	void removeTabInDock(QWidget* tabWidget);
78
	const QList<QWidget*>& getTabWidgets() const { return l_tabWidgets; }
Pierre Kraemer's avatar
Pierre Kraemer committed
79
80
81
82

	/*********************************************************
	 * MANAGE MENU ACTIONS
	 *********************************************************/
Pierre Kraemer's avatar
Pierre Kraemer committed
83

Pierre Kraemer's avatar
Pierre Kraemer committed
84
85
86
87
88
89
	bool addMenuAction(const QString& menuPath, QAction* action);
	void removeMenuAction(QAction* action);

	/*********************************************************
	 * MANAGE TOOLBAR ACTIONS
	 *********************************************************/
Pierre Kraemer's avatar
Pierre Kraemer committed
90

Pierre Kraemer's avatar
Pierre Kraemer committed
91
92
	bool addToolbarAction(QAction* action);
	void removeToolbarAction(QAction* action);
93

Pierre Kraemer's avatar
Pierre Kraemer committed
94
95
96
97
protected:
	QString m_name;
	QString m_filePath;
	Window* m_window;
98

99
100
	bool b_providesRendering;

Pierre Kraemer's avatar
Pierre Kraemer committed
101
	QList<View*> l_views;
Pierre Kraemer's avatar
Pierre Kraemer committed
102
103
104
	QList<QWidget*> l_tabWidgets;
	QList<QAction*> l_menuActions;
	QList<QAction*> l_toolbarActions;
105

106
	QList<Utils::GLSLShader*> l_shaders;
107
108
};

Pierre Kraemer's avatar
Pierre Kraemer committed
109
110
111
112
113
} // namespace SCHNApps

} // namespace CGoGN

Q_DECLARE_INTERFACE(CGoGN::SCHNApps::Plugin, "CGoGN.SCHNapps.Plugin")
114
115

#endif