Qwt Programmer's Manual

QwtCurve


NAME

QwtCurve - A class which draws curves

DESCRIPTION

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:

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 (2) member, or explicitly using setMap (1) or setMap (2) before drawing. The map can also be changed with the setRect and setRange members.

D. Draw

The draw (1) member assumes that a curve has already been mapped. The draw (2) member draws the curve with specified y and y maps. The draw (3) member draws the curve into a rectangle, thereby adjusting the curve's mapping.

PUBLIC MEMBERS

draw (1)
Draw the curve
draw (2)
Assign maps and raw the curve
draw (3)
Assign a bounding rectangle and draw the curve
drawIntv
Draw a specified part of the curve
QwtCurve (1)
Constructor
QwtCurve (2)
Constructor
~QwtCurve
Destructor
operator=
Assignment operator
setData
Copy data from arrays
setMap (1)
Assign maps
setMap (2)
Assign maps
setOptions
Specify style options
setPen
Assign a pen
setRange
Specify a range
setRawData
Attach arrays
setRect
Specify drawing region
setBaseline
Set baseline to value
setStyle
Set style
setSymbol
Assign a symbol
setSplineSize
Change Spline size
setTitle
Assign a title
dataSize
Return data size
minXValue
Return smallest x value
minYValue
Return smallest y value
maxXValue
Return greatest x value
maxYValue
Return greatest y value
options
Return style options
pen
Return pen
baseline
Return value of the baseline
splineSize
Return spline size
style
Return style
symbol
Return symbol
title
Return title
x
Return x value with specified index
y
Return y value with specified index

Protected members

curveChanged
Called when properties have been changed (virtual)
verifyRange
Correct a specified range if invalid

See also

QwtSymbol, QwtDiMap

EXAMPLE

see examples/curvdemo

MEMBER FUNCTION DESCRIPTION


QwtCurve::~QwtCurve

Destructor

Syntax

QwtCurve::~QwtCurve()

QwtCurve::QwtCurve

Copy Constructor

Syntax

QwtCurve::QwtCurve(const QwtCurve &c)

Note

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

QwtCurve::operator=

Assignment operator

Syntax

const QwtCurve & QwtCurve::operator=(const QwtCurve &)

Note

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

QwtCurve::setStyle

Set the curve's drawing style

Syntax

void QwtCurve::setStyle(CurveStyle cs, int options)

Parameters

QwtCurve::CurveStyle cs

Description

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.

QwtCurve::setSymbol

Assign a symbol

Syntax

void QwtCurve::setSymbol(const QwtSymbol &s )

Parameters:

const QwtSymbol &s
symbol

See also

QwtSymbol

QwtCurve::setPen

Assign a pen

Syntax

void QwtCurve::setPen(const QwtPen &p)

Parameters

const QPen &p
New pen

QwtCurve::setData

Copy x-y data from specified arrays

Syntax

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

Parameters

double *x, double *y
x and y data arrays
int size
size of x and y

QwtCurve::setRawData

Attach raw data

Syntax

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

Parameters

double *x, double *y
x and y data arrays
int size
size of y and y

Description

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.

QwtCurve::setTitle

Assign a title to a curve

Syntax

void QwtCurve::setTitle(const char *title)

Parameters

const char *title

QwtCurve::minXValue

find the smallest x value

Syntax

double QwtCurve::minXValue() const

QwtCurve::minYValue

find the smallest y value

Syntax

double QwtCurve::minYValue() const

QwtCurve::maxXValue

Find the largest x value

Syntax

double QwtCurve::maxXValue() const

QwtCurve::maxYValue

Find the largest y value

Syntax

double QwtCurve::maxYValue() const

QwtCurve::QwtCurve

Constructor

Syntax

QwtCurve::QwtCurve(const char *title)

Parameters

const char *title
title of the curve

QwtCurve::verifyRange

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

Syntax

int QwtCurve::verifyRange(int &i1, int &i2)

Parameters

int &i1, int &i2

QwtCurve::draw (2)

Assign maps and draw the curve

Syntax

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

Parameters

QPainter *p, const QwtDiMap &xMap, const QwtDiMap &yMap

Note

This function changes the maps and overrides any previous settings done by setRect, setRange, setMap (1), and setMap (2).

QwtCurve::draw (1)

Draw the curve

Syntax

void QwtCurve::draw(QPainter *p)

Parameters

QPainter *p
Painter

Note

Before drawing, you have to assign a map using setMap (1) or setMap (2).

QwtCurve::drawIntv

Draw a specified part of the curve

Syntax

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

Parameters

QPainter *p
Painter
int imin, int imax
Interval boundaries as indices of the data arrays. The subset to be drawn includes both boundaries.

Bugs

Drawing subintervals does not work with QwtCurve::Spline.

QwtCurve::draw (3)

Assign a bounding rectangle and draw the curve

Syntax

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

Parameters

QPainter *p
Painter
const QRect &r
Bounding rectangle

Note

This function changes the maps and overrides previous settings done by setRect, setMap (1), and setMap (2).

QwtCurve::setOptions

Specify options for the drawing style

Syntax

void QwtCurve::setOptions(int opt)

Parameters

int opt
new options

Description

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.

QwtCurve::setSplineSize

Change the number of interpolated points

Syntax

void QwtCurve::setSplineSize(int s)

Parameters

int s
new size

Note

The default is 250 points.

QwtCurve::setMap (2)

Specify x and y ranges

Syntax

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

Parameters

const QRect &r
bounding rectangle
double x1
left boundary of the x axis
double x2
right boundary of the y axis
bool xlog
logarithmic x division if nonzero
double y1
lower boundary of the y axis
double y2
upper boundary of the y axis
bool ylog
logarithmic y division if nonzero

Note

This function overrides the settings of setRect and setRange.

QwtCurve::setRect

Changes the drawing region of the map.

Syntax

void QwtCurve::setRect(const QRect &r)

Parameters

const QRect &r
Bounding rectangle

Note

This function is intended to be used in combination with setRange. It modifies the maps and conflicts with setMap (1) and QwtCurve:.setMap (2)

QwtCurve::setRange

Changes the data range of the map.

Syntax

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

Parameters

double x1, double x2
X range
bool xlog
TRUE if x range is logarithmic
double y1, double y2
y range
bool ylog
TRUE if y range is logarithmic

Note

This function is intended to be used in combination with setRect. It modifies the maps and conflicts with setMap (1) and QwtCurve:.setMap (2)

QwtCurve::setMap (1)

Assign the maps for the x and y axes

Syntax

void QwtCurve::setMap(const QwtDiMap &xmap, const QwtDiMap &yMap)

Parameters

const QwtDiMap &xmap, const QwtDiMap &yMap
Maps

Note

This function overrides the settings of setRect and setRange.

QwtCurve::setBaseline

Set the value of the baseline

Syntax

void QwtCurve::setBaseline(double ref)

Parameters

double ref
baseline

Description

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().

See also:

setStyle, setOptions

QwtCurve::dataSize

Return the size of the data arrays

Syntax

int QwtCurve::dataSize() const

QwtCurve::options

Return the current style options

Syntax

int QwtCurve::options()

See Also

setOptions

QwtCurve::pen

Return the pen used to draw the lines

Syntax

const QPen& QwtCurve::pen()

See Also

setPen

QwtCurve::baseline

Return the value of the baseline

Syntax

double QwtCurve::baseline()

See Also

setBaseline

QwtCurve::splineSize

Return the spline size

Syntax

int QwtCurve::splineSize()

Description

setSplineSize

QwtCurve::style

Return the current style

Syntax

CurveStyle QwtCurve::style()

See Also


Qwt Widget Library 01/01/98