Commit graph

293 commits

Author SHA1 Message Date
Dirk Hohndel
98414ac9a9 Fix compiler warnings
Doing this on Arch Linux with gcc 4.8.0 helped find one real bug.

The rest are simply changes to make static functions externally visible
(as they are kept around to eventually become helpers used by Qt) which
for now avoids the warnings.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-03 14:21:13 -07:00
Dirk Hohndel
8677721e85 Remove the majority of the Gtk related code
- rip all Gtk code from qt-gui.cpp
- don't compile Gtk specific files
- don't link against Gtk libraries
- don't compile modules we don't use at all (yet)
- use #if USE_GTK_UI on the remaining files to disable Gtk related parts
- disable the non-functional Cochran support while I'm at it

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-03 11:37:09 -07:00
Dirk Hohndel
63c5080561 Move gas string computation into core logic code
This is now a helper called from the Gtk UI code (and will soon be used by
the Qt UI code).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-02 10:39:35 -07:00
Dirk Hohndel
4587f8a274 Call the get_date functions with timestamp_t instead of struct tm
This is the much more natural way to use this function, now that I look at
it...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-24 21:05:57 -07:00
Dirk Hohndel
92a5a5c35b Split report_dives into UI and logic and move to divelist files
Functionality is unchanged, except we now have a nice process_dives
function that deals with all the logic and that gets called from
report_dives from the Gtk code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-24 16:38:25 -07:00
Anton Lundin
ee0025f696 Add a simple table-based cns calculations
For dives where divecomputers haven't provided us with a cns, we
calculate our cns accumulated during that dive based on a simple table.

We also check if we did a dive in the prior 12 ours and grab the cns
from it and calculate how much of that still affects us.

[Dirk Hohndel: a couple of small changes: remove unnecessary check of cns
               values in the samples of the first dive computer, changed
	       the way we determine the 'previous dive' and used the end
	       time of that previous dive for the decay calculation]

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-23 20:43:34 -07:00
Dirk Hohndel
75765be14c Move creation of dive and dive trip date string into helper functions
This allows this code to easily be shared by Gtk and Qt UI.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-18 13:18:09 -07:00
Amit Chaudhuri
073be111f4 Delay Qt ui construction
The Qt ui will need to read the dive_table to populate widgets with
dives. Gtk functionality in init_ui is required to parse the dives.
Split init_ui to allow parsing to proceed and complete before Qt ui
mainwindow constructor is called.

Play with qDebug()'s printf style (Thiago!)

Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-18 12:31:15 -07:00
Dirk Hohndel
081000963a Continue to separate Gtk related code from core logic: divelist
Move some more logic out of the divelist-gtk.c file.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-06 21:28:42 -07:00
Dirk Hohndel
1d61955be9 Separate Gtk related code from core logic: divelist
This is simplistic & brute force: any function that touches Gtk related
data structures is moved to divelist-gtk.c, everything else stays in
divelist.c.

Header files have been adjusted so that this still compiles and appears to
work. More thought is needed to truly abstract this out, but this seems to
be a good point to commit this change.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-06 20:49:06 -07:00
Miika Turkia
12d5ab4ce3 Export dives to UDDF file
This patch implements exporting dives from Subsurface to UDDF format.
Events and cylinder info are the most remarkable things still missing
from the export.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-24 06:37:56 -07:00
Lubomir I. Ivanov
5766e299c3 divelist.c: Fix an 'implicit declaration' warning
close() should be included from unistd.h, instead of fcntl.h for
better portability.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-20 10:23:25 -07:00
Robert C. Helling
959dc942be Correctly handle first gas when deciding if gas is used
Gas with index 0 is assumed to be the first gas only if there is no
gaschage event in the first 30 seconds of the dive.

[Dirk Hohndel: minor formatting change in a logical expression]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-18 08:08:02 -07:00
Robert C. Helling
ae4bd802af Take only used gases into account when showing gas in divelist
Here is a patch that restricts the gases listed in the divelist to those
that are actually used. I seem to have the indentation now under control
but I am not sure about the logic:

1) First gas (with index 0) is always used.

2) If there is a gas switch event, the new gas is also used (determined by
walking the list of dive computers and then the list of events).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-18 07:37:08 -07:00
Dirk Hohndel
fbb260aeb5 Use a generic 64bit int type
The zip_int64_t type appears to be missing with mingw so it breaks my cross
builds - and this is clearly equivalent.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-15 16:36:41 -07:00
Dirk Hohndel
bd9f8ad7f8 First simplistic implementation of a divelogs.de upload
This has no user interface and hardcodes a testing username / password.
But it can successfully create a DLD file (thanks to Miika and Lubomir)
and then uses libsoup to upload that to the server.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-13 20:37:38 -07:00
Lubomir I. Ivanov
099953e776 DLD upload: Avoid using open_memstream() and non-portable functions
patch contains:
- replacement for open_memstream()
- storage of the temporary zip file in the OS temporary directory
- replacement usage of mktemp() with g_mkstemp()

patch based on work by Miika Turkia.

[Dirk Hohndel: as suggested by Miika I commented out the deletion of the
               DLD file]

Acked-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-12 22:17:20 -07:00
Miika Turkia
42ea5e3510 .DLD generation for uploading to divelogs.de
This generates a .DLD file of selected dives to be uploaded to
divelogs.de. The actual upload functionality along with sensible user
interface is still to be implemented. However, the resulting file from
this patch is tested to work (as far as I can tell) using upload API of
divelogs.de.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-10 09:29:12 -07:00
Dirk Hohndel
1a69a845e1 Saving individual dives should not change the exiting filename
The current data file is not the same as the file to which individual
dives were saved.

Reported-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-03 23:31:24 -08:00
Dirk Hohndel
0129192958 Try to capture some more potential buffer overflows caused by localization
A couple of these could clearly cause a crash just like the one fixed by
commit 00865f5a1e1a ("equipment.c: Fix potential buffer overflow in
size_data_funct()").

One would append user input to fixed length buffer without checking.

We were hardcoding the (correct) max path length in macos.c - replaced by
the actual OS constant.

But the vast majority are just extremely generous guesses how long
localized strings could possibly be.

Yes, this commit is likely leaning towards overkill. But we have now been
bitten by buffer overflow crashes twice that were caused by localization,
so I tried to go through all of the code and identify every possible
buffer that could be affected by this.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-03 20:18:23 -08:00
Dirk Hohndel
9e8aaad133 When manually adding a dive allow user to set avg depth as well
So far we only allowed setting the max depth.

This changes the layout of the entry widget and makes our helper function
create_date_time_widget return the hbox in which it positions the time
entry. I plan to reuse this later when allowing to edit the duration as
well as the start date and time under certain circumstances.

This is a small part of a feature request; see #75

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-27 14:46:47 -08:00
Linus Torvalds
308d71ec39 Take incompressibility of gas into account at higher pressures
This creates a helper function called "gas_volume()" that takes the
cylinder and a particular pressure, and returns the estimated volume of
the gas at surface pressure, including proper approximation of the
incompressibility of gas.

It very much is an approximation, but it's closer to reality than
assuming a pure ideal gas.  See for example compressibility at

    http://en.wikipedia.org/wiki/Compressibility_factor

Suggested-by: Jukka Lind <jukka.lind@iki.fi>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-25 16:48:16 -08:00
Linus Torvalds
7b20fb826c Use the improved duration and average depth for everything
The code was written to get the SAC rate correct, but we probably do
want to have the duration and mean depth of the dive always be shown for
the non-surface-time.

So move the code from the sac-rate calculation to the generic dive fixup
part.  This makes the dive list and statistics all show the duration as
the under-water duration, which is not necessarily the same as
"difference between beginning and end of dive".

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-24 11:48:29 -08:00
Linus Torvalds
6d548d2028 Correctly calculate SAC rate in the presense of surface events
This assumes that you are not breathing your cylinders while at the
surface, which may or may not be correct, but is usually the right
thing.  Regardless, we're better off giving a conservative (higher) SAC
rate estimate for a diver that breathes his cylinder at the surface too
than giving an artificially low one because the diver ended up using his
snorkel and we didn't take that into account.

NOTE! This basically calculates a better duration and average depth than
the ones we end up showing in the dive list.  Maybe we should actually
show this "no-surface-time" duration and average depth instead of the
ones we do show?

That's a separate question, though.

Added a test-case for the surface case to the sac-test.xml dives.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-24 11:09:52 -08:00
Linus Torvalds
f4bf16d5db Fix up SAC calculations for ATM/bar confusion
We even documented that we did SAC in bar*l/min, but the "S" in SAC
stands for "Surface".  So we should normalize SAC rate to surface
pressure, not one bar.

It's a tiny 1% difference, and doesn't actually matter in practice, but
it's noticeable when you want to explicitly test for SAC-rate by
creating a test-dive that averages exactly 10m.  Suddenly you don't get
the round numbers you expect.

[ Side note: 10m is not _exactly_ one extra atmosphere according to our
  calculations, but it's darn close in sea water: the standard salinity
  of 1.03 kg/l together with the standard acceleration of 9.81m/s^2
  gives an additional pressure of 1.01 bar, which is within a fraction
  of a percent of one ATM.

  Of course, divers have likely chosen that value exactly for the math
  to come out that way, since the true average salinity of seawater is
  actually slightly lower ]

So here's a few test-dives, along with the SAC rate fixup to make them
look right.

(There's also a one-liner to dive.c that makes the duration come out
right if the last sample has a non-zero depth, and the previous sample
did not: one of my original test-dives did the "average 10m depth" by
starting at 0 and ending at 20m, and dive.c got a tiny bit confused
about that ;)

[ The rationale for me testing our SAC rate calculations in the first
  place was that on snorkkeli.net user "Poltsi" reported that our SAC rate
  calculations differ from the ones that Suunto DM4 reports. So I wanted
  to verify that we did things right.

  Note that Poltsi reported differences larger than the difference of
  BAR/ATM, so this is not the cause. I'll continue to look at this. ]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-24 10:49:26 -08:00
Lubomir I. Ivanov
0b4dfd6cff Unref the two GtkTreeStore instances when destroying the divelist
Even if these exists for the heap lifespan, we can call:
g_object_unref(dive_list.treemodel);
g_object_unref(dive_list.listmodel);

in divelist.c:dive_list_destroy()

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-20 17:20:22 -08:00
Lubomir I. Ivanov
9a5818e92c Fixed a memory leak in the divelist when moving with the keyboard
There were some small leaks before here, related to gtk_tree_iter_copy(),
but there is another one in select_next_dive():
nextiter = gtk_tree_iter_copy(iter);

This now requires a SJ near the epilog where we do the memory cleanup.
Lets call this similar label consistently "free_iter" between
select_prev_dive and select_next_dive.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-20 17:19:50 -08:00
Lubomir I. Ivanov
32761485d1 Indicate to the user a default divelist sorting order
Each time subsurface starts there is supposedly no sorting order
(or divelist column) specified by the UI, yet the actual column is '#'
(or dive number column), since its the *only* column which allows
trips to be visible. If the user selects a different sorting order
then he has no idea which column was the one who had the trips visible.

"Where did all those 'trip' things go?"
This can be a bit confusing...

Lets provide indication by calling gtk_tree_view_column_set_sort_indicator().
Also call gtk_tree_view_column_set_sort_order() to specify a descending
order.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-20 07:24:59 -08:00
Lubomir I. Ivanov
57e8349b87 Preserve keyboard focus when changing sorting order in the divelist
When the user changes the dive list sorting order via clicking
on different column titles, using gtk_widget_grab_focus() gives
keyboard focus back to the list itself (not staying on the column titles),
which gives a hint that the list itself has focus index of 0 and is
reset each time the widget receives this type of "initial" focus.

Acked-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-20 07:24:28 -08:00
Dirk Hohndel
b406dbe1c0 Fix tracking of selected dives across sort column changes
With  commit 800b0482f39e ("When switching sort order, scroll the dive
list to the current dive") we introduced an unwanted new behavior. When
changing sort columns we could lose all selections except for the main
"selected_dive". This was caused by the call to gtk_tree_view_set_cursor
on the selected_dive which unselected all other dives.

As a side-effect this also fixed another bug that was introduced by the
same change: shift-cursor-up and -down now works again to select multiple
dives with the keyboard.

But fixing that bug unearthed a different issue. Our code that restored
the selection state of the tree model oddly decided to mark a divetrip as
selected if its first child was selected. The bug above masked that by
immediately unselecting the trip again, but now that this was fixed the
problem was immediately obvious: we would start with both the first trip
and the first dive in that trip selected (well, since we are in reverse
order it's actually the chronologically last trip and last dive...).

Instead we now use the remembered state of the trip to determine whether
it should be expanded or selected.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-19 23:55:24 -08:00
Linus Torvalds
0fd6907965 Obviate the need for explicit 'remember_tree_state/restore_tree_state' calls
Instead, just keep track of the expanded state of trips as we get the
gtk callbacks for the state changes (which we need to track anyway for
the selection logic), and automatically restore the state whenever we
re-create the divelist.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-19 14:00:21 -08:00
Linus Torvalds
aa6b164a3e Remember non-expanded state in 'remember_tree_state()' too
The 'remember_tree_state()' thing is meant to remember if a dive trip is
expanded or not, but it missed the "or not" part.  IOW, it never cleared
the expanded flag, it only ever set it.

As a result, if you were doing multiple operations on the divelist tree
(testing all the recent gtk-model removal, for example) the dive trips
would end up expanding more and more, even if you collapsed things by
hand in between operations.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-19 13:05:48 -08:00
Linus Torvalds
7847de62b1 Rewrite "merge_dive_into_trip_above()" using our own data structures
This does the moving of dives into the trip above without the complexity
of the gtk data structures, and instead just recreates the whole
divelist afterwards.  As usual, this simplifies things a lot, and the
less gtk-specific code we have, the better.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-19 11:50:58 -08:00
Linus Torvalds
e453ea8695 Don't do "insert_trip_before" using the gtk data structures
.. use our own data structures instead, and regenerate the gtk ones
after having successfully created the new trip.

This simplifies the code enormously, and also makes it much more
generic.  You can now create a new trip from any arbitrary set of
selected dives (it used to be that the "multiple selected dives" case
worked, but only for some very specific special cases of selected dives).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-19 11:24:42 -08:00
Linus Torvalds
a00bfc918a Fix find_trip_by_idx() over-zealous cleanup
Commit bcf1f8c4fe ("Don't do "remove_from_trip" by walking the gtk
data structures") made find_trip_by_idx() only work for negative indexes
(positive indexes are dives), but when it removed the unnecessary test
for negativity, the statement inside it should have been kept as
unconditional, rather than removed with the test.

Oops.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-19 11:24:04 -08:00
Linus Torvalds
bcf1f8c4fe Don't do "remove_from_trip" by walking the gtk data structures
They are complicated and confusing.  Just use our own data structures
and re-generate the gtk ones from them.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-19 10:38:20 -08:00
Linus Torvalds
97bd24246e Don't do "remove_trip()" by walking the gtk data structures
They are complicated and confusing.  Just use our own data structures
and re-generate the gtk ones from them.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-19 10:38:17 -08:00
Linus Torvalds
cb490b7abf Use the divetrip index to look up divelist trip entries
We used to look up dive trips by their date, but these days we always
create a dynamic index for a dive trip when we insert it into the
divelist model, so we can use that to unambiguously match up dive trips
with the dive model entries.

That means that we don't get confused if we have two trips with the
exact same time, which happens when you load all the test-dives, for
example.

Reported-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-19 08:23:27 -08:00
Linus Torvalds
1e04e08064 When only a dive trip is selected, select all the dives in the trip
This does a final pass after all the selection logic, and notices if we
have dive trips that are selected, but that have no dives in them
selected.  In that case, we assume that the user wanted to select all
dives in that trip.

NOTE! This still allows a range selection that selects the dive trip
entry and a few dives under the trip.  If a trip has any dives selected
in it, we leave that manual selection alone.  So this new logic really
only triggers on the case where somebody selected *just* the trip.

Note: unselecting the trip still leaves the dives under it selected,
because having a dive trip that isn't selected have all the dives under
it be selected is normal, and we can't recognize that as some kind of
special event.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-18 16:18:26 -08:00
Dirk Hohndel
2f059c8b81 Replace deprecated gdk_pixbuf_unref with g_object_unref
This appears to be the better API call to do this (according to online
documentation and compiler warnings on Linux).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 11:48:12 -08:00
Lubomir I. Ivanov
ea21126f62 Fixed a memory leak related to the satelite icon
divelist.c:get_gps_icon_for_dive()
In all callers of the function use gdk_pixbuf_unref() to
release the returned GdkPixbuf (but also check for NULL).

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 11:40:20 -08:00
Lubomir I. Ivanov
363c38f557 Fixed some memory leaks in divelist.c related to gtk_tree_iter_copy()
divelist.c:
get_iter_from_idx() goes trought the tree model and calls
iter_has_index(), until a match is found. when the match is found
we use gtk_tree_iter_copy() to make a copy of the iterator.

This means that the caller of get_iter_from_idx() has to take care
the de-allocation using gtk_tree_iter_free().

Also take care of the eventual:
parent = gtk_tree_iter_copy(...)
allocation in select_prev_dive(), select_next_dive()

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 11:40:03 -08:00
Dirk Hohndel
ebcbe5aedd Finish removing accesses to first divecomputer instead of dive
This adds watertemp and airtemp to the dive, populates them in fixup and
uses them elsewhere in the code.

WARNING: as a sideeffect we now edit the airtemp in the dive, but we never
display this in the DIve Info notebook (as that always displays the data
from the specific selected divecomputer). This is likely to cause
confusion. It's consistent behavior, but... odd. This brings back the
desire to have a view of "best data available" for a dive, in addition to
the "per divecomputer" view. This would also allow us to consolidate the
different pressure graphs we may be getting from different divecomputers
(consider the case where you dive with multiple air integrated computers
that are connected to different tanks - now we could have one profile with
all the correct tank pressure plots overlayed - and the best available (or
edited) data in the corresponding Dive Info notebook.

This commit also fixes a few remaining accesses to the first divecomputer
that fell through the cracks earlier and does a couple of other related
cleanups.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 07:41:15 -08:00
Dirk Hohndel
b9865d6bbc Move duration to dive structure and replace accessor function
When starting on this quest to stop using the first divecomputer instead
of data for the whole dive in commit eb73b5a528c8 ("Duration of a dive is
the maximum duration from all divecomputers") I introduced an accessor
function that calculates the dive duration on the fly as the maximum of
the durations in the divecomputers.

Since then Linus and I have added quite a few of the variables back to the
dive data structure and it makes perfect sense to do the same thing for
the duration as well and simply do the calculation once during fixup.

This commit also replaces accesses to the first divecomputer in
likely_same_dive to use the maxdepth and meandepth of the dive (those two
slipped through the cracks in the previous commits, it seems).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 07:19:29 -08:00
Dirk Hohndel
1511271201 Add maxdepth back to the dive structure
Populate during dive fixup as the maximum depth shown by all the
divecomputers. Use this value (instead of the one in the first
divecomputer) in printing, statistics, etc.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 20:44:04 -08:00
Linus Torvalds
926fcef2a1 Do more dive fixup for each dive computer
In commit b6c9301e58 ("Move more dive computer filled data to the
divecomputer structure") we moved the fields that get filled in by the
dive computers to be per-divecomputer data structures.

This patch re-creates some of those fields back in the "struct dive",
but now the fields are initialized to be a reasonable average from the
dive computer data.  We already did some of this for the temperature
min/max fields for the statistics, so this just continues that trend.

The goal is to make it easy to look at "dive values" without having to
iterate over dive computers every time you do.  Just do it once in
"fixup_dive()" instead.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 18:22:30 -08:00
Dirk Hohndel
61861d2611 Clean up the handling of surface pressure
There are two ways to look at surface pressure. One is to say "what was
the surface pressure during that dive?" - in that case we now return an
average over the pressure reported by the different divecomputers (or the
standard 1013mbar if none reported any).

Or you want to do specific calculations for a specific divecomputer - in
which case we access only the pressure reported by THAT divecomputer, if
present (and fall back to the previous case, otherwise).

We still have lots of places in Subsurface that only act on the first
divecomputer. As a side effect of this change we now make this more
obvious as we in those cases pass a pointer to the first divecomputer
explicitly to the calculations.

Either way, this commit should prevent us from ever mistakenly basing our
calculations on a surface pressure of 0 (which is the initial bug in
deco.c that triggered all this).

Similar changes need to be made for other elements that we currently only
use from the first divecomputer, i.e., salinity.

Reported-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09 08:01:59 +11:00
Dirk Hohndel
9846ba9e94 Duration of a dive is the maximum duration from all divecomputers
So far we always used the duration of the first divecomputer. The same fix
needs to be done for some of the other calculations that always use the
first divecomputer.

This commit also removes some obsolete code from the webservice merging.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 17:48:07 +11:00
Linus Torvalds
b18c34373f Properly de-select dives in collapsed trips that are unselected
We had the logic for the "select" case, but not for the "deselect" case. Ugh.

Reported-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-08 11:46:06 +11:00
Jan Schubert
99dbd667bf Fixing SP handling in planner, adding event
This moves some double/floating handling for po2 to plain integer. There
are still non int values around (also for phe and po2) in the plot area.

Signed-off-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-03 07:07:12 +11:00