profile: move max_gas() from DivePlotDataModel to ProfileScene

There is only one user of this - let's remove complex
interdependencies.

Note: there seem to be two independent plot_infos: in the
ProfileScene and in the DivePlotDataModel. To avoid behavioral
change, this keeps using the DivePlotDataModel's version.
In any case, this has to be unified.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-12-03 14:18:31 +01:00 committed by Dirk Hohndel
parent 1df1f3d0b5
commit e0f44237cc
3 changed files with 13 additions and 30 deletions

View file

@ -178,28 +178,3 @@ void DivePlotDataModel::setDive(const plot_info &info)
memcpy(pInfo.pressures, info.pressures, sizeof(plot_pressure_data) * pInfo.nr_cylinders * pInfo.nr);
endResetModel();
}
static double max_gas(const plot_info &pi, double gas_pressures::*gas)
{
double ret = -1;
for (int i = 0; i < pi.nr; ++i) {
if (pi.entry[i].pressures.*gas > ret)
ret = pi.entry[i].pressures.*gas;
}
return ret;
}
double DivePlotDataModel::pheMax() const
{
return max_gas(pInfo, &gas_pressures::he);
}
double DivePlotDataModel::pn2Max() const
{
return max_gas(pInfo, &gas_pressures::n2);
}
double DivePlotDataModel::po2Max() const
{
return max_gas(pInfo, &gas_pressures::o2);
}

View file

@ -63,9 +63,6 @@ public:
void clear();
void setDive(const plot_info &pInfo);
const plot_info &data() const;
double pheMax() const;
double pn2Max() const;
double po2Max() const;
private:
struct plot_info pInfo;