MCPcopy Create free account
hub / github.com/CloudCompare/CloudCompare / setNumberFormat

Method setNumberFormat

qCC/extern/QCustomPlot/qcustomplot.cpp:8710–8763  ·  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

Source from the content-addressed store, hash-verified

8708 code will not be changed.
8709*/
8710void QCPAxis::setNumberFormat(const QString &formatCode)
8711{
8712 if (formatCode.isEmpty())
8713 {
8714 qDebug() << Q_FUNC_INFO << "Passed formatCode is empty";
8715 return;
8716 }
8717 mCachedMarginValid = false;
8718
8719 // interpret first char as number format char:
8720 QString allowedFormatChars(QLatin1String("eEfgG"));
8721 if (allowedFormatChars.contains(formatCode.at(0)))
8722 {
8723 mNumberFormatChar = QLatin1Char(formatCode.at(0).toLatin1());
8724 } else
8725 {
8726 qDebug() << Q_FUNC_INFO << "Invalid number format code (first char not in 'eEfgG'):" << formatCode;
8727 return;
8728 }
8729 if (formatCode.length() < 2)
8730 {
8731 mNumberBeautifulPowers = false;
8732 mAxisPainter->numberMultiplyCross = false;
8733 return;
8734 }
8735
8736 // interpret second char as indicator for beautiful decimal powers:
8737 if (formatCode.at(1) == QLatin1Char('b') && (mNumberFormatChar == QLatin1Char('e') || mNumberFormatChar == QLatin1Char('g')))
8738 {
8739 mNumberBeautifulPowers = true;
8740 } else
8741 {
8742 qDebug() << Q_FUNC_INFO << "Invalid number format code (second char not 'b' or first char neither 'e' nor 'g'):" << formatCode;
8743 return;
8744 }
8745 if (formatCode.length() < 3)
8746 {
8747 mAxisPainter->numberMultiplyCross = false;
8748 return;
8749 }
8750
8751 // interpret third char as indicator for dot or cross multiplication symbol:
8752 if (formatCode.at(2) == QLatin1Char('c'))
8753 {
8754 mAxisPainter->numberMultiplyCross = true;
8755 } else if (formatCode.at(2) == QLatin1Char('d'))
8756 {
8757 mAxisPainter->numberMultiplyCross = false;
8758 } else
8759 {
8760 qDebug() << Q_FUNC_INFO << "Invalid number format code (third char neither 'c' nor 'd'):" << formatCode;
8761 return;
8762 }
8763}
8764
8765/*!
8766 Sets the precision of the tick label numbers. See QLocale::toString(double i, char f, int prec)

Callers 1

setupFullAxesBoxMethod · 0.80

Calls 6

lengthMethod · 0.80
setSubstituteExponentMethod · 0.80
isEmptyMethod · 0.45
containsMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected