Qwt User's Guide 6.3.0

Loading...
Searching...
No Matches
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:
65 enum CurveStyle
66 {
70 NoCurve = -1,
71
77 Lines,
78
83 Sticks,
84
90 Steps,
91
98 Dots,
99
105 UserCurve = 100
106 };
107
112 enum CurveAttribute
113 {
118 Inverted = 0x01,
119
130 Fitted = 0x02
131 };
132
133 Q_DECLARE_FLAGS( CurveAttributes, CurveAttribute )
134
135
142 enum LegendAttribute
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
176 enum PaintAttribute
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 virtual int adjacentPoint( Qt::Orientation orientation, qreal value ) const;
275
276 qreal interpolatedValueAt( Qt::Orientation, double ) const;
277
278 double minXValue() const;
279 double maxXValue() const;
280 double minYValue() const;
281 double maxYValue() const;
282
283 void setCurveAttribute( CurveAttribute, bool on = true );
284 bool testCurveAttribute( CurveAttribute ) const;
285
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;
292
293 void setBaseline( double );
294 double baseline() const;
295
296 void setStyle( CurveStyle style );
297 CurveStyle style() const;
298
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:
312
313 void init();
314
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:
347 class PrivateData;
348 PrivateData* m_data;
349};
350
352inline double QwtPlotCurve::minXValue() const
353{
354 return boundingRect().left();
355}
356
358 inline double QwtPlotCurve::maxXValue() const
359{
360 return boundingRect().right();
361}
362
364 inline double QwtPlotCurve::minYValue() const
365{
366 return boundingRect().top();
367}
368
370 inline double QwtPlotCurve::maxYValue() const
371{
372 return boundingRect().bottom();
373}
374
375Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::PaintAttributes )
376Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::LegendAttributes )
377Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::CurveAttributes )
378
379#endif
QVector
Definition qwt_clipper.h:23
QwtCurveFitter
Abstract base class for a curve fitter.
Definition qwt_curve_fitter.h:22
QwtGraphic
A paint device for scalable graphics.
Definition qwt_graphic.h:76
QwtPlotCurve
A plot item, that represents a series of points.
Definition qwt_plot_curve.h:59
QwtPlotCurve::CurveStyle
CurveStyle
Definition qwt_plot_curve.h:66
QwtPlotCurve::Steps
@ Steps
Definition qwt_plot_curve.h:90
QwtPlotCurve::Sticks
@ Sticks
Definition qwt_plot_curve.h:83
QwtPlotCurve::Lines
@ Lines
Definition qwt_plot_curve.h:77
QwtPlotCurve::Dots
@ Dots
Definition qwt_plot_curve.h:98
QwtPlotCurve::LegendAttributes
QFlags< LegendAttribute > LegendAttributes
Definition qwt_plot_curve.h:168
QwtPlotCurve::CurveAttribute
CurveAttribute
Definition qwt_plot_curve.h:113
QwtPlotCurve::maxXValue
double maxXValue() const
boundingRect().right()
Definition qwt_plot_curve.h:358
QwtPlotCurve::LegendAttribute
LegendAttribute
Definition qwt_plot_curve.h:143
QwtPlotCurve::minYValue
double minYValue() const
boundingRect().top()
Definition qwt_plot_curve.h:364
QwtPlotCurve::PaintAttribute
PaintAttribute
Definition qwt_plot_curve.h:177
QwtPlotCurve::maxYValue
double maxYValue() const
boundingRect().bottom()
Definition qwt_plot_curve.h:370
QwtPlotCurve::PaintAttributes
QFlags< PaintAttribute > PaintAttributes
Definition qwt_plot_curve.h:234
QwtPlotCurve::CurveAttributes
QFlags< CurveAttribute > CurveAttributes
Definition qwt_plot_curve.h:133
QwtPlotItem::rtti
virtual int rtti() const
Definition qwt_plot_item.cpp:136
QwtPlotSeriesItem
Base class for plot items representing a series of samples.
Definition qwt_plot_seriesitem.h:26
QwtPlotSeriesItem::boundingRect
virtual QRectF boundingRect() const override
Definition qwt_plot_seriesitem.cpp:97
QwtScaleMap
A scale map.
Definition qwt_scale_map.h:27
QwtSeriesData
Abstract interface for iterating over samples.
Definition qwt_series_data.h:50
QwtSeriesStore
Class storing a QwtSeriesData object.
Definition qwt_series_store.h:67
QwtSymbol
A class for drawing symbols.
Definition qwt_symbol.h:32
QwtText
A class representing a text.
Definition qwt_text.h:52