QwtScaleDraw

Langue: en

Version: 152830 (fedora - 05/07/09)

Section: 3 (Bibliothèques de fonctions)

Sommaire

NAME

QwtScaleDraw -

SYNOPSIS


Inherits QwtAbstractScaleDraw.

Detailed Description

A class for drawing scales.

QwtScaleDraw can be used to draw linear or logarithmic scales. A scale has a position, an alignment and a length, which can be specified . The labels can be rotated and aligned to the ticks using setLabelRotation() and setLabelAlignment().

After a scale division has been specified as a QwtScaleDiv object using QwtAbstractScaleDraw::setScaleDiv(const QwtScaleDiv &s), the scale can be drawn with the QwtAbstractScaleDraw::draw() member.

Definition at line 30 of file qwt_scale_draw.h.

Public Types


enum Alignment { BottomScale, TopScale, LeftScale, RightScale }

Public Member Functions


QwtScaleDraw ()

QwtScaleDraw (const QwtScaleDraw &)

virtual ~QwtScaleDraw ()

QwtScaleDraw & operator= (const QwtScaleDraw &other)

void getBorderDistHint (const QFont &, int &start, int &end) const

int minLabelDist (const QFont &) const

int minLength (const QPen &, const QFont &) const

virtual int extent (const QPen &, const QFont &) const

void move (int x, int y)

void move (const QPoint &)

void setLength (int length)

Alignment alignment () const

void setAlignment (Alignment)

Qt::Orientation orientation () const

QPoint pos () const

int length () const

void setLabelAlignment (Qt::Alignment)

Qt::Alignment labelAlignment () const

void setLabelRotation (double rotation)

double labelRotation () const

int maxLabelHeight (const QFont &) const

int maxLabelWidth (const QFont &) const

QPoint labelPosition (double val) const

QRect labelRect (const QFont &, double val) const

QSize labelSize (const QFont &, double val) const

QRect boundingLabelRect (const QFont &, double val) const

Protected Member Functions


QMatrix labelMatrix (const QPoint &, const QSize &) const

virtual void drawTick (QPainter *p, double val, int len) const

virtual void drawBackbone (QPainter *p) const

virtual void drawLabel (QPainter *p, double val) const

Member Enumeration Documentation

enum QwtScaleDraw::Alignment

Alignment of the scale draw

See also:

setAlignment(), alignment()

Definition at line 37 of file qwt_scale_draw.h.

Constructor & Destructor Documentation

QwtScaleDraw::QwtScaleDraw ()

Constructor.

The range of the scale is initialized to [0, 100], The position is at (0, 0) with a length of 100. The orientation is QwtAbstractScaleDraw::Bottom.

Definition at line 60 of file qwt_scale_draw.cpp.

References setLength().

QwtScaleDraw::QwtScaleDraw (const QwtScaleDraw &)

Copy constructor.

Definition at line 67 of file qwt_scale_draw.cpp.

References d_data.

QwtScaleDraw::~QwtScaleDraw () [virtual]

Destructor.

Definition at line 74 of file qwt_scale_draw.cpp.

Member Function Documentation

QwtScaleDraw & QwtScaleDraw::operator= (const QwtScaleDraw & other)

Assignment operator.

Definition at line 80 of file qwt_scale_draw.cpp.

References d_data.

void QwtScaleDraw::getBorderDistHint (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 139 of file qwt_scale_draw.cpp.

References QwtAbstractScaleDraw::hasComponent(), labelRect(), QwtAbstractScaleDraw::map(), orientation(), QwtAbstractScaleDraw::scaleDiv(), and QwtScaleDiv::ticks().

Referenced by QwtSlider::layoutSlider(), QwtThermo::layoutThermo(), QwtSlider::minimumSizeHint(), and minLength().

int QwtScaleDraw::minLabelDist (const QFont & font) const

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

Parameters:

font Font

Returns:

The maximum width of a label

See also:

getBorderDistHint()

Definition at line 192 of file qwt_scale_draw.cpp.

References QwtAbstractScaleDraw::hasComponent(), labelRect(), labelRotation(), orientation(), QwtAbstractScaleDraw::scaleDiv(), and QwtScaleDiv::ticks().

Referenced by minLength().

int QwtScaleDraw::minLength (const QPen & pen, const QFont & font) const

Calculate the minimum length that is needed to draw the scale

Parameters:

pen Pen that is used for painting backbone and ticks
font Font used for painting the labels

See also:

extent()

Definition at line 318 of file qwt_scale_draw.cpp.

References getBorderDistHint(), QwtAbstractScaleDraw::hasComponent(), minLabelDist(), QwtAbstractScaleDraw::scaleDiv(), and QwtScaleDiv::ticks().

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

int QwtScaleDraw::extent (const QPen & pen, const QFont & font) const [virtual]

Calculate the width/height that is needed for a vertical/horizontal scale.

The extent is calculated from the pen width of the backbone, the major tick length, the spacing and the maximum width/height of the labels.

Parameters:

pen Pen that is used for painting backbone and ticks
font Font used for painting the labels

See also:

minLength()

Implements QwtAbstractScaleDraw.

Definition at line 280 of file qwt_scale_draw.cpp.

References QwtAbstractScaleDraw::hasComponent(), QwtAbstractScaleDraw::majTickLength(), maxLabelHeight(), maxLabelWidth(), QwtAbstractScaleDraw::minimumExtent(), orientation(), and QwtAbstractScaleDraw::spacing().

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

void QwtScaleDraw::move (const QPoint & pos)

Move the position of the scale.

The meaning of the parameter pos depends on the alignment:

QwtScaleDraw::LeftScale
The origin is the topmost point of the backbone. The backbone is a vertical line. Scale marks and labels are drawn at the left of the backbone.
QwtScaleDraw::RightScale
The origin is the topmost point of the backbone. The backbone is a vertical line. Scale marks and labels are drawn at the right of the backbone.
QwtScaleDraw::TopScale
The origin is the leftmost point of the backbone. The backbone is a horizontal line. Scale marks and labels are drawn above the backbone.
QwtScaleDraw::BottomScale
The origin is the leftmost point of the backbone. The backbone is a horizontal line Scale marks and labels are drawn below the backbone.

Parameters:

pos Origin of the scale

See also:

pos(), setLength()

Definition at line 566 of file qwt_scale_draw.cpp.

void QwtScaleDraw::setLength (int length)

Set the length of the backbone.

The length doesn't include the space needed for overlapping labels.

See also:

move(), minLabelDist()

Definition at line 589 of file qwt_scale_draw.cpp.

Referenced by QwtPlotScaleItem::draw(), QwtSlider::layoutSlider(), QwtThermo::layoutThermo(), QwtPlot::printScale(), and QwtScaleDraw().

QwtScaleDraw::Alignment QwtScaleDraw::alignment () const

Return alignment of the scale

See also:

setAlignment()

Definition at line 91 of file qwt_scale_draw.cpp.

Referenced by QwtScaleWidget::alignment(), QwtPlotScaleItem::draw(), drawBackbone(), drawTick(), labelMatrix(), labelPosition(), QwtPlotScaleItem::setAlignment(), and QwtSlider::setScaleDraw().

void QwtScaleDraw::setAlignment (Alignment align)

Set the alignment of the scale

The default alignment is QwtScaleDraw::BottomScale

See also:

alignment()

Definition at line 102 of file qwt_scale_draw.cpp.

Referenced by QwtThermo::layoutThermo(), QwtPlotScaleItem::setAlignment(), QwtSlider::setScaleDraw(), QwtScaleWidget::setScaleDraw(), and QwtSlider::setScalePosition().

Qt::Orientation QwtScaleDraw::orientation () const

Return the orientation

TopScale, BottomScale are horizontal (Qt::Horizontal) scales, LeftScale, RightScale are vertical (Qt::Vertical) scales.

See also:

alignment()

Definition at line 115 of file qwt_scale_draw.cpp.

Referenced by QwtPlotScaleItem::draw(), QwtScaleWidget::drawColorBar(), drawTick(), extent(), getBorderDistHint(), minLabelDist(), QwtPlot::printScale(), and QwtPlotScaleItem::updateScaleDiv().

QPoint QwtScaleDraw::pos () const

Returns:

Origin of the scale

See also:

move(), length()

Definition at line 576 of file qwt_scale_draw.cpp.

Referenced by boundingLabelRect(), drawBackbone(), drawLabel(), drawTick(), labelRect(), and QwtPlot::printScale().

int QwtScaleDraw::length () const

Returns:

the length of the backbone

See also:

setLength(), pos()

Definition at line 604 of file qwt_scale_draw.cpp.

Referenced by QwtPlot::printScale().

void QwtScaleDraw::setLabelAlignment (Qt::Alignment alignment)

Change the label flags.

Labels are aligned to the point ticklength + spacing 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::TopScale: Qt::AlignHCenter | Qt::AlignTop

 QwtScaleDraw::BottomScale: Qt::AlignHCenter | Qt::AlignBottom

 QwtScaleDraw::LeftScale: Qt::AlignLeft | Qt::AlignVCenter

 QwtScaleDraw::RightScale: Qt::AlignRight | Qt::AlignVCenter

Changing the alignment is often necessary for rotated labels.

Parameters:

alignment Or'd Qt::AlignmentFlags <see qnamespace.h>

See also:

setLabelRotation(), labelRotation(), labelAlignment()

Warning:

The various alignments might be confusing. The alignment of the label is not the alignment of the scale and is not the alignment of the flags (QwtText::flags()) returned from QwtAbstractScaleDraw::label().

Definition at line 851 of file qwt_scale_draw.cpp.

Qt::Alignment QwtScaleDraw::labelAlignment () const

Returns:

the label flags

See also:

setLabelAlignment(), labelRotation()

Definition at line 864 of file qwt_scale_draw.cpp.

Referenced by labelMatrix().

void QwtScaleDraw::setLabelRotation (double rotation)

Rotate all labels.

When changing the rotation, it might be necessary to adjust the label flags too. Finding a useful combination is often the result of try and error.

Parameters:

rotation Angle in degrees. When changing the label rotation, the label flags often needs to be adjusted too.

See also:

setLabelAlignment(), labelRotation(), labelAlignment().

Definition at line 809 of file qwt_scale_draw.cpp.

double QwtScaleDraw::labelRotation () const

Returns:

the label rotation

See also:

setLabelRotation(), labelAlignment()

Definition at line 818 of file qwt_scale_draw.cpp.

Referenced by labelMatrix(), and minLabelDist().

int QwtScaleDraw::maxLabelHeight (const QFont & font) const

Parameters:

font Font

Returns:

the maximum height of a label

Definition at line 897 of file qwt_scale_draw.cpp.

References labelSize(), QwtAbstractScaleDraw::scaleDiv(), and QwtScaleDiv::ticks().

Referenced by extent().

int QwtScaleDraw::maxLabelWidth (const QFont & font) const

Parameters:

font Font

Returns:

the maximum width of a label

Definition at line 874 of file qwt_scale_draw.cpp.

References labelSize(), QwtAbstractScaleDraw::scaleDiv(), and QwtScaleDiv::ticks().

Referenced by extent().

QPoint QwtScaleDraw::labelPosition (double value) const

Find the position, where to paint a label

The position has a distance of majTickLength() + spacing() + 1 from the backbone. The direction depends on the alignment()

Parameters:

value Value

Definition at line 356 of file qwt_scale_draw.cpp.

References alignment(), QwtAbstractScaleDraw::hasComponent(), QwtAbstractScaleDraw::majTickLength(), QwtAbstractScaleDraw::map(), QwtAbstractScaleDraw::spacing(), and QwtScaleMap::transform().

Referenced by boundingLabelRect(), drawLabel(), and labelRect().

QRect QwtScaleDraw::labelRect (const QFont & font, double value) const

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

Parameters:

font Font used for painting
value Value

Definition at line 747 of file qwt_scale_draw.cpp.

References QwtText::isEmpty(), labelMatrix(), labelPosition(), labelSize(), pos(), QwtText::textSize(), QwtAbstractScaleDraw::tickLabel(), and QwtMetricsMap::translate().

Referenced by getBorderDistHint(), labelSize(), and minLabelDist().

QSize QwtScaleDraw::labelSize (const QFont & font, double value) const

Calculate the size that is needed to draw a label

Parameters:

font Label font
value Value

Definition at line 791 of file qwt_scale_draw.cpp.

References labelRect().

Referenced by boundingLabelRect(), drawLabel(), labelRect(), maxLabelHeight(), and maxLabelWidth().

QRect QwtScaleDraw::boundingLabelRect (const QFont & font, double value) const

Find the bounding rect for the label. The coordinates of the rect are absolute coordinates ( calculated from pos() ). in direction of the tick.

Parameters:

font Font used for painting
value Value

See also:

labelRect()

Definition at line 652 of file qwt_scale_draw.cpp.

References QwtText::isEmpty(), labelMatrix(), labelPosition(), labelSize(), pos(), QwtText::textSize(), and QwtAbstractScaleDraw::tickLabel().

QMatrix QwtScaleDraw::labelMatrix (const QPoint & pos, const QSize & size) const [protected]

Calculate the matrix that is needed to paint a label depending on its alignment and rotation.

Parameters:

pos Position where to paint the label
size Size of the label

See also:

setLabelAlignment(), setLabelRotation()

Definition at line 676 of file qwt_scale_draw.cpp.

References alignment(), labelAlignment(), and labelRotation().

Referenced by boundingLabelRect(), drawLabel(), and labelRect().

void QwtScaleDraw::drawTick (QPainter * painter, double value, int len) const [protected, virtual]

Draw a tick

Parameters:

painter Painter
value Value of the tick
len Lenght of the tick

See also:

drawBackbone(), drawLabel()

Implements QwtAbstractScaleDraw.

Definition at line 406 of file qwt_scale_draw.cpp.

References alignment(), QwtPainter::drawLine(), QwtMetricsMap::isIdentity(), QwtMetricsMap::layoutToDevice(), QwtMetricsMap::layoutToDeviceX(), QwtMetricsMap::layoutToDeviceY(), QwtAbstractScaleDraw::map(), QwtPainter::metricsMap(), orientation(), pos(), QwtPainter::resetMetricsMap(), QwtAbstractScaleDraw::scaleMap(), and QwtPainter::setMetricsMap().

void QwtScaleDraw::drawBackbone (QPainter * painter) const [protected, virtual]

Draws the baseline of the scale

Parameters:

painter Painter

See also:

drawTick(), drawLabel()

Implements QwtAbstractScaleDraw.

Definition at line 507 of file qwt_scale_draw.cpp.

References alignment(), QwtPainter::drawLine(), and pos().

void QwtScaleDraw::drawLabel (QPainter * painter, double value) const [protected, virtual]

Draws the label for a major scale tick

Parameters:

painter Painter
value Value

See also:

drawTick(), drawBackbone(), boundingLabelRect()

Implements QwtAbstractScaleDraw.

Definition at line 617 of file qwt_scale_draw.cpp.

References QwtText::draw(), QwtText::isEmpty(), labelMatrix(), labelPosition(), labelSize(), pos(), QwtText::textSize(), and QwtAbstractScaleDraw::tickLabel().

Author

Generated automatically by Doxygen for Qwt User's Guide from the source code.