In commit 904aa0be0d0e ("Do more dive fixup for each dive computer") two
new helper functions were introduced that sadly both incremented variables
without initializing them, first.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Populate during dive fixup as the maximum depth shown by all the
divecomputers. Use this value (instead of the one in the first
divecomputer) in printing, statistics, etc.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The existing code only populated the maxtemp based on the samples of a
dive and then in statistics.c checked if there was no such temperature and
replaced it with the water temperature of the first divecomputer.
It makes much more sense to add the water temperature information in every
divecomputer to the min / max calculation during the dive fixup phase.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Float values have insufficient precision compared to the udeg we usually
store - so we create a special callback function to use from osm-gps-map
and everywhere else use integers.
This patch also increases the decimal places displayed in the GPS text
entry box - this way we can cut and paste the text without loss of
precision.
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The fixup_dives() code used to only look at the first divecomputer,
which meant that minimun temperatures etc for the dive would only ever
come from the primary divecomputer.
This splits up the code that walks over the divecomputer into a function
of its own, and iterates over all computers in fixup_dive() calling into
it.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In commit b6c9301e58 ("Move more dive computer filled data to the
divecomputer structure") we moved the fields that get filled in by the
dive computers to be per-divecomputer data structures.
This patch re-creates some of those fields back in the "struct dive",
but now the fields are initialized to be a reasonable average from the
dive computer data. We already did some of this for the temperature
min/max fields for the statistics, so this just continues that trend.
The goal is to make it easy to look at "dive values" without having to
iterate over dive computers every time you do. Just do it once in
"fixup_dive()" instead.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of maintaining a rolling average and re-calculating it at each
stage, just calculate the surface_pressure average the natural way: as
the sum divided by the number of entries.
This results in a single rounding, rather than doing rounding multiple
times and possibly rounding wrong as a result.
Not that we care all that deeply about the LSB of the mbar value, but
the code is simpler and more obvious this way too.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Translated all missing and fuzzy strings in preparation for v3.0
Abbreviated a few Dutch strings to take up less space on screen.
Signed-off-by: Reinout Hoornweg <reinout@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
There are two ways to look at surface pressure. One is to say "what was
the surface pressure during that dive?" - in that case we now return an
average over the pressure reported by the different divecomputers (or the
standard 1013mbar if none reported any).
Or you want to do specific calculations for a specific divecomputer - in
which case we access only the pressure reported by THAT divecomputer, if
present (and fall back to the previous case, otherwise).
We still have lots of places in Subsurface that only act on the first
divecomputer. As a side effect of this change we now make this more
obvious as we in those cases pass a pointer to the first divecomputer
explicitly to the calculations.
Either way, this commit should prevent us from ever mistakenly basing our
calculations on a surface pressure of 0 (which is the initial bug in
deco.c that triggered all this).
Similar changes need to be made for other elements that we currently only
use from the first divecomputer, i.e., salinity.
Reported-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I forgot to include the list in my reply to Linus, but here comes
an updated translation with fix for some spelling and change of
"Långkalsonger" to "Longjohn" which seems like the accepted wording
used for that kind of wetsuit.
Dirk, I hope I got it right this time (wrapping/utf-8)
Signed-off-by: Fredrik Steen <fredrik@ppo2.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It wasn't really used. The only reader of that array was the same thing
that wrote the entry, so instead of storing it in the array (and never
using it ever after), just use the calculation directly, and remove the
array entirely.
This makes it much easier to see that the gradient factors are not used
for any long-term state. We use them only for the pressure tolerance
calculations at that particular point, and there is no "history"
associated with it.
This matters mainly because it means that we can do all the deco
initialization and setup without worrying about exactly which gradient
factors we will use. And we can use different gradient factors for
diving and planning and no-fly calculations without the GF choice
affecting the tissue state.
Acked-by: Robert C. Helling <helling@lmu.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Some days I'm just a f*cking moron. That code was so stupid that I'm
lacking words. I replaced using the first divecomputer with using the last
divecomputer. When what I wanted was to use the maximum duration.
This looks better.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We'll want to use a 'static const' gasmix for the upcoming no-fly-time
code, so prepare for it by just marking the read-only gasmix argument as
'const'.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
So far we always used the duration of the first divecomputer. The same fix
needs to be done for some of the other calculations that always use the
first divecomputer.
This commit also removes some obsolete code from the webservice merging.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The Uemis SDA returns the data for each dive from several different
databases. And oddly, the getDive data uses a different key than the
getDivelog data. We have always compensated for that by looking up the
correct key and applying the data to that dive, but unfortunately we
didn't adjust the loop to correctly retrieve the getDive data for the
dives that were downloaded. So depending on how big the offset between
those two keys was we wouldn't get all of the necessary data.
With this change we try one, calculate the offset and then restart the
loop. Insane, but appears to be the only way to make this work.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We had the logic for the "select" case, but not for the "deselect" case. Ugh.
Reported-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is only slightly better than "Bork bork bork". I've never done any
diving in Swedish. It's probably hilarious, but should be mostly
understandable.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The cylinder size is treated as metric as the samples received indicate
it would be so.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Making sure the XSL transformation does not occur on Subsurface's old
XML format. A deeper inspection on the XML content is required as
MacDive and Subsurface (old format) have the same root element (dives).
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is not getting us ready for 3.0, it mostly fixes some of the obvious
errors in there that were correct for Subsurface 2.1 but clearly are no
longer true (like the suggestion to specifically check out libdivecomputer
0.2.0).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Increase the size of "buffer" to 160 bytes. This was causing
a problem with the first call to pango_layout_text(), where
for the "bg_BG" locale, not enought space was allocated for the
month name, the translation of "dive" and the other values.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
gtk-gui.c:
+ added the method get_screen_dpi() that uses a simple
formula to retrieve the actual screen DPI
display.h:
+ use get_screen_dpi() in the SCALE_PRINT macro
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This XSLT converts MacDive logs into Subsurface format. It supports both
the current version and the upcoming version of the log format.
Conversion was not tested with Imperial units as no samples were
available of such logs. Thus functionality with Imperial units is not
guaranteed.
Note that the gear inventory is currently discarded.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When we download dives with libdivecomputer, we create this strdup'ed
name of the model information, but we then re-use that (single) strdup
allocation for every dive we download. This works fine *until* you
start freeing those dives (possibly directly after the download because
they are redundant), at which point things go to hell in a handbasket,
since there is just the one allocation for all the different dives.
Fix by just doing another strdup() at the point where we assign the
model information to the dive computer.
Reported-by: Marc Merlin <marc@merlins.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The temperature plot line was drawn to the end of the dive, but the last
temperature plot text was printed near the last temperature *sample*.
This was most visible on dives/test27.xml where two "20˚C" were
printed on top of each other at the start of the dive, while nothing
was printed at the end.
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
"Arial Unicode MS" doesn't have bold fonts, at least not on my system.
This makes it impossible to distinguish trip dives from non-trip dives,
since dives without at trip have bold index numbers.
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Still plenty to be translated and verified by someone who actually knows
the finnish scuba vocabulary
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Merging two different dives by interleaving dive computer data got
broken by the multi-dive-computer code in commit b6c9301e58 ("Move
more dive computer filled data to the divecomputer structure") which
added a lot more entries to the dive computer data structure, and then
copied the resulting structure incorrectly.
Make sure we don't copy the events and samples allocations when we copy
all the other fields of the divecomputer.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We had this special logic to not show the end of a dive when a dive
computer shows a series of very shallow samples (basically snorkeling
back to shore after the dive ended). However, that logic ended up being
global per dive, which is very annoying when you have two or more dive
computers, and it decides to cut off the second one because the first
one surfaces.
So get rid of this per-dive state, and just use the plot-info 'maxtime'
field for this (we never used the 'start' case anyway). That way we
will properly cut off boring surface entries only when they are past the
end of the interesting entries of *all* dive computers, and we won't be
cutting things short.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If any component of the suit information downloaded from the Uemis SDA is
"" we would replace that by the POT information when running the software
in a different locale. So only add this text (and translate this text) if
it is != "".
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The previous attempt in commit f305c5c83fe1 ("Correctly parse translated
cardinal directions") suffered from a bit of false advertising in that it
wasn't, actually, "correct". It made silly assumptions about the length of
the translated strings being 1 and also forgot the middle part of the
algorithm where we use the appearance of 'E' or 'W' (and their translated
brethren) as indication that there are no minutes for the the latitude.
Hopefully this version does better.
Reported-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
- Set parameters for scaling the layout ( w and h_scale_factor),
number of prints per page and rotation.
- Let draw_page() manage the whole print whith the received params.
- Remove draw_oneperpage() as it's unused.
- Use the w_scale_factor for scaling the fonts.
- Change option text in the GTK menu.
TODO:
- A GTK menu which let the user select the print params directly or ...
- Introduce new predefined options in the printing menu.
- Modify draw_page() for printing "landscaped" 6 dives if selected.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This doesn't change any real semantics, but it means that we will write
out the device computer information in a well-defined order, rather than
in some random order (before this: reverse order of reading them in).
Having the XML file be as stable as possible is important so that *real*
changes stand out when you make changes to your dives.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The air temperature editing was broken when you edited multiple dives at
once: even if you didn't actually change the air temperature, all dives
would be reset to that particular temperature.
The logic for editing dives is that we have a 'master' dive (which is
the dive that all the entries get filled in from), and only if the
entries have changed from what the master dive information was (ie the
user actually edited it) do we change that particular piece of
information.
And we only change it for dives that match the master dive for that
entry.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When editing a new dive, and using a dive site name that we have
already seen previously, and have GPS information for, pick up that
GPS information from the previous dive by default.
NOTE! When editing dive site locations for dives that already have GPS
information, or when we've modified the GPS information explicitly
some way while editing the dive (either through map input or by
editing the text field directly) we do *not* use this automatic logic.
So if you messed up the GPS information some way and want to
re-populate it with the automatic mode, you need to explicitly clear
the GPS text-field, at which point we go back to "ok, let's try to
pick up automatic GPS data from previous dives with the same name"
mode.
Also note that we do the automatic location lookup only when actually
editing the location field. So if you already wrote the dive site
name, then cleared the GPS field, you now need to go back to the dive
site name and edit it again to get the automatic GPS filling.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fixed the different usages of "Gas used", as well as a couple
of other small fixes
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Commit acd5a935850 ("Distinguish the two uses of "Gas Used" for
translation purposes") allows us to get this right.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>