Qwt User's Guide: QwtSyntheticPointData Class Reference

Qwt User's Guide 6.1.6

Public Member Functions | List of all members
QwtSyntheticPointData Class Referenceabstract

Synthetic point data. More...

`#include <qwt_point_data.h>`

Inheritance diagram for QwtSyntheticPointData:
[legend]

## Public Member Functions
| QwtSyntheticPointData (size_t size, const QwtInterval &=QwtInterval())
void | setSize (size_t size)
virtual size_t | size () const
void | setInterval (const QwtInterval &)
QwtInterval | interval () const
virtual QRectF | boundingRect () const
| Calculate the bounding rectangle. More...
virtual QPointF | sample (size_t index) const
virtual double | y (double x) const =0
virtual double | x (uint index) const
virtual void | setRectOfInterest (const QRectF &)
QRectF | rectOfInterest () const
Public Member Functions inherited from QwtSeriesData< QPointF >
| QwtSeriesData ()
| Constructor.
virtual | ~QwtSeriesData ()
| Destructor.
virtual size_t | size () const=0
virtual QRectF | boundingRect () const=0

## Additional Inherited Members
Protected Attributes inherited from QwtSeriesData< QPointF >
QRectF | d_boundingRect
| Can be used to cache a calculated bounding rectangle.

## Detailed Description

Synthetic point data.

QwtSyntheticPointData provides a fixed number of points for an interval. The points are calculated in equidistant steps in x-direction.

If the interval is invalid, the points are calculated for the "rectangle of interest", what normally is the displayed area on the plot canvas. In this mode you get different levels of detail, when zooming in/out.

Example

The following example shows how to implement a sinus curve.

#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 double y( double x ) const
{
return qSin( 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( new SinusData() );
curve->attach( &plot );
plot.show();
return a.exec();
}

## Constructor & Destructor Documentation

## ◆ QwtSyntheticPointData()

QwtSyntheticPointData::QwtSyntheticPointData | ( | size_t | size,
|  | const QwtInterval & | interval = `QwtInterval()`
| ) |  |

Constructor

Parameters

  size | Number of points
  interval | Bounding interval for the points

See also
  setInterval(), setSize()

## Member Function Documentation

## ◆ boundingRect()

QRectF QwtSyntheticPointData::boundingRect | ( |  | ) | const
| virtual

Calculate the bounding rectangle.

This implementation iterates over all points, what could often be implemented much faster using the characteristics of the series. When there are many points it is recommended to overload and reimplement this method using the characteristics of the series ( if possible ).

Returns
  Bounding rectangle

## ◆ interval()

QwtInterval QwtSyntheticPointData::interval | ( |  | ) | const

Returns
  Bounding interval

See also
  setInterval(), size()

## ◆ rectOfInterest()

QRectF QwtSyntheticPointData::rectOfInterest | ( |  | ) | const

Returns
  "rectangle of interest"

See also
  setRectOfInterest()

## ◆ sample()

QPointF QwtSyntheticPointData::sample | ( | size_t | index | ) | const
| virtual

Calculate the point from an index

Parameters

  index | Index

Returns
  QPointF(x(index), y(x(index)));

Warning
  For invalid indices ( index < 0 || index >= size() ) (0, 0) is returned.

Implements QwtSeriesData< QPointF >.

## ◆ setInterval()

void QwtSyntheticPointData::setInterval | ( | const QwtInterval & | interval | ) |

Set the bounding interval

Parameters

  interval | Interval

See also
  interval(), setSize()

## ◆ setRectOfInterest()

void QwtSyntheticPointData::setRectOfInterest | ( | const QRectF & | rect | ) |
| virtual

Set a the "rectangle 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().

See also
  rectOfInterest()

Reimplemented from QwtSeriesData< QPointF >.

## ◆ setSize()

void QwtSyntheticPointData::setSize | ( | size_t | size | ) |

Change the number of points

Parameters

  size | Number of points

See also
  size(), setInterval()

## ◆ size()

size_t QwtSyntheticPointData::size | ( |  | ) | const
| virtual

Returns
  Number of points

See also
  setSize(), interval()

## ◆ x()

double QwtSyntheticPointData::x | ( | uint | index | ) | const
| virtual

Calculate a x-value from an index

x values are calculated by dividing an interval into equidistant steps. If !interval().isValid() the interval is calculated from the "rectangle of interest".

Parameters

  index | Index of the requested point

Returns
  Calculated x coordinate

See also
  interval(), rectOfInterest(), y()

## ◆ y()

virtual double QwtSyntheticPointData::y | ( | double | x | ) | const
| pure virtual

Calculate a y value for a x value

Parameters

  x | x value

Returns
  Corresponding y value

QwtPlot
A 2-D plotting widget.
Definition: qwt_plot.h:76
QwtSyntheticPointData
Synthetic point data.
Definition: qwt_point_data.h:113
QwtPlot::yLeft
@ yLeft
Y axis left of the canvas.
Definition: qwt_plot.h:97
QwtPlot::setAxisScale
void setAxisScale(int axisId, double min, double max, double stepSize=0)
Disable autoscaling and specify a fixed scale for a selected axis.
Definition: qwt_plot_axis.cpp:447
QwtSeriesStore::setData
void setData(QwtSeriesData< T > *series)
Definition: qwt_series_store.h:163
QwtSyntheticPointData::x
virtual double x(uint index) const
Definition: qwt_point_data.cpp:294
QwtPlot::xBottom
@ xBottom
X axis below the canvas.
Definition: qwt_plot.h:103
QwtPlotItem::attach
void attach(QwtPlot *plot)
Attach the item to a plot.
Definition: qwt_plot_item.cpp:82
QwtPlotCurve
A plot item, that represents a series of points.
Definition: qwt_plot_curve.h:57
QwtSyntheticPointData::y
virtual double y(double x) const =0