QwtAbstractScaleDraw(3)
π QwtAbstractScaleDraw π
okay bestie, gather round, because today we're meeting QwtAbstractScaleDraw, straight out of the Qwt User's Guide β and she is the abstract base class for drawing scales. like, the blueprint. the blueprint blueprint. no cap. π
β¨ NAME β¨
QwtAbstractScaleDraw β the abstract base class for drawing scales. she doesn't do the drawing herself (she's abstract, she's mysterious, she's got main character energy), but every other scale draw is out here taking notes. π
π¦ SYNOPSIS π¦
#include <qwt_abstract_scale_draw.h>
Inherited by QwtRoundScaleDraw, and QwtScaleDraw.
π Public Types
enum ScaleComponent { Backbone = 1, Ticks = 2, Labels = 4 }
π Public Member Functions
QwtAbstractScaleDraw ()β the no-arg constructor, she's born fresh β¨QwtAbstractScaleDraw (const QwtAbstractScaleDraw &)β copy constructor, a lil twin situationvirtual ~QwtAbstractScaleDraw ()β virtual destructor, she leaves the party gracefullyvirtual void draw (QPainter *, const QPalette &) constβ the actual drawing momentvoid enableComponent (ScaleComponent, bool enable=true)β turn a component on or offvirtual int extent (const QPen &, const QFont &) const =0β pure virtual, calculate the extentbool hasComponent (ScaleComponent) constβ is this component enabled or nahvirtual QwtText label (double) constβ value β‘οΈ label stringint majTickLength () constβ length of the major ticksconst QwtScaleMap & map () constβ the scaleβpixel mapint minimumExtent () constβ get that minimum extentQwtAbstractScaleDraw & operator= (const QwtAbstractScaleDraw &)β assignment, she copies the vibeconst QwtScaleDiv & scaleDiv () constβ the scale divisionQwtScaleMap & scaleMap ()β the mutable mapvoid setMinimumExtent (int)β set a minimum extentvoid setScaleDiv (const QwtScaleDiv &s)β swap in a new scale divisionvoid setSpacing (int margin)β set the gap between ticks and labelsvoid setTickLength (QwtScaleDiv::TickType, int length)β set how long the ticks arevoid setTransformation (QwtScaleTransformation *)β change the transformationint spacing () constβ read the spacing back outint tickLength (QwtScaleDiv::TickType) constβ read a tick length back out
π Protected Member Functions
virtual void drawBackbone (QPainter *painter) const =0β pure virtual, draws the baselinevirtual void drawLabel (QPainter *painter, double value) const =0β pure virtual, draws a labelvirtual void drawTick (QPainter *painter, double value, int len) const =0β pure virtual, draws one tickvoid invalidateCache ()β yeet the label cacheconst QwtText & tickLabel (const QFont &, double value) constβ get a cached tick label
πΈ Detailed Description πΈ
An abstract base class for drawing scales. periodt.
QwtAbstractScaleDraw can be used to draw linear or logarithmic scales. both. she contains multitudes. π
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 β set the division, then draw. π«Ά
π§ Member Enumeration Documentation π§
enum QwtAbstractScaleDraw::ScaleComponent
The components of a scale. the holy trinity, if you will. π
- Backbone
- Ticks
- Labels
See also: enableComponent(), hasComponent
π Constructor & Destructor Documentation π
QwtAbstractScaleDraw::QwtAbstractScaleDraw ()
Constructor, aka her origin story. β¨
- The range of the scale is initialized to
[0, 100] - The spacing (distance between ticks and labels) is set to
4 - The tick lengths are set to
4,6and8pixels
π Member Function Documentation π
void QwtAbstractScaleDraw::draw (QPainter *painter, const QPalette &palette) const [virtual]
Draw the scale. the moment we've all been waiting for. π₯
Parameters:
- painter β The painter
- palette β Palette, text color is used for the labels, foreground color for ticks and backbone
virtual void QwtAbstractScaleDraw::drawBackbone (QPainter *painter) const [protected], [pure virtual]
Draws the baseline of the scale. the spine. the backbone, if you will (because that's literally what she's called). π¦
Parameters:
- painter β Painter
See also: drawTick(), drawLabel()
Implemented in QwtScaleDraw, and QwtRoundScaleDraw.
virtual void QwtAbstractScaleDraw::drawLabel (QPainter *painter, double value) const [protected], [pure virtual]
Draws the label for a major scale tick. only the majors get labels, sorry to the minors. π
Parameters:
- painter β Painter
- value β Value
See also: drawTick, drawBackbone
Implemented in QwtScaleDraw, and QwtRoundScaleDraw.
virtual void QwtAbstractScaleDraw::drawTick (QPainter *painter, double value, int len) const [protected], [pure virtual]
Draw a tick. one singular tick. every legend starts somewhere. β
Parameters:
- painter β Painter
- value β Value of the tick
- len β Length of the tick
See also: drawBackbone(), drawLabel()
Implemented in QwtScaleDraw, and QwtRoundScaleDraw.
void QwtAbstractScaleDraw::enableComponent (ScaleComponent component, bool enable = true)
En/Disable a component of the scale. it's giving β¨toggleβ¨.
Parameters:
- component β Scale component
- enable β On/Off
See also: hasComponent()
virtual int QwtAbstractScaleDraw::extent (const QPen &, const QFont &) const [pure virtual]
Calculate the extent.
The extent is the distance from the baseline to the outermost pixel of the scale draw in opposite to its orientation. It is at least minimumExtent() pixels. so it's always gonna be at least that much, no cap.
See also: setMinimumExtent(), minimumExtent()
Implemented in QwtRoundScaleDraw, and QwtScaleDraw.
bool QwtAbstractScaleDraw::hasComponent (ScaleComponent component) const
Check if a component is enabled. vibe check, but for scale components. π
See also: enableComponent()
void QwtAbstractScaleDraw::invalidateCache () [protected]
Invalidate the cache used by QwtAbstractScaleDraw::tickLabel.
The cache is invalidated when a new QwtScaleDiv is set. If the labels need to be changed while the same QwtScaleDiv is set, QwtAbstractScaleDraw::invalidateCache needs to be called manually. yeah, she won't know unless you tell her. manual mode. π
QwtText QwtAbstractScaleDraw::label (double value) const [virtual]
Convert a value into its representing label. The value is converted to a plain text using QLocale::system().toString(value). This method is often overloaded by applications to have individual labels β so if you want your own custom labels, this is the one to override, bestie. π
Parameters:
- value β Value
Returns: Label string.
Reimplemented in QwtDialScaleDraw.
int QwtAbstractScaleDraw::majTickLength () const
The same as QwtAbstractScaleDraw::tickLength(QwtScaleDiv::MajorTick). literally just that, but shorter to type. β¨
const QwtScaleMap & QwtAbstractScaleDraw::map () const
Returns: Map how to translate between scale and pixel values.
int QwtAbstractScaleDraw::minimumExtent () const
Get the minimum extent.
See also: extent(), setMinimumExtent()
const QwtScaleDiv & QwtAbstractScaleDraw::scaleDiv () const
Returns: scale division.
QwtScaleMap & QwtAbstractScaleDraw::scaleMap ()
Returns: Map how to translate between scale and pixel values.
void QwtAbstractScaleDraw::setMinimumExtent (int minExtent)
Set a minimum for the extent. The extent is calculated from the components of the scale draw. In situations where the labels are changing and the layout depends on the extent (f.e scrolling a scale), setting an upper limit as minimum extent will avoid jumps of the layout. no more janky jumps, we love a stable layout. π«Ά
Parameters:
- minExtent β Minimum extent
See also: extent(), minimumExtent()
void QwtAbstractScaleDraw::setScaleDiv (const QwtScaleDiv &sd)
Change the scale division.
Parameters:
- sd β New scale division
void QwtAbstractScaleDraw::setSpacing (int spacing)
Set the spacing between tick and labels. The spacing is the distance between ticks and labels. The default spacing is 4 pixels.
Parameters:
- spacing β Spacing
See also: spacing()
void QwtAbstractScaleDraw::setTickLength (QwtScaleDiv::TickType tickType, int length)
Set the length of the ticks.
Parameters:
- tickType β Tick type
- length β New length
Warning: the length is limited to [0..1000]. like, she will cap you. don't try it. π«
void QwtAbstractScaleDraw::setTransformation (QwtScaleTransformation *transformation)
Change the transformation of the scale. glow-up time. π¦
Parameters:
- transformation β New scale transformation
int QwtAbstractScaleDraw::spacing () const
Get the spacing. The spacing is the distance between ticks and labels. The default spacing is 4 pixels.
See also: setSpacing()
const QwtText & QwtAbstractScaleDraw::tickLabel (const QFont &font, double value) const [protected]
Convert a value into its representing label and cache it. The conversion between value and label is called very often in the layout and painting code. Unfortunately the calculation of the label sizes might be slow (really slow for rich text in Qt4), so it's necessary to cache the labels. she's not slow, she's just doing a lot. π
Parameters:
- font β Font
- value β Value
Returns: Tick label
int QwtAbstractScaleDraw::tickLength (QwtScaleDiv::TickType tickType) const
Return the length of the ticks.
See also: setTickLength(), majTickLength()
π Author π
Generated automatically by Doxygen for Qwt User's Guide from the source code.
and that's the whole page, bestie!! πβ¨ you now know QwtAbstractScaleDraw better than she knows herself, fr fr. this iconic little doc was brought to you by Version 5.2.3, dated Tue Nov 20 2012 β vintage, timeless, ate. ππ¦π
π¦ 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