With this every cylinder downloaded from a divecomputer that doesn't
provide cylinder data, and every cylinder manually added anywhere will
default to the default cylinder that is set in the preferences.
For people who most of the time dive with the same equipment (always on
dive boats with AL80, or almost always diving their personal HP119) this
should be a nice improvement.
If you don't like this behavior, simply leave the default cylinder setting
in the preferences empty.
This commit also fixes the incorrect s->value call (should be
s->setValue). I wonder what this did to the default filename before...
Fixes#145
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The *-clang* selector doesn't appear to work correctly in my build environment
(or I just don't understand how it is supposed to work). Either way, making
this conditional on !mac works.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
There is a add_gas_switch_event, so don't duplicate the code.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This allows to add missing gas change events to the currently shown dive
computer. Only gases defined in the Equipment section are offered.
Fixes: #250
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
- get_gas_from_events does NOT always set o2/he. It only updates them IFF
a matching event is found; so we need to make sure we start out with a
valid gas mix
- the way we tried to restore the edited dive in case of an edit to a
manually added that is cancelled was completely bogus. Way too complex
when we can simply and reliably simply store the dive and then copy it
back
Fixes#270
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Right now hardcoded to AL80. This way in the future we'll have a volume of
gas that's available. And this makes much more sense then a random string
in the description field.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This partially reverts changes in commit 1b655d5c806b ("Correctly track
gases when manually adding and then editing dives") as it turns out this
did NOT help us correctly track gases (which is ironic, given the title of
that commit). I didn't actually want to revert that commit as
infrastructure has changed since then and this made the patches look even
more incomprehensible.
So we are back to tracking the "gas on which we arrive at this spot" in
each dive plan node as this makes the rest of our planning so much easier
- I had forgotten about the reasons why we did things this way when I made
the above mentioned commit.
Instead we now make sure that our available tanks are added the correct
way, that such entries are ignored when planning and when drawing the
editable profile, and that at the end it all gets assembled correctly.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is a corner case in the planner that was exposed by the recent
changes to the way the dive plan reflects the gases during the dive.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The code had quite a few odd special cases that may have been left-overs
from the old Gtk algorithm. With this the gas is actually in the dive plan
node where it's use starts. And we maintain the gas correctly between
multiple edit sessions.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since the model name is written into the XML file it has to be a literal
string that isn't translated. Otherwise a datafile written in one locale
behaves differently when opened by Subsurface under a different locale.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This gets rid of compiler warnings "format not a string literal and no
format arguments [-Wformat-security]". E.g. when building distribution
packages these warnings are often treated as errors preventing the
build (with good reason).
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
This may seem like a really odd change - but with this change the Qt tools
can correctly parse the C files (and qt-gui.cpp) and get the context for
the translatable strings right.
It's not super-pretty (I'll admit that _("string literal") is much easier
on the eye than translate("gettextFromC", "string literal") ) but I think
this will be the price of success.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I always worry if these are worth following up on - but these seem pretty
clear and obvious to me. As far as the planner is concerned, depth is
unsigned.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
- remove the build flags and libraries from the Makefile / Configure.mk
- remove the glib types (gboolean, gchar, gint64, gint)
- comment out / hack around gettext
- replace the glib file helper functions
- replace g_ascii_strtod
- replace g_build_filename
- use environment variables instead of g_get_home_dir() & g_get_user_name()
- comment out GPS string parsing (uses glib utf8 macros)
This needs massive cleanup, but it's a snapshot of what I have right now, in
case people want to look at it.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Simply trying to role-model safe behavior I guess. Fundamentally all this
should be configurable (so I added comments about that on the planner side
as well).
One of the interseting side effects of this implementation is that if the
user removes the safety stop and comes up directly from a deeper depth,
the slope of the ascent will change at 5m :-)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In add dive mode simply bring the diver safely back to the surface
(currently with a fixed ascent rate of 30ft/min (or 9m/min)).
We should make that rate configurable (for the planner as well as the dive
add function). Also, the dive add function should offer to automatically
include a safety stop.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The gas choice now works and correctly ( I hope ) calculates
the gas choosen to show on the planner. User can choose the
gas from the list on the visual planner, and also on the table.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Remove circle in plan by starting the first line at the first point
rather than the last.
In addition marks all entered points as entered and not just the first and
sets line color accordingly.
Makes plan_add_segment return the added data point.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This uses a bunch of default values that we eventually need to get from
the UI, but it's a first step towards a working dive planner.
This exhibits some graphical artifacts when running, but other than that
appears to be mostly correct.
Things go far worse if I enable the changing of the scale once the deco
makes the dive longer than the displayed time window. Things quickly
spiral out of control.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I expanded the DiveHandler to include the actual time / depth of each
node on the graph - this way things will stay consistent if we need to
rescale the graph.
One thing that this makes obvious is that the whole design for the
planner so far assumes metric data. We need to make sure this works well
with feet instead of meters as well (and that it uses the information in
the units settings).
With this change we actually create a dive based on the plan input and
add the deco stops (if needed) to it - but we don't do anything with the
results of those calculations, yet.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
After the 3.1 release it is time to shift the focus on the Qt effort - and
the best way to do this is to merge the changes in the Qt branch into
master.
Linus was extremely nice and did a merge for me. I decided to do my own
merge instead (which by accident actually based on a different version of
the Qt branch) and then used his merge to double check what I was doing.
I resolved a few things differently but overall what we did was very much
the same (and I say this with pride since Linus is a professional git
merger)
Here's his merge commit message:
This is a rough and tumble merge of the Qt branch into 'master',
trying to sort out the conflicts as best as I could.
There were two major kinds of conflicts:
- the Makefile changes, in particular the split of the single
Makefile into Rules.mk and Configure.mk, along with the obvious Qt
build changes themselves.
Those changes conflicted with some of the updates done in mainline
wrt "release" targets and some helper macros ($(NAME) etc).
Resolved by largely taking the Qt branch versions, and then editing
in the most obvious parts of the Makefile updates from mainline.
NOTE! The script/get_version shell script was made to just fail
silently on not finding a git repository, which avoided having to
take some particularly ugly Makefile changes.
- Various random updates in mainline to support things like dive tags.
The conflicts were mainly to the gtk GUI parts, which obviously
looked different afterwards. I fixed things up to look like the
newer code, but since the gtk files themselves are actually dead in
the Qt branch, this is largely irrelevant.
NOTE! This does *NOT* introduce the equivalent Qt functionality.
The fields are there in the code now, but there's no Qt UI for the
whole dive tag stuff etc.
This seems to compile for me (although I have to force
"QMAKE=qmake-qt4" on f19), and results in a Linux binary that seems to
work, but it is otherwise largely untested.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When diving in areas where there are risk of boats passing above you,
its common practise to do the last stop at 6m to better stay out of
harms way. When doing o2-deco, it doesn't matter for the deco time if
you are doing all the time at 6m, due to that you don't have any inert
gas in your breathing gas.
This code is a reintroduction of 0b8462bd lost somehow between
a70a8898..8fae0031
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
- rip all Gtk code from qt-gui.cpp
- don't compile Gtk specific files
- don't link against Gtk libraries
- don't compile modules we don't use at all (yet)
- use #if USE_GTK_UI on the remaining files to disable Gtk related parts
- disable the non-functional Cochran support while I'm at it
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Relatively straight forward, just a handful of places where we call
show_error() (a UI function) from the logic code. In the process I noticed
a few places where error returns weren't dealt with correctly.
Added a new planner.h files for the necessary declarations.
This should make no difference to functionality.
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Relatively straight forward, just a handful of places where we call
show_error() (a UI function) from the logic code. In the process I noticed
a few places where error returns weren't dealt with correctly.
Added a new planner.h files for the necessary declarations.
This should make no difference to functionality.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When diving in areas where there are risk of boats passing above you,
its common practise to do the last stop at 6m to better stay out of
harms way. When doing o2-deco, it doesn't matter for the deco time if
you are doing all the time at 6m, due to that you don't have any inert
gas in your breathing gas.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In planning you usually plan lengths of segments rather than runtimes to
leave a level.
This patch superseeds a previous one with a similar name and (even more)
broken spacing.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Create a little widget that lists all the gases / tanks we know about and
allow the user to pick one of them.
Turns out that add_event only added events at the end of the list - but we
treat that list as chronologically sorted. So I fixed that little
mis-feature as well.
This does raise the question whether we need the inverse operation
(removing a gas change). And if there are other things that we should be
able to manually edit, now that we have the infrastructure for this neat
little context menu...
See #60 -- this doesn't address all of the issues mentioned there, but at
least deals with the 'headline' of the feature request...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Testing the Planner in Subsurface on a Windows XP SP3 installation,
shows corrupted UTF-8 strings in the case of Cyrillic locales, but
possibly others as well. Instead limited to the Planner, this affects
the entire application.
After some examination it appears that <ctype>'s isspace() in MSVC
on the tested version of Windows is broken for some UTF-8 characters,
after enabling the user locale using: setlocale(LC_ALL, "");
For example, characters such as the Cyrillic capital "BE" are defined as:
0xD091, where isspace() for the first byte returns 0x08, which is the
bytemask for C1_SPACE and the character is treated as space.
After a byte is treated as space, it is usually discarded from a UTF-8
character/string, where if only one byte left, corrupting the entire
string.
In Subsurface, usages of string trimming are present in multiple
locations, so to make this work try to use GLib's g_ascii_isspace(),
which is a locale agnostic version of isspace().
Affected versions of Windows could be everything up to XP SP3,
but not apparently Vista.
Reported-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The existing code has an embarrassing error in its logic. It picked the
last dive in the table and made sure that the relative start time was
either N minutes after 'now' or N minutes after the last dive ends,
whichever is later.
But once the planned dive has been added to the dive list (so once we have
a first depth and time entry, that last dive now is the planned dive. And
every time focus left the start time field the start time would be
recalculated relative to the end of the dive we are currently planning.
With this patch we instead simply remember the number of the last dive
just as we create the dive plan and use that to look up the end time of
previous dive. I could have just stored that end time but I figured maybe
there could be other reasons to go back to the last dive before the
planned dive, so this seemed cleaner.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This should do the same as the GTimeZone variant.
Also works on Windows.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The problem is that when we reach the gas change depth and compute the
stop time, no gas change event is created yet but time_at_last_depth tries
to determine the gas for the stop from events.
So instead we pass o2 and he as parameters of that function and calculate
the wait time based on that information.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We stored the He permille instead of the He percentage. But for most
casual testing this was hidden by the previous bug.
Reported-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The planner had a fatal flaw in that it ALWAYS started with AIR, even when
clearly claiming to use the correct gas. We only picked up correct gases
from events, but not at the beginning of the dive (where there is no
event).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Linus pointed out that the warning wasn't shown until the main loop got
control back, so even a gtk_widget_show_all() doesn't really help to make
sure that things are shown right then.
This commit adds a little loop to handle all pending gtk_events before
exiting the show_error() function. Now the warning should be shown BEFORE
a potentially slow calculation gets started.
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since we now support dives all the way down to 400m we should also support
deeper stops. And of course this can create insanely long dive plans, so
make sure there is plenty of space for those.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Printf is not a way to issue warnings and errors. This is a very late
addition but seems necessary for a viable release of the planner.
This also adds one artificial limit and two warnings:
a) no dives deeper than 400m
b) warning of potentially very long calculation times for dives longer
than 3h (180min) before the ascent and dives deeper than 150m
It also creates quite a number of new strings that need to be translated
(and marks a few existing ones for translation as well).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
To quote Linus, gentle as always:
Stuff like this is just BS.
Don't do it. You already fixed the bug with matching gas change events,
so adding this idiotic workaround no longer fixes anything, and its
confusing and actively misleading.
It's not even percent. It's still permille, just rounded. So it's a
nonsensical number and a misleading name. Just delete it as the abortion
it is. It is only going to cause more problems later.
Just use the correct value.
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Two separate bugs.
a) Air cylinders were created with o2=209 and no other value set.
sanitize_gasmix() turned that into o2=0 which meant that this cylinder was
now identified as "nodata", i.e., unset.
We now set a fake cylinder name to deal with that issue.
b) the gaschange event is inherited from libdivecomputer and therefore
only supports 1 percent granularity for o2 and h2. Since we didn't round
when assigning the value we ended up with air being stored as o2=20 he=0
which of course then didn't match air anymore (which we have defined as
208 <= o2 <= 210).
We now use o2=210 for air in the planner and carefully round the permille
values whenever we convert into percent - and compare gases with percent
granularity as well.
A better fix for b) would be to change the Subsurface event to not simply
copy the libdivecomputer behavior and use percent granularity but support
permille instead. But this closely before the 3.0 release that seemed like
a far too invasive change to make - the changes to the planner should have
no impact outside the planner module.
Reported-by: Chris Lewis <chrislewis915@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While this is a pain for everyone, I decided not to edit out the code
reference noise - after all this is supposed to help translators find
where the text is used in case it's unclear how to translate something.
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>
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>