Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_color_map.h


Ignore:
Timestamp:
Nov 3, 2026, 10:53:35 AM (4 weeks ago)
Author:
stuerze
Message:

deprecated functions exchanged libs updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_color_map.h

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    1212
    1313#include "qwt_global.h"
    14 #include "qwt_interval.h"
    1514#include <qcolor.h>
    16 #include <qvector.h>
    17 
    18 /*!
    19   \brief QwtColorMap is used to map values into colors.
    20 
    21   For displaying 3D data on a 2D plane the 3rd dimension is often
    22   displayed using colors, like f.e in a spectrogram.
    23 
    24   Each color map is optimized to return colors for only one of the
    25   following image formats:
    26 
    27   - QImage::Format_Indexed8\n
    28   - QImage::Format_ARGB32\n
    29 
    30   \sa QwtPlotSpectrogram, QwtScaleWidget
    31 */
     15
     16class QwtInterval;
     17
     18#if QT_VERSION < 0x060000
     19template< typename T > class QVector;
     20#endif
     21
     22/*!
     23   \brief QwtColorMap is used to map values into colors.
     24
     25   For displaying 3D data on a 2D plane the 3rd dimension is often
     26   displayed using colors, like f.e in a spectrogram.
     27
     28   Each color map is optimized to return colors for only one of the
     29   following image formats:
     30
     31   - QImage::Format_Indexed8\n
     32   - QImage::Format_ARGB32\n
     33
     34   \sa QwtPlotSpectrogram, QwtScaleWidget
     35 */
    3236
    3337class QWT_EXPORT QwtColorMap
    3438{
    35 public:
     39  public:
    3640    /*!
    3741        Format for color mapping
    3842        \sa rgb(), colorIndex(), colorTable()
    39     */
     43     */
    4044
    4145    enum Format
    … …  
    4549
    4650        /*!
    47           The map is intended to map into 8 bit values, that
    48           are indices into the color table.
     51           Map values into 8 bit values, that
     52           are used as indexes into the color table.
     53
     54           Indexed color maps are used to generate QImage::Format_Indexed8
     55           images. The calculation of the color index is usually faster
     56           and the resulting image has a lower memory footprint.
     57
     58           \sa colorIndex(), colorTable()
    4959         */
    5060        Indexed
    5161    };
    5262
    53     QwtColorMap( Format = QwtColorMap::RGB );
     63    explicit QwtColorMap( Format = QwtColorMap::RGB );
    5464    virtual ~QwtColorMap();
    5565
     66    void setFormat( Format );
    5667    Format format() const;
    5768
    … …  
    6273       \param value Value
    6374       \return RGB value, corresponding to value
    64     */
    65     virtual QRgb rgb( const QwtInterval &interval,
    66         double value ) const = 0;
    67 
    68     /*!
    69        Map a value of a given interval into a color index
    70 
    71        \param interval Range for the values
    72        \param value Value
    73        \return color index, corresponding to value
    7475     */
    75     virtual unsigned char colorIndex(
    76         const QwtInterval &interval, double value ) const = 0;
    77 
    78     QColor color( const QwtInterval &, double value ) const;
    79     virtual QVector<QRgb> colorTable( const QwtInterval & ) const;
    80 
    81 private:
    82     Format d_format;
    83 };
    84 
    85 /*!
    86   \brief QwtLinearColorMap builds a color map from color stops.
    87 
    88   A color stop is a color at a specific position. The valid
    89   range for the positions is [0.0, 1.0]. When mapping a value
    90   into a color it is translated into this interval according to mode().
    91 */
    92 class QWT_EXPORT QwtLinearColorMap: public QwtColorMap
    93 {
    94 public:
     76    virtual QRgb rgb( const QwtInterval& interval, double value ) const = 0;
     77
     78    virtual uint colorIndex( int numColors,
     79        const QwtInterval& interval, double value ) const;
     80
     81    QColor color( const QwtInterval&, double value ) const;
     82    virtual QVector< QRgb > colorTable( int numColors ) const;
     83    virtual QVector< QRgb > colorTable256() const;
     84
     85  private:
     86    Q_DISABLE_COPY(QwtColorMap)
     87
     88    Format m_format;
     89};
     90
     91/*!
     92   \brief QwtLinearColorMap builds a color map from color stops.
     93
     94   A color stop is a color at a specific position. The valid
     95   range for the positions is [0.0, 1.0]. When mapping a value
     96   into a color it is translated into this interval according to mode().
     97 */
     98class QWT_EXPORT QwtLinearColorMap : public QwtColorMap
     99{
     100  public:
    95101    /*!
    96102       Mode of color map
    97103       \sa setMode(), mode()
    98     */
     104     */
    99105    enum Mode
    100106    {
    … …  
    106112    };
    107113
    108     QwtLinearColorMap( QwtColorMap::Format = QwtColorMap::RGB );
    109     QwtLinearColorMap( const QColor &color1, const QColor &color2,
     114    explicit QwtLinearColorMap( QwtColorMap::Format = QwtColorMap::RGB );
     115
     116    QwtLinearColorMap( const QColor& from, const QColor& to,
    110117        QwtColorMap::Format = QwtColorMap::RGB );
    111118
    … …  
    115122    Mode mode() const;
    116123
    117     void setColorInterval( const QColor &color1, const QColor &color2 );
     124    void setColorInterval( const QColor& color1, const QColor& color2 );
    118125    void addColorStop( double value, const QColor& );
    119     QVector<double> colorStops() const;
     126    QVector< double > colorStops() const;
    120127
    121128    QColor color1() const;
    122129    QColor color2() const;
    123130
    124     virtual QRgb rgb( const QwtInterval &, double value ) const;
    125     virtual unsigned char colorIndex(
    126         const QwtInterval &, double value ) const;
     131    virtual QRgb rgb( const QwtInterval&,
     132        double value ) const QWT_OVERRIDE;
     133
     134    virtual uint colorIndex( int numColors,
     135        const QwtInterval&, double value ) const QWT_OVERRIDE;
    127136
    128137    class ColorStops;
    129138
    130 private:
    131     // Disabled copy constructor and operator=
    132     QwtLinearColorMap( const QwtLinearColorMap & );
    133     QwtLinearColorMap &operator=( const QwtLinearColorMap & );
    134 
    135     class PrivateData;
    136     PrivateData *d_data;
    137 };
    138 
    139 /*!
    140   \brief QwtAlphaColorMap varies the alpha value of a color
    141 */
    142 class QWT_EXPORT QwtAlphaColorMap: public QwtColorMap
    143 {
    144 public:
    145     QwtAlphaColorMap( const QColor & = QColor( Qt::gray ) );
     139  private:
     140    class PrivateData;
     141    PrivateData* m_data;
     142};
     143
     144/*!
     145   \brief QwtAlphaColorMap varies the alpha value of a color
     146 */
     147class QWT_EXPORT QwtAlphaColorMap : public QwtColorMap
     148{
     149  public:
     150    explicit QwtAlphaColorMap( const QColor& = QColor( Qt::gray ) );
    146151    virtual ~QwtAlphaColorMap();
    147152
    148     void setColor( const QColor & );
     153    void setAlphaInterval( int alpha1, int alpha2 );
     154
     155    int alpha1() const;
     156    int alpha2() const;
     157
     158    void setColor( const QColor& );
    149159    QColor color() const;
    150160
    151     virtual QRgb rgb( const QwtInterval &, double value ) const;
    152 
    153 private:
    154     QwtAlphaColorMap( const QwtAlphaColorMap & );
    155     QwtAlphaColorMap &operator=( const QwtAlphaColorMap & );
    156 
    157     virtual unsigned char colorIndex(
    158         const QwtInterval &, double value ) const;
    159 
    160     class PrivateData;
    161     PrivateData *d_data;
    162 };
    163 
     161    virtual QRgb rgb( const QwtInterval&,
     162        double value ) const QWT_OVERRIDE;
     163
     164  private:
     165    class PrivateData;
     166    PrivateData* m_data;
     167};
     168
     169/*!
     170   \brief QwtHueColorMap varies the hue value of the HSV color model.
     171
     172   QwtHueColorMap can be used to set up a color map easily, that runs cyclic over
     173   all colors. Each cycle has 360 different steps.
     174
     175   The values for value and saturation are in the range of 0 to 255 and doesn't
     176   depend on the data value to be mapped.
     177
     178   \sa QwtSaturationValueColorMap
     179 */
     180class QWT_EXPORT QwtHueColorMap : public QwtColorMap
     181{
     182  public:
     183    explicit QwtHueColorMap( QwtColorMap::Format = QwtColorMap::RGB );
     184    virtual ~QwtHueColorMap();
     185
     186    void setHueInterval( int hue1, int hue2 ); // direction ?
     187    void setSaturation( int saturation );
     188    void setValue( int value );
     189    void setAlpha( int alpha );
     190
     191    int hue1() const;
     192    int hue2() const;
     193    int saturation() const;
     194    int value() const;
     195    int alpha() const;
     196
     197    virtual QRgb rgb( const QwtInterval&,
     198        double value ) const QWT_OVERRIDE;
     199
     200  private:
     201    class PrivateData;
     202    PrivateData* m_data;
     203};
     204
     205/*!
     206   \brief QwtSaturationValueColorMap varies the saturation and/or value for a given
     207         hue in the HSV color model.
     208
     209   Value and saturation are in the range of 0 to 255 while hue is in the range
     210   of 0 to 259.
     211
     212   \sa QwtHueColorMap
     213 */
     214class QWT_EXPORT QwtSaturationValueColorMap : public QwtColorMap
     215{
     216  public:
     217    QwtSaturationValueColorMap();
     218    virtual ~QwtSaturationValueColorMap();
     219
     220    void setHue( int hue );
     221    void setSaturationInterval( int sat1, int sat2 );
     222    void setValueInterval( int value1, int value2 );
     223    void setAlpha( int alpha );
     224
     225    int hue() const;
     226    int saturation1() const;
     227    int saturation2() const;
     228    int value1() const;
     229    int value2() const;
     230    int alpha() const;
     231
     232    virtual QRgb rgb( const QwtInterval&,
     233        double value ) const QWT_OVERRIDE;
     234
     235  private:
     236    class PrivateData;
     237    PrivateData* m_data;
     238};
    164239
    165240/*!
    … …  
    170245
    171246   \return Color corresponding to value
    172 
    173    \warning This method is slow for Indexed color maps. If it is
    174             necessary to map many values, its better to get the
    175             color table once and find the color using colorIndex().
    176 */
    177 inline QColor QwtColorMap::color(
    178     const QwtInterval &interval, double value ) const
    179 {
    180     if ( d_format == RGB )
    181     {
    182         return QColor::fromRgba( rgb( interval, value ) );
    183     }
    184     else
    185     {
    186         const unsigned int index = colorIndex( interval, value );
    187 
    188         const QVector<QRgb> rgbTable = colorTable( interval );
    189         return rgbTable[index]; // slow
    190     }
     247 */
     248inline QColor QwtColorMap::color( const QwtInterval& interval, double value ) const
     249{
     250    return QColor::fromRgba( rgb( interval, value ) );
    191251}
    192252
    … …  
    194254   \return Intended format of the color map
    195255   \sa Format
    196 */
     256 */
    197257inline QwtColorMap::Format QwtColorMap::format() const
    198258{
    199     return d_format;
     259    return m_format;
    200260}
    201261
Note: See TracChangeset for help on using the changeset viewer.