Lookup gas via the plot_data, not the event

When straight decoding the event, it failed to handle older
SAMPLE_EVENT_GASCHANGE(11), the ones without he-part correctly. This was
shown clearly when it printed the 21/35 in dives/test20.xml as air.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Anton Lundin 2013-10-03 22:44:04 +02:00 committed by Dirk Hohndel
parent ad52301ca7
commit d53d00db02

View file

@ -819,8 +819,9 @@ void ProfileGraphicsView::plot_events(struct divecomputer *dc)
void ProfileGraphicsView::plot_one_event(struct event *ev) void ProfileGraphicsView::plot_one_event(struct event *ev)
{ {
int i, depth = 0; int i;
struct plot_info *pi = &gc.pi; struct plot_info *pi = &gc.pi;
struct plot_data *entry;
/* is plotting of this event disabled? */ /* is plotting of this event disabled? */
if (ev->name) { if (ev->name) {
@ -840,16 +841,15 @@ void ProfileGraphicsView::plot_one_event(struct event *ev)
return; return;
for (i = 0; i < pi->nr; i++) { for (i = 0; i < pi->nr; i++) {
struct plot_data *data = pi->entry + i; entry = pi->entry + i;
if (ev->time.seconds < data->sec) if (ev->time.seconds < entry->sec)
break; break;
depth = data->depth;
} }
/* draw a little triangular marker and attach tooltip */ /* draw a little triangular marker and attach tooltip */
int x = SCALEXGC(ev->time.seconds); int x = SCALEXGC(ev->time.seconds);
int y = SCALEYGC(depth); int y = SCALEYGC(entry->depth);
EventItem *item = new EventItem(0, isGrayscale); EventItem *item = new EventItem(0, isGrayscale);
item->setPos(x, y); item->setPos(x, y);
@ -859,13 +859,13 @@ void ProfileGraphicsView::plot_one_event(struct event *ev)
QString name = tr(ev->name); QString name = tr(ev->name);
if (ev->value) { if (ev->value) {
if (ev->name && name == "gaschange") { if (ev->name && name == "gaschange") {
unsigned int he = ev->value >> 16; int he = get_he(&dive->cylinder[entry->cylinderindex].gasmix);
unsigned int o2 = ev->value & 0xffff; int o2 = get_o2(&dive->cylinder[entry->cylinderindex].gasmix);
name += ": "; name += ": ";
name += (he) ? QString("%1/%2").arg(o2, he) name += (he) ? QString("%1/%2").arg((o2 + 5) / 10).arg((he + 5) / 10)
: (o2 == 21) ? name += tr("air") : is_air(o2, he) ? name += tr("air")
: QString("%1% %2").arg(o2).arg("O" UTF8_SUBSCRIPT_2); : QString(tr("EAN%1")).arg((o2 + 5) / 10);
} else if (ev->name && !strcmp(ev->name, "SP change")) { } else if (ev->name && !strcmp(ev->name, "SP change")) {
name += QString(":%1").arg((double) ev->value / 1000); name += QString(":%1").arg((double) ev->value / 1000);