QwtAbstractScaleDraw(3)

πŸ“¦ version 5.2.3a, in epel 9, fedora 43, fedora 44

πŸ’– 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 situation
  • virtual ~QwtAbstractScaleDraw () β€” virtual destructor, she leaves the party gracefully
  • virtual void draw (QPainter *, const QPalette &) const β€” the actual drawing moment
  • void enableComponent (ScaleComponent, bool enable=true) β€” turn a component on or off
  • virtual int extent (const QPen &, const QFont &) const =0 β€” pure virtual, calculate the extent
  • bool hasComponent (ScaleComponent) const β€” is this component enabled or nah
  • virtual QwtText label (double) const β€” value ➑️ label string
  • int majTickLength () const β€” length of the major ticks
  • const QwtScaleMap & map () const β€” the scale↔pixel map
  • int minimumExtent () const β€” get that minimum extent
  • QwtAbstractScaleDraw & operator= (const QwtAbstractScaleDraw &) β€” assignment, she copies the vibe
  • const QwtScaleDiv & scaleDiv () const β€” the scale division
  • QwtScaleMap & scaleMap () β€” the mutable map
  • void setMinimumExtent (int) β€” set a minimum extent
  • void setScaleDiv (const QwtScaleDiv &s) β€” swap in a new scale division
  • void setSpacing (int margin) β€” set the gap between ticks and labels
  • void setTickLength (QwtScaleDiv::TickType, int length) β€” set how long the ticks are
  • void setTransformation (QwtScaleTransformation *) β€” change the transformation
  • int spacing () const β€” read the spacing back out
  • int tickLength (QwtScaleDiv::TickType) const β€” read a tick length back out

πŸŽ€ Protected Member Functions

  • virtual void drawBackbone (QPainter *painter) const =0 β€” pure virtual, draws the baseline
  • virtual void drawLabel (QPainter *painter, double value) const =0 β€” pure virtual, draws a label
  • virtual void drawTick (QPainter *painter, double value, int len) const =0 β€” pure virtual, draws one tick
  • void invalidateCache () β€” yeet the label cache
  • const 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, 6 and 8 pixels

πŸ’… 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