2017-04-27 18:26:36 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2016-04-05 05:02:03 +00:00
|
|
|
#include "profile-widget/diveeventitem.h"
|
|
|
|
#include "profile-widget/divecartesianaxis.h"
|
2021-08-30 19:11:11 +00:00
|
|
|
#include "profile-widget/divepixmapcache.h"
|
2016-04-05 05:02:03 +00:00
|
|
|
#include "profile-widget/animationfunctions.h"
|
2020-10-25 08:14:16 +00:00
|
|
|
#include "core/event.h"
|
2021-07-20 05:52:54 +00:00
|
|
|
#include "core/format.h"
|
2016-04-05 05:02:03 +00:00
|
|
|
#include "core/profile.h"
|
|
|
|
#include "core/gettextfromc.h"
|
2020-10-25 12:28:55 +00:00
|
|
|
#include "core/sample.h"
|
2018-05-11 15:25:41 +00:00
|
|
|
#include "core/subsurface-string.h"
|
2014-01-16 17:02:32 +00:00
|
|
|
|
2019-03-20 15:29:27 +00:00
|
|
|
#define DEPTH_NOT_FOUND (-2342)
|
|
|
|
|
2021-08-31 18:44:37 +00:00
|
|
|
static int depthAtTime(const plot_info &pi, duration_t time);
|
|
|
|
|
2021-06-05 07:15:51 +00:00
|
|
|
DiveEventItem::DiveEventItem(const struct dive *d, struct event *ev, struct gasmix lastgasmix,
|
2021-08-31 18:44:37 +00:00
|
|
|
const plot_info &pi, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis,
|
2021-08-30 19:11:11 +00:00
|
|
|
int speed, const DivePixmaps &pixmaps, QGraphicsItem *parent) : DivePixmapItem(parent),
|
2021-06-05 07:15:51 +00:00
|
|
|
vAxis(vAxis),
|
|
|
|
hAxis(hAxis),
|
2021-06-05 07:29:41 +00:00
|
|
|
ev(ev),
|
2021-08-31 18:44:37 +00:00
|
|
|
dive(d),
|
|
|
|
depth(depthAtTime(pi, ev->time))
|
2014-01-16 17:02:32 +00:00
|
|
|
{
|
|
|
|
setFlag(ItemIgnoresTransformations);
|
2021-06-05 07:05:46 +00:00
|
|
|
|
2021-08-30 19:11:11 +00:00
|
|
|
setupPixmap(lastgasmix, pixmaps);
|
2021-06-05 07:05:46 +00:00
|
|
|
setupToolTipString(lastgasmix);
|
|
|
|
recalculatePos(0);
|
2014-01-16 17:02:32 +00:00
|
|
|
|
2021-06-05 07:15:51 +00:00
|
|
|
connect(vAxis, &DiveCartesianAxis::sizeChanged, this,
|
|
|
|
[speed, this] { recalculatePos(speed); });
|
2014-01-16 17:02:32 +00:00
|
|
|
}
|
|
|
|
|
2021-06-05 07:15:51 +00:00
|
|
|
DiveEventItem::~DiveEventItem()
|
2014-01-16 17:02:32 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-06-05 07:29:41 +00:00
|
|
|
const struct event *DiveEventItem::getEvent() const
|
2014-02-25 20:27:12 +00:00
|
|
|
{
|
2021-06-05 07:29:41 +00:00
|
|
|
return ev;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct event *DiveEventItem::getEventMutable()
|
|
|
|
{
|
|
|
|
return ev;
|
2014-02-25 20:27:12 +00:00
|
|
|
}
|
|
|
|
|
2021-08-30 19:11:11 +00:00
|
|
|
void DiveEventItem::setupPixmap(struct gasmix lastgasmix, const DivePixmaps &pixmaps)
|
2014-01-16 17:02:32 +00:00
|
|
|
{
|
2021-06-05 07:29:41 +00:00
|
|
|
if (empty_string(ev->name)) {
|
2021-08-30 19:11:11 +00:00
|
|
|
setPixmap(pixmaps.warning);
|
2021-06-05 07:29:41 +00:00
|
|
|
} else if (same_string_caseinsensitive(ev->name, "modechange")) {
|
|
|
|
if (ev->value == 0)
|
2021-08-30 19:11:11 +00:00
|
|
|
setPixmap(pixmaps.bailout);
|
2018-04-07 12:56:37 +00:00
|
|
|
else
|
2021-08-30 19:11:11 +00:00
|
|
|
setPixmap(pixmaps.onCCRLoop);
|
2021-06-05 07:29:41 +00:00
|
|
|
} else if (ev->type == SAMPLE_EVENT_BOOKMARK) {
|
2021-08-30 19:11:11 +00:00
|
|
|
setPixmap(pixmaps.bookmark);
|
2021-06-05 07:29:41 +00:00
|
|
|
} else if (event_is_gaschange(ev)) {
|
|
|
|
struct gasmix mix = get_gasmix_from_event(dive, ev);
|
2018-01-20 17:21:39 +00:00
|
|
|
struct icd_data icd_data;
|
2018-08-16 17:10:10 +00:00
|
|
|
bool icd = isobaric_counterdiffusion(lastgasmix, mix, &icd_data);
|
2018-08-16 11:35:14 +00:00
|
|
|
if (mix.he.permille) {
|
2018-01-20 17:21:39 +00:00
|
|
|
if (icd)
|
2021-08-30 19:11:11 +00:00
|
|
|
setPixmap(pixmaps.gaschangeTrimixICD);
|
2018-01-20 17:21:39 +00:00
|
|
|
else
|
2021-08-30 19:11:11 +00:00
|
|
|
setPixmap(pixmaps.gaschangeTrimix);
|
2018-08-16 17:10:10 +00:00
|
|
|
} else if (gasmix_is_air(mix)) {
|
2018-01-20 17:21:39 +00:00
|
|
|
if (icd)
|
2021-08-30 19:11:11 +00:00
|
|
|
setPixmap(pixmaps.gaschangeAirICD);
|
2018-01-20 17:21:39 +00:00
|
|
|
else
|
2021-08-30 19:11:11 +00:00
|
|
|
setPixmap(pixmaps.gaschangeAir);
|
2018-08-16 11:35:14 +00:00
|
|
|
} else if (mix.o2.permille == 1000) {
|
2018-01-20 17:21:39 +00:00
|
|
|
if (icd)
|
2021-08-30 19:11:11 +00:00
|
|
|
setPixmap(pixmaps.gaschangeOxygenICD);
|
2018-01-20 17:21:39 +00:00
|
|
|
else
|
2021-08-30 19:11:11 +00:00
|
|
|
setPixmap(pixmaps.gaschangeOxygen);
|
2018-01-20 17:21:39 +00:00
|
|
|
} else {
|
|
|
|
if (icd)
|
2021-08-30 19:11:11 +00:00
|
|
|
setPixmap(pixmaps.gaschangeEANICD);
|
2018-01-20 17:21:39 +00:00
|
|
|
else
|
2021-08-30 19:11:11 +00:00
|
|
|
setPixmap(pixmaps.gaschangeEAN);
|
2018-01-20 17:21:39 +00:00
|
|
|
}
|
2016-07-23 07:08:41 +00:00
|
|
|
#ifdef SAMPLE_FLAGS_SEVERITY_SHIFT
|
2021-06-05 07:29:41 +00:00
|
|
|
} else if ((((ev->flags & SAMPLE_FLAGS_SEVERITY_MASK) >> SAMPLE_FLAGS_SEVERITY_SHIFT) == 1) ||
|
2016-07-23 07:08:41 +00:00
|
|
|
// those are useless internals of the dive computer
|
|
|
|
#else
|
|
|
|
} else if (
|
|
|
|
#endif
|
2021-06-05 07:29:41 +00:00
|
|
|
same_string_caseinsensitive(ev->name, "heading") ||
|
|
|
|
(same_string_caseinsensitive(ev->name, "SP change") && ev->time.seconds == 0)) {
|
2015-02-07 16:47:59 +00:00
|
|
|
// 2 cases:
|
|
|
|
// a) some dive computers have heading in every sample
|
|
|
|
// b) at t=0 we might have an "SP change" to indicate dive type
|
|
|
|
// in both cases we want to get the right data into the tooltip but don't want the visual clutter
|
|
|
|
// so set an "almost invisible" pixmap (a narrow but somewhat tall, basically transparent pixmap)
|
2014-11-14 19:52:55 +00:00
|
|
|
// that allows tooltips to work when we don't want to show a specific
|
|
|
|
// pixmap for an event, but want to show the event value in the tooltip
|
2021-08-30 19:11:11 +00:00
|
|
|
setPixmap(pixmaps.transparent);
|
2016-07-23 07:08:41 +00:00
|
|
|
#ifdef SAMPLE_FLAGS_SEVERITY_SHIFT
|
2021-06-05 07:29:41 +00:00
|
|
|
} else if (((ev->flags & SAMPLE_FLAGS_SEVERITY_MASK) >> SAMPLE_FLAGS_SEVERITY_SHIFT) == 2) {
|
2021-08-30 19:11:11 +00:00
|
|
|
setPixmap(pixmaps.info);
|
2021-06-05 07:29:41 +00:00
|
|
|
} else if (((ev->flags & SAMPLE_FLAGS_SEVERITY_MASK) >> SAMPLE_FLAGS_SEVERITY_SHIFT) == 3) {
|
2021-08-30 19:11:11 +00:00
|
|
|
setPixmap(pixmaps.warning);
|
2021-06-05 07:29:41 +00:00
|
|
|
} else if (((ev->flags & SAMPLE_FLAGS_SEVERITY_MASK) >> SAMPLE_FLAGS_SEVERITY_SHIFT) == 4) {
|
2021-08-30 19:11:11 +00:00
|
|
|
setPixmap(pixmaps.violation);
|
2016-07-23 07:08:41 +00:00
|
|
|
#endif
|
2021-06-05 07:29:41 +00:00
|
|
|
} else if (same_string_caseinsensitive(ev->name, "violation") || // generic libdivecomputer
|
|
|
|
same_string_caseinsensitive(ev->name, "Safety stop violation") || // the rest are from the Uemis downloader
|
|
|
|
same_string_caseinsensitive(ev->name, "pO₂ ascend alarm") ||
|
|
|
|
same_string_caseinsensitive(ev->name, "RGT alert") ||
|
|
|
|
same_string_caseinsensitive(ev->name, "Dive time alert") ||
|
|
|
|
same_string_caseinsensitive(ev->name, "Low battery alert") ||
|
|
|
|
same_string_caseinsensitive(ev->name, "Speed alarm")) {
|
2021-08-30 19:11:11 +00:00
|
|
|
setPixmap(pixmaps.violation);
|
2021-06-05 07:29:41 +00:00
|
|
|
} else if (same_string_caseinsensitive(ev->name, "non stop time") || // generic libdivecomputer
|
|
|
|
same_string_caseinsensitive(ev->name, "safety stop") ||
|
|
|
|
same_string_caseinsensitive(ev->name, "safety stop (voluntary)") ||
|
|
|
|
same_string_caseinsensitive(ev->name, "Tank change suggested") || // Uemis downloader
|
|
|
|
same_string_caseinsensitive(ev->name, "Marker")) {
|
2021-08-30 19:11:11 +00:00
|
|
|
setPixmap(pixmaps.info);
|
2014-01-16 17:02:32 +00:00
|
|
|
} else {
|
2016-07-23 07:08:41 +00:00
|
|
|
// we should do some guessing based on the type / name of the event;
|
|
|
|
// for now they all get the warning icon
|
2021-08-30 19:11:11 +00:00
|
|
|
setPixmap(pixmaps.warning);
|
2014-01-16 17:02:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-16 17:10:10 +00:00
|
|
|
void DiveEventItem::setupToolTipString(struct gasmix lastgasmix)
|
2014-01-16 17:02:32 +00:00
|
|
|
{
|
2014-02-25 20:27:12 +00:00
|
|
|
// we display the event on screen - so translate
|
2021-06-05 07:29:41 +00:00
|
|
|
QString name = gettextFromC::tr(ev->name);
|
|
|
|
int value = ev->value;
|
|
|
|
int type = ev->type;
|
2015-01-03 06:09:01 +00:00
|
|
|
|
2021-06-05 07:29:41 +00:00
|
|
|
if (event_is_gaschange(ev)) {
|
2018-01-20 20:39:38 +00:00
|
|
|
struct icd_data icd_data;
|
2021-06-05 07:29:41 +00:00
|
|
|
struct gasmix mix = get_gasmix_from_event(dive, ev);
|
Start using the actual cylinder data for gas switch events
Now that gas switch events always have indices into the cylinder table,
start using that to look up the gas mix from the cylinders rather than
from the gas switch event itself. In other words, the cylinder index is
now the primary data for gas switch events.
This means that now as you change the cylinder information, the gas
switch events will automatically update to reflect those changes.
Note that on loading data from the outside (either from a xml file, from
a git/cloud account, or from a dive computer), we may or may not
initially have an index for the gas change event. The external data may
be from an older version of subsurface, or it may be from a
libdivecomputer download that just doesn't give index data at all.
In that case, we will do:
- if there is no index, but there is explicit gas mix information, we
will look up the index based on that gas mix, picking the cylinder
that has the closest mix.
- if there isn't even explicit gas mix data, so we only have the event
value from libdivecomputer, we will turn that value into a gasmix,
and use that to look up the cylinder index as above.
- if no valid cylinder information is available at all, gas switch
events will just be dropped.
When saving the data, we now always save the cylinder index, and the gas
mix associated with that cylinder (that gas mix will be ignored on load,
since the index is the primary, but it makes the event much easier to
read).
It is worth noting we do not modify the libdivecomputer value, even if
the gasmix has changed, so that remains as a record of the original
download.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-02 21:07:06 +00:00
|
|
|
name += ": ";
|
2018-08-16 17:10:10 +00:00
|
|
|
name += gasname(mix);
|
Start using the actual cylinder data for gas switch events
Now that gas switch events always have indices into the cylinder table,
start using that to look up the gas mix from the cylinders rather than
from the gas switch event itself. In other words, the cylinder index is
now the primary data for gas switch events.
This means that now as you change the cylinder information, the gas
switch events will automatically update to reflect those changes.
Note that on loading data from the outside (either from a xml file, from
a git/cloud account, or from a dive computer), we may or may not
initially have an index for the gas change event. The external data may
be from an older version of subsurface, or it may be from a
libdivecomputer download that just doesn't give index data at all.
In that case, we will do:
- if there is no index, but there is explicit gas mix information, we
will look up the index based on that gas mix, picking the cylinder
that has the closest mix.
- if there isn't even explicit gas mix data, so we only have the event
value from libdivecomputer, we will turn that value into a gasmix,
and use that to look up the cylinder index as above.
- if no valid cylinder information is available at all, gas switch
events will just be dropped.
When saving the data, we now always save the cylinder index, and the gas
mix associated with that cylinder (that gas mix will be ignored on load,
since the index is the primary, but it makes the event much easier to
read).
It is worth noting we do not modify the libdivecomputer value, even if
the gasmix has changed, so that remains as a record of the original
download.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-02 21:07:06 +00:00
|
|
|
|
|
|
|
/* Do we have an explicit cylinder index? Show it. */
|
2021-06-05 07:29:41 +00:00
|
|
|
if (ev->gas.index >= 0)
|
|
|
|
name += tr(" (cyl. %1)").arg(ev->gas.index + 1);
|
2018-08-16 17:10:10 +00:00
|
|
|
bool icd = isobaric_counterdiffusion(lastgasmix, mix, &icd_data);
|
2018-01-20 20:39:38 +00:00
|
|
|
if (icd_data.dHe < 0) {
|
2021-07-20 05:52:54 +00:00
|
|
|
name += qasprintf_loc("\n%s %s:%+.3g%% %s:%+.3g%%%s%+.3g%%",
|
|
|
|
qPrintable(tr("ICD")),
|
|
|
|
qPrintable(tr("ΔHe")), icd_data.dHe / 10.0,
|
|
|
|
qPrintable(tr("ΔN₂")), icd_data.dN2 / 10.0,
|
|
|
|
icd ? ">" : "<", lrint(-icd_data.dHe / 5.0) / 10.0);
|
2018-01-20 20:39:38 +00:00
|
|
|
}
|
2021-06-05 07:29:41 +00:00
|
|
|
} else if (same_string(ev->name, "modechange")) {
|
|
|
|
name += QString(": %1").arg(gettextFromC::tr(divemode_text_ui[ev->value]));
|
Start using the actual cylinder data for gas switch events
Now that gas switch events always have indices into the cylinder table,
start using that to look up the gas mix from the cylinders rather than
from the gas switch event itself. In other words, the cylinder index is
now the primary data for gas switch events.
This means that now as you change the cylinder information, the gas
switch events will automatically update to reflect those changes.
Note that on loading data from the outside (either from a xml file, from
a git/cloud account, or from a dive computer), we may or may not
initially have an index for the gas change event. The external data may
be from an older version of subsurface, or it may be from a
libdivecomputer download that just doesn't give index data at all.
In that case, we will do:
- if there is no index, but there is explicit gas mix information, we
will look up the index based on that gas mix, picking the cylinder
that has the closest mix.
- if there isn't even explicit gas mix data, so we only have the event
value from libdivecomputer, we will turn that value into a gasmix,
and use that to look up the cylinder index as above.
- if no valid cylinder information is available at all, gas switch
events will just be dropped.
When saving the data, we now always save the cylinder index, and the gas
mix associated with that cylinder (that gas mix will be ignored on load,
since the index is the primary, but it makes the event much easier to
read).
It is worth noting we do not modify the libdivecomputer value, even if
the gasmix has changed, so that remains as a record of the original
download.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-02 21:07:06 +00:00
|
|
|
} else if (value) {
|
2021-06-05 07:29:41 +00:00
|
|
|
if (type == SAMPLE_EVENT_PO2 && same_string(ev->name, "SP change")) {
|
2017-02-21 17:04:00 +00:00
|
|
|
name += QString(": %1bar").arg((double)value / 1000, 0, 'f', 1);
|
2021-06-05 07:29:41 +00:00
|
|
|
} else if (type == SAMPLE_EVENT_CEILING && same_string(ev->name, "planned waypoint above ceiling")) {
|
2017-02-21 18:26:38 +00:00
|
|
|
const char *depth_unit;
|
|
|
|
double depth_value = get_depth_units(value*1000, NULL, &depth_unit);
|
|
|
|
name += QString(": %1%2").arg((int) round(depth_value)).arg(depth_unit);
|
2014-01-16 17:02:32 +00:00
|
|
|
} else {
|
2017-02-21 17:04:00 +00:00
|
|
|
name += QString(": %1").arg(value);
|
2014-01-16 17:02:32 +00:00
|
|
|
}
|
2021-06-05 07:29:41 +00:00
|
|
|
} else if (type == SAMPLE_EVENT_PO2 && same_string(ev->name, "SP change")) {
|
2014-05-05 16:28:58 +00:00
|
|
|
// this is a bad idea - we are abusing an existing event type that is supposed to
|
2017-03-06 12:36:42 +00:00
|
|
|
// warn of high or low pO₂ and are turning it into a setpoint change event
|
2017-02-21 17:04:00 +00:00
|
|
|
name += ":\n" + tr("Manual switch to OC");
|
2014-01-16 17:02:32 +00:00
|
|
|
} else {
|
2021-06-05 07:29:41 +00:00
|
|
|
name += ev->flags & SAMPLE_FLAGS_BEGIN ? tr(" begin", "Starts with space!") :
|
|
|
|
ev->flags & SAMPLE_FLAGS_END ? tr(" end", "Starts with space!") : "";
|
2014-01-16 17:02:32 +00:00
|
|
|
}
|
2014-02-25 20:27:12 +00:00
|
|
|
setToolTip(name);
|
2014-01-16 17:02:32 +00:00
|
|
|
}
|
|
|
|
|
2018-05-21 16:20:29 +00:00
|
|
|
void DiveEventItem::eventVisibilityChanged(const QString&, bool)
|
2014-01-16 17:02:32 +00:00
|
|
|
{
|
2016-03-08 05:22:34 +00:00
|
|
|
//WARN: lookslike we should implement this.
|
2014-01-16 17:02:32 +00:00
|
|
|
}
|
|
|
|
|
2021-08-31 18:44:37 +00:00
|
|
|
static int depthAtTime(const plot_info &pi, duration_t time)
|
2014-03-16 22:10:03 +00:00
|
|
|
{
|
2021-08-31 18:31:55 +00:00
|
|
|
// Do a binary search for the timestamp
|
|
|
|
auto it = std::lower_bound(pi.entry, pi.entry + pi.nr, time,
|
2021-08-31 18:44:37 +00:00
|
|
|
[](const plot_data &d1, duration_t t) { return d1.sec < t.seconds; });
|
|
|
|
if (it == pi.entry + pi.nr || it->sec != time.seconds) {
|
2021-08-31 18:10:24 +00:00
|
|
|
qWarning("can't find a spot in the dataModel");
|
|
|
|
return DEPTH_NOT_FOUND;
|
|
|
|
}
|
2021-08-31 18:31:55 +00:00
|
|
|
return it->depth;
|
2021-08-31 18:10:24 +00:00
|
|
|
}
|
2014-07-01 19:07:38 +00:00
|
|
|
|
2021-08-31 18:10:24 +00:00
|
|
|
bool DiveEventItem::isInteresting(const struct dive *d, const struct divecomputer *dc,
|
2021-08-31 18:44:37 +00:00
|
|
|
const struct event *ev, const plot_info &pi)
|
2021-08-31 18:10:24 +00:00
|
|
|
{
|
2014-07-01 19:07:38 +00:00
|
|
|
/*
|
2014-10-28 20:48:15 +00:00
|
|
|
* Some gas change events are special. Some dive computers just tell us the initial gas this way.
|
|
|
|
* Don't bother showing those
|
2014-07-01 19:07:38 +00:00
|
|
|
*/
|
2021-01-09 17:58:33 +00:00
|
|
|
const struct sample *first_sample = &dc->sample[0];
|
2021-06-05 07:29:41 +00:00
|
|
|
if (!strcmp(ev->name, "gaschange") &&
|
|
|
|
(ev->time.seconds == 0 ||
|
|
|
|
(first_sample && ev->time.seconds == first_sample->time.seconds) ||
|
2021-08-31 18:44:37 +00:00
|
|
|
depthAtTime(pi, ev->time) < SURFACE_THRESHOLD))
|
2021-08-31 18:10:24 +00:00
|
|
|
return false;
|
2014-10-28 20:48:15 +00:00
|
|
|
|
2016-05-31 18:56:35 +00:00
|
|
|
/*
|
|
|
|
* Some divecomputers give "surface" events that just aren't interesting.
|
|
|
|
* Like at the beginning or very end of a dive. Well, duh.
|
|
|
|
*/
|
2021-06-05 07:29:41 +00:00
|
|
|
if (!strcmp(ev->name, "surface")) {
|
|
|
|
int time = ev->time.seconds;
|
2016-07-23 07:12:16 +00:00
|
|
|
if (time <= 30 || time + 30 >= (int)dc->duration.seconds)
|
2021-08-31 18:10:24 +00:00
|
|
|
return false;
|
2016-05-31 18:56:35 +00:00
|
|
|
}
|
2021-08-31 18:10:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-05-31 18:56:35 +00:00
|
|
|
|
2021-08-31 18:10:24 +00:00
|
|
|
bool DiveEventItem::shouldBeHidden()
|
|
|
|
{
|
2014-03-16 22:10:03 +00:00
|
|
|
for (int i = 0; i < evn_used; i++) {
|
2021-06-05 07:29:41 +00:00
|
|
|
if (!strcmp(ev->name, ev_namelist[i].ev_name) && ev_namelist[i].plot_ev == false)
|
2014-03-16 22:10:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-07-10 19:57:51 +00:00
|
|
|
void DiveEventItem::recalculatePos(int speed)
|
2014-01-16 17:02:32 +00:00
|
|
|
{
|
2021-06-05 07:29:41 +00:00
|
|
|
if (!ev)
|
2014-01-16 17:02:32 +00:00
|
|
|
return;
|
2014-02-23 16:35:06 +00:00
|
|
|
|
2021-08-31 18:10:24 +00:00
|
|
|
if (depth == DEPTH_NOT_FOUND) {
|
|
|
|
hide();
|
2019-03-20 15:29:27 +00:00
|
|
|
return;
|
2021-08-31 18:10:24 +00:00
|
|
|
}
|
|
|
|
setVisible(!shouldBeHidden());
|
2021-06-05 07:29:41 +00:00
|
|
|
qreal x = hAxis->posAtValue(ev->time.seconds);
|
2014-01-16 17:02:32 +00:00
|
|
|
qreal y = vAxis->posAtValue(depth);
|
2019-07-10 19:57:51 +00:00
|
|
|
if (speed > 0)
|
2019-07-10 20:23:25 +00:00
|
|
|
Animations::moveTo(this, speed, x, y);
|
2014-02-23 16:35:06 +00:00
|
|
|
else
|
2014-02-28 04:09:57 +00:00
|
|
|
setPos(x, y);
|
2014-01-16 17:02:32 +00:00
|
|
|
}
|