Qwt User's Guide 6.0.2

- Main Page
- Related Pages
- Classes

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: public QwtPlotSeriesItem<QPointF>
56 {
57 public:
62 enum CurveStyle
63 {
67 NoCurve = -1,
68
74 Lines,
75
80 Sticks,
81
87 Steps,
88
95 Dots,
96
102 UserCurve = 100
103 };
104
109 enum CurveAttribute
110 {
115 Inverted = 0x01,
116
127 Fitted = 0x02
128 };
129
131 typedef QFlags<CurveAttribute> CurveAttributes;
132
140 enum LegendAttribute
141 {
146 LegendNoAttribute = 0x00,
147
152 LegendShowLine = 0x01,
153
157 LegendShowSymbol = 0x02,
158
163 LegendShowBrush = 0x04
164 };
165
167 typedef QFlags<LegendAttribute> LegendAttributes;
168
175 enum PaintAttribute
176 {
182 ClipPolygons = 0x01,
183
190 CacheSymbols = 0x02
191 };
192
194 typedef QFlags<PaintAttribute> PaintAttributes;
195
196 explicit QwtPlotCurve( const QString &title = QString::null );
197 explicit QwtPlotCurve( const QwtText &title );
198
199 virtual ~QwtPlotCurve();
200
201 virtual int rtti() const;
202
203 void setPaintAttribute( PaintAttribute, bool on = true );
204 bool testPaintAttribute( PaintAttribute ) const;
205
206 void setLegendAttribute( LegendAttribute, bool on = true );
207 bool testLegendAttribute( LegendAttribute ) const;
208
209 #ifndef QWT_NO_COMPAT
210 void setRawSamples( const double *xData, const double *yData, int size );
211 void setSamples( const double *xData, const double *yData, int size );
212 void setSamples( const QVector<double> &xData, const QVector<double> &yData );
213 #endif
214 void setSamples( const QVector<QPointF> & );
215
216 int closestPoint( const QPoint &pos, double *dist = NULL ) const;
217
218 double minXValue() const;
219 double maxXValue() const;
220 double minYValue() const;
221 double maxYValue() const;
222
223 void setCurveAttribute( CurveAttribute, bool on = true );
224 bool testCurveAttribute( CurveAttribute ) const;
225
226 void setPen( const QPen & );
227 const QPen &pen() const;
228
229 void setBrush( const QBrush & );
230 const QBrush &brush() const;
231
232 void setBaseline( double ref );
233 double baseline() const;
234
235 void setStyle( CurveStyle style );
236 CurveStyle style() const;
237
238 void setSymbol( const QwtSymbol *s );
239 const QwtSymbol *symbol() const;
240
241 void setCurveFitter( QwtCurveFitter * );
242 QwtCurveFitter *curveFitter() const;
243
244 virtual void drawSeries( QPainter *,
245 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
246 const QRectF &canvasRect, int from, int to ) const;
247
248 virtual void updateLegend( QwtLegend * ) const;
249 virtual void drawLegendIdentifier( QPainter *, const QRectF & ) const;
250
251 protected:
252
253 void init();
254
255 virtual void drawCurve( QPainter *, int style,
256 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
257 const QRectF &canvasRect, int from, int to ) const;
258
259 virtual void drawSymbols( QPainter *, const QwtSymbol &,
260 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
261 const QRectF &canvasRect, int from, int to ) const;
262
263 void drawLines( QPainter *,
264 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
265 const QRectF &canvasRect, int from, int to ) const;
266
267 void drawSticks( QPainter *,
268 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
269 const QRectF &canvasRect, int from, int to ) const;
270
271 void drawDots( QPainter *,
272 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
273 const QRectF &canvasRect, int from, int to ) const;
274
275 void drawSteps( QPainter *,
276 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
277 const QRectF &canvasRect, int from, int to ) const;
278
279 virtual void fillCurve( QPainter *,
280 const QwtScaleMap &, const QwtScaleMap &,
281 const QRectF &canvasRect, QPolygonF & ) const;
282
283 void closePolyline( QPainter *,
284 const QwtScaleMap &, const QwtScaleMap &, QPolygonF & ) const;
285
286 private:
287 class PrivateData;
288 PrivateData *d_data;
289 };
290
292 inline double QwtPlotCurve::minXValue() const
293 {
294 return boundingRect().left();
295 }
296
298 inline double QwtPlotCurve::maxXValue() const
299 {
300 return boundingRect().right();
301 }
302
304 inline double QwtPlotCurve::minYValue() const
305 {
306 return boundingRect().top();
307 }
308
310 inline double QwtPlotCurve::maxYValue() const
311 {
312 return boundingRect().bottom();
313 }
314
315 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::PaintAttributes )
316 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::LegendAttributes )
317 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::CurveAttributes )
318
319 #endif