18 return QColor::fromHsv( h, s, v, a ).rgb();
21 const double vs = v * s / 255.0;
22 const int p = v - qRound( vs );
28 const double r = ( 60 - h ) / 60.0;
29 return qRgba( v, v - qRound( r * vs ), p, a );
33 const double r = ( h - 60 ) / 60.0;
34 return qRgba( v - qRound( r * vs ), v, p, a );
38 const double r = ( 180 - h ) / 60.0;
39 return qRgba( p, v, v - qRound( r * vs ), a );
43 const double r = ( h - 180 ) / 60.0;
44 return qRgba( p, v - qRound( r * vs ), v, a );
48 const double r = ( 300 - h ) / 60.0;
49 return qRgba( v - qRound( r * vs ), p, v, a );
54 const double r = ( h - 300 ) / 60.0;
55 return qRgba( v, p, v - qRound( r * vs ), a );
129 inline int findUpper(
double pos )
const;
139 if ( pos < 0.0 || pos > 1.0 )
151 if ( index ==
d_stops.size() ||
152 qAbs(
d_stops[index].pos - pos ) >= 0.001 )
155 for (
int i =
d_stops.size() - 1; i > index; i-- )
161 if ( color.alpha() != 255 )
167 if ( index <
d_stops.size() - 1 )
174 for (
int i = 0; i <
d_stops.size(); i++ )
188 const int half = n >> 1;
189 const int middle = index + half;
191 if ( stops[middle].pos <= pos )
220 const double ratio = ( pos - s1.
pos ) / ( s1.
posStep );
222 const int r = int( s1.
r0 + ratio * s1.
rStep );
223 const int g = int( s1.
g0 + ratio * s1.
gStep );
224 const int b = int( s1.
b0 + ratio * s1.
bStep );
230 const int a = int( s1.
a0 + ratio * s1.
aStep );
231 return qRgba( r, g, b, a );
235 return qRgba( r, g, b, s1.
a );
240 return qRgb( r, g, b );
281 const double width = interval.
width();
288 const int maxIndex = numColors - 1;
292 const double v = maxIndex * ( ( value - interval.
minValue() ) / width );
293 return static_cast<unsigned int>( v + 0.5 );
310 for (
int i = 0; i < 256; i++ )
311 table[i] =
rgb( interval, i );
331 const double step = 1.0 / ( numColors - 1 );
332 for (
int i = 0; i < numColors; i++ )
333 table[i] =
rgb( interval, step * i );
435 if ( value >= 0.0 && value <= 1.0 )
476 const double width = interval.
width();
480 const double ratio = ( value - interval.
minValue() ) / width;
497 const double width = interval.
width();
505 return numColors - 1;
507 const double v = ( numColors - 1 ) * ( value - interval.
minValue() ) / width;
561 d_data->
rgb = color.rgb() & qRgba( 255, 255, 255, 0 );
624 const double width = interval.
width();
634 const double ratio = ( value - interval.
minValue() ) / width;
673 for (
int i = 0; i < 60; i++ )
675 const double r = ( 60 - i ) / 60.0;
679 for (
int i = 60; i < 120; i++ )
681 const double r = ( i - 60 ) / 60.0;
685 for (
int i = 120; i < 180; i++ )
687 const double r = ( 180 - i ) / 60.0;
691 for (
int i = 180; i < 240; i++ )
693 const double r = ( i - 180 ) / 60.0;
697 for (
int i = 240; i < 300; i++ )
699 const double r = ( 300 - i ) / 60.0;
703 for (
int i = 300; i < 360; i++ )
705 const double r = ( i - 300 ) / 60.0;
766 saturation = qBound( 0, saturation, 255 );
786 value = qBound( 0, value, 255 );
807 alpha = qBound( 0, alpha, 255 );
871 const double width = interval.
width();
881 const double ratio = ( value - interval.
minValue() ) / width;
914 if ( ( value1 == value2 ) && ( sat1 != sat2 ) )
916 rgbTable.resize( 256 );
918 for (
int i = 0; i < 256; i++ )
921 tableType = Saturation;
923 else if ( ( value1 != value2 ) && ( sat1 == sat2 ) )
925 rgbTable.resize( 256 );
927 for (
int i = 0; i < 256; i++ )
934 rgbTable.resize( 256 * 256 );
936 for (
int s = 0; s < 256; s++ )
938 const int v0 = s * 256;
940 for (
int v = 0; v < 256; v++ )
1017 int saturation1,
int saturation2 )
1019 saturation1 = qBound( 0, saturation1, 255 );
1020 saturation2 = qBound( 0, saturation2, 255 );
1022 if ( ( saturation1 !=
d_data->sat1 ) || ( saturation2 !=
d_data->sat2 ) )
1024 d_data->sat1 = saturation1;
1025 d_data->sat2 = saturation2;
1045 value1 = qBound( 0, value1, 255 );
1046 value2 = qBound( 0, value2, 255 );
1048 if ( ( value1 !=
d_data->value1 ) || ( value2 !=
d_data->value2 ) )
1069 alpha = qBound( 0, alpha, 255 );
1143 const double width = interval.
width();
1149 switch(
d_data->tableType )
1151 case PrivateData::Saturation:
1153 if ( value <= interval.
minValue() )
1156 if ( value >= interval.
maxValue() )
1159 const double ratio = ( value - interval.
minValue() ) / width;
1160 const int sat =
d_data->sat1
1163 return rgbTable[sat];
1167 if ( value <= interval.
minValue() )
1170 if ( value >= interval.
maxValue() )
1173 const double ratio = ( value - interval.
minValue() ) / width;
1174 const int v =
d_data->value1 +
1177 return rgbTable[ v ];
1182 if ( value <= interval.
minValue() )
1187 else if ( value >= interval.
maxValue() )
1194 const double ratio = ( value - interval.
minValue() ) / width;
1200 return rgbTable[ 256 * s + v ];
enum MQTTPropertyCodes value
void setColorInterval(const QColor &color1, const QColor &color2)
void setSaturationInterval(int sat1, int sat2)
Set the interval for the saturation coordinate.
void updateSteps(const ColorStop &nextStop)
QwtHueColorMap(QwtColorMap::Format=QwtColorMap::RGB)
Constructor.
virtual QVector< QRgb > colorTable256() const
A class representing an interval.
QwtColorMap(Format=QwtColorMap::RGB)
virtual QRgb rgb(const QwtInterval &, double value) const QWT_OVERRIDE
void setAlpha(int alpha)
Set the the alpha coordinate.
Return the color from the next lower color stop.
virtual ~QwtLinearColorMap()
Destructor.
virtual QRgb rgb(const QwtInterval &, double value) const QWT_OVERRIDE
void insert(double pos, const QColor &color)
void setHueInterval(int hue1, int hue2)
QVector< double > colorStops() const
QwtSaturationValueColorMap()
Constructor.
void setValue(int value)
Set the the value coordinate.
virtual ~QwtSaturationValueColorMap()
Destructor.
static QRgb qwtHsvToRgb(int h, int s, int v, int a)
void setHue(int hue)
Set the the hue coordinate.
QRgb rgb(QwtLinearColorMap::Mode, double pos) const
virtual QVector< QRgb > colorTable(int numColors) const
virtual uint colorIndex(int numColors, const QwtInterval &interval, double value) const
Map a value of a given interval into a color index.
QVector< double > stops() const
QwtAlphaColorMap(const QColor &=QColor(Qt::gray))
Constructor.
void setMode(Mode)
Set the mode of the color map.
int findUpper(double pos) const
virtual ~QwtHueColorMap()
Destructor.
table_core< false > table
QwtColorMap is used to map values into colors.
virtual QRgb rgb(const QwtInterval &, double value) const QWT_OVERRIDE
Map a value of a given interval into a alpha value.
virtual uint colorIndex(int numColors, const QwtInterval &, double value) const QWT_OVERRIDE
Map a value of a given interval into a color index.
QColor color(const QwtInterval &, double value) const
The map is intended to map into RGB values.
void setAlphaInterval(int alpha1, int alpha2)
Interpolating the colors of the adjacent stops.
ColorStop(double p, const QColor &c)
void setValueInterval(int value1, int value2)
Set the interval for the value coordinate.
virtual QRgb rgb(const QwtInterval &interval, double value) const =0
virtual ~QwtAlphaColorMap()
Destructor.
virtual QRgb rgb(const QwtInterval &, double value) const QWT_OVERRIDE
virtual ~QwtColorMap()
Destructor.
QVector< ColorStop > d_stops
QwtLinearColorMap::Mode mode
void setAlpha(int alpha)
Set the the alpha coordinate.
void setSaturation(int saturation)
Set the the saturation coordinate.
double width() const
Return the width of an interval.
void setColor(const QColor &)
QwtLinearColorMap(QwtColorMap::Format=QwtColorMap::RGB)
void addColorStop(double value, const QColor &)