1
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
3
* Copyright (C) 1997 Josef Wilgen
4
* Copyright (C) 2002 Uwe Rathmann
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
*****************************************************************************/
10
#ifndef QWT_PLOT_CURVE_H
11
#define QWT_PLOT_CURVE_H
15
#include "qwt_global.h"
16
#include "qwt_plot_item.h"
18
#include "qwt_polygon.h"
27
\brief A class which draws curves
29
This class can be used to display data as a curve in the x-y plane.
30
It supports different display styles, spline interpolation and symbols.
33
<dl><dt>A. Assign curve properties</dt>
34
<dd>When a curve is created, it is configured to draw black solid lines
35
with QwtPlotCurve::Lines and no symbols. You can change this by calling
36
setPen(), setStyle() and setSymbol().</dd>
37
<dt>B. Assign or change data.</dt>
38
<dd>Data can be set in two ways:<ul>
39
<li>setData() is overloaded to initialize the x and y data by
40
copying from different data structures with different kind of copy semantics.
41
<li>setRawData() only stores the pointers and size information
42
and is provided for backwards compatibility. This function is less safe (you
43
must not delete the data while they are attached), but has been more
44
efficient, and has been more convenient for dynamically changing data.
45
Use of setData() in combination with a problem-specific subclass
46
of QwtData is always preferrable.</ul></dd>
48
<dd>draw() maps the data into pixel coordinates and paints them.
54
\sa QwtData, QwtSymbol, QwtScaleMap
56
class QWT_EXPORT QwtPlotCurve: public QwtPlotItem
83
\sa setCurveAttribute, testCurveAttribute
93
\sa setPaintAttribute, testPaintAttribute
101
explicit QwtPlotCurve();
102
explicit QwtPlotCurve(const QwtText &title);
103
explicit QwtPlotCurve(const QString &title);
105
virtual ~QwtPlotCurve();
107
virtual int rtti() const;
109
void setCurveType(CurveType);
110
CurveType curveType() const;
112
void setPaintAttribute(PaintAttribute, bool on = true);
113
bool testPaintAttribute(PaintAttribute) const;
115
void setRawData(const double *x, const double *y, int size);
116
void setData(const double *xData, const double *yData, int size);
117
void setData(const QwtArray<double> &xData, const QwtArray<double> &yData);
118
#if QT_VERSION < 0x040000
119
void setData(const QwtArray<QwtDoublePoint> &data);
121
void setData(const QPolygonF &data);
123
void setData(const QwtData &data);
125
int closestPoint(const QPoint &pos, double *dist = NULL) const;
128
const QwtData &data() const;
130
int dataSize() const;
131
inline double x(int i) const;
132
inline double y(int i) const;
134
virtual QwtDoubleRect boundingRect() const;
136
//! boundingRect().left()
137
inline double minXValue() const { return boundingRect().left(); }
138
//! boundingRect().right()
139
inline double maxXValue() const { return boundingRect().right(); }
140
//! boundingRect().top()
141
inline double minYValue() const { return boundingRect().top(); }
142
//! boundingRect().bottom()
143
inline double maxYValue() const { return boundingRect().bottom(); }
145
void setCurveAttribute(CurveAttribute, bool on = true);
146
bool testCurveAttribute(CurveAttribute) const;
148
void setPen(const QPen &);
149
const QPen &pen() const;
151
void setBrush(const QBrush &);
152
const QBrush &brush() const;
154
void setBaseline(double ref);
155
double baseline() const;
157
void setStyle(CurveStyle style);
158
CurveStyle style() const;
160
void setSymbol(const QwtSymbol &s);
161
const QwtSymbol& symbol() const;
163
void setCurveFitter(QwtCurveFitter *);
164
QwtCurveFitter *curveFitter() const;
166
virtual void draw(QPainter *p,
167
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
168
const QRect &) const;
170
virtual void draw(QPainter *p,
171
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
172
int from, int to) const;
174
void draw(int from, int to) const;
176
virtual void updateLegend(QwtLegend *) const;
182
virtual void drawCurve(QPainter *p, int style,
183
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
184
int from, int to) const;
186
virtual void drawSymbols(QPainter *p, const QwtSymbol &,
187
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
188
int from, int to) const;
190
void drawLines(QPainter *p,
191
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
192
int from, int to) const;
193
void drawSticks(QPainter *p,
194
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
195
int from, int to) const;
196
void drawDots(QPainter *p,
197
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
198
int from, int to) const;
199
void drawSteps(QPainter *p,
200
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
201
int from, int to) const;
203
void fillCurve(QPainter *,
204
const QwtScaleMap &, const QwtScaleMap &,
206
void closePolyline(const QwtScaleMap &, const QwtScaleMap &,
216
//! \return the the curve data
217
inline QwtData &QwtPlotCurve::data()
222
//! \return the the curve data
223
inline const QwtData &QwtPlotCurve::data() const
230
\return x-value at position i
232
inline double QwtPlotCurve::x(int i) const
239
\return y-value at position i
241
inline double QwtPlotCurve::y(int i) const