Don't show surface events at the beginning or end of the dive

That's just annoying and pointless.  So we arbitrarily say that surface
events within the first and last 30s of the dive are suppressed.

But we now do show them in the middle, in case the sampling rate is too
low, and the profile itself doesn't show that we got to the surface.

These heuristics still needs tweaking - if the profile already shows
that we're at the surface, then we should probably suppress the event
triangle.

But in the meantime this at least gets rid of the truly pointless cases.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2016-05-31 11:56:35 -07:00 committed by Dirk Hohndel
parent 5ea16c0bab
commit 36a3f649c5

View file

@ -150,17 +150,29 @@ void DiveEventItem::eventVisibilityChanged(const QString &eventName, bool visibl
bool DiveEventItem::shouldBeHidden()
{
struct event *event = internalEvent;
struct dive *dive = &displayed_dive;
struct divecomputer *dc = get_dive_dc(dive, dc_number);
/*
* Some gas change events are special. Some dive computers just tell us the initial gas this way.
* Don't bother showing those
*/
struct sample *first_sample = &get_dive_dc(&displayed_dive, dc_number)->sample[0];
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)))
return true;
/*
* Some divecomputers give "surface" events that just aren't interesting.
* Like at the beginning or very end of a dive. Well, duh.
*/
if (!strcmp(event->name, "surface")) {
int time = event->time.seconds;
if (time <= 30 || time + 30 >= dc->duration.seconds)
return true;
}
for (int i = 0; i < evn_used; i++) {
if (!strcmp(event->name, ev_namelist[i].ev_name) && ev_namelist[i].plot_ev == false)
return true;