Qwt User's Guide: qwt_plot_curve.h Source File

Qwt User's Guide 5.2.3

- 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 <qpen.h>
14 #include <qstring.h>
15 #include "qwt_global.h"
16 #include "qwt_plot_item.h"
17 #include "qwt_text.h"
18 #include "qwt_polygon.h"
19 #include "qwt_data.h"
20
21 class QPainter;
22 class QwtScaleMap;
23 class QwtSymbol;
24 class QwtCurveFitter;
25
54 class QWT_EXPORT QwtPlotCurve: public QwtPlotItem
55 {
56 public:
73 enum CurveType
74 {
75 Yfx,
76 Xfy
77 };
78
106 enum CurveStyle
107 {
108 NoCurve,
109
110 Lines,
111 Sticks,
112 Steps,
113 Dots,
114
115 UserCurve = 100
116 };
117
134 enum CurveAttribute
135 {
136 Inverted = 1,
137 Fitted = 2
138 };
139
158 enum PaintAttribute
159 {
160 PaintFiltered = 1,
161 ClipPolygons = 2
162 };
163
164 explicit QwtPlotCurve();
165 explicit QwtPlotCurve(const QwtText &title);
166 explicit QwtPlotCurve(const QString &title);
167
168 virtual ~QwtPlotCurve();
169
170 virtual int rtti() const;
171
172 void setCurveType(CurveType);
173 CurveType curveType() const;
174
175 void setPaintAttribute(PaintAttribute, bool on = true);
176 bool testPaintAttribute(PaintAttribute) const;
177
178 void setRawData(const double *x, const double *y, int size);
179 void setData(const double *xData, const double *yData, int size);
180 void setData(const QwtArray<double> &xData, const QwtArray<double> &yData);
181 #if QT_VERSION < 0x040000
182 void setData(const QwtArray<QwtDoublePoint> &data);
183 #else
184 void setData(const QPolygonF &data);
185 #endif
186 void setData(const QwtData &data);
187
188 int closestPoint(const QPoint &pos, double *dist = NULL) const;
189
190 QwtData &data();
191 const QwtData &data() const;
192
193 int dataSize() const;
194 double x(int i) const;
195 double y(int i) const;
196
197 virtual QwtDoubleRect boundingRect() const;
198
199 double minXValue() const;
200 double maxXValue() const;
201 double minYValue() const;
202 double maxYValue() const;
203
204 void setCurveAttribute(CurveAttribute, bool on = true);
205 bool testCurveAttribute(CurveAttribute) const;
206
207 void setPen(const QPen &);
208 const QPen &pen() const;
209
210 void setBrush(const QBrush &);
211 const QBrush &brush() const;
212
213 void setBaseline(double ref);
214 double baseline() const;
215
216 void setStyle(CurveStyle style);
217 CurveStyle style() const;
218
219 void setSymbol(const QwtSymbol &s);
220 const QwtSymbol& symbol() const;
221
222 void setCurveFitter(QwtCurveFitter *);
223 QwtCurveFitter *curveFitter() const;
224
225 virtual void draw(QPainter *p,
226 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
227 const QRect &) const;
228
229 virtual void draw(QPainter *p,
230 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
231 int from, int to) const;
232
233 void draw(int from, int to) const;
234
235 virtual void updateLegend(QwtLegend *) const;
236
237 protected:
238
239 void init();
240
241 virtual void drawCurve(QPainter *p, int style,
242 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
243 int from, int to) const;
244
245 virtual void drawSymbols(QPainter *p, const QwtSymbol &,
246 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
247 int from, int to) const;
248
249 void drawLines(QPainter *p,
250 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
251 int from, int to) const;
252 void drawSticks(QPainter *p,
253 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
254 int from, int to) const;
255 void drawDots(QPainter *p,
256 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
257 int from, int to) const;
258 void drawSteps(QPainter *p,
259 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
260 int from, int to) const;
261
262 void fillCurve(QPainter *,
263 const QwtScaleMap &, const QwtScaleMap &,
264 QwtPolygon &) const;
265 void closePolyline(const QwtScaleMap &, const QwtScaleMap &,
266 QwtPolygon &) const;
267
268 private:
269 QwtData *d_xy;
270
271 class PrivateData;
272 PrivateData *d_data;
273 };
274
276 inline QwtData &QwtPlotCurve::data()
277 {
278 return *d_xy;
279 }
280
282 inline const QwtData &QwtPlotCurve::data() const
283 {
284 return *d_xy;
285 }
286
291 inline double QwtPlotCurve::x(int i) const
292 {
293 return d_xy->x(i);
294 }
295
300 inline double QwtPlotCurve::y(int i) const
301 {
302 return d_xy->y(i);
303 }
304
306 inline double QwtPlotCurve::minXValue() const
307 {
308 return boundingRect().left();
309 }
310
312 inline double QwtPlotCurve::maxXValue() const
313 {
314 return boundingRect().right();
315 }
316
318 inline double QwtPlotCurve::minYValue() const
319 {
320 return boundingRect().top();
321 }
322
324 inline double QwtPlotCurve::maxYValue() const
325 {
326 return boundingRect().bottom();
327 }
328
329 #endif