summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2012-11-11Create tool-tip with depth/pressure for the whole profile areaGravatar Linus Torvalds
This extends on our current tooltip logic (which shows events when you mouse over them) to show tooltips for the whole profile area. If you mouse over an event, that is still shown in the tooltip, but even in the absense of events, the tooltip will be active, and mousing over the profile area will show the time, depth and pressure. This can certainly be improved upon further, but even in this form it is useful. Fixes #9 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-11Add special download modes to force updates from the divecomputerGravatar Dirk Hohndel
This will hopefully not be something we need often, but if we improve support for a divecomputer (either in libdivecomputer or in our native Uemis code or even in the way we handle (and potentially discard) events), then it is extremely useful to be able to say "re-download things from the divecomputer and for things that were not edited in Subsurface, don't try to merge the data (which gives BAD results if for example you fixed a bug in the depth calculation in libdivecomputer) but instead simply take the samples, the events and some of the other unedited data straight from the download". This commit implements just that - a "force download" checkbox in the download dialog that makes us reimport all dives from the dive computer, even the ones we already have, and an "always prefer downloaded dive" checkbox that then tells Subsurface not to merge but simply to take the data from the downloaded dive - without overwriting the things we have already edited in Subsurface (like location, buddy, equipment, etc). This, as a precaution, refuses to merge dives that don't have identical start times. So if you have edited the date / time of a dive or if you have previously merged your dive with a different dive computer (and therefore modified samples and events) you are out of luck. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-11Initial not-so-pretty profile zoom supportGravatar Linus Torvalds
You can press the left mouse-button on the profile and drag the mouse around to zoom in on a specific area. Releasing the mouse button unzooms. Yeah, everybody wants rubber-banding, but I have reached the end of my willingness to fight gtk for more details. Some day. [Dirk Hohndel: changed this to use the right mouse button instead of the left which seemed just terribly unnatural] References ticket 9 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-11Fix selection and trip expansion logic after merging divesGravatar Linus Torvalds
This just makes sure that the merged dive is properly selected, and that we've saved the trip tree state so that the dive list repaints nicely and with the newly merged dive selected after the merge. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-11Draw a thin frame around dive printsGravatar Salvador Cuñat
Just that trivial, simple and cosmetic thing. Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-11Add another print option, 1 dive per sheet.Gravatar boret
Simply add a dive option on bigger surface, whith bigger fonts. The size isn't A4 nor A5, but the size used by some popular paper divelogs. The modification performs better if we transpose the profile and the text of the dive, because, if the notes are very brief,we get an excess of white space at the bottom of the print. Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-11Support merging of two adjacent divesGravatar Linus Torvalds
This introduces the notion of merging two disjoint dives: you can select two dives from the dive list, and if the selection is exactly two dives, and they are adjacent (and share the same dive trip), we support the notion of merging the dives into one dive. The most common reason for this is an extended surface event, which made the dive computer decide that the dive was ended, but maybe you were just waiting for a buddy or a student at the surface, and you want to stitch together two dives into one. There are still details to be sorted out: my Suunto dive computers don't actually do surface samples at the beginning or end of the dive, so when you stitch two dives together, the profile ends up being this odd "a couple of feet under water between the two parts of the dive" thing. But that's an independent thing from the actual merging logic, and I'll work on that separately. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-11Prepare to merge non-overlapping divesGravatar Linus Torvalds
This just re-organizes the dive merging code so that we expose a new "merge_dives(a, b, offset)" function that merges two dives together into one with the samples (and events) of 'b' at the specified offset after 'a'. We'll want to use this if a dive computer has decided that the dive ended (due to a pause at the surface), but we really want to just turn the two computer dives into one long one with an extended surface swim. No functional changes, but some independent cleanups due to the trip simplifications. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-11Trim the dive to exclude surface time at beginning and endGravatar Dirk Hohndel
We don't change any of the samples, we just don't plot (or consider for dive time / mean calculations) the samples at the beginning or end of the dive that are less than a certain threshold under water. Right now that's an arbitrary 75cm which seems to Do The Right Thing(tm) for the dives I tried this with - but I'm happy to look at other values if this causes problems for people with dive computers I do not have access to. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-11Merge branch 'pressure'Gravatar Dirk Hohndel
Make depth to absolute pressure conversions consistent.
2012-11-11Add depth to mbar helper functionGravatar Dirk Hohndel
This ensures that we use consistent math to get the absolute pressure at a certain depth. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-11Don't simplify 'bookmark' and 'heading' eventsGravatar Linus Torvalds
Add the bookmark and heading events to the list of events not to be simplified just because they are redundant - in both cases they are about the user doing something explicit (like the gaschange), so even if the data is otherwise identical, they should likely be saved. That said, both events are kind of pointless (we don't actually seem to save the heading value for the heading events, and bookmarks are universally just due to user error in at least my case). But still.. This overly aggressive filtering was introduced in commit 6ad73a8f043b ("Improve logic handling events"). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-11Simplify and clean up dive trip managementGravatar Linus Torvalds
This adds a couple of helper functions to manage dive trips ("add_dive_to_trip()" and "remove_dive_from_trip()") and makes those functions do the trip statistics maintenance (trip beginning times, number of dives, etc). This was needed because the dive merge cases for multiple dive computers showed some rather nasty special cases: especially if the new dive information has been loaded into an XML file with trips auto-generated, merging several of these kinds of xml files with multiple dives in several overlapping trips would completely confuse our previous code. In particular, auto-generated trips that had the exact same date as previous trips (because they were generated from the same dive computer) really confused the code that used the trip timestamp to manage the trips. Adding the helper functions allows us to get the general case right without having to have each piece of code that handles trip information having to bother about all the odd rules. It will eventually also allow us to make the dive trip data structures more logical: right now the dive trip list is largely designed around the odd gtk model handling, rather than some more higher-level conceptual relationship with the actual dives. But for now, this keeps all the data structures unchanged, and just modifies them using the new helper functions. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10Add support for obtaining salinity from libdivecomputerGravatar Dirk Hohndel
This requires a patched libdivecomputer that can return salinity of the water the dive was conducted in. Experimental patches exist that implement this for the OSTC. The code is designed so that it simply defaults to salt water if libdivecomputer doesn't include the feature. The patch also fixes the dive merge code to merge two other recent additions to the dive structure (surface_pressure and visibility). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10Add threshold feature for partial pressure graphsGravatar Dirk Hohndel
The tec diving preference pane now allows us to set a partial pressure threshold for each of the three gases. When the partial pressure surpasses that value, the graph becomes red. Fixes #12 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10Fix default filename handling errorsGravatar Linus Torvalds
The default filename handling is broken in two different ways: (a) if we start subsurface with a non-existing file, we warn about the inability to read that file, and then we exit without setting the default filename. This is broken because it means that if the user (perhaps by mistake, by pressing ^S) now saves the file, he will overwrite the default filename, even though that was *not* the file we read, and *not* the file that subsurface was started with. So just set the default filename even for a failed file open. The exact same logic is true of a failed parse of an XML file that we successfully opened. We do *not* want to leave the old default filename in place just because the XML parsing failed, and possibly then overwriting some file that was never involved with that failure in the first place. So just get rid of all the logic to push the filename saving into the XML parsing layer, it has zero relevance at that point. (b) if we do replace the default filename with a NULL file, we need to set that even if we cannot do a strdup() on the NULL. This fixes both errors. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10gtk spinbuttons are crazy - fix possible divide-by-zeroGravatar Linus Torvalds
When we fill the cylinder information in an imperial unit world, a working pressure of zero is a special case, and forces us to use the actual physical size of the cylinder in liter, despite the fact that we normally would use cuft. However, we compare that value against zero in a 'double', and in between going through the gtk spinbutton logic, the zero we have filled in then gets read out as some very tiny epsilon value from the gtk spinbuttons (typically in the 10**-317 range). This causes us to think that the zero isn't actually a zero, because gtk has done odd things with it. Fix this by calculating the millibar value (as an integer) first, and check that *integer* against zero. Any crazy epsilon values will have been rounded away, and our logic works again. There's a good reason why subsurface does everything using integers (ie the afore-mentioned "convert to integer millibar" etc) and doesn't use floating point for any core data structures, only for conversion. FP rounding and inexact behavior can be really subtle. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10Try to find optimal dive sample merge offsetGravatar Linus Torvalds
When we merge dives where the samples have come from different dive computers, the samples may be offset from each other due to the dive computers not having decided that the dive starts at quite the same time. For example, some dive computers may take a while to wake up when submerged, or there may be differences in exactly when the dive computer decides that a dive has started. Different computers tend to have different depths that they consider the start of a real dive. So when we merge two dives, look for differences in the sample data, and search for the sample time offset that minimizes the differences (logic: minimize the sum-of-square of the depth differences over a two-minute window at the start of the dive). This still doesn't really result in perfect merges, since different computers will give slightly different values anyway, but it improves the dive merging noticeably. To the point that this seems to have found a bug in our Uemis data import (it looks like the Uemis importer does an incorrect saltwater pressure conversion, and the data is actually in centimeter, not in pressure). So there is room for improvement, but this is at least a reasonable approximation and starting point. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10Merge branch 'ceiling-plot'Gravatar Dirk Hohndel
This enables plotting the ceiling in deco dives and also adds the necessary code to the uemis importer. The only other dive computer this has been tested with the OSTC and that needs a libdivecomputer patch in order to provide the deco/ceiling information to Subsurface. Fixes #5
2012-11-10Improve logic handling eventsGravatar Dirk Hohndel
We now throw away redundant events, just as we throw away other redundant data coming from the dive computer. Events are considered redundant if they are less than 61 seconds apart and identical. This also improves the display of the remaining events in the profile as we now show the value of the event, if it is present (for example for a deco event we show the duration of the deepest stop). Finally, for events that define a range (so they set the beginning flag and assume and end flag some time later) we no loger show the triangle but assume that some other code handles visualizing them (as happens for the ceiling events). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10Convert Uemis deco stop hold time to secondsGravatar Dirk Hohndel
This is actually stored in minutes (which seems odd, given they allocate 16 bits for it... how much deco do these people want to be prepared for??) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10Fix cut and paste error in an error messageGravatar Dirk Hohndel
This has been around for a loooong time, I just happened to stamble across it when reading the code... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10Use correct surface pressure to detect ceiling with Uemis ZurichGravatar Dirk Hohndel
The dive data contains the surface pressure prior to the dive, and that is what we need to compare p_amb_tol to, not the standard 1013mbar. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10Create the correct ceiling events for Uemis ZurichGravatar Dirk Hohndel
The hold_depth field is rather misleading as it normally gives the safety stop depth and only when the p_amb_tol goes "below the surface" does it switch to showing the first deco stop depth. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10Instead of the ugly red boxes make the surface come down to ceilingGravatar Dirk Hohndel
Based on suggestions from Linus (and a few iterations) we now simply have the surface (i.e., background color / pattern) come down to where the ceiling is. And we only do the angry red shading when the diver violates the ceiling. I think this looks much better. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10Ignore last dive read from Uemis when starting with empty divelistGravatar Dirk Hohndel
When the user closes the divelist and starts with an empty file it makes no sense to assume that she only wants to download new dives since the last time dives have been downloaded. So if the current divelist is empty we ignore that information and start from the beginning again. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10Add plotting of the deco ceilingGravatar Dirk Hohndel
Plot a red-shaded area on top of the depth profile to indicate the deco ceiling (i.e., the area into which it isn't save to ascend at this point of the dive. So far this is of very limited use as libdivecomputer doesn't give us the necessary information to plot this. I have sent patches for the OSTC to Jef, hoping that he will include them in an update. I don't know how many other dive computers will make this data available - I still need to add this to our native Uemis support. This commit also fixes two cut and paste errors in the previous commit 6540be9bd924 "Process ceiling events and store ceiling data in plot_info". Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10Process ceiling events and store ceiling data in plot_infoGravatar Dirk Hohndel
This just creates the infrastructure but doesn't yet do anything useful with the data. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-09Fix dive trip merging logicGravatar Linus Torvalds
We used to have very spotty logic for picking the dive trip when merging two dives. It turns out that that spotty logic almost never really matters, because in practice you'll never hit the situation of merging two dives with different dive trips, but it *can* happen. In particular, it happens when you use multiple dive computers, and end up loading the dives from one computer on top of the dives of your other computer. If the clocks of the dive computers was set sufficiently close to each other, the dive merging logic will kick in and you may now have slightly different times for the dives that get merged, and the trip merging logic got *really* confused. The trip management also depends on the trip dates being updated correctly when the dives associated with a trip are updated (whether added or removed), and the trip merging code did none of that. This fixes it all up. Hopefully correctly. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-07Fix partial pressure calculationGravatar Dirk Hohndel
The existing implementation failed on dive computers that did gas changes based on events (instead of tracking them in the sample data like the Uemis Zurich does that I tested the code with). This commit moves the calculations slightly later in create_plot_info() after the gas change events are processed and the plot_info data has been fixed up. Now this works with the data from Linus' Suunto as well. Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-06Merge branch 'po2'Gravatar Dirk Hohndel
Plotting pO2 / pN2 / PHe
2012-11-06Remove pN2 debug printout and add disabled code for partial pressure scaleGravatar Dirk Hohndel
The pN2 print shouldn't have been committed, but I don't want to try and rewrite all the commit history. Oh well. The pressure scale I am ambivalent about. It seems that it should be useful - but that would require guide lines that coincide with the values which would really throw off the visual for me. So I added the code, but left it disabled. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-06Don't print mean depth across the whole profile areaGravatar Dirk Hohndel
I can't remember why we initially did this instead of ending the horizontal red line whith the last data point of the pressure profile. But especially nuw with more graphs shown the one line that extends past the end of the dive looked really silly. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-06Be smarter about printing gas partial pressure textGravatar Dirk Hohndel
We always want to print absolute maxima and minima - but not when multiple consecutive data points all have the same value (this happens, for example, when printing a pHe plot on non-helium dives - or when the dive profile includes a brief surface intervall which causes all the partial pressures to be at their minimum). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-05Fine tune the vertical spacing of the graphsGravatar Dirk Hohndel
Whatever I pick here, there will be dives where the different graphs end up interfering with each other. I don't think there isn't an easy, generic solution for this (but I can envision awesome non-easy solutions - they just don't seem to be worth the effort). But for most dives that I played with this seems to work pretty well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-05Fix incorrect variable reuse bug in preferences dialogGravatar Dirk Hohndel
This was introduced in commit ee803ef5d85b "Change preferences into a notebook and add second page for tec settings" In order to be able to get the new default XML file name back from the button, we need to keep that variable around and not overwrite it with more buttons for the tec preferences page. Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-05Prevent UI errors while the the import thread is runningGravatar Lubomir I. Ivanov
While the import thread is running it is possible to: 1) click the [x] button of the "download dialog". To prevent that, we attach a "delete-event" signal to no-op function. 2) to interact with the main window, once the "accept" event is triggered. To prevent that, we make sure that the window is set back to "modal". Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-05Trim the device name in the download dialog, if necessaryGravatar Lubomir I. Ivanov
On Windows, device names can end up being <drive-letter> (<drive-label>). In such a case we are only interested in the <drive-letter> part, when passing this value to libdivecomputer. This patch provides a method to trim all text in parentheses and also any leading and trailing whitespace. An important addition is enabling back the user to enter a device manually even it's absent in the combo box list. This device is then stored and retrieved as the default device, but not stored in the device list (dc_device_selector()). As a side effect this change prevents the download dialog closing, when a user-entered device is not one of the found devices via subsurface_fill_device_list(). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-05Repair broken Add Dive menu itemGravatar Henrik Brautaset Aronsen
Lubomir's commit aec904b612cbee57f8bb5c3289a120b69c9ade24 broke the Add Dive menu item: The Edit Dive dialogue didn't show up after the initial dialogue. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-05Fix broken MacOSX buildGravatar Henrik Brautaset Aronsen
Dirk's commit 2de6f796354ad029e9e786027210fcf1b02868e2 had a typo. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-05Spanish translation fixes.Gravatar Pablo Garcia Castro
Signed-off-by: Pablo Garcia Castro <freixido@gmail.com Signed-Off-By: Matthias Kaehlcke <matthias@kaehlcke.net> Signed-off-by: Jose Angel Tortosa Delfa <angeltordel@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-05Plot text values for partial pressure graphsGravatar Dirk Hohndel
The algorithms attempt to identify "interesting" points where the user might want to know the value of the graph. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-01Add pHe and pN2 plottingGravatar Dirk Hohndel
Adjust the color for pN2 to the standard for this gas (black). We keep pO2 green (even though the ISO 32 color for that would be white). pHe is marked in brown (which is the matching standard color). Calculate correct partial pressures for the synthetic plot info points at the beginning and end of the dive. Minor fine tuning to the positioning / scaling of the temperature plot when partial pressures are plotted. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-01Fix the pO2 calculation when diving with airGravatar Dirk Hohndel
So few of my dives are on air that at first I didn't notice - but for those dives we set the o2 permille to 0 - which of course causes incorrect (and extremely deadly) pO2 of 0... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-01Add vertical space to depth plot if we are showing partial pressure graphsGravatar Dirk Hohndel
Fairly simplistic change that modifies the way we calculate the "maxdepth" for a particular dive as that is used to scale the plot vertically. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-01Change preferences into a notebook and add second page for tec settingsGravatar Dirk Hohndel
Not sure this is the best naming scheme (General Settings / Tec Settings) but it's a start. The idea is to have the settings that a recreational diver might care about on the first page, and all the other stuff on the second one. Let's see how this works out long term. For now I moved OTU over and added toggles for the different partial pressure graphs (only the pO2 one is implemented so far). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-01First stab at plotting a pO2 graphGravatar Dirk Hohndel
So far this is done unconditionally. This already starts some of the infrastructure for other gases, but so far only O2 is handled. We also need a pressure scale on the right to make this useful - or we need to do peek / trough pressure prints like we do for temperature and depth. Finally, I think I want to move the plot further down, maybe make the whole plot area taller if we are plotting partial gas pressures as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-31Merge branch 'dc-device-selector'Gravatar Dirk Hohndel
Bring the device selector (when downloading from a dive computer) into master.
2012-10-31Show drive name after the drive letter on WindowsGravatar Dirk Hohndel
In the device selector when downloading from a divecomputer add the drive name that we have been looking for (so far that's only "UEMISSDA") to the drive letter - this should make it easier for people to figure out why there is a drive letter offered as an option. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-29windows.c: added device retrieval from subsurface_fill_device_list()Gravatar Lubomir I. Ivanov
subsurface_fill_device_list() now goes trough the list of registry entries in the SERIALCOMM key and adds all present values (such as COM1, COM2) to a GtkListStore. Once done the function compares all logic drive label to a static list of known DC labels, such a 'UEMISSDA', which is the only present one at the moment and adds any matching drive letters (e.g. C:\, H:\) to the list store as well. If no serial ports were added or no matching logical drives were found the function simply adds a default entry named "COM1". Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>