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:
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
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
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:355
QwtPlotCurve::LegendAttribute
LegendAttribute
Definition: qwt_plot_curve.h:143
QwtPlotCurve::minYValue
double minYValue() const
boundingRect().top()
Definition: qwt_plot_curve.h:361
QwtPlotCurve::PaintAttribute
PaintAttribute
Definition: qwt_plot_curve.h:177
QwtPlotCurve::maxYValue
double maxYValue() const
boundingRect().bottom()
Definition: qwt_plot_curve.h:367
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