/* PIP - Platform Independent Primitives Pressure units Ivan Pelipenko peri4ko@yandex.ru This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ #include "piunits_class_pressure.h" PIString PIUnits::Class::Pressure::name(int type) const { switch (type) { case Pascal: return "pascal"_tr("PIUnitsPressure"); case Atmosphere: return "atmosphere"_tr("PIUnitsPressure"); case Bar: return "bar"_tr("PIUnitsPressure"); case MillimetreOfMercury: return "mm Hg"_tr("PIUnitsPressure"); } return Class::Internal::unknown; } PIString PIUnits::Class::Pressure::unit(int type) const { switch (type) { case Pascal: return "Pa"_tr("PIUnitsPressure"); case Atmosphere: return "atm"_tr("PIUnitsPressure"); case Bar: return "bar"_tr("PIUnitsPressure"); case MillimetreOfMercury: return "mmHg"_tr("PIUnitsPressure"); } return Class::Internal::unknown; } double PIUnits::Class::Pressure::convert(double v, int from, int to) const { double pa = v; switch (from) { case Atmosphere: pa /= 9.86923E-6; break; case Bar: pa /= 1.E-5; break; case MillimetreOfMercury: pa *= 133.322387415; break; default: break; } switch (to) { case Atmosphere: return pa * 9.86923E-6; case Bar: return pa * 1.E-5; case MillimetreOfMercury: return pa / 133.322387415; default: break; } return pa; } PIString PIUnits::Class::Pressure::valueToString(double v, char format, int prec) const { return PIString::fromNumber(v, format, prec); } bool PIUnits::Class::Pressure::supportPrefixes(int type) const { if (type == Pascal) return true; return false; } bool PIUnits::Class::Pressure::supportPrefixesNon3(int type) const { return false; } bool PIUnits::Class::Pressure::supportPrefixesGreater(int type) const { return ClassBase::supportPrefixesGreater(type); } bool PIUnits::Class::Pressure::supportPrefixesSmaller(int type) const { return ClassBase::supportPrefixesSmaller(type); }