QwtPlotCurve(3) | Qwt User's Guide | QwtPlotCurve(3) |
NAME¶
QwtPlotCurve -A plot item, that represents a series of points.
SYNOPSIS¶
#include <qwt_plot_curve.h>
Inherits QwtPlotSeriesItem, and QwtSeriesStore< QPointF >.
Public Types¶
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 }
typedef QFlags< CurveAttribute > CurveAttributes
Curve attributes. typedef QFlags< LegendAttribute > LegendAttributes
Legend attributes. typedef QFlags< PaintAttribute > PaintAttributes
Paint attributes.
Public Member Functions¶
QwtPlotCurve (const QString &title=QString::null)
QwtPlotCurve (const QwtText &title)
virtual ~QwtPlotCurve ()
Destructor. virtual int rtti () const
void setPaintAttribute (PaintAttribute, bool on=true)
bool testPaintAttribute (PaintAttribute) const
void setLegendAttribute (LegendAttribute, bool on=true)
bool testLegendAttribute (LegendAttribute) 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 setSamples (const double *xData, const double *yData, int size)
void setSamples (const QVector< double > &xData, const QVector< double > &yData)
Initialize data with x- and y-arrays (explicitly shared) void setSamples (const QVector< QPointF > &)
void setSamples (QwtSeriesData< QPointF > *)
int closestPoint (const QPoint &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
virtual QwtGraphic legendIcon (int index, const QSizeF &) const
Protected Member Functions¶
void init ()
Initialize internal members. virtual void drawCurve (QPainter *p, 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 *p, const QwtSymbol &, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
virtual void drawLines (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
Draw lines. virtual void drawSticks (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
virtual void drawDots (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
virtual void drawSteps (QPainter *p, 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.
Detailed Description¶
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 Also:
Member Enumeration Documentation¶
enum QwtPlotCurve::CurveAttribute¶
Attribute for drawing the curveSee Also:
Enumerator
- 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.
Note:
enum QwtPlotCurve::CurveStyle¶
Curve styles.See Also:
Enumerator
- 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.
enum QwtPlotCurve::LegendAttribute¶
Attributes how to represent the curve on the legendSee Also:
Enumerator
- 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.
enum QwtPlotCurve::PaintAttribute¶
Attributes to modify the drawing algorithm. The default setting enables ClipPolygons | FilterPointsSee Also:
Enumerator
- 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.
Constructor & Destructor Documentation¶
QwtPlotCurve::QwtPlotCurve (const QString &title = QString::null) [explicit]¶
ConstructorParameters:
QwtPlotCurve::QwtPlotCurve (const QwtText &title) [explicit]¶
ConstructorParameters:
Member Function Documentation¶
double QwtPlotCurve::baseline () const¶
Returns:See Also:
const QBrush & QwtPlotCurve::brush () const¶
Returns:See Also:
void QwtPlotCurve::closePolyline (QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, QPolygonF &polygon) const [protected]¶
Complete a polygon to be a closed polygon including the area between the original polygon and the baseline.Parameters:
xMap X map
yMap Y map
polygon Polygon to be completed
int QwtPlotCurve::closestPoint (const QPoint &pos, double *dist = NULL) const¶
Find the closest curve point for a specific positionParameters:
dist If dist != NULL, closestPoint() returns the distance between the position and the closest curve point
Returns:
Note:
QwtCurveFitter * QwtPlotCurve::curveFitter () const¶
Get the curve fitter. If curve fitting is disabled NULL is returned.Returns:
See Also:
void QwtPlotCurve::drawCurve (QPainter *painter, intstyle, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, intfrom, intto) const [protected], [virtual]¶
Draw the line part (without symbols) of a curve interval.Parameters:
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:
void QwtPlotCurve::drawDots (QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, intfrom, intto) const [protected], [virtual]¶
Draw dotsParameters:
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:
void QwtPlotCurve::drawLines (QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, intfrom, intto) const [protected], [virtual]¶
Draw lines. If the CurveAttribute Fitted is enabled a QwtCurveFitter tries to interpolate/smooth the curve, before it is painted.Parameters:
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:
void QwtPlotCurve::drawSeries (QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, intfrom, intto) const [virtual]¶
Draw an interval of the curveParameters:
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:
Implements QwtPlotSeriesItem.
void QwtPlotCurve::drawSteps (QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, intfrom, intto) const [protected], [virtual]¶
Draw step functionThe direction of the steps depends on Inverted attribute.
Parameters:
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:
void QwtPlotCurve::drawSticks (QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, intfrom, intto) const [protected], [virtual]¶
Draw sticksParameters:
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:
void QwtPlotCurve::drawSymbols (QPainter *painter, const QwtSymbol &symbol, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, intfrom, intto) const [protected], [virtual]¶
Draw symbolsParameters:
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:
void QwtPlotCurve::fillCurve (QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, QPolygonF &polygon) const [protected], [virtual]¶
Fill the area between the curve and the baseline with the curve brushParameters:
xMap x map
yMap y map
canvasRect Contents rectangle of the canvas
polygon Polygon - will be modified !
See Also:
QwtGraphic QwtPlotCurve::legendIcon (intindex, const QSizeF &size) const [virtual]¶
Returns:Parameters:
size Icon size
See Also:
Reimplemented from QwtPlotItem.
const QPen & QwtPlotCurve::pen () const¶
Returns:See Also:
int QwtPlotCurve::rtti () const [virtual]¶
Returns:Reimplemented from QwtPlotItem.
void QwtPlotCurve::setBaseline (doublevalue)¶
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::Horizontal, the baseline is interpreted as a horizontal line at y = baseline(), with Qt::Vertical, it is interpreted as a vertical line at x = baseline().
The default value is 0.0.
Parameters:
See Also:
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).
Parameters:
See Also:
void QwtPlotCurve::setCurveAttribute (CurveAttributeattribute, boolon = true)¶
Specify an attribute for drawing the curveParameters:
on On/Off
/sa testCurveAttribute(), setCurveFitter()
void QwtPlotCurve::setCurveFitter (QwtCurveFitter *curveFitter)¶
Assign a curve fitterThe 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:
See Also:
void QwtPlotCurve::setLegendAttribute (LegendAttributeattribute, boolon = true)¶
Specify an attribute how to draw the legend iconParameters:
on On/Off /sa testLegendAttribute(). legendIcon()
void QwtPlotCurve::setPaintAttribute (PaintAttributeattribute, boolon = true)¶
Specify an attribute how to draw the curveParameters:
on On/Off
See Also:
void QwtPlotCurve::setPen (const QColor &color, qrealwidth = 0.0, Qt::PenStylestyle = Qt::SolidLine)¶
Build and assign a penIn 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:
width Pen width
style Pen style
See Also:
void QwtPlotCurve::setPen (const QPen &pen)¶
Assign a penParameters:
See Also:
void QwtPlotCurve::setRawSamples (const double *xData, const double *yData, intsize)¶
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:
yData pointer to y data
size size of x and y
See Also:
void QwtPlotCurve::setSamples (const double *xData, const double *yData, intsize)¶
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:
yData pointer to y values
size size of xData and yData
See Also:
void QwtPlotCurve::setSamples (const QVector< double > &xData, const QVector< double > &yData)¶
Initialize data with x- and y-arrays (explicitly shared)Parameters:
yData y data
See Also:
void QwtPlotCurve::setSamples (const QVector< QPointF > &samples)¶
Initialize data with an array of points.Parameters:
Note:
QPolygonF is derived from QVector<QPointF>
void QwtPlotCurve::setSamples (QwtSeriesData< QPointF > *data)¶
Assign a series of pointssetSamples() is just a wrapper for setData() without any additional value - beside that it is easier to find for the developer.
Parameters:
Warning:
void QwtPlotCurve::setStyle (CurveStylestyle)¶
Set the curve's drawing styleParameters:
See Also:
void QwtPlotCurve::setSymbol (QwtSymbol *symbol)¶
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:
See Also:
QwtPlotCurve::CurveStyle QwtPlotCurve::style () const¶
Returns:See Also:
const QwtSymbol * QwtPlotCurve::symbol () const¶
Returns:See Also:
bool QwtPlotCurve::testCurveAttribute (CurveAttributeattribute) const¶
Returns:See Also:
bool QwtPlotCurve::testLegendAttribute (LegendAttributeattribute) const¶
Returns:See Also:
bool QwtPlotCurve::testPaintAttribute (PaintAttributeattribute) const¶
Returns:See Also:
Author¶
Generated automatically by Doxygen for Qwt User's Guide from the source code.Thu Dec 11 2014 | Version 6.1.2 |