Refactoring: Use core functions to find gasmixes in TankItem.

Small refactoring to use `get_gasmix_at_time` from `core` in `TankItem`
to find the first gasmix used during a dive.

Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
Michael Keller 2023-02-03 19:09:54 +13:00 committed by Robert C. Helling
parent 72c40a18c2
commit a92ee1e05d

View file

@ -79,16 +79,10 @@ void TankItem::setData(const struct dive *d, const struct divecomputer *dc, int
if (d->cylinders.nr <= 0) if (d->cylinders.nr <= 0)
return; return;
// start with the first gasmix and at the start of the dive // start with the first gasmix and at the start of the plotted range
int cyl = explicit_first_cylinder(d, dc); const struct event *ev = NULL;
struct gasmix gasmix = get_cylinder(d, cyl)->gasmix; struct gasmix gasmix = gasmix_air;
gasmix = get_gasmix(d, dc, plotStartTime, &ev, gasmix);
// skip over all gas changes before the plotted range
const struct event *ev = get_next_event(dc->events, "gaschange");
while (ev && (int)ev->time.seconds <= plotStartTime) {
gasmix = get_gasmix_from_event(d, ev);
ev = get_next_event(ev->next, "gaschange");
}
// work through all the gas changes and add the rectangle for each gas while it was used // work through all the gas changes and add the rectangle for each gas while it was used
int startTime = plotStartTime; int startTime = plotStartTime;