plugin.h 3.09 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
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
20
	Plugin();
Pierre Kraemer's avatar
Pierre Kraemer committed
21 22 23 24 25 26 27 28 29 30 31
	virtual ~Plugin();

	const QString& getName() { return m_name; }
	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
32 33
	bool isUsed() const { return !l_views.empty(); }

34
	bool getProvidesRendering() { return b_providesRendering; }
35
	void setProvidesRendering(bool b) {	b_providesRendering = b; }
36

37 38 39
	virtual bool enable() = 0;
	virtual void disable() = 0;

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

42 43 44 45 46 47 48
	virtual void keyPress(View* view, int key) = 0;
	virtual void keyRelease(View* view, int key) = 0;
	virtual void mousePress(View* view, int button, int x, int y) = 0;
	virtual void mouseRelease(View* view, int button, int x, int y) = 0;
	virtual void mouseMove(View* view, int buttons, int x, int y) = 0;
	virtual void wheelEvent(View* view, int delta, int x, int y) = 0;

49 50 51
//	virtual void viewLinked(View* view) = 0;
//	virtual void viewUnlinked(View* view) = 0;
//	virtual void currentViewChanged(View* view) = 0;
52

Pierre Kraemer's avatar
Pierre Kraemer committed
53
	/*********************************************************
Pierre Kraemer's avatar
Pierre Kraemer committed
54
	 * MANAGE LINKED VIEWS
Pierre Kraemer's avatar
Pierre Kraemer committed
55 56
	 *********************************************************/

57
	void linkView(View* view);
Pierre Kraemer's avatar
Pierre Kraemer committed
58
	void unlinkView(View* view);
59 60
	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
61

62 63 64 65 66 67
	/*********************************************************
	 * MANAGE SHADERS
	 *********************************************************/

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

Pierre Kraemer's avatar
Pierre Kraemer committed
70 71 72
	/*********************************************************
	 * MANAGE DOCK TABS
	 *********************************************************/
Pierre Kraemer's avatar
Pierre Kraemer committed
73

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

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

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

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

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

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

97 98
	bool b_providesRendering;

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

104
	QList<Utils::GLSLShader*> l_shaders;
105 106
};

Pierre Kraemer's avatar
Pierre Kraemer committed
107 108 109 110 111
} // namespace SCHNApps

} // namespace CGoGN

Q_DECLARE_INTERFACE(CGoGN::SCHNApps::Plugin, "CGoGN.SCHNapps.Plugin")
112 113

#endif