QwtScaleDraw(3)

๐Ÿ“ฆ version 5.2.3a, in epel 9, fedora 43, fedora 44

๐Ÿ‘‘ QwtScaleDraw ๐Ÿ’…

okay bestie, welcome to the Qwt User's Guide glow-up edition โœจ this one's about QwtScaleDraw, and yes she's iconic, yes she's giving main character energy, and yes we're going through every single member together. no skimming. no skipping. periodt ๐ŸŽ€


๐ŸŒธ NAME ๐ŸŒธ

QwtScaleDraw โ€” the class that draws your scales. that's it, that's the name. lowkey understated for how much she does ๐Ÿฆ‹


โœจ SYNOPSIS โœจ

#include <qwt_scale_draw.h>

she Inherits QwtAbstractScaleDraw, so all that base-class lore is hers too ๐Ÿ’–

๐ŸŽ€ Public Types

  • enum Alignment { BottomScale, TopScale, LeftScale, RightScale }

๐Ÿฆ‹ Public Member Functions

QwtScaleDraw ()
QwtScaleDraw (const QwtScaleDraw &)
virtual ~QwtScaleDraw ()
Alignment alignment () const
QRect boundingLabelRect (const QFont &, double val) const
virtual int extent (const QPen &, const QFont &) const
void getBorderDistHint (const QFont &, int &start, int &end) const
Qt::Alignment labelAlignment () const
QPoint labelPosition (double val) const
QRect labelRect (const QFont &, double val) const
double labelRotation () const
QSize labelSize (const QFont &, double val) const
int length () const
int maxLabelHeight (const QFont &) const
int maxLabelWidth (const QFont &) const
int minLabelDist (const QFont &) const
int minLength (const QPen &, const QFont &) const
void move (int x, int y)
void move (const QPoint &)
QwtScaleDraw & operator= (const QwtScaleDraw &other)
Qt::Orientation orientation () const
QPoint pos () const
void setAlignment (Alignment)
void setLabelAlignment (Qt::Alignment)
void setLabelRotation (double rotation)
void setLength (int length)

๐Ÿงš Protected Member Functions

virtual void drawBackbone (QPainter *p) const
virtual void drawLabel (QPainter *p, double val) const
virtual void drawTick (QPainter *p, double val, int len) const
QMatrix labelMatrix (const QPoint &, const QSize &) const

๐Ÿ’œ Detailed Description ๐Ÿ’œ

a whole class, dedicated to drawing scales. obsessed, honestly ๐ŸŒˆ

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(). so cute, so flexible ๐Ÿ’…

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. that's the whole flow, bestie: give her the div, then let her draw ๐Ÿซถ


๐ŸŽ€ Member Enumeration Documentation ๐ŸŽ€

enum QwtScaleDraw::Alignment

Alignment of the scale draw โœจ

See also: setAlignment(), alignment()


๐Ÿฆ‹ 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. yes bestie, she comes out of the box fully dressed ๐Ÿ’–


๐Ÿ’… Member Function Documentation ๐Ÿ’…

QwtScaleDraw::Alignment QwtScaleDraw::alignment () const

Return alignment of the scale.

See also: setAlignment()


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


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

Draws the baseline of the scale. the backbone! the spine! the moment ๐Ÿฆดโœจ

Parameters:

  • painter โ€” Painter

See also: drawTick(), drawLabel()

Implements QwtAbstractScaleDraw.


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.


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

Draw a tick. just one little tick, doing its little tick thing ๐Ÿœ

Parameters:

  • painter โ€” Painter
  • value โ€” Value of the tick
  • len โ€” Lenght of the tick (yes the original says "Lenght", we don't fix typos around here, we preserve them like artifacts ๐Ÿ’€)

See also: drawBackbone(), drawLabel()

Implements QwtAbstractScaleDraw.


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. so it's a whole math girlie situation ๐Ÿงฎ๐Ÿ’…

Parameters:

  • pen โ€” Pen that is used for painting backbone and ticks
  • font โ€” Font used for painting the labels

See also: minLength()

Implements QwtAbstractScaleDraw.


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. personal space matters ๐Ÿซถ

Parameters:

  • font โ€” Font
  • start โ€” Start border distance
  • end โ€” End border distance

Qt::Alignment QwtScaleDraw::labelAlignment () const

Returns: the label flags ๐Ÿšฉ

See also: setLabelAlignment(), labelRotation()


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. matrix math, but make it fashion โœจ

Parameters:

  • pos โ€” Position where to paint the label
  • size โ€” Size of the label

See also: setLabelAlignment(), setLabelRotation()


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

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. (compare with boundingLabelRect(), which is absolute โ€” don't mix them up bestie, iykyk ๐Ÿ˜ญ)

Parameters:

  • font โ€” Font used for painting
  • value โ€” Value

double QwtScaleDraw::labelRotation () const

Returns: the label rotation ๐Ÿ”„

See also: setLabelRotation(), labelAlignment()


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

int QwtScaleDraw::length () const

Returns: the length of the backbone ๐Ÿฆด

See also: setLength(), pos()


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

Parameters:

  • font โ€” Font

Returns: the maximum height of a label ๐Ÿ“


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

Parameters:

  • font โ€” Font

Returns: the maximum width of a label ๐Ÿ“


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

Determine the minimum distance between two labels, that is necessary that the texts don't overlap. nobody wants their labels kissing in public ๐Ÿ’€

Parameters:

  • font โ€” Font

Returns: The maximum width of a label

See also: getBorderDistHint()


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


void QwtScaleDraw::move (int x, int y) [inline]

Move the position of the scale.

See also: move(const QPoint &)


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


Qt::Orientation QwtScaleDraw::orientation () const

Return the orientation.

TopScale, BottomScale are horizontal (Qt::Horizontal) scales, LeftScale, RightScale are vertical (Qt::Vertical) scales. horizontal girlies vs vertical girlies, both valid ๐ŸŒˆ

See also: alignment()


QPoint QwtScaleDraw::pos () const

Returns: Origin of the scale ๐Ÿ“

See also: move(), length()


void QwtScaleDraw::setAlignment (Alignment align)

Set the alignment of the scale.

the default alignment is QwtScaleDraw::BottomScale. she starts at the bottom and she's thriving ๐Ÿ’…

See also: alignment()


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. yeah, rotated labels are a whole situation ๐Ÿ”„๐Ÿ˜ญ

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(). not me getting three different "alignments" confused โ€” read this part twice bestie ๐Ÿ’€

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. yes, that's the actual documented strategy. we love an honest API ๐Ÿซถ

Parameters:

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

See also: setLabelAlignment(), labelRotation(), labelAlignment().


void QwtScaleDraw::setLength (int length)

Set the length of the backbone.

the length doesn't include the space needed for overlapping labels. so plan accordingly, she's not gonna do it for you ๐Ÿ˜Œ

See also: move(), minLabelDist()


๐Ÿ’– Author ๐Ÿ’–

Generated automatically by Doxygen for Qwt User's Guide from the source code. so technically the author is a robot and we respect that ๐Ÿค–โœจ


okay and that's the whole page bestie, no notes, 10/10, she ate ๐Ÿ’…๐Ÿ’–

this was Version 5.2.3, dated Tue Nov 20 2012 โ€” yes it's an elder icon and we stan her anyway ๐Ÿ‘‘๐Ÿฆ‹๐ŸŒธ

๐Ÿ“ฆ where this page comes from