diff options
author | Robert C. Helling <helling@atdotde.de> | 2019-03-20 16:29:27 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-03-29 06:51:12 -0700 |
commit | 5e494ce76106fe16f614e163c2bc6b8bf6903c86 (patch) | |
tree | 5162c2523e8a731eda22ce464e72c1d42124616d /profile-widget/diveeventitem.cpp | |
parent | 7635ee3e776f7adb96dda70ea21920569368ae30 (diff) | |
download | subsurface-5e494ce76106fe16f614e163c2bc6b8bf6903c86.tar.gz |
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>
Diffstat (limited to 'profile-widget/diveeventitem.cpp')
-rw-r--r-- | profile-widget/diveeventitem.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/profile-widget/diveeventitem.cpp b/profile-widget/diveeventitem.cpp index 64de02436..afde2dc92 100644 --- a/profile-widget/diveeventitem.cpp +++ b/profile-widget/diveeventitem.cpp @@ -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) |