QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_colormap.h
1/******************************************************************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *****************************************************************************/
9
10#ifndef QWT_COLOR_MAP_H
11#define QWT_COLOR_MAP_H
12
13#include "qwtcore_global.h"
14#include <qcolor.h>
15
16#if QT_VERSION < 0x060000
17template< typename T >
18class QVector;
19#endif
20
32class QWTCORE_EXPORT QwtColorMap
33{
34public:
40 enum Format
41 {
44
55 Indexed
56 };
57
58 explicit QwtColorMap(Format = QwtColorMap::RGB);
59 virtual ~QwtColorMap();
60
61 void setFormat(Format);
62 Format format() const;
63
65 virtual QRgb rgb(double vMin, double vMax, double value) const = 0;
66
67 virtual uint colorIndex(int numColors, double vMin, double vMax, double value) const;
68
69 QColor color(double vMin, double vMax, double value) const;
70 virtual QVector< QRgb > colorTable(int numColors) const;
71 virtual QVector< QRgb > colorTable256() const;
72
73private:
74 QwtColorMap(const QwtColorMap&) = delete;
75 QwtColorMap& operator=(const QwtColorMap&) = delete;
76
77 Format m_format;
78};
79
86class QWTCORE_EXPORT QwtLinearColorMap : public QwtColorMap
87{
88public:
93 enum Mode
94 {
97
99 ScaledColors
100 };
101
103
104 QwtLinearColorMap(const QColor& from, const QColor& to, QwtColorMap::Format = QwtColorMap::RGB);
105
106 ~QwtLinearColorMap() override;
107
108 void setMode(Mode);
109 Mode mode() const;
110
111 void setColorInterval(const QColor& color1, const QColor& color2);
112 void addColorStop(double value, const QColor&);
113 QVector< double > stopPos() const;
114 QVector< QColor > stopColors() const;
115 QColor color1() const;
116 QColor color2() const;
117
118 virtual QRgb rgb(double vMin, double vMax, double value) const override;
119
120 virtual uint colorIndex(int numColors, double vMin, double vMax, double value) const override;
121
122 class ColorStops;
123
124private:
125 QWT_DECLARE_PRIVATE(QwtLinearColorMap)
126};
127
131class QWTCORE_EXPORT QwtAlphaColorMap : public QwtColorMap
132{
133public:
134 explicit QwtAlphaColorMap(const QColor& = QColor(Qt::gray));
135 ~QwtAlphaColorMap() override;
136
137 void setAlphaInterval(int alpha1, int alpha2);
138
139 int alpha1() const;
140 int alpha2() const;
141
142 void setColor(const QColor&);
143 QColor color() const;
144
145 virtual QRgb rgb(double vMin, double vMax, double value) const override;
146
147private:
148 QWT_DECLARE_PRIVATE(QwtAlphaColorMap)
149};
150
159class QWTCORE_EXPORT QwtHueColorMap : public QwtColorMap
160{
161public:
163 ~QwtHueColorMap() override;
164
165 void setHueInterval(int hue1, int hue2); // direction ?
166 void setSaturation(int saturation);
167 void setValue(int value);
168 void setAlpha(int alpha);
169
170 int hue1() const;
171 int hue2() const;
172 int saturation() const;
173 int value() const;
174 int alpha() const;
175
176 virtual QRgb rgb(double vMin, double vMax, double value) const override;
177
178private:
179 QWT_DECLARE_PRIVATE(QwtHueColorMap)
180};
181
187class QWTCORE_EXPORT QwtSaturationValueColorMap : public QwtColorMap
188{
189public:
192
193 void setHue(int hue);
194 void setSaturationInterval(int sat1, int sat2);
195 void setValueInterval(int value1, int value2);
196 void setAlpha(int alpha);
197
198 int hue() const;
199 int saturation1() const;
200 int saturation2() const;
201 int value1() const;
202 int value2() const;
203 int alpha() const;
204
205 virtual QRgb rgb(double vMin, double vMax, double value) const override;
206
207private:
208 QWT_DECLARE_PRIVATE(QwtSaturationValueColorMap)
209};
210
211// Map a value into a color.
212inline QColor QwtColorMap::color(double vMin, double vMax, double value) const
213{
214 return QColor::fromRgba(rgb(vMin, vMax, value));
215}
216
217// Return the intended format of the color map.
218inline QwtColorMap::Format QwtColorMap::format() const
219{
220 return m_format;
221}
222
223#endif
Definition qwt_clipper.h:41
QwtAlphaColorMap varies the alpha value of a color.
Definition qwt_colormap.h:132
QwtColorMap is used to map values into colors.
Definition qwt_colormap.h:33
virtual QRgb rgb(double vMin, double vMax, double value) const =0
Map a value of a given interval into a RGB value.
Format
Format for color mapping
Definition qwt_colormap.h:41
@ RGB
The map is intended to map into RGB values.
Definition qwt_colormap.h:43
QwtHueColorMap varies the hue value of the HSV color model.
Definition qwt_colormap.h:160
QwtLinearColorMap builds a color map from color stops.
Definition qwt_colormap.h:87
Mode
Mode of color map
Definition qwt_colormap.h:94
@ FixedColors
Return the color from the next lower color stop
Definition qwt_colormap.h:96
QwtSaturationValueColorMap varies the saturation and/or value for a given hue in the HSV color model.
Definition qwt_colormap.h:188