15 #ifndef QGSFRACTIONNUMERICFORMAT_H
16 #define QGSFRACTIONNUMERICFORMAT_H
18 #include "qgis_core.h"
39 QString
id()
const override;
54 bool useDedicatedUnicodeCharacters()
const;
62 void setUseDedicatedUnicodeCharacters(
bool enabled );
69 bool useUnicodeSuperSubscript()
const;
76 void setUseUnicodeSuperSubscript(
bool enabled );
82 bool showThousandsSeparator()
const;
88 void setShowThousandsSeparator(
bool show );
94 bool showPlusSign()
const;
100 void setShowPlusSign(
bool show );
108 QChar thousandsSeparator()
const;
116 void setThousandsSeparator( QChar character );
131 static bool doubleToVulgarFraction(
const double value,
unsigned long long &numerator
SIP_OUT,
unsigned long long &denominator
SIP_OUT,
int &sign
SIP_OUT,
const double tolerance = 1e-10 )
133 sign = value < 0 ? -1 : 1;
134 double g = std::fabs( value );
135 unsigned long long a = 0;
136 unsigned long long b = 1;
137 unsigned long long c = 1;
138 unsigned long long d = 0;
139 unsigned long long s;
140 unsigned int iteration = 0;
144 numerator = a + s *
c;
145 denominator = b + s * d;
151 if (
qgsDoubleNear(
static_cast< double >( sign )*
static_cast< double >( numerator ) / denominator, value, tolerance ) )
156 while ( iteration++ < 100 );
164 static QString toUnicodeSuperscript(
const QString &input );
170 static QString toUnicodeSubscript(
const QString &input );
177 virtual void setConfiguration(
const QVariantMap &configuration,
const QgsReadWriteContext &context );
181 bool mUseDedicatedUnicode =
false;
182 bool mUseUnicodeSuperSubscript =
true;
183 bool mShowThousandsSeparator =
true;
184 bool mShowPlusSign =
false;
185 QChar mThousandsSeparator;
188 #endif // QGSFRACTIONNUMERICFORMAT_H