QString gasToStr(const int o2Permille, const int hePermille) { uint o2 = (o2Permille + 5) / 10, he = (hePermille + 5) / 10; QString result = is_air(o2Permille, hePermille) ? QObject::tr("AIR") : he == 0 ? QString("EAN%1").arg(o2, 2, 10, QChar('0')) : QString("%1/%2").arg(o2).arg(he); return result; }
void DiveGasPressureItem::plot_gas_value(int mbar, int sec, QFlags<Qt::AlignmentFlag> flags, int o2, int he) { QString gas = (is_air(o2, he)) ? tr("air") : (he == 0) ? QString(tr("EAN%1")).arg((o2 + 5) / 10) : QString("%1/%2").arg((o2 + 5) / 10).arg((he + 5) / 10); DiveTextItem *text = new DiveTextItem(this); text->setPos(hAxis->posAtValue(sec), vAxis->posAtValue(mbar)); text->setText(gas); text->setAlignment(flags); text->setBrush(getColor(PRESSURE_TEXT)); texts.push_back(text); }
void ProfileGraphicsView::plot_gas_value(int mbar, int sec, double xalign, double yalign, int o2, int he) { QString gas; if (is_air(o2, he)) gas = tr("air"); else if (he == 0) gas = QString(tr("EAN%1")).arg((o2 + 5) / 10); else gas = QString("%1/%2").arg((o2 + 5) / 10).arg((he + 5) / 10); static text_render_options_t tro = {PRESSURE_TEXT_SIZE, PRESSURE_TEXT, xalign, yalign}; plot_text(&tro, QPointF(sec, mbar), gas); }
bool is_gas_used(struct dive *dive, int idx) { cylinder_t *cyl = &dive->cylinder[idx]; int o2, he; struct divecomputer *dc; bool used = FALSE; bool firstGasExplicit = FALSE; if (cylinder_none(cyl)) return FALSE; o2 = get_o2(&cyl->gasmix); he = get_he(&cyl->gasmix); dc = &dive->dc; while (dc) { struct event *event = dc->events; while (event) { if (event->value) { if (event->name && !strcmp(event->name, "gaschange")) { unsigned int event_he = event->value >> 16; unsigned int event_o2 = event->value & 0xffff; if (event->time.seconds < 30) firstGasExplicit = TRUE; if (is_air(o2, he)) { if (is_air(event_o2 * 10, event_he * 10)) used = TRUE; } else if (he == event_he * 10 && o2 == event_o2 * 10) { used = TRUE; } } } if (used) break; event = event->next; } if (used) break; dc = dc->next; }
void DiveEventItem::setupToolTipString() { // we display the event on screen - so translate QString name = tr(internalEvent->name); int value = internalEvent->value; if (value) { if (name == "gaschange") { int he = value >> 16; int o2 = value & 0xffff; name += ": "; if (he) name += QString("%1/%2").arg(o2).arg(he); else if (is_air(o2, he)) name += tr("air"); else name += QString(tr("EAN%1")).arg(o2); } else if (name == "SP change") {
/* * Get "maximal" dive gas for a dive. * Rules: * - Trimix trumps nitrox (highest He wins, O2 breaks ties) * - Nitrox trumps air (even if hypoxic) * These are the same rules as the inter-dive sorting rules. */ void get_dive_gas(struct dive *dive, int *o2_p, int *he_p, int *o2low_p) { int i; int maxo2 = -1, maxhe = -1, mino2 = 1000; for (i = 0; i < MAX_CYLINDERS; i++) { cylinder_t *cyl = dive->cylinder + i; struct gasmix *mix = &cyl->gasmix; int o2 = mix->o2.permille; int he = mix->he.permille; struct divecomputer *dc = &dive->dc; int used = 0; int first_gas_explicit = 0; while (dc) { struct event *event = dc->events; while (event) { if (event->value) { if (event->name && !strcmp(event->name, "gaschange")) { unsigned int event_he = event->value >> 16; unsigned int event_o2 = event->value & 0xffff; if (event->time.seconds < 30) first_gas_explicit = 1; if (is_air(o2, he)) { if (is_air(event_o2 * 10, event_he * 10)) used = 1; } else { if (he == event_he*10 && o2 == event_o2*10) used = 1; } } } event = event->next; } dc = dc->next; } /* Unless explicity set, the first gas to use has index 0 */ if (i == 0 && !first_gas_explicit) used = 1; if (!used) continue; if (cylinder_none(cyl)) continue; if (!o2) o2 = O2_IN_AIR; if (o2 < mino2) mino2 = o2; if (he > maxhe) goto newmax; if (he < maxhe) continue; if (o2 <= maxo2) continue; newmax: maxhe = he; maxo2 = o2; }
void ProfileGraphicsView::plot_one_event(struct event *ev) { int i; struct plot_info *pi = &gc.pi; struct plot_data *entry; /* is plotting of this event disabled? */ if (ev->name) { for (i = 0; i < evn_used; i++) { if (! strcmp(ev->name, ev_namelist[i].ev_name)) { if (ev_namelist[i].plot_ev) break; else return; } } } if (ev->time.seconds < 30 && !strcmp(ev->name, "gaschange")) /* a gas change in the first 30 seconds is the way of some dive computers * to tell us the gas that is used; let's not plot a marker for that */ return; for (i = 0; i < pi->nr; i++) { entry = pi->entry + i; if (ev->time.seconds < entry->sec) break; } /* draw a little triangular marker and attach tooltip */ int x = SCALEXGC(ev->time.seconds); int y = SCALEYGC(entry->depth); EventItem *item = new EventItem(0, isGrayscale); item->setPos(x, y); scene()->addItem(item); /* we display the event on screen - so translate */ QString name = tr(ev->name); if (ev->value) { if (ev->name && name == "gaschange") { int he = get_he(&dive->cylinder[entry->cylinderindex].gasmix); int o2 = get_o2(&dive->cylinder[entry->cylinderindex].gasmix); name += ": "; name += (he) ? QString("%1/%2").arg((o2 + 5) / 10).arg((he + 5) / 10) : is_air(o2, he) ? name += tr("air") : QString(tr("EAN%1")).arg((o2 + 5) / 10); } else if (ev->name && !strcmp(ev->name, "SP change")) { name += QString(":%1").arg((double) ev->value / 1000); } else { name += QString(":%1").arg(ev->value); } } else if (ev->name && name == "SP change") { name += tr("Bailing out to OC"); } else { name += ev->flags == SAMPLE_FLAGS_BEGIN ? tr(" begin", "Starts with space!") : ev->flags == SAMPLE_FLAGS_END ? tr(" end", "Starts with space!") : ""; } //item->setToolTipController(toolTip); //item->addToolTip(name); item->setToolTip(name); }