qwt_plot_spectrogram.h 3.52 KB
Newer Older
pixhawk's avatar
pixhawk committed
1 2 3 4 5 6 7 8 9 10 11 12
/* -*- 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

Bryant's avatar
Bryant committed
13
#include "qwt_global.h"
14 15
#include "qwt_raster_data.h"
#include "qwt_plot_rasteritem.h"
Bryant's avatar
Bryant committed
16
#include <qlist.h>
pixhawk's avatar
pixhawk committed
17 18 19 20 21 22

class QwtColorMap;

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

Bryant's avatar
Bryant committed
23
  A spectrogram displays 3-dimensional data, where the 3rd dimension
pixhawk's avatar
pixhawk committed
24 25 26
  ( the intensity ) is displayed using colors. The colors are calculated
  from the values using a color map.

Bryant's avatar
Bryant committed
27 28 29 30
  On multi-core systems the performance of the image composition
  can often be improved by dividing the area into tiles - each of them
  rendered in a different thread ( see QwtPlotItem::setRenderThreadCount() ).

pixhawk's avatar
pixhawk committed
31
  In ContourMode contour lines are painted for the contour levels.
32

pixhawk's avatar
pixhawk committed
33 34
  \image html spectrogram3.png

Bryant's avatar
Bryant committed
35
  \sa QwtRasterData, QwtColorMap, QwtPlotItem::setRenderThreadCount()
pixhawk's avatar
pixhawk committed
36 37 38 39 40 41 42 43 44 45
*/

class QWT_EXPORT QwtPlotSpectrogram: public QwtPlotRasterItem
{
public:
    /*!
      The display mode controls how the raster data will be represented.
      \sa setDisplayMode(), testDisplayMode()
    */

Bryant's avatar
Bryant committed
46 47 48 49 50 51 52
    enum DisplayMode
    {
        //! The values are mapped to colors using a color map.
        ImageMode = 0x01,

        //! The data is displayed using contour lines
        ContourMode = 0x02
pixhawk's avatar
pixhawk committed
53 54
    };

Bryant's avatar
Bryant committed
55 56 57 58
    //! Display modes
    typedef QFlags<DisplayMode> DisplayModes;

    explicit QwtPlotSpectrogram( const QString &title = QString::null );
pixhawk's avatar
pixhawk committed
59 60
    virtual ~QwtPlotSpectrogram();

Bryant's avatar
Bryant committed
61 62
    void setDisplayMode( DisplayMode, bool on = true );
    bool testDisplayMode( DisplayMode ) const;
pixhawk's avatar
pixhawk committed
63

Bryant's avatar
Bryant committed
64 65 66
    void setData( QwtRasterData *data );
    const QwtRasterData *data() const;
    QwtRasterData *data();
pixhawk's avatar
pixhawk committed
67

Bryant's avatar
Bryant committed
68 69
    void setColorMap( QwtColorMap * );
    const QwtColorMap *colorMap() const;
pixhawk's avatar
pixhawk committed
70

Bryant's avatar
Bryant committed
71 72
    virtual QwtInterval interval(Qt::Axis) const;
    virtual QRectF pixelHint( const QRectF & ) const;
pixhawk's avatar
pixhawk committed
73

Bryant's avatar
Bryant committed
74 75 76
    void setDefaultContourPen( const QColor &, 
        qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
    void setDefaultContourPen( const QPen & );
pixhawk's avatar
pixhawk committed
77 78
    QPen defaultContourPen() const;

Bryant's avatar
Bryant committed
79
    virtual QPen contourPen( double level ) const;
pixhawk's avatar
pixhawk committed
80

Bryant's avatar
Bryant committed
81 82
    void setConrecFlag( QwtRasterData::ConrecFlag, bool on );
    bool testConrecFlag( QwtRasterData::ConrecFlag ) const;
pixhawk's avatar
pixhawk committed
83

Bryant's avatar
Bryant committed
84 85
    void setContourLevels( const QList<double> & );
    QList<double> contourLevels() const;
pixhawk's avatar
pixhawk committed
86 87 88

    virtual int rtti() const;

Bryant's avatar
Bryant committed
89 90 91
    virtual void draw( QPainter *p,
        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
        const QRectF &rect ) const;
pixhawk's avatar
pixhawk committed
92 93 94

protected:
    virtual QImage renderImage(
95
        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
Bryant's avatar
Bryant committed
96
        const QRectF &area, const QSize &imageSize ) const;
pixhawk's avatar
pixhawk committed
97 98

    virtual QSize contourRasterSize(
Bryant's avatar
Bryant committed
99
        const QRectF &, const QRect & ) const;
pixhawk's avatar
pixhawk committed
100 101

    virtual QwtRasterData::ContourLines renderContourLines(
Bryant's avatar
Bryant committed
102
        const QRectF &rect, const QSize &raster ) const;
pixhawk's avatar
pixhawk committed
103

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

    void renderTile( const QwtScaleMap &xMap, const QwtScaleMap &yMap,
        const QRect &imageRect, QImage *image ) const;
pixhawk's avatar
pixhawk committed
110 111 112 113 114 115

private:
    class PrivateData;
    PrivateData *d_data;
};

Bryant's avatar
Bryant committed
116 117
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotSpectrogram::DisplayModes )

pixhawk's avatar
pixhawk committed
118
#endif