firstPlugin.cpp 1.68 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1 2 3
#include "firstPlugin.h"
#include "Algo/Geometry/boundingbox.h"

Pierre Kraemer's avatar
Pierre Kraemer committed
4
void FirstPlugin::cb_initGL(View *view)
5
{
Pierre Kraemer's avatar
Pierre Kraemer committed
6
	if (view)
7 8 9
	{
		// bounding box of scene
		Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);
Pierre Kraemer's avatar
Pierre Kraemer committed
10

Pierre Kraemer's avatar
Pierre Kraemer committed
11
//		scene->firstViewFitSphere(bb.center()[0], bb.center()[1], bb.center()[2], bb.maxSize());
Pierre Kraemer's avatar
Pierre Kraemer committed
12

13
		m_render_topo = new Algo::Render::GL2::TopoRender() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
14

15 16 17
		// render the topo of the map without boundary darts
		SelectorDartNoBoundary<PFP::MAP> nb(myMap);
		m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f, nb);
Pierre Kraemer's avatar
Pierre Kraemer committed
18 19 20
	}
}

Pierre Kraemer's avatar
Pierre Kraemer committed
21
void FirstPlugin::cb_redraw(View* view)
22
{
Pierre Kraemer's avatar
Pierre Kraemer committed
23 24 25
	m_render_topo->drawTopo();
}

26
bool FirstPlugin::enable()
27 28 29 30
{
	// creation of 2 new faces: 1 triangle and 1 square
	Dart d1 = myMap.newFace(3);
	Dart d2 = myMap.newFace(4);
Pierre Kraemer's avatar
Pierre Kraemer committed
31

32 33
	// sew these faces along one of their edge
	myMap.sewFaces(d1, d2);
Pierre Kraemer's avatar
Pierre Kraemer committed
34

35 36 37
	// creation of a new attribute on vertices of type 3D vector for position.
	// a handler to this attribute is returned
	position = myMap.addAttribute<VEC3, VERTEX>("position");
Pierre Kraemer's avatar
Pierre Kraemer committed
38

39 40 41 42 43 44
	// affect position by moving in the map
	position[d1] = VEC3(0, 0, 0);
	position[PHI1(d1)] = VEC3(2, 0, 0);
	position[PHI_1(d1)] = VEC3(1, 2, 0);
	position[PHI<11>(d2)] = VEC3(0, -2, 0);
	position[PHI_1(d2)] = VEC3(2, -2, 0);
Pierre Kraemer's avatar
Pierre Kraemer committed
45

Pierre Kraemer's avatar
Pierre Kraemer committed
46
	m_render_topo = NULL;
Pierre Kraemer's avatar
Pierre Kraemer committed
47

48 49
	return true;
}
Pierre Kraemer's avatar
Pierre Kraemer committed
50

51 52
void FirstPlugin::disable()
{
Pierre Kraemer's avatar
Pierre Kraemer committed
53
	if (m_render_topo)
54 55
	{
		delete m_render_topo;
Pierre Kraemer's avatar
Pierre Kraemer committed
56 57 58 59 60 61 62 63
	}
}

/**
 * If we want to compile this plugin in debug mode,
 * we also define a DEBUG macro at the compilation
 */
#ifndef DEBUG
Pierre Kraemer's avatar
Pierre Kraemer committed
64 65 66
// essential Qt function:
// arguments are
//  - the complied name of the plugin
Pierre Kraemer's avatar
Pierre Kraemer committed
67
//  - the main class of our plugin
Pierre Kraemer's avatar
Pierre Kraemer committed
68
Q_EXPORT_PLUGIN2(FirstPlugin, FirstPlugin)
Pierre Kraemer's avatar
Pierre Kraemer committed
69
#else
Pierre Kraemer's avatar
Pierre Kraemer committed
70
Q_EXPORT_PLUGIN2(FirstPluginD, FirstPlugin)
Pierre Kraemer's avatar
Pierre Kraemer committed
71
#endif