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

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

7
8
9
//#include "Topology/generic/functor.h"
//#include "Topology/generic/parameters.h"
//#include "Topology/map/embeddedMap2.h"
10
11

#include "Utils/Shaders/shaderFlat.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
12
#include "Utils/Shaders/shaderPhong.h"
13
14
15
16
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/pointSprite.h"


Pierre Kraemer's avatar
Pierre Kraemer committed
17
18
19
20
21
22
23
24
25
26
using namespace CGoGN;
using namespace SCHNApps;


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

27
struct ParameterSet
28
{
29
30
31
32
33
34
	ParameterSet() :
		verticesScaleFactor(1.0f),
		renderVertices(false),
		renderEdges(false),
		renderFaces(true),
		faceStyle(FLAT)
35
36
37
38
39
40
	{}

	float verticesScaleFactor;
	bool renderVertices;
	bool renderEdges;
	bool renderFaces;
Pierre Kraemer's avatar
Pierre Kraemer committed
41
	FaceShadingStyle faceStyle;
42
43
44
};


45
46
47
48
49
50
51
52
53
class RenderDockTab : public QWidget, public Ui::RenderWidget
{
public:
	RenderDockTab() { setupUi(this); }

	void refreshUI(ParameterSet* params);
};


54
55
56
class RenderPlugin : public Plugin
{
	Q_OBJECT
Pierre Kraemer's avatar
Pierre Kraemer committed
57
	Q_INTERFACES(CGoGN::SCHNApps::Plugin)
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

public:
	RenderPlugin()
	{
		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) {}

	virtual void viewLinked(View* view);
	virtual void viewUnlinked(View* view);
	virtual void currentViewChanged(View* view);

84
85
86
	virtual void mapLinked(View* view, MapHandlerGen* m) {}
	virtual void mapUnlinked(View* view, MapHandlerGen* m) {}

87
88
protected:
	RenderDockTab* m_dockTab;
89
	QHash<View*, ParameterSet*> h_viewParams;
90
91

	CGoGN::Utils::ShaderFlat* m_flatShader;
Pierre Kraemer's avatar
Pierre Kraemer committed
92
93
94
	CGoGN::Utils::ShaderPhong* m_phongShader;
	CGoGN::Utils::ShaderSimpleColor* m_simpleColorShader;
	CGoGN::Utils::PointSprite* m_pointSprite;
95
96
97
98
99
100

public slots:
	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
101
	void cb_faceStyleChanged(QAbstractButton* b);
102
103
104
};

#endif