First stab at deco calculations

This seems to give us roughly the right data but needs a lot more testing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add configurable visualization of calculated ceiling

This is on top of the deco information reported by the dive computer (in a
different color - currently ugly green). The user needs to enable this via
the Tec page of the preferences.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use gradient factors in deco calculation

Usually dive computers show the ceiling in terms of the next deco stop -
and those are in 3m increments. This commit also adds the ability to chose
either the typical 3m increments or the smooth ceiling that the Bühlmann
algorithm actually calculates.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Consider previous dives when calculating deco

This also initializes the N2 tissue saturations to correct numbers
(setting them to zero was clearly silly).

With this commit we walk back in the dive_table until we find a surface
intervall that's longer than 48h. Or a dive that comes after the last one
we looked at; that would indicate that this is a divelist that contains
dives from multiple divers or dives that for other reasons are not
ordered. In a sane environment one would assume that the dives that need
to be taken into account when doing deco calculations are organized as one
trip in the XML file and so this logic should work.

One major downside of the current implementation is that we recalculate
everything whenever the plot_info is recreated - which happens quite
frequently, for example when resizing the window or even when we go into
loup mode. While this isn't all that compute intensive, this is an utter
waste and we should at least cache the saturation inherited from previous
dives (and clear that number when the selected dive changes). We don't
want to cache all of it as the recreation of the plot_info may be
triggered by the user changing equipment (and most importantly, gasmix)
information. In that case the deco data for this dive does indeed have to
be recreated. But without changing the current dive the saturation after
the last surface intervall should stay the same.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Make GF values configurable

There are a couple of issues with this commit:

GtkEntry should emit the 'changed' signal when it is modified (so that
changes in the preferences get applied right away) - but that doesn't
appear to be working consistently.

Also, this doesn't appear to affect the deco of any dives that I try it
with. So my guess is something is wrong with the underlying deco
algorithm. That's diappointing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix cylinder printout information

If we print out the pressure difference (because we do not have a cylinder
size), we didn't initialize the precision. We should print out pressures
without decimals.

The attached patch fixes that, and also avoids a NULL pointer printout
(which on Linux will just print out "(null)") if there is no cylinder
type descriptor string. It also cleans things up a bit and uses the
"cyl" pointer instead of repeating the "dive->cylinder[n]" thing.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Improvements to select_prev_dive() and select_next_dive()

There were some minor problems when moving the selection
cursor around:

1) If the selection was larger than 1, it was possible
for the selection to get "stuck" in the middle of the list.

This patch approaches this by always calling
gtk_tree_selection_unselect_all() before
gtk_tree_selection_select_iter(), or simply always making
sure we have one selected iterator when navigating with the keys.

2) When there was a single top level dive before the first trip
it wasn't possible to navigate trough the child dives of said
trip in both directions.

The patch attempts to fix this by having the hunks/checks:
if (idx < 0) {

(idx is of a trip) performed regardless of other conditions.

*** Note: testing was done by importing all test*.xml
dives with auto-group on.

[Dirk Hohndel: adjusted the patch to also fix on_key_press to only grab
               the key if no modifier key is pressed; otherwise this
	       breaks shift-cursor-keys for selecting multiple dives.]

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Merge branch 'deco2'

Bringing in the first attempts to do our own deco calculations