10 #include <QTextStream>
27 using namespace swift::misc::aviation;
28 using namespace swift::misc::physical_quantities;
30 namespace swift::sample
32 int CSamplesPhysicalQuantities::samples(QTextStream &out)
39 out <<
"units: " << lu1 <<
" " << lu2 <<
" " << lu1s <<
" " << lu2s <<
" " << lu1.
getName(
true) <<
" "
40 << lu2.
getName(
true) << Qt::endl;
41 const CLength l1(5.0, CLengthUnit::ft());
42 CLength l2(1, CLengthUnit::NM());
43 CLength l3(1, CLengthUnit::km());
46 out << CLengthUnit::ft() << Qt::endl;
47 out << l1 <<
" " << l2 <<
" " << l3 <<
" " << l4 << Qt::endl;
50 out << l3.
getUnit() << Qt::endl;
55 out << l2 <<
" " << l3 << Qt::endl;
58 out <<
"doubled l3: " << l3 << Qt::endl;
61 CLength nullLength(0, CLengthUnit::nullUnit());
62 out <<
"Null PQ: " << nullLength <<
" converted " << nullLength.
valueRoundedWithUnit(CLengthUnit::m(), 2)
76 out << s2 <<
" " << s3 << Qt::endl;
78 CAngle a1(180, CAngleUnit::deg());
79 CAngle a2(1.5 * CAngle::PI(), CAngleUnit::rad());
80 CAngle a3(180.5, CAngleUnit::deg());
81 CAngle a4(35.4336, CAngleUnit::sexagesimalDeg());
91 out << a2 << Qt::endl;
94 out << a3 <<
" " << a4 << Qt::endl;
96 CMass w1(1, CMassUnit::tonne());
108 out << t1 <<
" " << t2 <<
" " << t2.
valueRoundedWithUnit(CTemperatureUnit::defaultUnit(), -1,
true);
111 <<
"I18N/UTF" << Qt::endl;
113 (t1 - t2).switchUnit(CTemperatureUnit::F());
116 out << duB << Qt::endl;
118 CTime ti1(1, CTimeUnit::h());
121 CTime ti3(1.0101, CTimeUnit::hms());
122 CTime ti4(1.15, CTimeUnit::hrmin());
123 CTime ti5(1.30, CTimeUnit::minsec());
126 CTime ti8(
"12:30:40");
128 out << ti1 <<
" " << ti2 <<
" " << ti3 <<
" " << ti4 <<
" " << ti5 << Qt::endl;
129 out << ti6 <<
" " << ti7 <<
" " << ti8 << Qt::endl;
133 <<
"I18N/UTF" << Qt::endl;
136 out <<
"-----------------------------------------------" << Qt::endl;
static const physical_quantities::CPressure & standardISASeaLevelPressure()
Standard pressure 1013.25mbar/hPa.
QString toQString(bool i18n=false) const
Cast as QString.
Physical unit angle (radians, degrees)
double piFactor() const
Value as factor of PI (e.g. 0.5PI)
Physical unit length (length)
Specialized class for distance units (meter, foot, nautical miles).
QString getName(bool i18n=false) const
Name such as "meter".
const MU & getUnit() const
Unit.
PQ & switchUnit(const MU &newUnit)
Change unit, and convert value to maintain the same quantity.
QString valueRoundedWithUnit(const MU &unit, int digits=-1, bool withGroupSeparator=false, bool i18n=false) const
Value to QString with the given unit, e.g. "5.00m".
Physical unit temperature.
Free functions in swift::misc.