renderScalar.h 2.28 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#ifndef _RENDERSCALAR_PLUGIN_H_
#define _RENDERSCALAR_PLUGIN_H_

#include "plugin.h"
#include "renderScalarDockTab.h"

#include "Utils/Shaders/shaderScalarField.h"

namespace CGoGN
{

namespace SCHNApps
{

15 16 17 18 19 20 21
enum ColorMap {
	BlueWhiteRed = 0,
	CyanWhiteRed = 1,
	BlueCyanGreenYellowRed = 2,
	BlueGreenRed = 3
};

22 23 24 25 26 27 28 29 30
struct PerMapParameterSet
{
	PerMapParameterSet() :
		positionVBO(NULL)
	{}

	PerMapParameterSet(MapHandlerGen* map);

	Utils::VBO* positionVBO;
31 32
	Utils::VBO* scalarVBO;
	float scalarMin, scalarMax;
33
	int colorMap;
34
	int expansion;
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 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 84 85 86 87 88 89 90 91 92 93 94
};

struct ParameterSet
{
	ParameterSet() : selectedMap(NULL)
	{}

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


class RenderScalarPlugin : public Plugin
{
	Q_OBJECT
	Q_INTERFACES(CGoGN::SCHNApps::Plugin)

public:
	RenderScalarPlugin()
	{
		setProvidesRendering(true);
	}

	~RenderScalarPlugin()
	{}

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

	virtual void redraw(View *view);

	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) {}

protected:
	RenderScalarDockTab* m_dockTab;
	QHash<View*, ParameterSet*> h_viewParams;

	CGoGN::Utils::ShaderScalarField* m_scalarShader;

public slots:
	void viewLinked(View* view, Plugin* plugin);
	void viewUnlinked(View* view, Plugin* plugin);
	void currentViewChanged(View* view);

	void mapLinked(MapHandlerGen* m);
	void mapUnlinked(MapHandlerGen* m);

protected:
	void addManagedMap(View *v, MapHandlerGen* m);
	void removeManagedMap(View *v, MapHandlerGen* m);

public slots:
	void changeSelectedMap(View* view, MapHandlerGen* map);

	void changePositionVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI = false);
95
	void changeScalarVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI = false);
96
	void changeColorMap(View* view, MapHandlerGen* map, int c, bool fromUI = false);
97
	void changeExpansion(View* view, MapHandlerGen* map, int i, bool fromUI = false);
98 99

	void attributeModified(unsigned int orbit, QString nameAttr);
100 101 102 103 104 105 106
};

} // namespace SCHNApps

} // namespace CGoGN

#endif