Commit graph

79 commits

Author SHA1 Message Date
Dirk Hohndel
ef0272f5ef Perform deco calculation for plan
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>
2013-06-23 21:36:50 -07:00
Dirk Hohndel
596095389b Start hooking in the deco calculations
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>
2013-06-23 20:32:32 -07:00
Dirk Hohndel
f3f7bf51fa Merge branch 'Qt'
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>
2013-05-17 22:01:41 -07:00
Anton Lundin
935af9e8af planning: Add option to have last stop at 6m/20ft
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>
2013-05-03 11:43:50 -07:00
Dirk Hohndel
8677721e85 Remove the majority of the Gtk related code
- 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>
2013-05-03 11:37:09 -07:00
Dirk Hohndel
f86b13102c Separate Gtk related code from core logic: planner
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>
2013-04-08 09:37:38 +02:00
Dirk Hohndel
1d02ba12a3 Separate Gtk related code from core logic: planner
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>
2013-04-07 20:22:41 -07:00
Anton Lundin
0b8462bd58 planning: Add option to have last stop at 6m/20ft
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>
2013-04-02 10:55:19 -07:00
Robert C. Helling
c083ec45a9 Make relative times default in planner 2
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>
2013-03-26 19:30:38 -07:00
Dirk Hohndel
8a5792d473 Manually add gas changes to a dive
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>
2013-03-17 20:04:25 -07:00
Lubomir I. Ivanov
4401132836 Fix potentially broken white space truncation on certain Windows versions
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>
2013-03-07 12:01:47 -08:00
Dirk Hohndel
d2f9ee8d45 Planner: don't use the planned dive for relative start time
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>
2013-02-27 10:22:51 -08:00
Lubomir I. Ivanov
97a43003c4 Planner: use time.h and utc_mktime() to retrive the current time (no TZ)
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>
2013-02-27 09:58:53 -08:00
Robert C. Helling
e5b73d9cb7 Planner: fix wait time calculations
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>
2013-02-23 16:15:18 -08:00
Dirk Hohndel
ac38aa0243 Planner: fix incorrect gas change event
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>
2013-02-19 15:10:01 -08:00
Dirk Hohndel
8527720794 Planner: Start calculations with gas 0 instead of air
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>
2013-02-19 14:28:07 -08:00
Dirk Hohndel
6b458ad7fa Ensure that planner warnings get shown before calculations are run
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>
2013-02-14 07:51:25 -08:00
Dirk Hohndel
d1ee250524 Make planner.c warning consistent
Just a tiny change to make them look more consistent.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-13 23:14:55 -08:00
Dirk Hohndel
fd703f3ca0 Support deeper stops and longer dive notes in planner
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>
2013-02-13 23:02:05 -08:00
Dirk Hohndel
0cde0eff10 Rewriting the error handling in planner.c
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>
2013-02-13 23:02:00 -08:00
Dirk Hohndel
5a540fb9d1 Remove rounded O2 in air
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>
2013-02-12 22:28:31 -08:00
Dirk Hohndel
5e93469f35 Fix gas handling in planner
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>
2013-02-12 21:12:17 -08:00
Dirk Hohndel
9d9eff718b Hopefully last change to po files
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>
2013-02-09 10:39:11 -08:00
Linus Torvalds
926fcef2a1 Do more dive fixup for each dive computer
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>
2013-02-08 18:22:30 -08:00
Dirk Hohndel
61861d2611 Clean up the handling of surface pressure
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>
2013-02-09 08:01:59 +11:00
Dirk Hohndel
79e55b019b Add a more stronly worded warning / disclaimer for dive planning
This is a late string change, but I think this may be a valid exception of
the string freeze...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 22:53:42 +11:00
Sergey Starosek
5cc6e21064 Increase the buffer for the gas text in planner
UTF-8 strings could create more characters.

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-03 21:27:25 +11:00
Dirk Hohndel
de0cdf28b2 Merge branch 'po-files'
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>

Conflicts:
	po/nb_NO.po
	po/ru_RU.po
2013-02-03 18:08:26 +11:00
Dirk Hohndel
7f59026dbf Distinguish the two uses of "Gas Used" for translation purposes
One is about the amount, the other about the specific type of gar that was
used.

Reported-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-03 18:03:10 +11:00
Dirk Hohndel
3e426283b4 Increase the buffer for the gas text in planner
Translations that use UTF-8 could easily create more characters than I had
initially specified.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-03 08:44:51 +11:00
Jan Schubert
99dbd667bf Fixing SP handling in planner, adding event
This moves some double/floating handling for po2 to plain integer. There
are still non int values around (also for phe and po2) in the plot area.

Signed-off-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-03 07:07:12 +11:00
Jan Schubert
59cfa5c427 Fixing SP handling in planner, adding event
Fixing the SP change event and introducing a bailout scenario.

I decided not to use a event showing SP=0.0 nor using a gaschange event as
is in fact there is no gas change related to bailing out itself. If there
is also a gaschange for the event it will be displayed anyway.

Signed-off-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-03 07:06:38 +11:00
Jan Schubert
057253c4eb Fixing SP handling in planner, adding event
Fixes bug in planner which prevents from bailing out (setpoint = 0).

Also introduces events for changing setpoints in planner.
It also makes the eventtype for gaschange slightly more consistent by
changing it from SAMPLE_EVENT_GASCHANGE (O2 only) to
SAMPLE_EVENT_GASCHANGE2 (O2/He). But Subsurface treats them both the same
(the distinction comes from libdivecomputer).

Signed-off-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-03 07:05:16 +11:00
Lubomir I. Ivanov
60f9c338e9 planner.c: Use g_time_zone_find_interval()
current_time_notz():
Attempt to use g_time_zone_find_interval() to retrieve a
timezone interval, which is then passed to g_time_zone_get_offset()

Reported and tested-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-02 00:05:03 +11:00
Dirk Hohndel
aa55bda944 Don't allow to plan dives out of order
The planned dive always has to be the last dive in the dive list. To make
sure of that we interpret the relative start time to be relative to either
the current time or the end of the last dive, whichever is later.

This fixes a bug where we would delete the wrong dive and get our data
structures confused by planning multiple dives out of order.

Reported-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-31 23:50:35 +11:00
Dirk Hohndel
e3a8ed5183 Massive cleanup
Mostly coding style and whitespace changes plus making lots of functions
static that have no need to be extern. This also helped find a bit of code
that is actually no longer used.

This should have absolutely no functional impact - all changes should be
purely cosmetic. But it removes a bunch of lines of code and makes the
rest easier to read.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-30 08:31:53 +11:00
Dirk Hohndel
a61877d1d4 Add missing strings for translations
Mostly in new code, but some of them are strings in older code that have
been missed in the past.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-29 20:32:56 +11:00
Dirk Hohndel
55b3fd12a8 Make dive planner more useful for closed circuit diving
Add a sample at time 0 to allow for a pO2 from the start of the dive.
Remember the last pO2 so it doesn't have to be repeated (and the right
thing happens for the planned part of the dive).

This still doesn't allow us to change the setpoint at a certain depth
(which would be analogous to being able to switch to a certain gas at a
certain depth in OC plans), but with this commit it's already usable.

This commit also fixes a couple of small bugs in commit b8ee3de870fa
("Dive planning for closed circuit rebreather") where a pO2 of 1.1 was
hardcoded in one place, throwing off all plan calculations and integer
math was used to calculate a floating point value (leading to most pO2
values actually used being 1.0).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-28 21:39:25 -08:00
Jan Schubert
9df9fc088d Dive planning for closed circuit rebreather
This misses a single issue to be used as a base for further discussion:
The CC setpoint is used for the next segment, not the one specified for. I
also have in mind to modify the existing code to use setpoints specified
in mbar and plain integer instead of float values.

Signed-off-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-28 18:31:30 -08:00
Linus Torvalds
77ece3fccb Clean up gtk combo box handling
This cleans up our handling of combo boxes and all the duplicated
completion logic, and simplifies the code.

In particular, we get rid of the deprecated GtkComboBoxEntry.  While it
made some things easier, it made other things harder.  Just using
GtkComboBox and setting that up correctly ends up being simpler, and
also makes the logic work with gtk-3.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-28 13:17:44 -08:00
Henrik Brautaset Aronsen
d1262848d8 Fix compile error in planner.c
Linus seems to have been too eager in the dc refactoring: a diveplan
doesn't have a divecomputer.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24 08:47:34 -08:00
Linus Torvalds
b6c9301e58 Move more dive computer filled data to the divecomputer structure
This moves the fields 'duration', 'surfacetime', 'maxdepth',
'meandepth', 'airtemp', 'watertemp', 'salinity' and 'surface_pressure'
to the per-divecomputer data structure.  They are filled in by the dive
computer, and normally not edited.

NOTE! All actual *use* of this data was then changed from dive->field to
dive->dc.field programmatically with a shell-script and sed, and the
result then edited for details.  So while the XML save and restore code
has been updated, all the displaying etc will currently always just show
the first dive computer entry.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23 12:55:33 -08:00
Dirk Hohndel
aa3eb364bc Add GFlow/GFhigh settings in dive planner
The planner interactively responds to changes to the GFlow and GFhigh in
the dialog and calculates an appropriate profile. If there is a previous
dive within the 48 hours prior to this dive then its saturation is
correctly taken into account if the gradient factors are changed - so if
they are aggressively lowered it is possible to start the dive with
already an existing ceiling (simply increase the surface interval to 'fix'
that).

Once the plan is accepted the GF values are reset to the current
preferences. This can cause the ceiling in the plot to change and the deco
stops to no longer match the ceiling - but that's a logical consequence of
the ability to change a temporary copy of GFlow/GFhigh during the planning
process and not the actual preferences (which would be counter intuitive,
I think).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-16 15:40:38 -08:00
Dirk Hohndel
2cee400ad1 Correctly mark divelist changed after accepting dive plan
Commit 293126257b20 ("Mark divelist as changed if user accepts planned
dive") had the correct commit message but an incorrect implementation.

This moves the mark_divelist_changed() call into the GTK_RESPONSE_ACCEPT
clause where it belongs.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-16 14:44:11 -08:00
Dirk Hohndel
348c590ac6 Mark divelist as changed if user accepts planned dive
When the user clicks OK in the dive planner and the dive is added to the
divelist the divelist needs to be marked as changed so Subsurface prompts
the user to save the file before quitting.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-15 17:35:29 -08:00
Dirk Hohndel
db8de4233d Calculate the gas used during the planned dive
This works on the assumption that the diver uses the deco SAC rate while
on a calculated deco stop and the bottom SAC rate during the rest of the
dive (including the time they move from deco stop to deco stop).

This is making the planning function mostly useful for open circuit
diving.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-15 17:35:14 -08:00
Dirk Hohndel
c3a08ff056 Add diveplan to the dive notes
This makes it easy to print out a dive plan - it's simply stored in the
notes of the simulated dive we create.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-15 17:34:51 -08:00
Dirk Hohndel
189cba7fd2 Add code to enter SAC rates for dive planning
This just provides the infrastructure to enter the data, nothing is
calculated, yet.

This adds a new get_thousandths() helper function so we can enter
information of the 'mili-' type as decimal values. So things like
"14.5 l/min" or "0.75 cuft/min" are parsed correctly and converted
into a ml value.

In the process of implementing that I also fixed a bug introduced in
commit ab7aecf16e ("Simplify dive planning code") which broke the
get_tenth() function.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-15 17:31:27 -08:00
Dirk Hohndel
417391a801 Add small helper function to make planner gui function easier to read
This is just preparation for the next set of changes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-15 17:31:03 -08:00
Jan Schubert
322410a845 Trivial pressure related fixes
This patch removes the need for the "string" pressurebuf in planner.c.

It also adds a unit to the partial pressures displayed in the mouse
overlay which are always displayed in bar.

BTW: Has anyone seen a pO2 shown in PSI?

Signed-off-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-15 10:13:33 -08:00