surface_render.h 3.94 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
2
3
4
5
6
7
8
#ifndef _SURFACE_RENDER_PLUGIN_H_
#define _SURFACE_RENDER_PLUGIN_H_

#include "plugin_interaction.h"
#include "surface_render_dockTab.h"

#include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderPhong.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
9
#include "Utils/Shaders/shaderColorPerVertex.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/pointSprite.h"

namespace CGoGN
{

namespace SCHNApps
{

class MapHandlerGen;

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

	MapParameters() :
		positionVBO(NULL),
		normalVBO(NULL),
Pierre Kraemer's avatar
Pierre Kraemer committed
32
		colorVBO(NULL),
Pierre Kraemer's avatar
Pierre Kraemer committed
33
34
35
36
		verticesScaleFactor(1.0f),
		renderVertices(false),
		renderEdges(false),
		renderFaces(true),
37
		faceStyle(FLAT),
Pierre Kraemer's avatar
Pierre Kraemer committed
38
		diffuseColor(0.85f,0.25f,0.19f,0.0f),
Sylvain Thery's avatar
Sylvain Thery committed
39
		simpleColor(0.0f,0.0f,0.0f,0.0f),
40
41
		vertexColor(0.0f,0.0f,1.0f,0.0f),
		backColor(0.85f, 0.25f, 0.19f, 0.0f)
Pierre Kraemer's avatar
Pierre Kraemer committed
42
43
44
45
	{}

	Utils::VBO* positionVBO;
	Utils::VBO* normalVBO;
Pierre Kraemer's avatar
Pierre Kraemer committed
46
47
	Utils::VBO* colorVBO;

Pierre Kraemer's avatar
Pierre Kraemer committed
48
	float verticesScaleFactor;
Sylvain Thery's avatar
Sylvain Thery committed
49
	float basePSradius;
Pierre Kraemer's avatar
Pierre Kraemer committed
50
51
52
	bool renderVertices;
	bool renderEdges;
	bool renderFaces;
53
	bool renderBoundary;
54
	bool renderBackfaces;
Pierre Kraemer's avatar
Pierre Kraemer committed
55
	FaceShadingStyle faceStyle;
56
57
58
59

	Geom::Vec4f diffuseColor;
	Geom::Vec4f simpleColor;
	Geom::Vec4f vertexColor;
60
	Geom::Vec4f backColor;
Pierre Kraemer's avatar
Pierre Kraemer committed
61
62
};

Pierre Kraemer's avatar
Pierre Kraemer committed
63
class Surface_Render_Plugin : public PluginInteraction
Pierre Kraemer's avatar
Pierre Kraemer committed
64
65
{
	Q_OBJECT
Pierre Kraemer's avatar
Pierre Kraemer committed
66

Pierre Kraemer's avatar
Pierre Kraemer committed
67
	Q_INTERFACES(CGoGN::SCHNApps::Plugin)
Sylvain Thery's avatar
Sylvain Thery committed
68
69
70
#if CGOGN_QT_DESIRED_VERSION == 5
	Q_PLUGIN_METADATA(IID "CGoGN.SCHNapps.Plugin")
#endif
Pierre Kraemer's avatar
Pierre Kraemer committed
71

Pierre Kraemer's avatar
Pierre Kraemer committed
72
	friend class Surface_Render_DockTab;
Pierre Kraemer's avatar
Pierre Kraemer committed
73
74

public:
Pierre Kraemer's avatar
Pierre Kraemer committed
75
	Surface_Render_Plugin()
Pierre Kraemer's avatar
Pierre Kraemer committed
76
77
	{}

Pierre Kraemer's avatar
Pierre Kraemer committed
78
	~Surface_Render_Plugin()
Pierre Kraemer's avatar
Pierre Kraemer committed
79
80
81
82
83
84
	{}

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

85
86
	virtual void draw(View *view) {}
	virtual void drawMap(View* view, MapHandlerGen* map);
Pierre Kraemer's avatar
Pierre Kraemer committed
87

Sylvain Thery's avatar
Sylvain Thery committed
88
89
90
91
92
93
	virtual void keyPress(View* , QKeyEvent* ) {}
	virtual void keyRelease(View* , QKeyEvent* ) {}
	virtual void mousePress(View* , QMouseEvent* ) {}
	virtual void mouseRelease(View* , QMouseEvent* ) {}
	virtual void mouseMove(View* , QMouseEvent* ) {}
	virtual void wheelEvent(View* , QWheelEvent* ) {}
Pierre Kraemer's avatar
Pierre Kraemer committed
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108

	virtual void viewLinked(View *view) {}
	virtual void viewUnlinked(View *view) {}

private slots:
	// slots called from SCHNApps signals
	void selectedViewChanged(View* prev, View* cur);
	void selectedMapChanged(MapHandlerGen* prev, MapHandlerGen* cur);
	void mapAdded(MapHandlerGen* map);
	void mapRemoved(MapHandlerGen* map);

	// slots called from MapHandler signals
	void vboAdded(Utils::VBO* vbo);
	void vboRemoved(Utils::VBO* vbo);

109
	void schnappsClosing();
Sylvain Thery's avatar
Sylvain Thery committed
110

Pierre Kraemer's avatar
Pierre Kraemer committed
111
112
113
114
public slots:
	// slots for Python calls
	void changePositionVBO(const QString& view, const QString& map, const QString& vbo);
	void changeNormalVBO(const QString& view, const QString& map, const QString& vbo);
Pierre Kraemer's avatar
Pierre Kraemer committed
115
	void changeColorVBO(const QString& view, const QString& map, const QString& vbo);
Pierre Kraemer's avatar
Pierre Kraemer committed
116
117
118
119
	void changeRenderVertices(const QString& view, const QString& map, bool b);
	void changeVerticesScaleFactor(const QString&view, const QString& map, float f);
	void changeRenderEdges(const QString& view, const QString& map, bool b);
	void changeRenderFaces(const QString& view, const QString& map, bool b);
Sylvain Thery's avatar
Sylvain Thery committed
120
	void changeFacesStyle(const QString& view, const QString& map, int);
121
	void changeRenderBoundary(const QString& view, const QString& map, bool b);
122
123
124
	void changeFaceColor(const QString& view, const QString& map, float r, float g, float b);
	void changeEdgeColor(const QString& view, const QString& map, float r, float g, float b);
	void changeVertexColor(const QString& view, const QString& map, float r, float g, float b);
125
	void changeBackColor(const QString& view, const QString& map, float r, float g, float b);
126
	void changeRenderBackfaces(const QString& view, const QString& map, bool b);
127

128

Pierre Kraemer's avatar
Pierre Kraemer committed
129
protected:
Pierre Kraemer's avatar
Pierre Kraemer committed
130
	Surface_Render_DockTab* m_dockTab;
Pierre Kraemer's avatar
Pierre Kraemer committed
131
132
133
134
	QHash<View*, QHash<MapHandlerGen*, MapParameters> > h_viewParameterSet;

	CGoGN::Utils::ShaderFlat* m_flatShader;
	CGoGN::Utils::ShaderPhong* m_phongShader;
Pierre Kraemer's avatar
Pierre Kraemer committed
135
	CGoGN::Utils::ShaderColorPerVertex* m_colorPerVertexShader;
Pierre Kraemer's avatar
Pierre Kraemer committed
136
137
	CGoGN::Utils::ShaderSimpleColor* m_simpleColorShader;
	CGoGN::Utils::PointSprite* m_pointSprite;
Sylvain Thery's avatar
Sylvain Thery committed
138

Pierre Kraemer's avatar
Pierre Kraemer committed
139
140
141
142
143
144
145
};

} // namespace SCHNApps

} // namespace CGoGN

#endif