]> git.tdb.fi Git - ext/subsurface.git/log
ext/subsurface.git
12 years agoSeparate out the UI from the program logic
Dirk Hohndel [Tue, 20 Sep 2011 19:40:34 +0000 (12:40 -0700)]
Separate out the UI from the program logic

The following are UI toolkit specific:
gtk-gui.c   - overall layout, main window of the UI
divelist.c  - list of dives subsurface maintains
equipment.c - equipment / tank information for each dive
info.c      - detailed dive info
print.c     - printing

The rest is independent of the UI:
main.c i    - program frame
dive.c i    - creates and maintaines the internal dive list structure
libdivecomputer.c
uemis.c
parse-xml.c
save-xml.c  - interface with dive computers and the XML files
profile.c   - creates the data for the profile and draws it using cairo

This commit should contain NO functional changes, just moving code around
and a couple of minor abstractions.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
12 years agoMake the divelist font configurable
Linus Torvalds [Tue, 20 Sep 2011 18:24:15 +0000 (11:24 -0700)]
Make the divelist font configurable

Instead of the hardcoding to "Sans 8", allow people to set it in the
preferences.

Also, make the unit choice be a frame in the preferences dialog instead.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoMerge git://github.com/sirowain/subsurface
Linus Torvalds [Tue, 20 Sep 2011 17:12:24 +0000 (10:12 -0700)]
Merge git://github.com/sirowain/subsurface

* git://github.com/sirowain/subsurface:
  Fix Segmentation fault when trying to print an empty plot.
  Provide an icon for subsurface.
  Added a comment about libusb dependency in Makefile.

12 years agoMerge branch 'for-linus' of git://github.com/dirkhh/subsurface
Linus Torvalds [Tue, 20 Sep 2011 17:08:27 +0000 (10:08 -0700)]
Merge branch 'for-linus' of git://github.com/dirkhh/subsurface

* 'for-linus' of git://github.com/dirkhh/subsurface:
  Attempt to get the location column to resize in a sensible way
  Minor tweaks to column headers

[ Fixed up minor semantic merge conflict due to the change to make
  'dive_list' internal to divelist.c ]

12 years agoMake 'struct DiveList' entirely internal to divelist.c
Linus Torvalds [Tue, 20 Sep 2011 17:06:24 +0000 (10:06 -0700)]
Make 'struct DiveList' entirely internal to divelist.c

Passing it around is just annoying, and we only ever have one.  Let's
not burden all the users with the silly thing.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAdd "Apply"/"Cancel" buttons to dive equipment page
Linus Torvalds [Tue, 20 Sep 2011 16:53:45 +0000 (09:53 -0700)]
Add "Apply"/"Cancel" buttons to dive equipment page

It's too damn easy to make mistakes and not even notice them (odd gtk
widget selection and keyboard input), or just start editing a cylinder
thing and realize it was wrong.

So instead of always saving the equipment information implicitly, add
explicit "Apply" and "Cancel" buttons that save the information (or
re-load it from the dive data structure)

So now you need to press an extra button for your changes to *really*
take effect.  It can be a bit annoying, but it's better than the silent
accidental equipment change that could happen before.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAttempt to get the location column to resize in a sensible way
Dirk Hohndel [Tue, 20 Sep 2011 16:57:38 +0000 (09:57 -0700)]
Attempt to get the location column to resize in a sensible way

Previously the SAC column was the one that expanded which is silly

We also used to cut the location off at 16 characters

Now we try to make the location the one that expands and allow up to 40
characters, but there's something broken, still. If you manually shrink
the location column to its minimum size then subsequently resizing the
window gets the desired behavior. But if you don't manually resize the
location column it doesn't shrink correctly for windows that are smaller
than the space we need for all columns to fully display (instead we get a
horizontal scrollbar)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
12 years agoMinor tweaks to column headers
Dirk Hohndel [Tue, 20 Sep 2011 16:56:46 +0000 (09:56 -0700)]
Minor tweaks to column headers

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
12 years agoMake a separate "Log" menu
Linus Torvalds [Tue, 20 Sep 2011 16:37:37 +0000 (09:37 -0700)]
Make a separate "Log" menu

Instead o fhaving everything in the "File" menu, make a separate menu
for things that are very much specific about divelogs, rather than
"generic" things like open/save/import.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoFix Segmentation fault when trying to print an empty plot.
Riccardo Albertini [Tue, 20 Sep 2011 12:44:45 +0000 (14:44 +0200)]
Fix Segmentation fault when trying to print an empty plot.

When printing an empty plot, the function was missing nullability check for 'current_dive'. Now the print of an empty plot results with an empty blank page.
A better solution could be making unsensitive the Print entry in the menu, until a plot is loaded.

Signed-off-by: Riccardo Albertini <ssirowain@gmail.com>
12 years agoProvide an icon for subsurface.
Riccardo Albertini [Tue, 20 Sep 2011 10:32:40 +0000 (12:32 +0200)]
Provide an icon for subsurface.

I designed a simple blue icon for subsurface with a diver in the middle.
As suggested by Dirk Hohndel, I added the surface line above diver's head,
so that now the icon reflects better the new application name.

Signed-off-by: Riccardo Albertini <ssirowain@gmail.com>
12 years agoAdded a comment about libusb dependency in Makefile.
Riccardo Albertini [Tue, 20 Sep 2011 10:22:45 +0000 (12:22 +0200)]
Added a comment about libusb dependency in Makefile.

Due to libdivecomputer's dependency, can be necessary to add libusb to pkg-config in order to compile,
so I exported the pkg-config line in the subsurface target to LIBS variable, and added a comment about libusb.

Signed-off-by: Riccardo Albertini <ssirowain@gmail.com>
12 years agoReinstate the main window title
Linus Torvalds [Tue, 20 Sep 2011 05:09:47 +0000 (22:09 -0700)]
Reinstate the main window title

It got removed by some of my overly aggressive cleanup in commit
fefcbf125e89 ("Remove dive info frame") because the dive info frame
initialization also initialized the main window title..

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoSwitch the dive list and dive profile panes around
Linus Torvalds [Tue, 20 Sep 2011 05:08:43 +0000 (22:08 -0700)]
Switch the dive list and dive profile panes around

It looks better this way, I think.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoHacky hard-coded font for dive list entries
Linus Torvalds [Tue, 20 Sep 2011 05:01:55 +0000 (22:01 -0700)]
Hacky hard-coded font for dive list entries

This really is too wrong for words, but I do think the dive list may
look better with a smaller font.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoMake helper function for creating TreeView columns in the dive list
Linus Torvalds [Tue, 20 Sep 2011 04:39:15 +0000 (21:39 -0700)]
Make helper function for creating TreeView columns in the dive list

Let's not repeat the boiler-plate code more than necessary.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAdd cylinder description to dive list
Linus Torvalds [Tue, 20 Sep 2011 03:06:54 +0000 (20:06 -0700)]
Add cylinder description to dive list

And I *really* would want to make the dive list be a ComboBox or
something like that, rather than a ListView.  I need to really
understand those things, though.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoTurn the rest of the duplicate string fields to use render functions
Linus Torvalds [Tue, 20 Sep 2011 02:13:36 +0000 (19:13 -0700)]
Turn the rest of the duplicate string fields to use render functions

So instead of having a depth field (in mm) for sorting, and the text
field that contains the same thing in text, we now have all the fields
we use in "native" format, and we just render them as text dynamically.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoUse renderer function for divelist depth field too
Linus Torvalds [Tue, 20 Sep 2011 01:52:23 +0000 (18:52 -0700)]
Use renderer function for divelist depth field too

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoUse a renderer function on the date field
Linus Torvalds [Tue, 20 Sep 2011 01:44:47 +0000 (18:44 -0700)]
Use a renderer function on the date field

Instead of creatign an extra column containing the date text, use a
renderer function to create the text dynamically.

Just the date right now, but we'll do them all this way.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoOops, fix typo. EAN, not EAD
Linus Torvalds [Mon, 19 Sep 2011 23:58:46 +0000 (16:58 -0700)]
Oops, fix typo. EAN, not EAD

Typo turned EAN (Enriched Air Nitrox) to EAD.  Which does mean something
too, just to confuse people - but while it's still nitrox-related, it's
entirely the wrong thing (Equivalent Air Depth).  I don't think anybody
would ever care to see *that*. With computers, why would you care?

Anyway, Dirk noticed it, and suggested I just use O2% instead.  It's not
like EAN is all that readable either.

Reported-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoUpdate the divelist when dive info changes
Linus Torvalds [Mon, 19 Sep 2011 23:41:56 +0000 (16:41 -0700)]
Update the divelist when dive info changes

This flushes the dive changes to the dive list, the way the old dive
info frame would update as you update dive fields.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAdd air usage calculations to dive list
Linus Torvalds [Mon, 19 Sep 2011 23:11:38 +0000 (16:11 -0700)]
Add air usage calculations to dive list

Hey, now you can sort your dives by how good your SAC is.  Which sounds
more useful than it probably actually is.  But maybe you can see
patterns in what makes your SAC suck..

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAdd location to divelist too
Linus Torvalds [Mon, 19 Sep 2011 22:52:42 +0000 (15:52 -0700)]
Add location to divelist too

Sure, it's visible elsewhere, but this way you can search and sort for
it, and see several entries at once.  So again, having it visible in the
dive list is a good thing.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoClean up divelist generation some more
Linus Torvalds [Mon, 19 Sep 2011 22:39:29 +0000 (15:39 -0700)]
Clean up divelist generation some more

.. and make the date string much more readable, now that we aren't
actually size-constrained any more.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoStart filling in temperature and nitrox data in dive list
Linus Torvalds [Mon, 19 Sep 2011 20:32:10 +0000 (13:32 -0700)]
Start filling in temperature and nitrox data in dive list

Still more to go, but it's slowly fleshing out..

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAdd temp/nitrox/sac entries to divelist
Linus Torvalds [Mon, 19 Sep 2011 19:56:37 +0000 (12:56 -0700)]
Add temp/nitrox/sac entries to divelist

This doesn't really fill them, it just adds them to the possible
entries.  I'll get to it later.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoMake the pane split be vertical rather than horizontal
Linus Torvalds [Mon, 19 Sep 2011 19:46:22 +0000 (12:46 -0700)]
Make the pane split be vertical rather than horizontal

Ok, this makes that dive list look empty and ugly, but as mentioned, we
really should start filling it with all the useful information that we
can sort by, like temperature and air use.

And even stuff that might not make sense to sort by (would you want to
sort by cylinder size or name? Or by nitrox percentage) could still be
*shown* in the list fairly naturally.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoRemove dive info frame
Linus Torvalds [Mon, 19 Sep 2011 19:39:35 +0000 (12:39 -0700)]
Remove dive info frame

It has always been problematic, and I've been moving things in and out
of it.

And it just isn't a very powerful widget.  You can't *do* anything with
it.  The information it shows you may be useful, but the core stuff
already shows up in the dive list.

And the dive list is actually a much superior widget over that static
dive info frame.  The information that shows up in the dive list can be
sorted by column, for example.

So when we show temperatures or SAC numbers in the dive info frame,
that's actually a very bad place to show them: we would be much better
off showing it in the dive list, and then we could sort by SAC or by
temperature.

In other words: just remove the thing.  Instead, plan to extend the dive
list to contain all the information.  That will probably mean that we
need to change the current pane widget to be a vertical pane, rather
than a horizontal one, but what's wrong with that?

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoMake the divelist column naming clearer
Linus Torvalds [Mon, 19 Sep 2011 19:25:16 +0000 (12:25 -0700)]
Make the divelist column naming clearer

Currently we use random hard-coded integers, and it's not always clear
what is going on.  Make it much more explicit with an enumeration of the
different divelist columns.

And change the column order to make it more logical, and make sure we
actually catch all uses while at it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAttempt to smooth out the velocity readings
Dirk Hohndel [Sat, 17 Sep 2011 04:45:32 +0000 (21:45 -0700)]
Attempt to smooth out the velocity readings

If the velocity is slower than FAST then we look back up to 30 seconds and
calculate the velocity for the past 30 seconds instead.

For the first version I'm not doing the average of the changes but simply
the change from beginning to end.

The alternative would be to do another triangle smoothing or something
like that - but as we don't know how many samples we have in the 30 second
window, it's a little harder here.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
12 years agoFlip tank pressure graph to show the RIGHT way
Dirk Hohndel [Sat, 17 Sep 2011 03:53:05 +0000 (20:53 -0700)]
Flip tank pressure graph to show the RIGHT way

This annoyed me from the first moment Linus added the tank pressure graph.
As the pressure goes down, the graph needs to go down. Seriously.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
12 years agoStop plotting the gas / consumption information into the profile
Dirk Hohndel [Sat, 17 Sep 2011 03:44:40 +0000 (20:44 -0700)]
Stop plotting the gas / consumption information into the profile

And move the code into info.c where it now belongs

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
12 years agoMake handling of empty airconsumption string consistent
Dirk Hohndel [Sat, 17 Sep 2011 03:20:28 +0000 (20:20 -0700)]
Make handling of empty airconsumption string consistent

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
12 years agoMore fixes to positioning of gas / consumption information in info_frame
Dirk Hohndel [Sat, 17 Sep 2011 03:13:57 +0000 (20:13 -0700)]
More fixes to positioning of gas / consumption information in info_frame

This gives the airconsumption label a fixed size and changes its alignment
so it is anchored to the right.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
12 years agoStop tank / gas / consumption info from changing info_frame size
Dirk Hohndel [Fri, 16 Sep 2011 23:29:43 +0000 (16:29 -0700)]
Stop tank / gas / consumption info from changing info_frame size

Simply set it to an empty string with TWO lines when there is nothing to
display

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
12 years agoIndicate vertical velocity through color
Dirk Hohndel [Fri, 16 Sep 2011 23:22:00 +0000 (16:22 -0700)]
Indicate vertical velocity through color

So far Linus has hated all of my attempts to visualize vertical velocity
through color. This time I'm trying something dramatically new: there is
no PURPLE involved. Maybe that will convince him of the value.

We simply calculate the vertical velocity for the current plot segment
(last sample point to this sample point - in this version even without
divisions by zero) and assign a label based on the rate of change. These
labels are translated through a predefined table into colors:

Dark green is +/- 5ft/min (stable)
Light green is descents up to 30ft/min and ascents up to 15ft/min
Yellow is descents up to 60ft/min and ascents up to 30ft/min
Orange is descents up to 100ft/min and ascents up to 60ft/min
Red is outside of those ranges - you are most likely in danger

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
12 years agoShow tank / nitrox / air consumption information in the info_frame
Dirk Hohndel [Fri, 16 Sep 2011 22:45:14 +0000 (15:45 -0700)]
Show tank / nitrox / air consumption information in the info_frame

Even though we go down to an 8pt font the info_frame changes size when the
air info is added. I don't like this but want to see how Linus would like
this resolved before going overboard.

Minor tweaks to the formating (we don't need two decimals when printing
the liters of air consumed).

This patch does NOT remove the plot of the air information in the profile
graph. I think we want to remove that once we like the text where it is,
but I wanted to do one thing at a time.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
12 years agoDirk can't count to ten
Linus Torvalds [Fri, 16 Sep 2011 21:21:30 +0000 (14:21 -0700)]
Dirk can't count to ten

That's ok, Dirk. I've got your back.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoRemove dive number from frame label
Dirk Hohndel [Fri, 16 Sep 2011 21:12:37 +0000 (14:12 -0700)]
Remove dive number from frame label

It's now in the window title - no point in having it twice.
Also added a little "Dive #xx - " template. The old "##. " was a bit too
minimalistic for my liking.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
12 years agoPut the dive number and location in the window title bar
Linus Torvalds [Fri, 16 Sep 2011 19:15:46 +0000 (12:15 -0700)]
Put the dive number and location in the window title bar

I suspect the "info" area is better used for actual values, so move the
dive location into the window title instead (using date if no location
info), and title the info frame with date and time.

This just means that the date/time gets removed from inside the frame:
we may want to put air consumption info in there instead?

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoTweak temperature plot to look better for small fluctuations
Dirk Hohndel [Fri, 16 Sep 2011 18:35:04 +0000 (11:35 -0700)]
Tweak temperature plot to look better for small fluctuations

If the temperature is in a very narrow range the existing code visually
exaggerated the fluctuations. This tries to dampen that effect a bit.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
12 years agoTweak plot scaling a bit
Linus Torvalds [Fri, 16 Sep 2011 17:28:40 +0000 (10:28 -0700)]
Tweak plot scaling a bit

Change the duration max rounding as noted by Dirk, and move the air
consumption down further towards the bottom right corner.  In
particular, I make the text positions not scale with the window size,
purely by the size of the text.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoMinor corrections to printing of the last temperature
Dirk Hohndel [Fri, 16 Sep 2011 16:51:38 +0000 (09:51 -0700)]
Minor corrections to printing of the last temperature

 - the time stamp where we printed the last temp was wrong
 - we really shouldn't check mK for being identical - especially on dive
   computers that store a lot of samples

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoUse plot_info for final remaining temperature and pressure data plots too
Linus Torvalds [Fri, 16 Sep 2011 16:23:54 +0000 (09:23 -0700)]
Use plot_info for final remaining temperature and pressure data plots too

Ok, this is pretty much it now.  Instead of having various random checks
for "is the time of the sample past the end of the dive" hacks, we not
plot all graphs from the cleaned-up plot_info structure instead of the
raw samples.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoPlot pressure data based on 'struct plot_info' rather than raw dive data
Linus Torvalds [Fri, 16 Sep 2011 16:10:13 +0000 (09:10 -0700)]
Plot pressure data based on 'struct plot_info' rather than raw dive data

Further movement to using the sanitized and cleaned-up plot info rather
than the raw data.

The raw dive data contains samples from the end of the dive that we
don't want to drop, but that we also don't want to actually use for
plotting the dive.  So the eventual end goal here is to not ever use the
raw dive samples directly for plotting, but use the diveplot data that
we have analyzed for min/max (properly ignoring final entries) etc.

There's still some data that we take from the samples when plotting, but
it's getting rarer.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoDo min/max pressure and temperature based on the non-surface data
Linus Torvalds [Fri, 16 Sep 2011 15:47:13 +0000 (08:47 -0700)]
Do min/max pressure and temperature based on the non-surface data

Do the min/max calculations only *after* we have removed the extra
surface events at the end.

The Uemis data in particular has a lot of surface events after the dive,
and we don't really want to take them into account since we won't be
plotting them anyway.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoPlot temperature info using 'struct plot_info' rather than the raw dive samples
Linus Torvalds [Fri, 16 Sep 2011 15:42:27 +0000 (08:42 -0700)]
Plot temperature info using 'struct plot_info' rather than the raw dive samples

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoStart using 'plot_info' more for dive-time limits
Linus Torvalds [Fri, 16 Sep 2011 15:20:06 +0000 (08:20 -0700)]
Start using 'plot_info' more for dive-time limits

.. I'll want to move pressure limit calculations into the 'plot_info',
so that we can do several passes of analysis and change dive limits etc
without having to actually modify the dive data itself (or add new
fields to 'struct dive' just for plotting).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoDo libdivecomputer imports in a separate thread
Linus Torvalds [Fri, 16 Sep 2011 05:58:02 +0000 (22:58 -0700)]
Do libdivecomputer imports in a separate thread

This is the hackiest thing ever, unless you count the previous code that
was even hackier (and just called the gtk main routine at random
places).

The libdivecomputer library is not really set up to be part of the gtk
main loop, and cannot afford (for example) to have lots of mainloop
events while it's parsing.  Some dive computers are very timing
sensitive for the communication.

So just start a thread for doing the libdivecomputer stuff, and just
continually call the gtk main loop while that thread is running.  I'm
sure we could actually use some gtk signalling thing to make the thread
exit do the right thing, but instead we just poll the status every
100ms.

I did say it was hacky.  It does seem to work, though.  No more
temporary graying out of the windows when they don't react in a timely
manner because libdivecomputer does some blocking operation.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoSupport gps coordinates for the location info
Linus Torvalds [Fri, 16 Sep 2011 01:16:07 +0000 (18:16 -0700)]
Support gps coordinates for the location info

Sadly, no way to show them yet.  But it would be nice to let people
enter them (and it would be doubly nice to have a dive computer that
does it at the surface), and then perhaps just do the "point browser at
google maps" thing.

Saving/parsing tested by hand-feeding the location of Enenui (Molokini
Crater) from google maps by hand into my divelog.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoRename the project 'subsurface'
Linus Torvalds [Thu, 15 Sep 2011 16:43:14 +0000 (09:43 -0700)]
Rename the project 'subsurface'

I never really liked 'diveclog' as a name - it's not like the C part is
all that important.  And while I could try to just make up another slang
word for despicable person (in the tradition of naming all my projects
after myself), I just can't see it.

So let's just call it "subsurface".

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoPrint the end temperature of the dive
Dirk Hohndel [Thu, 15 Sep 2011 16:10:08 +0000 (09:10 -0700)]
Print the end temperature of the dive

Currently we print the temperature every five minutes. Especially with
dive computers that keep rather frequent temperature samples that means
that we have one more interesting data point that we don't label: the
surface temperature at the end of the dive.

This patch adds some logic to try to print the last temperature sample
that was recorded before the dive ended - unless that same value has
already been printed (to avoid silly duplications on dive computers with
less frequent sampling)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoDon't draw temperature plot past the end of the dive
Dirk Hohndel [Thu, 15 Sep 2011 16:09:25 +0000 (09:09 -0700)]
Don't draw temperature plot past the end of the dive

Just like we end depth and tank pressure plots once we are on the surface
(this is relevant for dive computers like the uemis Zurich that keep
recording samples after the end of the dive)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoFix uemis depth calculation in the uemis XML importer
Dirk Hohndel [Thu, 15 Sep 2011 15:15:25 +0000 (08:15 -0700)]
Fix uemis depth calculation in the uemis XML importer

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoFix depth calculations in SDA import
Dirk Hohndel [Thu, 15 Sep 2011 15:12:51 +0000 (08:12 -0700)]
Fix depth calculations in SDA import

stole and fixed Linus' code in the uemis XML importer

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoFix incorrect data dereference
Dirk Hohndel [Thu, 15 Sep 2011 14:08:57 +0000 (07:08 -0700)]
Fix incorrect data dereference

This caused incorrect "missing Dive100" messages when importing SDA file
from the uemis Zurich.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoFirst pass to parse uemis Zurich '.SDA' files
Dirk Hohndel [Thu, 15 Sep 2011 04:00:49 +0000 (21:00 -0700)]
First pass to parse uemis Zurich '.SDA' files

This is missing a ton of the information in the .SDA files It only
parses the divelog.SDA file, not the dive.SDA file It ignores the
information on the gas(es) used and all the data on the tanks.

It still draws some strange artefacts at the end of the dive

But it correctly hooks into the import dialogue, it gives you a file
select box (somewhere, I'm sure, a gtk developer cries quietly) and then
parses enough of this file to serve as a proof of concept.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoFlush any pending changes at notebook 'switch-page' time
Linus Torvalds [Wed, 14 Sep 2011 23:05:37 +0000 (16:05 -0700)]
Flush any pending changes at notebook 'switch-page' time

Dirk points out that equipment changes (cylinder size etc) do not cause
a proper repaint of the dive profile with new SAC information.  The
reason? We haven't flushed the changes when the notebook changes from
the equipment page to the dive profile page.

Reported-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoQuick fix to hardcode device name only once
Dirk Hohndel [Wed, 14 Sep 2011 18:25:15 +0000 (11:25 -0700)]
Quick fix to hardcode device name only once

Linus clearly wanted to make SURE that we use /dev/ttyUSB0

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoI'm trying to figure something out that prints reasonably..
Linus Torvalds [Wed, 14 Sep 2011 03:39:43 +0000 (20:39 -0700)]
I'm trying to figure something out that prints reasonably..

I'll get there.  Shrink it down a bit, start adding notes and location,
and maybe put three per page. That might work.

.. or maybe I should just take a look at how others have done this.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoMake the printout look different
Linus Torvalds [Wed, 14 Sep 2011 02:49:48 +0000 (19:49 -0700)]
Make the printout look different

Not *better* mint you. Just different.

I suck at graphs.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAdd the capability to print a dive profile
Linus Torvalds [Tue, 13 Sep 2011 23:02:42 +0000 (16:02 -0700)]
Add the capability to print a dive profile

Ok, this is the ugliest f*&$ing printout I have ever seen in my life,
but think of it as a "the concept of printing works" commit, and you'll
be able to hold your lunch down and not gouge out your eyeballs with a
spoon.  Maybe.

I'm just doing the cairo display as-is for the printout, which is a
seriously bad idea.  I need to not try to do colors etc, and instead of
having white lines on a black background I just need to make thelines be
black on white paper.

But that would involve actually changing the current "plot()" routine,
which is against the point of the exercise right now.  This really is
just a demonstration of how to add printing capabilities.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAdd divemaster/buddy field and text entry
Linus Torvalds [Tue, 13 Sep 2011 21:58:06 +0000 (14:58 -0700)]
Add divemaster/buddy field and text entry

I have it in some of my notes, and Dirk seems to fill that in too, so
let's just show it, save it, and allow editing of it..

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoSeparate the notion of creating the cylinder widgets from showing them
Linus Torvalds [Tue, 13 Sep 2011 20:50:03 +0000 (13:50 -0700)]
Separate the notion of creating the cylinder widgets from showing them

Now we always create the MAX_CYLINDER sets of cylinder widgets.  But we
don't actually pack them into the frame - that's a separate phase.

Right now we still do the stupid "always just pack two cylinders" thing,
but the idea is that we can pack just as many as the dive needs on a
per-dive basis.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoMake multiple cylinders actually work
Linus Torvalds [Tue, 13 Sep 2011 20:25:06 +0000 (13:25 -0700)]
Make multiple cylinders actually work

This just always shows two cylinders, which is obviously bogus, but it's
a good test-case for the multi-cylinder case.

I need to figure out how to dynamically show the right number of
cylinders, but that also involves the notion of adding a cylinder in
order to fill out information that didn't use to exist.

That's lower priority - now the infrastructure seems to be there.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoMore work on abstracting the gtk cylinder widget thing
Linus Torvalds [Tue, 13 Sep 2011 20:15:31 +0000 (13:15 -0700)]
More work on abstracting the gtk cylinder widget thing

Ok, now we have an array of them, and most of the time we pass the right
pointer back and forth.

There's still a couple of places that hardcode "gtk_cylinder[0]" as the
data, but by now they are mostly things that should iterate over all the
cylinders.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoStart abstracting out the cylinder equipment widgets
Linus Torvalds [Tue, 13 Sep 2011 19:58:53 +0000 (12:58 -0700)]
Start abstracting out the cylinder equipment widgets

Create a "struct cylinder_widget" so that when we handle multiple
cylinders, we can match them up with the actual cylinder data;

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAlways pack the widgets into boxes, not frames
Linus Torvalds [Tue, 13 Sep 2011 18:56:42 +0000 (11:56 -0700)]
Always pack the widgets into boxes, not frames

Let's try to be consistent about this.  Make the parent of each widget
be a box.  Maybe the frames come with boxes, but since I have no clue
about gtk, I'm going to just always create them by hand.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAdd a checkbox for nitrox settings
Linus Torvalds [Tue, 13 Sep 2011 18:47:20 +0000 (11:47 -0700)]
Add a checkbox for nitrox settings

Grey out the nitrox value unless the user explicitly checks the checkbox.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoUse round line noins and caps
Linus Torvalds [Tue, 13 Sep 2011 15:25:54 +0000 (08:25 -0700)]
Use round line noins and caps

It doesn't really make much of a difference, but it can be visible
especially with lots of tight samples.  Miter joins really look horrible
for acute angles.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoLabel the temperature graph
Linus Torvalds [Tue, 13 Sep 2011 15:16:29 +0000 (08:16 -0700)]
Label the temperature graph

Oooh, pretty.

Or not.  The temperature graph is usually ugly as hell, but Dirk has the
cool dive computer with lots and lots of temperature readings.  Which
makes the graph a pretty graph, rather than a butt-ugly staircase like
mine.

Next time: get a dive computer with an OLED screen, and that can draw
pretty temperature graphs.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoPlot a sick kind of temperature curve
Linus Torvalds [Tue, 13 Sep 2011 03:37:32 +0000 (20:37 -0700)]
Plot a sick kind of temperature curve

.. without the actual text, because I'm a "random plots that cannot
actually be interpreted" kind of guy.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoUpdate the README about libdivecomputer
Linus Torvalds [Mon, 12 Sep 2011 21:05:44 +0000 (14:05 -0700)]
Update the README about libdivecomputer

The build instructions are in the git commit log too, but let's make
them a bit easier to find.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoDon't save empty cylinder descriptions in the xml
Linus Torvalds [Mon, 12 Sep 2011 20:41:37 +0000 (13:41 -0700)]
Don't save empty cylinder descriptions in the xml

They get created when the equipment thing doesn't have a name for the
cylinder, but we don't want to save that lack of description.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoDo some basic sanity testing on the libdivecomputer gasmix data
Linus Torvalds [Mon, 12 Sep 2011 20:31:43 +0000 (13:31 -0700)]
Do some basic sanity testing on the libdivecomputer gasmix data

It's quite often obvious crap for the "doesn't exist" or "plain air" case.

So if it's reporting 100% O2, we just ignore it.  Sure, it could be
right, but for the dives I have I know it's just libdivecomputer being
wrong.

Same goes for obvious crap like 255% Helium.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoLibdivecomputer: start actually importing the dive data
Linus Torvalds [Mon, 12 Sep 2011 20:25:05 +0000 (13:25 -0700)]
Libdivecomputer: start actually importing the dive data

So this actually reports the dive data that libdivecomputer generates.
It doesn't import special events etc, but neither do we for the xml
importer.

It is also slow as heck, since it doesn't try to do the "hey, I already
have this dive" logic and always imports everything, but the basics are
definitely there.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAbstract out dive/sample allocation a bit
Linus Torvalds [Mon, 12 Sep 2011 19:56:34 +0000 (12:56 -0700)]
Abstract out dive/sample allocation a bit

We're going to start to want to allocate dives and samples for the
libdivecomputer import too, so let's clean things up a bit for that.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agolibdivecomputer integration: add a progress bar
Linus Torvalds [Mon, 12 Sep 2011 18:41:26 +0000 (11:41 -0700)]
libdivecomputer integration: add a progress bar

Instead of writing out the progress events, use them to update a real
progress bar.

Also, we need to handle gtk events while busy with the dive computer
reading.  That should *probably* be done with a threading model, because
libdivecomputer does seem to have some timing sensitivity - I'm getting
"failure to read memory block" if I make that loop do the standard

while (gtk_events_pending())
  gtk_main_iteration();

thing.  Besides, even if we did do that loop, it would still cause
problems when the libdivecomputer code is stuck reading a serial line
that doesn't respond or whatever.

But for now this ugly hack is "good enough" to get further.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoLibdivecomputer integration, part n+1
Linus Torvalds [Mon, 12 Sep 2011 18:05:32 +0000 (11:05 -0700)]
Libdivecomputer integration, part n+1

This actually gets me far enough that it prints out all the dives on my
dive computer.  It doesn't actually turn them into real dives yet,
though - only a series of ugly 'printf's so far.

And it hangs after printing the last dive. So I'm doing something wrong.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoMore libdivecomputer boilerplate stuff
Linus Torvalds [Mon, 12 Sep 2011 17:37:54 +0000 (10:37 -0700)]
More libdivecomputer boilerplate stuff

.. fill in the event parsing.  This doesn't generate the fingerprint
like the example does, I just don't care about that yet.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoFurther work on libdivecomputer integration
Linus Torvalds [Mon, 12 Sep 2011 17:27:35 +0000 (10:27 -0700)]
Further work on libdivecomputer integration

.. this now registers the dive parsing callback, and starts to parse the
data.  So I can see the last divetime on my Suunto Vyper Air now.

Still a lot more boilerplate stuff to go, though.  The libdivecomputer
interfaces really are pretty insane: why should the caller set up the
dive parsing for each computer type, when libdivecomputer knows what
types it has? IOW, much of that boilerplate should be hidden inside of
libdivecomputer, rather than exposed to the user.

But whatever.  I'm taking pieces from "examples/universal.c" as I go
along (it's under LGPL 2.1).  I want to do it in small chunks just to
feel that I understand what's going on, rather than just blindly copying
it all.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoFlesh out the libdivecomputer interfaces some more
Linus Torvalds [Mon, 12 Sep 2011 16:50:40 +0000 (09:50 -0700)]
Flesh out the libdivecomputer interfaces some more

.. start some error reporting, and register some early (empty)
callbacks.

This still doesn't actually do anything.  But commit early, commit
often: when I start seriously breaking things, I want to have a "hey,
this still at least compiled" state.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoMake 'report_error()' usable from outside of main.c
Linus Torvalds [Mon, 12 Sep 2011 16:49:54 +0000 (09:49 -0700)]
Make 'report_error()' usable from outside of main.c

The dive computer import code will want to show errors too..

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAvoid using type 'gasmix_t': use 'struct gasmix' instead
Linus Torvalds [Mon, 12 Sep 2011 16:47:55 +0000 (09:47 -0700)]
Avoid using type 'gasmix_t': use 'struct gasmix' instead

libdivecomputer already uses 'gasmix_t' for its own gasmix thing.  I
don't like th eway we step on each others name spaces, but hey, might as
well just use 'struct gasmix' and avoid the typedef.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoStart some very initial libdivecomputer integration
Linus Torvalds [Mon, 12 Sep 2011 16:19:21 +0000 (09:19 -0700)]
Start some very initial libdivecomputer integration

Ok, so this is quite broken right now: it doesn't actually really *do*
anything, and it now requires that you have libdivecomputer all set up
and installed.

That is fairly easy:

mkdir ../src
cd ../src
git clone git://libdivecomputer.git.sourceforge.net/gitroot/libdivecomputer/libdivecomputer
cd libdivecomputer
autoreconf --install
./configure
make
sudo make install

but you may feel that this is not exactly useful considering that
nothing actually *works* yet.

Some day.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoClean up dive info box too
Linus Torvalds [Sun, 11 Sep 2011 23:34:01 +0000 (16:34 -0700)]
Clean up dive info box too

Make it denser by putting the dive number/location in the frame label,
and make it size up and down more naturally.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAccept a smaller profile window
Linus Torvalds [Sun, 11 Sep 2011 23:21:21 +0000 (16:21 -0700)]
Accept a smaller profile window

I'm trying to make sure that we can shrink the main window and still get
a useful experience.  Sometimes you have small bad netbooks when diving..

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAdd a 'Renumber' menu choice
Linus Torvalds [Sun, 11 Sep 2011 22:39:46 +0000 (15:39 -0700)]
Add a 'Renumber' menu choice

If you want to re-number your dives - either because they didn't have
any numbering at all, or because you forgot about other dives - you now
can.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoPack all the equipment widgets into boxes
Linus Torvalds [Sun, 11 Sep 2011 22:37:56 +0000 (15:37 -0700)]
Pack all the equipment widgets into boxes

We really do want to "pack" them, rather than use up the whole size.  I
think.

I may end up playing around more with this.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoOops. Fix 'buffered dive' information
Linus Torvalds [Sun, 11 Sep 2011 20:43:37 +0000 (13:43 -0700)]
Oops. Fix 'buffered dive' information

When fixing the unit changes, I broke the dive buffering logic entirely
for switching between dives. Duh.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoWork around more Diving Log bugs..
Linus Torvalds [Sun, 11 Sep 2011 20:16:23 +0000 (13:16 -0700)]
Work around more Diving Log bugs..

The Diving Log temperature reading is in Fahrenheit for the samples (for
the per-dive water/air temperature it's in Celsius).  But it seems to
have a bug where a lack of a sample has been turned into 32 Fahrenheit
(which is 0 celsius).  This is despite the dive itself having a water
temperature of 8 degF.

Just throw away those bogus freezing temperatures.  Sure, they can
happen, and ice divers are crazy - but in this case I know it's just an
error in the log, and it looks very much like a Diving Log bug.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoCall an LP85 an LP85 even when it's "10% extra".
Linus Torvalds [Sun, 11 Sep 2011 20:03:43 +0000 (13:03 -0700)]
Call an LP85 an LP85 even when it's "10% extra".

The LP85+ name is not something we'd normally want to recognize.  The LP
cylinder names all tend to be by the "+" pressure anyway, and that's
what we do in the equipment handling naming.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoBe more careful about unit changes
Linus Torvalds [Sun, 11 Sep 2011 19:53:59 +0000 (12:53 -0700)]
Be more careful about unit changes

When we change units, we need to flush any currently active dive
information in the old units, and then carefully reload it in the new
units.

Otherwise crazy stuff happens - like having current cylinder working
pressure values that are in PSI because that *used* to be the output
unit, but then interpreting those values as BAR, because we changed the
units.

Also, since we now properly import working pressure from Diving Log,
stop importing the (useless) cylinder description.  The Diving Log
cylinder descriptions are things like "Alu" or "Steel".  We're better
off just making up our own.

Finally, since Diving Log has cylinder size in metric, make sure that we
do the "match standard cylinder sizes" *after* we've done all the
cylinder size conversions to proper units.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoParse 'Diving Log' cylinder working pressure
Linus Torvalds [Sun, 11 Sep 2011 19:24:57 +0000 (12:24 -0700)]
Parse 'Diving Log' cylinder working pressure

Oh Gods. Why are all other scuba programs so f*&% messed up?

The Diving Log cylinder working pressure is in bar - which is all good.
But their pressure *samples* are in PSI.  Why the h*ll do people mix up
units in the same damn file like that? I despair at the pure
incompetence sometimes.

I suspect the pressure samples aren't "really" in PSI: they are probably
in some user-specified units.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoFix up dive number naming
Linus Torvalds [Sun, 11 Sep 2011 18:36:33 +0000 (11:36 -0700)]
Fix up dive number naming

Use "dive->number" instead of "dive->nr". And make the XML match too.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoShow dive number (if it exists) in the location note
Linus Torvalds [Sun, 11 Sep 2011 18:54:55 +0000 (11:54 -0700)]
Show dive number (if it exists) in the location note

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoSave and restore a "dive number"
Linus Torvalds [Sun, 11 Sep 2011 18:36:33 +0000 (11:36 -0700)]
Save and restore a "dive number"

Some people want to know how many dives they have under their belt, so
let's save and restore the dive number if it exists.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAdd more static cylinder types - and pick them up from the dive log
Linus Torvalds [Sun, 11 Sep 2011 00:14:07 +0000 (17:14 -0700)]
Add more static cylinder types - and pick them up from the dive log

This adds a few more predefined cylinder types to the static list, but
perhaps more importantly, if we try to show a cylinder description that
we haven't seen before, we automatically add that description to the
list as well.

This way, if people have their own cylinder types, our cylinder
management will automatically figure them out and make it easy to enter
them.

NOTE! It might be best to add the new cylinder description at dive log
load time, rather than at 'show' time.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
12 years agoAdd new cylinder models to the cylinder model store
Linus Torvalds [Sat, 10 Sep 2011 23:27:19 +0000 (16:27 -0700)]
Add new cylinder models to the cylinder model store

We also need to actually fill the model store with the cylinder models
we have in our dive lists to begin with.

This makes it all *trivial* to add a new cylinder model: just use a new
description, fill in the size and working pressure, and you're done.
The type automatically gets filled in, unless that description already
existed (in which case we leave it alone).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>