Qwt User's Guide  6.2.0
qwt_plot_curve.h
1 /******************************************************************************
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 
10 #ifndef QWT_PLOT_CURVE_H
11 #define QWT_PLOT_CURVE_H
12 
13 #include "qwt_global.h"
14 #include "qwt_plot_seriesitem.h"
15 
16 #include <qstring.h>
17 
18 class QwtScaleMap;
19 class QwtSymbol;
20 class QwtCurveFitter;
21 template< typename T > class QwtSeriesData;
22 class QwtText;
23 class QPainter;
24 class QPolygonF;
25 class QPen;
26 
56 class QWT_EXPORT QwtPlotCurve
57  : public QwtPlotSeriesItem
58  , public QwtSeriesStore< QPointF >
59 {
60  public:
66  {
70  NoCurve = -1,
71 
78 
84 
91 
99 
105  UserCurve = 100
106  };
107 
113  {
118  Inverted = 0x01,
119 
130  Fitted = 0x02
131  };
132 
133  Q_DECLARE_FLAGS( CurveAttributes, CurveAttribute )
134 
135 
143  {
148  LegendNoAttribute = 0x00,
149 
154  LegendShowLine = 0x01,
155 
159  LegendShowSymbol = 0x02,
160 
165  LegendShowBrush = 0x04
166  };
167 
168  Q_DECLARE_FLAGS( LegendAttributes, LegendAttribute )
169 
170 
177  {
183  ClipPolygons = 0x01,
184 
191  FilterPoints = 0x02,
192 
198  MinimizeMemory = 0x04,
199 
207  ImageBuffer = 0x08,
208 
231  FilterPointsAggressive = 0x10,
232  };
233 
234  Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute )
235 
236  explicit QwtPlotCurve( const QString& title = QString() );
237  explicit QwtPlotCurve( const QwtText& title );
238 
239  virtual ~QwtPlotCurve();
240 
241  virtual int rtti() const QWT_OVERRIDE;
242 
243  void setPaintAttribute( PaintAttribute, bool on = true );
244  bool testPaintAttribute( PaintAttribute ) const;
245 
246  void setLegendAttribute( LegendAttribute, bool on = true );
247  bool testLegendAttribute( LegendAttribute ) const;
248 
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 
275  double minXValue() const;
276  double maxXValue() const;
277  double minYValue() const;
278  double maxYValue() const;
279 
280  void setCurveAttribute( CurveAttribute, bool on = true );
281  bool testCurveAttribute( CurveAttribute ) const;
282 
283  void setPen( const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
284  void setPen( const QPen& );
285  const QPen& pen() const;
286 
287  void setBrush( const QBrush& );
288  const QBrush& brush() const;
289 
290  void setBaseline( double );
291  double baseline() const;
292 
293  void setStyle( CurveStyle style );
294  CurveStyle style() const;
295 
296  void setSymbol( QwtSymbol* );
297  const QwtSymbol* symbol() const;
298 
299  void setCurveFitter( QwtCurveFitter* );
300  QwtCurveFitter* curveFitter() const;
301 
302  virtual void drawSeries( QPainter*,
303  const QwtScaleMap& xMap, const QwtScaleMap& yMap,
304  const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE;
305 
306  virtual QwtGraphic legendIcon( int index, const QSizeF& ) const QWT_OVERRIDE;
307 
308  protected:
309 
310  void init();
311 
312  virtual void drawCurve( QPainter*, int style,
313  const QwtScaleMap& xMap, const QwtScaleMap& yMap,
314  const QRectF& canvasRect, int from, int to ) const;
315 
316  virtual void drawSymbols( QPainter*, const QwtSymbol&,
317  const QwtScaleMap& xMap, const QwtScaleMap& yMap,
318  const QRectF& canvasRect, int from, int to ) const;
319 
320  virtual void drawLines( QPainter*,
321  const QwtScaleMap& xMap, const QwtScaleMap& yMap,
322  const QRectF& canvasRect, int from, int to ) const;
323 
324  virtual void drawSticks( QPainter*,
325  const QwtScaleMap& xMap, const QwtScaleMap& yMap,
326  const QRectF& canvasRect, int from, int to ) const;
327 
328  virtual void drawDots( QPainter*,
329  const QwtScaleMap& xMap, const QwtScaleMap& yMap,
330  const QRectF& canvasRect, int from, int to ) const;
331 
332  virtual void drawSteps( QPainter*,
333  const QwtScaleMap& xMap, const QwtScaleMap& yMap,
334  const QRectF& canvasRect, int from, int to ) const;
335 
336  virtual void fillCurve( QPainter*,
337  const QwtScaleMap&, const QwtScaleMap&,
338  const QRectF& canvasRect, QPolygonF& ) const;
339 
340  void closePolyline( QPainter*,
341  const QwtScaleMap&, const QwtScaleMap&, QPolygonF& ) const;
342 
343  private:
344  class PrivateData;
345  PrivateData* m_data;
346 };
347 
349 inline double QwtPlotCurve::minXValue() const
350 {
351  return boundingRect().left();
352 }
353 
355 inline double QwtPlotCurve::maxXValue() const
356 {
357  return boundingRect().right();
358 }
359 
361 inline double QwtPlotCurve::minYValue() const
362 {
363  return boundingRect().top();
364 }
365 
367 inline double QwtPlotCurve::maxYValue() const
368 {
369  return boundingRect().bottom();
370 }
371 
372 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::PaintAttributes )
373 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::LegendAttributes )
374 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::CurveAttributes )
375 
376 #endif
Abstract base class for a curve fitter.
A paint device for scalable graphics.
Definition: qwt_graphic.h:76
A plot item, that represents a series of points.
QFlags< LegendAttribute > LegendAttributes
double maxXValue() const
boundingRect().right()
double minYValue() const
boundingRect().top()
double maxYValue() const
boundingRect().bottom()
QFlags< PaintAttribute > PaintAttributes
QFlags< CurveAttribute > CurveAttributes
virtual int rtti() const
Base class for plot items representing a series of samples.
virtual QRectF boundingRect() const override
A scale map.
Definition: qwt_scale_map.h:27
Abstract interface for iterating over samples.
Class storing a QwtSeriesData object.
A class for drawing symbols.
Definition: qwt_symbol.h:32
A class representing a text.
Definition: qwt_text.h:52