add the following units:
- mmol - ml - bar - mbar - kJ - kWh - eV - C - T - F (p, n, u, m) - H (n, u, m)
This commit is contained in:
@@ -246,7 +246,8 @@ Quantity Quantity::DeciMetre (100.0 ,Unit(1));
|
||||
Quantity Quantity::Metre (1.0e3 ,Unit(1));
|
||||
Quantity Quantity::KiloMetre (1.0e6 ,Unit(1));
|
||||
|
||||
Quantity Quantity::Liter (1000000.0 ,Unit(3));
|
||||
Quantity Quantity::MilliLiter (1000.0 ,Unit(3));
|
||||
Quantity Quantity::Liter (1.0e6 ,Unit(3));
|
||||
|
||||
Quantity Quantity::Hertz (1.0 ,Unit(0,0,-1));
|
||||
Quantity Quantity::KiloHertz (1.0e3 ,Unit(0,0,-1));
|
||||
@@ -272,6 +273,7 @@ Quantity Quantity::Kelvin (1.0 ,Unit(0,0,0,0,1));
|
||||
Quantity Quantity::MilliKelvin (0.001 ,Unit(0,0,0,0,1));
|
||||
Quantity Quantity::MicroKelvin (0.000001 ,Unit(0,0,0,0,1));
|
||||
|
||||
Quantity Quantity::MilliMole (0.001 ,Unit(0,0,0,0,0,1));
|
||||
Quantity Quantity::Mole (1.0 ,Unit(0,0,0,0,0,1));
|
||||
|
||||
Quantity Quantity::Candela (1.0 ,Unit(0,0,0,0,0,0,1));
|
||||
@@ -299,6 +301,9 @@ Quantity Quantity::KiloPascal (1.00 ,Unit(-1,1,-2));
|
||||
Quantity Quantity::MegaPascal (1000.0 ,Unit(-1,1,-2));
|
||||
Quantity Quantity::GigaPascal (1e+6 ,Unit(-1,1,-2));
|
||||
|
||||
Quantity Quantity::MilliBar (0.1 ,Unit(-1,1,-2));
|
||||
Quantity Quantity::Bar (100.0 ,Unit(-1,1,-2)); // 1 bar = 100 kPa
|
||||
|
||||
Quantity Quantity::Torr (101.325/760.0 ,Unit(-1,1,-2)); // Torr is a defined fraction of Pascal (kg/m/s^2 or N/m^2)
|
||||
Quantity Quantity::mTorr (0.101325/760.0,Unit(-1,1,-2)); // Torr is a defined fraction of Pascal (kg/m/s^2 or N/m^2)
|
||||
Quantity Quantity::yTorr (0.000101325/760.0 ,Unit(-1,1,-2)); // Torr is a defined fraction of Pascal (kg/m/s^2 or N/m^2)
|
||||
@@ -309,12 +314,32 @@ Quantity Quantity::KSI (6894.744825494,Unit(-1,1,-2)); // 1000 x po
|
||||
Quantity Quantity::Watt (1e+6 ,Unit(2,1,-3)); // Watt (kg*m^2/s^3)
|
||||
Quantity Quantity::VoltAmpere (1e+6 ,Unit(2,1,-3)); // VoltAmpere (kg*m^2/s^3)
|
||||
|
||||
Quantity Quantity::Volt (1e+6 ,Unit(2,1,-3,-1)); // Volt (kg*m^2/A/s^3)
|
||||
Quantity Quantity::Volt (1e+6 ,Unit(2,1,-3,-1)); // Volt (kg*m^2/A/s^3)
|
||||
Quantity Quantity::MilliVolt (1e+3 ,Unit(2,1,-3,-1));
|
||||
Quantity Quantity::KiloVolt (1e+9 ,Unit(2,1,-3,-1));
|
||||
|
||||
Quantity Quantity::Joule (1e+6 ,Unit(2,1,-2)); // Joule (kg*m^2/s^2)
|
||||
Quantity Quantity::NewtonMeter (1e+6 ,Unit(2,1,-2)); // Joule (kg*m^2/s^2)
|
||||
Quantity Quantity::VoltAmpereSecond (1e+6 ,Unit(2,1,-2)); // Joule (kg*m^2/s^2)
|
||||
Quantity Quantity::WattSecond (1e+6 ,Unit(2,1,-2)); // Joule (kg*m^2/s^2)
|
||||
Quantity Quantity::Coulomb (1.0 ,Unit(0,0,1,1)); // Coulomb (A*s)
|
||||
|
||||
Quantity Quantity::Tesla (1.0 ,Unit(0,1,-2,-1)); // Tesla (kg/s^2/A)
|
||||
|
||||
Quantity Quantity::PicoFarad (1e-18 ,Unit(-2,-1,4,2));
|
||||
Quantity Quantity::NanoFarad (1e-15 ,Unit(-2,-1,4,2));
|
||||
Quantity Quantity::MicroFarad (1e-12 ,Unit(-2,-1,4,2));
|
||||
Quantity Quantity::MilliFarad (1e-9 ,Unit(-2,-1,4,2));
|
||||
Quantity Quantity::Farad (1e-6 ,Unit(-2,-1,4,2)); // Farad (s^4*A^2/m^2/kg)
|
||||
|
||||
Quantity Quantity::NanoHenry (1e-3 ,Unit(2,1,-2,-2));
|
||||
Quantity Quantity::MicroHenry (1.0 ,Unit(2,1,-2,-2));
|
||||
Quantity Quantity::MilliHenry (1e+3 ,Unit(2,1,-2,-2));
|
||||
Quantity Quantity::Henry (1e+6 ,Unit(2,1,-2,-2)); // Henry (kg*m^2/s^2/A^2)
|
||||
|
||||
Quantity Quantity::Joule (1e+6 ,Unit(2,1,-2)); // Joule (kg*m^2/s^2)
|
||||
Quantity Quantity::KiloJoule (1e+9 ,Unit(2,1,-2));
|
||||
Quantity Quantity::NewtonMeter (1e+6 ,Unit(2,1,-2)); // Joule (kg*m^2/s^2)
|
||||
Quantity Quantity::VoltAmpereSecond (1e+6 ,Unit(2,1,-2)); // Joule (kg*m^2/s^2)
|
||||
Quantity Quantity::WattSecond (1e+6 ,Unit(2,1,-2)); // Joule (kg*m^2/s^2)
|
||||
Quantity Quantity::KiloWattHour (3.6e+12 ,Unit(2,1,-2)); // 1 kWh = 3.6e6 J
|
||||
Quantity Quantity::ElectronVolt (1.602176634e-13 ,Unit(2,1,-2)); // 1 eV = 1.602176634e-19 J
|
||||
|
||||
Quantity Quantity::KMH (277.778 ,Unit(1,0,-1)); // km/h
|
||||
Quantity Quantity::MPH (447.04 ,Unit(1,0,-1)); // Mile/h
|
||||
|
||||
@@ -187,6 +187,7 @@ public:
|
||||
static Quantity KiloMetre;
|
||||
|
||||
static Quantity Liter;
|
||||
static Quantity MilliLiter;
|
||||
|
||||
static Quantity Hertz;
|
||||
static Quantity KiloHertz;
|
||||
@@ -212,6 +213,7 @@ public:
|
||||
static Quantity MilliKelvin;
|
||||
static Quantity MicroKelvin;
|
||||
|
||||
static Quantity MilliMole;
|
||||
static Quantity Mole;
|
||||
|
||||
static Quantity Candela;
|
||||
@@ -239,6 +241,9 @@ public:
|
||||
static Quantity MegaPascal;
|
||||
static Quantity GigaPascal;
|
||||
|
||||
static Quantity Bar;
|
||||
static Quantity MilliBar;
|
||||
|
||||
static Quantity Torr;
|
||||
static Quantity mTorr;
|
||||
static Quantity yTorr;
|
||||
@@ -250,11 +255,31 @@ public:
|
||||
static Quantity VoltAmpere;
|
||||
|
||||
static Quantity Volt;
|
||||
static Quantity MilliVolt;
|
||||
static Quantity KiloVolt;
|
||||
|
||||
static Quantity Coulomb;
|
||||
|
||||
static Quantity Tesla;
|
||||
|
||||
static Quantity Farad;
|
||||
static Quantity MilliFarad;
|
||||
static Quantity MicroFarad;
|
||||
static Quantity NanoFarad;
|
||||
static Quantity PicoFarad;
|
||||
|
||||
static Quantity Henry;
|
||||
static Quantity MilliHenry;
|
||||
static Quantity MicroHenry;
|
||||
static Quantity NanoHenry;
|
||||
|
||||
static Quantity Joule;
|
||||
static Quantity KiloJoule;
|
||||
static Quantity NewtonMeter;
|
||||
static Quantity VoltAmpereSecond;
|
||||
static Quantity WattSecond;
|
||||
static Quantity KiloWattHour;
|
||||
static Quantity ElectronVolt;
|
||||
|
||||
static Quantity KMH;
|
||||
static Quantity MPH;
|
||||
|
||||
@@ -53,7 +53,8 @@ CGRP '\,'[0-9][0-9][0-9]
|
||||
"m" yylval = Quantity::Metre; return UNIT; // metre
|
||||
"km" yylval = Quantity::KiloMetre; return UNIT; // kilo meter
|
||||
|
||||
"l" yylval = Quantity::Liter; return UNIT; // Liter dm^3
|
||||
"l" yylval = Quantity::Liter; return UNIT; // Liter (dm^3)
|
||||
"ml" yylval = Quantity::MilliLiter; return UNIT; // milli Liter
|
||||
|
||||
"Hz" yylval = Quantity::Hertz; return UNIT; // Hertz
|
||||
"kHz" yylval = Quantity::KiloHertz; return UNIT; // Kilo Hertz
|
||||
@@ -82,6 +83,7 @@ CGRP '\,'[0-9][0-9][0-9]
|
||||
"uK" yylval = Quantity::MicroKelvin; return UNIT; // Kelvin
|
||||
|
||||
"mol" yylval = Quantity::Mole; return UNIT; // Mole (internal standard amount of substance)
|
||||
"mmol" yylval = Quantity::Mole; return UNIT; // Milli Mole
|
||||
|
||||
"cd" yylval = Quantity::Candela; return UNIT; // Candela (internal standard luminous intensity)
|
||||
|
||||
@@ -94,8 +96,6 @@ CGRP '\,'[0-9][0-9][0-9]
|
||||
"yd" yylval = Quantity::Yard; return UNIT; // yard
|
||||
"mi" yylval = Quantity::Mile; return UNIT; // mile
|
||||
|
||||
|
||||
|
||||
"lb" yylval = Quantity::Pound; return UNIT; // pound
|
||||
"lbm" yylval = Quantity::Pound; return UNIT; // pound
|
||||
"oz" yylval = Quantity::Ounce; return UNIT; // ounce
|
||||
@@ -114,6 +114,9 @@ CGRP '\,'[0-9][0-9][0-9]
|
||||
"MPa" yylval = Quantity::MegaPascal; return UNIT; // Pascal
|
||||
"GPa" yylval = Quantity::GigaPascal; return UNIT; // Pascal
|
||||
|
||||
"bar" yylval = Quantity::Bar; return UNIT; // 1 bar = 100 kPa
|
||||
"mbar" yylval = Quantity::MilliBar; return UNIT; // Milli Bar
|
||||
|
||||
"Torr" yylval = Quantity::Torr; return UNIT; // portion of Pascal ( 101325/760 )
|
||||
"mTorr" yylval = Quantity::mTorr; return UNIT; //
|
||||
"uTorr" yylval = Quantity::yTorr; return UNIT; //
|
||||
@@ -123,15 +126,38 @@ CGRP '\,'[0-9][0-9][0-9]
|
||||
"ksi" yylval = Quantity::KSI; return UNIT; // 1000 x pounds/in^2
|
||||
|
||||
"W" yylval = Quantity::Watt; return UNIT; // Watt (kg*m^2/s^3)
|
||||
"mW" yylval = Quantity::Watt; return UNIT; // Milli Watt
|
||||
"VA" yylval = Quantity::VoltAmpere; return UNIT; // VoltAmpere (kg*m^2/s^3)
|
||||
|
||||
"V" yylval = Quantity::Volt; return UNIT; // Volt (kg*m^2/A/s^3)
|
||||
"kV" yylval = Quantity::KiloVolt; return UNIT; // Kilo Volt
|
||||
"mV" yylval = Quantity::MilliVolt; return UNIT; // Milli Volt
|
||||
|
||||
"C" yylval = Quantity::Coulomb; return UNIT; // Coulomb (A*s)
|
||||
|
||||
"T" yylval = Quantity::Tesla; return UNIT; // Tesla (kg/s^2/A)
|
||||
|
||||
"F" yylval = Quantity::Farad; return UNIT; // Farad (s^4*A^2/m^2/kg)
|
||||
"mF" yylval = Quantity::MilliFarad; return UNIT; // Milli Farad
|
||||
"\xC2\xB5F" yylval = Quantity::MicroFarad; return UNIT; // Micro Farad
|
||||
"uF" yylval = Quantity::MicroFarad; return UNIT; // Micro Farad
|
||||
"nF" yylval = Quantity::NanoFarad; return UNIT; // Nano Farad
|
||||
"pF" yylval = Quantity::PicoFarad; return UNIT; // Pico Farad
|
||||
|
||||
"H" yylval = Quantity::Henry; return UNIT; // Henry (kg*m^2/s^2/A^2)
|
||||
"mH" yylval = Quantity::MilliHenry; return UNIT; // Milli Henry
|
||||
"\xC2\xB5H" yylval = Quantity::MicroHenry; return UNIT; // Micro Henry
|
||||
"uH" yylval = Quantity::MicroHenry; return UNIT; // Micro Henry
|
||||
"nH" yylval = Quantity::NanoHenry; return UNIT; // Nano Henry
|
||||
|
||||
"J" yylval = Quantity::Joule; return UNIT; // Joule (kg*m^2/s^2)
|
||||
"kJ" yylval = Quantity::KiloJoule; return UNIT; // Kilo Joule
|
||||
"Nm" yylval = Quantity::NewtonMeter; return UNIT; // N*m = Joule
|
||||
"VAs" yylval = Quantity::VoltAmpereSecond; return UNIT; // V*A*s = Joule
|
||||
"CV" yylval = Quantity::WattSecond; return UNIT; //
|
||||
"Ws" yylval = Quantity::WattSecond; return UNIT; // W*s = Joule
|
||||
"kWh" yylval = Quantity::KiloWattHour; return UNIT; // 1 kWh = 3.6e6 J
|
||||
"eV" yylval = Quantity::ElectronVolt; return UNIT; // 1 eV = 1.602176634e-19 J
|
||||
|
||||
"\xC2\xB0" yylval = Quantity::Degree; return UNIT; // degree (internal standard angle)
|
||||
"deg" yylval = Quantity::Degree; return UNIT; // degree (internal standard angle)
|
||||
|
||||
@@ -439,6 +439,10 @@ QString Unit::getTypeString(void) const
|
||||
if(*this == Unit::Temperature ) return QString::fromLatin1("Temperature");
|
||||
if(*this == Unit::ElectricCurrent ) return QString::fromLatin1("ElectricCurrent");
|
||||
if(*this == Unit::ElectricPotential ) return QString::fromLatin1("ElectricPotential");
|
||||
if(*this == Unit::ElectricCharge ) return QString::fromLatin1("ElectricCharge");
|
||||
if(*this == Unit::MagneticFluxDensity ) return QString::fromLatin1("MagneticFluxDensity");
|
||||
if(*this == Unit::ElectricalCapacitance ) return QString::fromLatin1("ElectricalCapacitance");
|
||||
if(*this == Unit::ElectricalInductance ) return QString::fromLatin1("ElectricalInductance");
|
||||
if(*this == Unit::AmountOfSubstance ) return QString::fromLatin1("AmountOfSubstance");
|
||||
if(*this == Unit::LuminousIntensity ) return QString::fromLatin1("LuminousIntensity");
|
||||
if(*this == Unit::Pressure ) return QString::fromLatin1("Pressure");
|
||||
@@ -478,6 +482,10 @@ Unit Unit::Temperature(0,0,0,0,1);
|
||||
|
||||
Unit Unit::ElectricCurrent(0,0,0,1);
|
||||
Unit Unit::ElectricPotential(2,1,-3,-1);
|
||||
Unit Unit::ElectricCharge(0,0,1,1);
|
||||
Unit Unit::MagneticFluxDensity(0,1,-2,-1);
|
||||
Unit Unit::ElectricalCapacitance(-2,-1,4,2);
|
||||
Unit Unit::ElectricalInductance(2,1,-2,-2);
|
||||
Unit Unit::AmountOfSubstance(0,0,0,0,0,1);
|
||||
Unit Unit::LuminousIntensity(0,0,0,0,0,0,1);
|
||||
|
||||
|
||||
@@ -110,6 +110,10 @@ public:
|
||||
|
||||
static Unit ElectricCurrent;
|
||||
static Unit ElectricPotential;
|
||||
static Unit ElectricCharge;
|
||||
static Unit MagneticFluxDensity;
|
||||
static Unit ElectricalCapacitance;
|
||||
static Unit ElectricalInductance;
|
||||
static Unit AmountOfSubstance;
|
||||
static Unit LuminousIntensity;
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ QString UnitsSchemaInternal::schemaTranslate(const Quantity &quant, double &fact
|
||||
|
||||
// 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
|
||||
if (UnitValue < 0.000000001) {// smaller than 0.001 nm -> scientific notation
|
||||
unitString = QString::fromLatin1("mm");
|
||||
factor = 1.0;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ QString UnitsSchemaInternal::schemaTranslate(const Quantity &quant, double &fact
|
||||
unitString = QString::fromLatin1("km");
|
||||
factor = 1000000.0;
|
||||
}
|
||||
else { // bigger then 1000 km -> scientific notation
|
||||
else { // bigger than 1000 km -> scientific notation
|
||||
unitString = QString::fromLatin1("mm");
|
||||
factor = 1.0;
|
||||
}
|
||||
|
||||
@@ -175,8 +175,76 @@ QString UnitsSchemaMKS::schemaTranslate(const Quantity &quant, double &factor, Q
|
||||
factor = 1000000;
|
||||
}
|
||||
else if (unit == Unit::ElectricPotential) {
|
||||
unitString = QString::fromLatin1("V");
|
||||
factor = 1000000;
|
||||
if (UnitValue < 1.0) {
|
||||
unitString = QString::fromLatin1("mV");
|
||||
factor = 1e3;
|
||||
}
|
||||
if (UnitValue < 1e3) {
|
||||
unitString = QString::fromLatin1("V");
|
||||
factor = 1e6;
|
||||
}
|
||||
if (UnitValue < 1e6) {
|
||||
unitString = QString::fromLatin1("kV");
|
||||
factor = 1e9;
|
||||
}
|
||||
}
|
||||
else if (unit == Unit::ElectricCharge) {
|
||||
unitString = QString::fromLatin1("C");
|
||||
factor = 1.0;
|
||||
}
|
||||
else if (unit == Unit::MagneticFluxDensity) {
|
||||
unitString = QString::fromLatin1("T");
|
||||
factor = 1.0;
|
||||
}
|
||||
else if (unit == Unit::ElectricalCapacitance) {
|
||||
if (UnitValue < 1e-15) {
|
||||
unitString = QString::fromLatin1("pF");
|
||||
factor = 1e-18;
|
||||
}
|
||||
else if (UnitValue < 1e-12) {
|
||||
unitString = QString::fromLatin1("nF");
|
||||
factor = 1e-15;
|
||||
}
|
||||
else if (UnitValue < 1e-9) {
|
||||
unitString = QString::fromUtf8("µF");
|
||||
factor = 1e-12;
|
||||
}
|
||||
else if (UnitValue < 1e-6) {
|
||||
unitString = QString::fromLatin1("mF");
|
||||
factor = 1e-9;
|
||||
}
|
||||
else {
|
||||
unitString = QString::fromLatin1("F");
|
||||
factor = 1e-6;
|
||||
}
|
||||
}
|
||||
else if (unit == Unit::ElectricalInductance) {
|
||||
if (UnitValue < 1e-6) {
|
||||
unitString = QString::fromLatin1("nH");
|
||||
factor = 1e-3;
|
||||
}
|
||||
else if (UnitValue < 1e-3) {
|
||||
unitString = QString::fromUtf8("µH");
|
||||
factor = 1.0;
|
||||
}
|
||||
else if (UnitValue < 1.0) {
|
||||
unitString = QString::fromLatin1("mH");
|
||||
factor = 1e3;
|
||||
}
|
||||
else {
|
||||
unitString = QString::fromLatin1("H");
|
||||
factor = 1e6;
|
||||
}
|
||||
}
|
||||
else if (unit == Unit::Work) {
|
||||
if (UnitValue < 1e3) {
|
||||
unitString = QString::fromLatin1("J");
|
||||
factor = 1e6;
|
||||
}
|
||||
else {
|
||||
unitString = QString::fromLatin1("kJ");
|
||||
factor = 1e9;
|
||||
}
|
||||
}
|
||||
else if (unit == Unit::SpecificEnergy) {
|
||||
unitString = QString::fromLatin1("m^2/s^2");
|
||||
|
||||
Reference in New Issue
Block a user