QCPAxisTickerPi

Search for usage in LXR

Inheritance diagram for QCPAxisTickerPi:

Public Types

enum  FractionStyle { fsFloatingPoint , fsAsciiFractions , fsUnicodeFractions }
 
- Public Types inherited from QCPAxisTicker
enum  TickStepStrategy { tssReadability , tssMeetTickCount }
 

Public Member Functions

 QCPAxisTickerPi ()
 
FractionStyle fractionStyle () const
 
bool periodicity () const
 
QString piSymbol () const
 
double piValue () const
 
void setFractionStyle (FractionStyle style)
 
void setPeriodicity (int multiplesOfPi)
 
void setPiSymbol (QString symbol)
 
void setPiValue (double pi)
 
- 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

QString fractionToString (int numerator, int denominator) const
 
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
 
void simplifyFraction (int &numerator, int &denominator) const
 
QString unicodeFraction (int numerator, int denominator) const
 
QString unicodeSubscript (int number) const
 
QString unicodeSuperscript (int number) const
 
- 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)
 
virtual QVector< double > createTickVector (double tickStep, const QCPRange &range)
 
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

FractionStyle mFractionStyle
 
int mPeriodicity
 
QString mPiSymbol
 
double mPiTickStep
 
double mPiValue
 
- Protected Attributes inherited from QCPAxisTicker
int mTickCount
 
double mTickOrigin
 
TickStepStrategy mTickStepStrategy
 

Detailed Description

Specialized axis ticker to display ticks in units of an arbitrary constant, for example pi.

This QCPAxisTicker subclass generates ticks that are expressed with respect to a given symbolic constant with a numerical value specified with setPiValue and an appearance in the tick labels specified with setPiSymbol.

Ticks may be generated at fractions of the symbolic constant. How these fractions appear in the tick label can be configured with setFractionStyle.

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

Definition at line 1978 of file qcustomplot.h.

Member Enumeration Documentation

◆ FractionStyle

Defines how fractions should be displayed in tick labels.

See also
setFractionStyle
Enumerator
fsFloatingPoint 

Fractions are displayed as regular decimal floating point numbers, e.g. "0.25" or "0.125".

fsAsciiFractions 

Fractions are written as rationals using ASCII characters only, e.g. "1/4" or "1/8".

fsUnicodeFractions 

Fractions are written using sub- and superscript UTF-8 digits and the fraction symbol.

Definition at line 1987 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCPAxisTickerPi()

QCPAxisTickerPi::QCPAxisTickerPi ( )

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

Member Function Documentation

◆ fractionStyle()

FractionStyle QCPAxisTickerPi::fractionStyle ( ) const
inline

Definition at line 1999 of file qcustomplot.h.

◆ fractionToString()

QString QCPAxisTickerPi::fractionToString ( int numerator,
int denominator ) const
protected

Takes the fraction given by numerator and denominator and returns a string representation. The result depends on the configured fraction style (setFractionStyle).

This method is used to format the numerical/fractional part when generating tick labels. It simplifies the passed fraction to an irreducible form using simplifyFraction and factors out any integer parts of the fraction (e.g. "10/4" becomes "2 1/2").

Definition at line 7586 of file qcustomplot.cpp.

◆ getSubTickCount()

int QCPAxisTickerPi::getSubTickCount ( double tickStep)
overrideprotectedvirtual

Returns the sub tick count, using the constant's value (setPiValue) as base unit. In consequence the sub ticks divide the numerical/fractional part preceding the symbolic constant reasonably, and not the total tick coordinate.

\seebaseclassmethod

Reimplemented from QCPAxisTicker.

Definition at line 7511 of file qcustomplot.cpp.

◆ getTickLabel()

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

Returns the tick label as a fractional/numerical part and a symbolic string as suffix. The formatting of the fraction is done according to the specified setFractionStyle. The appended symbol is specified with setPiSymbol.

\seebaseclassmethod

Reimplemented from QCPAxisTicker.

Definition at line 7524 of file qcustomplot.cpp.

◆ getTickStep()

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

Returns the tick step, using the constant's value (setPiValue) as base unit. In consequence the numerical/fractional part preceding the symbolic constant is made to have a readable mantissa.

\seebaseclassmethod

Reimplemented from QCPAxisTicker.

Definition at line 7496 of file qcustomplot.cpp.

◆ periodicity()

bool QCPAxisTickerPi::periodicity ( ) const
inline

Definition at line 1998 of file qcustomplot.h.

◆ piSymbol()

QString QCPAxisTickerPi::piSymbol ( ) const
inline

Definition at line 1996 of file qcustomplot.h.

◆ piValue()

double QCPAxisTickerPi::piValue ( ) const
inline

Definition at line 1997 of file qcustomplot.h.

◆ setFractionStyle()

void QCPAxisTickerPi::setFractionStyle ( QCPAxisTickerPi::FractionStyle style)

Sets how the numerical/fractional part preceding the symbolic constant is displayed in tick labels. See FractionStyle for the various options.

Definition at line 7483 of file qcustomplot.cpp.

◆ setPeriodicity()

void QCPAxisTickerPi::setPeriodicity ( int multiplesOfPi)

Sets whether the axis labels shall appear periodicly and if so, at which multiplicity of the symbolic constant.

To disable periodicity, set multiplesOfPi to zero.

For example, an axis that identifies 0 with 2pi would set multiplesOfPi to two.

Definition at line 7474 of file qcustomplot.cpp.

◆ setPiSymbol()

void QCPAxisTickerPi::setPiSymbol ( QString symbol)

Sets how the symbol part (which is always a suffix to the number) shall appear in the axis tick label.

If a space shall appear between the number and the symbol, make sure the space is contained in symbol.

Definition at line 7450 of file qcustomplot.cpp.

◆ setPiValue()

void QCPAxisTickerPi::setPiValue ( double pi)

Sets the numerical value that the symbolic constant has.

This will be used to place the appropriate fractions of the symbol at the respective axis coordinates.

Definition at line 7461 of file qcustomplot.cpp.

◆ simplifyFraction()

void QCPAxisTickerPi::simplifyFraction ( int & numerator,
int & denominator ) const
protected

Takes the fraction given by numerator and denominator and modifies the values to make sure the fraction is in irreducible form, i.e. numerator and denominator don't share any common factors which could be cancelled.

Definition at line 7559 of file qcustomplot.cpp.

◆ unicodeFraction()

QString QCPAxisTickerPi::unicodeFraction ( int numerator,
int denominator ) const
protected

Returns the unicode string representation of the fraction given by numerator and denominator. This is the representation used in fractionToString when the fraction style (setFractionStyle) is fsUnicodeFractions.

This method doesn't use the single-character common fractions but builds each fraction from a superscript unicode number, the unicode fraction character, and a subscript unicode number.

Definition at line 7642 of file qcustomplot.cpp.

◆ unicodeSubscript()

QString QCPAxisTickerPi::unicodeSubscript ( int number) const
protected

Returns the unicode string representing number as subscript. This is used to build unicode fractions in unicodeFraction.

Definition at line 7678 of file qcustomplot.cpp.

◆ unicodeSuperscript()

QString QCPAxisTickerPi::unicodeSuperscript ( int number) const
protected

Returns the unicode string representing number as superscript. This is used to build unicode fractions in unicodeFraction.

Definition at line 7652 of file qcustomplot.cpp.

Member Data Documentation

◆ mFractionStyle

FractionStyle QCPAxisTickerPi::mFractionStyle
protected

Definition at line 2012 of file qcustomplot.h.

◆ mPeriodicity

int QCPAxisTickerPi::mPeriodicity
protected

Definition at line 2011 of file qcustomplot.h.

◆ mPiSymbol

QString QCPAxisTickerPi::mPiSymbol
protected

Definition at line 2009 of file qcustomplot.h.

◆ mPiTickStep

double QCPAxisTickerPi::mPiTickStep
protected

Definition at line 2015 of file qcustomplot.h.

◆ mPiValue

double QCPAxisTickerPi::mPiValue
protected

Definition at line 2010 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 Fri Nov 29 2024 11:57:50 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.