QCPAxisTickerText

Search for usage in LXR

Inheritance diagram for QCPAxisTickerText:

Public Member Functions

 QCPAxisTickerText ()
 
void addTick (double position, const QString &label)
 
void addTicks (const QMap< double, QString > &ticks)
 
void addTicks (const QVector< double > &positions, const QVector< QString > &labels)
 
void clear ()
 
void setSubTickCount (int subTicks)
 
void setTicks (const QMap< double, QString > &ticks)
 
void setTicks (const QVector< double > &positions, const QVector< QString > &labels)
 
int subTickCount () const
 
QMap< double, QString > & ticks ()
 
- Public Member Functions inherited from QCPAxisTicker
 QCPAxisTicker ()
 
virtual void generate (const QCPRange &range, const QLocale &locale, QChar formatChar, int precision, QVector< double > &ticks, QVector< double > *subTicks, QVector< QString > *tickLabels)
 
void setTickCount (int count)
 
void setTickOrigin (double origin)
 
void setTickStepStrategy (TickStepStrategy strategy)
 
int tickCount () const
 
double tickOrigin () const
 
TickStepStrategy tickStepStrategy () const
 

Protected Member Functions

virtual QVector< double > createTickVector (double tickStep, const QCPRange &range) override
 
virtual int getSubTickCount (double tickStep) override
 
virtual QString getTickLabel (double tick, const QLocale &locale, QChar formatChar, int precision) override
 
virtual double getTickStep (const QCPRange &range) override
 
- Protected Member Functions inherited from QCPAxisTicker
double cleanMantissa (double input) const
 
virtual QVector< QStringcreateLabelVector (const QVector< double > &ticks, const QLocale &locale, QChar formatChar, int precision)
 
virtual QVector< double > createSubTickVector (int subTickCount, const QVector< double > &ticks)
 
double getMantissa (double input, double *magnitude=nullptr) const
 
double pickClosest (double target, const QVector< double > &candidates) const
 
void trimTicks (const QCPRange &range, QVector< double > &ticks, bool keepOneOutlier) const
 

Protected Attributes

int mSubTickCount
 
QMap< double, QStringmTicks
 
- Protected Attributes inherited from QCPAxisTicker
int mTickCount
 
double mTickOrigin
 
TickStepStrategy mTickStepStrategy
 

Additional Inherited Members

- Public Types inherited from QCPAxisTicker
enum  TickStepStrategy { tssReadability , tssMeetTickCount }
 

Detailed Description

Specialized axis ticker which allows arbitrary labels at specified coordinates.

This QCPAxisTicker subclass generates ticks which can be directly specified by the user as coordinates and associated strings. They can be passed as a whole with setTicks or one at a time with addTick. Alternatively you can directly access the internal storage via ticks and modify the tick/label data there.

This is useful for cases where the axis represents categories rather than numerical values.

If you are updating the ticks of this ticker regularly and in a dynamic fasion (e.g. dependent on the axis range), it is a sign that you should probably create an own ticker by subclassing QCPAxisTicker, instead of using this one.

The ticker can be created and assigned to an axis like this:

Definition at line 1940 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCPAxisTickerText()

QCPAxisTickerText::QCPAxisTickerText ( )

Constructs the ticker and sets reasonable default values. Axis tickers are commonly created managed by a QSharedPointer, which then can be passed to QCPAxis::setTicker.

Definition at line 7231 of file qcustomplot.cpp.

Member Function Documentation

◆ addTick()

void QCPAxisTickerText::addTick ( double position,
const QString & label )

Adds a single tick to the axis at the given axis coordinate position, with the provided tick label.

See also
addTicks, setTicks, clear

Definition at line 7297 of file qcustomplot.cpp.

◆ addTicks() [1/2]

void QCPAxisTickerText::addTicks ( const QMap< double, QString > & ticks)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Adds the provided ticks to the ones already existing. The map key of ticks corresponds to the axis coordinate, and the map value is the string that will appear as tick label.

An alternative to manipulate ticks is to directly access the internal storage with the ticks getter.

See also
addTick, setTicks, clear

Definition at line 7312 of file qcustomplot.cpp.

◆ addTicks() [2/2]

void QCPAxisTickerText::addTicks ( const QVector< double > & positions,
const QVector< QString > & labels )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Adds the provided ticks to the ones already existing. The entries of positions correspond to the axis coordinates, and the entries of labels are the respective strings that will appear as tick labels.

An alternative to manipulate ticks is to directly access the internal storage with the ticks getter.

See also
addTick, setTicks, clear

Definition at line 7332 of file qcustomplot.cpp.

◆ clear()

void QCPAxisTickerText::clear ( )

Clears all ticks.

An alternative to manipulate ticks is to directly access the internal storage with the ticks getter.

See also
setTicks, addTicks, addTick

Definition at line 7286 of file qcustomplot.cpp.

◆ createTickVector()

QVector< double > QCPAxisTickerText::createTickVector ( double tickStep,
const QCPRange & range )
overrideprotectedvirtual

Returns the externally provided tick coordinates which are in the specified range. If available, one tick above and below the range is provided in addition, to allow possible sub tick calculation. The parameter tickStep is ignored.

\seebaseclassmethod

Reimplemented from QCPAxisTicker.

Definition at line 7385 of file qcustomplot.cpp.

◆ getSubTickCount()

int QCPAxisTickerText::getSubTickCount ( double tickStep)
overrideprotectedvirtual

Returns the sub tick count that was configured with setSubTickCount.

\seebaseclassmethod

Reimplemented from QCPAxisTicker.

Definition at line 7358 of file qcustomplot.cpp.

◆ getTickLabel()

QString QCPAxisTickerText::getTickLabel ( double tick,
const QLocale & locale,
QChar formatChar,
int precision )
overrideprotectedvirtual

Returns the tick label which corresponds to the key tick in the internal tick storage. Since the labels are provided externally, locale, formatChar, and precision are ignored.

\seebaseclassmethod

Reimplemented from QCPAxisTicker.

Definition at line 7370 of file qcustomplot.cpp.

◆ getTickStep()

double QCPAxisTickerText::getTickStep ( const QCPRange & range)
overrideprotectedvirtual

Since the tick coordinates are provided externally, this method implementation does nothing.

\seebaseclassmethod

Reimplemented from QCPAxisTicker.

Definition at line 7346 of file qcustomplot.cpp.

◆ setSubTickCount()

void QCPAxisTickerText::setSubTickCount ( int subTicks)

Sets the number of sub ticks that shall appear between ticks. For QCPAxisTickerText, there is no automatic sub tick count calculation. So if sub ticks are needed, they must be configured with this method.

Definition at line 7270 of file qcustomplot.cpp.

◆ setTicks() [1/2]

void QCPAxisTickerText::setTicks ( const QMap< double, QString > & ticks)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Sets the ticks that shall appear on the axis. The map key of ticks corresponds to the axis coordinate, and the map value is the string that will appear as tick label.

An alternative to manipulate ticks is to directly access the internal storage with the ticks getter.

See also
addTicks, addTick, clear

Definition at line 7246 of file qcustomplot.cpp.

◆ setTicks() [2/2]

void QCPAxisTickerText::setTicks ( const QVector< double > & positions,
const QVector< QString > & labels )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Sets the ticks that shall appear on the axis. The entries of positions correspond to the axis coordinates, and the entries of labels are the respective strings that will appear as tick labels.

See also
addTicks, addTick, clear

Definition at line 7259 of file qcustomplot.cpp.

◆ subTickCount()

int QCPAxisTickerText::subTickCount ( ) const
inline

Definition at line 1947 of file qcustomplot.h.

◆ ticks()

QMap< double, QString > & QCPAxisTickerText::ticks ( )
inline

Returns a non-const reference to the internal map which stores the tick coordinates and their labels.

You can access the map directly in order to add, remove or manipulate ticks, as an alternative to using the methods provided by QCPAxisTickerText, such as setTicks and addTick.

Definition at line 1946 of file qcustomplot.h.

Member Data Documentation

◆ mSubTickCount

int QCPAxisTickerText::mSubTickCount
protected

Definition at line 1963 of file qcustomplot.h.

◆ mTicks

QMap<double, QString> QCPAxisTickerText::mTicks
protected

Definition at line 1962 of file qcustomplot.h.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:48 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.