surface_render.h 3.45 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#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"
#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),
		verticesScaleFactor(1.0f),
		renderVertices(false),
		renderEdges(false),
		renderFaces(true),
35 36 37 38 39
		faceStyle(FLAT),
		diffuseColor(0.8,0.9,0.7,0.0),
		simpleColor(0.0,0.0,0.0,0.0),
		vertexColor(0.0,0.0,1.0,0.0)

Pierre Kraemer's avatar
Pierre Kraemer committed
40 41 42 43 44 45 46 47
	{}

	Utils::VBO* positionVBO;
	Utils::VBO* normalVBO;
	float verticesScaleFactor;
	bool renderVertices;
	bool renderEdges;
	bool renderFaces;
48
	bool renderBoundary;
Pierre Kraemer's avatar
Pierre Kraemer committed
49
	FaceShadingStyle faceStyle;
50 51 52 53

	Geom::Vec4f diffuseColor;
	Geom::Vec4f simpleColor;
	Geom::Vec4f vertexColor;
Pierre Kraemer's avatar
Pierre Kraemer committed
54 55
};

Pierre Kraemer's avatar
Pierre Kraemer committed
56
class Surface_Render_Plugin : public PluginInteraction
Pierre Kraemer's avatar
Pierre Kraemer committed
57 58 59
{
	Q_OBJECT
	Q_INTERFACES(CGoGN::SCHNApps::Plugin)
Sylvain Thery's avatar
Sylvain Thery committed
60 61 62
#if CGOGN_QT_DESIRED_VERSION == 5
	Q_PLUGIN_METADATA(IID "CGoGN.SCHNapps.Plugin")
#endif
Pierre Kraemer's avatar
Pierre Kraemer committed
63
	friend class Surface_Render_DockTab;
Pierre Kraemer's avatar
Pierre Kraemer committed
64 65

public:
Pierre Kraemer's avatar
Pierre Kraemer committed
66
	Surface_Render_Plugin()
Pierre Kraemer's avatar
Pierre Kraemer committed
67 68
	{}

Pierre Kraemer's avatar
Pierre Kraemer committed
69
	~Surface_Render_Plugin()
Pierre Kraemer's avatar
Pierre Kraemer committed
70 71 72 73 74 75
	{}

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

76 77
	virtual void draw(View *view) {}
	virtual void drawMap(View* view, MapHandlerGen* map);
Pierre Kraemer's avatar
Pierre Kraemer committed
78

Sylvain Thery's avatar
Sylvain Thery committed
79 80 81 82 83 84
	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
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

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

Sylvain Thery's avatar
Sylvain Thery committed
100 101
	void appsFinished();

Pierre Kraemer's avatar
Pierre Kraemer committed
102 103 104 105 106 107 108 109 110
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);
	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);
	void changeFacesStyle(const QString& view, const QString& map, MapParameters::FaceShadingStyle style);
111
	void changeRenderBoundary(const QString& view, const QString& map, bool b);
112 113 114 115
	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);

Pierre Kraemer's avatar
Pierre Kraemer committed
116
protected:
Pierre Kraemer's avatar
Pierre Kraemer committed
117
	Surface_Render_DockTab* m_dockTab;
Pierre Kraemer's avatar
Pierre Kraemer committed
118 119 120 121 122 123 124 125 126 127 128 129 130
	QHash<View*, QHash<MapHandlerGen*, MapParameters> > h_viewParameterSet;

	CGoGN::Utils::ShaderFlat* m_flatShader;
	CGoGN::Utils::ShaderPhong* m_phongShader;
	CGoGN::Utils::ShaderSimpleColor* m_simpleColorShader;
	CGoGN::Utils::PointSprite* m_pointSprite;
};

} // namespace SCHNApps

} // namespace CGoGN

#endif