14 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 25 #define QWT_GCC_OPTIMIZE 1 32 return QColor::fromHsv( h, s, v, a ).rgb();
35 const double vs = v * s / 255.0;
36 const int p = v - qRound( vs );
42 const double r = ( 60 - h ) / 60.0;
43 return qRgba( v, v - qRound( r * vs ), p, a );
47 const double r = ( h - 60 ) / 60.0;
48 return qRgba( v - qRound( r * vs ), v, p, a );
52 const double r = ( 180 - h ) / 60.0;
53 return qRgba( p, v, v - qRound( r * vs ), a );
57 const double r = ( h - 180 ) / 60.0;
58 return qRgba( p, v - qRound( r * vs ), v, a );
62 const double r = ( 300 - h ) / 60.0;
63 return qRgba( v - qRound( r * vs ), p, v, a );
68 const double r = ( h - 300 ) / 60.0;
69 return qRgba( v, p, v - qRound( r * vs ), a );
87 QVector<double>
stops()
const;
143 inline int findUpper(
double pos )
const;
153 if ( pos < 0.0 || pos > 1.0 )
165 if ( index ==
d_stops.size() ||
166 qAbs(
d_stops[index].pos - pos ) >= 0.001 )
169 for (
int i =
d_stops.size() - 1;
i > index;
i-- )
175 if ( color.alpha() != 255 )
181 if ( index <
d_stops.size() - 1 )
187 QVector<double> positions(
d_stops.size() );
202 const int half = n >> 1;
203 const int middle = index + half;
205 if ( stops[middle].pos <= pos )
234 const double ratio = ( pos - s1.
pos ) / ( s1.
posStep );
236 const int r = int( s1.
r0 + ratio * s1.
rStep );
237 const int g = int( s1.
g0 + ratio * s1.
gStep );
238 const int b = int( s1.
b0 + ratio * s1.
bStep );
244 const int a = int( s1.
a0 + ratio * s1.
aStep );
245 return qRgba( r, g, b, a );
249 return qRgba( r, g, b, s1.
a );
254 return qRgb( r, g, b );
283 #ifdef QWT_GCC_OPTIMIZE 284 #pragma GCC push_options 285 #pragma GCC optimize("tree-partial-pre") 300 #ifdef QWT_GCC_OPTIMIZE 303 if ( ((uchar *)&value)[0] )
asm(
"");
307 const double width = interval.
width();
314 const int maxIndex = numColors - 1;
318 const double v = maxIndex * ( ( value - interval.
minValue() ) / width );
319 return static_cast<unsigned int>( v + 0.5 );
322 #ifdef QWT_GCC_OPTIMIZE 323 #pragma GCC pop_options 336 QVector<QRgb> table( 256 );
340 for (
int i = 0;
i < 256;
i++ )
341 table[
i] =
rgb( interval,
i );
357 QVector<QRgb> table( numColors );
361 const double step = 1.0 / ( numColors - 1 );
362 for (
int i = 0;
i < numColors;
i++ )
363 table[
i] =
rgb( interval, step *
i );
465 if ( value >= 0.0 && value <= 1.0 )
506 const double width = interval.
width();
510 const double ratio = ( value - interval.
minValue() ) / width;
514 #ifdef QWT_GCC_OPTIMIZE 515 #pragma GCC push_options 516 #pragma GCC optimize("tree-partial-pre") 532 #ifdef QWT_GCC_OPTIMIZE 535 if ( ((uchar *)&value)[0] )
asm(
"");
538 const double width = interval.
width();
546 return numColors - 1;
548 const double v = ( numColors - 1 ) * ( value - interval.
minValue() ) / width;
552 #ifdef QWT_GCC_OPTIMIZE 553 #pragma GCC pop_options 606 d_data->
rgb = color.rgb() & qRgba( 255, 255, 255, 0 );
669 const double width = interval.
width();
679 const double ratio = ( value - interval.
minValue() ) / width;
718 for (
int i = 0;
i < 60;
i++ )
720 const double r = ( 60 -
i ) / 60.0;
724 for (
int i = 60;
i < 120;
i++ )
726 const double r = (
i - 60 ) / 60.0;
730 for (
int i = 120;
i < 180;
i++ )
732 const double r = ( 180 -
i ) / 60.0;
736 for (
int i = 180;
i < 240;
i++ )
738 const double r = (
i - 180 ) / 60.0;
742 for (
int i = 240;
i < 300;
i++ )
744 const double r = ( 300 -
i ) / 60.0;
748 for (
int i = 300;
i < 360;
i++ )
750 const double r = (
i - 300 ) / 60.0;
811 saturation = qBound( 0, saturation, 255 );
831 value = qBound( 0, value, 255 );
852 alpha = qBound( 0, alpha, 255 );
916 const double width = interval.
width();
926 const double ratio = ( value - interval.
minValue() ) / width;
961 rgbTable.resize( 256 );
963 for (
int i = 0;
i < 256;
i++ )
966 tableType = Saturation;
970 rgbTable.resize( 256 );
972 for (
int i = 0;
i < 256;
i++ )
979 rgbTable.resize( 256 * 256 );
981 for (
int s = 0;
s < 256;
s++ )
983 const int v0 =
s * 256;
985 for (
int v = 0;
v < 256;
v++ )
1041 if ( hue !=
d_data->hue )
1062 int saturation1,
int saturation2 )
1064 saturation1 = qBound( 0, saturation1, 255 );
1065 saturation2 = qBound( 0, saturation2, 255 );
1067 if ( ( saturation1 !=
d_data->sat1 ) || ( saturation2 !=
d_data->sat2 ) )
1069 d_data->sat1 = saturation1;
1070 d_data->sat2 = saturation2;
1090 value1 = qBound( 0, value1, 255 );
1091 value2 = qBound( 0, value2, 255 );
1093 if ( ( value1 !=
d_data->value1 ) || ( value2 !=
d_data->value2 ) )
1114 alpha = qBound( 0, alpha, 255 );
1188 const double width = interval.
width();
1194 switch(
d_data->tableType )
1196 case PrivateData::Saturation:
1198 if ( value <= interval.
minValue() )
1201 if ( value >= interval.
maxValue() )
1204 const double ratio = ( value - interval.
minValue() ) / width;
1205 const int sat =
d_data->sat1
1208 return rgbTable[sat];
1210 case PrivateData::Value:
1212 if ( value <= interval.
minValue() )
1215 if ( value >= interval.
maxValue() )
1218 const double ratio = ( value - interval.
minValue() ) / width;
1219 const int v =
d_data->value1 +
1222 return rgbTable[ v ];
1227 if ( value <= interval.
minValue() )
1232 else if ( value >= interval.
maxValue() )
1239 const double ratio = ( value - interval.
minValue() ) / width;
1245 return rgbTable[ 256 * s + v ];
void setColorInterval(const QColor &color1, const QColor &color2)
virtual QRgb rgb(const QwtInterval &, double value) const
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
virtual QRgb rgb(const QwtInterval &, double value) const
A class representing an interval.
QwtColorMap(Format=QwtColorMap::RGB)
void setAlpha(int alpha)
Set the the alpha coordinate.
Return the color from the next lower color stop.
virtual ~QwtLinearColorMap()
Destructor.
void insert(double pos, const QColor &color)
void setHueInterval(int hue1, int hue2)
virtual QRgb rgb(const QwtInterval &, double value) const
QVector< double > colorStops() const
virtual QRgb rgb(const QwtInterval &, double value) const
Map a value of a given interval into a alpha value.
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.
QwtColorMap is used to map values into colors.
QColor color(const QwtInterval &, double value) const
The map is intended to map into RGB values.
virtual uint colorIndex(int numColors, const QwtInterval &, double value) const
Map a value of a given interval into a color index.
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 ~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 &)