This class can be used to display data as a curve in the x-y plane. It supports different display styles, spline interpolation and symbols.
Definition at line 56 of file qwt_plot_curve.h.
Public Types | |
enum | CurveType { Yfx, Xfy } |
enum | CurveStyle { NoCurve, Lines, Sticks, Steps, Dots, UserCurve = 100 } |
enum | CurveAttribute { Inverted = 1, Fitted = 2 } |
enum | PaintAttribute { PaintCached = 1, PaintPacked = 2, PaintFiltered = 1, ClipPolygons = 2, PaintUsingTextFont = 1, PaintUsingTextColor = 2, PaintBackground = 4 } |
Public Member Functions | |
QwtPlotCurve () | |
QwtPlotCurve (const QwtText &title) | |
QwtPlotCurve (const QString &title) | |
virtual | ~QwtPlotCurve () |
virtual int | rtti () const |
void | setCurveType (CurveType) |
CurveType | curveType () const |
void | setPaintAttribute (PaintAttribute, bool on=true) |
bool | testPaintAttribute (PaintAttribute) const |
void | setRawData (const double *x, const double *y, int size) |
void | setData (const double *xData, const double *yData, int size) |
void | setData (const QwtArray< double > &xData, const QwtArray< double > &yData) |
void | setData (const QPolygonF &data) |
void | setData (const QwtData &data) |
int | closestPoint (const QPoint &pos, double *dist=NULL) const |
QwtData & | data () |
const QwtData & | data () const |
int | dataSize () const |
double | x (int i) const |
double | y (int i) const |
virtual QwtDoubleRect | boundingRect () 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 | draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &) const |
virtual void | draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const |
void | draw (int from, int to) const |
virtual void | updateLegend (QwtLegend *) const |
Protected Member Functions | |
void | init () |
virtual void | drawCurve (QPainter *p, int style, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const |
virtual void | drawSymbols (QPainter *p, const QwtSymbol &, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const |
void | drawLines (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const |
void | drawSticks (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const |
void | drawDots (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const |
void | drawSteps (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const |
void | fillCurve (QPainter *, const QwtScaleMap &, const QwtScaleMap &, QwtPolygon &) const |
void | closePolyline (const QwtScaleMap &, const QwtScaleMap &, QwtPolygon &) const |
Curve attributes.
Definition at line 85 of file qwt_plot_curve.h.
Paint attributes
Definition at line 95 of file qwt_plot_curve.h.
QwtPlotCurve::QwtPlotCurve | ( | ) | [explicit] |
QwtPlotCurve::QwtPlotCurve | ( | const QwtText & | title | ) | [explicit] |
Constructor
title | title of the curve |
Definition at line 267 of file qwt_plot_curve.cpp.
References init().
QwtPlotCurve::QwtPlotCurve | ( | const QString & | title | ) | [explicit] |
Constructor
title | title of the curve |
Definition at line 277 of file qwt_plot_curve.cpp.
References init().
QwtPlotCurve::~QwtPlotCurve | ( | ) | [virtual] |
int QwtPlotCurve::rtti | ( | ) | const [virtual] |
Reimplemented from QwtPlotItem.
Definition at line 305 of file qwt_plot_curve.cpp.
void QwtPlotCurve::setCurveType | ( | CurveType | curveType | ) |
Assign the curve type
QwtPlotCurve::Yfx Draws y as a function of x (the default). The baseline is interpreted as a horizontal line with y = baseline().
QwtPlotCurve::Xfy Draws x as a function of y. The baseline is interpreted as a vertical line with x = baseline().
The baseline is used for aligning the sticks, or filling the curve with a brush.
Definition at line 1130 of file qwt_plot_curve.cpp.
References QwtPlotItem::itemChanged().
QwtPlotCurve::CurveType QwtPlotCurve::curveType | ( | ) | const |
void QwtPlotCurve::setPaintAttribute | ( | PaintAttribute | attribute, | |
bool | on = true | |||
) |
Specify an attribute how to draw the curve.
The attributes can be used to modify the drawing algorithm.
The following attributes are defined:
The default is, that no paint attributes are enabled.
attribute | Paint attribute | |
on | On/Off /sa testPaintAttribute() |
Definition at line 333 of file qwt_plot_curve.cpp.
bool QwtPlotCurve::testPaintAttribute | ( | PaintAttribute | attribute | ) | const |
Return the current paint attributes.
Definition at line 345 of file qwt_plot_curve.cpp.
void QwtPlotCurve::setRawData | ( | const double * | xData, | |
const double * | yData, | |||
int | size | |||
) |
Initialize the data by pointing to memory blocks which are not managed by QwtPlotCurve.
setRawData 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 |
Definition at line 547 of file qwt_plot_curve.cpp.
References QwtPlotItem::itemChanged().
void QwtPlotCurve::setData | ( | const double * | xData, | |
const double * | yData, | |||
int | size | |||
) |
Set data by copying x- and y-values from specified memory blocks. Contrary to setCurveRawData(), 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 |
Definition at line 481 of file qwt_plot_curve.cpp.
References QwtPlotItem::itemChanged().
void QwtPlotCurve::setData | ( | const QwtArray< double > & | xData, | |
const QwtArray< double > & | yData | |||
) |
Initialize data with x- and y-arrays (explicitly shared).
xData | x data | |
yData | y data |
Definition at line 496 of file qwt_plot_curve.cpp.
References QwtPlotItem::itemChanged().
void QwtPlotCurve::setData | ( | const QPolygonF & | data | ) |
Initialize data with an array of points (explicitly shared).
data | Data |
Definition at line 513 of file qwt_plot_curve.cpp.
void QwtPlotCurve::setData | ( | const QwtData & | data | ) |
Initialize data with a pointer to QwtData.
data | Data |
Definition at line 527 of file qwt_plot_curve.cpp.
References QwtData::copy(), data(), and QwtPlotItem::itemChanged().
QwtData & QwtPlotCurve::data | ( | ) | [inline] |
Definition at line 217 of file qwt_plot_curve.h.
Referenced by setData().
const QwtData & QwtPlotCurve::data | ( | ) | const [inline] |
int QwtPlotCurve::dataSize | ( | ) | const |
Return the size of the data arrays
Definition at line 1332 of file qwt_plot_curve.cpp.
References QwtData::size().
Referenced by closestPoint(), draw(), and drawCurve().
double QwtPlotCurve::x | ( | int | i | ) | const [inline] |
i | index |
Definition at line 232 of file qwt_plot_curve.h.
References QwtData::x().
Referenced by closestPoint(), drawDots(), drawLines(), drawSteps(), drawSticks(), and drawSymbols().
double QwtPlotCurve::y | ( | int | i | ) | const [inline] |
i | index |
Definition at line 241 of file qwt_plot_curve.h.
References QwtData::y().
Referenced by closestPoint(), drawDots(), drawLines(), drawSteps(), drawSticks(), and drawSymbols().
QwtDoubleRect QwtPlotCurve::boundingRect | ( | ) | const [virtual] |
Returns the bounding rectangle of the curve data. If there is no bounding rect, like for empty data the rectangle is invalid.
Reimplemented from QwtPlotItem.
Definition at line 560 of file qwt_plot_curve.cpp.
References QwtData::boundingRect().
double QwtPlotCurve::minXValue | ( | ) | const [inline] |
boundingRect().left()
Definition at line 137 of file qwt_plot_curve.h.
References QwtPlotItem::boundingRect().
double QwtPlotCurve::maxXValue | ( | ) | const [inline] |
boundingRect().right()
Definition at line 139 of file qwt_plot_curve.h.
References QwtPlotItem::boundingRect().
double QwtPlotCurve::minYValue | ( | ) | const [inline] |
boundingRect().top()
Definition at line 141 of file qwt_plot_curve.h.
References QwtPlotItem::boundingRect().
double QwtPlotCurve::maxYValue | ( | ) | const [inline] |
boundingRect().bottom()
Definition at line 143 of file qwt_plot_curve.h.
References QwtPlotItem::boundingRect().
void QwtPlotCurve::setCurveAttribute | ( | CurveAttribute | attribute, | |
bool | on = true | |||
) |
Specify an attribute for drawing the curve.
The attributes can be used to modify the drawing style. The following attributes are defined:
attribute | Curve attribute | |
on | On/Off |
Definition at line 1092 of file qwt_plot_curve.cpp.
References QwtPlotItem::itemChanged().
bool QwtPlotCurve::testCurveAttribute | ( | CurveAttribute | attribute | ) | const |
Definition at line 1109 of file qwt_plot_curve.cpp.
Referenced by drawCurve().
void QwtPlotCurve::setPen | ( | const QPen & | pen | ) |
Assign a pen.
pen | New pen |
Definition at line 421 of file qwt_plot_curve.cpp.
References QwtPlotItem::itemChanged().
Referenced by QwtPlotPrintFilter::apply(), and QwtPlotPrintFilter::reset().
const QPen & QwtPlotCurve::pen | ( | ) | const |
Return the pen used to draw the lines.
Definition at line 434 of file qwt_plot_curve.cpp.
Referenced by QwtPlotPrintFilter::apply(), draw(), drawSymbols(), QwtPlotPrintFilter::reset(), and updateLegend().
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 |
Definition at line 451 of file qwt_plot_curve.cpp.
References QwtPlotItem::itemChanged().
const QBrush & QwtPlotCurve::brush | ( | ) | const |
Return the brush used to fill the area between lines and the baseline.
Definition at line 464 of file qwt_plot_curve.cpp.
void QwtPlotCurve::setBaseline | ( | double | reference | ) |
Set the value of the baseline.
The baseline is needed for filling the curve with a brush or the Sticks drawing style. The default value is 0.0. 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().
reference | baseline |
Definition at line 1310 of file qwt_plot_curve.cpp.
References QwtPlotItem::itemChanged().
double QwtPlotCurve::baseline | ( | ) | const |
Return the value of the baseline
Definition at line 1323 of file qwt_plot_curve.cpp.
void QwtPlotCurve::setStyle | ( | CurveStyle | style | ) |
Set the curve's drawing style.
Valid styles are:
Definition at line 377 of file qwt_plot_curve.cpp.
References QwtPlotItem::itemChanged().
QwtPlotCurve::CurveStyle QwtPlotCurve::style | ( | ) | const |
Return the current style.
Definition at line 390 of file qwt_plot_curve.cpp.
Referenced by updateLegend().
void QwtPlotCurve::setSymbol | ( | const QwtSymbol & | symbol | ) |
Assign a symbol.
symbol | Symbol |
Definition at line 400 of file qwt_plot_curve.cpp.
References QwtSymbol::clone(), QwtPlotItem::itemChanged(), and symbol().
Referenced by QwtPlotPrintFilter::apply(), and QwtPlotPrintFilter::reset().
const QwtSymbol & QwtPlotCurve::symbol | ( | ) | const |
Return the current symbol.
Definition at line 411 of file qwt_plot_curve.cpp.
Referenced by QwtPlotPrintFilter::apply(), drawSymbols(), QwtPlotPrintFilter::reset(), setSymbol(), and updateLegend().
void QwtPlotCurve::draw | ( | QPainter * | painter, | |
const QwtScaleMap & | xMap, | |||
const QwtScaleMap & | yMap, | |||
const QRect & | ||||
) | const [virtual] |
Draw the complete curve.
painter | Painter | |
xMap | Maps x-values into pixel coordinates. | |
yMap | Maps y-values into pixel coordinates. |
Implements QwtPlotItem.
Definition at line 577 of file qwt_plot_curve.cpp.
Referenced by draw().
void QwtPlotCurve::draw | ( | QPainter * | painter, | |
const QwtScaleMap & | xMap, | |||
const QwtScaleMap & | yMap, | |||
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. | |
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. |
Definition at line 687 of file qwt_plot_curve.cpp.
References dataSize(), drawCurve(), drawSymbols(), QwtPainter::metricsMap(), and pen().
void QwtPlotCurve::draw | ( | int | from, | |
int | to | |||
) | const |
Draw a set of points of a curve.
When observing an measurement while it is running, new points have to be added to an existing curve. drawCurve can be used to display them avoiding a complete redraw of the canvas.
Setting plot()->canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true); will result in faster painting, if the paint engine of the canvas widget supports this feature.
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. |
Definition at line 601 of file qwt_plot_curve.cpp.
References QwtPlot::canvas(), QwtPlot::canvasMap(), draw(), QwtPlotCanvas::paintCache(), QwtPlotItem::plot(), QwtPlotCanvas::testPaintAttribute(), QwtPlotItem::xAxis(), and QwtPlotItem::yAxis().
void QwtPlotCurve::updateLegend | ( | QwtLegend * | ) | const [virtual] |
Update the widget that represents the curve on the legend.
Reimplemented from QwtPlotItem.
Definition at line 1367 of file qwt_plot_curve.cpp.
References QwtLegend::displayPolicy(), QwtLegend::find(), QwtLegend::identifierMode(), QwtPlotItem::legendItem(), pen(), style(), symbol(), QwtPlotItem::title(), and QwtPlotItem::updateLegend().
void QwtPlotCurve::init | ( | ) | [protected] |
Initialize data members.
Definition at line 293 of file qwt_plot_curve.cpp.
References QwtPlotItem::setItemAttribute(), and QwtPlotItem::setZ().
Referenced by QwtPlotCurve().
void QwtPlotCurve::drawCurve | ( | QPainter * | painter, | |
int | style, | |||
const QwtScaleMap & | xMap, | |||
const QwtScaleMap & | yMap, | |||
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 | |
from | index of the first point to be painted | |
to | index of the last point to be painted |
Definition at line 742 of file qwt_plot_curve.cpp.
References dataSize(), drawDots(), drawLines(), drawSteps(), drawSticks(), and testCurveAttribute().
Referenced by draw().
void QwtPlotCurve::drawSymbols | ( | QPainter * | painter, | |
const QwtSymbol & | symbol, | |||
const QwtScaleMap & | xMap, | |||
const QwtScaleMap & | yMap, | |||
int | from, | |||
int | to | |||
) | const [protected, virtual] |
Draw symbols.
painter | Painter | |
symbol | Curve symbol | |
xMap | x map | |
yMap | y map | |
from | index of the first point to be painted | |
to | index of the last point to be painted |
Definition at line 1244 of file qwt_plot_curve.cpp.
References QwtSymbol::brush(), QwtSymbol::draw(), QwtPainter::metricsMap(), QwtSymbol::pen(), pen(), QwtMetricsMap::screenToLayout(), QwtMetricsMap::screenToLayoutX(), QwtSymbol::size(), symbol(), QwtScaleMap::transform(), x(), and y().
Referenced by draw().
void QwtPlotCurve::drawLines | ( | QPainter * | painter, | |
const QwtScaleMap & | xMap, | |||
const QwtScaleMap & | yMap, | |||
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 | |
from | index of the first point to be painted | |
to | index of the last point to be painted |
Definition at line 788 of file qwt_plot_curve.cpp.
References QwtPainter::drawPolyline(), fillCurve(), QwtScaleMap::transform(), x(), QwtScaleMap::xTransform(), and y().
Referenced by drawCurve().
void QwtPlotCurve::drawSticks | ( | QPainter * | painter, | |
const QwtScaleMap & | xMap, | |||
const QwtScaleMap & | yMap, | |||
int | from, | |||
int | to | |||
) | const [protected] |
Draw sticks
painter | Painter | |
xMap | x map | |
yMap | y map | |
from | index of the first point to be painted | |
to | index of the last point to be painted |
Definition at line 913 of file qwt_plot_curve.cpp.
References QwtPainter::drawLine(), QwtScaleMap::transform(), x(), and y().
Referenced by drawCurve().
void QwtPlotCurve::drawDots | ( | QPainter * | painter, | |
const QwtScaleMap & | xMap, | |||
const QwtScaleMap & | yMap, | |||
int | from, | |||
int | to | |||
) | const [protected] |
Draw dots
painter | Painter | |
xMap | x map | |
yMap | y map | |
from | index of the first point to be painted | |
to | index of the last point to be painted |
Definition at line 943 of file qwt_plot_curve.cpp.
References QwtPainter::drawPoint(), fillCurve(), QwtScaleMap::transform(), x(), and y().
Referenced by drawCurve().
void QwtPlotCurve::drawSteps | ( | QPainter * | painter, | |
const QwtScaleMap & | xMap, | |||
const QwtScaleMap & | yMap, | |||
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 | |
from | index of the first point to be painted | |
to | index of the last point to be painted |
Definition at line 1034 of file qwt_plot_curve.cpp.
References QwtPainter::drawPolyline(), fillCurve(), QwtScaleMap::transform(), x(), and y().
Referenced by drawCurve().
void QwtPlotCurve::fillCurve | ( | QPainter * | painter, | |
const QwtScaleMap & | xMap, | |||
const QwtScaleMap & | yMap, | |||
QwtPolygon & | pa | |||
) | const [protected] |
Fill the area between the curve and the baseline with the curve brush
painter | Painter | |
xMap | x map | |
yMap | y map | |
pa | Polygon |
Definition at line 1173 of file qwt_plot_curve.cpp.
References closePolyline(), and QwtPainter::drawPolygon().
Referenced by drawDots(), drawLines(), and drawSteps().
void QwtPlotCurve::closePolyline | ( | const QwtScaleMap & | xMap, | |
const QwtScaleMap & | yMap, | |||
QwtPolygon & | pa | |||
) | const [protected] |
Complete a polygon to be a closed polygon including the area between the original polygon and the baseline.
xMap | X map | |
yMap | Y map | |
pa | Polygon to be completed |
Definition at line 1207 of file qwt_plot_curve.cpp.
References QwtScaleMap::transform().
Referenced by fillCurve().