mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: explicitly update gas-axis
On each profile replot, the gas axis was implicitly reset by calling "dataModel->emitDataChanged()", which would send a signal recieved by the axis. To make the code less confusing and, more importantly, make order of execution deterministic, explicitly reset the axis. Rename the function that resets the axis from "settingsChanged" to "update" to reflect its usage. Moreover, remove the "setModel()" function and pass the model to the constructore. Make it a const reference to make clear that it can't change during the life time of the axis. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
f4103e4998
commit
dd0939b6f5
3 changed files with 16 additions and 24 deletions
|
@ -413,34 +413,27 @@ QString TemperatureAxis::textForValue(double value) const
|
|||
return QString::number(mkelvin_to_C((int)value));
|
||||
}
|
||||
|
||||
PartialGasPressureAxis::PartialGasPressureAxis(ProfileWidget2 *widget) :
|
||||
PartialGasPressureAxis::PartialGasPressureAxis(const DivePlotDataModel &model, ProfileWidget2 *widget) :
|
||||
DiveCartesianAxis(widget),
|
||||
model(NULL)
|
||||
model(model)
|
||||
{
|
||||
connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &PartialGasPressureAxis::settingsChanged);
|
||||
connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &PartialGasPressureAxis::update);
|
||||
}
|
||||
|
||||
void PartialGasPressureAxis::setModel(DivePlotDataModel *m)
|
||||
{
|
||||
model = m;
|
||||
connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(settingsChanged()));
|
||||
settingsChanged();
|
||||
}
|
||||
|
||||
void PartialGasPressureAxis::settingsChanged()
|
||||
void PartialGasPressureAxis::update()
|
||||
{
|
||||
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())
|
||||
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();
|
||||
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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue