Qwt User's Guide 5.2.2
|
A plot item, that represents a series of points. More...
#include <qwt_plot_curve.h>
Public Types | |
enum | CurveAttribute { Inverted = 1, Fitted = 2 } |
enum | CurveStyle { NoCurve, Lines, Sticks, Steps, Dots, UserCurve = 100 } |
enum | CurveType { Yfx, Xfy } |
enum | ItemAttribute { Legend = 1, AutoScale = 2 } |
enum | PaintAttribute { PaintFiltered = 1, ClipPolygons = 2 } |
enum | RenderHint { RenderAntialiased = 1 } |
enum | RttiValues { Rtti_PlotItem = 0, Rtti_PlotGrid, Rtti_PlotScale, Rtti_PlotMarker, Rtti_PlotCurve, Rtti_PlotHistogram, Rtti_PlotSpectrogram, Rtti_PlotSVG, Rtti_PlotUserItem = 1000 } |
Public Member Functions | |
void | attach (QwtPlot *plot) |
double | baseline () const |
virtual QwtDoubleRect | boundingRect () const |
const QBrush & | brush () const |
int | closestPoint (const QPoint &pos, double *dist=NULL) const |
QwtCurveFitter * | curveFitter () const |
CurveType | curveType () const |
const QwtData & | data () const |
QwtData & | data () |
int | dataSize () const |
void | detach () |
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 |
void | hide () |
QwtDoubleRect | invTransform (const QwtScaleMap &, const QwtScaleMap &, const QRect &) const |
bool | isVisible () const |
virtual void | itemChanged () |
virtual QWidget * | legendItem () const |
double | maxXValue () const |
double | maxYValue () const |
double | minXValue () const |
double | minYValue () const |
QRect | paintRect (const QwtScaleMap &, const QwtScaleMap &) const |
const QPen & | pen () const |
QwtPlot * | plot () const |
QwtPlotCurve (const QwtText &title) | |
QwtPlotCurve () | |
QwtPlotCurve (const QString &title) | |
virtual int | rtti () const |
QwtDoubleRect | scaleRect (const QwtScaleMap &, const QwtScaleMap &) const |
void | setAxis (int xAxis, int yAxis) |
void | setBaseline (double ref) |
void | setBrush (const QBrush &) |
void | setCurveAttribute (CurveAttribute, bool on=true) |
void | setCurveFitter (QwtCurveFitter *) |
void | setCurveType (CurveType) |
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) |
void | setItemAttribute (ItemAttribute, bool on=true) |
void | setPaintAttribute (PaintAttribute, bool on=true) |
void | setPen (const QPen &) |
void | setRawData (const double *x, const double *y, int size) |
void | setRenderHint (RenderHint, bool on=true) |
void | setStyle (CurveStyle style) |
void | setSymbol (const QwtSymbol &s) |
void | setTitle (const QString &title) |
void | setTitle (const QwtText &title) |
virtual void | setVisible (bool) |
void | setXAxis (int axis) |
void | setYAxis (int axis) |
void | setZ (double z) |
void | show () |
CurveStyle | style () const |
const QwtSymbol & | symbol () const |
bool | testCurveAttribute (CurveAttribute) const |
bool | testItemAttribute (ItemAttribute) const |
bool | testPaintAttribute (PaintAttribute) const |
bool | testRenderHint (RenderHint) const |
const QwtText & | title () const |
QRect | transform (const QwtScaleMap &, const QwtScaleMap &, const QwtDoubleRect &) const |
virtual void | updateLegend (QwtLegend *) const |
virtual void | updateScaleDiv (const QwtScaleDiv &, const QwtScaleDiv &) |
double | x (int i) const |
int | xAxis () const |
double | y (int i) const |
int | yAxis () const |
double | z () const |
virtual | ~QwtPlotCurve () |
Protected Member Functions | |
void | closePolyline (const QwtScaleMap &, const QwtScaleMap &, QwtPolygon &) const |
virtual void | drawCurve (QPainter *p, int style, 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 | drawLines (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 | drawSticks (QPainter *p, 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 | fillCurve (QPainter *, const QwtScaleMap &, const QwtScaleMap &, QwtPolygon &) const |
void | init () |
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.
Curve type.
The baseline is used for aligning the sticks, or filling the curve with a brush.
enum QwtPlotItem::ItemAttribute [inherited] |
Plot Item Attributes
Attributes to modify the drawing algorithm.
The default is, that no paint attributes are enabled.
enum QwtPlotItem::RenderHint [inherited] |
Render hints.
enum QwtPlotItem::RttiValues [inherited] |
Runtime type information.
RttiValues is used to cast plot items, without having to enable runtime type information of the compiler.
QwtPlotCurve::QwtPlotCurve | ( | ) | [explicit] |
Constructor.
QwtPlotCurve::QwtPlotCurve | ( | const QwtText & | title | ) | [explicit] |
Constructor
title | Title of the curve |
QwtPlotCurve::QwtPlotCurve | ( | const QString & | title | ) | [explicit] |
Constructor
title | Title of the curve |
QwtPlotCurve::~QwtPlotCurve | ( | ) | [virtual] |
Destructor.
void QwtPlotItem::attach | ( | QwtPlot * | plot | ) | [inherited] |
Attach the item to a plot.
This method will attach a QwtPlotItem to the QwtPlot argument. It will first detach the QwtPlotItem from any plot from a previous call to attach (if necessary). If a NULL argument is passed, it will detach from any QwtPlot it was attached to.
plot | Plot widget |
double QwtPlotCurve::baseline | ( | ) | const |
Return the value of the baseline
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.
const QBrush & QwtPlotCurve::brush | ( | ) | const |
Return the brush used to fill the area between lines and the baseline.
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 |
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.
QwtPlotCurve::CurveType QwtPlotCurve::curveType | ( | ) | const |
Return the curve type
QwtData & QwtPlotCurve::data | ( | ) | [inline] |
const QwtData & QwtPlotCurve::data | ( | ) | const [inline] |
int QwtPlotCurve::dataSize | ( | ) | const |
Return the size of the data arrays
void QwtPlotItem::detach | ( | ) | [inline, inherited] |
This method detaches a QwtPlotItem from any QwtPlot it has been associated with.
detach() is equivalent to calling attach( NULL )
void QwtPlotCurve::draw | ( | QPainter * | painter, |
const QwtScaleMap & | xMap, | ||
const QwtScaleMap & | yMap, | ||
const QRect & | canvasRect | ||
) | const [virtual] |
Draw the complete curve.
painter | Painter |
xMap | Maps x-values into pixel coordinates. |
yMap | Maps y-values into pixel coordinates. |
Implements QwtPlotItem.
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. |
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. |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
void QwtPlotItem::hide | ( | ) | [inherited] |
Hide the item.
void QwtPlotCurve::init | ( | ) | [protected] |
Initialize data members.
QwtDoubleRect QwtPlotItem::invTransform | ( | const QwtScaleMap & | xMap, |
const QwtScaleMap & | yMap, | ||
const QRect & | rect | ||
) | const [inherited] |
Transform a rectangle from paint to scale coordinates
xMap | X map |
yMap | Y map |
rect | Rectangle in paint coordinates |
bool QwtPlotItem::isVisible | ( | ) | const [inherited] |
void QwtPlotItem::itemChanged | ( | ) | [virtual, inherited] |
Update the legend and call QwtPlot::autoRefresh for the parent plot.
QWidget * QwtPlotItem::legendItem | ( | ) | const [virtual, inherited] |
Allocate the widget that represents the item on the legend.
The default implementation is made for QwtPlotCurve and returns a QwtLegendItem(), but an item could be represented by any type of widget, by overloading legendItem() and updateLegend().
Implements QwtLegendItemManager.
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()
QRect QwtPlotItem::paintRect | ( | const QwtScaleMap & | xMap, |
const QwtScaleMap & | yMap | ||
) | const [inherited] |
Calculate the bounding paint rect of 2 maps.
xMap | X map |
yMap | X map |
const QPen & QwtPlotCurve::pen | ( | ) | const |
QwtPlot * QwtPlotItem::plot | ( | ) | const [inherited] |
Return attached plot.
int QwtPlotCurve::rtti | ( | ) | const [virtual] |
Reimplemented from QwtPlotItem.
QwtDoubleRect QwtPlotItem::scaleRect | ( | const QwtScaleMap & | xMap, |
const QwtScaleMap & | yMap | ||
) | const [inherited] |
Calculate the bounding scale rect of 2 maps.
xMap | X map |
yMap | X map |
void QwtPlotItem::setAxis | ( | int | xAxis, |
int | yAxis | ||
) | [inherited] |
Set X and Y axis
The item will painted according to the coordinates its Axes.
xAxis | X Axis |
yAxis | Y Axis |
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 |
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 setCurveFitter(NULL) disables curve fitting.
curveFitter | Curve fitter |
void QwtPlotCurve::setCurveType | ( | CurveType | curveType | ) |
void QwtPlotCurve::setData | ( | const QPolygonF & | data | ) |
Initialize data with an array of points (explicitly shared).
data | Data |
void QwtPlotCurve::setData | ( | const QwtArray< double > & | xData, |
const QwtArray< double > & | yData | ||
) |
Initialize data with x- and y-arrays (explicitly shared) ( Builds an QwtArrayData object internally )
xData | x data |
yData | y data |
void QwtPlotCurve::setData | ( | const QwtData & | data | ) |
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 |
void QwtPlotItem::setItemAttribute | ( | ItemAttribute | attribute, |
bool | on = true |
||
) | [inherited] |
Toggle an item attribute
attribute | Attribute type |
on | true/false |
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 | ) |
Assign a pen
The width of non cosmetic pens is scaled according to the resolution of the paint device.
pen | New pen |
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 |
void QwtPlotItem::setRenderHint | ( | RenderHint | hint, |
bool | on = true |
||
) | [inherited] |
Toggle an render hint
hint | Render hint |
on | true/false |
void QwtPlotCurve::setStyle | ( | CurveStyle | style | ) |
void QwtPlotCurve::setSymbol | ( | const QwtSymbol & | symbol | ) |
void QwtPlotItem::setTitle | ( | const QwtText & | title | ) | [inherited] |
void QwtPlotItem::setTitle | ( | const QString & | title | ) | [inherited] |
void QwtPlotItem::setVisible | ( | bool | on | ) | [virtual, inherited] |
void QwtPlotItem::setXAxis | ( | int | axis | ) | [inherited] |
Set the X axis
The item will painted according to the coordinates its Axes.
axis | X Axis |
void QwtPlotItem::setYAxis | ( | int | axis | ) | [inherited] |
Set the Y axis
The item will painted according to the coordinates its Axes.
axis | Y Axis |
void QwtPlotItem::setZ | ( | double | z | ) | [inherited] |
Set the z value.
Plot items are painted in increasing z-order.
z | Z-value |
void QwtPlotItem::show | ( | ) | [inherited] |
Show the item.
QwtPlotCurve::CurveStyle QwtPlotCurve::style | ( | ) | const |
Return the current style
const QwtSymbol & QwtPlotCurve::symbol | ( | ) | const |
Return the current symbol.
bool QwtPlotCurve::testCurveAttribute | ( | CurveAttribute | attribute | ) | const |
bool QwtPlotItem::testItemAttribute | ( | ItemAttribute | attribute | ) | const [inherited] |
Test an item attribute
attribute | Attribute type |
bool QwtPlotCurve::testPaintAttribute | ( | PaintAttribute | attribute | ) | const |
Return the current paint attributes.
bool QwtPlotItem::testRenderHint | ( | RenderHint | hint | ) | const [inherited] |
Test a render hint
hint | Render hint |
const QwtText & QwtPlotItem::title | ( | ) | const [inherited] |
QRect QwtPlotItem::transform | ( | const QwtScaleMap & | xMap, |
const QwtScaleMap & | yMap, | ||
const QwtDoubleRect & | rect | ||
) | const [inherited] |
Transform a rectangle
xMap | X map |
yMap | Y map |
rect | Rectangle in scale coordinates |
void QwtPlotCurve::updateLegend | ( | QwtLegend * | legend | ) | const [virtual] |
Update the widget that represents the curve on the legend.
Reimplemented from QwtPlotItem.
void QwtPlotItem::updateScaleDiv | ( | const QwtScaleDiv & | , |
const QwtScaleDiv & | |||
) | [virtual, inherited] |
Update the item to changes of the axes scale division.
Update the item, when the axes of plot have changed. The default implementation does nothing, but items that depend on the scale division (like QwtPlotGrid()) have to reimplement updateScaleDiv()
xScaleDiv | Scale division of the x-axis |
yScaleDiv | Scale division of the y-axis |
Reimplemented in QwtPlotGrid, and QwtPlotScaleItem.
double QwtPlotCurve::x | ( | int | i | ) | const [inline] |
i | index |
int QwtPlotItem::xAxis | ( | ) | const [inherited] |
Return xAxis.
double QwtPlotCurve::y | ( | int | i | ) | const [inline] |
i | index |
int QwtPlotItem::yAxis | ( | ) | const [inherited] |
Return yAxis.
double QwtPlotItem::z | ( | ) | const [inherited] |
Plot items are painted in increasing z-order.