qwt_plot_intervalcurve.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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_INTERVAL_CURVE_H
  10. #define QWT_PLOT_INTERVAL_CURVE_H
  11. #include "qwt_global.h"
  12. #include "qwt_plot_seriesitem.h"
  13. #include "qwt_series_data.h"
  14. class QwtIntervalSymbol;
  15. /*!
  16. \brief QwtPlotIntervalCurve represents a series of samples, where each value
  17. is associated with an interval ( \f$[y1,y2] = f(x)\f$ ).
  18. The representation depends on the style() and an optional symbol()
  19. that is displayed for each interval. QwtPlotIntervalCurve might be used
  20. to display error bars or the area between 2 curves.
  21. */
  22. class QWT_EXPORT QwtPlotIntervalCurve:
  23. public QwtPlotSeriesItem, public QwtSeriesStore<QwtIntervalSample>
  24. {
  25. public:
  26. /*!
  27. \brief Curve styles.
  28. The default setting is QwtPlotIntervalCurve::Tube.
  29. \sa setStyle(), style()
  30. */
  31. enum CurveStyle
  32. {
  33. /*!
  34. Don't draw a curve. Note: This doesn't affect the symbols.
  35. */
  36. NoCurve,
  37. /*!
  38. Build 2 curves from the upper and lower limits of the intervals
  39. and draw them with the pen(). The area between the curves is
  40. filled with the brush().
  41. */
  42. Tube,
  43. /*!
  44. Styles >= QwtPlotIntervalCurve::UserCurve are reserved for derived
  45. classes that overload drawSeries() with
  46. additional application specific curve types.
  47. */
  48. UserCurve = 100
  49. };
  50. /*!
  51. Attributes to modify the drawing algorithm.
  52. \sa setPaintAttribute(), testPaintAttribute()
  53. */
  54. enum PaintAttribute
  55. {
  56. /*!
  57. Clip polygons before painting them. In situations, where points
  58. are far outside the visible area (f.e when zooming deep) this
  59. might be a substantial improvement for the painting performance.
  60. */
  61. ClipPolygons = 0x01,
  62. //! Check if a symbol is on the plot canvas before painting it.
  63. ClipSymbol = 0x02
  64. };
  65. //! Paint attributes
  66. typedef QFlags<PaintAttribute> PaintAttributes;
  67. explicit QwtPlotIntervalCurve( const QString &title = QString() );
  68. explicit QwtPlotIntervalCurve( const QwtText &title );
  69. virtual ~QwtPlotIntervalCurve();
  70. virtual int rtti() const;
  71. void setPaintAttribute( PaintAttribute, bool on = true );
  72. bool testPaintAttribute( PaintAttribute ) const;
  73. void setSamples( const QVector<QwtIntervalSample> & );
  74. void setSamples( QwtSeriesData<QwtIntervalSample> * );
  75. void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
  76. void setPen( const QPen & );
  77. const QPen &pen() const;
  78. void setBrush( const QBrush & );
  79. const QBrush &brush() const;
  80. void setStyle( CurveStyle style );
  81. CurveStyle style() const;
  82. void setSymbol( const QwtIntervalSymbol * );
  83. const QwtIntervalSymbol *symbol() const;
  84. virtual void drawSeries( QPainter *,
  85. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  86. const QRectF &canvasRect, int from, int to ) const;
  87. virtual QRectF boundingRect() const;
  88. virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
  89. protected:
  90. void init();
  91. virtual void drawTube( QPainter *,
  92. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  93. const QRectF &canvasRect, int from, int to ) const;
  94. virtual void drawSymbols( QPainter *, const QwtIntervalSymbol &,
  95. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  96. const QRectF &canvasRect, int from, int to ) const;
  97. private:
  98. class PrivateData;
  99. PrivateData *d_data;
  100. };
  101. Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotIntervalCurve::PaintAttributes )
  102. #endif