renderVector.h 2.44 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
#ifndef _RENDERVECTOR_PLUGIN_H_
#define _RENDERVECTOR_PLUGIN_H_

#include "plugin.h"
#include "ui_renderVector.h"

#include "Utils/Shaders/shaderVectorPerVertex.h"


using namespace CGoGN;
using namespace SCHNApps;


14
struct PerMapParameterSet
15
{
16
17
18
	PerMapParameterSet() :
		positionVBO(NULL),
		vectorsScaleFactor(1.0f)
19
20
	{}

21
22
	PerMapParameterSet(MapHandlerGen* map);

23
	Utils::VBO* positionVBO;
24
	std::vector<Utils::VBO*> vectorVBO;
25
26
27
	float vectorsScaleFactor;
};

28
struct ParameterSet
29
{
30
31
32
33
	ParameterSet() : selectedMap(NULL)
	{}

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

37

38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class RenderVectorPlugin;

class RenderVectorDockTab : public QWidget, public Ui::RenderVectorWidget
{
public:
	RenderVectorDockTab(RenderVectorPlugin* p) : plugin(p)
	{
		setupUi(this);
	}

	void refreshUI(ParameterSet* params);

private:
	RenderVectorPlugin* plugin;
};


55
56
57
58
59
60
class RenderVectorPlugin : public Plugin
{
	Q_OBJECT
	Q_INTERFACES(CGoGN::SCHNApps::Plugin)

public:
61
	RenderVectorPlugin() : b_refreshingUI(false)
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
	{
		setProvidesRendering(true);
	}

	~RenderVectorPlugin()
	{}

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

85
	void setRefreshingUI(bool b) { b_refreshingUI = b; }
86

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

	CGoGN::Utils::ShaderVectorPerVertex* m_vectorShader;

93
94
	bool b_refreshingUI;

95
public slots:
96
97
98
99
100
101
102
103
104
105
	void mapLinked(MapHandlerGen* m);
	void mapUnlinked(MapHandlerGen* m);
	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 changeSelectedVectorsVBO(View* view, MapHandlerGen* map, const std::vector<Utils::VBO*>& vbos);
	void changeVectorsScaleFactor(View* view, MapHandlerGen* map, int i);

106
107
	void cb_selectedMapChanged();
	void cb_positionVBOChanged(int index);
108
	void cb_selectedVectorsVBOChanged();
109
110
111
112
	void cb_vectorsScaleFactorChanged(int i);
};

#endif