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

A helper class for translating a series of points 更多...

#include <qwt_point_mapper.h>

类

class  PrivateData
 

Public 类型

enum  TransformationFlag {
  RoundPoints = 0x01 , WeedOutPoints = 0x02 , WeedOutIntermediatePoints = 0x04 , PixelColumnReduce = 0x08 ,
  LTTBReduce = 0x20 , MinMaxReduce = 0x10 , AdaptiveColumnReduce = 0x40
}
 Flags affecting the transformation process 更多...
 

Public 成员函数

 QwtPointMapper ()
 Constructor
 
void setFlags (TransformationFlags)
 Set the flags affecting the transformation process
 
TransformationFlags flags () const
 Get the flags affecting the transformation process
 
void setFlag (TransformationFlag, bool on=true)
 Modify a flag affecting the transformation process
 
bool testFlag (TransformationFlag) const
 Test if a flag is set
 
void setBoundingRect (const QRectF &)
 Set a bounding rectangle for the point mapping algorithm
 
QRectF boundingRect () const
 Get the bounding rectangle
 
void setDevicePixelRatio (qreal ratio)
 Set the device pixel ratio of the target paint device
 
qreal devicePixelRatio () const
 Get the device pixel ratio of the target paint device
 
QPolygonF toPolygonF (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtSeriesData< QPointF > *series, int from, int to) const
 Translate a series of points into a QPolygonF
 
QPolygon toPolygon (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtSeriesData< QPointF > *series, int from, int to) const
 Translate a series of points into a QPolygon
 
QPolygon toPoints (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtSeriesData< QPointF > *series, int from, int to) const
 Translate a series of points into a QPolygon (scattered points)
 
QPolygonF toPointsF (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtSeriesData< QPointF > *series, int from, int to) const
 Translate a series into a QPolygonF (scattered points)
 
QImage toImage (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtSeriesData< QPointF > *series, int from, int to, const QPen &, bool antialiased, uint numThreads) const
 Translate a series into a QImage
 

详细描述

A helper class for translating a series of points

QwtPointMapper is a collection of methods and optimizations for translating a series of points into paint device coordinates. It is used by QwtPlotCurve but might also be useful for similar plot items displaying a QwtSeriesData<QPointF>.

成员枚举类型说明

◆ TransformationFlag

Flags affecting the transformation process

参见
setFlag(), setFlags()
枚举值
RoundPoints 

Round points to the device pixel grid ( see devicePixelRatio() )

WeedOutPoints 

Try to remove points, that are translated to the same position

WeedOutIntermediatePoints 

An even more aggressive weeding algorithm

An even more aggressive weeding algorithm, that can be used in toPolygon(). A consecutive chunk of points being mapped to the same x coordinate is reduced to 4 points:

  • first point
  • point with the minimum y coordinate
  • point with the maximum y coordinate
  • last point

In the worst case (first and last points are never one of the extremes) the number of points will be 4 times the width. As the algorithm is fast it can be used inside of a polyline render cycle.

PixelColumnReduce 

Pixel-column based downsampling

Allocates a bin array indexed by device pixel column ( see devicePixelRatio() ) and stores first/min/max/last Y per column. Output is at most 4 points per column. Requires a valid boundingRect() to determine the canvas width. Overrides WeedOutIntermediatePoints when both are set.

LTTBReduce 

Largest-Triangle-Three-Buckets (LTTB) downsampling

Divides the visible data into equal-count buckets and keeps the sample of each bucket, that forms the largest triangle with the previously selected point and the average of the next bucket. The first and last sample are always kept. Target bucket count is 4 * boundingRect() width in device pixels ( see devicePixelRatio() ), the output is at most one point per bucket. Overrides WeedOutIntermediatePoints when both are set.

MinMaxReduce 

MinMax bucket downsampling

Divides the visible data into equal-count buckets and keeps the min-Y and max-Y point from each bucket. Target bucket count is derived from boundingRect() width in device pixels ( see devicePixelRatio() ). Overrides WeedOutIntermediatePoints when both are set.

AdaptiveColumnReduce 

Adaptive column reduce downsampling

Single pass O(n) reduction combining a density gate with an ordered vertical tolerance selection, all pixel quantities in device pixels ( see devicePixelRatio() ):

  • When the visible samples are not denser than 2 points per device pixel column the data is mapped 1:1 without any reduction, so zooming in always restores full fidelity.
  • Otherwise the samples are clustered by device pixel column. Inside a cluster the first sample, every sample whose mapped y differs by at least 1 device pixel from the last kept sample and the last sample are kept - in their original order and at their real sub pixel coordinates. In contrast to the min/max envelope per column ( PixelColumnReduce ) ramps stay ramps instead of degenerating into a 1px staircase of vertical strokes and horizontal steps.
  • When this selection of a cluster would emit more than K = 4 + ( cluster y span in device pixels ) points ( high frequency noise inside one column ) the cluster falls back to an ordered first/min/max/last quadruple, so the output per column is bounded by K + 1 points.

The deviation from the original curve is bounded by 1 device pixel vertically and one column horizontally, visible features of at least 1 device pixel ( including in-column extrema and spikes ) are kept in sample order. For smooth data the output size is roughly the vertical pixel travel.

Overrides all other reduction flags when set.

构造及析构函数说明

◆ QwtPointMapper()

QwtPointMapper::QwtPointMapper ( )

Constructor

Creates a QwtPointMapper with default settings.

Destructor

Destroys the QwtPointMapper and frees all allocated resources.

成员函数说明

◆ boundingRect()

QRectF QwtPointMapper::boundingRect ( ) const

Get the bounding rectangle

返回
Bounding rectangle
参见
setBoundingRect()

◆ devicePixelRatio()

qreal QwtPointMapper::devicePixelRatio ( ) const

Get the device pixel ratio of the target paint device

返回
Device pixel ratio
参见
setDevicePixelRatio()

◆ flags()

QwtPointMapper::TransformationFlags QwtPointMapper::flags ( ) const

Get the flags affecting the transformation process

返回
Flags affecting the transformation process
参见
setFlags(), setFlag()

◆ setBoundingRect()

void QwtPointMapper::setBoundingRect ( const QRectF &  rect)

Set a bounding rectangle for the point mapping algorithm

A valid bounding rectangle can be used for optimizations.

参数
[in]rectBounding rectangle
参见
boundingRect()

◆ setDevicePixelRatio()

void QwtPointMapper::setDevicePixelRatio ( qreal  ratio)

Set the device pixel ratio of the target paint device

All pixel based reductions ( bucket counts, pixel columns ) and the rounding of RoundPoints are calculated in device pixels of the target paint device. On high DPI screens ( ratio > 1 ) this keeps the resolution of the reduction and the granularity of the rounding aligned with what the device can actually display. The mapped coordinates themselves remain in paint coordinates.

参数
[in]ratioDevice pixel ratio - values <= 0 are reset to 1.0
参见
devicePixelRatio(), QwtPainter::devicePixelRatio()

◆ setFlag()

void QwtPointMapper::setFlag ( TransformationFlag  flag,
bool  on = true 
)

Modify a flag affecting the transformation process

参数
[in]flagFlag type
[in]onValue
参见
testFlag(), setFlags()

◆ setFlags()

void QwtPointMapper::setFlags ( TransformationFlags  flags)

Set the flags affecting the transformation process

参数
[in]flagsFlags
参见
flags(), setFlag()

◆ testFlag()

bool QwtPointMapper::testFlag ( TransformationFlag  flag) const

Test if a flag is set

参数
[in]flagFlag type
返回
True when the flag is set
参见
setFlag(), setFlags()

◆ toImage()

QImage QwtPointMapper::toImage ( const QwtScaleMap &  xMap,
const QwtScaleMap &  yMap,
const QwtSeriesData< QPointF > *  series,
int  from,
int  to,
const QPen &  pen,
bool  antialiased,
uint  numThreads 
) const

Translate a series into a QImage

参数
[in]xMapx map
[in]yMapy map
[in]seriesSeries of points to be mapped
[in]fromIndex of the first point to be painted
[in]toIndex of the last point to be painted
[in]penPen used for drawing a point of the image, where a point is mapped to
[in]antialiasedTrue when the dots should be displayed antialiased
[in]numThreadsNumber of threads to be used for rendering. If numThreads is set to 0, the system specific ideal thread count is used.
返回
Image displaying the series

◆ toPoints()

QPolygon QwtPointMapper::toPoints ( const QwtScaleMap &  xMap,
const QwtScaleMap &  yMap,
const QwtSeriesData< QPointF > *  series,
int  from,
int  to 
) const

Translate a series of points into a QPolygon (scattered points)

  • WeedOutPoints & boundingRect().isValid(): All points that are mapped to the same position will be one point. Points outside of the bounding rectangle are ignored.
  • WeedOutPoints & !boundingRect().isValid(): All consecutive points that are mapped to the same position will one point.
  • !WeedOutPoints & boundingRect().isValid(): Points outside of the bounding rectangle are ignored.
参数
[in]xMapx map
[in]yMapy map
[in]seriesSeries of points to be mapped
[in]fromIndex of the first point to be painted
[in]toIndex of the last point to be painted
返回
Translated polygon

◆ toPointsF()

QPolygonF QwtPointMapper::toPointsF ( const QwtScaleMap &  xMap,
const QwtScaleMap &  yMap,
const QwtSeriesData< QPointF > *  series,
int  from,
int  to 
) const

Translate a series into a QPolygonF (scattered points)

  • WeedOutPoints & RoundPoints & boundingRect().isValid(): All points that are mapped to the same position will be one point. Points outside of the bounding rectangle are ignored.
  • WeedOutPoints & RoundPoints & !boundingRect().isValid(): All consecutive points that are mapped to the same position will one point.
  • WeedOutPoints & !RoundPoints: All consecutive points that are mapped to the same position will one point.
  • !WeedOutPoints & boundingRect().isValid(): Points outside of the bounding rectangle are ignored.

    When RoundPoints is set, all points are rounded to the device pixel grid ( see devicePixelRatio() ) but returned as PolygonF - what only makes sense when the further processing of the values need a QPolygonF.

参数
[in]xMapx map
[in]yMapy map
[in]seriesSeries of points to be mapped
[in]fromIndex of the first point to be painted
[in]toIndex of the last point to be painted
返回
Translated polygon

◆ toPolygon()

QPolygon QwtPointMapper::toPolygon ( const QwtScaleMap &  xMap,
const QwtScaleMap &  yMap,
const QwtSeriesData< QPointF > *  series,
int  from,
int  to 
) const

Translate a series of points into a QPolygon

When the WeedOutPoints flag is enabled, consecutive points that are mapped to the same position will be one point.

参数
[in]xMapx map
[in]yMapy map
[in]seriesSeries of points to be mapped
[in]fromIndex of the first point to be painted
[in]toIndex of the last point to be painted
返回
Translated polygon

◆ toPolygonF()

QPolygonF QwtPointMapper::toPolygonF ( const QwtScaleMap &  xMap,
const QwtScaleMap &  yMap,
const QwtSeriesData< QPointF > *  series,
int  from,
int  to 
) const

Translate a series of points into a QPolygonF

When the WeedOutPoints flag is enabled, consecutive points that are mapped to the same position will be one point. When RoundPoints is set, all points are rounded to the device pixel grid ( see devicePixelRatio() ) but returned as PolygonF - what only makes sense when the further processing of the values need a QPolygonF. When WeedOutIntermediatePoints is enabled, an even more aggressive weeding algorithm is enabled. It rounds to device pixels on its own and does not require RoundPoints to be set.

参数
[in]xMapx map
[in]yMapy map
[in]seriesSeries of points to be mapped
[in]fromIndex of the first point to be painted
[in]toIndex of the last point to be painted
返回
Translated polygon

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