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

A plot item, that represents a series of points 更多...

#include <qwt_plot_curve.h>

类 QwtPlotCurve 继承关系图:
QwtPlotSeriesItem QwtSeriesStore< QPointF > QwtPlotItem QwtAbstractSeriesStore QwtAbstractSeriesStore

类

class  PrivateData
 

Public 类型

enum  CurveStyle {
  NoCurve = -1 , Lines , Sticks , Steps ,
  Dots , UserCurve = 100
}
 Curve styles 更多...
 
enum  CurveAttribute { Inverted = 0x01 , Fitted = 0x02 , BreakAtNan = 0x04 }
 Attribute for drawing the curve 更多...
 
enum  LegendAttribute { LegendNoAttribute = 0x00 , LegendShowLine = 0x01 , LegendShowSymbol = 0x02 , LegendShowBrush = 0x04 }
 Attributes how to represent the curve on the legend 更多...
 
enum  PaintAttribute {
  ClipPolygons = 0x01 , FilterPoints = 0x02 , MinimizeMemory = 0x04 , ImageBuffer = 0x08 ,
  FilterPointsAggressive = 0x10 , FilterPointsPixel = 0x20 , FilterPointsLTTB = 0x40 , FilterPointsMinMaxLTTB = 0x80 ,
  FilterPointsAdaptive = 0x100
}
 Attributes to modify the drawing algorithm 更多...
 
enum  SmoothAlgorithm { NoSmoothing = 0 , GaussianSmoothing , SavitzkyGolaySmoothing }
 Algorithm for smoothing the rendered polyline 更多...
 
- Public 类型 继承自 QwtPlotItem
enum  RttiValues {
  Rtti_PlotItem = 0 , Rtti_PlotGrid , Rtti_PlotScale , Rtti_PlotLegend ,
  Rtti_PlotMarker , Rtti_PlotCurve , Rtti_PlotSpectroCurve , Rtti_PlotIntervalCurve ,
  Rtti_PlotHistogram , Rtti_PlotSpectrogram , Rtti_PlotGraphic , Rtti_PlotTradingCurve ,
  Rtti_PlotBarChart , Rtti_PlotMultiBarChart , Rtti_PlotShape , Rtti_PlotTextLabel ,
  Rtti_PlotZone , Rtti_PlotVectorField , Rtti_PlotArrowMarker , Rtti_PlotBoxChart ,
  Rtti_PlotUserItem = 1000
}
 Runtime type information 更多...
 
enum  ItemAttribute { Legend = 0x01 , AutoScale = 0x02 , Margins = 0x04 }
 Plot Item Attributes 更多...
 
enum  ItemInterest { ScaleInterest = 0x01 , LegendInterest = 0x02 }
 Plot Item Interests 更多...
 
enum  RenderHint { RenderAntialiased = 0x1 }
 Render hints 更多...
 

Public 成员函数

 QwtPlotCurve (const QString &title=QString())
 
 QwtPlotCurve (const QwtText &title)
 Constructor with QwtText title
 
virtual int rtti () const override
 Get the runtime type information
 
void attach (QwtPlot *plot) override
 Attach the curve to a plot
 
void setPaintAttribute (PaintAttribute, bool on=true)
 Set paint attribute
 
bool testPaintAttribute (PaintAttribute) const
 Test paint attribute
 
void setLegendAttribute (LegendAttribute, bool on=true)
 Set legend attribute
 
bool testLegendAttribute (LegendAttribute) const
 Test legend attribute
 
void setLegendAttributes (LegendAttributes)
 Set legend attributes
 
LegendAttributes legendAttributes () const
 Get legend attributes
 
void setRawSamples (const double *xData, const double *yData, int size)
 Initialize data by pointing to memory blocks not managed by QwtPlotCurve (double)
 
void setRawSamples (const float *xData, const float *yData, int size)
 Initialize data by pointing to memory blocks not managed by QwtPlotCurve (float)
 
void setRawSamples (const double *yData, int size)
 Initialize data by pointing to a memory block not managed by QwtPlotCurve (double, y-axis only)
 
void setRawSamples (const float *yData, int size)
 Initialize data by pointing to a memory block not managed by QwtPlotCurve (float, y-axis only)
 
void setSamples (const double *xData, const double *yData, int size)
 Set data by copying x- and y-values from specified memory blocks (double)
 
void setSamples (const float *xData, const float *yData, int size)
 Set data by copying x- and y-values from specified memory blocks (float)
 
void setSamples (const double *yData, int size)
 Set data by copying y-values from a specified memory block (double)
 
void setSamples (const float *yData, int size)
 Set data by copying y-values from a specified memory block (float)
 
void setSamples (const QVector< double > &yData)
 Initialize data with an array of y values (explicitly shared, double)
 
void setSamples (const QVector< float > &yData)
 Initialize data with an array of y values (explicitly shared, float)
 
void setSamples (const QVector< double > &xData, const QVector< double > &yData)
 Initialize data with x- and y-arrays (explicitly shared, double)
 
void setSamples (const QVector< float > &xData, const QVector< float > &yData)
 Initialize data with x- and y-arrays (explicitly shared, float)
 
void setSamples (QVector< double > &&xData, QVector< double > &&yData)
 Initialize data with x- and y-arrays (rvalue, double)
 
void setSamples (QVector< float > &&xData, QVector< float > &&yData)
 Initialize data with x- and y-arrays (rvalue, float)
 
void setSamples (QVector< QPointF > &&)
 Initialize data with an array of points (rvalue)
 
void setSamples (const QVector< QPointF > &)
 Initialize data with an array of points
 
void setSamples (QwtSeriesData< QPointF > *)
 Assign a series of points
 
virtual int closestPoint (const QPointF &pos, double *dist=nullptr) const
 Find the closest curve point for a specific position
 
double minXValue () const
 boundingRect().left()
 
double maxXValue () const
 boundingRect().right()
 
double minYValue () const
 boundingRect().top()
 
double maxYValue () const
 boundingRect().bottom()
 
void setCurveAttribute (CurveAttribute, bool on=true)
 Set curve attribute
 
bool testCurveAttribute (CurveAttribute) const
 Test curve attribute
 
void setPen (const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
 Build and assign a pen
 
void setPen (const QPen &)
 Assign a pen
 
const QPen & pen () const
 Get the pen used to draw the lines
 
void setBrush (const QBrush &)
 Assign a brush
 
const QBrush & brush () const
 Get the brush used to fill the area between lines and the baseline
 
void setBaseline (double)
 Set the value of the baseline
 
double baseline () const
 Get the baseline value
 
void setStyle (CurveStyle style)
 Set the curve's drawing style
 
CurveStyle style () const
 Get the curve's drawing style
 
void setSymbol (QwtSymbol *)
 Assign a symbol
 
const QwtSymbol * symbol () const
 Get the current symbol
 
void setCurveFitter (QwtCurveFitter *)
 Assign a curve fitter
 
QwtCurveFitter * curveFitter () const
 Get the curve fitter
 
void setSmoothAlgorithm (SmoothAlgorithm)
 Set the render smoothing algorithm
 
SmoothAlgorithm smoothAlgorithm () const
 Get the render smoothing algorithm
 
void setSmoothWindow (int numPoints)
 Set the window of the render smoothing algorithms
 
int smoothWindow () const
 Get the window of the render smoothing algorithms
 
void setSmoothPolynomialOrder (int order)
 Set the polynomial order of SavitzkyGolaySmoothing
 
int smoothPolynomialOrder () const
 Get the polynomial order of SavitzkyGolaySmoothing
 
void setSmoothPreserveThreshold (double threshold)
 Set the feature preservation threshold of the render smoothing
 
double smoothPreserveThreshold () const
 Get the feature preservation threshold of the render smoothing
 
virtual void drawSeries (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const override
 Draw an interval of the curve
 
virtual QwtGraphic legendIcon (int index, const QSizeF &) const override
 Get the icon representing the curve on the legend
 
- Public 成员函数 继承自 QwtPlotSeriesItem
 QwtPlotSeriesItem (const QString &title=QString())
 
 QwtPlotSeriesItem (const QwtText &title)
 Constructor
 
void setOrientation (Qt::Orientation)
 Set the orientation of the item
 
Qt::Orientation orientation () const
 Get the orientation of the plot item
 
virtual void draw (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const override
 Draw the complete series
 
virtual QRectF boundingRect () const override
 Get the bounding rectangle
 
virtual void updateScaleDiv (const QwtScaleDiv &, const QwtScaleDiv &) override
 Update the scale divisions
 
- Public 成员函数 继承自 QwtPlotItem
 QwtPlotItem ()
 Default constructor
 
 QwtPlotItem (const QString &title)
 Constructor with title as QString
 
 QwtPlotItem (const QwtText &title)
 Constructor with title as QwtText
 
virtual ~QwtPlotItem ()
 Destructor
 
void detach ()
 Detach the item from the plot
 
QwtPlot * plot () const
 Get the plot the item is attached to
 
void setTitle (const QString &title)
 Set the title using a QString
 
void setTitle (const QwtText &title)
 Set the title using a QwtText
 
const QwtText & title () const
 Get the title
 
void setItemAttribute (ItemAttribute, bool on=true)
 Set an item attribute
 
bool testItemAttribute (ItemAttribute) const
 Test an item attribute
 
void setItemInterest (ItemInterest, bool on=true)
 Set an item interest
 
bool testItemInterest (ItemInterest) const
 Test an item interest
 
void setRenderHint (RenderHint, bool on=true)
 Set a render hint
 
bool testRenderHint (RenderHint) const
 Test a render hint
 
void setRenderThreadCount (uint numThreads)
 Set the number of render threads
 
uint renderThreadCount () const
 Get the number of render threads
 
void setLegendIconSize (const QSize &)
 Set the legend icon size
 
QSize legendIconSize () const
 Get the legend icon size
 
double z () const
 Get the z-value
 
void setZ (double z)
 Set the z-value
 
void show ()
 Show the item
 
void hide ()
 Hide the item
 
virtual void setVisible (bool)
 Set the visibility
 
bool isVisible () const
 Check if the item is visible
 
void setAxes (QwtAxisId xAxis, QwtAxisId yAxis)
 Set both axes
 
void setXAxis (QwtAxisId)
 Set the x-axis
 
QwtAxisId xAxis () const
 Get the x-axis
 
void setYAxis (QwtAxisId)
 Set the y-axis
 
QwtAxisId yAxis () const
 Get the y-axis
 
virtual void itemChanged ()
 Notify the plot that the item has changed
 
virtual void legendChanged ()
 Notify the item that the legend has changed
 
virtual void getCanvasMarginHint (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, double &left, double &top, double &right, double &bottom) const
 Get margin hints for the canvas
 
virtual void updateLegend (const QwtPlotItem *, const QList< QwtLegendData > &)
 Update the item with changes of the legend
 
QRectF scaleRect (const QwtScaleMap &, const QwtScaleMap &) const
 Calculate the scale rectangle
 
QRectF paintRect (const QwtScaleMap &, const QwtScaleMap &) const
 Calculate the paint rectangle
 
virtual QList< QwtLegendData > legendData () const
 Return legend data
 
- Public 成员函数 继承自 QwtSeriesStore< QPointF >
void setData (QwtSeriesData< QPointF > *series)
 
QwtSeriesData< QPointF > * data ()
 
const QwtSeriesData< QPointF > * data () const
 
QPointF sample (size_t index) const
 
virtual size_t dataSize () const override
 
virtual QRectF dataRect () const override
 
virtual void setRectOfInterest (const QRectF &rect) override
 Set a the "rectangle of interest" for the stored series
 
QwtSeriesData< QPointF > * swapData (QwtSeriesData< QPointF > *series)
 

Protected 成员函数

virtual void dataChanged () override
 Invalidate data dependent caches when the series has been changed
 
void init ()
 Initialize the curve
 
virtual void drawCurve (QPainter *, int style, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
 Draw the curve
 
virtual void drawSymbols (QPainter *, const QwtSymbol &, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
 Draw symbols
 
virtual void drawLines (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
 Draw lines
 
virtual void drawSticks (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
 Draw sticks
 
virtual void drawDots (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
 Draw dots
 
virtual void drawSteps (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
 Draw steps
 
virtual void fillCurve (QPainter *, const QwtScaleMap &, const QwtScaleMap &, const QRectF &canvasRect, QPolygonF &) const
 Fill the curve
 
void closePolyline (QPainter *, const QwtScaleMap &, const QwtScaleMap &, QPolygonF &) const
 Close the polyline
 
- Protected 成员函数 继承自 QwtPlotItem
QwtGraphic defaultIcon (const QBrush &, const QSizeF &) const
 Create a default icon
 

详细描述

A plot item, that represents a series of points

A curve is the representation of a series of points in the x-y plane. It supports different display styles, interpolation ( f.e. spline ) and symbols.

Usage
a) Assign curve properties
When a curve is created, it is configured to draw black solid lines with in QwtPlotCurve::Lines style and no symbols. You can change this by calling setPen(), setStyle() and setSymbol().
b) Connect/Assign data.
QwtPlotCurve gets its points using a QwtSeriesData object offering a bridge to the real storage of the points ( like QAbstractItemModel ). There are several convenience classes derived from QwtSeriesData, that also store the points inside ( like QStandardItemModel ). QwtPlotCurve also offers a couple of variations of setSamples(), that build QwtSeriesData objects from arrays internally.
c) Attach the curve to a plot
See QwtPlotItem::attach()
Example:
see examples/bode
参见
QwtPointSeriesData, QwtSymbol, QwtScaleMap

成员枚举类型说明

◆ CurveAttribute

Attribute for drawing the curve

参见
setCurveAttribute(), testCurveAttribute(), curveFitter()
枚举值
Inverted 

For QwtPlotCurve::Steps only. Draws a step function from the right to the left.

Fitted 

Only in combination with QwtPlotCurve::Lines A QwtCurveFitter tries to interpolate/smooth the curve, before it is painted.

注解
Curve fitting requires temporary memory for calculating coefficients and additional points. If painting in QwtPlotCurve::Fitted mode is slow it might be better to fit the points, before they are passed to QwtPlotCurve.
BreakAtNan 

For Lines and Steps style only. Samples with NaN/Inf coordinates mark gaps: instead of connecting the neighboring finite samples with a bridging line, every run of consecutive finite samples is rendered as an independent polyline and gaps stay blank.

Without this attribute gaps are bridged, what is the default behavior of all paint attribute filtering modes.

Each run is smoothed, fitted, clipped and filled on its own, so neither the smoothing kernel nor the fill area crosses a gap. Downsampling budgets also apply per run - short runs fall back to simpler filtering algorithms.

The Dots and Sticks styles are not affected, as they draw per sample and skip NaN/Inf samples anyway.

注解
The finite sample runs are cached and recomputed whenever the series data is set ( setSamples()/setData() ).

Example:

QwtPlotCurve* curve = new QwtPlotCurve();
curve->setSamples( x, y ); // y contains qQNaN() gaps
curve->attach( plot );
A plot item, that represents a series of points
Definition qwt_plot_curve.h:75
@ BreakAtNan
Definition qwt_plot_curve.h:177
void setCurveAttribute(CurveAttribute, bool on=true)
Set curve attribute
Definition qwt_plot_curve.cpp:986
void setSamples(const double *xData, const double *yData, int size)
Set data by copying x- and y-values from specified memory blocks (double)
Definition qwt_plot_curve.cpp:1558
void attach(QwtPlot *plot) override
Attach the curve to a plot
Definition qwt_plot_curve.cpp:227
QwtPlot * plot() const
Get the plot the item is attached to
Definition qwt_plot_item.cpp:164

◆ CurveStyle

Curve styles

参见
setStyle(), style()
枚举值
NoCurve 

Don't draw a curve. Note: This doesn't affect the symbols.

Lines 

Connect the points with straight lines. The lines might be interpolated depending on the 'Fitted' attribute. Curve fitting can be configured using setCurveFitter().

Sticks 

Draw vertical or horizontal sticks ( depending on the orientation() ) from a baseline which is defined by setBaseline().

Steps 

Connect the points with a step function. The step function is drawn from the left to the right or vice versa, depending on the QwtPlotCurve::Inverted attribute.

Dots 

Draw dots at the locations of the data points. Note: This is different from a dotted line (see setPen()), and faster as a curve in QwtPlotCurve::NoStyle style and a symbol painting a point.

UserCurve 

Styles >= QwtPlotCurve::UserCurve are reserved for derived classes of QwtPlotCurve that overload drawCurve() with additional application specific curve types.

◆ LegendAttribute

Attributes how to represent the curve on the legend

参见
setLegendAttribute(), testLegendAttribute(), QwtPlotItem::legendData(), legendIcon()
枚举值
LegendNoAttribute 

QwtPlotCurve tries to find a color representing the curve and paints a rectangle with it.

LegendShowLine 

If the style() is not QwtPlotCurve::NoCurve a line is painted with the curve pen().

LegendShowSymbol 

If the curve has a valid symbol it is painted.

LegendShowBrush 

If the curve has a brush a rectangle filled with the curve brush() is painted.

◆ PaintAttribute

Attributes to modify the drawing algorithm

The default setting enables ClipPolygons | FilterPointsLTTB

参见
setPaintAttribute(), testPaintAttribute()
枚举值
ClipPolygons 

Clip polygons before painting them. In situations, where points are far outside the visible area (f.e when zooming deep) this might be a substantial improvement for the painting performance

FilterPoints 

Tries to reduce the data that has to be painted, by sorting out duplicates, or paintings outside the visible area. Might have a notable impact on curves with many close points. Only a couple of very basic filtering algorithms are implemented.

MinimizeMemory 

Minimize memory usage that is temporarily needed for the translated points, before they get painted. This might slow down the performance of painting

ImageBuffer 

Render the points to a temporary image and paint the image. This is a very special optimization for Dots style, when having a huge amount of points. With a reasonable number of points QPainter::drawPoints() will be faster.

FilterPointsAggressive 

More aggressive point filtering trying to filter out intermediate points, accepting minor visual differences.

Has only an effect, when drawing the curve to a paint device in integer coordinates ( f.e. all widgets on screen ) using the fact, that consecutive points are often mapped to the same x or y coordinate. Each chunk of samples mapped to the same coordinate can be reduced to 4 points ( first, min, max last ).

In the worst case the polygon to be rendered will be 4 times the width of the plot canvas.

The algorithm is very fast and effective for huge datasets, and can be used inside a replot cycle.

弃用:
Superseded by FilterPointsAdaptive: reducing each chunk to integer first/min/max/last quadruples produces 1px staircase artifacts for oversampled smooth curves. Kept for compatibility for at least one version cycle.
注解
Implemented for QwtPlotCurve::Lines only
As this algo replaces many small lines by a long one a nasty bug of the raster paint engine ( Qt 4.8, Qt 5.1 - 5.3 ) becomes more dominant. For these versions the bug can be worked around by enabling the QwtPainter::polylineSplitting() mode.
FilterPointsPixel 

Pixel-column based downsampling for extreme performance.

Allocates a bin array indexed by pixel column and stores first/min/max/last Y per column. Each column produces at most 4 points. Combined with binary-search visible range for monotonic X data.

Columns holding more than one point are emitted as a cluster in the layout of the adaptive sampling of QCustomPlot: min and max at fixed sub pixel positions ( +0.25 / +0.75 ), so that the vertical stroke of a column stays inside its pixel, plus the real first/last point only where the neighbor column is empty or holds a single point.

Output size: ~4 * canvasWidth points regardless of input size. This is the fastest algorithm for datasets exceeding 100k points.

弃用:
Superseded by FilterPointsAdaptive: the min/max envelope per pixel column discards the sample order and shape, producing ( milder ) staircase artifacts of the same family as FilterPointsAggressive for oversampled smooth curves. Kept for compatibility for at least one version cycle.
注解
Implemented for QwtPlotCurve::Lines only
Overrides FilterPointsAggressive when both are set
FilterPointsLTTB 

Largest-Triangle-Three-Buckets (LTTB) downsampling.

Divides the visible data range into N 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. N is auto-calculated as 4 * canvasWidth.

Output size: ~N points. O(n) time complexity. Preserves the visual shape of the curve ( f.e. narrow peaks ) much better than the MinMax bucket algorithm, at the cost of being slightly slower.

注解
Implemented for QwtPlotCurve::Lines only
Overrides FilterPointsAggressive when both are set
FilterPointsMinMaxLTTB 

MinMax bucket downsampling.

Divides the visible data range into N equal-count buckets and keeps the min-Y and max-Y point from each bucket. N is auto-calculated as 2 * canvasWidth.

Output size: ~2 * N points. O(n) time complexity. Preserves the extremes of each bucket, but may collapse narrow peaks into vertical strokes.

This is the algorithm that was behind FilterPointsLTTB up to v7.4.2.

注解
Implemented for QwtPlotCurve::Lines only
Overrides FilterPointsAggressive when both are set
FilterPointsAdaptive 

Adaptive column reduce downsampling.

Single pass O(n) algorithm designed for the display quality of oversampled curves ( f.e. smooth spectra with many samples per peak ), all pixel quantities in device pixels:

  • Density gate: when the visible samples are not denser than 2 points per device pixel column the curve is painted 1:1 without any reduction - 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. Ramps stay ramps: no 1px staircase artifacts like with the min/max envelope per column ( FilterPointsPixel, FilterPointsAggressive ).
  • High frequency noise inside one column falls back to an ordered first/min/max/last quadruple, bounding the output to at most K + 1 points per column ( K = 4 + column span in device pixels ).

The deviation from the original curve is bounded by 1 device pixel vertically and one column horizontally. For smooth data the output size is roughly the vertical pixel travel - typically larger than FilterPointsLTTB ( the price of the shape preservation ), but far below the unreduced point count.

注解
Implemented for QwtPlotCurve::Lines only
Overrides all other FilterPoints reductions when both are set

◆ SmoothAlgorithm

Algorithm for smoothing the rendered polyline

The smoothing is applied to the polyline that has been downsampled and translated to paint coordinates. It targets the pixel level noise of curves with many samples ( f.e. spectra with random jitter ), while the sample data itself is not modified.

In contrast to the Fitted attribute, that interpolates through all points, the smoothing algorithms are low pass filters. Significant features ( peaks, dips ) are restored to their original position and height afterwards, so that the smoothing does not distort the curve, see setSmoothPreserveThreshold().

注解
Implemented for QwtPlotCurve::Lines only
参见
setSmoothAlgorithm(), setSmoothWindow(), setSmoothPolynomialOrder(), setSmoothPreserveThreshold()
枚举值
NoSmoothing 

No smoothing ( default )

GaussianSmoothing 

Gaussian weighted moving window: strong noise suppression

SavitzkyGolaySmoothing 

Savitzky-Golay local polynomial regression: keeps the height and shape of narrow peaks better than GaussianSmoothing

构造及析构函数说明

◆ QwtPlotCurve()

QwtPlotCurve::QwtPlotCurve ( const QwtText &  title)
explicit

Constructor with QwtText title

参数
[in]titleTitle of the curve

Constructor with QString title

参数
[in]titleTitle of the curve

Destructor

成员函数说明

◆ attach()

void QwtPlotCurve::attach ( QwtPlot *  plot)
overridevirtual

Attach the curve to a plot

If the pen has not been explicitly set by the user via setPen(), the curve automatically receives a color from the plot's color cycle. If an uncustomized symbol (default brush/pen) has been assigned, it is auto-colored to match the curve pen as well.

参数
plotPlot to attach to (nullptr to detach)
参见
QwtPlot::nextColorForItem(), QwtPlot::setColorCycle(), setSymbol()

重载 QwtPlotItem .

◆ baseline()

double QwtPlotCurve::baseline ( ) const

Get the baseline value

返回
Value of the baseline
参见
setBaseline()

◆ brush()

const QBrush & QwtPlotCurve::brush ( ) const

Get the brush used to fill the area between lines and the baseline

返回
Brush used to fill the area between lines and the baseline
参见
setBrush(), setBaseline(), baseline()

◆ closePolyline()

void QwtPlotCurve::closePolyline ( QPainter *  painter,
const QwtScaleMap &  xMap,
const QwtScaleMap &  yMap,
QPolygonF &  polygon 
) const
protected

Close the polyline

Complete a polygon to be a closed polygon including the area between the original polygon and the baseline

参数
[in]painterPainter
[in]xMapX map
[in]yMapY map
[in,out]polygonPolygon to be completed

◆ closestPoint()

int QwtPlotCurve::closestPoint ( const QPointF &  pos,
double *  dist = nullptr 
) const
virtual

Find the closest curve point for a specific position

参数
[in]posPosition where to look for the closest curve point
[out]distIf dist != nullptr, returns the distance between the position and the closest curve point
返回
Index of the closest curve point, or -1 if none can be found (e.g. when the curve has no points)
注解
closestPoint() implements a dumb algorithm that iterates over all points

◆ curveFitter()

QwtCurveFitter * QwtPlotCurve::curveFitter ( ) const

Get the curve fitter

返回
Curve fitter, or nullptr if curve fitting is disabled
参见
setCurveFitter(), Fitted

◆ dataChanged()

void QwtPlotCurve::dataChanged ( )
overrideprotectedvirtual

Invalidate data dependent caches when the series has been changed

重载 QwtPlotSeriesItem .

◆ drawCurve()

void QwtPlotCurve::drawCurve ( QPainter *  painter,
int  style,
const QwtScaleMap &  xMap,
const QwtScaleMap &  yMap,
const QRectF &  canvasRect,
int  from,
int  to 
) const
protectedvirtual

Draw the curve

Draw the line part (without symbols) of a curve interval

参数
[in]painterPainter
[in]styleCurve style, see QwtPlotCurve::CurveStyle
[in]xMapX map
[in]yMapY map
[in]canvasRectContents rectangle of the canvas
[in]fromIndex of the first point to be painted
[in]toIndex of the last point to be painted
参见
draw(), drawDots(), drawLines(), drawSteps(), drawSticks()

◆ drawDots()

void QwtPlotCurve::drawDots ( QPainter *  painter,
const QwtScaleMap &  xMap,
const QwtScaleMap &  yMap,
const QRectF &  canvasRect,
int  from,
int  to 
) const
protectedvirtual

Draw dots

参数
[in]painterPainter
[in]xMapX map
[in]yMapY map
[in]canvasRectContents rectangle of the canvas
[in]fromIndex of the first point to be painted
[in]toIndex of the last point to be painted
参见
draw(), drawCurve(), drawSticks(), drawLines(), drawSteps()

◆ drawLines()

void QwtPlotCurve::drawLines ( QPainter *  painter,
const QwtScaleMap &  xMap,
const QwtScaleMap &  yMap,
const QRectF &  canvasRect,
int  from,
int  to 
) const
protectedvirtual

Draw lines

If the CurveAttribute Fitted is enabled a QwtCurveFitter tries to interpolate/smooth the curve, before it is painted.

参数
[in]painterPainter
[in]xMapX map
[in]yMapY map
[in]canvasRectContents rectangle of the canvas
[in]fromIndex of the first point to be painted
[in]toIndex of the last point to be painted
参见
setCurveAttribute(), setCurveFitter(), draw(), drawLines(), drawDots(), drawSteps(), drawSticks()

◆ drawSeries()

void QwtPlotCurve::drawSeries ( QPainter *  painter,
const QwtScaleMap &  xMap,
const QwtScaleMap &  yMap,
const QRectF &  canvasRect,
int  from,
int  to 
) const
overridevirtual

Draw an interval of the curve

参数
[in]painterPainter
[in]xMapMaps x-values into pixel coordinates
[in]yMapMaps y-values into pixel coordinates
[in]canvasRectContents rectangle of the canvas
[in]fromIndex of the first point to be painted
[in]toIndex of the last point to be painted. If to < 0 the curve will be painted to its last point.
参见
drawCurve(), drawSymbols()

实现了 QwtPlotSeriesItem.

◆ drawSteps()

void QwtPlotCurve::drawSteps ( QPainter *  painter,
const QwtScaleMap &  xMap,
const QwtScaleMap &  yMap,
const QRectF &  canvasRect,
int  from,
int  to 
) const
protectedvirtual

Draw steps

Draw step function

The direction of the steps depends on Inverted attribute.

参数
[in]painterPainter
[in]xMapX map
[in]yMapY map
[in]canvasRectContents rectangle of the canvas
[in]fromIndex of the first point to be painted
[in]toIndex of the last point to be painted
参见
CurveAttribute, setCurveAttribute(), draw(), drawCurve(), drawDots(), drawLines(), drawSticks()

◆ drawSticks()

void QwtPlotCurve::drawSticks ( QPainter *  painter,
const QwtScaleMap &  xMap,
const QwtScaleMap &  yMap,
const QRectF &  canvasRect,
int  from,
int  to 
) const
protectedvirtual

Draw sticks

参数
[in]painterPainter
[in]xMapX map
[in]yMapY map
[in]canvasRectContents rectangle of the canvas
[in]fromIndex of the first point to be painted
[in]toIndex of the last point to be painted
参见
draw(), drawCurve(), drawDots(), drawLines(), drawSteps()

◆ drawSymbols()

void QwtPlotCurve::drawSymbols ( QPainter *  painter,
const QwtSymbol &  symbol,
const QwtScaleMap &  xMap,
const QwtScaleMap &  yMap,
const QRectF &  canvasRect,
int  from,
int  to 
) const
protectedvirtual

Draw symbols

参数
[in]painterPainter
[in]symbolCurve symbol
[in]xMapX map
[in]yMapY map
[in]canvasRectContents rectangle of the canvas
[in]fromIndex of the first point to be painted
[in]toIndex of the last point to be painted
参见
setSymbol(), drawSeries(), drawCurve()

◆ fillCurve()

void QwtPlotCurve::fillCurve ( QPainter *  painter,
const QwtScaleMap &  xMap,
const QwtScaleMap &  yMap,
const QRectF &  canvasRect,
QPolygonF &  polygon 
) const
protectedvirtual

Fill the curve

Fill the area between the curve and the baseline with the curve brush

参数
[in]painterPainter
[in]xMapX map
[in]yMapY map
[in]canvasRectContents rectangle of the canvas
[in,out]polygonPolygon - will be modified
参见
setBrush(), setBaseline(), setStyle()

◆ init()

void QwtPlotCurve::init ( )
protected

Initialize the curve

Initialize internal members

Sets default attributes and creates internal data structures.

◆ legendAttributes()

QwtPlotCurve::LegendAttributes QwtPlotCurve::legendAttributes ( ) const

Get legend attributes

返回
Attributes for drawing the legend icon
参见
setLegendAttributes(), testLegendAttribute()

◆ legendIcon()

QwtGraphic QwtPlotCurve::legendIcon ( int  index,
const QSizeF &  size 
) const
overridevirtual

Get the icon representing the curve on the legend

参数
[in]indexIndex of the legend entry (ignored as there is only one)
[in]sizeIcon size
返回
Icon representing the curve on the legend
参见
QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()

重载 QwtPlotItem .

◆ pen()

const QPen & QwtPlotCurve::pen ( ) const

Get the pen used to draw the lines

返回
Pen used to draw the lines
参见
setPen(), brush()

◆ rtti()

int QwtPlotCurve::rtti ( ) const
overridevirtual

Get the runtime type information

返回
QwtPlotItem::Rtti_PlotCurve

重载 QwtPlotItem .

◆ setBaseline()

void QwtPlotCurve::setBaseline ( double  value)

Set the value of the baseline

The baseline is needed for filling the curve with a brush or the Sticks drawing style. The interpretation of the baseline depends on the orientation(). With Qt::Vertical, the baseline is interpreted as a horizontal line at y = baseline(), with Qt::Horizontal, it is interpreted as a vertical line at x = baseline(). The default value is 0.0.

参数
[in]valueValue of the baseline
参见
baseline(), setBrush(), setStyle(), QwtPlotAbstractSeriesItem::orientation()

◆ setBrush()

void QwtPlotCurve::setBrush ( const QBrush &  brush)

Assign a brush

In case of brush.style() != QBrush::NoBrush and style() != QwtPlotCurve::Sticks, the area between the curve and the baseline will be filled. In case !brush.color().isValid() the area will be filled by pen.color(). The fill algorithm simply connects the first and the last curve point to the baseline. So the curve data has to be sorted (ascending or descending).

参数
[in]brushNew brush
参见
brush(), setBaseline(), baseline()

◆ setCurveAttribute()

void QwtPlotCurve::setCurveAttribute ( CurveAttribute  attribute,
bool  on = true 
)

Set curve attribute

参数
[in]attributeCurve attribute
[in]onOn/Off
参见
testCurveAttribute(), setCurveFitter()

◆ setCurveFitter()

void QwtPlotCurve::setCurveFitter ( QwtCurveFitter *  curveFitter)

Assign a curve fitter

The curve fitter "smooths" the curve points, when the Fitted CurveAttribute is set. setCurveFitter(nullptr) also disables curve fitting. The curve fitter operates on the translated points (= widget coordinates) to be functional for logarithmic scales. Obviously this is less performant for fitting algorithms, that reduce the number of points. For situations, where curve fitting is used to improve the performance of painting huge series of points it might be better to execute the fitter on the curve points once and to cache the result in the QwtSeriesData object.

参数
[in]curveFitterCurve fitter
参见
Fitted

◆ setLegendAttribute()

void QwtPlotCurve::setLegendAttribute ( LegendAttribute  attribute,
bool  on = true 
)

Set legend attribute

参数
[in]attributeLegend attribute
[in]onOn/Off
参见
testLegendAttribute(), legendIcon()

◆ setLegendAttributes()

void QwtPlotCurve::setLegendAttributes ( LegendAttributes  attributes)

Set legend attributes

参数
[in]attributesLegend attributes
参见
setLegendAttribute(), legendIcon()

◆ setPaintAttribute()

void QwtPlotCurve::setPaintAttribute ( PaintAttribute  attribute,
bool  on = true 
)

Set paint attribute

参数
[in]attributePaint attribute
[in]onOn/Off
参见
testPaintAttribute()

◆ setPen() [1/2]

void QwtPlotCurve::setPen ( const QColor &  color,
qreal  width = 0.0,
Qt::PenStyle  style = Qt::SolidLine 
)

Build and assign a pen

In Qt5 the default pen width is 1.0 (0.0 in Qt4) which makes it non cosmetic (see QPen::isCosmetic()). This method has been introduced to hide this incompatibility.

参数
[in]colorPen color
[in]widthPen width
[in]stylePen style
参见
pen(), brush()

◆ setPen() [2/2]

void QwtPlotCurve::setPen ( const QPen &  pen)

Assign a pen

参数
[in]penNew pen
参见
pen(), brush()

◆ setRawSamples() [1/4]

void QwtPlotCurve::setRawSamples ( const double *  xData,
const double *  yData,
int  size 
)

Initialize data by pointing to memory blocks not managed by QwtPlotCurve (double)

setRawSamples is provided for efficiency. It is important to keep the pointers during the lifetime of the underlying QwtCPointerData class.

参数
[in]xDataPointer to x data
[in]yDataPointer to y data
[in]sizeSize of x and y
参见
QwtCPointerData

◆ setRawSamples() [2/4]

void QwtPlotCurve::setRawSamples ( const double *  yData,
int  size 
)

Initialize data by pointing to a memory block not managed by QwtPlotCurve (double, y-axis only)

The memory contains the y coordinates, while the index is interpreted as x coordinate. setRawSamples() is provided for efficiency. It is important to keep the pointers during the lifetime of the underlying QwtCPointerValueData class.

参数
[in]yDataPointer to y data
[in]sizeSize of y data
参见
QwtCPointerData

◆ setRawSamples() [3/4]

void QwtPlotCurve::setRawSamples ( const float *  xData,
const float *  yData,
int  size 
)

Initialize data by pointing to memory blocks not managed by QwtPlotCurve (float)

setRawSamples is provided for efficiency. It is important to keep the pointers during the lifetime of the underlying QwtCPointerData class.

参数
[in]xDataPointer to x data
[in]yDataPointer to y data
[in]sizeSize of x and y
参见
QwtCPointerData

◆ setRawSamples() [4/4]

void QwtPlotCurve::setRawSamples ( const float *  yData,
int  size 
)

Initialize data by pointing to a memory block not managed by QwtPlotCurve (float, y-axis only)

The memory contains the y coordinates, while the index is interpreted as x coordinate. setRawSamples() is provided for efficiency. It is important to keep the pointers during the lifetime of the underlying QwtCPointerValueData class.

参数
[in]yDataPointer to y data
[in]sizeSize of y data
参见
QwtCPointerData

◆ setSamples() [1/13]

void QwtPlotCurve::setSamples ( const double *  xData,
const double *  yData,
int  size 
)

Set data by copying x- and y-values from specified memory blocks (double)

Contrary to setRawSamples(), this function makes a 'deep copy' of the data.

参数
[in]xDataPointer to x values
[in]yDataPointer to y values
[in]sizeSize of xData and yData
参见
QwtPointArrayData

◆ setSamples() [2/13]

void QwtPlotCurve::setSamples ( const double *  yData,
int  size 
)

Set data by copying y-values from a specified memory block (double)

The memory contains the y coordinates, while the index is interpreted as x coordinate.

参数
[in]yDataY data
[in]sizeSize of yData
参见
QwtValuePointData

◆ setSamples() [3/13]

void QwtPlotCurve::setSamples ( const float *  xData,
const float *  yData,
int  size 
)

Set data by copying x- and y-values from specified memory blocks (float)

Contrary to setRawSamples(), this function makes a 'deep copy' of the data.

参数
[in]xDataPointer to x values
[in]yDataPointer to y values
[in]sizeSize of xData and yData
参见
QwtPointArrayData

◆ setSamples() [4/13]

void QwtPlotCurve::setSamples ( const float *  yData,
int  size 
)

Set data by copying y-values from a specified memory block (float)

The vector contains the y coordinates, while the index is interpreted as x coordinate.

参数
[in]yDataY data
[in]sizeSize of yData
参见
QwtValuePointData

◆ setSamples() [5/13]

void QwtPlotCurve::setSamples ( const QVector< double > &  xData,
const QVector< double > &  yData 
)

Initialize data with x- and y-arrays (explicitly shared, double)

参数
[in]xDataX data
[in]yDataY data
参见
QwtPointArrayData

◆ setSamples() [6/13]

void QwtPlotCurve::setSamples ( const QVector< double > &  yData)

Initialize data with an array of y values (explicitly shared, double)

The vector contains the y coordinates, while the index is the x coordinate.

参数
[in]yDataY data
参见
QwtValuePointData

◆ setSamples() [7/13]

void QwtPlotCurve::setSamples ( const QVector< float > &  xData,
const QVector< float > &  yData 
)

Initialize data with x- and y-arrays (explicitly shared, float)

参数
[in]xDataX data
[in]yDataY data
参见
QwtPointArrayData

◆ setSamples() [8/13]

void QwtPlotCurve::setSamples ( const QVector< float > &  yData)

Initialize data with an array of y values (explicitly shared, float)

The vector contains the y coordinates, while the index is the x coordinate.

参数
[in]yDataY data
参见
QwtValuePointData

◆ setSamples() [9/13]

void QwtPlotCurve::setSamples ( const QVector< QPointF > &  samples)

Initialize data with an array of points

参数
[in]samplesVector of points
注解
QVector is implicitly shared
QPolygonF is derived from QVector<QPointF>

◆ setSamples() [10/13]

void QwtPlotCurve::setSamples ( QVector< double > &&  xData,
QVector< double > &&  yData 
)

Initialize data with x- and y-arrays (rvalue, double)

参数
[in]xDataX data
[in]yDataY data
参见
QwtPointArrayData

◆ setSamples() [11/13]

void QwtPlotCurve::setSamples ( QVector< float > &&  xData,
QVector< float > &&  yData 
)

Initialize data with x- and y-arrays (rvalue, float)

参数
[in]xDataX data
[in]yDataY data
参见
QwtPointArrayData

◆ setSamples() [12/13]

void QwtPlotCurve::setSamples ( QVector< QPointF > &&  samples)

Initialize data with an array of points (rvalue)

参数
[in]samplesVector of points
注解
QVector is implicitly shared
QPolygonF is derived from QVector<QPointF>

◆ setSamples() [13/13]

void QwtPlotCurve::setSamples ( QwtSeriesData< QPointF > *  data)

Assign a series of points

setSamples() is just a wrapper for setData() without any additional value - beside that it is easier to find for the developer.

参数
[in]dataData
警告
The item takes ownership of the data object, deleting it when it's not used anymore.

◆ setSmoothAlgorithm()

void QwtPlotCurve::setSmoothAlgorithm ( SmoothAlgorithm  algorithm)

Set the render smoothing algorithm

In combination with QwtPlotCurve::Lines the rendered polyline can be smoothed by a low pass filter, that is applied to the polyline that has been downsampled and translated to paint coordinates.

This is about removing pixel level noise ( f.e. from spectra with random jitter ), while the sample data itself is not modified. In contrast to the Fitted attribute the algorithms do not interpolate through the points.

参数
[in]algorithmSmoothing algorithm
参见
smoothAlgorithm(), setSmoothWindow(), setSmoothPolynomialOrder()

◆ setSmoothPolynomialOrder()

void QwtPlotCurve::setSmoothPolynomialOrder ( int  order)

Set the polynomial order of SavitzkyGolaySmoothing

Higher orders keep the shape of narrow peaks better, but reduce the noise suppression. The order is limited to 1 .. smoothWindow() - 2.

The setting has no effect for other smoothing algorithms. The default value is 3.

参数
[in]orderPolynomial order
参见
smoothPolynomialOrder(), setSmoothWindow()

◆ setSmoothPreserveThreshold()

void QwtPlotCurve::setSmoothPreserveThreshold ( double  threshold)

Set the feature preservation threshold of the render smoothing

A linear low pass filter attenuates features that are narrower than its window ( f.e. the peaks of a spectrum ). To avoid this distortion the smoothing restores the original position and height of all points, that deviate from a wide baseline by more than threshold multiples of the estimated noise level.

Lower values preserve more of the curve ( at the cost of keeping more noise ), higher values preserve only the most significant features. A value <= 0 disables the feature preservation, what results in a pure low pass filter.

The default value is 3.0.

参数
[in]thresholdThreshold in multiples of the noise level
参见
smoothPreserveThreshold(), setSmoothAlgorithm()

◆ setSmoothWindow()

void QwtPlotCurve::setSmoothWindow ( int  numPoints)

Set the window of the render smoothing algorithms

The window is the number of neighboring polyline points, that contribute to the smoothed position of a point. As the smoothing happens after downsampling, the polyline is usually not much longer than a multiple of the canvas width.

Values < 3 are raised to 3, even values are rounded up to the next odd value. The default value is 9.

参数
[in]numPointsWindow size
参见
smoothWindow(), setSmoothAlgorithm()

◆ setStyle()

void QwtPlotCurve::setStyle ( CurveStyle  style)

Set the curve's drawing style

参数
[in]styleCurve style
参见
style()

◆ setSymbol()

void QwtPlotCurve::setSymbol ( QwtSymbol *  symbol)

Assign a symbol

The curve will take the ownership of the symbol, hence the previously set symbol will be deleted by setting a new one. If symbol is nullptr no symbol will be drawn.

If the curve is already attached and the new symbol is in its default (uncustomized) state, it is auto-colored to match the curve pen, so that a scatter-style curve inherits the color cycle color of its pen.

参数
[in]symbolSymbol
参见
symbol(), attach()

◆ smoothAlgorithm()

QwtPlotCurve::SmoothAlgorithm QwtPlotCurve::smoothAlgorithm ( ) const

Get the render smoothing algorithm

返回
Smoothing algorithm
参见
setSmoothAlgorithm()

◆ smoothPolynomialOrder()

int QwtPlotCurve::smoothPolynomialOrder ( ) const

Get the polynomial order of SavitzkyGolaySmoothing

返回
Polynomial order
参见
setSmoothPolynomialOrder()

◆ smoothPreserveThreshold()

double QwtPlotCurve::smoothPreserveThreshold ( ) const

Get the feature preservation threshold of the render smoothing

返回
Threshold in multiples of the noise level
参见
setSmoothPreserveThreshold()

◆ smoothWindow()

int QwtPlotCurve::smoothWindow ( ) const

Get the window of the render smoothing algorithms

返回
Window size
参见
setSmoothWindow()

◆ style()

QwtPlotCurve::CurveStyle QwtPlotCurve::style ( ) const

Get the curve's drawing style

返回
Style of the curve
参见
setStyle()

◆ symbol()

const QwtSymbol * QwtPlotCurve::symbol ( ) const

Get the current symbol

返回
Current symbol or nullptr when no symbol has been assigned
参见
setSymbol()

◆ testCurveAttribute()

bool QwtPlotCurve::testCurveAttribute ( CurveAttribute  attribute) const

Test curve attribute

参数
[in]attributeCurve attribute
返回
True if attribute is enabled
参见
setCurveAttribute()

◆ testLegendAttribute()

bool QwtPlotCurve::testLegendAttribute ( LegendAttribute  attribute) const

Test legend attribute

参数
[in]attributeLegend attribute
返回
True when attribute is enabled
参见
setLegendAttribute()

◆ testPaintAttribute()

bool QwtPlotCurve::testPaintAttribute ( PaintAttribute  attribute) const

Test paint attribute

参数
[in]attributePaint attribute
返回
True when attribute is enabled
参见
setPaintAttribute()

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