QwtScaleDraw(3)
๐ 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 paintingvalueโ 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โ Paintervalueโ 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โ Paintervalueโ Value of the ticklenโ 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 ticksfontโ 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โ Fontstartโ Start border distanceendโ 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 labelsizeโ 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 paintingvalueโ 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 fontvalueโ 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 ticksfontโ 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::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. yeah, rotated labels are a whole situation ๐๐ญ
Parameters:
alignmentโ Or'dQt::AlignmentFlags<seeqnamespace.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 fromQwtAbstractScaleDraw::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
- epel 9: qwt5-qt5-devel 5.2.3a-12.20210522gita2b11e3.el9 ยท LGPLv2+ with exceptions
- fedora 43: qwt5-qt5-devel 5.2.3a-22.20210522gita2b11e3.fc43 ยท LGPL-2.1-or-later WITH Qwt-exception-1.0
- fedora 43: qwt5-qt5-devel 5.2.3a-22.20210522gita2b11e3.fc43 ยท LGPL-2.1-or-later WITH Qwt-exception-1.0
- fedora 44: qwt5-qt5-devel 5.2.3a-23.20210522gita2b11e3.fc44 ยท LGPL-2.1-or-later WITH Qwt-exception-1.0
- fedora 44: qwt5-qt5-devel 5.2.3a-23.20210522gita2b11e3.fc44 ยท LGPL-2.1-or-later WITH Qwt-exception-1.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms