Commit graph

9219 commits

Author SHA1 Message Date
Dirk Hohndel
ff0209a5b4 fix mingw-win32 specific warnings in libdivecomputer.c
1) since %lld is not defined in the MSVC runtime, use
the portable PRId64 macro from inttypes.h for 64bit integers

notice in inttypes.h from mingw-win32:
/* 7.8.1 Macros for format specifiers
 *
 * MS runtime does not yet understand C9x standard "ll"
 * length specifier. It appears to treat "ll" as "l".
 * The non-standard I64 length specifier causes warning in GCC,
 * but understood by MS runtime functions.
 */

2) include unistd.h to disable warning:
warning: implicit declaration of function 'usleep'

Lubomir's code then caused a warning building natively under Linux, which
I fixed as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2011-11-27 09:10:37 -08:00
Dirk Hohndel
9b9355c770 Fix mingw-make.sh to find correct xslt-config
I hadn't noticed that xslt was available as cross built library as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-27 09:08:55 -08:00
Linus Torvalds
19356de246 Merge branch 'windows-fixes' of git://git.hohndel.org/subsurface
* 'windows-fixes' of git://git.hohndel.org/subsurface:
  Add more typecasts for Windows`
  Fix the Windows preferences support
  Update the Windows installer creation script
2011-11-25 21:51:34 -08:00
Linus Torvalds
0d879f8fbe Remove stale notebook drag-and-drop support
It doesn't make sense with the new three-pane layout, and I don't think
we're reviving it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-25 21:50:38 -08:00
Dirk Hohndel
192713680e Add more typecasts for Windows`
This is based on an older patch by Lubomir I. Ivanov <neolit123@gmail.com>
which no longer applies due to the refactoring of the registry setting
code.

It takes care of all of the casts between actual C types and the Windows
specific types that the Windows API functions expect. It also adds some
comments to the overloading of "value" in our subsurface_set_conf function.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-25 20:19:58 -08:00
Dirk Hohndel
d2654d4951 Fix the Windows preferences support
Now that I can test Windows binaries again, the bugs were rather easy to
spot. Because of the different flow of the opening, writing and closing of
the registry key my first attempt got things wrong - we simply always
create the key with all access rights; if it exists Windows will just open
it for us. The second bug was a cut'n'paste error.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-25 19:48:53 -08:00
Dirk Hohndel
a9d1f318b5 Update the Windows installer creation script
This now works with a straight out of the box MinGW install on OpenSUSE.
A simple shell script that shows how to invoke the cross build is
included.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-25 19:48:09 -08:00
Dirk Hohndel
042c77c0fc Improve cross compile support and fix windows.c
This should make the Makefile much more robust when cross compiling.

The windows.c code is now compile tested but not functionally tested.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-24 22:34:39 -08:00
Linus Torvalds
290ce56d01 Merge branch 'mac-fixes' of git://git.hohndel.org/subsurface
* 'mac-fixes' of git://git.hohndel.org/subsurface:
  Split reading/writing preferences into OS specific files
2011-11-24 10:42:37 -08:00
Dirk Hohndel
671f6544ac Split reading/writing preferences into OS specific files
This adds tested code for Linux and Mac OS, implementing the api that
Linus suggested.

The Windows code was moved into its own file, but hasn't even been compile
tested, yet.

In order to have just one interface to set or get a preference value we
encode TRUE as (void *) 1 and FALSE as NULL. This works consistently on
all platforms and regardless of whether we have 32 or 64 bit.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-24 10:12:40 -08:00
Linus Torvalds
cb2114f263 Merge branch 'mac-fixes' of git://git.hohndel.org/subsurface
* 'mac-fixes' of git://git.hohndel.org/subsurface:
  Preference handling on Mac
2011-11-22 15:57:08 -08:00
Dirk Hohndel
cf6e0e7ca1 Preference handling on Mac
This cleans up the platform conditional handling and gets rid of gconf on the Mac.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-22 12:20:36 -08:00
Dirk Hohndel
b577484998 Exclude surface intervals from sac rate calculation
We assume every sample with a depth of less than 10cm to be on the
surface.

This does not impact our interpolated pressures (one could assume that the
diver is not breathing from the regulator when on the surface - but
without air integration that's just an assumption).

It also doesn't change our tank pressure coloring by sac rate as that
always uses the momentary sac rate. Technically speaking this might impact
the actual colors printed (as those are relative to the total sac on the
dive which may go up due to this change).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-21 13:23:13 -08:00
Dirk Hohndel
0d1f8f9a5d Don't colorize the pressure plot when printing
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-21 12:35:42 -08:00
Dirk Hohndel
0f13971869 Add debugging function to dump tank pressure tracking data
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-21 12:29:16 -08:00
Linus Torvalds
e5471e3fe8 Remove suunto parsing hacks from parse-xml.c
We can just depend on Miika's xslt transform instead.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-21 11:35:06 -08:00
Miika Turkia
61f3114fce XSLT to import SDM dive log
This is tested with Linus' sample data, all basic functionality seems to
be working properly. Gas changes are implemented but not tested as there
was no samples of those. Multiple cylinders are missing because there
was no samples available.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-21 11:33:52 -08:00
Miika Turkia
5a046d94ea Support for importing multiple XSLT formats
Have information of multiple XSLT files on an array for importing
"alien" formatted XML dive log files. Adding support for new XSLT
requires updating the array and adding the XSLT file (provided the
format can be identified by root element of the XML).

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-21 11:33:52 -08:00
Linus Torvalds
f09266897b Merge branch 'multi-pane'
* multi-pane:
  Experimental hard-coded three-pane layout

Ok, so it's not perfect, but I've been using a version of this for the
last week or so by now, and every time I go back to the old layout I
just cringe.

So the three-pane window approach requires much more display area, and
probably wouldn't work wonderfully on low-resolution devices (ie 720x480
or even 1024x600).  So for anybody doing a cellphone port, you may need
to play around with the interface.  But this should be usable even on a
netbook, although not as good as on a device with more pixels.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-20 10:35:27 -08:00
Linus Torvalds
a643e740dc Do proper rounding in interpolated pressure calculations
We do all the pressures in mbar, which has plenty of precision for
interpolated pressures - even when we then do our discrete integration
over many samples.

However, when we calculate those interpolated pressure points, we should
make sure that we round the result correctly, otherwise the consistent
rounding errors (from truncating the FP value into our integer mbar
values) will result in a final pressure that is noticeably off in ugly
ways (ie "end pressure set by hand to 750 mbar, but shown as 748").

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-20 10:27:33 -08:00
Linus Torvalds
bb421a416d Revert "Correctly plot the tank end pressure if it was set manually"
This reverts commit abdee5b1b8.

There's no point in doing random hacks.  Instead, do the intermediate
pressure calculations with proper rounding instead of always truncating
to mbar.  With the math done correctly we have enough precision that the
end result of the pressure interpolation doesn't have the kind of errors
that caused Dirk to try to fix things up later.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-20 10:27:19 -08:00
Linus Torvalds
e8230c9d13 Merge branch 'sacplot' of git://git.hohndel.org/subsurface
* 'sacplot' of git://git.hohndel.org/subsurface:
  Fix error when gaschange event is one second before next sample
2011-11-19 13:22:21 -08:00
Dirk Hohndel
855df669d9 Fix error when gaschange event is one second before next sample
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-19 13:18:10 -08:00
Terrance Stanfield
c9df1f868c Fix the Makefile '-c' location, add XML2CFLAGS
I was getting the following error:

   dive.h:8:25: fatal error: libxml/tree.h: No such file or directory
   compilation terminated.

So I updated the Makefile to fix that error and follow the standard in
the file.

Signed-off-by: Terrance Stanfield <t@hollowcranium.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-19 13:11:22 -08:00
Linus Torvalds
2d26dbc9f7 Merge branch 'sacplot' of git://git.hohndel.org/subsurface
* 'sacplot' of git://git.hohndel.org/subsurface:
  Correctly plot the tank end pressure if it was set manually
2011-11-19 12:59:48 -08:00
Linus Torvalds
c36bf636bd Experimental hard-coded three-pane layout
I'm not happy with it, but it looks good and works better than the
alternatives I've looked at so far.

So why not happy? It's not configurable, and gtk really doesn't do a
great job with the case of notebook widgets that are shrunk to be
smaller than the contents (the cut-off gets ugly, and is outside the
notebook page!)

But committing as a way to keep track of this, and let Dirk use it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-19 12:54:58 -08:00
Dirk Hohndel
abdee5b1b8 Correctly plot the tank end pressure if it was set manually
While printing the last pressure in the calculated sequence may seem more
logical, given that the discrete series will create some amount of error
this simply looks wrong. Instead we pick the end pressure that was
manually set.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-19 12:47:07 -08:00
Linus Torvalds
25e18211ec Merge branch 'sacplot' of git://git.hohndel.org/subsurface
* 'sacplot' of git://git.hohndel.org/subsurface:
  Make pressure plot shading by sac rate consistent
  Improve tank pressure sac coloring
  Be more consistent in our handling of rgb value tables
  Remove redundant linear sample tank pressure data
2011-11-19 12:25:35 -08:00
Dirk Hohndel
e7491d3bf5 Make pressure plot shading by sac rate consistent
Some parts of the existing code used the depth at the time of the sample
to calculate the sac rate - it makes much more sense to use the average
depth. But that requires us to loop over the entries and average the
individual sac rates per segment instead of just using the beginning and
end depth of the multi-segment interval we use for smoothing purposes.

This may seem like a subtle detail, but it does in fact matter when we
plot the synthetic tank pressure values that we create when we have no
tank pressure data in the samples.

Another detail we change here is to not artificially start with a forward
looking segment of the full SAC_WINDOW but instead just start with the
first two data points and then simply let the time window grow until it
hits SAC_WINDOW - at which point it becomes a sliding window.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-19 15:12:30 -05:00
Dirk Hohndel
e1019cafa8 Improve tank pressure sac coloring
This changes the algorithm that picks the sac color to consider
+/- 1 l/min to be the same color (before the color changed every
time you crossed above or below the average which looked silly with
our synthetic "constant sac" values as those are discrete and oscilate
around the average.

This also changes the order in which things are drawn so so that the
pressure plot goes over the depth profile plot (so the red shading of the
dive no longer changes the color of the tank pressure plot).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-19 15:12:29 -05:00
Dirk Hohndel
4e876b3082 Be more consistent in our handling of rgb value tables
Use rgb_t for the sac colors, create a new set_source_rgb_struct function
and use that for the velocity values (in the depth plot) as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-19 15:12:29 -05:00
Dirk Hohndel
b5abdd46f0 Remove redundant linear sample tank pressure data
I've seen at least DivingLog do this. If you manually enter beginning and
end pressure for a tank it will either linearize the samples in between or
offer to simulate a dive (with constant SAC rate). At least the first case
is reasonably easy to detect. We throw out those samples and ensure that
we still have valid beginning and end pressure for that dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-19 15:12:11 -05:00
Linus Torvalds
9f500ec8dc Add the cylinder list to the dive info edit dialog
This way, when you have a new dive that you just imported from your dive
computer, you can just double-click on the dive and fill out all the
relevant information: location, notes, buddies and cylinder info.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-19 11:47:04 -08:00
Linus Torvalds
6f81b3636b Add dive number and date to the dive info edit dialog
It's pretty basic information, and might be hidden behind the dialog
especially on a small screen.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-19 12:23:58 -05:00
Linus Torvalds
7e920844ac Add an 'edit' menu item to the dive info text fields
It just pops up the dive info edit box.  This way you can be in the dive
info tab, and not have to go to the dive list just to double-click on
the dive.

This thing still needs some polish, but it's now usable.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-19 12:06:20 -05:00
Linus Torvalds
1efcf4538b Make double-clicking on the dive list bring up the dive editor
Now that the dive info window is read-only, we need to edit the dives
some other way.  We bring up a dive info edit dialog when you
double-click on the dive list entry for that dive.

I do want to have an "edit" button or keyboard shortcut or something
too, though.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-19 10:11:56 -05:00
Linus Torvalds
842b05415f Make all the normal widgets uneditable and non-focusing
We always keep the focus on the dive list, so that the random gtk focus
handling doesn't suddenly randomly make us edit the combo boxes when the
cursor up/down keys start changing them instead of the dive list.

This means that dive location, notes and buddy/divemaster aren't
editable at all any more, but I'll fix that by making a separate dive
edit popup window.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-18 11:13:02 -02:00
Linus Torvalds
9930e1ecad Merge branch 'sacplot' of git://github.com/dirkhh/subsurface
* 'sacplot' of git://github.com/dirkhh/subsurface:
  Color tank pressure plot based on relative sac
2011-11-18 10:14:37 -02:00
Dirk Hohndel
47a0e0e4be Color tank pressure plot based on relative sac
Linus suggested that instead of using absolute SAC values to base the
color on (which forced us to pre-define which SAC rates are green and
which are red) we should color the tank pressure plot relative to the avg
SAC rate of that dive - which I think makes the coloring much more useful
to spot when on your dive you were doing well and when you were not.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-18 09:57:49 -02:00
Linus Torvalds
160745c545 Merge branch 'sacplot' of git://github.com/dirkhh/subsurface
* 'sacplot' of git://github.com/dirkhh/subsurface:
  Color pressure plot according to current SAC rate
  Fix minor coding standard issues introduced by my last commit
2011-11-17 18:38:46 -02:00
Dirk Hohndel
4cff1f5b90 Color pressure plot according to current SAC rate
Similar to color indicating vertical speed in the profile plot we now use
color in the tank pressure plot to indicate current SAC rate.

We use a 45 sec sliding window to make sure we cover at least two breaths
for each current SAC sample to avoid artificial oscillation based on
breathing rhythm for corputers with high sample resolution.

Not sure about the color coding that I'm using right now - it's green-ish
for SAC rates under 15l/min ~= .55cuft/min and turns yellow and red as you
go higher. That seems to work well for me, but for other divers this may
be way off (or at least not as useful). Maybe this should be configurable?
This is a lot more diver specific than the vertical velocity where there
are clear recommendations based on safety considerations on what is good
and bad.

As a side effect, this removes the color coding that showed you whether
you were looking at pressure data from samples (green) vs. interpolated
pressure data (yellow). Not sure if people really want to see that. We
might be able to indicate this differently (I am thinking different line
width or transparency or something along those line)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-17 18:13:10 -02:00
Linus Torvalds
c486a9ee81 Remove redundant duplicate pressure samples
At least the Suunto pressure transmitter seems to be pretty
"quantisized", and it will send identical samples for a while until the
pressure changes enough.  Then subsurface gives this silly flat line
with a sudden jump downwards, which *could* be you suddenly taking a
deep breath after holding it for a while, but almost certainly it's a
sensor issue.

So just remove successive identical pressure readings.  They aren't
interesting, and subsurface will actually do a good job of interpolating
it according to SAC rate instead.  And they just make the XML look
worse.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-17 12:03:11 -02:00
Linus Torvalds
1268e0d225 Show dives "latest-first" by default
You can still order them by date by just setting the sort order on the
date column, but normally you'd be more interested in the most recent
dives.

I tried to just scroll down to the last ones automatically instead, but
gtk makes that *really* hard to do.  If you do it in the natural place
for it, the scroll bar wll show up later and then cover up the last
entry anyway.  So you'd have to do some crazy expose event thing or
something.  Which may be the right thing to do eventually anyway, but
not worth the pain right now.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-16 16:30:34 -02:00
Linus Torvalds
7930567c27 Show more of the dive location in the dive list
Randomly picked up to 60 characters.  But maybe we should just get rid
of the limit entirely.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-16 16:29:38 -02:00
Dirk Hohndel
4891fa812f Fix minor coding standard issues introduced by my last commit
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-13 15:51:34 -02:00
Linus Torvalds
ede70c03b0 Merge branch 'forlinus' of git://github.com/dirkhh/subsurface
* 'forlinus' of git://github.com/dirkhh/subsurface:
  Make sure SAC and OTU get recalculated after cylinder info was changed
2011-11-13 15:41:05 -02:00
Dirk Hohndel
97a1dd6830 Make sure SAC and OTU get recalculated after cylinder info was changed
Also fixed minor coding style issues (prevent useless code from being
executed).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-13 15:29:07 -02:00
Linus Torvalds
f967d6fb26 Fix the stupid gtk combo box text reset issue for real
Lubomir's solution to fill them with a newline doesn't work.  Well, it
may work on some versions of gtk, but on mine it just results in an ugly
box for the control character '000a' that tries to show the newline.

So this is a third approach: if we reset the text to empty, first set it
to space (to clear it), and then set it to empty.  That seems to work on
at least one version of gtk, and doesn't have the problem with the space
*remaining* when you cut-and-paste something into the combo box.

Let's see if it breaks anything else, but at worst it should be no worse
than the old "set it to space" approach - iow the combo box might
remember the space, but at least not some random data from the previous
dive that it happened to show.

Lovely gtk bugs.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-13 15:17:38 -02:00
Lubomir I. Ivanov
f826470d32 gtk_combo_box_entries and empty text
Passing -1 to gtk_combo_box_set_active, seems not to work as the gtk
documentation explains; there might be a bug in the library or some
special case that is not explained.

could be related to:
  http://mail.gnome.org/archives/gtk-devel-list/2004-March/msg00170.html

passing \n seems to "trick" the cell renderer to clear the entry
completely.  This is a temporary solution.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-13 15:10:14 -02:00
Linus Torvalds
5c2fca2620 Save cylinder O2/He content after the cylinder type description
This changes the save format xml to be a bit more readable: instead of
putting the gasmix first, put the cylinder type (size, workpressure and
description) first, then gasmix, then pressure details.

It makes no difference for machine parsing, but I think it's a lot more
logical for humans that actually look at the xml file.  And we really do
want to make the xml file readable by humans.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-10 21:42:37 -02:00