firstPlugin.h 2.71 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1 2
#ifndef _FIRSTPLUGIN_H_
#define _FIRSTPLUGIN_H_
Pierre Kraemer's avatar
Pierre Kraemer committed
3

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

/**---CGoGN includes **/
7
#include "Topology/generic/parameters.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
8
#include "Topology/map/embeddedMap2.h"
9
#include "Algo/Render/GL2/topoRender.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
10 11
/**---CGoGN includes **/

12 13
/**---Definitions specific to CGoGN ---*/
using namespace CGoGN ;
Pierre Kraemer's avatar
Pierre Kraemer committed
14

15 16 17 18 19 20
/**
 * Struct that contains some informations about the types of the manipulated objects
 * Mainly here to be used by the algorithms that are parameterized by it
 */
struct PFP: public PFP_STANDARD
{
Pierre Kraemer's avatar
Pierre Kraemer committed
21
	// definition of the map
22 23
	typedef EmbeddedMap2 MAP;
};
Pierre Kraemer's avatar
Pierre Kraemer committed
24

25 26
typedef PFP::MAP MAP;
typedef PFP::VEC3 VEC3;
Pierre Kraemer's avatar
Pierre Kraemer committed
27
/**---Definitions specific to CGoGN ---*/
Pierre Kraemer's avatar
Pierre Kraemer committed
28 29 30 31 32 33 34 35 36 37 38

/**
 * This class is a basic minimal plugin.
 * All the methods in this class are overloaded methods.
 * In order to create a valid plugin, all the method in this
 * needs to be declared (they are actually overloaded methods
 * from VisualPlugin), even if your plugin doesn't make any
 * drawing.
 */

/**
Pierre Kraemer's avatar
Pierre Kraemer committed
39
 * Our plugin must inherit from Plugin
Pierre Kraemer's avatar
Pierre Kraemer committed
40
 */
Pierre Kraemer's avatar
Pierre Kraemer committed
41
class FirstPlugin : public Plugin
42
{
Pierre Kraemer's avatar
Pierre Kraemer committed
43 44 45 46 47
	/**
	 * Essential Qt macros.
	 */
	Q_OBJECT
	Q_INTERFACES(Plugin)
48

Pierre Kraemer's avatar
Pierre Kraemer committed
49
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
50
	FirstPlugin()
51 52 53 54
	{
		setProvidesRendering(true);
		glewInit();
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
55

Pierre Kraemer's avatar
Pierre Kraemer committed
56 57
	~FirstPlugin()
	{}
Pierre Kraemer's avatar
Pierre Kraemer committed
58 59

	/**
Pierre Kraemer's avatar
Pierre Kraemer committed
60
	 * The plugin's enable method
Pierre Kraemer's avatar
Pierre Kraemer committed
61 62 63 64 65 66
	 * Each time the main application loads this plugin,
	 * it call this method. Writing this method is
	 * the occasion to initialize the plugin and check certain
	 * conditions.
	 * If this methods return 'false', the plugin load will be aborted.
	 */
67
	bool enable();
68

Pierre Kraemer's avatar
Pierre Kraemer committed
69
	/**
Pierre Kraemer's avatar
Pierre Kraemer committed
70
	 * The plugin's disable method
Pierre Kraemer's avatar
Pierre Kraemer committed
71 72 73 74 75
	 * Each time the main application will unload the plugin
	 * it will call this method.
	 */
	void disable();

76
	virtual void redraw(View *view);
Pierre Kraemer's avatar
Pierre Kraemer committed
77

78 79 80 81 82 83 84
	virtual void keyPress(View* view, int key) {}
	virtual void keyRelease(View* view, int key) {}
	virtual void mousePress(View* view, int button, int x, int y) {}
	virtual void mouseRelease(View* view, int button, int x, int y) {}
//	virtual void mouseClick(View* view, int button, int x, int y) {}
	virtual void mouseMove(View* view, int buttons, int x, int y) {}
	virtual void wheelEvent(View* view, int delta, int x, int y) {}
Pierre Kraemer's avatar
Pierre Kraemer committed
85

86 87
	virtual void viewAdded(View* view);
	virtual void viewRemoved(View* view) {}
Pierre Kraemer's avatar
Pierre Kraemer committed
88

Pierre Kraemer's avatar
Pierre Kraemer committed
89 90
protected:
	/** Attributes that are specific to this plugin **/
91
	MAP myMap;
Pierre Kraemer's avatar
Pierre Kraemer committed
92

93 94
	// attribute for vertices positions
	VertexAttribute<VEC3> position;
Pierre Kraemer's avatar
Pierre Kraemer committed
95

96
	// render (for the topo)
Pierre Kraemer's avatar
Pierre Kraemer committed
97
	Algo::Render::GL2::TopoRender *m_render_topo;
Pierre Kraemer's avatar
Pierre Kraemer committed
98

99
	// just for more compact writing
Pierre Kraemer's avatar
Pierre Kraemer committed
100 101 102 103 104 105 106 107 108 109 110 111
	inline Dart PHI1(Dart d)
	{
		return myMap.phi1(d);
	}
	inline Dart PHI_1(Dart d)
	{
		return myMap.phi_1(d);
	}
	inline Dart PHI2(Dart d)
	{
		return myMap.phi2(d);
	}
112
	template<int X>
Pierre Kraemer's avatar
Pierre Kraemer committed
113 114 115 116
	Dart PHI(Dart d)
	{
		return myMap.phi<X>(d);
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
117 118 119
	/** Attributes that are specific to this plugin **/
};

Pierre Kraemer's avatar
Pierre Kraemer committed
120
#endif // _FIRSTPLUGIN_H_