Use a more standard approach to save preferences on MacOSX
CFPreferences* seems to be the proper way to handle preferences on MacOSX.
This approach also eliminates a problem where the hard coded preferences
path couldn't be read.
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
[ fixed small coding style issues ] Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Linus Torvalds [Sun, 1 Jan 2012 23:12:28 +0000 (15:12 -0800)]
First try at converting user-manual to AsciiDoc
You can do "make doc" in the main directory to create the html version,
and if you want to play around with it, do "make show" in the
Documentation subdirectory to start firefox on the end result.
It's by no means perfect, but it gives somewhat reasonable results, and
this is enough initial work for people to play around with, I think.
NOTE! You need "asciidoc" installed to do this: it's a python program,
so it should be pretty easy even on non-Linux platforms. And on Linux,
most distributions package it, so you just have to do something like
yum install asciidoc
to get it (replace with apt-get/zypper/whatever).
Asciidoc can generate other output too (man-pages, LaTeX, etc), maybe
people want to play with that part too.
Linus Torvalds [Fri, 30 Dec 2011 21:09:17 +0000 (13:09 -0800)]
Move the gasmix cleanups from XML parsing to the generic dive fixup stage
Right now we do certain cylinder info operations only when importing
from an XML file, which is wrong. In particular, we do the "is the
gasmix air" or "what is the standard cylinder name" only at XML read
time, which means that if you import a dive directly from the dive
computer, it won't have the air sanitization or the proper default
cylinder names.
Of course, most dive computers don't actually save enough cylinder
information for us to do the cylinder name lookup anyway, but some do.
And all Nitrox-capable dive computers do have that O2 percentage that
needs cleanup too.
Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Fix incorrect utf-8 in Documentation/user-manual.txt
Not sure, but us-ascii might have been intended.
Signed-off-by: Cristian Ionescu-Idbohrn <cii@axis.com>
[ And even if you do want to use utf8, you should use it correctly, not
with this "pick random character" approach - Linus ] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Jacco van Koll [Fri, 23 Dec 2011 18:43:58 +0000 (19:43 +0100)]
Version 0.0.6 of user manual
Corrected some typo's
Modified chapter 12. Importing dives from JDivelogAdded chapter 13.
Importing dives from Suunto Divemanager 3.*
Added Appendix B: very tiny example script for importing Suunto
Divemanager 3.* xml files
Signed-off-by: Jacco van Koll <jacco.van.koll@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Linus Torvalds [Mon, 19 Dec 2011 02:30:31 +0000 (18:30 -0800)]
parse-xml: read the file into memory separately
Using xmlParseFile() was simple, but I'm planning on extending the file
parsing past just XML, since we want to be able to import other formats
too. And quite frankly, that means that we'll want to read the file
into memory to look at it before we start parsing it.
We could decide do it by file extensions too, and I'll look at that
approach as well, but regardless of how we do things it's almost
certainly a good idea to do the file access in one place. The XML
parsing might as well happen from a memory buffer instead anyway.
Miika Turkia [Sun, 18 Dec 2011 12:36:28 +0000 (14:36 +0200)]
Multiple cylinder support for JDiveLog import
Support for multiple cylinders and gas change events when Importing
JDiveLog logs to Subsurface. This is tested with manually crafted data
and not real data (originating from dive computer).
NOTE: Subsurface does not handle importing multiple cylinders
correctly but imports only the first cylinder. However, manually
converting data to a file and opening that in Subsurface works
correctly.
(xsltproc jdivelog2subsurface.xslt jdivelog-gas.jlb > gas.xml)
Some minor tweaking on importing JDiveLog specific fields to notes
fields in Subsurface is also included.
Linus Torvalds [Thu, 15 Dec 2011 02:19:48 +0000 (18:19 -0800)]
Merge branch 'forlinus' of git://git.hohndel.org/subsurface
* 'forlinus' of git://git.hohndel.org/subsurface:
Improve Makefile for MacOS
Add reasonable default device names for divecomputer import
More intuitive label for "not saving" when exiting
Dirk Hohndel [Wed, 14 Dec 2011 19:22:12 +0000 (11:22 -0800)]
Improve Makefile for MacOS
Some macs appear to need "-framework CoreFoundation" added to the linking
step, others (which appear to have the exact same OS and tools installed),
don't. But as it doesn't appeart to hurt, I unconditionally add this.
Switched to using pkgconfig to find libdivecomputer on the Mac.
Tried to clean up the Makefile a bit
Signed-off-by: Dirk Hohndel <dirk@hohndel.org> Acked-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Dirk Hohndel [Wed, 14 Dec 2011 04:34:56 +0000 (20:34 -0800)]
Add reasonable default device names for divecomputer import
So far we hard coded /dev/ttyUSB0 - which is a good starting point in
Linux but not so useful on Windows or MacOS. This was now moved into one
of our OS helper functions with (somewhat) reasonable defaults.
Dirk Hohndel [Tue, 13 Dec 2011 22:34:42 +0000 (14:34 -0800)]
More intuitive label for "not saving" when exiting
Right now the options are "Save" and "Cancel". I wrote that code and it
always bugged me - "Cancel" could mean that I want to cancel the the whole
operation, i.e. that I don't want to quit after all. Showing "Save" and
"No" seems much more logical.
Linus Torvalds [Mon, 12 Dec 2011 19:20:36 +0000 (11:20 -0800)]
Merge branch 'forlinus' of git://git.hohndel.org/subsurface
* 'forlinus' of git://git.hohndel.org/subsurface:
Small improvement to plot info debugging code
Add three more trimix test dives
Make test dive 15 a bit more useful
Two test dives I added a couple of months ago
Add libxslt to Windows packaging file
Linus Torvalds [Mon, 12 Dec 2011 17:24:47 +0000 (09:24 -0800)]
Pack the star rating on a line of its own
Packing it next to the divemaster/buddy information may work great on a
big screen with lots of pixes, but it makes the minimum window size way
wide for a small screen. So don't do it.
Linus Torvalds [Mon, 12 Dec 2011 17:20:22 +0000 (09:20 -0800)]
divelist: show/sort nitrox dive oxygen percentage as a range
If you are diving multiple nitrox cylinders, we now show them as a range
instead of just the max. We'll still sort by max O2 (and for the same
max, by min O2).
So now with trimix dives, we'll show the bottom gas (we assume that
"highest He percentage" is that bottom gas), for nitrox dives we'll show
the range of Oxygen percentage, and for all-air dives we'll show just
"air".
For simple nitrox dives (only a single mix), we'll obviously show just
that single percentage. This should hopefully conclude the whole "show
multiple cylinders in dive list" mess.
Linus Torvalds [Mon, 12 Dec 2011 05:28:18 +0000 (21:28 -0800)]
Make the dive gas record the single highest mix
.. using the regular sorting rules: sort by Helium content first, Oxygen
content second. Air always sorts last (even behind the theoretical
hypoxic Nitrox that nobody sane would use).
This is what Don Kinney implies would be the natural thing for a trimix
diver.
Linus Torvalds [Sun, 11 Dec 2011 22:38:58 +0000 (14:38 -0800)]
Add capability of custom sorts to divelist columns
.. and use this for the nitrox column, which can now be more complex
than just a single number.
The rule for the "nitrox" column is now:
- we look up the highest Oxygen and Helium mix for the dive
(Note: we look them up independently, so if you have a EAN50 deco
bottle, and a 20% Helium low-oxygen bottle for the deep portion, then
we'll consider the dive to be a "50% Oxygen, 20% Helium" dive, even
though you obviously never used that combination at the same time)
- we sort by Helium first, Oxygen second. So a dive with a 10% Helium
mix is considered to be "stronger" than a 50% Nitrox mix.
- If Helium is non-zero, we show "O2/He", otherwise we show just "O2"
(or "air"). So "21/20" means "21% oxygen, 20% Helium", while "40"
means "Ean 40".
- I got rid of the decimals. We save them, and you can see them in the
dive equipment details, but for the dive list we just use rounded
percentages.
Let's see how many bugs I introduced. I don't actually have any trimix
dives, but I edited a few for (very limited) testing.
Linus Torvalds [Sun, 11 Dec 2011 20:03:55 +0000 (12:03 -0800)]
Add the "Common European Cylinders" as per Henrik
This is Henrik's list of common metric sized cylinders, although my
experience differs from this one. In Cyprus, I was diving double 12L
cylinders, but they were 200 bar, not the 232 bar ones Henrik has on the
list.
Also, I really think we should just have a checkbox for "double" instead
of naming them explicitly like this. Henrik does have the 12L 200 bar
ones in his singles list.
But as a stop-gap, I'm just taking the values from Henrik's patch, but
converted to the new cleaned-up reference tank model setup.
Based-on-patch-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Linus Torvalds [Sun, 11 Dec 2011 19:54:17 +0000 (11:54 -0800)]
Clean up reference tank information table
This makes the reference tanks ("struct tank_info") use a saner format
which specifies explicitly whether the size is in ml or cubic feet, and
whether the pressure is in psi or bar.
So instead of having magic rules ("size is in cuft if < 1000, otherwise
mliter"), just set the size explicitly:
and then the code can just convert to standard measurements without any
odd rules, and the initialization table becomes self-explanatory too.
This is in preparation for doing the metric tanks with pressure: Henrik
Aronsen sent a really ugly patch using the previous setup, I just
couldn't stand the additional hackery.
Linus Torvalds [Sun, 11 Dec 2011 19:40:17 +0000 (11:40 -0800)]
Make the cylinder table columns unsortable
They were never intended to be sortable, but using common code with the
dive list picked up that "sort by index" thing by mistake.
If we really want to be able to sort cylinders by O2 percentage (which
really doesn't seem to make much sense, considering that you usually
have just one or two cylinders) we will need to also handle the case of
editing the (differently sorted) cylinder table. Which we don't do now.
Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Linus Torvalds [Sun, 11 Dec 2011 19:09:37 +0000 (11:09 -0800)]
Allow editing of Helium values in cylinder info
Henrik Aronsen points out that we've not made it possible to edit the He
percentages for trimix diving. It's easy enough to do, I just didn't
have any dives that needed it myself. So here goes.
Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Linus Torvalds [Fri, 9 Dec 2011 17:52:59 +0000 (09:52 -0800)]
Use common helper function for the "no cylinder info" case
Miika fixed the statistics code that didn't properly check for the "no
cylinder info" case - this cleans it up and just uses the helper
function in equipment.c.
Rename the helper to be slightly better named while at it.
Dirk Hohndel [Wed, 7 Dec 2011 19:58:16 +0000 (11:58 -0800)]
Add typical 0 to 5 star rating for dives
This works ok-ish, but doesn't allow us to click on the stars and edit
them in the divelist, which a user might expect to be able to do - in
most "star rating UIs" you simply click on the n-th star to set that
rating. Here you need to edit the dive and pick the rating from a drop
down menu.
Minor oddity: you can actually (if you force it) write anything you want
into the star rating. But anything that isn't one of the predefined
strings simply results in a zero star rating.
Overall the UI feels a bit... forced. But I think this is quite useful
anyway.
Linus Torvalds [Tue, 6 Dec 2011 21:00:01 +0000 (13:00 -0800)]
Add shorthand actions for showing just one of the panes
Currently just tied to F1-F4 (for divelist, profile, info, and "all
three" respectively), which is just crazy. But using "ctrl-P" for
"Profile" isn't sane either, that's the standard printer keyboard
shortcut. So what would be good keyboard shortcuts for these things?
I also wonder how I can get gtk to shut up about the fact that a pane
becomes too small for the contents of that pane? We very much want to do
that, and it's very intentional. Gtk does the right thing apart from
the whining (and apart from the visually ugly part of a widget that
doesn't fit, but making it pretty doesn't really seem possible).
The profile colors were defined all over the place, so I put them all in one spot. I'm unsure if this is the best solution to that problem, but I guess it's a step in the right direction.
Signed-Off-By: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Linus Torvalds [Sun, 27 Nov 2011 20:07:49 +0000 (12:07 -0800)]
Merge branch 'windows-fixes' of git://git.hohndel.org/subsurface
* 'windows-fixes' of git://git.hohndel.org/subsurface:
fix mingw-win32 specific warnings in libdivecomputer.c
Fix mingw-make.sh to find correct xslt-config
Dirk Hohndel [Sun, 27 Nov 2011 17:10:37 +0000 (09:10 -0800)]
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>
Linus Torvalds [Sat, 26 Nov 2011 05:51:34 +0000 (21:51 -0800)]
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
Dirk Hohndel [Sat, 26 Nov 2011 04:09:01 +0000 (20:09 -0800)]
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.
Dirk Hohndel [Sat, 26 Nov 2011 03:48:53 +0000 (19:48 -0800)]
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.
Dirk Hohndel [Thu, 24 Nov 2011 06:56:57 +0000 (22:56 -0800)]
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.
Dirk Hohndel [Mon, 21 Nov 2011 21:23:13 +0000 (13:23 -0800)]
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).
Miika Turkia [Wed, 16 Nov 2011 05:12:44 +0000 (07:12 +0200)]
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.
Miika Turkia [Wed, 16 Nov 2011 05:12:43 +0000 (07:12 +0200)]
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).
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.
Linus Torvalds [Sun, 20 Nov 2011 18:27:33 +0000 (10:27 -0800)]
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").
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.
Linus Torvalds [Sat, 19 Nov 2011 20:54:58 +0000 (12:54 -0800)]
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.