Add CNS and pO2 tracking in the samples

This adds the new members to the sample structure and fills them from
supported dive computers (Uemis SDA and OSTC / Shearwater Predator,
assuming you have libdivecomputer 0.3).

Save relvant values of this to the XML file and load it back. Handle the
new fields when merging dives.

At this stage we don't DO anything with this, all we do is extract them
from the dive computer, save them to the XML file and load them back.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Plot pO2 graph based on sample information, if available

This should give closed circuit divers with a supported dive computer
correct partial pressure plots.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Show two decimal digits in pO2, pN2 and pHe in the tooltip

Tec divers seem to like a little bit more precision - and the dive
computers certainly provide it (or we can calculate it).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Make changes to some of the preference immediately visible

This is just a small part of the solution to the bigger problem with the
preferences.

See ticket 21

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Make sure pO2 and cns are filled in all samples

This allows things to work for dive computers like the OSTC that give us
setpoint information in the sample, but not constant pO2 readings.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Draw pO2 profile last

This way it sits on top of the other partial pressure plots and is a bit
easier to read.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Correctly parse the two different gas change events

This now takes the He percentage into account when matching tanks. Given
the encoding of fO2 and fHe in the GASCHANGE2 event, we can simply mask
and shift as if we have a GASCHANGE2 event and things will automatically
work correctly for the regular GASCHANGE event.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Correct partial pressure calculations

Regardless what the dive computer tells us, don't believe that pO2 was
higher than the ambient pressure. This gives much more realistic values.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Don't print an initial gaschange event that just tells us the gas used

Some dive computers appear to tell us the gas used in a gaschange event
right at the beginning of the dive. We arbitrary have a cut-off that says
"a gas change in the first 30 seconds shouldn't get a marker".

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Don't print partial pressure values in the profile

Instead provide a scale on the right in a highly transparent grey and rely
on the tooltip available with mouse-over to pinpoint the value at certain
spots with much better accuracy.

Fixes #30

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Display maximum CNS in the divelist

We either pick the CNS reported by the dive computer at the end of the
dive, or the maximum of that and the CNS values in the samples, if any.

As usual, this column in the dive list defaults to off and it is
controlled by a setting in the tec page of the preferences.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Update to the new deco / ndl code in libdivecomputer

Early in the libdivecomputer 0.3 development cycle Jef and I implemented
deco and ndl as events. That wasn't a wise design choice and we agreed to
switch this to be instead new sample types which makes much more sense
(and is much more aligned with the way we are handling them inside
Subsurface). So this commit tracks the change in libdivecomputer. Since
this happened during the development cycle there isn't a way to detect
this at compile time - so you need to make sure you have a matching
version of libdivecomputer when compiling Subsurface.

To make this easier: this commit of Subsurface requires a libdivecomputer
version that includes the libdivecomputer commit d5d44c1e0ffd "Convert
decostop / ndl to samples".

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Merge branch 'cns' into cns-merge

I foolishly changed visible_columns in both the (ill-named) cns branch and
master...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>

Conflicts:
	divelist.c
	gtk-gui.c
	profile.c
Fix minor indentation issue

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Correctly merge cns, ndl and deco information

I keep forgetting to do that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Show CNS value in the profile mouseover

If we have per-sample CNS values, then show them in the profile tooltip.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>