render.h 3.23 KB
Newer Older
1
2
3
4
5
6
7
#ifndef _RENDER_PLUGIN_H_
#define _RENDER_PLUGIN_H_

#include "plugin.h"
#include "ui_render.h"

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


Pierre Kraemer's avatar
Pierre Kraemer committed
13
14
15
16
17
18
19
20
21
22
using namespace CGoGN;
using namespace SCHNApps;


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

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

35
36
	PerMapParameterSet(MapHandlerGen* map);

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

46
47
48
49
50
51
52
53
54
55
56
struct ParameterSet
{
	ParameterSet() : selectedMap(NULL)
	{}

	QHash<QString, PerMapParameterSet> perMap;
	MapHandlerGen* selectedMap;
};


class RenderPlugin;
57

58
59
60
class RenderDockTab : public QWidget, public Ui::RenderWidget
{
public:
61
62
63
64
	RenderDockTab(RenderPlugin* p) : plugin(p)
	{
		setupUi(this);
	}
65
66

	void refreshUI(ParameterSet* params);
67
68
69

private:
	RenderPlugin* plugin;
70
71
72
};


73
74
75
class RenderPlugin : public Plugin
{
	Q_OBJECT
Pierre Kraemer's avatar
Pierre Kraemer committed
76
	Q_INTERFACES(CGoGN::SCHNApps::Plugin)
77
78

public:
79
	RenderPlugin() : b_refreshingUI(false)
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
	{
		setProvidesRendering(true);
	}

	~RenderPlugin()
	{}

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

	virtual void redraw(View *view);

	virtual void keyPress(View* view, int key) {}
	virtual void keyRelease(View* view, int key) {}
	virtual void mousePress(View* view, int button, int x, int y) {}
	virtual void mouseRelease(View* view, int button, int x, int y) {}
	virtual void mouseMove(View* view, int buttons, int x, int y) {}
	virtual void wheelEvent(View* view, int delta, int x, int y) {}

99
	void setRefreshingUI(bool b) { b_refreshingUI = b; }
100

101
102
protected:
	RenderDockTab* m_dockTab;
103
	QHash<View*, ParameterSet*> h_viewParams;
104
105

	CGoGN::Utils::ShaderFlat* m_flatShader;
Pierre Kraemer's avatar
Pierre Kraemer committed
106
107
108
	CGoGN::Utils::ShaderPhong* m_phongShader;
	CGoGN::Utils::ShaderSimpleColor* m_simpleColorShader;
	CGoGN::Utils::PointSprite* m_pointSprite;
109

110
111
	bool b_refreshingUI;

112
public slots:
113
114
115
116
	void viewLinked(View* view, Plugin* plugin);
	void viewUnlinked(View* view, Plugin* plugin);
	void currentViewChanged(View* view);

117
118
	void mapLinked(MapHandlerGen* m);
	void mapUnlinked(MapHandlerGen* m);
119

120
121
122
123
124
125
126
127
128
129
130
131
	void vboAdded(Utils::VBO* vbo);
	void vboRemoved(Utils::VBO* vbo);

	void changeSelectedMap(View* view, MapHandlerGen* map);
	void changePositionVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo);
	void changeNormalVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo);
	void changeRenderVertices(View* view, MapHandlerGen* map, bool b);
	void changeVerticesScaleFactor(View* view, MapHandlerGen* map, int i);
	void changeRenderEdges(View* view, MapHandlerGen* map, bool b);
	void changeRenderFaces(View* view, MapHandlerGen* map, bool b);
	void changeFacesStyle(View* view, MapHandlerGen* map, FaceShadingStyle style);

132
133
134
	void cb_selectedMapChanged();
	void cb_positionVBOChanged(int index);
	void cb_normalVBOChanged(int index);
135
136
137
138
	void cb_renderVerticesChanged(bool b);
	void cb_verticesScaleFactorChanged(int i);
	void cb_renderEdgesChanged(bool b);
	void cb_renderFacesChanged(bool b);
Pierre Kraemer's avatar
Pierre Kraemer committed
139
	void cb_faceStyleChanged(QAbstractButton* b);
140
141
142
};

#endif