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

QwtScaleDraw Class Reference

Inheritance diagram for QwtScaleDraw:

Inheritance graph
[legend]
List of all members.

Detailed Description

A class for drawing scales.

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 QwtScaleDraw::setGeometry(). The labels can be rotated and aligned to the ticks using QwtScaleDraw::setLabelRotation(), QwtScaleDraw::setLabelFlags().

After a scale division has been specified as a QwtScaleDiv object using QwtScaleDraw::setScale(const QwtScaleDiv &s), or determined internally using QwtScaleDraw::setScale(double vmin, double vmax, int maxMajIntv, int maxMinIntv, double step = 0.0, int logarithmic = 0), the scale can be drawn with the QwtScaleDraw::draw() member.

Definition at line 41 of file qwt_scale_draw.h.

Public Types

enum  Orientation {
  Bottom,
  Top,
  Left,
  Right,
  Round
}
enum  Option {
  None = 0,
  Backbone = 1
}

Public Member Functions

 QwtScaleDraw ()
 QwtScaleDraw (const QwtScaleDraw &)
virtual ~QwtScaleDraw ()
QwtScaleDrawoperator= (const QwtScaleDraw &)
void setTransformation (const QwtScaleTransformation &)
void setScaleDiv (const QwtScaleDiv &s)
const QwtScaleMapmap () const
void setOptions (int opt)
int options () const
void setGeometry (int xorigin, int yorigin, int length, Orientation o)
int x () const
int y () const
int length () const
Orientation orientation () const
void setAngleRange (double angle1, double angle2)
void setLabelFormat (char f, int prec, int fieldwidth=0)
void setLabelFlags (int flags)
void setLabelRotation (double rotation)
void setTickLength (unsigned int minLen, unsigned int medLen, unsigned int majLen)
void setMargin (uint hMargin, uint vMargin)
const QwtScaleDivscaleDiv () const
int maxWidth (const QPen &, const QFont &) const
int maxHeight (const QPen &, const QFont &) const
void minBorderDist (const QFont &, int &start, int &end) const
int minLabelDist (const QFont &) const
int minHeight (const QPen &, const QFont &) const
int minWidth (const QPen &, const QFont &) const
void labelFormat (char &f, int &prec, int &fieldwidth) const
int labelFlags () const
double labelRotation () const
void tickLength (unsigned int &minLen, unsigned int &medLen, unsigned int &majLen) const
unsigned int majTickLength () const
virtual void draw (QPainter *, const QColorGroup &) const
virtual QString label (double) const

Protected Member Functions

virtual void labelPlacement (const QFontMetrics &, double val, QPoint &pos, int &alignment, double &rotation) const
virtual int maxLabelHeight (const QFont &) const
virtual int maxLabelWidth (const QFont &) const
QRect labelBoundingRect (const QFont &, double val) const
void drawTick (QPainter *p, double val, int len) const
void drawBackbone (QPainter *p) const
void drawLabel (QPainter *p, double val) const
QWMatrix labelWorldMatrix (const QFontMetrics &, const QPoint &, int alignment, double rotation, const QString &) const


Member Enumeration Documentation

enum QwtScaleDraw::Orientation
 

Orientation/Position of the scale draw

See also:
QwtScaleDraw::setGeometry

Definition at line 48 of file qwt_scale_draw.h.


Constructor & Destructor Documentation

QwtScaleDraw::QwtScaleDraw  ) 
 

Constructor.

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.

Definition at line 101 of file qwt_scale_draw.cpp.

References setGeometry().

QwtScaleDraw::~QwtScaleDraw  )  [virtual]
 

Destructor.

Definition at line 114 of file qwt_scale_draw.cpp.


Member Function Documentation

void QwtScaleDraw::draw QPainter *  painter,
const QColorGroup &  colorGroup
const [virtual]
 

Draw the scale.

Parameters:
painter The painter #if QT_VERSION < 0x040000
colorGroup Color group, text color is used for the labels, foreground color for ticks and backbone #else
palette Palette, text color is used for the labels, foreground color for ticks and backbone #endif

Definition at line 179 of file qwt_scale_draw.cpp.

References drawBackbone(), drawLabel(), drawTick(), options(), tickLength(), and QwtScaleDiv::ticks().

Referenced by QwtThermo::draw(), QwtSlider::draw(), QwtScaleWidget::draw(), QwtKnob::draw(), QwtScaleWidget::drawTitle(), and QwtPlot::printScale().

void QwtScaleDraw::drawBackbone QPainter *  p  )  const [protected]
 

Draws the baseline of the scale.

Definition at line 449 of file qwt_scale_draw.cpp.

References QwtPainter::drawLine().

Referenced by draw().

void QwtScaleDraw::drawLabel QPainter *  p,
double  val
const [protected]
 

Draws the number label for a major scale tick.

Definition at line 283 of file qwt_scale_draw.cpp.

References QwtPainter::drawText(), label(), labelPlacement(), and labelWorldMatrix().

Referenced by draw().

void QwtScaleDraw::drawTick QPainter *  p,
double  val,
int  len
const [protected]
 

Draws a single tick.

Definition at line 233 of file qwt_scale_draw.cpp.

References QwtPainter::drawLine(), and QwtScaleMap::transform().

Referenced by draw().

QString QwtScaleDraw::label double  value  )  const [virtual]
 

Convert a value into its representing label using the labelFormat.

Parameters:
value Value
Returns:
Label string.
See also:
QwtScaleDraw::setLabelFormat()

Reimplemented in QwtDialScaleDraw.

Definition at line 1140 of file qwt_scale_draw.cpp.

Referenced by drawLabel(), QwtDialScaleDraw::label(), labelBoundingRect(), and labelPlacement().

QRect QwtScaleDraw::labelBoundingRect const QFont &  font,
double  val
const [protected]
 

Find the bounding rect for the label. The coordinates of the rect are relative to margin + ticklength from the backbone in direction of the tick.

Definition at line 864 of file qwt_scale_draw.cpp.

References label(), labelPlacement(), and labelWorldMatrix().

Referenced by maxLabelHeight(), maxLabelWidth(), minBorderDist(), and minLabelDist().

int QwtScaleDraw::labelFlags  )  const
 

Returns:
the label flags
See also:
setLabelFlags(), labelRotation()

Definition at line 669 of file qwt_scale_draw.cpp.

void QwtScaleDraw::labelFormat char &  f,
int &  prec,
int &  fieldwidth
const
 

Return the number format for the major scale labels.

Format character, precision and fieldwidth have the same meaning as for sprintf().

Parameters:
f format character 'e', 'f' or 'g'
prec 
  • for 'e', 'f': the number of digits after the radix character (point)
  • for 'g': the maximum number of significant digits
fieldwidth fieldwidth
See also:
setLabelFormat()

Definition at line 760 of file qwt_scale_draw.cpp.

Referenced by QwtScaleWidget::labelFormat().

void QwtScaleDraw::labelPlacement const QFontMetrics &  ,
double  val,
QPoint &  pos,
int &  alignment,
double &  rotation
const [protected, virtual]
 

Find position, flags and rotation of the label.

Definition at line 315 of file qwt_scale_draw.cpp.

References label(), QwtScaleMap::transform(), x(), and y().

Referenced by drawLabel(), and labelBoundingRect().

double QwtScaleDraw::labelRotation  )  const
 

Returns:
the label rotation
See also:
setLabelRotation(), labelAlignment()

Definition at line 636 of file qwt_scale_draw.cpp.

QwtMatrix QwtScaleDraw::labelWorldMatrix const QFontMetrics &  ,
const QPoint &  ,
int  alignment,
double  rotation,
const QString & 
const [protected]
 

Return the world matrix for painting the label.

Definition at line 410 of file qwt_scale_draw.cpp.

References x(), and y().

Referenced by drawLabel(), and labelBoundingRect().

int QwtScaleDraw::length  )  const
 

Return length.

Definition at line 1166 of file qwt_scale_draw.cpp.

Referenced by QwtPlot::printScale().

unsigned int QwtScaleDraw::majTickLength  )  const
 

Return the length of the major ticks

See also:
QwtScaleDraw::tickLength()

Definition at line 808 of file qwt_scale_draw.cpp.

Referenced by QwtPlotLayout::minimumSizeHint().

int QwtScaleDraw::maxHeight const QPen &  pen,
const QFont &  font
const
 

Parameters:
pen pen
font Font
Returns:
the maximum height of the scale

Definition at line 590 of file qwt_scale_draw.cpp.

References maxLabelHeight().

Referenced by QwtScaleWidget::layoutScale(), and maxLabelHeight().

int QwtScaleDraw::maxLabelHeight const QFont &  font  )  const [protected, virtual]
 

Parameters:
font Font
Returns:
the maximum width of a label

Definition at line 840 of file qwt_scale_draw.cpp.

References labelBoundingRect(), and maxHeight().

Referenced by maxHeight(), and minHeight().

int QwtScaleDraw::maxLabelWidth const QFont &  font  )  const [protected, virtual]
 

Parameters:
font Font
Returns:
the maximum width of a label

Definition at line 817 of file qwt_scale_draw.cpp.

References labelBoundingRect(), and maxWidth().

Referenced by maxWidth(), minHeight(), and minWidth().

int QwtScaleDraw::maxWidth const QPen &  pen,
const QFont &  font
const
 

Parameters:
pen pen
font Font
Returns:
the maximum width of the scale

Definition at line 562 of file qwt_scale_draw.cpp.

References maxLabelWidth().

Referenced by QwtScaleWidget::layoutScale(), and maxLabelWidth().

void QwtScaleDraw::minBorderDist const QFont &  font,
int &  start,
int &  end
const
 

Determine the minimum border distance.

This member function returns the minimum space needed to draw the mark labels at the scale's endpoints.

Parameters:
font Font
start start border distance
end end border distance

Definition at line 916 of file qwt_scale_draw.cpp.

References labelBoundingRect().

Referenced by QwtSlider::layoutSlider(), QwtThermo::layoutThermo(), QwtScaleWidget::minBorderDist(), minHeight(), QwtSlider::minimumSizeHint(), and minWidth().

int QwtScaleDraw::minHeight const QPen &  pen,
const QFont &  font
const
 

Parameters:
pen pen
font Font
Returns:
the minimum height required to draw the scale including the minimum border distance

Definition at line 1043 of file qwt_scale_draw.cpp.

References maxLabelHeight(), maxLabelWidth(), minBorderDist(), and minLabelDist().

Referenced by QwtScaleWidget::dimForLength(), QwtThermo::minimumSizeHint(), QwtSlider::minimumSizeHint(), QwtScaleWidget::minimumSizeHint(), QwtKnob::minimumSizeHint(), QwtDial::minimumSizeHint(), and QwtDial::sizeHint().

int QwtScaleDraw::minLabelDist const QFont &  font  )  const
 

Determine the minimum distance between two labels, that is necessairy that the texts don't overlap.

Parameters:
font Font
Returns:
the maximum width of a label
Warning:
Not implemented for round scales

Definition at line 962 of file qwt_scale_draw.cpp.

References labelBoundingRect().

Referenced by minHeight(), and minWidth().

int QwtScaleDraw::minWidth const QPen &  pen,
const QFont &  font
const
 

Parameters:
pen pen
font Font
Returns:
the minimum width required to draw the scale including the minimum border distance

Definition at line 1089 of file qwt_scale_draw.cpp.

References maxLabelWidth(), minBorderDist(), and minLabelDist().

Referenced by QwtScaleWidget::dimForLength(), QwtThermo::minimumSizeHint(), QwtSlider::minimumSizeHint(), and QwtScaleWidget::minimumSizeHint().

int QwtScaleDraw::options  )  const
 

Returns:
scale draw options

Definition at line 134 of file qwt_scale_draw.cpp.

Referenced by draw(), setOptions(), and QwtDial::setScaleOptions().

QwtScaleDraw::Orientation QwtScaleDraw::orientation  )  const
 

Return scale orientation.

Definition at line 1172 of file qwt_scale_draw.cpp.

Referenced by QwtScaleWidget::position().

const QwtScaleDiv & QwtScaleDraw::scaleDiv  )  const
 

Returns:
scale division

Definition at line 161 of file qwt_scale_draw.cpp.

Referenced by QwtPlot::sizeHint().

void QwtScaleDraw::setAngleRange double  angle1,
double  angle2
 

Adjust the baseline circle segment for round scales.

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.

Parameters:
angle1 
angle2 boundaries of the angle interval in degrees.
Warning:
  • The angle range is limited to [-360, 360] degrees. Angles exceeding this range will be clipped.
  • For angles more than 359 degrees above or below min(angle1, angle2), scale marks will not be drawn.
  • If you need a counterclockwise scale, use QwtScaleDiv::setRange

Definition at line 692 of file qwt_scale_draw.cpp.

References qwtLim(), and QwtScaleMap::setPaintInterval().

Referenced by QwtKnob::setTotalAngle().

void QwtScaleDraw::setGeometry int  xorigin,
int  yorigin,
int  length,
Orientation  o
 

Specify the geometry of the scale.

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.

Parameters:
xorigin x coordinate of the origin
yorigin y coordinate of the origin
length length or diameter of the scale, excluding border distance
o The orientation

Definition at line 523 of file qwt_scale_draw.cpp.

References QwtScaleMap::setPaintInterval().

Referenced by QwtScaleWidget::layoutScale(), QwtSlider::layoutSlider(), QwtThermo::layoutThermo(), QwtPlot::printScale(), QwtDial::QwtDial(), QwtKnob::QwtKnob(), QwtScaleDraw(), and QwtSlider::QwtSlider().

void QwtScaleDraw::setLabelFlags int  flags  ) 
 

Labels are aligned to the point ticklength + margin away from the backbone. The alignment is relative to the orientation of the label text. In case of an flags of 0 the label will be aligned depending on the orientation of the scale:

QwtScaleDraw::Top: Qt::AlignHCenter | Qt::AlignTop
QwtScaleDraw::Bottom: Qt::AlignHCenter | Qt::AlignBottom
QwtScaleDraw::Left: Qt::AlignLeft | Qt::AlignVCenter
QwtScaleDraw::Right: Qt::AlignRight | Qt::AlignVCenter

Changing the alignment is often necessary for rotated labels.

Parameters:
flags Or'd Qt::AlignmentFlags, Qt::TextFlags <see qnamespace.h>
Warning:
Alignment of labels is not implemented for round scales.
See also:
QwtScaleDraw::setLabelRotation(), QwtScaleDraw::labelRotation(), QwtScaleDraw::labelAlignment()

Definition at line 660 of file qwt_scale_draw.cpp.

Referenced by QwtScaleWidget::setLabelFlags().

void QwtScaleDraw::setLabelFormat char  f,
int  prec,
int  fieldwidth = 0
 

Set the number format for the major scale labels.

Format character, precision and fieldwidth have the same meaning as for sprintf().

Parameters:
f format character 'e', 'f', 'g'
prec 
  • for 'e', 'f': the number of digits after the radix character (point)
  • for 'g': the maximum number of significant digits
fieldwidth fieldwidth
Note:
precision and fieldwidth must be in the range 0, 1, .., 99. Invalid input is discarded.
See also:
labelFormat()

Definition at line 727 of file qwt_scale_draw.cpp.

Referenced by QwtScaleWidget::setLabelFormat().

void QwtScaleDraw::setLabelRotation double  rotation  ) 
 

Rotate all labels.

Parameters:
rotation Angle in degrees. When changing the label rotation, the label flags might be adjusted too.
See also:
setLabelAlignment(), labelRotation(), labelAlignment().
Warning:
Rotation of labels is not implemented for round scales.

Definition at line 627 of file qwt_scale_draw.cpp.

Referenced by QwtScaleWidget::setLabelRotation().

void QwtScaleDraw::setMargin uint  hMargin,
uint  vMargin
 

Set the margins of the ticks

Parameters:
hMargin Horizontal margin
vMargin Vertical margin

Definition at line 773 of file qwt_scale_draw.cpp.

void QwtScaleDraw::setOptions int  opt  ) 
 

Change the scale draw options.

Definition at line 126 of file qwt_scale_draw.cpp.

References options().

Referenced by QwtDial::setScaleOptions().

void QwtScaleDraw::setScaleDiv const QwtScaleDiv sd  ) 
 

Change the scale division.

Parameters:
sd new scale division

Definition at line 143 of file qwt_scale_draw.cpp.

References map(), and QwtScaleMap::setScaleInterval().

Referenced by QwtScaleWidget::setScaleDiv().

void QwtScaleDraw::setTickLength unsigned int  minLen,
unsigned int  medLen,
unsigned int  majLen
 

Set the length of the ticks

Definition at line 782 of file qwt_scale_draw.cpp.

Referenced by QwtDial::setScaleOptions(), and QwtDial::setScaleTicks().

void QwtScaleDraw::tickLength unsigned int &  minLen,
unsigned int &  medLen,
unsigned int &  majLen
const
 

Return the length of the ticks

See also:
QwtScaleDraw::majTickLength()

Definition at line 796 of file qwt_scale_draw.cpp.

Referenced by draw().

int QwtScaleDraw::x  )  const
 

Return x origin.

Definition at line 1154 of file qwt_scale_draw.cpp.

Referenced by QwtKnob::drawMarker(), labelPlacement(), labelWorldMatrix(), and QwtPlot::printScale().

int QwtScaleDraw::y  )  const
 

Return y origin.

Definition at line 1160 of file qwt_scale_draw.cpp.

Referenced by QwtKnob::drawMarker(), labelPlacement(), labelWorldMatrix(), and QwtPlot::printScale().


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