mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
1df1f3d0b5
commit
e0f44237cc
3 changed files with 13 additions and 30 deletions
|
@ -349,6 +349,16 @@ bool ProfileScene::pointOnProfile(const QPointF &point) const
|
|||
return timeAxis->pointInRange(point.x()) && profileYAxis->pointInRange(point.y());
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsModel *plannerModel,
|
||||
bool inPlanner, bool instant, bool keepPlotInfo, bool calcMax, double zoom, double zoomedPosition)
|
||||
{
|
||||
|
@ -471,10 +481,11 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM
|
|||
tankItem->setData(d, firstSecond, lastSecond);
|
||||
|
||||
if (ppGraphsEnabled(currentdc, simplified)) {
|
||||
double max = prefs.pp_graphs.phe ? max_gas(dataModel->data(), &gas_pressures::he) : -1;
|
||||
if (prefs.pp_graphs.pn2)
|
||||
max = std::max(dataModel->pn2Max(), max);
|
||||
max = std::max(max_gas(dataModel->data(), &gas_pressures::n2), max);
|
||||
if (prefs.pp_graphs.po2)
|
||||
max = std::max(dataModel->po2Max(), max);
|
||||
max = std::max(max_gas(dataModel->data(), &gas_pressures::o2), max);
|
||||
|
||||
gasYAxis->setBounds(0.0, max);
|
||||
gasYAxis->updateTicks(animSpeed);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue