Public Member Functions | Private Attributes | List of all members
QwtSyntheticPointData Class Referenceabstract

Synthetic point data. More...

#include <qwt_point_data.h>

Inheritance diagram for QwtSyntheticPointData:
Inheritance graph
[legend]

Public Member Functions

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

Private Attributes

QwtInterval m_interval
 
QwtInterval m_intervalOfInterest
 
QRectF m_rectOfInterest
 
size_t m_size
 

Additional Inherited Members

- Protected Attributes inherited from QwtSeriesData< QPointF >
QRectF cachedBoundingRect
 Can be used to cache a calculated bounding rectangle. More...
 

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_plot_curve.h>
#include <qwt_plot.h>
#include <qapplication.h>
class SinusData: public QwtSyntheticPointData
{
public:
SinusData():
{
}
virtual double y( double x ) const
{
return qSin( x );
}
};
int main(int argc, char **argv)
{
QApplication a( argc, argv );
QwtPlot plot;
plot.setAxisScale( QwtAxis::XBottom, 0.0, 10.0 );
plot.setAxisScale( QwtAxis::YLeft, -1.0, 1.0 );
QwtPlotCurve *curve = new QwtPlotCurve( "y = sin(x)" );
curve->setData( new SinusData() );
curve->attach( &plot );
plot.show();
return a.exec();
}

Definition at line 157 of file qwt_point_data.h.

Constructor & Destructor Documentation

◆ QwtSyntheticPointData()

QwtSyntheticPointData::QwtSyntheticPointData ( size_t  size,
const QwtInterval interval = QwtInterval() 
)

Constructor

Parameters
sizeNumber of points
intervalBounding interval for the points
See also
setInterval(), setSize()

Definition at line 20 of file qwt_point_data.cpp.

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

Definition at line 105 of file qwt_point_data.cpp.

◆ interval()

QwtInterval QwtSyntheticPointData::interval ( ) const
Returns
Bounding interval
See also
setInterval(), size()

Definition at line 62 of file qwt_point_data.cpp.

◆ rectOfInterest()

QRectF QwtSyntheticPointData::rectOfInterest ( ) const
Returns
"rectangle of interest"
See also
setRectOfInterest()

Definition at line 89 of file qwt_point_data.cpp.

◆ sample()

QPointF QwtSyntheticPointData::sample ( size_t  index) const
virtual

Calculate the point from an index

Parameters
indexIndex
Returns
QPointF(x(index), y(x(index)));
Warning
For invalid indices ( index < 0 || index >= size() ) (0, 0) is returned.

Implements QwtSeriesData< QPointF >.

Definition at line 125 of file qwt_point_data.cpp.

◆ setInterval()

void QwtSyntheticPointData::setInterval ( const QwtInterval interval)

Set the bounding interval

Parameters
intervalInterval
See also
interval(), setSize()

Definition at line 53 of file qwt_point_data.cpp.

◆ 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 >.

Definition at line 78 of file qwt_point_data.cpp.

◆ setSize()

void QwtSyntheticPointData::setSize ( size_t  size)

Change the number of points

Parameters
sizeNumber of points
See also
size(), setInterval()

Definition at line 33 of file qwt_point_data.cpp.

◆ size()

size_t QwtSyntheticPointData::size ( ) const
virtual
Returns
Number of points
See also
setSize(), interval()

Definition at line 42 of file qwt_point_data.cpp.

◆ 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
indexIndex of the requested point
Returns
Calculated x coordinate
See also
interval(), rectOfInterest(), y()

Definition at line 148 of file qwt_point_data.cpp.

◆ y()

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

Calculate a y value for a x value

Parameters
xx value
Returns
Corresponding y value

Member Data Documentation

◆ m_interval

QwtInterval QwtSyntheticPointData::m_interval
private

Definition at line 186 of file qwt_point_data.h.

◆ m_intervalOfInterest

QwtInterval QwtSyntheticPointData::m_intervalOfInterest
private

Definition at line 188 of file qwt_point_data.h.

◆ m_rectOfInterest

QRectF QwtSyntheticPointData::m_rectOfInterest
private

Definition at line 187 of file qwt_point_data.h.

◆ m_size

size_t QwtSyntheticPointData::m_size
private

Definition at line 185 of file qwt_point_data.h.


The documentation for this class was generated from the following files:
QwtPlot
A 2-D plotting widget.
Definition: qwt_plot.h:78
QwtPlot::setAxisScale
void setAxisScale(QwtAxisId, double min, double max, double stepSize=0)
Disable autoscaling and specify a fixed scale for a selected axis.
Definition: qwt_plot_axis.cpp:477
QwtSeriesStore::setData
void setData(QwtSeriesData< T > *series)
Definition: qwt_series_store.h:164
QwtAxis::YLeft
@ YLeft
Y axis left of the canvas.
Definition: qwt_axis.h:38
QwtSyntheticPointData::y
virtual double y(double x) const =0
QwtSyntheticPointData::x
virtual double x(uint index) const
Definition: qwt_point_data.cpp:148
QwtSyntheticPointData
Synthetic point data.
Definition: qwt_point_data.h:157
qwt_plot_curve.h
main
int main(int argc, char **argv)
Definition: lua.c:643
QwtPlotItem::attach
void attach(QwtPlot *plot)
Attach the item to a plot.
Definition: qwt_plot_item.cpp:98
QwtPlotCurve
A plot item, that represents a series of points.
Definition: qwt_plot_curve.h:56
qwt_plot.h
qwt_series_data.h
QwtAxis::XBottom
@ XBottom
X axis below the canvas.
Definition: qwt_axis.h:44


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:51