From 5e494ce76106fe16f614e163c2bc6b8bf6903c86 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Wed, 20 Mar 2019 16:29:27 +0100 Subject: 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 Signed-off-by: Robert C. Helling --- profile-widget/diveeventitem.cpp | 20 ++++++++++++++++++-- profile-widget/diveeventitem.h | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'profile-widget') 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) diff --git a/profile-widget/diveeventitem.h b/profile-widget/diveeventitem.h index 6547fa716..2039da616 100644 --- a/profile-widget/diveeventitem.h +++ b/profile-widget/diveeventitem.h @@ -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; -- cgit v1.2.3-70-g09d2