mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Planner: automate calculation of best mix for max depth
Add option to calculate the best mix portion of O2 and He for the dive's max depth if the user enters * in the MOD and MND cylinder fields. Gas portions are automatically recalculated if the max depth of the dive changes. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
ae9e147314
commit
f08b0e0e3e
5 changed files with 88 additions and 13 deletions
|
@ -41,6 +41,7 @@ void DivePlannerPointsModel::createSimpleDive()
|
|||
addStop(M_OR_FT(5, 15), 42 * 60, 0, cylinderid, true);
|
||||
addStop(M_OR_FT(5, 15), 45 * 60, 0, cylinderid, true);
|
||||
}
|
||||
updateMaxDepth();
|
||||
}
|
||||
|
||||
void DivePlannerPointsModel::setupStartTime()
|
||||
|
@ -136,6 +137,19 @@ void DivePlannerPointsModel::setupCylinders()
|
|||
CylindersModel::instance()->copyFromDive(&displayed_dive);
|
||||
}
|
||||
|
||||
// Update the dive's maximum depth. Returns true if max depth changed
|
||||
bool DivePlannerPointsModel::updateMaxDepth()
|
||||
{
|
||||
int prevMaxDepth = displayed_dive.maxdepth.mm;
|
||||
displayed_dive.maxdepth.mm = 0;
|
||||
for (int i = 0; i < rowCount(); i++) {
|
||||
divedatapoint p = at(i);
|
||||
if (p.depth > displayed_dive.maxdepth.mm)
|
||||
displayed_dive.maxdepth.mm = p.depth;
|
||||
}
|
||||
return (displayed_dive.maxdepth.mm != prevMaxDepth);
|
||||
}
|
||||
|
||||
QStringList &DivePlannerPointsModel::getGasList()
|
||||
{
|
||||
static QStringList list;
|
||||
|
@ -257,8 +271,11 @@ bool DivePlannerPointsModel::setData(const QModelIndex &index, const QVariant &v
|
|||
divedatapoint &p = divepoints[index.row()];
|
||||
switch (index.column()) {
|
||||
case DEPTH:
|
||||
if (value.toInt() >= 0)
|
||||
if (value.toInt() >= 0) {
|
||||
p.depth = units_to_depth(value.toInt());
|
||||
if (updateMaxDepth())
|
||||
CylindersModel::instance()->updateBestMixes();
|
||||
}
|
||||
break;
|
||||
case RUNTIME:
|
||||
p.time = value.toInt() * 60;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue