Qwt User's Guide 6.1.0

- Main Page
- Related Pages
- Classes

All Classes Functions Variables Typedefs Enumerations Enumerator Pages
qwt_plot_curve.h
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
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 #include "qwt_series_data.h"
16 #include "qwt_text.h"
17 #include <qpen.h>
18 #include <qstring.h>
19
20 class QPainter;
21 class QPolygonF;
22 class QwtScaleMap;
23 class QwtSymbol;
24 class QwtCurveFitter;
25
55 class QWT_EXPORT QwtPlotCurve:
56 public QwtPlotSeriesItem, public QwtSeriesStore<QPointF>
57 {
58 public:
63 enum CurveStyle
64 {
68 NoCurve = -1,
69
75 Lines,
76
81 Sticks,
82
88 Steps,
89
96 Dots,
97
103 UserCurve = 100
104 };
105
110 enum CurveAttribute
111 {
116 Inverted = 0x01,
117
128 Fitted = 0x02
129 };
130
132 typedef QFlags<CurveAttribute> CurveAttributes;
133
141 enum LegendAttribute
142 {
147 LegendNoAttribute = 0x00,
148
153 LegendShowLine = 0x01,
154
158 LegendShowSymbol = 0x02,
159
164 LegendShowBrush = 0x04
165 };
166
168 typedef QFlags<LegendAttribute> LegendAttributes;
169
176 enum PaintAttribute
177 {
183 ClipPolygons = 0x01,
184
191 FilterPoints = 0x02,
192
198 MinimizeMemory = 0x04,
199
207 ImageBuffer = 0x08
208 };
209
211 typedef QFlags<PaintAttribute> PaintAttributes;
212
213 explicit QwtPlotCurve( const QString &title = QString::null );
214 explicit QwtPlotCurve( const QwtText &title );
215
216 virtual ~QwtPlotCurve();
217
218 virtual int rtti() const;
219
220 void setPaintAttribute( PaintAttribute, bool on = true );
221 bool testPaintAttribute( PaintAttribute ) const;
222
223 void setLegendAttribute( LegendAttribute, bool on = true );
224 bool testLegendAttribute( LegendAttribute ) const;
225
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;
235
236 double minXValue() const;
237 double maxXValue() const;
238 double minYValue() const;
239 double maxYValue() const;
240
241 void setCurveAttribute( CurveAttribute, bool on = true );
242 bool testCurveAttribute( CurveAttribute ) const;
243
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;
250
251 void setBaseline( double );
252 double baseline() const;
253
254 void setStyle( CurveStyle style );
255 CurveStyle style() const;
256
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:
270
271 void init();
272
273 virtual void drawCurve( QPainter *p, int style,
274 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
275 const QRectF &canvasRect, int from, int to ) const;
276
277 virtual void drawSymbols( QPainter *p, const QwtSymbol &,
278 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
279 const QRectF &canvasRect, int from, int to ) const;
280
281 virtual void drawLines( QPainter *p,
282 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
283 const QRectF &canvasRect, int from, int to ) const;
284
285 virtual void drawSticks( QPainter *p,
286 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
287 const QRectF &canvasRect, int from, int to ) const;
288
289 virtual void drawDots( QPainter *p,
290 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
291 const QRectF &canvasRect, int from, int to ) const;
292
293 virtual void drawSteps( QPainter *p,
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:
305 class PrivateData;
306 PrivateData *d_data;
307 };
308
310 inline double QwtPlotCurve::minXValue() const
311 {
312 return boundingRect().left();
313 }
314
316 inline double QwtPlotCurve::maxXValue() const
317 {
318 return boundingRect().right();
319 }
320
322 inline double QwtPlotCurve::minYValue() const
323 {
324 return boundingRect().top();
325 }
326
328 inline double QwtPlotCurve::maxYValue() const
329 {
330 return boundingRect().bottom();
331 }
332
333 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::PaintAttributes )
334 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::LegendAttributes )
335 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::CurveAttributes )
336
337 #endif