core: turn M_OR_FT macro into a function

No point in this being a macro. Make it return a depth_t - it
was unclear that this returns a depth in mm.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-12-14 10:10:19 +01:00 committed by Michael Keller
parent 0e77dd9a68
commit bd2f7e72f1
11 changed files with 105 additions and 97 deletions

View file

@ -237,13 +237,13 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
} else {
pressure_t modpO2;
modpO2.mbar = inPlanner ? prefs.bottompo2 : (int)(prefs.modpO2 * 1000.0);
return get_depth_string(d->gas_mod(cyl->gasmix, modpO2, M_OR_FT(1,1)), true);
return get_depth_string(d->gas_mod(cyl->gasmix, modpO2, m_or_ft(1, 1).mm), true);
}
case MND:
if (cyl->bestmix_he)
return QStringLiteral("*");
else
return get_depth_string(d->gas_mnd(cyl->gasmix, prefs.bestmixend, M_OR_FT(1,1)), true);
return get_depth_string(d->gas_mnd(cyl->gasmix, prefs.bestmixend, m_or_ft(1, 1).mm), true);
break;
case USE:
return gettextFromC::tr(cylinderuse_text[cyl->cylinder_use]);
@ -414,7 +414,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
prefs.o2consumption / prefs.decosac / prefs.pscr_ratio;
else
modpO2.mbar = prefs.decopo2;
cyl.depth = d->gas_mod(cyl.gasmix, modpO2, M_OR_FT(3, 10));
cyl.depth = d->gas_mod(cyl.gasmix, modpO2, m_or_ft(3, 10).mm);
cyl.bestmix_o2 = false;
}
type = Command::EditCylinderType::GASMIX;
@ -443,7 +443,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
}
pressure_t modpO2;
modpO2.mbar = prefs.decopo2;
cyl.depth = d->gas_mod(cyl.gasmix, modpO2, M_OR_FT(3, 10));
cyl.depth = d->gas_mod(cyl.gasmix, modpO2, m_or_ft(3, 10).mm);
}
type = Command::EditCylinderType::GASMIX;
break;
@ -649,8 +649,8 @@ void CylindersModel::updateDecoDepths(pressure_t olddecopo2)
for (auto &cyl: d->cylinders) {
/* If the gas's deco MOD matches the old pO2, it will have been automatically calculated and should be updated.
* If they don't match, we should leave the user entered depth as it is */
if (cyl.depth.mm == d->gas_mod(cyl.gasmix, olddecopo2, M_OR_FT(3, 10)).mm) {
cyl.depth = d->gas_mod(cyl.gasmix, decopo2, M_OR_FT(3, 10));
if (cyl.depth.mm == d->gas_mod(cyl.gasmix, olddecopo2, m_or_ft(3, 10).mm).mm) {
cyl.depth = d->gas_mod(cyl.gasmix, decopo2, m_or_ft(3, 10).mm);
}
}
emit dataChanged(createIndex(0, 0), createIndex(numRows - 1, COLUMNS - 1));
@ -680,7 +680,7 @@ bool CylindersModel::updateBestMixes()
cyl.gasmix.he.permille = 1000 - get_o2(cyl.gasmix);
pressure_t modpO2;
modpO2.mbar = prefs.decopo2;
cyl.depth = d->gas_mod(cyl.gasmix, modpO2, M_OR_FT(3, 10));
cyl.depth = d->gas_mod(cyl.gasmix, modpO2, m_or_ft(3, 10).mm);
gasUpdated = true;
}
if (cyl.bestmix_he) {