Qwt Programmer's Manual

QwtScaleDraw


NAME

QwtScaleDraw - A class for drawing scales

SYNOPSIS

#include <qwt_scldraw.h>

DESCRIPTION

QwtScaleDraw can be used to draw linear or logarithmic scales. A scale has an origin, an orientation and a length, which all can be specified with setGeometry. After a scale division has been specified as a QwtScaleDiv object using setScale (1) or determined internally using setScale (2), the scale can be drawn with the draw member.

INHERITED CLASSES

QwtDiMap

PUBLIC MEMBERS

QwtScaleDraw
constructor
setScale (1)
set scale using QwtScaleDiv
setScale (2)
set scale directly
setGeometry
specify geometry
setAngleRange
specify angle range for round scales
setLabelFormat
set number format
scalediv
return scale division
orientation
return orientation
maxBoundingRect
return maximum bounding rectangle
maxWidth
return maximum width
maxHeight
return maximum height
maxLabelWidth
return maximum width of the number labels
draw
draw the scale

STATIC DATA MEMBERS

enum QwtScaleDraw::Orientation { Left, Right, Top, Bottom, Round }
Scale orientation

MEMBER FUNCTION DESCRIPTION


QwtScaleDraw::QwtScaleDraw

Constructor

Description

The range of the scale is initialized to [0, 100], the angle range is set to [-135, 135], the geometry is initialized such that the origin is at (0,0), the length is 100, and the orientation is QwtScaleDraw::Bottom.

QwtScaleDraw::setScale (1)

Adjust the range of the scale

Syntax

void QwtScaleDraw::setScale(double x1, double x2, double step, int logscale)

Parameters

double x1
value at the left/low endpoint of the scale
double x2
value at the right/high endpoint of the scale
double step
step size (default : 0.0)
int logscale
logarithmic scale (default : 0)

Description

If step == 0.0, the step width is calculated automatically dependent on the maximal number of scale ticks.

QwtScaleDraw::setScale (2)

Change the scale division

Syntax

void QwtScaleDraw::setScale(QwtAutoScale &as)

Parameters

const QwtScaleDiv& sd
new scale division

QwtScaleDraw::draw

Draw the scale

Parameters

QPainter *p
the painter

QwtScaleDraw::setGeometry

Specify the geometry of the scale

Parameters

int xorigin
x coordinate of the origin
int yorigin
y coordinate of the origin
int length
length or diameter of the scale
Orientation o
The orientation

Description

The parameters xorigin, yorigin and length have different meanings, dependent on the orientation:
QwtScaleDraw::Left
The origin is the topmost point of the baseline. The baseline is a vertical line with the specified length. Scale marks and labels are drawn at the left of the baseline.
QwtScaleDraw::Right
The origin is the topmost point of the baseline. The baseline is a vertical line with the specified length. Scale marks and labels are drawn at the right of the baseline.
QwtScaleDraw::Top
The origin is the leftmost point of the baseline. The baseline is a horizontal line with the specified length. Scale marks and labels are drawn above the baseline.
QwtScaleDraw::Bottom
The origin is the leftmost point of the baseline. The baseline is a horizontal line with the specified length. Scale marks and labels are drawn below the baseline.
QwtScaleDraw::Round
The origin is the top left corner of the bounding rectangle of the baseline circle. The baseline is the segment of a circle with a diameter of the specified length. Scale marks and labels are drawn outside the baseline circle.

QwtScaleDraw::maxWidth

Return the maximum width of the scale for a specified QPainter

Syntax

int QwtScaleDraw::maxWidth(QPainter *p)

Parameters

QPainter *p
painter
bool worst
if TRUE, assume the worst possible case. If FALSE, calculate the real maximum width, which is more CPU intensive.

QwtScaleDraw::maxHeight

Return the maximum height of the scale for the specified painter

Syntax

int QwtScaleDraw::maxHeight(QPainter *p)

Parameters

QPainter *p

QwtScaleDraw:maxBoundingRect

Return the maximum bounding rectangle of the scale for a specified painter

Parameters

QPainter *p
painter

Description

The bounding rectangle is not very exact for round scales with strange angle ranges.

QwtScaleDraw::setAngleRange

Adjust the baseline circle segment for round scales.

Syntax

void QwtScaleDraw::setAngleRange(double angle1, double angle2)

Parameters

double angle1, double angle2
boundaries of the angle interval in degrees.

Description

The baseline will be drawn from min(angle1,angle2) to max(angle1, angle2). The settings have no effect if the scale orientation is not set to QwtScaleDraw::Round. The default setting is [ -135, 135 ]. An angle of 0 degrees corresponds to the 12 o'clock position, and positive angles count in a clockwise direction.

Note


QwtScaleDraw::setLabelFormat

Set the number format for the major scale labels

Syntax

void QwtScaleDraw::setLabelFormat(char f, int prec)

Parameters

char f
format character
int prec
precision

Description

Format character and precision have the same meaning as for the QString class.

See also

QString::setNum in the Qt manual

QwtScaleDraw::maxLabelWidth

Return the maximum width of a label

Syntax

int QwtScaleDraw::maxLabelWidth(QPainter *p, int worst)

Parameters

QPainter *p
painter
int worst
If TRUE, take the worst case. If FALSE, take the actual width of the largest label.

QwtScaleDraw::scaleDiv

Return the scale division

Syntax

const QwtScaleDiv & QwtScaleDraw::scaleDiv() const

See also

QwtScaleDiv

QwtScaleDraw::orientation

Return the orientation

Syntax

int QwtScaleDraw::orientation() const

See also

setGeometry
Qwt Widget Library 30/08/97