static void check_gas_change_events(struct dive *dive, struct divecomputer *dc, struct plot_info *pi) { int i = 0, cylinderindex = 0; struct event *ev = get_next_event(dc->events, "gaschange"); // for dive computers that tell us their first gas as an event on the first sample // we need to make sure things are setup correctly cylinderindex = explicit_first_cylinder(dive, dc); set_first_cylinder_index(pi, 0, cylinderindex, ~0u); if (!ev) return; do { i = set_cylinder_index(pi, i, cylinderindex, ev->time.seconds); cylinderindex = get_cylinder_index(dive, ev); ev = get_next_event(ev->next, "gaschange"); } while (ev); set_cylinder_index(pi, i, cylinderindex, ~0u); }
void TankItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { Q_UNUSED(topLeft); Q_UNUSED(bottomRight); // We don't have enougth data to calculate things, quit. if (!dataModel || !pInfoEntry || !pInfoNr) return; // remove the old rectangles foreach (QGraphicsRectItem *r, rects) { delete(r); } rects.clear(); qreal width, left; // Find correct end of the dive plot for correct end of the tankbar struct plot_data *last_entry = &pInfoEntry[pInfoNr-1]; // get the information directly from the displayed_dive (the dc always exists) struct divecomputer *dc = get_dive_dc(&displayed_dive, dc_number); // start with the first gasmix and at the start of the dive int cyl = explicit_first_cylinder(&displayed_dive, dc); struct gasmix *gasmix = &displayed_dive.cylinder[cyl].gasmix; int startTime = 0; // work through all the gas changes and add the rectangle for each gas while it was used struct event *ev = get_next_event(dc->events, "gaschange"); while (ev && ev->time.seconds < last_entry->sec) { width = hAxis->posAtValue(ev->time.seconds) - hAxis->posAtValue(startTime); left = hAxis->posAtValue(startTime); createBar(left, width, gasmix); startTime = ev->time.seconds; gasmix = get_gasmix_from_event(&displayed_dive, ev); ev = get_next_event(ev->next, "gaschange"); } width = hAxis->posAtValue(last_entry->sec) - hAxis->posAtValue(startTime); left = hAxis->posAtValue(startTime); createBar(left, width, gasmix); }