QwtPlotCurve(3) Qwt User's Guide QwtPlotCurve(3)

QwtPlotCurve - A plot item, that represents a series of points.

#include <qwt_plot_curve.h>

Inherits QwtPlotSeriesItem, and QwtSeriesStore< QPointF >.


enum CurveStyle { NoCurve = -1, Lines, Sticks, Steps, Dots, UserCurve = 100 }
enum CurveAttribute { Inverted = 0x01, Fitted = 0x02 }
enum LegendAttribute { LegendNoAttribute = 0x00, LegendShowLine = 0x01, LegendShowSymbol = 0x02, LegendShowBrush = 0x04 }
enum PaintAttribute { ClipPolygons = 0x01, FilterPoints = 0x02, MinimizeMemory = 0x04, ImageBuffer = 0x08, FilterPointsAggressive = 0x10 }
typedef QFlags< CurveAttribute > CurveAttributes
typedef QFlags< LegendAttribute > LegendAttributes
typedef QFlags< PaintAttribute > PaintAttributes


QwtPlotCurve (const QString &title=QString())
QwtPlotCurve (const QwtText &title)
virtual ~QwtPlotCurve ()
Destructor. virtual int rtti () const override
void setPaintAttribute (PaintAttribute, bool on=true)
bool testPaintAttribute (PaintAttribute) const
void setLegendAttribute (LegendAttribute, bool on=true)
bool testLegendAttribute (LegendAttribute) const
void setLegendAttributes (LegendAttributes)
LegendAttributes legendAttributes () const
void setRawSamples (const double *xData, const double *yData, int size)
Initialize the data by pointing to memory blocks which are not managed by QwtPlotCurve. void setRawSamples (const float *xData, const float *yData, int size)
Initialize the data by pointing to memory blocks which are not managed by QwtPlotCurve. void setRawSamples (const double *yData, int size)
Initialize the data by pointing to a memory block which is not managed by QwtPlotCurve. void setRawSamples (const float *yData, int size)
Initialize the data by pointing to memory blocks which are not managed by QwtPlotCurve. void setSamples (const double *xData, const double *yData, int size)
void setSamples (const float *xData, const float *yData, int size)
void setSamples (const double *yData, int size)
void setSamples (const float *yData, int size)
void setSamples (const QVector< double > &yData)
void setSamples (const QVector< float > &yData)
void setSamples (const QVector< double > &xData, const QVector< double > &yData)
Initialize data with x- and y-arrays (explicitly shared) void setSamples (const QVector< float > &xData, const QVector< float > &yData)
Initialize data with x- and y-arrays (explicitly shared) void setSamples (const QVector< QPointF > &)
void setSamples (QwtSeriesData< QPointF > *)
virtual int closestPoint (const QPointF &pos, double *dist=NULL) const
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)
bool testCurveAttribute (CurveAttribute) const
void setPen (const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
void setPen (const QPen &)
const QPen & pen () const
void setBrush (const QBrush &)
Assign a brush. const QBrush & brush () const
void setBaseline (double)
Set the value of the baseline. double baseline () const
void setStyle (CurveStyle style)
CurveStyle style () const
void setSymbol (QwtSymbol *)
Assign a symbol. const QwtSymbol * symbol () const
void setCurveFitter (QwtCurveFitter *)
QwtCurveFitter * curveFitter () const
virtual void drawSeries (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const override
virtual QwtGraphic legendIcon (int index, const QSizeF &) const override


void init ()
Initialize internal members. virtual void drawCurve (QPainter *, int style, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
Draw the line part (without symbols) of a curve interval. virtual void drawSymbols (QPainter *, const QwtSymbol &, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
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
virtual void drawDots (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
virtual void drawSteps (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
virtual void fillCurve (QPainter *, const QwtScaleMap &, const QwtScaleMap &, const QRectF &canvasRect, QPolygonF &) const
void closePolyline (QPainter *, const QwtScaleMap &, const QwtScaleMap &, QPolygonF &) const
Complete a polygon to be a closed polygon including the area between the original polygon and the baseline.

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

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().
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.
See QwtPlotItem::attach()

Example:

see examples/bode

See also

QwtPointSeriesData, QwtSymbol, QwtScaleMap

Definition at line 56 of file qwt_plot_curve.h.

typedef QFlags<CurveAttribute > QwtPlotCurve::CurveAttributes

An ORed combination of CurveAttribute values.

Definition at line 133 of file qwt_plot_curve.h.

typedef QFlags<LegendAttribute > QwtPlotCurve::LegendAttributes

An ORed combination of LegendAttribute values.

Definition at line 168 of file qwt_plot_curve.h.

typedef QFlags<PaintAttribute > QwtPlotCurve::PaintAttributes

An ORed combination of PaintAttribute values.

Definition at line 234 of file qwt_plot_curve.h.

enum QwtPlotCurve::CurveAttribute

Attribute for drawing the curve

See also

setCurveAttribute(), testCurveAttribute(), curveFitter()

Enumerator

For QwtPlotCurve::Steps only. Draws a step function from the right to the left.
Only in combination with QwtPlotCurve::Lines A QwtCurveFitter tries to interpolate/smooth the curve, before it is painted.

Note

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.

Definition at line 112 of file qwt_plot_curve.h.

enum QwtPlotCurve::CurveStyle

Curve styles.

See also

setStyle(), style()

Enumerator

Don't draw a curve. Note: This doesn't affect the symbols.
Connect the points with straight lines. The lines might be interpolated depending on the 'Fitted' attribute. Curve fitting can be configured using setCurveFitter().
Draw vertical or horizontal sticks ( depending on the orientation() ) from a baseline which is defined by setBaseline().
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.
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.
Styles >= QwtPlotCurve::UserCurve are reserved for derived classes of QwtPlotCurve that overload drawCurve() with additional application specific curve types.

Definition at line 65 of file qwt_plot_curve.h.

enum QwtPlotCurve::LegendAttribute

Attributes how to represent the curve on the legend

See also

setLegendAttribute(), testLegendAttribute(), QwtPlotItem::legendData(), legendIcon()

Enumerator

QwtPlotCurve tries to find a color representing the curve and paints a rectangle with it.
If the style() is not QwtPlotCurve::NoCurve a line is painted with the curve pen().
If the curve has a valid symbol it is painted.
If the curve has a brush a rectangle filled with the curve brush() is painted.

Definition at line 142 of file qwt_plot_curve.h.

enum QwtPlotCurve::PaintAttribute

Attributes to modify the drawing algorithm. The default setting enables ClipPolygons | FilterPoints

See also

setPaintAttribute(), testPaintAttribute()

Enumerator

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
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.
Minimize memory usage that is temporarily needed for the translated points, before they get painted. This might slow down the performance of painting
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.
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.

Note

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.

Definition at line 176 of file qwt_plot_curve.h.

Constructor

Parameters

title Title of the curve

Definition at line 120 of file qwt_plot_curve.cpp.

Constructor

Parameters

title Title of the curve

Definition at line 110 of file qwt_plot_curve.cpp.

Returns

Value of the baseline

See also

setBaseline()

Definition at line 1035 of file qwt_plot_curve.cpp.

Returns

Brush used to fill the area between lines and the baseline

See also

setBrush(), setBaseline(), baseline()

Definition at line 363 of file qwt_plot_curve.cpp.

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

Parameters

painter Painter
xMap X map
yMap Y map
polygon Polygon to be completed

Definition at line 929 of file qwt_plot_curve.cpp.

Find the closest curve point for a specific position

Parameters

pos Position, where to look for the closest curve point
dist If dist != NULL, closestPoint() returns the distance between the position and the closest curve point

Returns

Index of the closest curve point, or -1 if none can be found ( f.e when the curve has no points )

Note

closestPoint() implements a dumb algorithm, that iterates over all points

Definition at line 1051 of file qwt_plot_curve.cpp.

QwtCurveFitter * QwtPlotCurve::curveFitter () const

Get the curve fitter. If curve fitting is disabled NULL is returned.

Returns

Curve fitter

See also

setCurveFitter(), Fitted

Definition at line 872 of file qwt_plot_curve.cpp.

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

Parameters

painter Painter
style curve style, see QwtPlotCurve::CurveStyle
xMap x map
yMap y map
canvasRect Contents rectangle of the canvas
from index of the first point to be painted
to index of the last point to be painted

See also

draw(), drawDots(), drawLines(), drawSteps(), drawSticks()

Definition at line 429 of file qwt_plot_curve.cpp.

Draw dots

Parameters

painter Painter
xMap x map
yMap y map
canvasRect Contents rectangle of the canvas
from index of the first point to be painted
to index of the last point to be painted

See also

draw(), drawCurve(), drawSticks(), drawLines(), drawSteps()

Definition at line 640 of file qwt_plot_curve.cpp.

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

Parameters

painter Painter
xMap x map
yMap y map
canvasRect Contents rectangle of the canvas
from index of the first point to be painted
to index of the last point to be painted

See also

setCurveAttribute(), setCurveFitter(), draw(), drawLines(), drawDots(), drawSteps(), drawSticks()

Definition at line 476 of file qwt_plot_curve.cpp.

Draw an interval of the curve

Parameters

painter Painter
xMap Maps x-values into pixel coordinates.
yMap Maps y-values into pixel coordinates.
canvasRect Contents rectangle of the canvas
from Index of the first point to be painted
to Index of the last point to be painted. If to < 0 the curve will be painted to its last point.

See also

drawCurve(), drawSymbols(),

Implements QwtPlotSeriesItem.

Definition at line 381 of file qwt_plot_curve.cpp.

Draw step function

The direction of the steps depends on Inverted attribute.

Parameters

painter Painter
xMap x map
yMap y map
canvasRect Contents rectangle of the canvas
from index of the first point to be painted
to index of the last point to be painted

See also

CurveAttribute, setCurveAttribute(), draw(), drawCurve(), drawDots(), drawLines(), drawSticks()

Definition at line 741 of file qwt_plot_curve.cpp.

Draw sticks

Parameters

painter Painter
xMap x map
yMap y map
canvasRect Contents rectangle of the canvas
from index of the first point to be painted
to index of the last point to be painted

See also

draw(), drawCurve(), drawDots(), drawLines(), drawSteps()

Definition at line 585 of file qwt_plot_curve.cpp.

Draw symbols

Parameters

painter Painter
symbol Curve symbol
xMap x map
yMap y map
canvasRect Contents rectangle of the canvas
from Index of the first point to be painted
to Index of the last point to be painted

See also

setSymbol(), drawSeries(), drawCurve()

Definition at line 979 of file qwt_plot_curve.cpp.

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

Parameters

painter Painter
xMap x map
yMap y map
canvasRect Contents rectangle of the canvas
polygon Polygon - will be modified !

See also

setBrush(), setBaseline(), setStyle()

Definition at line 889 of file qwt_plot_curve.cpp.

QwtPlotCurve::LegendAttributes QwtPlotCurve::legendAttributes () const

Returns

Attributes how to draw the legend icon

See also

setLegendAttributes(), testLegendAttribute()

Definition at line 225 of file qwt_plot_curve.cpp.

QwtGraphic QwtPlotCurve::legendIcon (int index, const QSizeF & size) const [override], [virtual]

Returns

Icon representing the curve on the legend

Parameters

index Index of the legend entry ( ignored as there is only one )
size Icon size

See also

QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()

Reimplemented from QwtPlotItem.

Definition at line 1095 of file qwt_plot_curve.cpp.

Returns

Pen used to draw the lines

See also

setPen(), brush()

Definition at line 328 of file qwt_plot_curve.cpp.

Returns

QwtPlotItem::Rtti_PlotCurve

Reimplemented from QwtPlotItem.

Definition at line 145 of file qwt_plot_curve.cpp.

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.

Parameters

value Value of the baseline

See also

baseline(), setBrush(), setStyle(), QwtPlotAbstractSeriesItem::orientation()

Definition at line 1022 of file qwt_plot_curve.cpp.

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

Parameters

brush New brush

See also

brush(), setBaseline(), baseline()

Definition at line 348 of file qwt_plot_curve.cpp.

Specify an attribute for drawing the curve

Parameters

attribute Curve attribute
on On/Off

/sa testCurveAttribute(), setCurveFitter()

Definition at line 819 of file qwt_plot_curve.cpp.

Assign a curve fitter

The curve fitter 'smooths' the curve points, when the Fitted CurveAttribute is set. setCurveFitter(NULL) 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.

Parameters

curveFitter() Curve fitter

See also

Fitted

Definition at line 858 of file qwt_plot_curve.cpp.

Specify an attribute how to draw the legend icon

Parameters

attribute Attribute
on On/Off /sa testLegendAttribute(). legendIcon()

Definition at line 181 of file qwt_plot_curve.cpp.

Specify the attributes how to draw the legend icon

Parameters

attributes Attributes /sa setLegendAttribute(). legendIcon()

Definition at line 210 of file qwt_plot_curve.cpp.

Specify an attribute how to draw the curve

Parameters

attribute Paint attribute
on On/Off

See also

testPaintAttribute()

Definition at line 157 of file qwt_plot_curve.cpp.

Build and assign a pen

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

Parameters

color Pen color
width Pen width
style Pen style

See also

pen(), brush()

Definition at line 302 of file qwt_plot_curve.cpp.

Assign a pen

Parameters

pen New pen

See also

pen(), brush()

Definition at line 313 of file qwt_plot_curve.cpp.

Initialize the data by pointing to memory blocks which are not managed by QwtPlotCurve. setRawSamples is provided for efficiency. It is important to keep the pointers during the lifetime of the underlying QwtCPointerData class.

Parameters

xData pointer to x data
yData pointer to y data
size size of x and y

See also

QwtCPointerData

Definition at line 1203 of file qwt_plot_curve.cpp.

Initialize the data by pointing to a memory block which is not managed by QwtPlotCurve. 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.

Parameters

yData pointer to y data
size size of x and y

See also

QwtCPointerData

Definition at line 1245 of file qwt_plot_curve.cpp.

Initialize the data by pointing to memory blocks which are not managed by QwtPlotCurve. setRawSamples is provided for efficiency. It is important to keep the pointers during the lifetime of the underlying QwtCPointerData class.

Parameters

xData pointer to x data
yData pointer to y data
size size of x and y

See also

QwtCPointerData

Definition at line 1223 of file qwt_plot_curve.cpp.

Initialize the data by pointing to memory blocks which are not managed by QwtPlotCurve. 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.

Parameters

yData pointer to y data
size size of x and y

See also

QwtCPointerData

Definition at line 1266 of file qwt_plot_curve.cpp.

Set data by copying x- and y-values from specified memory blocks. Contrary to setRawSamples(), this function makes a 'deep copy' of the data.

Parameters

xData pointer to x values
yData pointer to y values
size size of xData and yData

See also

QwtPointArrayData

Definition at line 1282 of file qwt_plot_curve.cpp.

Set data by copying y-values from a specified memory block.

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

Parameters

yData y data
size size of yData

See also

QwtValuePointData

Definition at line 1344 of file qwt_plot_curve.cpp.

Set data by copying x- and y-values from specified memory blocks. Contrary to setRawSamples(), this function makes a 'deep copy' of the data.

Parameters

xData pointer to x values
yData pointer to y values
size size of xData and yData

See also

QwtPointArrayData

Definition at line 1299 of file qwt_plot_curve.cpp.

Set data by copying y-values from a specified memory block.

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

Parameters

yData y data
size size of yData

See also

QwtValuePointData

Definition at line 1360 of file qwt_plot_curve.cpp.

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

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

Parameters

xData x data
yData y data

See also

QwtPointArrayData

Definition at line 1313 of file qwt_plot_curve.cpp.

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

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

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

Parameters

yData y data

See also

QwtValuePointData

Definition at line 1375 of file qwt_plot_curve.cpp.

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

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

Parameters

xData x data
yData y data

See also

QwtPointArrayData

Definition at line 1327 of file qwt_plot_curve.cpp.

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

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

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

Parameters

yData y data

See also

QwtValuePointData

Definition at line 1390 of file qwt_plot_curve.cpp.

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

Initialize data with an array of points.

Parameters

samples Vector of points

Note

QVector is implicitly shared

QPolygonF is derived from QVector<QPointF>

Definition at line 1184 of file qwt_plot_curve.cpp.

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.

Parameters

data Data

Warning

The item takes ownership of the data object, deleting it when its not used anymore.

Definition at line 1172 of file qwt_plot_curve.cpp.

Set the curve's drawing style

Parameters

style Curve style

See also

style()

Definition at line 236 of file qwt_plot_curve.cpp.

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

Parameters

symbol Symbol

See also

symbol()

Definition at line 266 of file qwt_plot_curve.cpp.

QwtPlotCurve::CurveStyle QwtPlotCurve::style () const

Returns

Style of the curve

See also

setStyle()

Definition at line 251 of file qwt_plot_curve.cpp.

Returns

Current symbol or NULL, when no symbol has been assigned

See also

setSymbol()

Definition at line 284 of file qwt_plot_curve.cpp.

Returns

true, if attribute is enabled

See also

setCurveAttribute()

Definition at line 836 of file qwt_plot_curve.cpp.

Returns

True, when attribute is enabled

See also

setLegendAttribute()

Definition at line 199 of file qwt_plot_curve.cpp.

Returns

True, when attribute is enabled

See also

setPaintAttribute()

Definition at line 169 of file qwt_plot_curve.cpp.

Generated automatically by Doxygen for Qwt User's Guide from the source code.

Sun Jul 18 2021 Version 6.2.0