Loading...
Searching...
No Matches
qwt_color_map.h
/******************************************************************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#ifndef QWT_COLOR_MAP_H
#define QWT_COLOR_MAP_H
#include "qwt_global.h"
#include <qcolor.h>
class QwtInterval;
#if QT_VERSION < 0x060000
template< typename T > class QVector;
#endif
class QWT_EXPORT QwtColorMap
{
public:
enum Format
{
RGB,
Indexed
};
explicit QwtColorMap( Format = QwtColorMap::RGB );
virtual ~QwtColorMap();
void setFormat( Format );
Format format() const;
virtual QRgb rgb( const QwtInterval& interval, double value ) const = 0;
virtual uint colorIndex( int numColors,
const QwtInterval& interval, double value ) const;
QColor color( const QwtInterval&, double value ) const;
virtual QVector< QRgb > colorTable( int numColors ) const;
virtual QVector< QRgb > colorTable256() const;
private:
Q_DISABLE_COPY(QwtColorMap)
Format m_format;
};
class QWT_EXPORT QwtLinearColorMap : public QwtColorMap
{
public:
enum Mode
{
FixedColors,
ScaledColors
};
explicit QwtLinearColorMap( QwtColorMap::Format = QwtColorMap::RGB );
QwtLinearColorMap( const QColor& from, const QColor& to,
QwtColorMap::Format = QwtColorMap::RGB );
virtual ~QwtLinearColorMap();
void setMode( Mode );
Mode mode() const;
void setColorInterval( const QColor& color1, const QColor& color2 );
void addColorStop( double value, const QColor& );
QVector< double > colorStops() const;
QColor color1() const;
QColor color2() const;
virtual QRgb rgb( const QwtInterval&,
double value ) const QWT_OVERRIDE;
virtual uint colorIndex( int numColors,
const QwtInterval&, double value ) const QWT_OVERRIDE;
class ColorStops;
private:
class PrivateData;
PrivateData* m_data;
};
class QWT_EXPORT QwtAlphaColorMap : public QwtColorMap
{
public:
explicit QwtAlphaColorMap( const QColor& = QColor( Qt::gray ) );
virtual ~QwtAlphaColorMap();
void setAlphaInterval( int alpha1, int alpha2 );
int alpha1() const;
int alpha2() const;
void setColor( const QColor& );
QColor color() const;
virtual QRgb rgb( const QwtInterval&,
double value ) const QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
class QWT_EXPORT QwtHueColorMap : public QwtColorMap
{
public:
explicit QwtHueColorMap( QwtColorMap::Format = QwtColorMap::RGB );
virtual ~QwtHueColorMap();
void setHueInterval( int hue1, int hue2 ); // direction ?
void setSaturation( int saturation );
void setValue( int value );
void setAlpha( int alpha );
int hue1() const;
int hue2() const;
int saturation() const;
int value() const;
int alpha() const;
virtual QRgb rgb( const QwtInterval&,
double value ) const QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
class QWT_EXPORT QwtSaturationValueColorMap : public QwtColorMap
{
public:
QwtSaturationValueColorMap();
virtual ~QwtSaturationValueColorMap();
void setHue( int hue );
void setSaturationInterval( int sat1, int sat2 );
void setValueInterval( int value1, int value2 );
void setAlpha( int alpha );
int hue() const;
int saturation1() const;
int saturation2() const;
int value1() const;
int value2() const;
int alpha() const;
virtual QRgb rgb( const QwtInterval&,
double value ) const QWT_OVERRIDE;
private:
class PrivateData;
PrivateData* m_data;
};
inline QColor QwtColorMap::color( const QwtInterval& interval, double value ) const
{
return QColor::fromRgba( rgb( interval, value ) );
}
inline QwtColorMap::Format QwtColorMap::format() const
{
return m_format;
}
#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