firstPlugin.h 2.76 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 51
	FirstPlugin()
	{}
Pierre Kraemer's avatar
Pierre Kraemer committed
52

Pierre Kraemer's avatar
Pierre Kraemer committed
53 54
	~FirstPlugin()
	{}
Pierre Kraemer's avatar
Pierre Kraemer committed
55 56

	/**
Pierre Kraemer's avatar
Pierre Kraemer committed
57
	 * The plugin's enable method
Pierre Kraemer's avatar
Pierre Kraemer committed
58 59 60 61 62 63
	 * 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.
	 */
64
	bool enable();
65

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

Pierre Kraemer's avatar
Pierre Kraemer committed
73
	void cb_initGL(View *scene);
Pierre Kraemer's avatar
Pierre Kraemer committed
74
	virtual void cb_updateMatrix(View* view) {}
Pierre Kraemer's avatar
Pierre Kraemer committed
75 76 77 78 79 80 81 82 83 84 85 86
	void cb_redraw(View *scene);

	virtual void cb_keyPress(View* scene, int key) {}
	virtual void cb_keyRelease(View* scene, int key) {}
	virtual void cb_mousePress(View* scene, int button, int x, int y) {}
	virtual void cb_mouseRelease(View* scene, int button, int x, int y) {}
//	virtual void cb_mouseClick(View* scene, int button, int x, int y) {}
	virtual void cb_mouseMove(View* scene, int buttons, int x, int y) {}
	virtual void cb_wheelEvent(View* scene, int delta, int x, int y) {}

	virtual void cb_viewAdded(View* s) {}
	virtual void cb_viewRemoved(View* s) {}
Pierre Kraemer's avatar
Pierre Kraemer committed
87

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

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

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

98
	// just for more compact writing
Pierre Kraemer's avatar
Pierre Kraemer committed
99 100 101 102 103 104 105 106 107 108 109 110
	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);
	}
111
	template<int X>
Pierre Kraemer's avatar
Pierre Kraemer committed
112 113 114 115
	Dart PHI(Dart d)
	{
		return myMap.phi<X>(d);
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
116 117 118
	/** Attributes that are specific to this plugin **/
};

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