mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
cylinders: add cylinder before hidden cylinders
When adding a cylinder, it was added at the end of the list. This would make hidden cylinders visible as the new rule is to only hide unused cylinders at the end of the list. Therefore, add the cylinder after the last used cylinder, i.e. before the first hidden cylinder. This means that the position where the cylinder is added has to be hidden in the undo command. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
a40b40ae7a
commit
1af67512a1
5 changed files with 42 additions and 34 deletions
|
|
@ -464,6 +464,34 @@ cylinder_t create_new_cylinder(const struct dive *d)
|
|||
return cyl;
|
||||
}
|
||||
|
||||
static bool show_cylinder(const struct dive *d, int i)
|
||||
{
|
||||
if (is_cylinder_used(d, i))
|
||||
return true;
|
||||
|
||||
const cylinder_t *cyl = &d->cylinders.cylinders[i];
|
||||
if (cyl->start.mbar || cyl->sample_start.mbar ||
|
||||
cyl->end.mbar || cyl->sample_end.mbar)
|
||||
return true;
|
||||
if (cyl->manually_added)
|
||||
return true;
|
||||
|
||||
/*
|
||||
* The cylinder has some data, but none of it is very interesting,
|
||||
* it has no pressures and no gas switches. Do we want to show it?
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/* The unused cylinders at the end of the cylinder list are hidden. */
|
||||
int first_hidden_cylinder(const struct dive *d)
|
||||
{
|
||||
int res = d->cylinders.nr;
|
||||
while (res > 0 && !show_cylinder(d, res - 1))
|
||||
--res;
|
||||
return res;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_CYL
|
||||
void dump_cylinders(struct dive *dive, bool verbose)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ extern int gas_volume(const cylinder_t *cyl, pressure_t p); /* Volume in mliter
|
|||
extern int find_best_gasmix_match(struct gasmix mix, const struct cylinder_table *cylinders);
|
||||
extern void fill_default_cylinder(const struct dive *dive, cylinder_t *cyl); /* dive is needed to fill out MOD, which depends on salinity. */
|
||||
extern cylinder_t create_new_cylinder(const struct dive *dive); /* dive is needed to fill out MOD, which depends on salinity. */
|
||||
extern int first_hidden_cylinder(const struct dive *d);
|
||||
#ifdef DEBUG_CYL
|
||||
extern void dump_cylinders(struct dive *dive, bool verbose);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue