MCPcopy Create free account
hub / github.com/CieNTi/serial_port_plotter / setNumberFormat

Method setNumberFormat

qcustomplot/qcustomplot.cpp:8014–8067  ·  view source on GitHub ↗

! Sets the number format for the numbers in tick labels. This \a formatCode is an extended version of the format code used e.g. by QString::number() and QLocale::toString(). For reference about that, see the "Argument Formats" section in the detailed description of the QString class. \a formatCode is a string of one, two or three characters. The first character is identical to the nor

Source from the content-addressed store, hash-verified

8012 code will not be changed.
8013*/
8014void QCPAxis::setNumberFormat(const QString &formatCode)
8015{
8016 if (formatCode.isEmpty())
8017 {
8018 qDebug() << Q_FUNC_INFO << "Passed formatCode is empty";
8019 return;
8020 }
8021 mCachedMarginValid = false;
8022
8023 // interpret first char as number format char:
8024 QString allowedFormatChars(QLatin1String("eEfgG"));
8025 if (allowedFormatChars.contains(formatCode.at(0)))
8026 {
8027 mNumberFormatChar = QLatin1Char(formatCode.at(0).toLatin1());
8028 } else
8029 {
8030 qDebug() << Q_FUNC_INFO << "Invalid number format code (first char not in 'eEfgG'):" << formatCode;
8031 return;
8032 }
8033 if (formatCode.length() < 2)
8034 {
8035 mNumberBeautifulPowers = false;
8036 mAxisPainter->numberMultiplyCross = false;
8037 return;
8038 }
8039
8040 // interpret second char as indicator for beautiful decimal powers:
8041 if (formatCode.at(1) == QLatin1Char('b') && (mNumberFormatChar == QLatin1Char('e') || mNumberFormatChar == QLatin1Char('g')))
8042 {
8043 mNumberBeautifulPowers = true;
8044 } else
8045 {
8046 qDebug() << Q_FUNC_INFO << "Invalid number format code (second char not 'b' or first char neither 'e' nor 'g'):" << formatCode;
8047 return;
8048 }
8049 if (formatCode.length() < 3)
8050 {
8051 mAxisPainter->numberMultiplyCross = false;
8052 return;
8053 }
8054
8055 // interpret third char as indicator for dot or cross multiplication symbol:
8056 if (formatCode.at(2) == QLatin1Char('c'))
8057 {
8058 mAxisPainter->numberMultiplyCross = true;
8059 } else if (formatCode.at(2) == QLatin1Char('d'))
8060 {
8061 mAxisPainter->numberMultiplyCross = false;
8062 } else
8063 {
8064 qDebug() << Q_FUNC_INFO << "Invalid number format code (third char neither 'c' nor 'd'):" << formatCode;
8065 return;
8066 }
8067}
8068
8069/*!
8070 Sets the precision of the tick label numbers. See QLocale::toString(double i, char f, int prec)

Callers 1

setupFullAxesBoxMethod · 0.80

Calls 3

containsMethod · 0.80
atMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected