mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Show a bit of surface degassing in the planner
to display the deco parameters at the surface, in particular tissue saturation and heat map. Suggeted-by: Matthias Heinrichs <info@heinrichsweikamp.com> Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
parent
7635ee3e77
commit
5e494ce761
5 changed files with 35 additions and 4 deletions
|
@ -1080,6 +1080,14 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
|
|||
diveplan->eff_gflow = lrint(100.0 * (regressiona() * first_stop_depth + regressionb()));
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_CYLINDERS; i++)
|
||||
if (cylinder_nodata(&dive->cylinder[i])) {
|
||||
// Switch to an empty air cylinder for breathing air at the surface
|
||||
// If no empty cylinder is found, keep using last deco gas
|
||||
current_cylinder = i;
|
||||
break;
|
||||
}
|
||||
plan_add_segment(diveplan, 600, 0, current_cylinder, 0, false, OC);
|
||||
create_dive_from_plan(diveplan, dive, is_planner);
|
||||
add_plan_to_notes(diveplan, dive, show_disclaimer, error);
|
||||
fixup_dc_duration(&dive->dc);
|
||||
|
|
|
@ -24,9 +24,12 @@ static int diveplan_duration(struct diveplan *diveplan)
|
|||
{
|
||||
struct divedatapoint *dp = diveplan->dp;
|
||||
int duration = 0;
|
||||
int lastdepth = 0;
|
||||
while(dp) {
|
||||
if (dp->time > duration)
|
||||
if (dp->time > duration && (dp->depth.mm > SURFACE_THRESHOLD || lastdepth > SURFACE_THRESHOLD)) {
|
||||
duration = dp->time;
|
||||
lastdepth = dp->depth.mm;
|
||||
}
|
||||
dp = dp->next;
|
||||
}
|
||||
return (duration + 30) / 60;
|
||||
|
@ -193,6 +196,9 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
!rebreatherchange_before &&
|
||||
!rebreatherchange_after)
|
||||
continue;
|
||||
// Ignore final surface segment for notes
|
||||
if (lastdepth == 0 && dp->depth.mm == 0 && !dp->next)
|
||||
continue;
|
||||
if ((dp->time - lasttime < 10 && lastdepth == dp->depth.mm) && !(gaschange_after && dp->next && dp->depth.mm != dp->next->depth.mm))
|
||||
continue;
|
||||
|
||||
|
|
|
@ -453,7 +453,7 @@ struct plot_info calculate_max_limits_new(struct dive *dive, struct divecomputer
|
|||
|
||||
if (depth > maxdepth)
|
||||
maxdepth = s->depth.mm;
|
||||
if ((depth > SURFACE_THRESHOLD || lastdepth > SURFACE_THRESHOLD) &&
|
||||
if ((depth > SURFACE_THRESHOLD || lastdepth > SURFACE_THRESHOLD || in_planner()) &&
|
||||
s->time.seconds > maxtime)
|
||||
maxtime = s->time.seconds;
|
||||
lastdepth = depth;
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include "core/membuffer.h"
|
||||
#include "core/subsurface-string.h"
|
||||
|
||||
#define DEPTH_NOT_FOUND (-2342)
|
||||
|
||||
extern struct ev_select *ev_namelist;
|
||||
extern int evn_used;
|
||||
|
||||
|
@ -234,7 +236,8 @@ bool DiveEventItem::shouldBeHidden()
|
|||
struct sample *first_sample = &dc->sample[0];
|
||||
if (!strcmp(event->name, "gaschange") &&
|
||||
(event->time.seconds == 0 ||
|
||||
(first_sample && event->time.seconds == first_sample->time.seconds)))
|
||||
(first_sample && event->time.seconds == first_sample->time.seconds) ||
|
||||
depthAtTime(event->time.seconds) < SURFACE_THRESHOLD))
|
||||
return true;
|
||||
|
||||
/*
|
||||
|
@ -254,6 +257,17 @@ bool DiveEventItem::shouldBeHidden()
|
|||
return false;
|
||||
}
|
||||
|
||||
int DiveEventItem::depthAtTime(int time)
|
||||
{
|
||||
QModelIndexList result = dataModel->match(dataModel->index(0, DivePlotDataModel::TIME), Qt::DisplayRole, time);
|
||||
if (result.isEmpty()) {
|
||||
Q_ASSERT("can't find a spot in the dataModel");
|
||||
hide();
|
||||
return DEPTH_NOT_FOUND;
|
||||
}
|
||||
return dataModel->data(dataModel->index(result.first().row(), DivePlotDataModel::DEPTH)).toInt();
|
||||
}
|
||||
|
||||
void DiveEventItem::recalculatePos(bool instant)
|
||||
{
|
||||
if (!vAxis || !hAxis || !internalEvent || !dataModel)
|
||||
|
@ -265,9 +279,11 @@ void DiveEventItem::recalculatePos(bool instant)
|
|||
hide();
|
||||
return;
|
||||
}
|
||||
int depth = depthAtTime(internalEvent->time.seconds);
|
||||
if (depth == DEPTH_NOT_FOUND)
|
||||
return;
|
||||
if (!isVisible() && !shouldBeHidden())
|
||||
show();
|
||||
int depth = dataModel->data(dataModel->index(result.first().row(), DivePlotDataModel::DEPTH)).toInt();
|
||||
qreal x = hAxis->posAtValue(internalEvent->time.seconds);
|
||||
qreal y = vAxis->posAtValue(depth);
|
||||
if (!instant)
|
||||
|
|
|
@ -27,6 +27,7 @@ slots:
|
|||
private:
|
||||
void setupToolTipString(struct gasmix lastgasmix);
|
||||
void setupPixmap(struct gasmix lastgasmix);
|
||||
int depthAtTime(int time);
|
||||
DiveCartesianAxis *vAxis;
|
||||
DiveCartesianAxis *hAxis;
|
||||
DivePlotDataModel *dataModel;
|
||||
|
|
Loading…
Reference in a new issue