fixes #0003137: Unit UserString wrong

This commit is contained in:
wmayer
2017-07-24 16:52:03 +02:00
parent 80ad5737f0
commit 7ab8a9996d
3 changed files with 25 additions and 3 deletions

View File

@@ -42,6 +42,14 @@ QString UnitsSchemaInternal::schemaTranslate(const Quantity &quant, double &fact
double UnitValue = std::abs(quant.getValue());
Unit unit = quant.getUnit();
// In order to get the right factor always express the target
// units as internal units where length is in mm and mass in kg
// Example:
// For W/mm/K we get the factor of 1000000.0 because
// W/mm/K = kg*m^2/s^3/mm/K
// = 10e6 * kg*mm^2/s^3/mm/K
// = 10e6 * kg*mm/s^3/K
// now do special treatment on all cases seems necessary:
if (unit == Unit::Length) { // Length handling ============================
if (UnitValue < 0.000000001) {// smaller then 0.001 nm -> scientific notation
@@ -108,7 +116,7 @@ QString UnitsSchemaInternal::schemaTranslate(const Quantity &quant, double &fact
else if (unit == Unit::ThermalConductivity) {
if (UnitValue < 1000) {
unitString = QString::fromLatin1("W/mm/K");
factor = 1.0;
factor = 1000000.0;
}
else {
unitString = QString::fromLatin1("W/m/K");