qwt_plot_spectrogram.h 3.13 KB
Newer Older
pixhawk's avatar
pixhawk committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
 * 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_PLOT_SPECTROGRAM_H
#define QWT_PLOT_SPECTROGRAM_H

#include <qglobal.h>

15 16 17
#include "qwt_valuelist.h"
#include "qwt_raster_data.h"
#include "qwt_plot_rasteritem.h"
pixhawk's avatar
pixhawk committed
18 19 20 21 22 23 24 25 26 27 28

class QwtColorMap;

/*!
  \brief A plot item, which displays a spectrogram

  A spectrogram displays threedimenional data, where the 3rd dimension
  ( the intensity ) is displayed using colors. The colors are calculated
  from the values using a color map.

  In ContourMode contour lines are painted for the contour levels.
29

pixhawk's avatar
pixhawk committed
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
  \image html spectrogram3.png

  \sa QwtRasterData, QwtColorMap
*/

class QWT_EXPORT QwtPlotSpectrogram: public QwtPlotRasterItem
{
public:
    /*!
      The display mode controls how the raster data will be represented.
      - ImageMode\n
        The values are mapped to colors using a color map.
      - ContourMode\n
        The data is displayed using contour lines

      When both modes are enabled the contour lines are painted on
      top of the spectrogram. The default setting enables ImageMode.

      \sa setDisplayMode(), testDisplayMode()
    */

51
    enum DisplayMode {
pixhawk's avatar
pixhawk committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
        ImageMode = 1,
        ContourMode = 2
    };

    explicit QwtPlotSpectrogram(const QString &title = QString::null);
    virtual ~QwtPlotSpectrogram();

    void setDisplayMode(DisplayMode, bool on = true);
    bool testDisplayMode(DisplayMode) const;

    void setData(const QwtRasterData &data);
    const QwtRasterData &data() const;

    void setColorMap(const QwtColorMap &);
    const QwtColorMap &colorMap() const;

    virtual QwtDoubleRect boundingRect() const;
    virtual QSize rasterHint(const QwtDoubleRect &) const;

    void setDefaultContourPen(const QPen &);
    QPen defaultContourPen() const;

    virtual QPen contourPen(double level) const;

    void setConrecAttribute(QwtRasterData::ConrecAttribute, bool on);
    bool testConrecAttribute(QwtRasterData::ConrecAttribute) const;

    void setContourLevels(const QwtValueList &);
    QwtValueList contourLevels() const;

    virtual int rtti() const;

    virtual void draw(QPainter *p,
85 86
                      const QwtScaleMap &xMap, const QwtScaleMap &yMap,
                      const QRect &rect) const;
pixhawk's avatar
pixhawk committed
87 88 89

protected:
    virtual QImage renderImage(
90
        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
pixhawk's avatar
pixhawk committed
91 92 93 94 95 96 97 98 99
        const QwtDoubleRect &rect) const;

    virtual QSize contourRasterSize(
        const QwtDoubleRect &, const QRect &) const;

    virtual QwtRasterData::ContourLines renderContourLines(
        const QwtDoubleRect &rect, const QSize &raster) const;

    virtual void drawContourLines(QPainter *p,
100 101
                                  const QwtScaleMap &xMap, const QwtScaleMap &yMap,
                                  const QwtRasterData::ContourLines& lines) const;
pixhawk's avatar
pixhawk committed
102 103 104 105 106 107 108

private:
    class PrivateData;
    PrivateData *d_data;
};

#endif