render.h 2.89 KB
Newer Older
1 2 3 4
#ifndef _RENDER_PLUGIN_H_
#define _RENDER_PLUGIN_H_

#include "plugin.h"
5
#include "renderDockTab.h"
6 7

#include "Utils/Shaders/shaderFlat.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
8
#include "Utils/Shaders/shaderPhong.h"
9 10 11
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/pointSprite.h"

12 13
namespace CGoGN
{
14

15 16
namespace SCHNApps
{
Pierre Kraemer's avatar
Pierre Kraemer committed
17 18 19 20 21 22 23

enum FaceShadingStyle
{
	FLAT = 0,
	PHONG = 1
};

24
struct PerMapParameterSet
25
{
26 27 28
	PerMapParameterSet() :
		positionVBO(NULL),
		normalVBO(NULL),
29 30 31 32 33
		verticesScaleFactor(1.0f),
		renderVertices(false),
		renderEdges(false),
		renderFaces(true),
		faceStyle(FLAT)
34 35
	{}

36 37
	PerMapParameterSet(MapHandlerGen* map);

38 39
	Utils::VBO* positionVBO;
	Utils::VBO* normalVBO;
40 41 42 43
	float verticesScaleFactor;
	bool renderVertices;
	bool renderEdges;
	bool renderFaces;
Pierre Kraemer's avatar
Pierre Kraemer committed
44
	FaceShadingStyle faceStyle;
45 46
};

47 48 49 50 51
struct ParameterSet
{
	ParameterSet() : selectedMap(NULL)
	{}

52
	QHash<QString, PerMapParameterSet*> perMap;
53 54 55 56
	MapHandlerGen* selectedMap;
};


57 58 59
class RenderPlugin : public Plugin
{
	Q_OBJECT
Pierre Kraemer's avatar
Pierre Kraemer committed
60
	Q_INTERFACES(CGoGN::SCHNApps::Plugin)
61 62

public:
63
	RenderPlugin()
64 65 66 67 68 69 70 71 72 73 74 75
	{
		setProvidesRendering(true);
	}

	~RenderPlugin()
	{}

	virtual bool enable();
	virtual void disable();

	virtual void redraw(View *view);

76 77 78 79 80 81
	virtual void keyPress(View* view, QKeyEvent* event) {}
	virtual void keyRelease(View* view, QKeyEvent* event) {}
	virtual void mousePress(View* view, QMouseEvent* event) {}
	virtual void mouseRelease(View* view, QMouseEvent* event) {}
	virtual void mouseMove(View* view, QMouseEvent* event) {}
	virtual void wheelEvent(View* view, QWheelEvent* event) {}
82 83 84

protected:
	RenderDockTab* m_dockTab;
85
	QHash<View*, ParameterSet*> h_viewParams;
86 87

	CGoGN::Utils::ShaderFlat* m_flatShader;
Pierre Kraemer's avatar
Pierre Kraemer committed
88 89 90
	CGoGN::Utils::ShaderPhong* m_phongShader;
	CGoGN::Utils::ShaderSimpleColor* m_simpleColorShader;
	CGoGN::Utils::PointSprite* m_pointSprite;
91 92

public slots:
93 94 95 96
	void viewLinked(View* view, Plugin* plugin);
	void viewUnlinked(View* view, Plugin* plugin);
	void currentViewChanged(View* view);

97 98
	void mapLinked(MapHandlerGen* m);
	void mapUnlinked(MapHandlerGen* m);
99

100 101 102 103 104 105
protected:
	void addManagedMap(View *v, MapHandlerGen* m);
	void removeManagedMap(View *v, MapHandlerGen* m);

public slots:

106 107 108
	void vboAdded(Utils::VBO* vbo);
	void vboRemoved(Utils::VBO* vbo);

109 110
	void changeSelectedMap(View* view, MapHandlerGen* map);

111 112 113 114 115 116 117
	void changePositionVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI = false);
	void changeNormalVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI = false);
	void changeRenderVertices(View* view, MapHandlerGen* map, bool b, bool fromUI = false);
	void changeVerticesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI = false);
	void changeRenderEdges(View* view, MapHandlerGen* map, bool b, bool fromUI = false);
	void changeRenderFaces(View* view, MapHandlerGen* map, bool b, bool fromUI = false);
	void changeFacesStyle(View* view, MapHandlerGen* map, FaceShadingStyle style, bool fromUI = false);
118 119
};

120 121 122 123
} // namespace SCHNApps

} // namespace CGoGN

124
#endif