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