profile: move setting of gasYAxis bounds to plotDive()

The partial-pressure-axis was the only DiveCartesianAxis
child that had its own code to set the bounds. The bounds
of all other axes were set in plotDive().

For consistency, do this here as well. Thus, the whole
class can be removed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-09-26 19:30:27 +02:00 committed by Dirk Hohndel
parent 0de40a85b7
commit 2c4e4b1e86
4 changed files with 12 additions and 44 deletions

View file

@ -407,34 +407,3 @@ QString TimeAxis::textForValue(double value) const
return QString("%1:%2").arg(nr).arg((int)value % 60, 2, 10, QChar('0'));
return QString::number(nr);
}
PartialGasPressureAxis::PartialGasPressureAxis(const DivePlotDataModel &model, Position position, int integralDigits, int fractionalDigits,
color_index_t gridColor, double dpr, double labelScale, bool printMode, bool isGrayscale,
ProfileScene &scene) :
DiveCartesianAxis(position, integralDigits, fractionalDigits, gridColor, dpr, labelScale, printMode, isGrayscale, scene),
model(model)
{
}
void PartialGasPressureAxis::update(int animSpeed)
{
bool showPhe = prefs.pp_graphs.phe;
bool showPn2 = prefs.pp_graphs.pn2;
bool showPo2 = prefs.pp_graphs.po2;
setVisible(showPhe || showPn2 || showPo2);
if (!model.rowCount())
return;
double max = showPhe ? model.pheMax() : -1;
if (showPn2 && model.pn2Max() > max)
max = model.pn2Max();
if (showPo2 && model.po2Max() > max)
max = model.po2Max();
qreal pp = floor(max * 10.0) / 10.0 + 0.2;
if (IS_FP_SAME(maximum(), pp))
return;
setBounds(0.0, pp);
updateTicks(animSpeed);
}

View file

@ -110,14 +110,4 @@ public:
using DiveCartesianAxis::DiveCartesianAxis;
};
class PartialGasPressureAxis : public DiveCartesianAxis {
Q_OBJECT
public:
PartialGasPressureAxis(const DivePlotDataModel &model, Position position, int integralDigits, int fractionalDigits,
color_index_t gridColor, double dpr, double labelScale, bool printMode, bool isGrayscale, ProfileScene &scene);
void update(int animSpeed);
private:
const DivePlotDataModel &model;
};
#endif // DIVECARTESIANAXIS_H

View file

@ -48,7 +48,7 @@ ProfileScene::ProfileScene(double dpr, bool printMode, bool isGrayscale) :
maxdepth(-1),
dataModel(new DivePlotDataModel(this)),
profileYAxis(new DepthAxis(DiveCartesianAxis::Position::Left, 3, 0, TIME_GRID, dpr, 1.0, printMode, isGrayscale, *this)),
gasYAxis(new PartialGasPressureAxis(*dataModel, DiveCartesianAxis::Position::Right, 1, 2, TIME_GRID, dpr, 0.7, printMode, isGrayscale, *this)),
gasYAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Right, 1, 2, TIME_GRID, dpr, 0.7, printMode, isGrayscale, *this)),
temperatureAxis(new TemperatureAxis(DiveCartesianAxis::Position::Right, 3, 0, TIME_GRID, dpr, 1.0, printMode, isGrayscale, *this)),
timeAxis(new TimeAxis(DiveCartesianAxis::Position::Bottom, 2, 2, TIME_GRID, dpr, 1.0, printMode, isGrayscale, *this)),
cylinderPressureAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Right, 4, 0, TIME_GRID, dpr, 1.0, printMode, isGrayscale, *this)),
@ -450,7 +450,16 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM
#endif
tankItem->setData(&plotInfo, d);
gasYAxis->update(animSpeed);
if (ppGraphsEnabled()) {
double max = prefs.pp_graphs.phe ? dataModel->pheMax() : -1;
if (prefs.pp_graphs.pn2)
max = std::max(dataModel->pn2Max(), max);
if (prefs.pp_graphs.po2)
max = std::max(dataModel->po2Max(), max);
gasYAxis->setBounds(0.0, max);
gasYAxis->updateTicks(animSpeed);
}
// Replot dive items
for (AbstractProfilePolygonItem *item: profileItems)

View file

@ -72,7 +72,7 @@ private:
DivePlotDataModel *dataModel;
struct plot_info plotInfo;
DepthAxis *profileYAxis;
PartialGasPressureAxis *gasYAxis;
DiveCartesianAxis *gasYAxis;
TemperatureAxis *temperatureAxis;
TimeAxis *timeAxis;
DiveCartesianAxis *cylinderPressureAxis;