QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
Loading...
Searching...
No Matches
qwt3d_color.h
1#ifndef QWT3D_COLOR_H
2#define QWT3D_COLOR_H
3
4#include <qstring.h>
5
6#include "qwt3d_global.h"
7#include "qwt3d_types.h"
8
24class QWT3D_EXPORT Qwt3DColor
25{
26public:
27 // Implement your color model here
28 virtual RGBA operator()(double x, double y, double z) const = 0;
29 virtual RGBA operator()(Triple const& t) const
30 {
31 return this->operator()(t.x, t.y, t.z);
32 }
33 // Should create a color vector usable by Qwt3DColorLegend. The default implementation returns its argument
34 virtual ColorVector& createVector(ColorVector& vec)
35 {
36 return vec;
37 }
38
39 void destroy() const
40 {
41 delete this;
42 }
43
45 void setActiveRange(double zMin, double zMax)
46 {
47 m_zMin = zMin;
48 m_zMax = zMax;
49 }
50
51protected:
52 virtual ~Qwt3DColor()
53 {
54 }
55
57 double activeZMin() const { return m_zMin; }
59 double activeZMax() const { return m_zMax; }
60
61private:
62 double m_zMin = 0.0;
63 double m_zMax = 1.0;
64};
65
71class QWT3D_EXPORT Qwt3DStandardColor : public Qwt3DColor
72{
73 QWT_DECLARE_PRIVATE(Qwt3DStandardColor)
74
75public:
76 // Initializes with a ColorVector of the given size sampled from the viridis colormap (default)
77 explicit Qwt3DStandardColor(unsigned size = 100);
78 ~Qwt3DStandardColor() override;
79 // Receives z-dependent color from ColorVector
80 RGBA operator()(double x, double y, double z) const override;
81 void setColorVector(ColorVector const& cv);
82 // Resets the standard colors
83 void reset(unsigned size = 100);
84 // Sets unitary alpha value for all colors
85 void setAlpha(double a);
86 // Creates color vector for Qwt3DColorLegend - essentially a copy from the internal vector
87 ColorVector& createVector(ColorVector& vec) override;
88
89 // Set colormap from a preset name (e.g. "viridis", "plasma", "jet")
90 void setPreset(const QString& presetName, unsigned size = 100);
91
92 // Returns the current preset name (empty if set via setColorVector)
93 QString presetName() const;
94 // Returns the number of colors in the color vector
95 unsigned colorCount() const;
96 // Returns the alpha value applied by the last setAlpha() call (default 1.0)
97 double alpha() const;
98};
99
100
101#endif
Abstract base class for color functors.
Definition qwt3d_color.h:25
double activeZMin() const
Lower bound of the active z-range (default 0.0)
Definition qwt3d_color.h:57
void setActiveRange(double zMin, double zMax)
Sets the active z-range used for color normalization (pushed by the owning Qwt3DPlotItem before VBO/l...
Definition qwt3d_color.h:45
double activeZMax() const
Upper bound of the active z-range (default 1.0)
Definition qwt3d_color.h:59
Standard color model for Qwt3DPlot - implements the data driven operator()(double x,...
Definition qwt3d_color.h:72
Red-Green-Blue-Alpha value.
Definition qwt3d_types.h:395
Triple [x,y,z].
Definition qwt3d_types.h:201