mapHandler.h 2.37 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 19
	MapHandlerGen(const QString& name, Window* window);
	virtual ~MapHandlerGen();

	virtual void draw(CGoGN::Utils::GLSLShader* shader, int primitive) = 0;
20

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

24 25 26
	Window* getWindow() { return m_window; }
	void setWindow(Window* w) { m_window = w; }

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

30 31 32 33 34 35 36 37 38 39 40 41
	const qglviewer::Vec& getBBmax() const { return m_bbMax; }
	void setBBmax(qglviewer::Vec& v) { m_bbMax = v; }

	/*********************************************************
	 * MANAGE VBOs
	 *********************************************************/

	CGoGN::Utils::VBO* getVBO(const std::string& name);
	void deleteVBO(const std::string& name);
//	CGoGN::Utils::VBO* addVBO(const QString& name);
//	CGoGN::Utils::VBO* findFirstVBOMatching(const QRegExp& regexp);
//	QList<CGoGN::Utils::VBO*> findVBOsMatching(const QRegExp& regexp);
42

43
	int getNbVBO() { return h_vbo.count(); }
44

45 46 47 48 49 50 51 52 53
	/*********************************************************
	 * MANAGE LINKED VIEWS
	 *********************************************************/

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

54
protected:
55
	QString m_name;
56
	Window* m_window;
57 58 59

	qglviewer::Vec m_bbMin;
	qglviewer::Vec m_bbMax;
60

61 62
	QList<View*> l_views;

63
	VBOHash h_vbo;
64
};
65

66 67 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 93 94 95 96 97
template <typename PFP>
class MapHandler : public MapHandlerGen
{
public:
	MapHandler(const QString& name, Window* window, typename PFP::MAP* map) :
		MapHandlerGen(name, window),
		m_map(map)
	{
		m_render = new CGoGN::Algo::Render::GL2::MapRender();
	}

	~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) ;
	}

	void draw(CGoGN::Utils::GLSLShader* shader, int primitive)
	{
		m_render->draw(shader, primitive);
	}

protected:
	typename PFP::MAP* m_map;
	CGoGN::Algo::Render::GL2::MapRender* m_render;
98 99 100
};

#endif