qwt_plot_spectrogram.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
  2. * Qwt Widget Library
  3. * Copyright (C) 1997 Josef Wilgen
  4. * Copyright (C) 2002 Uwe Rathmann
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the Qwt License, Version 1.0
  8. *****************************************************************************/
  9. #ifndef QWT_PLOT_SPECTROGRAM_H
  10. #define QWT_PLOT_SPECTROGRAM_H
  11. #include "qwt_global.h"
  12. #include "qwt_raster_data.h"
  13. #include "qwt_plot_rasteritem.h"
  14. #include <qlist.h>
  15. class QwtColorMap;
  16. /*!
  17. \brief A plot item, which displays a spectrogram
  18. A spectrogram displays 3-dimensional data, where the 3rd dimension
  19. ( the intensity ) is displayed using colors. The colors are calculated
  20. from the values using a color map.
  21. On multi-core systems the performance of the image composition
  22. can often be improved by dividing the area into tiles - each of them
  23. rendered in a different thread ( see QwtPlotItem::setRenderThreadCount() ).
  24. In ContourMode contour lines are painted for the contour levels.
  25. \image html spectrogram3.png
  26. \sa QwtRasterData, QwtColorMap, QwtPlotItem::setRenderThreadCount()
  27. */
  28. class QWT_EXPORT QwtPlotSpectrogram: public QwtPlotRasterItem
  29. {
  30. public:
  31. /*!
  32. The display mode controls how the raster data will be represented.
  33. \sa setDisplayMode(), testDisplayMode()
  34. */
  35. enum DisplayMode
  36. {
  37. //! The values are mapped to colors using a color map.
  38. ImageMode = 0x01,
  39. //! The data is displayed using contour lines
  40. ContourMode = 0x02
  41. };
  42. //! Display modes
  43. typedef QFlags<DisplayMode> DisplayModes;
  44. explicit QwtPlotSpectrogram( const QString &title = QString() );
  45. virtual ~QwtPlotSpectrogram();
  46. void setDisplayMode( DisplayMode, bool on = true );
  47. bool testDisplayMode( DisplayMode ) const;
  48. void setData( QwtRasterData *data );
  49. const QwtRasterData *data() const;
  50. QwtRasterData *data();
  51. void setColorMap( QwtColorMap * );
  52. const QwtColorMap *colorMap() const;
  53. virtual QwtInterval interval(Qt::Axis) const;
  54. virtual QRectF pixelHint( const QRectF & ) const;
  55. void setDefaultContourPen( const QColor &,
  56. qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
  57. void setDefaultContourPen( const QPen & );
  58. QPen defaultContourPen() const;
  59. virtual QPen contourPen( double level ) const;
  60. void setConrecFlag( QwtRasterData::ConrecFlag, bool on );
  61. bool testConrecFlag( QwtRasterData::ConrecFlag ) const;
  62. void setContourLevels( const QList<double> & );
  63. QList<double> contourLevels() const;
  64. virtual int rtti() const;
  65. virtual void draw( QPainter *,
  66. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  67. const QRectF &canvasRect ) const;
  68. protected:
  69. virtual QImage renderImage(
  70. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  71. const QRectF &area, const QSize &imageSize ) const;
  72. virtual QSize contourRasterSize(
  73. const QRectF &, const QRect & ) const;
  74. virtual QwtRasterData::ContourLines renderContourLines(
  75. const QRectF &rect, const QSize &raster ) const;
  76. virtual void drawContourLines( QPainter *,
  77. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  78. const QwtRasterData::ContourLines& ) const;
  79. void renderTile( const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  80. const QRect &tile, QImage * ) const;
  81. private:
  82. class PrivateData;
  83. PrivateData *d_data;
  84. };
  85. Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotSpectrogram::DisplayModes )
  86. #endif