Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

QwtPlotCurve Class Reference

Inheritance diagram for QwtPlotCurve:

Inheritance graph
[legend]
Collaboration diagram for QwtPlotCurve:

Collaboration graph
[legend]
List of all members.

Detailed Description

A class which draws curves.

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.

Usage
A. Assign curve properties
When a curve is created, it is configured to draw black solid lines with QwtPlotCurve::Lines and no symbols. You can change this by calling QwtPlotCurve::setPen(), QwtPlotCurve::setStyle() and QwtPlotCurve::setSymbol().
B. Assign or change data.
Data can be set in two ways:
  • QwtPlotCurve::setData() is overloaded to initialize the x and y data by copying from different data structures with different kind of copy semantics.
  • QwtPlotCurve::setRawData() only stores the pointers and size information and is provided for backwards compatibility. This function is less safe (you must not delete the data while they are attached), but has been more efficient, and has been more convenient for dynamically changing data. Use of QwtPlotCurve::setData() in combination with a problem-specific subclass of QwtData is always preferrable.
C. Draw
QwtPlotCurve::draw() maps the data into pixel coordinates and paints them.
Example:
see examples/curvdemo
See also:
QwtData, QwtSymbol, QwtScaleMap

Definition at line 59 of file qwt_plot_curve.h.

Public Types

enum  CurveStyle {
  NoCurve,
  Lines,
  Sticks,
  Steps,
  Dots,
  Spline,
  UserCurve = 100
}
enum  CurveAttribute {
  Auto = 0,
  Yfx = 1,
  Xfy = 2,
  Parametric = 4,
  Periodic = 8,
  Inverted = 16
}

Public Member Functions

 QwtPlotCurve (const QString &title=QString::null)
 QwtPlotCurve (const QwtPlotCurve &c)
virtual ~QwtPlotCurve ()
const QwtPlotCurveoperator= (const QwtPlotCurve &c)
virtual int rtti () 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 QwtArray< QwtDoublePoint > &data)
void setData (const QwtData &data)
int closestPoint (const QPoint &pos, double *dist=NULL) const
QwtDatadata ()
const QwtDatadata () 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 setTitle (const QString &title)
const QString & title () 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 QwtSymbolsymbol () const
void setSplineSize (int s)
int splineSize () 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 (const QString &title)
void copy (const QwtPlotCurve &c)
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 drawSpline (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap) const
void fillCurve (QPainter *, const QwtScaleMap &, const QwtScaleMap &, QPointArray &) const
void closePolyline (const QwtScaleMap &, const QwtScaleMap &, QPointArray &) const
int verifyRange (int &i1, int &i2) const


Member Enumeration Documentation

enum QwtPlotCurve::CurveAttribute
 

Curve options.

See also:
QwtPlotCurve::setOptions

Definition at line 81 of file qwt_plot_curve.h.

enum QwtPlotCurve::CurveStyle
 

Curve styles.

See also:
QwtPlotCurve::setStyle

Definition at line 66 of file qwt_plot_curve.h.


Constructor & Destructor Documentation

QwtPlotCurve::QwtPlotCurve const QString &  title = QString::null  )  [explicit]
 

Ctor.

Parameters:
title title of the curve

Definition at line 126 of file qwt_plot_curve.cpp.

References init(), and title().

QwtPlotCurve::QwtPlotCurve const QwtPlotCurve c  )  [explicit]
 

Copy Constructor.

Definition at line 134 of file qwt_plot_curve.cpp.

References copy(), and init().

QwtPlotCurve::~QwtPlotCurve  )  [virtual]
 

Dtor.

Definition at line 142 of file qwt_plot_curve.cpp.


Member Function Documentation

double QwtPlotCurve::baseline  )  const
 

Return the value of the baseline.

See also:
QwtPlotCurve::setBaseline

Definition at line 1142 of file qwt_plot_curve.cpp.

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: QwtDoubleRect.isValid() == false

Reimplemented from QwtPlotItem.

Definition at line 425 of file qwt_plot_curve.cpp.

References QwtData::boundingRect().

const QBrush & QwtPlotCurve::brush  )  const
 

Return the brush used to fill the area between lines and the baseline.

See also:
QwtPlotCurve::setBrush, QwtPlotCurve::setBaseline, QwtPlotCurve::baseline

Definition at line 312 of file qwt_plot_curve.cpp.

References QwtSymbol::brush().

Referenced by setBrush().

void QwtPlotCurve::copy const QwtPlotCurve c  )  [protected]
 

Copy the contents of a curve into another curve.

Definition at line 167 of file qwt_plot_curve.cpp.

References QwtData::copy(), and QwtPlotItem::itemChanged().

Referenced by operator=(), and QwtPlotCurve().

const QwtData & QwtPlotCurve::data  )  const
 

the the curve data

Definition at line 219 of file qwt_plot_curve.h.

QwtData & QwtPlotCurve::data  ) 
 

the the curve data

Definition at line 213 of file qwt_plot_curve.h.

Referenced by setData().

int QwtPlotCurve::dataSize  )  const
 

Return the size of the data arrays

Definition at line 1150 of file qwt_plot_curve.cpp.

References QwtData::size().

Referenced by draw(), drawCurve(), drawSpline(), and verifyRange().

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.

Parameters:
key curve key
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:
QwtCurve::draw

Definition at line 473 of file qwt_plot_curve.cpp.

References QwtPlotCanvas::cache(), QwtPlot::canvas(), QwtPlot::canvasMap(), draw(), QwtPlotItem::plot(), QwtPlotCanvas::testPaintAttribute(), QwtPlotItem::xAxis(), and QwtPlotItem::yAxis().

void QwtPlotCurve::draw QPainter *  painter,
const QwtScaleMap xMap,
const QwtScaleMap yMap,
int  from,
int  to
const [virtual]
 

Draw an interval of the curve.

Parameters:
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.
See also:
QwtPlotCurve::drawCurve, QwtPlotCurve::drawDots, QwtPlotCurve::drawLines, QwtPlotCurve::drawSpline, QwtPlotCurve::drawSteps, QwtPlotCurve::drawSticks

Definition at line 581 of file qwt_plot_curve.cpp.

References dataSize(), drawCurve(), drawSymbols(), and verifyRange().

Referenced by draw().

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.

Parameters:
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
See also:
QwtPlotCurve::draw, QwtPlotCurve::drawDots, QwtPlotCurve::drawLines, QwtPlotCurve::drawSpline, QwtPlotCurve::drawSteps, QwtPlotCurve::drawSticks

Definition at line 626 of file qwt_plot_curve.cpp.

References dataSize(), drawDots(), drawLines(), drawSpline(), drawSteps(), and drawSticks().

Referenced by draw().

void QwtPlotCurve::drawDots QPainter *  painter,
const QwtScaleMap xMap,
const QwtScaleMap yMap,
int  from,
int  to
const [protected]
 

Draw dots.

Parameters:
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
See also:
QwtPlotCurve::drawPolyline, QwtPlotCurve::drawLine, QwtPlotCurve::drawLines, QwtPlotCurve::drawSpline, QwtPlotCurve::drawSteps QwtPlotCurve::drawPolyline, QwtPlotCurve::drawPolygon

Definition at line 725 of file qwt_plot_curve.cpp.

References QwtPainter::drawPoint(), x(), and y().

Referenced by drawCurve().

void QwtPlotCurve::drawLines QPainter *  painter,
const QwtScaleMap xMap,
const QwtScaleMap yMap,
int  from,
int  to
const [protected]
 

Draw lines.

Parameters:
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
See also:
QwtPlotCurve::draw, QwtPlotCurve::drawLines, QwtPlotCurve::drawDots, QwtPlotCurve::drawSpline, QwtPlotCurve::drawSteps, QwtPlotCurve::drawSticks

Definition at line 666 of file qwt_plot_curve.cpp.

References x(), and y().

Referenced by drawCurve(), and drawSpline().

void QwtPlotCurve::drawSpline QPainter *  painter,
const QwtScaleMap xMap,
const QwtScaleMap yMap
const [protected]
 

Draw a spline.

Parameters:
painter Painter
xMap x map
yMap y map
See also:
QwtPlotCurve::draw, QwtPlotCurve::drawCurve, QwtPlotCurve::drawDots, QwtPlotCurve::drawLines, QwtPlotCurve::drawSteps, QwtPlotCurve::drawSticks

Definition at line 800 of file qwt_plot_curve.cpp.

References dataSize(), drawLines(), qwtSqr(), QwtSpline::recalc(), splineSize(), QwtSpline::value(), 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.

Parameters:
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
See also:
QwtPlotCurve::draw, QwtPlotCurve::drawCurve, QwtPlotCurve::drawDots, QwtPlotCurve::drawLines, QwtPlotCurve::drawSpline, QwtPlotCurve::drawSticks

Definition at line 759 of file qwt_plot_curve.cpp.

References x(), and y().

Referenced by drawCurve().

void QwtPlotCurve::drawSticks QPainter *  painter,
const QwtScaleMap xMap,
const QwtScaleMap yMap,
int  from,
int  to
const [protected]
 

Draw sticks.

Parameters:
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
See also:
QwtPlotCurve::draw, QwtPlotCurve::drawCurve, QwtPlotCurve::drawDots, QwtPlotCurve::drawLines, QwtPlotCurve::drawSpline, QwtPlotCurve::drawSteps

Definition at line 695 of file qwt_plot_curve.cpp.

References QwtPainter::drawLine(), x(), and y().

Referenced by drawCurve().

void QwtPlotCurve::drawSymbols QPainter *  painter,
const QwtSymbol symbol,
const QwtScaleMap xMap,
const QwtScaleMap yMap,
int  from,
int  to
const [protected, virtual]
 

Draw symbols.

Parameters:
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 1096 of file qwt_plot_curve.cpp.

References QwtSymbol::brush(), QwtSymbol::draw(), QwtSymbol::pen(), QwtSymbol::size(), symbol(), x(), and y().

Referenced by draw().

void QwtPlotCurve::init const QString &  title  )  [protected]
 

Initialize data members.

Definition at line 151 of file qwt_plot_curve.cpp.

References title().

Referenced by QwtPlotCurve().

double QwtPlotCurve::maxXValue  )  const
 

boundingRect().right()

Definition at line 119 of file qwt_plot_curve.h.

double QwtPlotCurve::maxYValue  )  const
 

boundingRect().bottom()

Definition at line 123 of file qwt_plot_curve.h.

double QwtPlotCurve::minXValue  )  const
 

boundingRect().left()

Definition at line 117 of file qwt_plot_curve.h.

double QwtPlotCurve::minYValue  )  const
 

boundingRect().top()

Definition at line 121 of file qwt_plot_curve.h.

const QwtPlotCurve & QwtPlotCurve::operator= const QwtPlotCurve c  ) 
 

Copy Assignment.

Definition at line 184 of file qwt_plot_curve.cpp.

References copy().

const QPen & QwtPlotCurve::pen  )  const
 

Return the pen used to draw the lines.

See also:
QwtPlotCurve::setPen

Definition at line 281 of file qwt_plot_curve.cpp.

References QwtSymbol::pen().

void QwtPlotCurve::setBaseline double  reference  ) 
 

Set the value of the baseline.

The baseline is needed for filling the curve with a brush or the QwtPlotCurve::Sticks drawing style. The default value is 0.0. The interpretation of the baseline depends on the style options. 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().

Parameters:
reference baseline
See also:
QwtPlotCurve::setBrush(), QwtPlotCurve::setStyle(), QwtPlotCurve::setCurveAttribute()

Definition at line 1129 of file qwt_plot_curve.cpp.

References QwtPlotItem::itemChanged().

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:
brush New brush
See also:
QwtPlotCurve::brush, QwtPlotCurve::setBaseline, QwtPlotCurve::baseline

Definition at line 298 of file qwt_plot_curve.cpp.

References QwtSymbol::brush(), brush(), and QwtPlotItem::itemChanged().

void QwtPlotCurve::setCurveAttribute CurveAttribute  attribute,
bool  on = true
 

Specify an attribute for the drawing style.

The attributes can be used to modify the drawing style. The following attributes are defined:

QwtPlotCurve::Auto
The default setting. For QwtPlotCurve::spline, this means that the type of the spline is determined automatically, depending on the data. For all other styles, this means that y is regarded as a function of x.
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().
QwtPlotCurve::Parametric
For QwtPlotCurve::Spline only. Draws a parametric spline.
QwtPlotCurve::Periodic
For QwtPlotCurve::Spline only. Draws a periodic spline.
QwtPlotCurve::Inverted
For QwtPlotCurve::Steps only. Draws a step function from the right to the left.

Parameters:
opt Curve attribute
on On/Off /sa QwtPlotCurve::testCurveAttribute()

Definition at line 983 of file qwt_plot_curve.cpp.

References QwtPlotItem::itemChanged().

void QwtPlotCurve::setData const QwtData data  ) 
 

Initialize data with a pointer to QwtData.

Parameters:
data Data
See also:
QwtData::copy.

Definition at line 373 of file qwt_plot_curve.cpp.

References QwtData::copy(), data(), and QwtPlotItem::itemChanged().

void QwtPlotCurve::setData const QwtArray< QwtDoublePoint > &  data  ) 
 

Initialize data with an array of points (explicitly shared).

Parameters:
data Data
See also:
QwtDoublePointData::setData.

Definition at line 359 of file qwt_plot_curve.cpp.

References data(), and QwtPlotItem::itemChanged().

void QwtPlotCurve::setData const QwtArray< double > &  xData,
const QwtArray< double > &  yData
 

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

Parameters:
xData x data
yData y data
See also:
QwtData::setData.

Definition at line 344 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 QwtPlot::setCurveRawData, 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:
QwData::setData.

Definition at line 329 of file qwt_plot_curve.cpp.

References QwtPlotItem::itemChanged().

void QwtPlotCurve::setPen const QPen &  p  ) 
 

Assign a pen.

Parameters:
p New pen

Definition at line 268 of file qwt_plot_curve.cpp.

References QwtPlotItem::itemChanged(), and QwtSymbol::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.

Parameters:
xData pointer to x data
yData pointer to y data
size size of x and y
See also:
QwtCPointerData::setData.

Definition at line 393 of file qwt_plot_curve.cpp.

References QwtPlotItem::itemChanged().

void QwtPlotCurve::setSplineSize int  s  ) 
 

Change the number of interpolated points.

Parameters:
s new size
Warning:
The default is 250 points.

Definition at line 1010 of file qwt_plot_curve.cpp.

References QwtPlotItem::itemChanged().

void QwtPlotCurve::setStyle CurveStyle  style  ) 
 

Set the curve's drawing style.

Valid styles are:

QwtPlotCurve::NoCurve
Don't draw a curve. Note: This doesn't affect the symbol.
QwtPlotCurve::Lines
Connect the points with straight lines.
QwtPlotCurve::Sticks
Draw vertical sticks from a baseline which is defined by setBaseline().
QwtPlotCurve::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 'Inverted' option.
QwtPlotCurves::Dots
Draw dots at the locations of the data points. Note: This is different from a dotted line (see setPen()).
QwtPlotCurve::Spline
Interpolate the points with a spline. The spline type can be specified with setCurveAttribute(), the size of the spline (= number of interpolated points) can be specified with setSplineSize().
QwtPlotCurve::UserCurve ...
Styles >= QwtPlotCurve::UserCurve are reserved for derived classes of QwtPlotCurve that overload QwtPlotCurve::draw() with additional application specific curve types.
See also:
QwtPlotCurve::style()

Definition at line 225 of file qwt_plot_curve.cpp.

References QwtPlotItem::itemChanged(), and style().

void QwtPlotCurve::setSymbol const QwtSymbol s  ) 
 

Assign a symbol.

Parameters:
s symbol
See also:
QwtSymbol

Definition at line 249 of file qwt_plot_curve.cpp.

References QwtPlotItem::itemChanged().

void QwtPlotCurve::setTitle const QString &  title  ) 
 

Assign a title to a curve.

Parameters:
title new title

Definition at line 404 of file qwt_plot_curve.cpp.

References QwtPlotItem::itemChanged(), and title().

int QwtPlotCurve::splineSize  )  const
 

Return the spline size.

See also:
QwtPlotCurve::setSplineSize

Definition at line 1022 of file qwt_plot_curve.cpp.

Referenced by drawSpline().

QwtPlotCurve::CurveStyle QwtPlotCurve::style  )  const
 

Return the current style.

See also:
QwtPlotCurve::setStyle

Definition at line 239 of file qwt_plot_curve.cpp.

Referenced by setStyle().

const QwtSymbol & QwtPlotCurve::symbol  )  const
 

Return the current symbol.

See also:
QwtPlotCurve::setSymbol

Definition at line 259 of file qwt_plot_curve.cpp.

Referenced by drawSymbols().

bool QwtPlotCurve::testCurveAttribute CurveAttribute  attribute  )  const
 

Return the current style options.

See also:
QwtPlotCurve::setCurveAttribute

Definition at line 1000 of file qwt_plot_curve.cpp.

const QString & QwtPlotCurve::title  )  const
 

Return the title.

See also:
QwtPlotCurve::setTitle

Definition at line 414 of file qwt_plot_curve.cpp.

Referenced by init(), QwtPlotCurve(), and setTitle().

int QwtPlotCurve::verifyRange int &  i1,
int &  i2
const [protected]
 

Checks if a range of indices is valid and corrects it if necessary.

Parameters:
i1 Index 1
i2 Index 2

Definition at line 439 of file qwt_plot_curve.cpp.

References dataSize(), and qwtLim().

Referenced by draw().

double QwtPlotCurve::x int  i  )  const
 

Parameters:
i index
Returns:
x-value at position i

Definition at line 228 of file qwt_plot_curve.h.

References QwtData::x().

Referenced by drawDots(), drawLines(), drawSpline(), drawSteps(), drawSticks(), and drawSymbols().

double QwtPlotCurve::y int  i  )  const
 

Parameters:
i index
Returns:
y-value at position i

Definition at line 237 of file qwt_plot_curve.h.

References QwtData::y().

Referenced by drawDots(), drawLines(), drawSpline(), drawSteps(), drawSticks(), and drawSymbols().


Generated on Wed Aug 31 23:03:37 2005 for Qwt User's Guide by  doxygen 1.4.1