Qwt User's Guide: qwt_color_map.h Source File

Qwt User's Guide 6.3.0

Loading...
Searching...
No Matches
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
10#ifndef QWT_COLOR_MAP_H
11#define QWT_COLOR_MAP_H
12
13#include "qwt_global.h"
14#include <qcolor.h>
15
16class QwtInterval;
17
18#if QT_VERSION < 0x060000
19template< typename T > class QVector;
20#endif
21
37 class QWT_EXPORT QwtColorMap
38{
39 public:
45 enum Format
46 {
48 RGB,
49
60 Indexed
61 };
62
63 explicit QwtColorMap( Format = QwtColorMap::RGB );
64 virtual ~QwtColorMap();
65
66 void setFormat( Format );
67 Format format() const;
68
76 virtual QRgb rgb( const QwtInterval& interval, double value ) const = 0;
77
78 virtual uint colorIndex( int numColors,
79 const QwtInterval& interval, double value ) const;
80
81 QColor color( const QwtInterval&, double value ) const;
82 virtual QVector< QRgb > colorTable( int numColors ) const;
83 virtual QVector< QRgb > colorTable256() const;
84
85 private:
86 Q_DISABLE_COPY(QwtColorMap)
87
88 Format m_format;
89};
90
98 class QWT_EXPORT QwtLinearColorMap : public QwtColorMap
99{
100 public:
105 enum Mode
106 {
108 FixedColors,
109
111 ScaledColors
112 };
113
114 explicit QwtLinearColorMap( QwtColorMap::Format = QwtColorMap::RGB );
115
116 QwtLinearColorMap( const QColor& from, const QColor& to,
117 QwtColorMap::Format = QwtColorMap::RGB );
118
119 virtual ~QwtLinearColorMap();
120
121 void setMode( Mode );
122 Mode mode() const;
123
124 void setColorInterval( const QColor& color1, const QColor& color2 );
125 void addColorStop( double value, const QColor& );
126 QVector< double > colorStops() const;
127
128 QColor color1() const;
129 QColor color2() const;
130
131 virtual QRgb rgb( const QwtInterval&,
132 double value ) const QWT_OVERRIDE;
133
134 virtual uint colorIndex( int numColors,
135 const QwtInterval&, double value ) const QWT_OVERRIDE;
136
137 class ColorStops;
138
139 private:
140 class PrivateData;
141 PrivateData* m_data;
142};
143
147 class QWT_EXPORT QwtAlphaColorMap : public QwtColorMap
148{
149 public:
150 explicit QwtAlphaColorMap( const QColor& = QColor( Qt::gray ) );
151 virtual ~QwtAlphaColorMap();
152
153 void setAlphaInterval( int alpha1, int alpha2 );
154
155 int alpha1() const;
156 int alpha2() const;
157
158 void setColor( const QColor& );
159 QColor color() const;
160
161 virtual QRgb rgb( const QwtInterval&,
162 double value ) const QWT_OVERRIDE;
163
164 private:
165 class PrivateData;
166 PrivateData* m_data;
167};
168
180 class QWT_EXPORT QwtHueColorMap : public QwtColorMap
181{
182 public:
183 explicit QwtHueColorMap( QwtColorMap::Format = QwtColorMap::RGB );
184 virtual ~QwtHueColorMap();
185
186 void setHueInterval( int hue1, int hue2 ); // direction ?
187 void setSaturation( int saturation );
188 void setValue( int value );
189 void setAlpha( int alpha );
190
191 int hue1() const;
192 int hue2() const;
193 int saturation() const;
194 int value() const;
195 int alpha() const;
196
197 virtual QRgb rgb( const QwtInterval&,
198 double value ) const QWT_OVERRIDE;
199
200 private:
201 class PrivateData;
202 PrivateData* m_data;
203};
204
214 class QWT_EXPORT QwtSaturationValueColorMap : public QwtColorMap
215{
216 public:
217 QwtSaturationValueColorMap();
218 virtual ~QwtSaturationValueColorMap();
219
220 void setHue( int hue );
221 void setSaturationInterval( int sat1, int sat2 );
222 void setValueInterval( int value1, int value2 );
223 void setAlpha( int alpha );
224
225 int hue() const;
226 int saturation1() const;
227 int saturation2() const;
228 int value1() const;
229 int value2() const;
230 int alpha() const;
231
232 virtual QRgb rgb( const QwtInterval&,
233 double value ) const QWT_OVERRIDE;
234
235 private:
236 class PrivateData;
237 PrivateData* m_data;
238};
239
248 inline QColor QwtColorMap::color( const QwtInterval& interval, double value ) const
249{
250 return QColor::fromRgba( rgb( interval, value ) );
251}
252
257inline QwtColorMap::Format QwtColorMap::format() const
258{
259 return m_format;
260}
261
262#endif
QVector
Definition qwt_clipper.h:23
QwtAlphaColorMap
QwtAlphaColorMap varies the alpha value of a color.
Definition qwt_color_map.h:148
QwtColorMap
QwtColorMap is used to map values into colors.
Definition qwt_color_map.h:38
QwtColorMap::color
QColor color(const QwtInterval &, double value) const
Definition qwt_color_map.h:248
QwtColorMap::Format
Format
Definition qwt_color_map.h:46
QwtColorMap::RGB
@ RGB
The map is intended to map into RGB values.
Definition qwt_color_map.h:48
QwtColorMap::rgb
virtual QRgb rgb(const QwtInterval &interval, double value) const =0
QwtHueColorMap
QwtHueColorMap varies the hue value of the HSV color model.
Definition qwt_color_map.h:181
QwtInterval
A class representing an interval.
Definition qwt_interval.h:23
QwtLinearColorMap
QwtLinearColorMap builds a color map from color stops.
Definition qwt_color_map.h:99
QwtLinearColorMap::Mode
Mode
Definition qwt_color_map.h:106
QwtLinearColorMap::FixedColors
@ FixedColors
Return the color from the next lower color stop.
Definition qwt_color_map.h:108
QwtSaturationValueColorMap
QwtSaturationValueColorMap varies the saturation and/or value for a given hue in the HSV color model.
Definition qwt_color_map.h:215