Commit graph

3092 commits

Author SHA1 Message Date
Michael Keller
0a27f124fd Fix the Diveplan Creation.
Signed-off-by: Michael Keller <github@ike.ch>
2024-12-29 23:22:47 +13:00
Michael Keller
07898f277c Profile: Improve Display of Bailout / Loop Events.
For dives in CCR mode, show 'bailout' and 'on loop' events whenever a
gas switch from a diluent gas to a bailout gas and vice versa happens.

Signed-off-by: Michael Keller <github@ike.ch>
2024-12-29 23:22:47 +13:00
Michael Keller
de12d3a6ea Disable Debugging in Planner.
Signed-off-by: Michael Keller <github@ike.ch>
2024-12-29 23:03:21 +13:00
Michael Keller
2673b7fa10 Bugfix: Fix planner debug code.
Fix the debug code in `core/planner.cpp`.

Signed-off-by: Michael Keller <github@ike.ch>
2024-12-29 23:03:21 +13:00
Berthold Stoeger
55b72d40e3 planner: round deco-stop levels to integral feet
In the decostop table, we had deco stops at fractional feet
(e.g. 333.33 ft). This was somewhat awkward, because the
user defined literals do not yet(?) support non-integers
and therefore, these entries were given in mm instead.

Just round to the nearest integral feet values.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-17 13:58:27 +13:00
Berthold Stoeger
992e258524 core: pass depth_t to get_depth_units()
Commit is longer than expected, because a few of the callers
were converted to use depth_t instead of int.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-17 13:58:27 +13:00
Berthold Stoeger
1d14b03935 core: let pressure_to_altitude return a depth_t
Also un-inline it. There seems no reason for exporting the
implementation details in the header file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-17 13:58:27 +13:00
Berthold Stoeger
4237cb9999 profile: turn plotdata::mod, ead, eadd, end into depth_t
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-17 13:58:27 +13:00
Berthold Stoeger
58d096adfc profile: turn plotdata::ceiling into depth_t
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-17 13:58:27 +13:00
Berthold Stoeger
9cf753fa56 core: refactor per_cylinder_mean_depth()
This function had a horrendous interface: The caller would have to
allocate two arrays of the correct size to be filled with data.
The callee couldn't even check the size, because the data was passed
as raw pointers.

Instead, use std::vector<>, construct everything in the called
function and do size-sanity check in the calling function.

Use depth_t and duration_t instead of plain integers to represent
mean depth and time.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-17 13:58:27 +13:00
Berthold Stoeger
dbc06d78b6 profile: small cleanup concerning depth_t
Operate directly on depth_t instead of working with the base
type.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-17 13:58:27 +13:00
Berthold Stoeger
94a54d8e35 profile: make plotdata::depth depth_t
A small drop in the bucket: more conversion to our unit types.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-17 13:58:27 +13:00
Berthold Stoeger
851e8bc5ee core: implement scalar multiplication/division for unit types
Allow multiplication/division of unit types with scalars,
such as
	depth * 4
or
	depth / 4
Multiplication the other way round (4 * depth) is not currently
supported, because that needs some template trickery.

Might do this later or wait for our switch to C++20, where we
could use concepts to make that trickery more palatable.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-17 13:58:27 +13:00
Berthold Stoeger
022b927755 planner: make argument to plan_add_segment() depth_t
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-17 13:58:27 +13:00
Berthold Stoeger
6b57b3b745 core: make round_to parameter of gas_mod() and gas_mnd() a depth_t
Simplifies practically all the callers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-17 13:58:27 +13:00
Berthold Stoeger
bd2f7e72f1 core: turn M_OR_FT macro into a function
No point in this being a macro. Make it return a depth_t - it
was unclear that this returns a depth in mm.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-17 13:58:27 +13:00
Berthold Stoeger
0e77dd9a68 core: implement interpolate() function for unit types
Calls the global interpolate() function for integer types.

For now, the template is enabled if the arguments are not
integer types. Might want to refine that in the future.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-17 13:58:27 +13:00
Berthold Stoeger
1ccfb823f0 core: make interpolate() a template
Make the type the interpolate() function works on a template type,
so that this can be used for arbitrary unit types without warnings.
Internally, it does its math using floating point arithmetics anyway,
so no risk of overflow. (Exception: when just taking the middle point,
but I would hope that no part of the code lives on the edge such that
addition of two values gives an overflow.)

Moreover, add an "math.h" include so that the header becomes
independent of others.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-17 13:58:27 +13:00
Berthold Stoeger
6fbc3917bb core: make unit user-defined literals constexpr
Currently, we can't use our unit literals, such as "3_m" in
constexpr context, for example to define them as variables
as such:

static constexpr deco_stops_multiplier = 3_m;

Declaring the respective operator""() functions as constexpr
enables this use case.

The _ft and _atm literals are left as non-constexpr, because
they use round(), which is not constexpr on our Android
compiler. Revise this later.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-17 13:58:27 +13:00
Berthold Stoeger
da17f6a08c core: pass depth_t to depth_to_* functions
This is a drop in the ocean. Make the usage of the unit-types a
bit more consistent throughout the code base.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-17 13:58:27 +13:00
Berthold Stoeger
661ce3f9c7 Whitespace fix: no Java-style functions
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-17 13:58:27 +13:00
Berthold Stoeger
bc35aadc20 trivial: replace macro cube() by inline function/template
Avoids funky side effects. The old version would have failed
horribly for innocent invocations such as "cube(a+b)" or
"cube(++a)".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-14 12:34:44 +01:00
Berthold Stoeger
d26f1a07cf trivial: remove unused macro
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-14 12:34:44 +01:00
Berthold Stoeger
4d4c250589 Avoid UTF8->UTF16->UTF8 roundtrip when logging on mobile
Make writeToAppLogFile() take an std::string parameter to avoid
an unnecessary UTF8->UTF16->UTF8 (std::string->QString->char *)
roundtrip.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-12-01 16:33:33 +01:00
Jef Driesen
7d1e0ef0d1 Redirect logs to the application log file again
In commit 4de109bbf1, qDebug() was
replaced with report_info(). As a side effect, the subsurface log
messages are no longer redirected to the application log file. Only the
internal Qt logging ends up in the log file.

For bug reporting by end-users, this application log file is important
because it's the easiest way to collect all the necessary information to
investigate the problem.

Signed-off-by: Jef Driesen <jef@libdivecomputer.org>
2024-11-30 16:22:30 +01:00
rmultan
46c439c443 Bluetooth: Add Mares Sirius to known devices
The app already supports Mares Sirius,
but user has to allow scanning for
unknown devices in app settings.
This adds Mares Sirius to known devices.

Signed-off-by: rmultan <multan.rafal.k@gmail.com>
2024-11-26 22:29:13 +13:00
Michael Keller
91d8bfef55 Import: Add Parsing for Divesoft Freedom+ Format Files.
Switch the Divesoft log file importer to use the parser in
libdivecomputer. This adds support for the newer Divesoft Freedom+ log
file format.
Also refactor the OSTCTools log file importer to share common
functionality.

Signed-off-by: Michael Keller <github@ike.ch>
2024-11-19 08:47:00 +13:00
Michael Keller
7f42acfdfb Import: Add Parsing for Divesoft Freedom+ Format Files.
Switch the Divesoft log file importer to use the parser in
libdivecomputer. This adds support for the newer Divesoft Freedom+ log
file format.
Also refactor the OSTCTools log file importer to share common
functionality.

Signed-off-by: Michael Keller <github@ike.ch>
2024-11-19 08:47:00 +13:00
Robert C. Helling
7dc92e170f Round MOD to lower depths
When computing the suggested switch depth for a gas,
we should take the next stop depth above the MOD, i.e.
round down. Otherwise we can produce MOD violation warnings.

We need, however, a bit of fudge as otherwise we do not
suggest to switch to o2 at 6m.

TestPlan uses the MOD to determine the depth to switch to
Tx21/35. This happens to be 65.378m. Therefore, switching
at 66m violates the MOD, the switch should be at 63m.
This then affects the gas usage.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2024-11-19 08:46:13 +13:00
Dirk Hohndel
e7900c514c export-html: prevent invalid json
A dive without events could lead to json with extra closing brackets that
prevents browsers from rendering the dive log.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2024-11-05 19:17:12 +01:00
Victor Arvidsson
e58824e636 Fixed small bug in replace_all.
Start_pos should of course be 0...

Signed-off-by: Victor Arvidsson <victarv@gmail.com>
2024-10-27 01:37:04 +13:00
Victor Arvidsson
6886c9ccf8 Make the "Save dive data as subtitles" feature more configurable.
Previously, the subtitle generation was hardcoded, making it unsuitable
if you didn't want all of the displayed values. This has been replaced
by a format string that is configurable in the settings, using predefined
tags that are replaced with the values. The default value for this has
been set to (mostly) match the currently generated subtitle string. This
also provides a good starting point for users that want to modify the string.

Signed-off-by: Victor Arvidsson <victarv@gmail.com>
2024-10-27 01:37:04 +13:00
Michael Keller
2244f3f528 Export: Cleanup jqplot Module References.
Clean up references to the jqplot modules that were overlooked in #4350.

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-10-22 10:23:29 +13:00
Michael Keller
364c776ff1 Export: Update jquery to a Secure Version.
Update jquery to a version that fixes known security vulnerabilities.
Triggered by https://github.com/subsurface/subsurface/security/dependabot/7

Signed-off-by: Michael Keller <github@ike.ch>
2024-10-21 09:25:19 +13:00
Michael Keller
8a64d1f4b9 Cleanup: Fix Warnings in MacOS build.
Signed-off-by: Michael Keller <github@ike.ch>
2024-09-28 23:50:55 +12:00
Michael Keller
478e444cd9 Fix problems from rebase, clean up debian packaging definition.
Signed-off-by: Michael Keller <github@ike.ch>
2024-09-21 11:03:53 +12:00
Dirk Hohndel
40c22f0fe9 deal with typo in older versions of libraw
longtitude instead of longitude prior to libraw 0.20.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2024-09-21 11:03:53 +12:00
Berthold Stoeger
13d1188c41 media: load metadata and thumbnails of raw pictures using libraw
The distinguished photographer shoots raw images. There is a
comprehensive library that can extract metadata and thumbnails
from these images. Let's use it if available.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-09-21 11:03:53 +12:00
Richard Fuchs
a6a15f9d3a core: add missing types to return values
Fixes build failing on Debian Buster (gcc 8.3.0) with:

/build/subsurface-beta-202409160411/./core/units.h: In function 'duration_t operator""_sec(long long unsigned int)':
/build/subsurface-beta-202409160411/./core/units.h:149:48: error: could not convert '{((int32_t)sec)}' from '<brace-enclosed initializer list>' to 'duration_t'
  return { .seconds = static_cast<int32_t>(sec) };

Signed-off-by: Richard Fuchs <dfx@dfx.at>
2024-09-16 22:02:51 +02:00
Berthold Stoeger
1a3bc9bf71 units: add comment concerning unit literals
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-09-11 10:23:07 +02:00
Berthold Stoeger
dd5def35f5 units: replace SURFACE_PRESSURE by 1_atm
Moreover, convert diveplan::surface_pressure from int to
pressure_t.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-09-11 10:23:07 +02:00
Berthold Stoeger
ae81b42fe2 core: introduce a few user-defined literals for unit types
Thise makes initialization of unit types more palatable.

For example:

    surface.time = sample.time - duration_t { .seconds = 20 };
=>  surface.time = sample.time - 20_sec;

    delta_depth.mm = feet_to_mm(1.0); // 1ft
=>  delta_depth = 1_ft;

    get_cylinderid_at_time(..., { .seconds = 20 * 60 + 1 }));
=>  get_cylinderid_at_time(..., 20_min + 1_sec));

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-09-11 10:23:07 +02:00
Berthold Stoeger
f09601bc93 core: remove to_feet() function
It wasn't used anywhere.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-09-11 10:23:07 +02:00
Berthold Stoeger
77b12bbccf core: add cast_int<> function
We had a pattern where doubles were converted to long with
lrint() and then down-cast to a narrower int type.

Because this is unwieldy, introduce a function encapsulating
this.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-09-11 10:23:07 +02:00
Berthold Stoeger
110e64bc66 general: simplify a few unit manipulations
Now that we have defined addition and subtraction on unit
classes, let's use them in a few examples.

Yes, some of these are a bit pointless, because they are
of the kind
        a.mbar - b.mbar => (a-b).mbar

However, these probably should be further simplified
by storing the result in a unit type.

This commit is mostly a proof-of-concept.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-09-11 10:23:07 +02:00
Berthold Stoeger
729cc16fc5 core: add addition / subtraction to unit types
When adding / subtracting unit objects it is completely
irrelevant with respect to which unit the data is stored.
Why should the user know this?

Therefore add addition / subtraction functions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-09-11 10:23:07 +02:00
Berthold Stoeger
12ca172a9e core: add CRTP base class to unit types
The goal here is to add general addition and scalar multiplication
functions to the unit types.

Thereto, we need a CRTP
(https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern)
base class.

However, this breaks compound initialization, so we have to use
named initializers:
	weight_t { 2000 } -> weight_t { .grams = 2000 }
The good thing is that this is exactly how these classes were
supposed to be used: make the unit explicit!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-09-11 10:23:07 +02:00
Berthold Stoeger
696ba61eef planner: move gaschange_before / gaschange_after into loop
Declaring everything at the begin of the function is a K&R
disease, that makes code very hard to follow.

Remove the last assignment to gaschange_after since that is
a noop (found by Coverity).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-09-11 07:54:50 +02:00
Berthold Stoeger
6f91a73a05 planner: add move assignment constructor and operator to diveplan
Makes coverity happy and is a good idea.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-09-11 07:54:50 +02:00
Berthold Stoeger
1287880be0 planner: return decotable from plan()
The old return code was not used by any caller.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-09-11 00:13:04 +12:00