Public Types | Public Member Functions

QwtColorMap Class Reference

QwtColorMap is used to map values into colors. More...

#include <qwt_color_map.h>

Inheritance diagram for QwtColorMap:
Inheritance graph
[legend]

List of all members.

Public Types

enum  Format { RGB, Indexed }

Public Member Functions

 QwtColorMap (Format=QwtColorMap::RGB)
 Constructor.
virtual ~QwtColorMap ()
 Destructor.
Format format () const
virtual QwtColorMapcopy () const =0
 Clone the color map.
virtual QRgb rgb (const QwtDoubleInterval &interval, double value) const =0
virtual unsigned char colorIndex (const QwtDoubleInterval &interval, double value) const =0
QColor color (const QwtDoubleInterval &, double value) const
virtual QValueVector< QRgb > colorTable (const QwtDoubleInterval &) const

Detailed Description

QwtColorMap is used to map values into colors.

For displaying 3D data on a 2D plane the 3rd dimension is often displayed using colors, like f.e in a spectrogram.

Each color map is optimized to return colors for only one of the following image formats:

See also:
QwtPlotSpectrogram, QwtScaleWidget

Definition at line 44 of file qwt_color_map.h.


Member Enumeration Documentation

  • RGB
    The map is intended to map into QRgb values.
  • Indexed
    The map is intended to map into 8 bit values, that are indices into the color table.
See also:
rgb(), colorIndex(), colorTable()
Enumerator:
RGB 
Indexed 

Definition at line 57 of file qwt_color_map.h.

    {
        RGB,
        Indexed
    };

Constructor & Destructor Documentation

QwtColorMap::QwtColorMap ( Format  format = QwtColorMap::RGB )

Constructor.

Definition at line 164 of file qwt_color_map.cpp.

                                     :
    d_format(format)
{
}
QwtColorMap::~QwtColorMap (  ) [virtual]

Destructor.

Definition at line 170 of file qwt_color_map.cpp.

{
}

Member Function Documentation

QColor QwtColorMap::color ( const QwtDoubleInterval interval,
double  value 
) const [inline]

Map a value into a color

Parameters:
intervalValid interval for values
valueValue
Returns:
Color corresponding to value
Warning:
This method is slow for Indexed color maps. If it is necessary to map many values, its better to get the color table once and find the color using colorIndex().

Definition at line 198 of file qwt_color_map.h.

References colorIndex(), colorTable(), rgb(), and RGB.

{
    if ( d_format == RGB )
    {
        return QColor( rgb(interval, value) );
    }
    else
    {
        const unsigned int index = colorIndex(interval, value);
        return colorTable(interval)[index]; // slow
    }
}
virtual unsigned char QwtColorMap::colorIndex ( const QwtDoubleInterval interval,
double  value 
) const [pure virtual]

Map a value of a given interval into a color index

Parameters:
intervalRange for the values
valueValue
Returns:
color index, corresponding to value

Implemented in QwtLinearColorMap.

Referenced by color(), QwtPainter::drawColorBar(), and QwtPlotSpectrogram::renderImage().

QwtColorTable QwtColorMap::colorTable ( const QwtDoubleInterval interval ) const [virtual]

Build and return a color map of 256 colors

The color table is needed for rendering indexed images in combination with using colorIndex().

Parameters:
intervalRange for the values
Returns:
A color table, that can be used for a QImage

Definition at line 183 of file qwt_color_map.cpp.

References int(), QwtDoubleInterval::isValid(), QwtDoubleInterval::minValue(), rgb(), and QwtDoubleInterval::width().

Referenced by color(), QwtPainter::drawColorBar(), and QwtPlotSpectrogram::renderImage().

{
    QwtColorTable table(256);

    if ( interval.isValid() )
    {
        const double step = interval.width() / (table.size() - 1);
        for ( int i = 0; i < (int) table.size(); i++ )
            table[i] = rgb(interval, interval.minValue() + step * i);
    }

    return table;
}
virtual QwtColorMap* QwtColorMap::copy (  ) const [pure virtual]

Clone the color map.

Implemented in QwtLinearColorMap, and QwtAlphaColorMap.

Referenced by QwtScaleWidget::setColorMap(), and QwtPlotSpectrogram::setColorMap().

QwtColorMap::Format QwtColorMap::format (  ) const [inline]
Returns:
Intended format of the color map
See also:
Format

Definition at line 216 of file qwt_color_map.h.

Referenced by QwtPainter::drawColorBar(), and QwtPlotSpectrogram::renderImage().

{
    return d_format;
}
virtual QRgb QwtColorMap::rgb ( const QwtDoubleInterval interval,
double  value 
) const [pure virtual]

Map a value of a given interval into a rgb value.

Parameters:
intervalRange for the values
valueValue
Returns:
rgb value, corresponding to value

Implemented in QwtLinearColorMap, and QwtAlphaColorMap.

Referenced by color(), colorTable(), QwtPlotSpectrogram::contourPen(), QwtPainter::drawColorBar(), and QwtPlotSpectrogram::renderImage().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines