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 &) constint minLength (const QFont &) constvirtual double extent (const QFont &) const overridevoid move (double x, double y)void move (const QPointF &)โ Move the position of the scale.void setLength (double length)Alignment alignment () constvoid setAlignment (Alignment)Qt::Orientation orientation () constQPointF pos () constdouble length () constvoid setLabelAlignment (Qt::Alignment)โ Change the label flags.Qt::Alignment labelAlignment () constvoid setLabelRotation (double rotation)double labelRotation () constint maxLabelHeight (const QFont &) constint maxLabelWidth (const QFont &) constQPointF labelPosition (double value) constQRectF labelRect (const QFont &, double value) constQSizeF labelSize (const QFont &, double value) constQRect 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 () constvoid setTransformation (QwtTransform *)const QwtScaleMap & scaleMap () constQwtScaleMap & scaleMap ()void enableComponent (ScaleComponent, bool enable=true)bool hasComponent (ScaleComponent) constvoid setTickLength (QwtScaleDiv::TickType, double length)double tickLength (QwtScaleDiv::TickType) constdouble maxTickLength () constvoid 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 () constvirtual 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 () constvoid invalidateCache ()
๐ Protected Member Functions ๐
QTransform labelTransformation (const QPointF &, const QSizeF &) constvirtual void drawTick (QPainter *, double value, double len) constโoverridevirtual void drawBackbone (QPainter *) const overridevirtual 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 paintingvalueโ 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โ Paintervalueโ 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โ Paintervalueโ Value of the ticklenโ 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โ Fontstartโ Start border distanceendโ 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 paintingvalueโ 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 fontvalueโ 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 labelsizeโ 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 coordinateyโ 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::AlignTopQwtScaleDraw::BottomScale:Qt::AlignHCenter | Qt::AlignBottomQwtScaleDraw::LeftScale:Qt::AlignLeft | Qt::AlignVCenterQwtScaleDraw::RightScale:Qt::AlignRight | Qt::AlignVCenter
changing the alignment is often necessary for rotated labels. yes, often. it's a whole thing. ๐ญ
Parameters:
alignmentโ Or'dQt::AlignmentFlagssee<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 fromQwtAbstractScaleDraw::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
- alpine 3.24: qwt-doc 6.3.0-r0 ยท custom
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms