A plot item, that represents a series of points. More...
#include <qwt_plot_curve.h>
Public Types | |
enum | CurveStyle { NoCurve, Lines, Sticks, Steps, Dots, UserCurve = 100 } |
enum | CurveAttribute { Inverted = 1, Fitted = 2 } |
enum | LegendAttribute { LegendShowLine = 1, LegendShowSymbol = 2, LegendShowBrush = 4 } |
enum | PaintAttribute { ClipPolygons = 1, CacheSymbols = 2 } |
Public Member Functions | |
QwtPlotCurve (const QString &title=QString::null) | |
QwtPlotCurve (const QwtText &title) | |
virtual | ~QwtPlotCurve () |
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) |
void | setSamples (const double *xData, const double *yData, int size) |
void | setSamples (const QVector< double > &xData, const QVector< double > &yData) |
void | setSamples (const QVector< QPointF > &) |
int | closestPoint (const QPoint &pos, double *dist=NULL) const |
double | minXValue () const |
double | maxXValue () const |
double | minYValue () const |
double | maxYValue () const |
void | setCurveAttribute (CurveAttribute, bool on=true) |
bool | testCurveAttribute (CurveAttribute) const |
void | setPen (const QPen &) |
const QPen & | pen () const |
void | setBrush (const QBrush &) |
const QBrush & | brush () const |
void | setBaseline (double ref) |
double | baseline () const |
void | setStyle (CurveStyle style) |
CurveStyle | style () const |
void | setSymbol (const QwtSymbol *s) |
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 void | updateLegend (QwtLegend *) const |
virtual void | drawLegendIdentifier (QPainter *, const QRectF &) const |
Protected Member Functions | |
void | init () |
virtual void | drawCurve (QPainter *p, int style, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const |
virtual void | drawSymbols (QPainter *p, const QwtSymbol &, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const |
void | drawLines (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const |
void | drawSticks (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const |
void | drawDots (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const |
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 &, QPolygonF &) const |
void | closePolyline (QPainter *, const QwtScaleMap &, const QwtScaleMap &, QPolygonF &) const |
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.
Attribute for drawing the curve
Curve styles.
Attributes how to represent the curve on the legend
If none of the flags is activated QwtPlotCurve tries to find a color representing the curve and paints a rectangle with it. In the default setting all attributes are off.
Attributes to modify the drawing algorithm.
The default setting enables ClipPolygons
QwtPlotCurve::QwtPlotCurve | ( | const QString & | title = QString::null |
) | [explicit] |
Constructor
title | Title of the curve |
QwtPlotCurve::QwtPlotCurve | ( | const QwtText & | title | ) | [explicit] |
Constructor
title | Title of the curve |
QwtPlotCurve::~QwtPlotCurve | ( | ) | [virtual] |
Destructor.
double QwtPlotCurve::baseline | ( | ) | const |
const QBrush & QwtPlotCurve::brush | ( | ) | const |
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.
painter | Painter | |
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 position
pos | Position, where to look for the closest curve point | |
dist | If dist != NULL, closestPoint() returns the distance between the position and the clostest curve point |
QwtCurveFitter * QwtPlotCurve::curveFitter | ( | ) | const |
Get the curve fitter. If curve fitting is disabled NULL is returned.
void QwtPlotCurve::drawCurve | ( | QPainter * | painter, | |
int | style, | |||
const QwtScaleMap & | xMap, | |||
const QwtScaleMap & | yMap, | |||
const QRectF & | canvasRect, | |||
int | from, | |||
int | to | |||
) | const [protected, virtual] |
Draw the line part (without symbols) of a curve interval.
painter | Painter | |
style | curve style, see QwtPlotCurve::CurveStyle | |
xMap | x map | |
yMap | y map | |
canvasRect | Contents rect of the canvas | |
from | index of the first point to be painted | |
to | index of the last point to be painted |
void QwtPlotCurve::drawDots | ( | QPainter * | painter, | |
const QwtScaleMap & | xMap, | |||
const QwtScaleMap & | yMap, | |||
const QRectF & | canvasRect, | |||
int | from, | |||
int | to | |||
) | const [protected] |
Draw dots
painter | Painter | |
xMap | x map | |
yMap | y map | |
canvasRect | Contents rect of the canvas | |
from | index of the first point to be painted | |
to | index of the last point to be painted |
void QwtPlotCurve::drawLegendIdentifier | ( | QPainter * | painter, | |
const QRectF & | rect | |||
) | const [virtual] |
Draw the identifier representing the curve on the legend.
painter | Üainter | |
rect | Bounding rectangle for the identifier |
Reimplemented from QwtLegendItemManager.
void QwtPlotCurve::drawLines | ( | QPainter * | painter, | |
const QwtScaleMap & | xMap, | |||
const QwtScaleMap & | yMap, | |||
const QRectF & | canvasRect, | |||
int | from, | |||
int | to | |||
) | const [protected] |
Draw lines.
If the CurveAttribute Fitted is enabled a QwtCurveFitter tries to interpolate/smooth the curve, before it is painted.
painter | Painter | |
xMap | x map | |
yMap | y map | |
canvasRect | Contents rect of the canvas | |
from | index of the first point to be painted | |
to | index of the last point to be painted |
void QwtPlotCurve::drawSeries | ( | QPainter * | painter, | |
const QwtScaleMap & | xMap, | |||
const QwtScaleMap & | yMap, | |||
const QRectF & | canvasRect, | |||
int | from, | |||
int | to | |||
) | const [virtual] |
Draw an interval of the curve
painter | Painter | |
xMap | Maps x-values into pixel coordinates. | |
yMap | Maps y-values into pixel coordinates. | |
canvasRect | Contents rect 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. |
Implements QwtPlotAbstractSeriesItem.
void QwtPlotCurve::drawSteps | ( | QPainter * | painter, | |
const QwtScaleMap & | xMap, | |||
const QwtScaleMap & | yMap, | |||
const QRectF & | canvasRect, | |||
int | from, | |||
int | to | |||
) | const [protected] |
Draw step function
The direction of the steps depends on Inverted attribute.
painter | Painter | |
xMap | x map | |
yMap | y map | |
canvasRect | Contents rect of the canvas | |
from | index of the first point to be painted | |
to | index of the last point to be painted |
void QwtPlotCurve::drawSticks | ( | QPainter * | painter, | |
const QwtScaleMap & | xMap, | |||
const QwtScaleMap & | yMap, | |||
const QRectF & | canvasRect, | |||
int | from, | |||
int | to | |||
) | const [protected] |
Draw sticks
painter | Painter | |
xMap | x map | |
yMap | y map | |
canvasRect | Contents rect of the canvas | |
from | index of the first point to be painted | |
to | index of the last point to be painted |
void QwtPlotCurve::drawSymbols | ( | QPainter * | painter, | |
const QwtSymbol & | symbol, | |||
const QwtScaleMap & | xMap, | |||
const QwtScaleMap & | yMap, | |||
const QRectF & | canvasRect, | |||
int | from, | |||
int | to | |||
) | const [protected, virtual] |
Draw symbols
painter | Painter | |
symbol | Curve symbol | |
xMap | x map | |
yMap | y map | |
canvasRect | Contents rect of the canvas | |
from | Index of the first point to be painted | |
to | Index of the last point to be painted |
void QwtPlotCurve::fillCurve | ( | QPainter * | painter, | |
const QwtScaleMap & | xMap, | |||
const QwtScaleMap & | yMap, | |||
QPolygonF & | polygon | |||
) | const [protected, virtual] |
Fill the area between the curve and the baseline with the curve brush
painter | Painter | |
xMap | x map | |
yMap | y map | |
polygon | Polygon |
void QwtPlotCurve::init | ( | ) | [protected] |
Initialize internal members.
double QwtPlotCurve::maxXValue | ( | ) | const [inline] |
boundingRect().right()
double QwtPlotCurve::maxYValue | ( | ) | const [inline] |
boundingRect().bottom()
double QwtPlotCurve::minXValue | ( | ) | const [inline] |
boundingRect().left()
double QwtPlotCurve::minYValue | ( | ) | const [inline] |
boundingRect().top()
const QPen & QwtPlotCurve::pen | ( | ) | const |
int QwtPlotCurve::rtti | ( | ) | const [virtual] |
Reimplemented from QwtPlotItem.
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 CurveType. With QwtPlotCurve::Yfx, the baseline is interpreted as a horizontal line at y = baseline(), with QwtPlotCurve::Yfy, it is interpreted as a vertical line at x = baseline().
The default value is 0.0.
value | Value of the baseline |
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).
brush | New brush |
void QwtPlotCurve::setCurveAttribute | ( | CurveAttribute | attribute, | |
bool | on = true | |||
) |
Specify an attribute for drawing the curve
attribute | Curve attribute | |
on | On/Off |
/sa CurveAttribute, testCurveAttribute(), setCurveFitter()
void QwtPlotCurve::setCurveFitter | ( | QwtCurveFitter * | curveFitter | ) |
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.
curveFitter() | Curve fitter |
void QwtPlotCurve::setLegendAttribute | ( | LegendAttribute | attribute, | |
bool | on = true | |||
) |
Specify an attribute how to draw the legend identifier
attribute | Attribute | |
on | On/Off /sa LegendAttribute, testLegendAttribute() |
void QwtPlotCurve::setPaintAttribute | ( | PaintAttribute | attribute, | |
bool | on = true | |||
) |
Specify an attribute how to draw the curve
attribute | Paint attribute | |
on | On/Off /sa PaintAttribute, testPaintAttribute() |
void QwtPlotCurve::setPen | ( | const QPen & | pen | ) |
void QwtPlotCurve::setRawSamples | ( | const double * | xData, | |
const double * | yData, | |||
int | size | |||
) |
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.
xData | pointer to x data | |
yData | pointer to y data | |
size | size of x and y |
void QwtPlotCurve::setSamples | ( | const QVector< QPointF > & | samples | ) |
Initialize data with an array of points (explicitly shared).
samples | Vector of points |
void QwtPlotCurve::setSamples | ( | const QVector< double > & | xData, | |
const QVector< double > & | yData | |||
) |
Initialize data with x- and y-arrays (explicitly shared).
xData | x data | |
yData | y data |
void QwtPlotCurve::setSamples | ( | const double * | xData, | |
const double * | yData, | |||
int | size | |||
) |
Set data by copying x- and y-values from specified memory blocks. Contrary to setRawSamples(), this function makes a 'deep copy' of the data.
xData | pointer to x values | |
yData | pointer to y values | |
size | size of xData and yData |
void QwtPlotCurve::setStyle | ( | CurveStyle | style | ) |
void QwtPlotCurve::setSymbol | ( | const QwtSymbol * | symbol | ) |
QwtPlotCurve::CurveStyle QwtPlotCurve::style | ( | ) | const |
Return the current style
const QwtSymbol * QwtPlotCurve::symbol | ( | ) | const |
bool QwtPlotCurve::testCurveAttribute | ( | CurveAttribute | attribute | ) | const |
bool QwtPlotCurve::testLegendAttribute | ( | LegendAttribute | attribute | ) | const |
Return the current paint attributes.
bool QwtPlotCurve::testPaintAttribute | ( | PaintAttribute | attribute | ) | const |
Return the current paint attributes.
void QwtPlotCurve::updateLegend | ( | QwtLegend * | legend | ) | const [virtual] |
Update the widget that represents the item on the legend.
legend | Legend |
Reimplemented from QwtPlotItem.