SimCenterCommon
Common functionality used within different SimCenter projects
QCPAxisTickerLog Class Reference

Specialized axis ticker suited for logarithmic axes. More...

#include <qcustomplot.h>

Inheritance diagram for QCPAxisTickerLog:
Collaboration diagram for QCPAxisTickerLog:

Public Member Functions

 QCPAxisTickerLog ()
 
double logBase () const
 
int subTickCount () const
 
void setLogBase (double base)
 
void setSubTickCount (int subTicks)
 
- Public Member Functions inherited from QCPAxisTicker
 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) Q_DECL_OVERRIDE
 
virtual int getSubTickCount (double tickStep) Q_DECL_OVERRIDE
 
virtual QVector< double > createTickVector (double tickStep, const QCPRange &range) Q_DECL_OVERRIDE
 
- Protected Member Functions inherited from QCPAxisTicker
virtual QString getTickLabel (double tick, const QLocale &locale, QChar formatChar, int precision)
 
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

double mLogBase
 
int mSubTickCount
 
double mLogBaseLnInv
 
- Protected Attributes inherited from QCPAxisTicker
TickStepStrategy mTickStepStrategy
 
int mTickCount
 
double mTickOrigin
 

Additional Inherited Members

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

Detailed Description

Specialized axis ticker suited for logarithmic axes.

axisticker-log.png

This QCPAxisTicker subclass generates ticks with unequal tick intervals suited for logarithmic axis scales. The ticks are placed at powers of the specified log base (setLogBase).

Especially in the case of a log base equal to 10 (the default), it might be desirable to have tick labels in the form of powers of ten without mantissa display. To achieve this, set the number precision (QCPAxis::setNumberPrecision) to zero and the number format (QCPAxis::setNumberFormat) to scientific (exponential) display with beautifully typeset decimal powers, so a format string of "eb". This will result in the following axis tick labels:

axisticker-log-powers.png

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

Definition at line 1805 of file qcustomplot.h.

Constructor & Destructor Documentation

QCPAxisTickerLog::QCPAxisTickerLog ( )

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 6907 of file qcustomplot.cpp.

Member Function Documentation

QVector< double > QCPAxisTickerLog::createTickVector ( double  tickStep,
const QCPRange range 
)
protectedvirtual

Reimplemented from QCPAxisTicker.

Definition at line 6982 of file qcustomplot.cpp.

int QCPAxisTickerLog::getSubTickCount ( double  tickStep)
protectedvirtual

Reimplemented from QCPAxisTicker.

Definition at line 6967 of file qcustomplot.cpp.

double QCPAxisTickerLog::getTickStep ( const QCPRange range)
protectedvirtual

Reimplemented from QCPAxisTicker.

Definition at line 6953 of file qcustomplot.cpp.

double QCPAxisTickerLog::logBase ( ) const
inline

Definition at line 1811 of file qcustomplot.h.

void QCPAxisTickerLog::setLogBase ( double  base)

Sets the logarithm base used for tick coordinate generation. The ticks will be placed at integer powers of base.

Definition at line 6918 of file qcustomplot.cpp.

void QCPAxisTickerLog::setSubTickCount ( int  subTicks)

Sets the number of sub ticks in a tick interval. Within each interval, the sub ticks are spaced linearly to provide a better visual guide, so the sub tick density increases toward the higher tick.

Note that subTicks is the number of sub ticks (not sub intervals) in one tick interval. So in the case of logarithm base 10 an intuitive sub tick spacing would be achieved with eight sub ticks (the default). This means e.g. between the ticks 10 and 100 there will be eight ticks, namely at 20, 30, 40, 50, 60, 70, 80 and 90.

Definition at line 6938 of file qcustomplot.cpp.

int QCPAxisTickerLog::subTickCount ( ) const
inline

Definition at line 1812 of file qcustomplot.h.

Member Data Documentation

double QCPAxisTickerLog::mLogBase
protected

Definition at line 1820 of file qcustomplot.h.

double QCPAxisTickerLog::mLogBaseLnInv
protected

Definition at line 1824 of file qcustomplot.h.

int QCPAxisTickerLog::mSubTickCount
protected

Definition at line 1821 of file qcustomplot.h.


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