6 #include <QCoreApplication>
20 namespace swift::misc::physical_quantities
26 void CLengthUnit::anchor() {}
28 void CFrequencyUnit::anchor() {}
30 void CMassUnit::anchor() {}
32 void CPressureUnit::anchor() {}
34 void CTemperatureUnit::anchor() {}
36 void CSpeedUnit::anchor() {}
38 void CAccelerationUnit::anchor() {}
47 Q_ASSERT(digits >= 0);
51 const char *fmt = value < 0 ?
"-%1 %2 %3" :
"%1 %2 %3";
53 s = s.
arg(fabs(de), 0,
'f', 0).
arg(fabs(mi), 2,
'f', 0,
'0').
arg(fabs(se), 3 + digits,
'f', digits,
'0');
58 Q_ASSERT(digits >= 0);
61 const char *fmt = value < 0 ?
"-%1 %2" :
"%1 %2";
63 s = s.
arg(fabs(de), 0,
'f', 0).
arg(fabs(mi), 3 + digits,
'f', digits,
'0');
76 Q_ASSERT(digits >= 0);
80 const char *fmt = value < 0 ?
"-%1h%2m%3s" :
"%1h%2m%3s";
82 s =
s.arg(fabs(hr), 2,
'f', 0,
'0')
83 .arg(fabs(mi), 2,
'f', 0,
'0')
84 .arg(fabs(se), 3 + digits,
'f', digits,
'0');
89 Q_ASSERT(digits >= 0);
92 const char *fmt = value < 0 ?
"-%1h%2m" :
"%1h%2m";
94 s =
s.arg(fabs(hr), 2,
'f', 0,
'0').arg(fabs(mi), 3 + digits,
'f', digits,
'0');
99 Q_ASSERT(digits >= 0);
102 const char *fmt = value < 0 ?
"-%2m%3s" :
"%2m%3s";
104 s =
s.arg(fabs(mi), 2,
'f', 0,
'0').arg(fabs(se), 3 + digits,
'f', digits,
'0');
static double trunc(double value, double epsilon=1e-10)
Nearest integer not greater in magnitude than value, correcting for epsilon.
static CAngleUnit sexagesimalDegMin()
Sexagesimal degree (degrees, minutes, decimal minutes)
virtual QString makeRoundedQStringWithUnit(double value, int digits=-1, bool withGroupSeparator=false, bool i18n=false) const
Value rounded with unit, e.g. "5.00m", "30kHz".
static CAngleUnit sexagesimalDeg()
Sexagesimal degree (degrees, minutes, seconds, decimal seconds)
virtual QString makeRoundedQStringWithUnit(double value, int digits=-1, bool withGroupSeparator=false, bool i18n=false) const
Value rounded with unit, e.g. "5.00m", "30kHz".
int getDisplayDigits() const
Display digits.
virtual QString makeRoundedQStringWithUnit(double value, int digits=-1, bool withGroupSeparator=false, bool i18n=false) const
Value rounded with unit, e.g. "5.00m", "30kHz".
static CTimeUnit hrmin()
Hours, minutes.
static CTimeUnit hms()
Hours, minutes, seconds.
static CTimeUnit s()
Second s.
static CTimeUnit minsec()
Minutes, seconds.
QString translate(const char *context, const char *sourceText, const char *disambiguation, int n)
QString arg(Args &&... args) const const
#define SWIFT_DEFINE_UNIT_MIXINS(MU)
Explicit template definition of mixins for a CMeasurementUnit subclass.