QWT API (中文) 7.0.1
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_color_map.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 * Modified by ChenZongYan in 2024 <czy.t@163.com>
10 * Summary of major modifications (see ChangeLog.md for full history):
11 * 1. CMake build system & C++11 throughout.
12 * 2. Core panner/ zoomer refactored:
13 * - QwtPanner → QwtCachePanner (pixmap-cache version)
14 * - New real-time QwtPlotPanner derived from QwtPicker.
15 * 3. Zoomer supports multi-axis.
16 * 4. Parasite-plot framework:
17 * - QwtFigure, QwtPlotParasiteLayout, QwtPlotTransparentCanvas,
18 * - QwtPlotScaleEventDispatcher, built-in pan/zoom on axis.
19 * 5. New picker: QwtPlotSeriesDataPicker (works with date axis).
20 * 6. Raster & color-map extensions:
21 * - QwtGridRasterData (2-D table + interpolation)
22 * - QwtLinearColorMap::stopColors(), stopPos() API rename.
23 * 7. Bar-chart: expose pen/brush control.
24 * 8. Amalgamated build: single QwtPlot.h / QwtPlot.cpp pair in src-amalgamate.
25 *****************************************************************************/
26
27#ifndef QWT_COLOR_MAP_H
28#define QWT_COLOR_MAP_H
29
30#include "qwt_global.h"
31#include <qcolor.h>
32
33class QwtInterval;
34
35#if QT_VERSION < 0x060000
36template< typename T >
37class QVector;
38#endif
39
61class QWT_EXPORT QwtColorMap
62{
63public:
69 enum Format
70 {
73
84 Indexed
85 };
86
87 explicit QwtColorMap(Format = QwtColorMap::RGB);
88 virtual ~QwtColorMap();
89
90 void setFormat(Format);
91 Format format() const;
92
94 virtual QRgb rgb(const QwtInterval& interval, double value) const = 0;
95
96 virtual uint colorIndex(int numColors, const QwtInterval& interval, double value) const;
97
98 QColor color(const QwtInterval&, double value) const;
99 virtual QVector< QRgb > colorTable(int numColors) const;
100 virtual QVector< QRgb > colorTable256() const;
101
102private:
103 Q_DISABLE_COPY(QwtColorMap)
104
105 Format m_format;
106};
107
121class QWT_EXPORT QwtLinearColorMap : public QwtColorMap
122{
123public:
128 enum Mode
129 {
132
134 ScaledColors
135 };
136
138
139 QwtLinearColorMap(const QColor& from, const QColor& to, QwtColorMap::Format = QwtColorMap::RGB);
140
141 virtual ~QwtLinearColorMap();
142
143 void setMode(Mode);
144 Mode mode() const;
145
146 void setColorInterval(const QColor& color1, const QColor& color2);
147 void addColorStop(double value, const QColor&);
148 QVector< double > stopPos() const;
149 QVector< QColor > stopColors() const;
150 QColor color1() const;
151 QColor color2() const;
152
153 virtual QRgb rgb(const QwtInterval&, double value) const override;
154
155 virtual uint colorIndex(int numColors, const QwtInterval&, double value) const override;
156
157 class ColorStops;
158
159private:
160 class PrivateData;
161 PrivateData* m_data;
162};
163
172class QWT_EXPORT QwtAlphaColorMap : public QwtColorMap
173{
174public:
175 explicit QwtAlphaColorMap(const QColor& = QColor(Qt::gray));
176 virtual ~QwtAlphaColorMap();
177
178 void setAlphaInterval(int alpha1, int alpha2);
179
180 int alpha1() const;
181 int alpha2() const;
182
183 void setColor(const QColor&);
184 QColor color() const;
185
186 virtual QRgb rgb(const QwtInterval&, double value) const override;
187
188private:
189 class PrivateData;
190 PrivateData* m_data;
191};
192
210class QWT_EXPORT QwtHueColorMap : public QwtColorMap
211{
212public:
214 virtual ~QwtHueColorMap();
215
216 void setHueInterval(int hue1, int hue2); // direction ?
217 void setSaturation(int saturation);
218 void setValue(int value);
219 void setAlpha(int alpha);
220
221 int hue1() const;
222 int hue2() const;
223 int saturation() const;
224 int value() const;
225 int alpha() const;
226
227 virtual QRgb rgb(const QwtInterval&, double value) const override;
228
229private:
230 class PrivateData;
231 PrivateData* m_data;
232};
233
247{
248public:
251
252 void setHue(int hue);
253 void setSaturationInterval(int sat1, int sat2);
254 void setValueInterval(int value1, int value2);
255 void setAlpha(int alpha);
256
257 int hue() const;
258 int saturation1() const;
259 int saturation2() const;
260 int value1() const;
261 int value2() const;
262 int alpha() const;
263
264 virtual QRgb rgb(const QwtInterval&, double value) const override;
265
266private:
267 class PrivateData;
268 PrivateData* m_data;
269};
270
271// Map a value into a color.
272 inline QColor QwtColorMap::color(const QwtInterval& interval, double value) const
273{
274 return QColor::fromRgba(rgb(interval, value));
275}
276
277// Return the intended format of the color map.
278 inline QwtColorMap::Format QwtColorMap::format() const
279{
280 return m_format;
281}
282
283#endif
Definition qwt_clipper.h:40
QwtAlphaColorMap 改变颜色的透明度值。
Definition qwt_color_map.h:173
QwtColorMap 用于将数值映射为颜色。
Definition qwt_color_map.h:62
Format
Format for color mapping
Definition qwt_color_map.h:70
@ RGB
The map is intended to map into RGB values.
Definition qwt_color_map.h:72
virtual QRgb rgb(const QwtInterval &interval, double value) const =0
Map a value of a given interval into a RGB value.
QwtHueColorMap 改变 HSV 颜色模型中的色调值。
Definition qwt_color_map.h:211
表示区间的类
Definition qwt_interval.h:45
QwtLinearColorMap 从颜色停止点构建颜色映射。
Definition qwt_color_map.h:122
Mode
Mode of color map
Definition qwt_color_map.h:129
@ FixedColors
Return the color from the next lower color stop
Definition qwt_color_map.h:131
QwtSaturationValueColorMap 改变 HSV 颜色模型中给定色调的饱和度和/或明度值。
Definition qwt_color_map.h:247