From 4c066a82962a9a0634dcfe0a305de7b2a4cacc5b Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Sat, 16 Jan 2016 20:55:45 +0100 Subject: Added the Colormap component. * The Colormap component is a simple rect with a texture mapped that displays a ColorScale with a fixed number of samples. This number of samples is exported as a member const, which is used on other components (such as VoronoiSplat). * The texture mapping is reflecting the colormap lookup used in VoronoiSplat. * The ColorScale class now has a method for sampling the color scale and outputs the samples to iterator-style objects, providing easy intergration with existing code. --- colormap.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 colormap.h (limited to 'colormap.h') diff --git a/colormap.h b/colormap.h new file mode 100644 index 0000000..806624a --- /dev/null +++ b/colormap.h @@ -0,0 +1,40 @@ +#ifndef COLORMAP_H +#define COLORMAP_H + +#include + +#include +#include + +#include + +#include "colorscale.h" + +class Colormap + : public QQuickItem +{ + Q_OBJECT +public: + static const int SAMPLES = 128; + + Colormap(QQuickItem *parent = 0); + ~Colormap(); + +signals: + void colorScaleChanged(const ColorScale &scale) const; + +public slots: + void setColorScale(const ColorScale &scale); + +protected: + QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *); + +private: + QSGNode *newSceneGraph(); + + QSGDynamicTexture *m_texture; + bool m_shouldUpdateTexture; + std::vector m_cmap; +}; + +#endif // COLORMAP_H -- cgit v1.2.3