#include <qwt_series_data.h>
Public Member Functions | |
QwtSyntheticPointData (size_t size, const QwtDoubleInterval &=QwtDoubleInterval()) | |
void | setSize (size_t size) |
size_t | size () const |
void | setInterval (const QwtDoubleInterval &) |
QwtDoubleInterval | interval () const |
virtual QwtDoubleRect | boundingRect () const |
virtual QwtDoublePoint | sample (size_t i) const |
virtual double | y (double x) const =0 |
virtual double | x (uint index) const |
virtual void | setRectOfInterest (const QwtDoubleRect &) |
QwtDoubleRect | rectOfInterest () const |
QwtSyntheticPointData provides a fixed number of points in an interval. The points are calculated in equidistant steps in x-direction.
If the interval is invalid, the points are calculated for the "rect of interest", what normally is the displayed area on the plot canvas. In this mode you get different level of details, when zooming in/out.
#include <cmath> #include <qwt_series_data.h> #include <qwt_plot_curve.h> #include <qwt_plot.h> #include <qapplication.h> class SinusData: public QwtSyntheticPointData { public: SinusData(): QwtSyntheticPointData(100) { } virtual QwtSeriesData<QwtDoublePoint> *copy() const { return new SinusData(); } virtual double y(double x) const { return std::sin(x); } }; int main(int argc, char **argv) { QApplication a(argc, argv); QwtPlot plot; plot.setAxisScale(QwtPlot::xBottom, 0.0, 10.0); plot.setAxisScale(QwtPlot::yLeft, -1.0, 1.0); QwtPlotCurve *curve = new QwtPlotCurve("y = sin(x)"); curve->setData(SinusData()); curve->attach(&plot); plot.show(); return a.exec(); }
QwtSyntheticPointData::QwtSyntheticPointData | ( | size_t | size, | |
const QwtDoubleInterval & | interval = QwtDoubleInterval() | |||
) |
Constructor
size | Number of points | |
interval | Bounding interval for the points |
QwtDoubleRect QwtSyntheticPointData::boundingRect | ( | ) | const [virtual] |
Calculate the bounding rect.
This implementation iterates over all points.
Implements QwtSeriesData< QwtDoublePoint >.
QwtDoubleInterval QwtSyntheticPointData::interval | ( | ) | const |
QwtDoubleRect QwtSyntheticPointData::rectOfInterest | ( | ) | const |
QwtDoublePoint QwtSyntheticPointData::sample | ( | size_t | index | ) | const [virtual] |
Calculate the point from an index
index | Index |
Implements QwtSeriesData< QwtDoublePoint >.
void QwtSyntheticPointData::setInterval | ( | const QwtDoubleInterval & | interval | ) |
void QwtSyntheticPointData::setRectOfInterest | ( | const QwtDoubleRect & | rect | ) | [virtual] |
Set a the "rect of interest"
QwtPlotSeriesItem defines the current area of the plot canvas as "rect of interest" ( QwtPlotSeriesItem::updateScaleDiv() ).
If interval().isValid() == false the x values are calculated in the interval rect.left() -> rect.right().
Reimplemented from QwtSeriesData< QwtDoublePoint >.
void QwtSyntheticPointData::setSize | ( | size_t | size | ) |
size_t QwtSyntheticPointData::size | ( | ) | const [virtual] |
double QwtSyntheticPointData::x | ( | uint | index | ) | const [virtual] |
Calculate a x-value from an index
x values are calculated by deviding an interval into equidistant steps. If !interval().isValid() the interval is calculated from the "rect of interest".
virtual double QwtSyntheticPointData::y | ( | double | x | ) | const [pure virtual] |
Calculate a y value for a x value
x | x value |