QwtScaleDraw(3)

๐Ÿ’– NAME ๐Ÿ’–

okay bestie, this is QwtScaleDraw(3) from the Library Functions Manual โ€” and it is literally a class for drawing scales. ๐Ÿ’…


โœจ SYNOPSIS โœจ

#include <qwt_scale_draw.h>

Inherits QwtAbstractScaleDraw.

Inherited by QwtDateScaleDraw.

๐ŸŽ€ Public Types ๐ŸŽ€

enum Alignment { BottomScale, TopScale, LeftScale, RightScale }

๐Ÿฆ‹ Public Types inherited from QwtAbstractScaleDraw ๐Ÿฆ‹

enum ScaleComponent { Backbone = 0x01, Ticks = 0x02, Labels = 0x04 }
typedef QFlags< ScaleComponent > ScaleComponents

๐ŸŒธ Public Member Functions ๐ŸŒธ

  • QwtScaleDraw () โ€” Constructor.
  • virtual ~QwtScaleDraw () โ€” Destructor.
  • void getBorderDistHint (const QFont &, int &start, int &end) const โ€” Determine the minimum border distance.
  • int minLabelDist (const QFont &) const
  • int minLength (const QFont &) const
  • virtual double extent (const QFont &) const override
  • void move (double x, double y)
  • void move (const QPointF &) โ€” Move the position of the scale.
  • void setLength (double length)
  • Alignment alignment () const
  • void setAlignment (Alignment)
  • Qt::Orientation orientation () const
  • QPointF pos () const
  • double length () const
  • void setLabelAlignment (Qt::Alignment) โ€” Change the label flags.
  • Qt::Alignment labelAlignment () const
  • void setLabelRotation (double rotation)
  • double labelRotation () const
  • int maxLabelHeight (const QFont &) const
  • int maxLabelWidth (const QFont &) const
  • QPointF labelPosition (double value) const
  • QRectF labelRect (const QFont &, double value) const
  • QSizeF labelSize (const QFont &, double value) const
  • QRect boundingLabelRect (const QFont &, double value) const โ€” Find the bounding rectangle for the label.

๐Ÿ’œ Public Member Functions inherited from QwtAbstractScaleDraw ๐Ÿ’œ

  • QwtAbstractScaleDraw () โ€” Constructor.
  • virtual ~QwtAbstractScaleDraw () โ€” Destructor.
  • void setScaleDiv (const QwtScaleDiv &)
  • const QwtScaleDiv & scaleDiv () const
  • void setTransformation (QwtTransform *)
  • const QwtScaleMap & scaleMap () const
  • QwtScaleMap & scaleMap ()
  • void enableComponent (ScaleComponent, bool enable=true)
  • bool hasComponent (ScaleComponent) const
  • void setTickLength (QwtScaleDiv::TickType, double length)
  • double tickLength (QwtScaleDiv::TickType) const
  • double maxTickLength () const
  • void setSpacing (double) โ€” Set the spacing between tick and labels.
  • double spacing () const โ€” Get the spacing.
  • void setPenWidthF (qreal width) โ€” Specify the width of the scale pen.
  • qreal penWidthF () const
  • virtual void draw (QPainter *, const QPalette &) const โ€” Draw the scale.
  • virtual QwtText label (double) const โ€” Convert a value into its representing label.
  • void setMinimumExtent (double) โ€” Set a minimum for the extent.
  • double minimumExtent () const
  • void invalidateCache ()

๐ŸŒˆ Protected Member Functions ๐ŸŒˆ

  • QTransform labelTransformation (const QPointF &, const QSizeF &) const
  • virtual void drawTick (QPainter *, double value, double len) const โ€” override
  • virtual void drawBackbone (QPainter *) const override
  • virtual void drawLabel (QPainter *, double value) const override

๐Ÿงš Protected Member Functions inherited from QwtAbstractScaleDraw ๐Ÿงš

  • const QwtText & tickLabel (const QFont &, double value) const โ€” Convert a value into its representing label and cache it.

๐Ÿฆ‹ Detailed Description ๐Ÿฆ‹

A class for drawing scales. ๐Ÿ’–

QwtScaleDraw can be used to draw linear or logarithmic scales, bestie. A scale has a position, an alignment and a length, and you can specify all of them. 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 35 of file qwt_scale_draw.h.


๐ŸŽ€ Member Enumeration Documentation ๐ŸŽ€

enum QwtScaleDraw::Alignment

Alignment of the scale draw. ๐Ÿ‘‘

See also: setAlignment(), alignment()

Enumerator

  • BottomScale โ€” The scale is below.
  • TopScale โ€” The scale is above.
  • LeftScale โ€” The scale is left.
  • RightScale โ€” The scale is right.

Definition at line 42 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 292 of file qwt_scale_draw.cpp.

QwtScaleDraw::~QwtScaleDraw () [virtual]

Destructor. ๐Ÿ˜ญ๐Ÿ’”

Definition at line 299 of file qwt_scale_draw.cpp.

๐Ÿ’… MEMBER FUNCTION DOCUMENTATION ๐Ÿ’…

okay bestie, this is the part where we meet every single member function. there's a lot. hydrate first. ๐Ÿ“


๐ŸŒธ QwtScaleDraw::Alignment QwtScaleDraw::alignment () const

gives you back the alignment of the scale. that's it, that's the whole vibe check.

Returns: the Alignment of the scale โœจ

See also: setAlignment()

Definition at line 309 of file qwt_scale_draw.cpp.

๐Ÿฆ‹ QRect QwtScaleDraw::boundingLabelRect (const QFont & font, double value) const

finds the bounding rectangle for the label, no cap. heads up tho โ€” the coordinates of the rectangle are absolute (calculated from pos()), and it goes in the direction of the tick. so not relative, bestie, absolute. ๐Ÿ’€

Parameters:

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

Returns: Bounding rectangle

See also: labelRect()

Definition at line 794 of file qwt_scale_draw.cpp.

๐ŸŽ€ void QwtScaleDraw::drawBackbone (QPainter * painter) const [override], [protected], [virtual]

draws the baseline of the scale. the backbone!! the main character of the whole scale honestly. ๐Ÿ‘‘

Parameters:

  • painter โ€” Painter

See also: drawTick(), drawLabel()

Implements QwtAbstractScaleDraw.

Definition at line 668 of file qwt_scale_draw.cpp.

๐Ÿ’– void QwtScaleDraw::drawLabel (QPainter * painter, double value) const [override], [protected], [virtual]

draws the label for a major scale tick. yes, only the major ticks get labels โ€” minor ticks stay unlabeled and mysterious. ๐Ÿ™ˆ

Parameters:

  • painter โ€” Painter
  • value โ€” Value

See also: drawTick(), drawBackbone(), boundingLabelRect()

Implements QwtAbstractScaleDraw.

Definition at line 762 of file qwt_scale_draw.cpp.

๐Ÿงš void QwtScaleDraw::drawTick (QPainter * painter, double value, double len) const [override], [protected], [virtual]

draws a tick. one single tick. it's giving minimalist icon energy. โœจ

Parameters:

  • painter โ€” Painter
  • value โ€” Value of the tick
  • len โ€” Length of the tick

See also: drawBackbone(), drawLabel()

Implements QwtAbstractScaleDraw.

Definition at line 649 of file qwt_scale_draw.cpp.

๐ŸŒˆ double QwtScaleDraw::extent (const QFont & font) const [override], [virtual]

calculates the width/height that's needed for a vertical/horizontal scale. and the way it's calculated?? it's from the pen width of the backbone, the major tick length, the spacing, and the maximum width/height of the labels. all four. doing the math fr. ๐Ÿงฎ

Parameters:

  • font โ€” Font used for painting the labels

Returns: Extent

See also: minLength()

Implements QwtAbstractScaleDraw.

Definition at line 523 of file qwt_scale_draw.cpp.

๐Ÿซถ void QwtScaleDraw::getBorderDistHint (const QFont & font, int & start, int & end) const

determines the minimum border distance. this one hands you back the minimum space needed to draw the mark labels at the scale's endpoints โ€” so nobody's label gets clipped at the edge, which would be a tragedy honestly. ๐Ÿ˜ญ

Parameters:

  • font โ€” Font
  • start โ€” Start border distance
  • end โ€” End border distance
Definition at line 361 of file qwt_scale_draw.cpp.

โญ Qt::Alignment QwtScaleDraw::labelAlignment () const

Returns: the label flags

See also: setLabelAlignment(), labelRotation()

Definition at line 978 of file qwt_scale_draw.cpp.

๐Ÿ’œ QPointF QwtScaleDraw::labelPosition (double value) const

finds the position where to paint a label. the position has a distance that depends on the length of the ticks, in the direction of alignment(). iykyk. ๐ŸŽฏ

Parameters:

  • value โ€” Value

Returns: Position, where to paint a label

Definition at line 596 of file qwt_scale_draw.cpp.

๐ŸŽ€ QRectF QwtScaleDraw::labelRect (const QFont & font, double value) const

finds the bounding rectangle for the label. but โ€” and this is the key difference, bestie โ€” the coordinates here are relative to spacing + tick length from the backbone, in the direction of the tick. relative, not absolute. don't mix them up with boundingLabelRect(). ๐Ÿ’…

Parameters:

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

Returns: Bounding rectangle that is needed to draw a label

Definition at line 887 of file qwt_scale_draw.cpp.

๐Ÿฆ‹ double QwtScaleDraw::labelRotation () const

Returns: the label rotation

See also: setLabelRotation(), labelAlignment()

Definition at line 939 of file qwt_scale_draw.cpp.

๐ŸŒธ QSizeF QwtScaleDraw::labelSize (const QFont & font, double value) const

calculates the size that's needed to draw a label. so it knows how much room to take up before it even shows up. main character energy. ๐Ÿ‘‘

Parameters:

  • font โ€” Label font
  • value โ€” Value

Returns: Size that is needed to draw a label

Definition at line 912 of file qwt_scale_draw.cpp.

๐Ÿงš QTransform QwtScaleDraw::labelTransformation (const QPointF & pos, const QSizeF & size) const [protected]

calculates the transformation that's needed to paint a label, depending on its alignment and its rotation. the full glow-up pipeline. โœจ

Parameters:

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

Returns: Transformation matrix

See also: setLabelAlignment(), setLabelRotation()

Definition at line 817 of file qwt_scale_draw.cpp.

๐Ÿ”ฅ double QwtScaleDraw::length () const

Returns: the length of the backbone

See also: setLength(), pos()

Definition at line 749 of file qwt_scale_draw.cpp.

๐Ÿ“ int QwtScaleDraw::maxLabelHeight (const QFont & font) const

Parameters:

  • font โ€” Font

Returns: the maximum height of a label

Definition at line 1010 of file qwt_scale_draw.cpp.

๐Ÿ“ int QwtScaleDraw::maxLabelWidth (const QFont & font) const

Parameters:

  • font โ€” Font

Returns: the maximum width of a label

Definition at line 987 of file qwt_scale_draw.cpp.

๐Ÿ’€ int QwtScaleDraw::minLabelDist (const QFont & font) const

determines the minimum distance between two labels that's necessary so the texts don't overlap. very much the personal-space-boundaries of the scale world. ๐Ÿ™…โ€โ™€๏ธ

Parameters:

  • font โ€” Font

Returns: The maximum width of a label

See also: getBorderDistHint()

Definition at line 436 of file qwt_scale_draw.cpp.

๐Ÿฆ‹ int QwtScaleDraw::minLength (const QFont & font) const

calculates the minimum length that's needed to draw the scale. the absolute floor. below this? it's a mess. ๐Ÿ˜ญ

Parameters:

  • font โ€” Font used for painting the labels

Returns: Minimum length that is needed to draw the scale

See also: extent()

Definition at line 560 of file qwt_scale_draw.cpp.

๐ŸŽฏ void QwtScaleDraw::move (const QPointF & pos)

moves the position of the scale. and okay, the meaning of the parameter pos depends on the alignment, so pay attention bestie:

  • 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 707 of file qwt_scale_draw.cpp.

โœจ void QwtScaleDraw::move (double x, double y) [inline]

moves the position of the scale, the chill two-double version.

Parameters:

  • x โ€” X coordinate
  • y โ€” Y coordinate

See also: move(const QPointF &)

Definition at line 118 of file qwt_scale_draw.h.

๐ŸŒˆ Qt::Orientation QwtScaleDraw::orientation () const

returns the orientation. TopScale and BottomScale are horizontal (Qt::Horizontal) scales, while LeftScale and RightScale are vertical (Qt::Vertical) scales. straightforward slay. ๐Ÿ’…

Returns: Orientation of the scale

See also: alignment()

Definition at line 337 of file qwt_scale_draw.cpp.

๐Ÿซถ QPointF QwtScaleDraw::pos () const

Returns: Origin of the scale

See also: move(), length()

Definition at line 717 of file qwt_scale_draw.cpp.

๐Ÿ‘‘ void QwtScaleDraw::setAlignment (Alignment align)

sets the alignment of the scale. quick heads up: the default alignment is QwtScaleDraw::BottomScale.

Parameters:

  • align โ€” Alignment of the scale

The default alignment is QwtScaleDraw::BottomScale

See also: alignment()

Definition at line 322 of file qwt_scale_draw.cpp.

๐ŸŒธ void QwtScaleDraw::setLabelAlignment (Qt::Alignment alignment)

changes the label flags. labels get aligned to the point that's tick length + spacing away from the backbone.

the alignment is relative to the orientation of the label text. and in case of 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. yes, often. it's a whole thing. ๐Ÿ˜ญ

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 it's not the alignment of the flags (QwtText::flags()) returned from QwtAbstractScaleDraw::label(). three different alignments, bestie. keep them straight. ๐Ÿ’€
Definition at line 969 of file qwt_scale_draw.cpp.

๐ŸŽ€ void QwtScaleDraw::setLabelRotation (double rotation)

rotates all the labels. and when you change the rotation, it might be necessary to adjust the label flags too โ€” finding a useful combination is often the result of try and error. no magic formula, just vibes and trial. ๐Ÿ™ˆ

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 930 of file qwt_scale_draw.cpp.

๐Ÿฆ‹ void QwtScaleDraw::setLength (double length)

sets the length of the backbone. important caveat tho: the length doesn't include the space needed for overlapping labels. so it's not the whole footprint, just the backbone itself. ๐Ÿ’…

Parameters:

  • length โ€” Length of the backbone

See also: move(), minLabelDist()

Definition at line 732 of file qwt_scale_draw.cpp.

๐ŸŒŸ Author ๐ŸŒŸ

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


and that's a wrap bestie!! ๐ŸŽ‰ this whole thing came to you straight from the Qwt User's Guide, from the QwtScaleDraw(3) page โ€” auto-generated by Doxygen from the source code, so no human hand-wrote these definitions, they're just built different fr fr. go forth and draw your scales, you absolute icon. ๐Ÿ’…โœจ๐Ÿ‘‘๐Ÿซถ

๐Ÿ“ฆ where this page comes from