Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_plot_curve.h
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_plot_curve.h (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_plot_curve.h
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 13 13 #include "qwt_global.h" 14 14 #include "qwt_plot_seriesitem.h" 15 #include "qwt_series_data.h" 16 #include "qwt_text.h" 17 #include <qpen.h> 15 18 16 #include <qstring.h> 19 17 20 class QPainter;21 class QPolygonF;22 18 class QwtScaleMap; 23 19 class QwtSymbol; 24 20 class QwtCurveFitter; 21 template< typename T > class QwtSeriesData; 22 class QwtText; 23 class QPainter; 24 class QPolygonF; 25 class QPen; 25 26 26 27 /*! 27 \brief A plot item, that represents a series of points 28 29 A curve is the representation of a series of points in the x-y plane. 30 It supports different display styles, interpolation ( f.e. spline ) 31 and symbols. 32 33 \par Usage 34 <dl><dt>a) Assign curve properties</dt> 35 <dd>When a curve is created, it is configured to draw black solid lines 36 with in QwtPlotCurve::Lines style and no symbols. 37 You can change this by calling 38 setPen(), setStyle() and setSymbol().</dd> 39 <dt>b) Connect/Assign data.</dt> 40 <dd>QwtPlotCurve gets its points using a QwtSeriesData object offering 41 a bridge to the real storage of the points ( like QAbstractItemModel ). 42 There are several convenience classes derived from QwtSeriesData, that also store 43 the points inside ( like QStandardItemModel ). QwtPlotCurve also offers 44 a couple of variations of setSamples(), that build QwtSeriesData objects from 45 arrays internally.</dd> 46 <dt>c) Attach the curve to a plot</dt> 47 <dd>See QwtPlotItem::attach() 48 </dd></dl> 49 50 \par Example: 51 see examples/bode 52 53 \sa QwtPointSeriesData, QwtSymbol, QwtScaleMap 54 */ 55 class QWT_EXPORT QwtPlotCurve: 56 public QwtPlotSeriesItem, public QwtSeriesStore<QPointF> 57 { 58 public: 28 \brief A plot item, that represents a series of points 29 30 A curve is the representation of a series of points in the x-y plane. 31 It supports different display styles, interpolation ( f.e. spline ) 32 and symbols. 33 34 \par Usage 35 <dl><dt>a) Assign curve properties</dt> 36 <dd>When a curve is created, it is configured to draw black solid lines 37 with in QwtPlotCurve::Lines style and no symbols. 38 You can change this by calling 39 setPen(), setStyle() and setSymbol().</dd> 40 <dt>b) Connect/Assign data.</dt> 41 <dd>QwtPlotCurve gets its points using a QwtSeriesData object offering 42 a bridge to the real storage of the points ( like QAbstractItemModel ). 43 There are several convenience classes derived from QwtSeriesData, that also store 44 the points inside ( like QStandardItemModel ). QwtPlotCurve also offers 45 a couple of variations of setSamples(), that build QwtSeriesData objects from 46 arrays internally.</dd> 47 <dt>c) Attach the curve to a plot</dt> 48 <dd>See QwtPlotItem::attach() 49 </dd></dl> 50 51 \par Example: 52 see examples/bode 53 54 \sa QwtPointSeriesData, QwtSymbol, QwtScaleMap 55 */ 56 class QWT_EXPORT QwtPlotCurve 57 : public QwtPlotSeriesItem 58 , public QwtSeriesStore< QPointF > 59 { 60 public: 59 61 /*! 60 62 Curve styles. 61 63 \sa setStyle(), style() 62 */ 64 */ 63 65 enum CurveStyle 64 66 { 65 67 /*! 66 68 Don't draw a curve. Note: This doesn't affect the symbols. 67 */ 69 */ 68 70 NoCurve = -1, 69 71 … … 72 74 be interpolated depending on the 'Fitted' attribute. Curve 73 75 fitting can be configured using setCurveFitter(). 74 */ 76 */ 75 77 Lines, 76 78 … … 78 80 Draw vertical or horizontal sticks ( depending on the 79 81 orientation() ) from a baseline which is defined by setBaseline(). 80 */ 82 */ 81 83 Sticks, 82 84 … … 85 87 is drawn from the left to the right or vice versa, 86 88 depending on the QwtPlotCurve::Inverted attribute. 87 */ 89 */ 88 90 Steps, 89 91 … … 93 95 as a curve in QwtPlotCurve::NoStyle style and a symbol 94 96 painting a point. 95 */ 97 */ 96 98 Dots, 97 99 … … 100 102 classes of QwtPlotCurve that overload drawCurve() with 101 103 additional application specific curve types. 102 */ 104 */ 103 105 UserCurve = 100 104 106 }; 105 107 106 108 /*! 107 Attribute for drawing the curve 108 \sa setCurveAttribute(), testCurveAttribute(), curveFitter() 109 */ 109 Attribute for drawing the curve 110 \sa setCurveAttribute(), testCurveAttribute(), curveFitter() 111 */ 110 112 enum CurveAttribute 111 113 { … … 117 119 118 120 /*! 119 Only in combination with QwtPlotCurve::Lines 120 A QwtCurveFitter tries to 121 interpolate/smooth the curve, before it is painted. 122 123 \note Curve fitting requires temporary memory 124 for calculating coefficients and additional points. 125 If painting in QwtPlotCurve::Fitted mode is slow it might be better 126 to fit the points, before they are passed to QwtPlotCurve. 121 Only in combination with QwtPlotCurve::Lines 122 A QwtCurveFitter tries to 123 interpolate/smooth the curve, before it is painted. 124 125 \note Curve fitting requires temporary memory 126 for calculating coefficients and additional points. 127 If painting in QwtPlotCurve::Fitted mode is slow it might be better 128 to fit the points, before they are passed to QwtPlotCurve. 127 129 */ 128 130 Fitted = 0x02 129 131 }; 130 132 131 //! Curve attributes 132 typedef QFlags<CurveAttribute> CurveAttributes; 133 Q_DECLARE_FLAGS( CurveAttributes, CurveAttribute ) 133 134 134 135 /*! … … 142 143 { 143 144 /*! 144 QwtPlotCurve tries to find a color representing the curve 145 and paints a rectangle with it. 145 QwtPlotCurve tries to find a color representing the curve 146 and paints a rectangle with it. 146 147 */ 147 148 LegendNoAttribute = 0x00, 148 149 149 150 /*! 150 If the style() is not QwtPlotCurve::NoCurve a line 151 is painted with the curve pen(). 151 If the style() is not QwtPlotCurve::NoCurve a line 152 is painted with the curve pen(). 152 153 */ 153 154 LegendShowLine = 0x01, 154 155 155 156 /*! 156 If the curve has a valid symbol it is painted. 157 If the curve has a valid symbol it is painted. 157 158 */ 158 159 LegendShowSymbol = 0x02, 159 160 160 161 /*! 161 If the curve has a brush a rectangle filled with the 162 curve brush() is painted. 162 If the curve has a brush a rectangle filled with the 163 curve brush() is painted. 163 164 */ 164 165 LegendShowBrush = 0x04 165 166 }; 166 167 167 //! Legend attributes 168 typedef QFlags<LegendAttribute> LegendAttributes; 168 Q_DECLARE_FLAGS( LegendAttributes, LegendAttribute ) 169 169 170 170 /*! … … 173 173 174 174 \sa setPaintAttribute(), testPaintAttribute() 175 */ 175 */ 176 176 enum PaintAttribute 177 177 { 178 178 /*! 179 Clip polygons before painting them. In situations, where points 180 are far outside the visible area (f.e when zooming deep) this 181 might be a substantial improvement for the painting performance 179 Clip polygons before painting them. In situations, where points 180 are far outside the visible area (f.e when zooming deep) this 181 might be a substantial improvement for the painting performance 182 182 */ 183 183 ClipPolygons = 0x01, 184 184 185 185 /*! 186 Tries to reduce the data that has to be painted, by sorting out 187 duplicates, or paintings outside the visible area. Might have a 188 notable impact on curves with many close points. 189 Only a couple of very basic filtering algorithms are implemented. 186 Tries to reduce the data that has to be painted, by sorting out 187 duplicates, or paintings outside the visible area. Might have a 188 notable impact on curves with many close points. 189 Only a couple of very basic filtering algorithms are implemented. 190 190 */ 191 191 FilterPoints = 0x02, 192 192 193 193 /*! 194 Minimize memory usage that is temporarily needed for the 195 translated points, before they get painted. 196 This might slow down the performance of painting 194 Minimize memory usage that is temporarily needed for the 195 translated points, before they get painted. 196 This might slow down the performance of painting 197 197 */ 198 198 MinimizeMemory = 0x04, 199 199 200 200 /*! 201 Render the points to a temporary image and paint the image. 202 This is a very special optimization for Dots style, when 203 having a huge amount of points. 204 With a reasonable number of points QPainter::drawPoints() 205 will be faster. 206 */ 207 ImageBuffer = 0x08 201 Render the points to a temporary image and paint the image. 202 This is a very special optimization for Dots style, when 203 having a huge amount of points. 204 With a reasonable number of points QPainter::drawPoints() 205 will be faster. 206 */ 207 ImageBuffer = 0x08, 208 209 /*! 210 More aggressive point filtering trying to filter out 211 intermediate points, accepting minor visual differences. 212 213 Has only an effect, when drawing the curve to a paint device 214 in integer coordinates ( f.e. all widgets on screen ) using the fact, 215 that consecutive points are often mapped to the same x or y coordinate. 216 Each chunk of samples mapped to the same coordinate can be reduced to 217 4 points ( first, min, max last ). 218 219 In the worst case the polygon to be rendered will be 4 times the width 220 of the plot canvas. 221 222 The algorithm is very fast and effective for huge datasets, and can be used 223 inside a replot cycle. 224 225 \note Implemented for QwtPlotCurve::Lines only 226 \note As this algo replaces many small lines by a long one 227 a nasty bug of the raster paint engine ( Qt 4.8, Qt 5.1 - 5.3 ) 228 becomes more dominant. For these versions the bug can be 229 worked around by enabling the QwtPainter::polylineSplitting() mode. 230 */ 231 FilterPointsAggressive = 0x10, 208 232 }; 209 233 210 //! Paint attributes 211 typedef QFlags<PaintAttribute> PaintAttributes; 212 213 explicit QwtPlotCurve( const QString &title = QString() ); 214 explicit QwtPlotCurve( const QwtText &title ); 234 Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute ) 235 236 explicit QwtPlotCurve( const QString& title = QString() ); 237 explicit QwtPlotCurve( const QwtText& title ); 215 238 216 239 virtual ~QwtPlotCurve(); 217 240 218 virtual int rtti() const; 241 virtual int rtti() const QWT_OVERRIDE; 219 242 220 243 void setPaintAttribute( PaintAttribute, bool on = true ); … … 224 247 bool testLegendAttribute( LegendAttribute ) const; 225 248 226 #ifndef QWT_NO_COMPAT 227 void setRawSamples( const double *xData, const double *yData, int size ); 228 void setSamples( const double *xData, const double *yData, int size ); 229 void setSamples( const QVector<double> &xData, const QVector<double> &yData ); 230 #endif 231 void setSamples( const QVector<QPointF> & ); 232 void setSamples( QwtSeriesData<QPointF> * ); 233 234 int closestPoint( const QPoint &pos, double *dist = NULL ) const; 249 void setLegendAttributes( LegendAttributes ); 250 LegendAttributes legendAttributes() const; 251 252 void setRawSamples( const double* xData, const double* yData, int size ); 253 void setRawSamples( const float* xData, const float* yData, int size ); 254 255 void setRawSamples( const double* yData, int size ); 256 void setRawSamples( const float* yData, int size ); 257 258 void setSamples( const double* xData, const double* yData, int size ); 259 void setSamples( const float* xData, const float* yData, int size ); 260 261 void setSamples( const double* yData, int size ); 262 void setSamples( const float* yData, int size ); 263 264 void setSamples( const QVector< double >& yData ); 265 void setSamples( const QVector< float >& yData ); 266 267 void setSamples( const QVector< double >& xData, const QVector< double >& yData ); 268 void setSamples( const QVector< float >& xData, const QVector< float >& yData ); 269 270 void setSamples( const QVector< QPointF >& ); 271 void setSamples( QwtSeriesData< QPointF >* ); 272 273 virtual int closestPoint( const QPointF& pos, double* dist = NULL ) const; 274 virtual int adjacentPoint( Qt::Orientation orientation, qreal value ) const; 275 276 qreal interpolatedValueAt( Qt::Orientation, double ) const; 235 277 236 278 double minXValue() const; … … 242 284 bool testCurveAttribute( CurveAttribute ) const; 243 285 244 void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );245 void setPen( const QPen & );246 const QPen &pen() const;247 248 void setBrush( const QBrush & );249 const QBrush &brush() const;286 void setPen( const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); 287 void setPen( const QPen& ); 288 const QPen& pen() const; 289 290 void setBrush( const QBrush& ); 291 const QBrush& brush() const; 250 292 251 293 void setBaseline( double ); … … 255 297 CurveStyle style() const; 256 298 257 void setSymbol( QwtSymbol * );258 const QwtSymbol *symbol() const;259 260 void setCurveFitter( QwtCurveFitter * );261 QwtCurveFitter *curveFitter() const;262 263 virtual void drawSeries( QPainter *,264 const QwtScaleMap &xMap, const QwtScaleMap&yMap,265 const QRectF &canvasRect, int from, int to ) const;266 267 virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;268 269 protected: 299 void setSymbol( QwtSymbol* ); 300 const QwtSymbol* symbol() const; 301 302 void setCurveFitter( QwtCurveFitter* ); 303 QwtCurveFitter* curveFitter() const; 304 305 virtual void drawSeries( QPainter*, 306 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 307 const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE; 308 309 virtual QwtGraphic legendIcon( int index, const QSizeF& ) const QWT_OVERRIDE; 310 311 protected: 270 312 271 313 void init(); 272 314 273 virtual void drawCurve( QPainter *, int style,274 const QwtScaleMap &xMap, const QwtScaleMap&yMap,275 const QRectF &canvasRect, int from, int to ) const;276 277 virtual void drawSymbols( QPainter *, const QwtSymbol&,278 const QwtScaleMap &xMap, const QwtScaleMap&yMap,279 const QRectF &canvasRect, int from, int to ) const;280 281 virtual void drawLines( QPainter *,282 const QwtScaleMap &xMap, const QwtScaleMap&yMap,283 const QRectF &canvasRect, int from, int to ) const;284 285 virtual void drawSticks( QPainter *,286 const QwtScaleMap &xMap, const QwtScaleMap&yMap,287 const QRectF &canvasRect, int from, int to ) const;288 289 virtual void drawDots( QPainter *,290 const QwtScaleMap &xMap, const QwtScaleMap&yMap,291 const QRectF &canvasRect, int from, int to ) const;292 293 virtual void drawSteps( QPainter *,294 const QwtScaleMap &xMap, const QwtScaleMap&yMap,295 const QRectF &canvasRect, int from, int to ) const;296 297 virtual void fillCurve( QPainter *,298 const QwtScaleMap &, const QwtScaleMap&,299 const QRectF &canvasRect, QPolygonF& ) const;300 301 void closePolyline( QPainter *,302 const QwtScaleMap &, const QwtScaleMap&, QPolygonF& ) const;303 304 private: 315 virtual void drawCurve( QPainter*, int style, 316 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 317 const QRectF& canvasRect, int from, int to ) const; 318 319 virtual void drawSymbols( QPainter*, const QwtSymbol&, 320 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 321 const QRectF& canvasRect, int from, int to ) const; 322 323 virtual void drawLines( QPainter*, 324 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 325 const QRectF& canvasRect, int from, int to ) const; 326 327 virtual void drawSticks( QPainter*, 328 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 329 const QRectF& canvasRect, int from, int to ) const; 330 331 virtual void drawDots( QPainter*, 332 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 333 const QRectF& canvasRect, int from, int to ) const; 334 335 virtual void drawSteps( QPainter*, 336 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 337 const QRectF& canvasRect, int from, int to ) const; 338 339 virtual void fillCurve( QPainter*, 340 const QwtScaleMap&, const QwtScaleMap&, 341 const QRectF& canvasRect, QPolygonF& ) const; 342 343 void closePolyline( QPainter*, 344 const QwtScaleMap&, const QwtScaleMap&, QPolygonF& ) const; 345 346 private: 305 347 class PrivateData; 306 PrivateData *d_data;348 PrivateData* m_data; 307 349 }; 308 350
Note:
See TracChangeset
for help on using the changeset viewer.
