It wants us to test for end of container when finding elements.
That is of course reasonable in "production" code, but a bit
pointless in the testing code. Oh well.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was quite ominous: a 60-element fixed size table was
passed as argument to plan(). But there was no check for 60
anywhere? Use a dynamic vector instead.
The whole thing is weird, as the depth of the decostop table
doesn't seem to be used.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
I don't get the point of these calls to dp.clear().
The plan is overwritten immediately afterwards anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Allow the initial gas of the dive to be edited through the context menu
in the dive profile, by right-clicking into the profile at the very
start of the dive.
Of course this will likely completely invalidate the decompression
calculation of any actually logged dives, but this is no different to
the addition and modification of gas changes during the dive that is
already possible.
Proposed by @harrydevil in #4291.
Signed-off-by: Michael Keller <github@ike.ch>
Still, mostly useful for me, but this correctly deals with relative path
names for the working directory (and gives a usage message).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix a bug introduced in #4245, causing an incorrect dive mode to be
selected when starting the dive planner from a CCR dive.
Signed-off-by: Michael Keller <github@ike.ch>
A reference to a unique_ptr<> was captured by a lambda used
to calculate variations in the background.
This is of course disastrous, because if the caller runs
first it will delete the object. It's a wonder that this
didn't crash regularly!?
The problem is that capturing unique_ptr<>s in lambdas
works, but makes the lambda non-copyable. Sadly, the
QtConcurrent::run() function wants to copy the lambda.
For now, do this by a release/reaquire pair. This is
not exception safe. However, sine Qt doesn't support
exceptions, we can live with that.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Improve the event loop architecture by making it set the divecomputer in
the constructor - using the same loop for multiple dive computers is not
intended to work.
Also change `next()` in `divemode_loop` to `at()` to make the name more
aligned with its function.
Signed-off-by: Michael Keller <github@ike.ch>
Fix an interger overflow warning when parsing setpoints.
@bstoeger: In the end it turned out that this parser was only used in
one place in the planner UI, and it was simplest to switch this to
using `QVariant.toFloat()` in the model itself, which is consistent how
the rest of the input values is parsed and validated.
Signed-off-by: Michael Keller <github@ike.ch>
When merging two dives, if a divesite is chosen that doesn't
have a GPS location, but another divesite has a GPS location,
then the GPS location of the former is set to that of the
latter.
However, that was done outside of the undo system, so that
it is not undone and the frontend is not made aware of the
change.
Fix this. To simplify things, move the code from the undo
machinery to the core.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
All callers were just using that member to set the dive_site
in the resulting dive. We might just do that in the called
function [merge_dives()].
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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 is the minimal fix to actually include the resulting location in
the merged dive. I'm not sure what the background was to setting the
dive location only in the "merge_result" variable, and not in the actual
result dive itself.
Berthold says that the whole site handling may be broken:
"From a quick glance, the code in dive_table::merge_dives looks
fundamentally broken, because it may overwrite site->location outside
of the undo system. I.e. this will not be undone."
but the "this will not be undone" is about the site location setting,
and is separate and independent of the dive->dive_set setting.
Presumably we would need to make a copy of the site for the undo
functionality. That will be for somebody else to worry about, this at
least fixes the resulting location in the dive itsels.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Commit c27314d60 ("core: replace add_sample() by append_sample()") broke
the dive computer interleaving when merging two dives: the sample
merging (done by "merge_samples()") no longer took the offset between
the two merged dives into account, and instead just blindly copied the
samples from the second dive computer with no time offset.
The end result was a completely broken profile.
This adds back the sample offset. It also takes the offset not from the
difference in time of the two dives, but the difference in time of the
dive computers. That way we're not mixing up different times from
different sources that aren't necessarily in sync (the time *difference*
is hopefully the same, but still..).
The dive merging still messes up the dive location. That's some other bug.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The Suunto FIT files end up creating a sample every second, but a lot of
those samples with no depth information, marked as "depth.mm" being negative.
That doesn't end up being a problem for subsurface, _except_ that it
really confuses our "dc_fixup_duration()" logic, and the dive duration
ends up being completely nonsensical (generally roughly by a factor of
five: every tenth sample has a depth, and we only count samples that
"begin or end under water" as being relevant for the dive duration, so
two out of the ten samples will count towards the dive time).
Saving the dive will then not save these invalid depths, so saving and
reloading the dive ends up fixing the dive duration calculation.
The fix is trivial - we just ignore samples with negative depth in
dc_fixup_duration().
The FIT file parser should probably be taught to not even bother sending
empty samples to subsurface, but that's a separate cleanup. This fixes
the actual bad behavior.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The (presumably) older label "Re-plan dive" in the Log menu was replaced with "Edit dive in planner",
but the documentation section "Modifying an existing dive plan" was not updated.
Signed-off-by: Tim D. Hammer <tdhammer@linux.com>
Fixes gcc complaining about
/build/subsurface-beta-202408210659/core/divecomputer.cpp: In function 'bool operator<(const event&, const event&)':
/build/subsurface-beta-202408210659/core/divecomputer.cpp:290:21: error: 'tie' is not a member of 'std'
290 | return std::tie(ev1.time.seconds, ev1.name) <
| ^~~
/build/subsurface-beta-202408210659/core/divecomputer.cpp:13:1: note: 'std::tie' is defined in header '<tuple>'; did you forget to '#include <tuple>'?
12 | #include <stdlib.h>
+++ |+#include <tuple>
13 |
/build/subsurface-beta-202408210659/core/divecomputer.cpp:291:21: error: 'tie' is not a member of 'std'
291 | std::tie(ev2.time.seconds, ev2.name);
| ^~~
/build/subsurface-beta-202408210659/core/divecomputer.cpp:291:21: note: 'std::tie' is defined in header '<tuple>'; did you forget to '#include <tuple>'?
Signed-off-by: Richard Fuchs <dfx@dfx.at>
This has become a bit of a catch-all overhaul of a large portion of the
planner - I started out wanting to improve the CCR mode, but then as I
started pulling all the other threads that needed addressing started to
come with it.
Improve how the gas selection is handled when planning dives in CCR
mode, by making the type (OC / CCR) of segments dependent on the gas use
type that was set for the selected gas.
Add a preference to allow the user to chose to use OC gases as diluent,
in a similar fashion to the original implementation.
Hide gases that cannot be used in the currently selected dive mode in
all drop downs.
Include usage type in gas names if this is needed.
Hide columns and disable elements in the 'Dive planner points' table if
they can they can not be edited in the curently selected dive mode.
Visually identify gases and usage types that are not appropriate for the
currently selected dive mode.
Move the 'Dive mode' selection to the top of the planner view, to
accommodate the fact that this is a property of the dive and not a
planner setting.
Show a warning instead of the dive plan if the plan contains gases that
are not usable in the selected dive mode.
Fix the data entry for the setpoint in the 'Dive planner points' table.
Fix problems with enabling / disabling planner settings when switching
between dive modes.
Refactor some names to make them more appropriate for their current
usage.
One point that is still open is to hide gas usage graphs in the planner
profile if the gas isn't used for OC, as there is no way to meaningfully
interpolate such usage.
Signed-off-by: Michael Keller <github@ike.ch>
In 1af00703b3 the constructor of
WSInfoModel was removed, not realizing that it contains a crucial
call to setHeaderDataStrings().
Fixes#4294
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Fixes gcc complaining about
/build/subsurface-beta-202408190452/core/event.cpp: In member function 'bool event::operator==(const event&) const':
/build/subsurface-beta-202408190452/core/event.cpp:64:21: error: 'tie' is not a member of 'std'
64 | return std::tie(time.seconds, type, flags, value, name) ==
| ^~~
/build/subsurface-beta-202408190452/core/event.cpp:6:1: note: 'std::tie' is defined in header '<tuple>'; did you forget to '#include <tuple>'?
5 | #include "subsurface-string.h"
+++ |+#include <tuple>
6 |
/build/subsurface-beta-202408190452/core/event.cpp:65:21: error: 'tie' is not a member of 'std'
65 | std::tie(b.time.seconds, b.type, b.flags, b.value, b.name);
| ^~~
/build/subsurface-beta-202408190452/core/event.cpp:65:21: note: 'std::tie' is defined in header '<tuple>'; did you forget to '#include <tuple>'?
Signed-off-by: Richard Fuchs <dfx@dfx.at>
If there were more than one redundant event in the 60 sec range,
the event would be deleted multiple time, leading to a crash.
Only mark for deletion once.
Moreover, don't consider events that were already marked for
deletion, because that would mean that redundant events all 59 secs
would lead to all events (but the first one) deleted.
Finally, optimize the loop by stopping once the 60 sec limit
is reached.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We check for the event, but then access it anyway even if it
doesn't exist. Should not happen, but let's be safe.
Found by Coverity.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>