Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

QwtCurve Class Reference

A class which draws curves. More...

#include <qwt_curve.h>

Inheritance diagram for QwtCurve::

List of all members.

Public Types

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

Public Methods

 QwtCurve (const char *title=0)
 QwtCurve (const QwtCurve &c)
virtual ~QwtCurve ()
const QwtCurve & operator= (const QwtCurve &c)
void draw (QPainter *p, const QwtDiMap &xMap, const QwtDiMap &yMap)
void draw (QPainter *p, const QRect &r)
void draw (QPainter *p)
void drawIntv (QPainter *p, int i1, int i2)
void setData (double *x, double *y, int size)
void setData (double *x, double *y, double *e, int size)
void setMap (const QRect &r, double x1, double x2, bool xlog, double y1, double y2, bool ylog)
void setMap (const QwtDiMap &mx, const QwtDiMap &my)
void setOptions (int t)
void setPen (const QPen &p)
void setRange (double x1, double x2, bool xlog, double y1, double y2, bool ylog)
void setRawData (double *x, double *y, int size)
void setRawData (double *x, double *y, double *e, int size)
void setRect (const QRect &r)
void setBaseline (double ref)
void setStyle (CurveStyle cs, int options=0)
void setSymbol (const QwtSymbol &s)
void setSplineSize (int s)
void setTitle (const char *title)
double baseline () const
int dataSize () const
double minXValue () const
double maxXValue () const
double minYValue () const
double maxYValue () const
int options () const
const QPen & pen () const
int splineSize () const
CurveStyle style () const
const QwtSymbolsymbol () const
const QString & title () const
double x (int i) const
double y (int i) const
double e (int i) const

Protected Methods

virtual void curveChanged ()
int verifyRange (int &i1, int &i2)

Protected Attributes

QPen d_pen
QString d_title
QPointArray d_pa
QArray< double > d_x
QArray< double > d_y
QArray< double > d_e
int d_options
int d_splineSize

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 y and y data.
Data can be assigned in two ways:
  • setData() copies the x and y data from the specified arrays into its internal buffer.
  • setRawData() does not make a copy of the data, but only stores the pointers and size information instead. This function is less safe (you must not delete the data while they are attached), but more efficient, and more convenient if the data change dynamically.
B. Assign Properties
When a curve is created, it is configured to draw black solid lines with no symbols. You can change this by calling the setPen() and setSymbolY() members.
C. Assign y and y maps
Before a curve can be drawn, it has be mapped into a rectangle. This can either be done implicitly with the draw() member, or explicitly using setMap(const QRect &r, double x1, double x2, bool xlog, double y1, double y2, bool ylog) or setMap(const QwtDiMap &mx, const QwtDiMap& my) before drawing. The map can also be changed with the setRect() and setRange() members.
D. Draw
The draw(QPainter *p, const QwtDiMap &xMap, const QwtDiMap &yMap) member assumes that a curve has already been mapped. The draw(QPainter *p, const QRect &r) member draws the curve with specified y and y maps. The draw(QPainter *p) member draws the curve into a rectangle, thereby adjusting the curve's mapping.
Example:
see examples/curvdemo
See also:
QwtSymbol, QwtDiMap


Constructor & Destructor Documentation

QwtCurve::QwtCurve const char *    title = 0
 

Ctor.

Parameters:
title  title of the curve

QwtCurve::QwtCurve const QwtCurve &    c
 

Copy Constructor.

Warning:
If the c has attached its data in raw mode (see @QwtCurve::setRawData@), the copy constructor creates a deep copy of the data. The data are implicitly shared otherwise.

QwtCurve::~QwtCurve   [virtual]
 

Dtor.


Member Function Documentation

double QwtCurve::baseline   const
 

Return the value of the baseline.

See also:
QwtCurve::setBaseline

int QwtCurve::dataSize   const
 

Return the size of the data arrays.

void QwtCurve::draw QPainter *    p
 

Draw the curve.

Parameters:
p  Painter
Warning:
Before drawing, you have to assign a map using QwtCurve::setMap.

void QwtCurve::draw QPainter *    p,
const QRect &    r
 

Assign a bounding rectangle and draw the curve.

Parameters:
p  Painter
r  bounding rectangle
Warning:
This function changes the maps and overrides previous settings done by QwtCurve::setRect and QwtCurve::setMap.

void QwtCurve::draw QPainter *    p,
const QwtDiMap   xMap,
const QwtDiMap   yMap
 

Assign maps and draw the curve.

Parameters:
p  Painter
xMap  x map
yMap  y map
Warning:
This function changes the maps and overrides any previous settings done by setRect(), setRange(), setMap(const QRect &r, double x1, double x2, bool xlog, double y1, double y2, bool ylog), and setMap(const QwtDiMap &mx, const QwtDiMap& my).

void QwtCurve::drawIntv QPainter *    p,
int    imin,
int    imax
 

Draw a specified part of the curve.

Parameters:
p  Painter
imin  lower boundary of the interval
imax  upper boundary of the interval
Warning:
Drawing subintervals does not work with QwtCurve::Spline.

double QwtCurve::maxXValue   const
 

find the largest x value.

double QwtCurve::maxYValue   const
 

find the largest y value.

double QwtCurve::minXValue   const
 

find the smallest x value.

double QwtCurve::minYValue   const
 

find the smallest y value.

const QwtCurve & QwtCurve::operator= const QwtCurve &    c
 

Copy Assignment.

Warning:
If the c has attached its data in raw mode, the assignment operator creates a deep copy of the data. The data are implicitly shared otherwise.
See also:
setRawData()

int QwtCurve::options   const
 

Return the current style options.

See also:
QwtCurve::setOptions

const QPen& QwtCurve::pen   const
 

Return the pen used to draw the lines.

See also:
QwtCurve::setPen

void QwtCurve::setBaseline double    ref
 

Set the value of the baseline.

The baseline is needed for the QwtCurve::Sticks drawing style. The default value is 0.0. The interpretation of the baseline depends on the style options. With QwtCurve::Yfx, the baseline is interpreted as a horizontal line at y = baseline(), with QwtCurve::Yfy, it is interpreted as a vertical line at x = baseline().

Parameters:
ref  baseline
See also:
setStyle(), setOptions()

void QwtCurve::setData double *    x,
double *    y,
double *    e,
int    size
 

Copy x-y data and error data from specified arrays.

Parameters:
x  pointer to x data
y  pointer to y data
e  pointer to error data
data  size

void QwtCurve::setData double *    x,
double *    y,
int    size
 

Copy x-y data from specified arrays.

Parameters:
x  pointer to x data
y  pointer to y data
size  size of x and y

void QwtCurve::setMap const QwtDiMap   mx,
const QwtDiMap   my
 

Assign the maps for the x and y axes.

Parameters:
xmap  x map
ymap  y map
Warning:
This function overrides the settings of setRect() and setRange().

void QwtCurve::setMap const QRect &    r,
double    x1,
double    x2,
bool    xlog,
double    y1,
double    y2,
bool    ylog
 

Specify x and y ranges.

Parameters:
r  bounding rectangle
x1  left boundary of the x axis
x2  right boundary of the y axis
xlog  logarithmic x division if nonzero
y1  lower boundary of the y axis
y2  upper boundary of the y axis
ylog  logarithmic y division if nonzero
Warning:
This function overrides the settings of setRect() and setRange().

void QwtCurve::setOptions int    opt
 

Specify options for the drawing style.

The options can be used to modify the drawing style. Options can be or-combined. The following options are defined:

QwtCurve::Auto
The default setting. For QwtCurve::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.
QwtCurve::Yfx
Draws y as a function of x (the default). The baseline is interpreted as a horizontal line with y = baseline().
QwtCurve::Xfy
Draws x as a function of y. The baseline is interpreted as a vertical line with x = baseline().
QwtCurve::Parametric
For QwtCurve::Spline only. Draws a parametric spline.
QwtCurve::Periodic
For QwtCurve::Spline only. Draws a periodic spline.
QwtCurve::Inverted
For QwtCurve::Steps only. Draws a step function from the right to the left.
Parameters:
opt  new options

void QwtCurve::setPen const QPen &    p
 

Assign a pen.

Parameters:
p  New pen

void QwtCurve::setRange double    x1,
double    x2,
bool    xlog,
double    y1,
double    y2,
bool    ylog
 

Changes the data range of the map.

Parameters:
x1  lower boundary of the x range
x2  upper boundary of the x range
xlog  TRUE if x range is logarithmic
y1  lower boundary of the x range
y2  upper boundary of the y range
ylog  TRUE if y range is logarithmic
Warning:
This function is intended to be used in combination with setRect(). It modifies the maps and conflicts with setMap().

void QwtCurve::setRawData double *    x,
double *    y,
double *    e,
int    size
 

Attach arrays of x, y, and error data.

Parameters:
x  pointer to x data
y  pointer to y data
e  pointer to error data
data  size
See also:
QwtCurve::setRawData(double *x, double *y, int size)

void QwtCurve::setRawData double *    x,
double *    y,
int    size
 

Attach raw data.

setRawData is provided for efficiency. In contrast to setData, it does not copy the data, so it is important to keep the pointers valid while they are attached.

The QwtCurve destructor does not delete the attached data, so you can safely call setRawData and setData several times subsequently.

Parameters:
x  pointer to x data
y  pointer to y data
size  size of x and y

void QwtCurve::setRect const QRect &    r
 

Changes the drawing region of the map.

Parameters:
r  Bounding rectangle
Warning:
This function is intended to be used in combination with setRange(). It modifies the maps and conflicts with setMap()

void QwtCurve::setSplineSize int    s
 

Change the number of interpolated points.

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

void QwtCurve::setStyle CurveStyle    cs,
int    options = 0
 

Set the curve's drawing style.

Valid styles are:

QwtCurve::NoCurve
Don't draw a curve. Note: This doesn't affect the symbol.
QwtCurve::Lines
Connect the points with straight lines
QwtCurve::Sticks
Draw vertical sticks from a baseline which is defined by setBaseline().
QwtCurve::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.
QwtCurves::Dots
Draw dots at the locations of the data points. Note: This is different from a dotted line (see setPen()).
QwtCurve::Spline
Interpolate the points with a spline. The spline type can be specified with setOptions(), the size of the spline (= number of interpolated points) can be specified with setSplineSize().

void QwtCurve::setSymbol const QwtSymbol   s
 

Assign a symbol.

Parameters:
s  symbol
See also:
QwtSymbol

void QwtCurve::setTitle const char *    title
 

Assign a title to a curve.

Parameters:
title  new title

int QwtCurve::splineSize   const
 

Return the spline size.

See also:
QwtCurve::setSplineSize

CurveStyle QwtCurve::style   const
 

Return the current style.

See also:
QwtCurve::setStyle

int QwtCurve::verifyRange int &    i1,
int &    i2
[protected]
 

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

Parameters:
i1  Index 1
i2  Index 2


The documentation for this class was generated from the following files:
Generated on Mon Oct 22 18:38:31 2001 for Qwt User's Guide by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001