qwt_polar_curve.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
  2. * QwtPolar Widget Library
  3. * Copyright (C) 2008 Uwe Rathmann
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the Qwt License, Version 1.0
  7. *****************************************************************************/
  8. #ifndef QWT_POLAR_CURVE_H
  9. #define QWT_POLAR_CURVE_H
  10. #include "qwt_polar_global.h"
  11. #include "qwt_polar_item.h"
  12. #include <qwt_point_polar.h>
  13. #include <qwt_series_data.h>
  14. class QPainter;
  15. class QwtSymbol;
  16. class QwtCurveFitter;
  17. /*!
  18. \brief An item, that represents a series of points
  19. A curve is the representation of a series of points in polar coordinates.
  20. The points are connected to the curve using the abstract QwtData interface.
  21. \sa QwtPolarPlot, QwtSymbol, QwtScaleMap
  22. */
  23. class QWT_POLAR_EXPORT QwtPolarCurve: public QwtPolarItem
  24. {
  25. public:
  26. /*!
  27. Curve styles.
  28. \sa setStyle(), style()
  29. */
  30. enum CurveStyle
  31. {
  32. //! Don't draw a curve. Note: This doesn't affect the symbols.
  33. NoCurve,
  34. /*!
  35. Connect the points with straight lines. The lines might
  36. be interpolated depending on the 'Fitted' attribute. Curve
  37. fitting can be configured using setCurveFitter().
  38. */
  39. Lines,
  40. //! Values > 100 are reserved for user specific curve styles
  41. UserCurve = 100
  42. };
  43. /*!
  44. \brief Attributes how to represent the curve on the legend
  45. If none of the flags is activated QwtPlotCurve tries to find
  46. a color representing the curve and paints a rectangle with it.
  47. In the default setting all attributes are off.
  48. \sa setLegendAttribute(), testLegendAttribute()
  49. */
  50. enum LegendAttribute
  51. {
  52. /*!
  53. If the curveStyle() is not NoCurve a line is painted with the
  54. curvePen().
  55. */
  56. LegendShowLine = 0x01,
  57. //! If the curve has a valid symbol it is painted.
  58. LegendShowSymbol = 0x02
  59. };
  60. //! Legend attributes
  61. typedef QFlags<LegendAttribute> LegendAttributes;
  62. explicit QwtPolarCurve();
  63. explicit QwtPolarCurve( const QwtText &title );
  64. explicit QwtPolarCurve( const QString &title );
  65. virtual ~QwtPolarCurve();
  66. virtual int rtti() const;
  67. void setLegendAttribute( LegendAttribute, bool on = true );
  68. bool testLegendAttribute( LegendAttribute ) const;
  69. void setData( QwtSeriesData<QwtPointPolar> *data );
  70. const QwtSeriesData<QwtPointPolar> *data() const;
  71. size_t dataSize() const;
  72. QwtPointPolar sample( int i ) const;
  73. void setPen( const QPen & );
  74. const QPen &pen() const;
  75. void setStyle( CurveStyle style );
  76. CurveStyle style() const;
  77. void setSymbol( QwtSymbol * );
  78. const QwtSymbol *symbol() const;
  79. void setCurveFitter( QwtCurveFitter * );
  80. QwtCurveFitter *curveFitter() const;
  81. virtual void draw( QPainter *p,
  82. const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
  83. const QPointF &pole, double radius,
  84. const QRectF &canvasRect ) const;
  85. virtual void draw( QPainter *p,
  86. const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
  87. const QPointF &pole, int from, int to ) const;
  88. virtual QwtInterval boundingInterval( int scaleId ) const;
  89. virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
  90. protected:
  91. void init();
  92. virtual void drawCurve( QPainter *, int style,
  93. const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
  94. const QPointF &pole, int from, int to ) const;
  95. virtual void drawSymbols( QPainter *, const QwtSymbol &,
  96. const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
  97. const QPointF &pole, int from, int to ) const;
  98. void drawLines( QPainter *,
  99. const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
  100. const QPointF &pole, int from, int to ) const;
  101. private:
  102. QwtSeriesData<QwtPointPolar> *d_series;
  103. class PrivateData;
  104. PrivateData *d_data;
  105. };
  106. //! \return the the curve data
  107. inline const QwtSeriesData<QwtPointPolar> *QwtPolarCurve::data() const
  108. {
  109. return d_series;
  110. }
  111. /*!
  112. \param i index
  113. \return point at position i
  114. */
  115. inline QwtPointPolar QwtPolarCurve::sample( int i ) const
  116. {
  117. return d_series->sample( i );
  118. }
  119. Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarCurve::LegendAttributes )
  120. #endif