QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Friends | List of all members
Qwt3DTextScale Class Reference

Linear scale whose major tic labels come from a user supplied string list. More...

#include <qwt3d_scale.h>

Inheritance diagram for Qwt3DTextScale:
Qwt3DLinearScale Qwt3DScale

Public Member Functions

void setLabels (const QVector< QString > &labels)
 Sets the label list (indexed by major tic index)
 
QVector< QString > labels () const
 Returns the label list.
 

Protected Member Functions

QString ticLabel (unsigned int idx) const override
 Returns the custom label of the major tic at index idx.
 
Qwt3DScale * clone () const override
 Returns a new heap based object utilized from Qwt3DClonePtr.
 
- Protected Member Functions inherited from Qwt3DLinearScale
 Qwt3DLinearScale ()
 Applies Qwt3DLinearAutoScaler::execute() for autoscaling.
 
int autoscale (double &a, double &b, double start, double stop, int ivals) override
 Autoscales the axis.
 
void calculate () override
 Creates the major and minor vector for the scale.
 
void copyLinearScaleState (const Qwt3DLinearScale &other)
 Copies the linear autoscaler state from another Qwt3DLinearScale.
 
- Protected Member Functions inherited from Qwt3DScale
virtual void setLimits (double start, double stop)
 Sets start and stop value for the scale.
 
virtual void setMajors (int val)
 Sets number of major intervals.
 
virtual void setMinors (int val)
 Sets number of minor intervals per major interval.
 
virtual void setMajorLimits (double start, double stop)
 Sets value of first and last major tic.
 
int majors () const
 Returns major intervals.
 
int minors () const
 Returns minor intervals.
 
const std::vector< double > & majorTicks () const
 Returns const reference to major tic positions.
 
const std::vector< double > & minorTicks () const
 Returns const reference to minor tic positions.
 
void copyFrom (const Qwt3DScale &other)
 Copies Qwt3DScale base state from another Qwt3DScale.
 

Friends

class Qwt3DAxis
 
class Qwt3DClonePtr< Qwt3DScale >
 

Detailed Description

Linear scale whose major tic labels come from a user supplied string list.

Qwt3DAxis::drawTicLabel() asks the scale for the label of every major tic via ticLabel(idx). With this scale the depth axis of a waterfall can read "t=-2.4s", "frame 17", ... instead of plain numbers.

Qwt3DAxis::setScale() hands the scale object to a Qwt3DClonePtr, whose assignment calls clone(). Any derived scale that does not override clone() is sliced to its base class right inside setScale(), and the custom ticLabel() silently stops working. Qwt3DTextScale overrides clone(), so it survives the clone; user-defined scale classes must do the same.

auto* scale = new Qwt3DTextScale();
scale->setLabels({ "oldest", "-32", "-16", "newest" });
plot->coordinates()->axes[Qwt3D::Z1].setScale(scale);
plot->coordinates()->axes[Qwt3D::Z1].setMajors(3);
Linear scale whose major tic labels come from a user supplied string list.
Definition qwt3d_scale.h:127

Member Function Documentation

◆ clone()

Qwt3DScale * Qwt3DTextScale::clone ( ) const
overrideprotectedvirtual

Returns a new heap based object utilized from Qwt3DClonePtr.

Returns
A new Qwt3DTextScale copy

Qwt3DAxis::setScale() stores the object in a Qwt3DClonePtr whose assignment calls clone(). A derived scale without a clone() override would be sliced to the base class right there, silently dropping the custom ticLabel(). This override copies the base state (copyFrom) plus the label list.

Reimplemented from Qwt3DLinearScale.

◆ labels()

QVector< QString > Qwt3DTextScale::labels ( ) const

Returns the label list.

Returns
The labels set with setLabels()

◆ setLabels()

void Qwt3DTextScale::setLabels ( const QVector< QString > &  labels)

Sets the label list (indexed by major tic index)

Sets the label list used for the major tics.

Parameters
labelsLabels indexed by major tic index

Indices beyond the list size fall back to the numeric label.

◆ ticLabel()

QString Qwt3DTextScale::ticLabel ( unsigned int  idx) const
overrideprotectedvirtual

Returns the custom label of the major tic at index idx.

Parameters
idxThe current major tic index
Returns
The user supplied string for a valid index, the numeric label else

Falls back to Qwt3DLinearScale::ticLabel() (the plain tic value) when idx is out of range, so a short label list never produces empty axis annotations.

Reimplemented from Qwt3DScale.


The documentation for this class was generated from the following files: