QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
Public 成员函数 | 所有成员列表
QwtSyntheticPointData类 参考abstract

Synthetic point data 更多...

#include <qwt_point_data.h>

类 QwtSyntheticPointData 继承关系图:
QwtPointSeriesData QwtArraySeriesData< QPointF > QwtSeriesData< T >

Public 成员函数

 QwtSyntheticPointData (size_t size, const QwtInterval &=QwtInterval())
 Constructor
 
void setSize (size_t size)
 Change the number of points
 
virtual size_t size () const override
 Get the number of points
 
void setInterval (const QwtInterval &)
 Set the bounding interval
 
QwtInterval interval () const
 Get the bounding interval
 
virtual QRectF boundingRect () const override
 Calculate the bounding rectangle
 
virtual QPointF sample (size_t index) const override
 Calculate the point from an index
 
virtual double y (double x) const =0
 
virtual double x (size_t index) const
 Calculate a x-value from an index
 
virtual void setRectOfInterest (const QRectF &) override
 Set the "rectangle of interest"
 
QRectF rectOfInterest () const
 Get the "rectangle of interest"
 
- Public 成员函数 继承自 QwtPointSeriesData
 QwtPointSeriesData (const QVector< QPointF > &=QVector< QPointF >())
 Constructor
 
- Public 成员函数 继承自 QwtArraySeriesData< QPointF >
 QwtArraySeriesData ()
 Constructor
 
 QwtArraySeriesData (const QVector< QPointF > &samples)
 Constructor
 
 QwtArraySeriesData (QVector< QPointF > &&samples)
 
void setSamples (const QVector< QPointF > &samples)
 Assign an array of samples
 
void setSamples (QVector< QPointF > &&samples)
 
const QVector< QPointF > samples () const
 
- Public 成员函数 继承自 QwtSeriesData< T >
 QwtSeriesData ()
 Constructor
 
virtual ~QwtSeriesData ()
 Destructor
 

额外继承的成员函数

- Protected 属性 继承自 QwtArraySeriesData< QPointF >
QVector< QPointF > m_samples
 Vector of samples
 
- Protected 属性 继承自 QwtSeriesData< T >
QRectF cachedBoundingRect
 Can be used to cache a calculated bounding rectangle
 

详细描述

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():
{
}
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();
}
A plot item, that represents a series of points
Definition qwt_plot_curve.h:75
void attach(QwtPlot *plot) override
Attach the curve to a plot
Definition qwt_plot_curve.cpp:164
A 2-D plotting widget
Definition qwt_plot.h:99
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:558
Synthetic point data
Definition qwt_point_data.h:197
@ XBottom
X axis below the canvas
Definition qwt_axis.h:51
@ YLeft
Y axis left of the canvas
Definition qwt_axis.h:45

构造及析构函数说明

◆ QwtSyntheticPointData()

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

Constructor

参数
[in]sizeNumber of points
[in]intervalBounding interval for the points
参见
setInterval(), setSize()

成员函数说明

◆ boundingRect()

QRectF QwtSyntheticPointData::boundingRect ( ) const
overridevirtual

Calculate the bounding rectangle

This implementation iterates over all points, which 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).

返回
Bounding rectangle

重载 QwtPointSeriesData .

◆ interval()

QwtInterval QwtSyntheticPointData::interval ( ) const

Get the bounding interval

返回
Bounding interval
参见
setInterval(), size()

◆ rectOfInterest()

QRectF QwtSyntheticPointData::rectOfInterest ( ) const

Get the "rectangle of interest"

返回
Rectangle of interest
参见
setRectOfInterest()

◆ sample()

QPointF QwtSyntheticPointData::sample ( size_t  index) const
overridevirtual

Calculate the point from an index

参数
[in]indexIndex
返回
QPointF(x(index), y(x(index)))
警告
For invalid indices (index < 0 || index >= size()) (0, 0) is returned.

重载 QwtArraySeriesData< QPointF > .

◆ setInterval()

void QwtSyntheticPointData::setInterval ( const QwtInterval interval)

Set the bounding interval

参数
[in]intervalInterval
参见
interval(), setSize()

◆ setRectOfInterest()

void QwtSyntheticPointData::setRectOfInterest ( const QRectF &  rect)
overridevirtual

Set 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().

参数
[in]rectRectangle of interest
参见
rectOfInterest()

重载 QwtSeriesData< T > .

◆ setSize()

void QwtSyntheticPointData::setSize ( size_t  size)

Change the number of points

参数
[in]sizeNumber of points
参见
size(), setInterval()

◆ size()

size_t QwtSyntheticPointData::size ( ) const
overridevirtual

Get the number of points

返回
Number of points
参见
setSize(), interval()

重载 QwtArraySeriesData< QPointF > .

◆ x()

double QwtSyntheticPointData::x ( size_t  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".

参数
[in]indexIndex of the requested point
返回
Calculated x coordinate
参见
interval(), rectOfInterest(), y()

该类的文档由以下文件生成: