Classes | |
class | ColorStop |
Public Member Functions | |
ColorStops () | |
void | insert (double pos, const QColor &color) |
QRgb | rgb (QwtLinearColorMap::Mode, double pos) const |
QMemArray< double > | stops () const |
Definition at line 22 of file qwt_color_map.cpp.
QwtLinearColorMap::ColorStops::ColorStops | ( | ) | [inline] |
Definition at line 25 of file qwt_color_map.cpp.
{ #if QT_VERSION >= 0x040000 _stops.reserve(256); #endif }
void QwtLinearColorMap::ColorStops::insert | ( | double | pos, |
const QColor & | color | ||
) |
Definition at line 66 of file qwt_color_map.cpp.
References qwtAbs.
Referenced by QwtLinearColorMap::addColorStop(), and QwtLinearColorMap::setColorInterval().
{ // Lookups need to be very fast, insertions are not so important. // Anyway, a balanced tree is what we need here. TODO ... if ( pos < 0.0 || pos > 1.0 ) return; int index; if ( _stops.size() == 0 ) { index = 0; #if QT_VERSION < 0x040000 _stops.resize(1, QGArray::SpeedOptim); #else _stops.resize(1); #endif } else { index = findUpper(pos); if ( index == (int)_stops.size() || qwtAbs(_stops[index].pos - pos) >= 0.001 ) { #if QT_VERSION < 0x040000 _stops.resize(_stops.size() + 1, QGArray::SpeedOptim); #else _stops.resize(_stops.size() + 1); #endif for ( int i = _stops.size() - 1; i > index; i-- ) _stops[i] = _stops[i-1]; } } _stops[index] = ColorStop(pos, color); }
QRgb QwtLinearColorMap::ColorStops::rgb | ( | QwtLinearColorMap::Mode | mode, |
double | pos | ||
) | const [inline] |
Definition at line 135 of file qwt_color_map.cpp.
References QwtLinearColorMap::FixedColors, int(), and QwtLinearColorMap::rgb().
Referenced by QwtLinearColorMap::color1(), QwtLinearColorMap::color2(), and QwtLinearColorMap::rgb().
{ if ( pos <= 0.0 ) return _stops[0].rgb; if ( pos >= 1.0 ) return _stops[(int)(_stops.size() - 1)].rgb; const int index = findUpper(pos); if ( mode == FixedColors ) { return _stops[index-1].rgb; } else { const ColorStop &s1 = _stops[index-1]; const ColorStop &s2 = _stops[index]; const double ratio = (pos - s1.pos) / (s2.pos - s1.pos); const int r = s1.r + qRound(ratio * (s2.r - s1.r)); const int g = s1.g + qRound(ratio * (s2.g - s1.g)); const int b = s1.b + qRound(ratio * (s2.b - s1.b)); return qRgb(r, g, b); } }
QMemArray< double > QwtLinearColorMap::ColorStops::stops | ( | ) | const [inline] |
Definition at line 103 of file qwt_color_map.cpp.
References int().
Referenced by QwtLinearColorMap::colorStops().
{ QwtArray<double> positions(_stops.size()); for ( int i = 0; i < (int)_stops.size(); i++ ) positions[i] = _stops[i].pos; return positions; }