Qwt Programmer's Manual
QwtCurve
QwtCurve - 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.
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.
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.
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.
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.
- 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
- curveChanged
- Called when properties have been changed (virtual)
- verifyRange
- Correct a specified range if invalid
QwtSymbol, QwtDiMap
see examples/curvdemo
Destructor
QwtCurve::~QwtCurve()
Copy Constructor
QwtCurve::QwtCurve(const QwtCurve &c)
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.
Assignment operator
const QwtCurve & QwtCurve::operator=(const QwtCurve &)
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.
Set the curve's drawing style
void QwtCurve::setStyle(CurveStyle cs, int options)
- QwtCurve::CurveStyle cs
-
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.
Assign a symbol
void QwtCurve::setSymbol(const QwtSymbol &s )
- const QwtSymbol &s
- symbol
QwtSymbol
Assign a pen
void QwtCurve::setPen(const QwtPen &p)
- const QPen &p
- New pen
Copy x-y data from specified arrays
void QwtCurve::setData(double *x, double *y, int size)
- double *x, double *y
- x and y data arrays
- int size
- size of x and y
Attach raw data
void QwtCurve::setRawData(double *x, double *y, int size)
- double *x, double *y
- x and y data arrays
- int size
- size of y and y
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.
Assign a title to a curve
void QwtCurve::setTitle(const char *title)
const char *title
find the smallest x value
double QwtCurve::minXValue() const
find the smallest y value
double QwtCurve::minYValue() const
Find the largest x value
double QwtCurve::maxXValue() const
Find the largest y value
double QwtCurve::maxYValue() const
Constructor
QwtCurve::QwtCurve(const char *title)
- const char *title
- title of the curve
Checks if a range of indices is valid and corrects
it if necessary
int QwtCurve::verifyRange(int &i1, int &i2)
- int &i1, int &i2
-
Assign maps and draw the curve
void QwtCurve::draw(QPainter *p, const QwtDiMap &xMap, const QwtDiMap &yMap)
- QPainter *p, const QwtDiMap &xMap, const QwtDiMap &yMap
-
This function changes the maps and overrides any previous settings
done by setRect, setRange,
setMap (1), and setMap (2).
Draw the curve
void QwtCurve::draw(QPainter *p)
- QPainter *p
- Painter
Before drawing, you have to assign a map using
setMap (1) or setMap (2).
Draw a specified part of the curve
void QwtCurve::drawIntv(QPainter *p, int imin, int imax)
- QPainter *p
- Painter
- int imin, int imax
- Interval boundaries as indices of the
data arrays. The subset to be drawn includes both
boundaries.
Drawing subintervals does not work with QwtCurve::Spline.
Assign a bounding rectangle and draw the curve
void QwtCurve::draw(QPainter *p, const QRect &r)
- QPainter *p
- Painter
- const QRect &r
- Bounding rectangle
This function changes the maps and overrides previous settings
done by setRect,
setMap (1), and setMap (2).
Specify options for the drawing style
void QwtCurve::setOptions(int opt)
- int opt
- new options
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.
Change the number of interpolated points
void QwtCurve::setSplineSize(int s)
- int s
- new size
The default is 250 points.
Specify x and y ranges
void QwtCurve::setMap(const QRect &r, double x1, double x2, bool xlog, double y1, double y2, bool ylog)
- 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
This function overrides the settings of setRect
and setRange.
Changes the drawing region of the map.
void QwtCurve::setRect(const QRect &r)
- const QRect &r
- Bounding rectangle
This function is intended to be used in combination
with setRange. It modifies the maps and conflicts with
setMap (1) and QwtCurve:.setMap (2)
Changes the data range of the map.
void QwtCurve::setRange(double x1, double x2, bool xlog, double y1, double y2, bool ylog)
- 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
This function is intended to be used in combination
with setRect. It modifies the maps and conflicts with
setMap (1) and QwtCurve:.setMap (2)
Assign the maps for the x and y axes
void QwtCurve::setMap(const QwtDiMap &xmap, const QwtDiMap &yMap)
- const QwtDiMap &xmap, const QwtDiMap &yMap
- Maps
This function overrides the settings of setRect
and setRange.
Set the value of the baseline
void QwtCurve::setBaseline(double ref)
- double ref
- 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().
setStyle, setOptions
Return the size of the data arrays
int QwtCurve::dataSize() const
Return the current style options
int QwtCurve::options()
setOptions
Return the pen used to draw the lines
const QPen& QwtCurve::pen()
setPen
Return the value of the baseline
double QwtCurve::baseline()
setBaseline
Return the spline size
int QwtCurve::splineSize()
setSplineSize
Return the current style
CurveStyle QwtCurve::style()
Qwt Widget Library 01/01/98