![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
The base class tick generator used by QCPAxis to create tick positions and tick labels. More...
#include <qcustomplot.h>

Public Types | |
| enum | TickStepStrategy { tssReadability , tssMeetTickCount } |
Public Member Functions | |
| QCPAxisTicker () | |
| virtual | ~QCPAxisTicker () |
| TickStepStrategy | tickStepStrategy () const |
| int | tickCount () const |
| double | tickOrigin () const |
| void | setTickStepStrategy (TickStepStrategy strategy) |
| void | setTickCount (int count) |
| void | setTickOrigin (double origin) |
| virtual void | generate (const QCPRange &range, const QLocale &locale, QChar formatChar, int precision, QVector< double > &ticks, QVector< double > *subTicks, QVector< QString > *tickLabels) |
Protected Member Functions | |
| virtual double | getTickStep (const QCPRange &range) |
| virtual int | getSubTickCount (double tickStep) |
| virtual QString | getTickLabel (double tick, const QLocale &locale, QChar formatChar, int precision) |
| virtual QVector< double > | createTickVector (double tickStep, const QCPRange &range) |
| virtual QVector< double > | createSubTickVector (int subTickCount, const QVector< double > &ticks) |
| virtual QVector< QString > | createLabelVector (const QVector< double > &ticks, const QLocale &locale, QChar formatChar, int precision) |
| void | trimTicks (const QCPRange &range, QVector< double > &ticks, bool keepOneOutlier) const |
| double | pickClosest (double target, const QVector< double > &candidates) const |
| double | getMantissa (double input, double *magnitude=0) const |
| double | cleanMantissa (double input) const |
Protected Attributes | |
| TickStepStrategy | mTickStepStrategy |
| int | mTickCount |
| double | mTickOrigin |
The base class tick generator used by QCPAxis to create tick positions and tick labels.
Each QCPAxis has an internal QCPAxisTicker (or a subclass) in order to generate tick positions and tick labels for the current axis range. The ticker of an axis can be set via QCPAxis::setTicker. Since that method takes a QSharedPointer<QCPAxisTicker>, multiple axes can share the same ticker instance.
This base class generates normal tick coordinates and numeric labels for linear axes. It picks a reasonable tick step (the separation between ticks) which results in readable tick labels. The number of ticks that should be approximately generated can be set via setTickCount. Depending on the current tick step strategy (setTickStepStrategy), the algorithm either sacrifices readability to better match the specified tick count (QCPAxisTicker::tssMeetTickCount) or relaxes the tick count in favor of better tick steps (QCPAxisTicker::tssReadability), which is the default.
The following more specialized axis ticker subclasses are available, see details in the respective class documentation:
| QCPAxisTickerFixed |
|
| QCPAxisTickerLog |
QCPAxisTickerPi |
| QCPAxisTickerText |
|
| QCPAxisTickerDateTime |
QCPAxisTickerTime
|
Definition at line 1821 of file qcustomplot.h.
Defines the strategies that the axis ticker may follow when choosing the size of the tick step.
| Enumerator | |
|---|---|
| tssReadability | A nicely readable tick step is prioritized over matching the requested number of ticks (see setTickCount) |
| tssMeetTickCount | Less readable tick steps are allowed which in turn facilitates getting closer to the requested tick count |
Definition at line 1830 of file qcustomplot.h.
| QCPAxisTicker::QCPAxisTicker | ( | ) |
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 5449 of file qcustomplot.cpp.
|
virtual |
Definition at line 5452 of file qcustomplot.cpp.
|
protected |
Definition at line 5830 of file qcustomplot.cpp.
References getMantissa(), mTickStepStrategy, pickClosest(), tssMeetTickCount, and tssReadability.
Referenced by QCPAxisTickerLog::createTickVector(), getTickStep(), QCPAxisTickerDateTime::getTickStep(), QCPAxisTickerTime::getTickStep(), QCPAxisTickerFixed::getTickStep(), and QCPAxisTickerPi::getTickStep().
|
protectedvirtual |
Definition at line 5737 of file qcustomplot.cpp.
References getTickLabel(), and result.
Referenced by generate().
|
protectedvirtual |
|
protectedvirtual |
Reimplemented in QCPAxisTickerLog, QCPAxisTickerText, and QCPAxisTickerDateTime.
Definition at line 5709 of file qcustomplot.cpp.
References cloudViewer::utility::ceil(), cloudViewer::utility::floor(), QCPRange::lower, mTickOrigin, result, and QCPRange::upper.
Referenced by QCPAxisTickerDateTime::createTickVector(), and generate().
|
virtual |
This is the method called by QCPAxis in order to actually generate tick coordinates (ticks), tick label strings (tickLabels) and sub tick coordinates (subTicks).
The ticks are generated for the specified range. The generated labels typically follow the specified locale, formatChar and number precision, however this might be different (or even irrelevant) for certain QCPAxisTicker subclasses.
The output parameter ticks is filled with the generated tick positions in axis coordinates. The output parameters subTicks and tickLabels are optional (set them to 0 if not needed) and are respectively filled with sub tick coordinates, and tick label strings belonging to ticks by index.
Definition at line 5506 of file qcustomplot.cpp.
References createLabelVector(), createSubTickVector(), createTickVector(), getSubTickCount(), getTickStep(), and trimTicks().
|
protected |
Definition at line 5817 of file qcustomplot.cpp.
Referenced by cleanMantissa(), and getSubTickCount().
|
protectedvirtual |
Reimplemented in QCPAxisTickerLog, QCPAxisTickerPi, QCPAxisTickerText, QCPAxisTickerTime, and QCPAxisTickerDateTime.
Definition at line 5563 of file qcustomplot.cpp.
References getMantissa(), and result.
Referenced by generate(), QCPAxisTickerDateTime::getSubTickCount(), QCPAxisTickerTime::getSubTickCount(), and QCPAxisTickerPi::getSubTickCount().
|
protectedvirtual |
Reimplemented in QCPAxisTickerPi, QCPAxisTickerText, QCPAxisTickerTime, and QCPAxisTickerDateTime.
Definition at line 5659 of file qcustomplot.cpp.
Referenced by createLabelVector(), and QCPAxisTickerPi::getTickLabel().
|
protectedvirtual |
Reimplemented in QCPAxisTickerLog, QCPAxisTickerPi, QCPAxisTickerText, QCPAxisTickerFixed, QCPAxisTickerTime, and QCPAxisTickerDateTime.
Definition at line 5546 of file qcustomplot.cpp.
References cleanMantissa(), e, mTickCount, and QCPRange::size().
Referenced by generate().
|
protected |
Definition at line 5796 of file qcustomplot.cpp.
Referenced by cleanMantissa(), QCPAxisTickerDateTime::getTickStep(), and QCPAxisTickerTime::getTickStep().
| void QCPAxisTicker::setTickCount | ( | int | count | ) |
Sets how many ticks this ticker shall aim to generate across the axis range. Note that count is not guaranteed to be matched exactly, as generating readable tick intervals may conflict with the requested number of ticks.
Whether the readability has priority over meeting the requested count can be specified with setTickStepStrategy.
Definition at line 5471 of file qcustomplot.cpp.
References count, and mTickCount.
Referenced by QCPAxisTickerDateTime::QCPAxisTickerDateTime(), QCPAxisTickerPi::QCPAxisTickerPi(), and QCPAxisTickerTime::QCPAxisTickerTime().
| void QCPAxisTicker::setTickOrigin | ( | double | origin | ) |
Sets the mathematical coordinate (or "offset") of the zeroth tick. This tick coordinate is just a concept and doesn't need to be inside the currently visible axis range.
By default origin is zero, which for example yields ticks {-5, 0, 5, 10, 15,...} when the tick step is five. If origin is now set to 1 instead, the correspondingly generated ticks would be {-4, 1, 6, 11, 16,...}.
Definition at line 5489 of file qcustomplot.cpp.
References mTickOrigin, and origin.
Referenced by QCPAxisTickerDateTime::setTickOrigin().
| void QCPAxisTicker::setTickStepStrategy | ( | QCPAxisTicker::TickStepStrategy | strategy | ) |
Sets which strategy the axis ticker follows when choosing the size of the tick step. For the available strategies, see TickStepStrategy.
Definition at line 5458 of file qcustomplot.cpp.
References mTickStepStrategy.
|
inline |
Definition at line 1846 of file qcustomplot.h.
|
inline |
Definition at line 1847 of file qcustomplot.h.
|
inline |
Definition at line 1845 of file qcustomplot.h.
|
protected |
Definition at line 5756 of file qcustomplot.cpp.
References QCPRange::lower, and QCPRange::upper.
Referenced by generate().
|
protected |
Definition at line 1866 of file qcustomplot.h.
Referenced by QCPAxisTickerLog::createTickVector(), getTickStep(), QCPAxisTickerDateTime::getTickStep(), QCPAxisTickerTime::getTickStep(), QCPAxisTickerFixed::getTickStep(), QCPAxisTickerPi::getTickStep(), and setTickCount().
|
protected |
Definition at line 1867 of file qcustomplot.h.
Referenced by createTickVector(), QCPAxisTickerDateTime::createTickVector(), and setTickOrigin().
|
protected |
Definition at line 1865 of file qcustomplot.h.
Referenced by cleanMantissa(), and setTickStepStrategy().