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

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

/**---CGoGN includes **/
7 8
#include "Utils/Qt/qtSimple.h"
#include "Utils/cgognStream.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
9

10
#include "Topology/generic/parameters.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
11

12 13 14 15 16
#ifdef USE_GMAP
	#include "Topology/gmap/embeddedGMap2.h"
#else
	#include "Topology/map/embeddedMap2.h"
#endif
Pierre Kraemer's avatar
Pierre Kraemer committed
17

18
#include "Algo/Render/GL2/topoRender.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
19 20
/**---CGoGN includes **/

21 22
/**---Definitions specific to CGoGN ---*/
using namespace CGoGN ;
Pierre Kraemer's avatar
Pierre Kraemer committed
23

24 25 26 27 28 29 30 31 32 33 34 35 36
/**
 * 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
{
	// definition of the type of the map
#ifdef USE_GMAP
	typedef EmbeddedGMap2 MAP;
#else
	typedef EmbeddedMap2 MAP;
#endif
};
Pierre Kraemer's avatar
Pierre Kraemer committed
37

38 39
typedef PFP::MAP MAP;
typedef PFP::VEC3 VEC3;
Pierre Kraemer's avatar
Pierre Kraemer committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
/**---Definitions  specific to CGoGN ---*/

/**
 * 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.
 */

/**
 * Our plugin must inherit from VisualPlugin,
 * that is a class that itself is an implementation
 * of the Plugin interface (virtual class). It contains
 * many useful and essantial methods.
 */
57 58
class FirstPlugin : public VisualPlugin
{
Pierre Kraemer's avatar
Pierre Kraemer committed
59 60 61 62 63
	/**
	 * Essential Qt macros.
	 */
	Q_OBJECT
	Q_INTERFACES(Plugin)
64

Pierre Kraemer's avatar
Pierre Kraemer committed
65
public:
66 67
	FirstPlugin() {}
	~FirstPlugin() {}
Pierre Kraemer's avatar
Pierre Kraemer committed
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

	/**
	 * The classical call back for the initGL method
	 * When a scene will be link to this plugin, it will call
	 * back this method with itself as a parameter.
	 */
	void cb_initGL(Scene* scene);

	/**
	 * The drawing method that needs to be overloaded.
	 * Each time a scene (that is to say, at least one of the
	 * views that is contains) needs to be refresh, it calls back
	 * this method with itself as a parameter
	 */
	void cb_redraw(Scene* scene);

	/**
	 * The plugin's activation method
	 * 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.
	 */
	bool activate();
93

Pierre Kraemer's avatar
Pierre Kraemer committed
94 95 96 97 98 99 100 101 102
	/**
	 * The plugin's disabling method
	 * Each time the main application will unload the plugin
	 * it will call this method.
	 */
	void disable();

protected:
	/** Attributes that are specific to this plugin **/
103
	MAP myMap;
Pierre Kraemer's avatar
Pierre Kraemer committed
104

105 106
	// attribute for vertices positions
	VertexAttribute<VEC3> position;
Pierre Kraemer's avatar
Pierre Kraemer committed
107

108 109
	// render (for the topo)
	Algo::Render::GL2::TopoRender* m_render_topo;
Pierre Kraemer's avatar
Pierre Kraemer committed
110

111 112 113 114 115 116
	// just for more compact writing
	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); }
	template<int X>
	Dart PHI(Dart d) { return myMap.phi<X>(d); }
Pierre Kraemer's avatar
Pierre Kraemer committed
117 118 119 120
	/** Attributes that are specific to this plugin **/
};

#endif /* FIRSTPLUGIN_H_ */