mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Profile: Fix the Initial Gasmix.
Fix the initial gasmix that is shown in the tank bar of the profile. Also add a meaningful gas name for gases with negative values for percentages. @bstoeger: This is a side effect of the `event_loop` functionality introduced as part of #4198. In the case of an `event_loop("gasmix")` this does not take into account the edge case where there is no gaschange event at the very beginning of the dive, and the first gasmix is implicitly used as the starting gasmix. This happens for planned and manually added dives, but also for some dive computers. We are using the same kind of loop in a number of other places in `core/profile.cpp`, `core/dive.cpp`, `core/gaspressures.cpp`, and `profile-widget/tankitem.cpp`, and I am wondering if we should be converting these to use `gasmix_loop` instead to avoid being bit by this special case? Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
parent
38fe08e5e1
commit
db516b6d4e
9 changed files with 171 additions and 140 deletions
20
core/event.h
20
core/event.h
|
|
@ -68,12 +68,26 @@ public:
|
|||
class gasmix_loop {
|
||||
const struct dive &dive;
|
||||
const struct divecomputer &dc;
|
||||
struct gasmix last;
|
||||
bool first_run;
|
||||
event_loop loop;
|
||||
const struct event *ev;
|
||||
const struct event *next_event;
|
||||
int last_cylinder_index;
|
||||
int last_time;
|
||||
public:
|
||||
gasmix_loop(const struct dive &dive, const struct divecomputer &dc);
|
||||
gasmix next(int time);
|
||||
// Return the next cylinder index / gasmix from the list of gas switches
|
||||
// and the time in seconds when this gas switch happened
|
||||
// (including the potentially imaginary first gas switch to cylinder 0 / air)
|
||||
std::pair<int, int> next_cylinder_index(); // -1 -> end
|
||||
std::pair<gasmix, int> next(); // gasmix_invalid -> end
|
||||
|
||||
// Return the cylinder index / gasmix at a given time during the dive
|
||||
// and the time in seconds when this switch to this gas happened
|
||||
// (including the potentially imaginary first gas switch to cylinder 0 / air)
|
||||
std::pair<int, int> cylinder_index_at(int time); // -1 -> end
|
||||
std::pair<gasmix, int> at(int time); // gasmix_invalid -> end
|
||||
|
||||
bool has_next() const;
|
||||
};
|
||||
|
||||
/* Get divemodes at increasing timestamps. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue