mapHandler.h 2.07 KB
Newer Older
1 2
#ifndef _MAPHANDLER_H_
#define _MAPHANDLER_H_
3

4
#include <QString>
5

6
#include "types.h"
7 8
#include "view.h"

9 10 11
#include "Topology/generic/functor.h"
#include "Utils/vbo.h"
#include "Algo/Render/GL2/mapRender.h"
12

13
class MapHandlerGen
14 15
{
public:
16 17 18
	MapHandlerGen(const QString& name, Window* window);
	virtual ~MapHandlerGen();

19
	const QString& getName() const { return m_name; }
20
	void setName(const QString& name) { m_name = name; }
21

22
	Window* getWindow() const { return m_window; }
23 24
	void setWindow(Window* w) { m_window = w; }

25 26
	const qglviewer::Vec& getBBmin() const { return m_bbMin; }
	void setBBmin(qglviewer::Vec& v) { m_bbMin = v; }
27

28 29 30
	const qglviewer::Vec& getBBmax() const { return m_bbMax; }
	void setBBmax(qglviewer::Vec& v) { m_bbMax = v; }

31 32 33 34
	float getBBdiagSize() { return (m_bbMax - m_bbMin).norm(); }

	void draw(CGoGN::Utils::GLSLShader* shader, int primitive);

35 36 37 38 39 40
	/*********************************************************
	 * MANAGE VBOs
	 *********************************************************/

	CGoGN::Utils::VBO* getVBO(const std::string& name);
	void deleteVBO(const std::string& name);
41

42 43 44 45 46 47
	/*********************************************************
	 * MANAGE LINKED VIEWS
	 *********************************************************/

	bool linkView(View* view);
	void unlinkView(View* view);
48 49
	const QList<View*>& getLinkedViews() const { return l_views; }
	bool isLinkedToView(View* view) const { return l_views.contains(view); }
50

51
protected:
52
	QString m_name;
53
	Window* m_window;
54

55 56
	CGoGN::Algo::Render::GL2::MapRender* m_render;

57 58
	qglviewer::Vec m_bbMin;
	qglviewer::Vec m_bbMax;
59

60 61
	QList<View*> l_views;

62
	VBOHash h_vbo;
63
};
64

65 66 67 68 69 70 71
template <typename PFP>
class MapHandler : public MapHandlerGen
{
public:
	MapHandler(const QString& name, Window* window, typename PFP::MAP* map) :
		MapHandlerGen(name, window),
		m_map(map)
72
	{}
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88

	~MapHandler()
	{
		if (m_map)
			delete m_map;
	}

	typename PFP::MAP* getMap() { return m_map; }

	void updatePrimitives(int primitive, const CGoGN::FunctorSelect& good)
	{
		m_render->initPrimitives<PFP>(*m_map, good, primitive) ;
	}

protected:
	typename PFP::MAP* m_map;
89 90 91
};

#endif