renderVector.h 2.45 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
	{
		setProvidesRendering(true);
	}

	~RenderVectorPlugin()
	{}

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

	virtual void redraw(View *view);

74 75 76 77 78 79
	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) {}
80

81
	void setRefreshingUI(bool b) { b_refreshingUI = b; }
82

83 84
protected:
	RenderVectorDockTab* m_dockTab;
85
	QHash<View*, ParameterSet*> h_viewParams;
86 87 88

	CGoGN::Utils::ShaderVectorPerVertex* m_vectorShader;

89 90
	bool b_refreshingUI;

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

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

99 100 101 102 103 104 105 106
	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);

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

#endif