summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2013-01-06Fix pressure_time calculation for SAC-rateGravatar Linus Torvalds
The code was using bar, not atm to calculate the pressure_time multiplier. But SAC-rate is relative to atm. We could do the correction at the end (and keep the pressure_time in "bar-seconds"), but let's just use the expected units during the integration. Especially since this also makes a helper function to do the calculations (with variables to keep the units obvious) instead of having multi-line expressions that have the wrong units. This fixes what I thought were rounding errors for the pressure graphs. They were just unit confusion. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-06Split up and re-organize the plot entry calculationsGravatar Linus Torvalds
This splits up the (very complex) function that calculates all the plot info data, so that the gas pressure logic is in several helper functions, and the deco and partial pressure calculations are in a function of their own. That makes the code almost readable. This also changes the cylinder pressure calculations so that if you have manually set the beginning and end pressures, those are the ones we will show (by making them fake "sensor pressures"). We used to shopw some random pressure that was related to the manually entered ones only distantly (through various rounding phases and the SAC-rate calculations). That does make the rounding errors more obvious in the graph, but we can fix that separately. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-06Display dive profile of the dive we plan, as we plan itGravatar Dirk Hohndel
As the user enters data into the entry fields, that data is validated and as soon as there is enough data we start constructing a dive profile, including the final ascent to the surface, including required deco stops, etc. This commit still has some serious issues. - when data is input that doesn't validate, we just print a warning to stdout - instead we need to change the backgroundcolor of the input field or something. - when we switch to the last dive in order to show the profile we don't actually search for the last dive - we just show the first one in the tree. This works for the default sort order but is of course wrong otherwise I'm sure there are many other bugs, but I want to push it out where it is right now for others to be able to take a look. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-06Remove Linus' plan input UIGravatar Dirk Hohndel
This was added in commit 594da00612ab "Do a minimal hook-up of the dive plan tree view to the actual planning" and has been replaced by a different UI in subsequent commits. No point in keeping it around. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-06Do a better job at creating plot info entriesGravatar Linus Torvalds
This simplifies - and improves - the code to generate the plot info entries from the samples. We used to generate exactly one plot info entry per sample, and then - because the result doesn't have high enough granularity - we'd generate additional plot info entries at gas change events etc. Which resulted in all kinds of ugly special case logic. Not only for the gas switch, btw: you can see the effects of this in the deco graph (done at plot entry boundaries) and in the gas pressure curves. So this throws that "do special plot entries for gas switch events" code away entirely, and replaces it with a much more straightforward model: we generate plot entries at a minimum of ten-second intervals. If you have samples more often than that, you'll get more frequent plot entries, but you'll never get less than that "every ten seconds". As a result, the code is smaller and simpler (99 insertions, 161 deletions), and actually does a better job too. You can see the difference especially in the test dives that only have a few entries (or if you create a new dive without a dive computer, using the "Add Dive" menu entry). Look at the deco graph of test-dive 20 before and after, for example. You can also see it very subtly in the cylinder pressure curves going from line segments to curves on that same dive. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-06Add the ability to cache our deco stateGravatar Dirk Hohndel
We kept reduing all the deco calculations, including the previous dives (if any) for each segment we add to the dive plan. This simply remembers the last stage and then just adds to that. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-06Planner: hook the gas combo box to a "focus-out" event handlerGravatar Lubomir I. Ivanov
GTK's logic might be a bit flawed (or complicated) in terms of "focus-out-event" and GtkComboBoxEntry objects as it does not work by attaching said signal type directly to the GtkComboBoxEntry. Perhaps it only makes sense for text input. Since "focus-out-event" works for GtkEntry, we can retrieve the child GtkEntry from the combo using gtk_bin_get_child(GTK_BIN(combo) and attach the event handler to that. This change should make it possible to update gas_model (GtkListStore) when changing the widget focus with both the keyboard and mouse clicks. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-05Make the dive plan input much more compactGravatar Dirk Hohndel
Have the frames just for the top row and get rid of all of the extra space in the layout. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-05Add new gases to the combo box in dive plan entryGravatar Dirk Hohndel
Once again Gtk does everything it can to make our lives miserable. It requires major hackery to be able to add new gases to the drop down lists "on the fly". Right now this only works if you edit the gas and then use Tab to move to the next field. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-05Make the 'Add waypoint' button work in the Input Plan dialogGravatar Dirk Hohndel
Just after pushing out the last set of changes I had one more idea what I could try. And of course that was it. Don't queue up a redraw. Simply run gtk_widget_show_all on the dialog! That does the trick. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-05Different widget to input the planGravatar Dirk Hohndel
Linus' treeview for the plan input is just too ugly for words. And doesn't work, either. So let's go with plan C: a table of waypoint entries. Depth, duration (or absolute time), and gas used. The gas is a combobox that does completion. I am reusing Linus' validation functions / parsers. This works if you can fit your dive into the four waypoints that are there by default. The add waypoint button is hooked up but even though it does what I think should modify the dialog that is currently displayed that clearly doesn't work. But at least it "mostly" works and isn't as horrifyingly uggly as the first two attempts. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-05Do a minimal hook-up of the dive plan tree view to theGravatar Linus Torvalds
actual planning Yes, you can actually enter your segments now. No, it's not wonderfully user-friendly. If you don't enter enough segments to create a dive plan, it will just silently fail, for example. And the <tab> key that should get you to the next editable segment doesn't. And so on. But it kind of works. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-05Create the infrastructure for a dive plannder based on a tree-modelGravatar Linus Torvalds
This doesn't actually do the real work yet, but it creates all the infrastructure to edit a tree model, and verify the contents for time, depth and gas mix. Now we just need the ability to add entries to the tree model (this adds one fake one, just to test the editing), and then read out the final end result and turn it into a plan. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-05Stub out a few things for a plan input UIGravatar Dirk Hohndel
This is not doing anything (which is why there are so many unused variable warnings). It's just a couple of entries lined up to give a visual impression how some of this could look. I am not a UI designer. And there are good reasons for that... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-05Fix bug in smooth ceiling modeGravatar Dirk Hohndel
The ceiling calculations for the gradient factors still had a 3m increment hardcoded. This is now also conditional on the smooth parameter. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-05Fix profile display for dives with no samplesGravatar Linus Torvalds
For dives with no samples, we crate a fake dive computer with a set of made-up samples and use those to display the profile. However, the actual calculations to do the maximum duration and depth etc were always done with the "real" dive information, which is empty. As a result, the scale of the plot ended up being bogus, and part of the dive would be missing. Trivially fix by just passing the same dive computer information to calculate_max_limits() that we use for everything else. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-04First stab at simplistic dive planningGravatar Dirk Hohndel
This comes with absolutely no gui - so the plan literally needs to be compiled into Subsurface. Not exactly a feature, but this allowed me to focus on the planning part instead of spending time on tedious UI work. A new menu "Planner" with entry "Test Planner" calls into the hard-coded function in planner.c. There a simple dive plan can be constructed with calls to plan_add_segment(&diveplan, duration, depth at the end, fO2, pO2) Calling plan(&diveplan) does the deco calculations and creates deco stops that keep us below the ceiling (with the GFlow/high values currently configured). The stop levels used are defined at the top of planner.c in the stoplevels array - there is no need to do the traditional multiples of 3m or anything like that. The dive including the ascents and deco stops all the way to the surface is completed and then added as simulated dive to the end of the divelist (I guess we could automatically select it later) and can be viewed. This is crude but shows the direction we can go with this. Envision a nice UI that allows you to simply enter the segments and pick the desired stops. What is missing is the ability to give the algorithm additional gases that it can use during the deco phase - right now it simply keeps using the last gas used in the diveplan. All that said, there are clear bugs here - and sadly they seem to be in the deco calculations, as with the example given the ceiling that is calculated makes no sense. When displayed in smooth mode it has very strange jumps up and down that I wouldn't expect. For example with GF 35/75 (the default) the deco ceiling when looking at the simulated dive jumps from 16m back up to 13m around 14:10 into the dive. That seems very odd. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-04Correctly handle air in the deco codeGravatar Dirk Hohndel
We mark air with o2.permille = 0. But it's actually 20.9% O2. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-04Clean up DEBUG codeGravatar Dirk Hohndel
It's still a mess (and the symbols aren't used consistently), but it's a tiny bit more logical... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-04Make sure that the calculated deco ends at 0Gravatar Dirk Hohndel
Without this the cairo_close_path call could do silly looking things (intersecting polygons...). Reported-by: "Robert C. Helling" <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-04Fix deco calculations to correctly use GF values and add CC supportGravatar Dirk Hohndel
The old implementation was broken in several ways. For one thing the GF values are percentages, so they should normally be 0 < GF < 1 (well, some crazy people like to go above that). With this most of the Bühlmann config constants were wrong. Furthermore, after we adjust the pressure tolerance based on the gradient factors, we need to convert this back into a depth (instead of passing back the unmodified depth - oops). Finally, this commit adds closed circuit support to the deco calculations. Major progress and much more useful at this stage. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-04Intercept all events to the GF fields in the property dialogGravatar Dirk Hohndel
This seems like a strange way to capture the FOCUS_CHANGE event, but manually trying to register a callback for it fails. Yet registering a callback for every event and then filtering for FOCUS_CHANGE in the callback works. Go figure. But with this commit you can actually change the GF settings in the preferences dialog and once you tab out of the entry field the change gets immediately applied - nice to play with the effects of changing GF values. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-03Merge branch 'deco2'Gravatar Dirk Hohndel
Bringing in the first attempts to do our own deco calculations
2013-01-03Improvements to select_prev_dive() and select_next_dive()Gravatar Lubomir I. Ivanov
There were some minor problems when moving the selection cursor around: 1) If the selection was larger than 1, it was possible for the selection to get "stuck" in the middle of the list. This patch approaches this by always calling gtk_tree_selection_unselect_all() before gtk_tree_selection_select_iter(), or simply always making sure we have one selected iterator when navigating with the keys. 2) When there was a single top level dive before the first trip it wasn't possible to navigate trough the child dives of said trip in both directions. The patch attempts to fix this by having the hunks/checks: if (idx < 0) { (idx is of a trip) performed regardless of other conditions. *** Note: testing was done by importing all test*.xml dives with auto-group on. [Dirk Hohndel: adjusted the patch to also fix on_key_press to only grab the key if no modifier key is pressed; otherwise this breaks shift-cursor-keys for selecting multiple dives.] Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-03Fix cylinder printout informationGravatar Linus Torvalds
If we print out the pressure difference (because we do not have a cylinder size), we didn't initialize the precision. We should print out pressures without decimals. The attached patch fixes that, and also avoids a NULL pointer printout (which on Linux will just print out "(null)") if there is no cylinder type descriptor string. It also cleans things up a bit and uses the "cyl" pointer instead of repeating the "dive->cylinder[n]" thing. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-03Make GF values configurableGravatar Dirk Hohndel
There are a couple of issues with this commit: GtkEntry should emit the 'changed' signal when it is modified (so that changes in the preferences get applied right away) - but that doesn't appear to be working consistently. Also, this doesn't appear to affect the deco of any dives that I try it with. So my guess is something is wrong with the underlying deco algorithm. That's diappointing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-03Consider previous dives when calculating decoGravatar Dirk Hohndel
This also initializes the N2 tissue saturations to correct numbers (setting them to zero was clearly silly). With this commit we walk back in the dive_table until we find a surface intervall that's longer than 48h. Or a dive that comes after the last one we looked at; that would indicate that this is a divelist that contains dives from multiple divers or dives that for other reasons are not ordered. In a sane environment one would assume that the dives that need to be taken into account when doing deco calculations are organized as one trip in the XML file and so this logic should work. One major downside of the current implementation is that we recalculate everything whenever the plot_info is recreated - which happens quite frequently, for example when resizing the window or even when we go into loup mode. While this isn't all that compute intensive, this is an utter waste and we should at least cache the saturation inherited from previous dives (and clear that number when the selected dive changes). We don't want to cache all of it as the recreation of the plot_info may be triggered by the user changing equipment (and most importantly, gasmix) information. In that case the deco data for this dive does indeed have to be recreated. But without changing the current dive the saturation after the last surface intervall should stay the same. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-03Use gradient factors in deco calculationGravatar Dirk Hohndel
Usually dive computers show the ceiling in terms of the next deco stop - and those are in 3m increments. This commit also adds the ability to chose either the typical 3m increments or the smooth ceiling that the Bühlmann algorithm actually calculates. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-03Add configurable visualization of calculated ceilingGravatar Dirk Hohndel
This is on top of the deco information reported by the dive computer (in a different color - currently ugly green). The user needs to enable this via the Tec page of the preferences. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-03First stab at deco calculationsGravatar Dirk Hohndel
This seems to give us roughly the right data but needs a lot more testing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-03Fix cylinder printout informationGravatar Linus Torvalds
The cylinder information in the printouts was wrong in many ways. As Dirk noted, it didn't work at all for air-integrated computers that had the pressures in the samples, but the math was also confusing and wrong. This should fix it. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-03Rewrite the nickname replacement functionGravatar Dirk Hohndel
This function had a couple of bugs. Two different off by one errors and on top of that it was matching only the deviceid instead of model and deviceid. So I simply rewrote it to match against the full pattern and take a much more straight forward approach to replacing the entry for the divecomputer under consideration. If the new nickname is entry this implementation allocates one extra byte - but that didn't seem worth the extra code to fix it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-02Limit to 4 the number of cylinders shown in the data frameGravatar Salvador Cuñat
For dives with more than 4 cylinders, the frame got very crowded and we needed a magnifier to see the numbers. If we used more than four tanks, let's put the info in another frame, if not, print the OTUs, the maxcns and the weight sytem in the new frame. There is still room for two more short data. Changed naming of nitrox and trimix mixes. Changed cylinder description. There are issues with the size of some translations. Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-02Use old style (pre gtk-2.22) keysymsGravatar Dirk Hohndel
And include the compatibility header to build on newer versions. Reported-by: Salvador Cuñat <salvador.cunat@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-02Fix mixed dive/trip tree model groupingGravatar Linus Torvalds
In commit 96db56f89c76 ("Allow overlapping (and disjoint) dive trips") I allowed dives to be part of arbitrary dive trips regardless of date, which meant that the divelist tree model code needed to find the right parent for a dive as it was inserted. That code stupidly assumed that the top level of the dive list tree containted *only* trips, which is not at all the case. It happens to be true if you group all your dives into divetrips (the common case for autogroup=1, which real users do tend to have), but now that Dirk made the autogrouping be a per-xml-file setting, it became much easier to trigger the "mixed trips and non-trip dives" case, and that showed the stupid bug with the test dives. So instead of just blindly iterating to the 'n'th entry, search for the actual entry that is the dive trip we want to associate a dive with. Reported-by: Lubomir Ivanov <neolit123@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-01Treat headings properly when importing Suunto logsGravatar Miika Turkia
This patch will convert a heading bookmark to Subsurface format. Suunto's bookmark uses "Heading: <degrees>°" format and was previously set as the full event name. Now the resulting event will look like: <event name="heading" value="333" time="0:58 min"/> Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-01Keep the selected dive visible in the divelistGravatar Linus Torvalds
This patch makes the divelist behave more as you would expect it as you scroll up and down through its entries. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-01Remove autogroup from the preferences and store per file insteadGravatar Dirk Hohndel
Having two spots to toggle autogroup had always been a clear sign of insanity. The inconsistent ludicrous semantic of when we remembered the state of autogroup was even worse. This finally gets rid of that disaster and drops the autogroup setting from the preferences and makes it instead a per file property. When you save a file, it saves the state of the autogroup toggle. This seems much more useful - you may have files where you want to create trips by default. And others, where you don't. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-01Make sure remember_dc has its own copy of the model stringGravatar Dirk Hohndel
When called from the parser the model string is freed right after passing it to remember_dc. So we need to get our own copy. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-01Add ability to remove a divecomputer from our data structuresGravatar Dirk Hohndel
Right now this isn't used but it will be needed for the yet to be written UI to manage our divecomputer database. This commit also fixes an oversight in the remember_dc function. Updates to nicknames weren't committed to the config. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-01Merge branch 'updown'Gravatar Dirk Hohndel
Bring in the keyboard handling change
2013-01-01Use the Left and Right keys to switch between divecomputersGravatar Dirk Hohndel
The existing code had the somewhat retarded Ctrl-C binding for displaying the next divecomputer and no way to go back to the previous one. With this commit we use our keyboard grab to map Left and Right to previous and next divecomputer. Much nicer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-01Clear divecomputer saved status before saving the nicknames to XMLGravatar Dirk Hohndel
In commit c7169bd24f22 "Fix nickname saving in XML file to deal with utf8 characters" I added the helper function to clear the "this divecomputer has already been saved"-flag. But then forgot to call it from save_dives before saving the divecomputer nicknames. Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-01First step towards grabbing keys and handling them ourselvesGravatar Dirk Hohndel
This commit steals the cursor up and down keys away from gtk so regardless where gtk thinks the focus may be, we can still use the keys to change between dives. In the current UI design where all editing happens in separate windows this works as expected, as we only grab the keys for the main window. If we manage to re-enable in-place editing then we need to make sure that this doesn't cause problems (as gtk uses up/down for the ability to change drop down selections in combo boxes or values in spin buttons. So we must make sure that we stop stealing these keys once we start editing something (in which case simply switching to the next/prev dive wouldn't be a good thing, anyway). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-30First step in cleaning up cylinder pressure sensor logicGravatar Linus Torvalds
This clarifies/changes the meaning of our "cylinderindex" entry in our samples. It has been rather confused, because different dive computers have done things differently, and the naming really hasn't helped. There are two totally different - and independent - cylinder "indexes": - the pressure sensor index, which indicates which cylinder the sensor data is from. - the "active cylinder" index, which indicates which cylinder we actually breathe from. These two values really are totally independent, and have nothing what-so-ever to do with each other. The sensor index may well be fixed: many dive computers only support a single pressure sensor (whether wireless or wired), and the sensor index is thus always zero. Other dive computers may support multiple pressure sensors, and the gas switch event may - or may not - indicate that the sensor changed too. A dive computer might give the sensor data for *all* cylinders it can read, regardless of which one is the one we're actively breathing. In fact, some dive computers might give sensor data for not just *your* cylinder, but your buddies. This patch renames "cylinderindex" in the samples as "sensor", making it quite clear that it's about which sensor index the pressure data in the sample is about. The way we figure out which is the currently active gas is with an explicit has change event. If a computer (like the Uemis Zurich) joins the two concepts together, then a sensor change should also create a gas switch event. This patch also changes the Uemis importer to do that. Finally, it should be noted that the plot info works totally separately from the sample data, and is about what we actually *display*, not about the sample pressures etc. In the plot info, the "cylinderindex" does in fact mean the currently active cylinder, and while it is initially set to match the sensor information from the samples, we then walk the gas change events and fix it up - and if the active cylinder differs from the sensor cylinder, we clear the sensor data. [Dirk Hohndel: this conflicted with some of my recent changes - I think I merged things correctly...] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-30Fix nickname saving in XML file to deal with utf8 charactersGravatar Dirk Hohndel
This makes the whole code much cleaner and simpler. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-30Allow overlapping (and disjoint) dive tripsGravatar Linus Torvalds
We used to have the rule that a dive trip has to have all dives in it in sequential order, even though our XML file really is much more flexible, and allows arbitrary nesting of dives within a dive trip. Put another way, the old model had fairly inflexible rules: - the dive array is sorted by time - a dive trip is always a contiguous slice of this sorted array which makes perfect sense when you think of the dive and trip list as a physical activity by one person, but leads to various very subtle issues in the general case when there are no guarantees that the user then uses subsurface that way. In particular, if you load the XML files of two divers that have overlapping dive trips, the end result is incredibly messy, and does not conform to the above model at all. There's two ways to enforce such conformance: - disallow that kind of behavior entirely. This is actually hard. Our XML files aren't date-based, they are based on XML nesting rules, and even a single XML file can have nesting that violates the date ordering. With multiple XML files, it's trivial to do in practice, and while we could just fail at loading, the failure would have to be a hard failure that leaves the user no way to use the data at all. - try to "fix it up" by sorting, splitting, and combining dive trips automatically. Dirk had a patch to do this, but it really does destroy the actual dive data: if you load both mine and Dirk's dive trips, you ended up with a result that followed the above two technical rules, but that didn't actually make any *sense*. So this patch doesn't try to enforce the rules, and instead just changes them to be more generic: - the dive array is still sorted by dive time - a dive trip is just an arbitrary collection of dives. The relaxed rules means that mixing dives and dive trips for two people is trivial, and we can easily handle any XML file. The dive trip is defined by the XML nesting level, and is totally independent of any date-based sorting. It does require a few things: - when we save our dive data, we have to do it hierarchically by dive trip, not just by walking the dive array linearly. - similarly, when we create the dive tree model, we can't just blindly walk the array of dives one by one, we have to look up the correct trip (parent) - when we try to merge two dives that are adjacent (by date sorting), we can't do it if they are in different trips. but apart from that, nothing else really changes. NOTE! Despite the new relaxed model, creating totally disjoing dive trips is not all that easy (nor is there any *reason* for it to be easty). Our GUI interfaces still are "add dive to trip above" etc, and the automatic adding of dives to dive trips is obviously still based on date. So this does not really change the expected normal usage, the relaxed data structure rules just mean that we don't need to worry about the odd cases as much, because we can just let them be. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-30Update deco handlingGravatar Dirk Hohndel
This commit makes deco handling in Subsurface more compatible with the way libdivecomputer creates the data. Previously we assumed that having a stopdepth or stoptime and no ndl meant that we were in deco. But libdivecomputer supports many dive computers that provide the deco state of the diver but with no information about the next stop or the time needed there. In order to be able to model this in Subsurface this adds an in_deco flag to the samples. This is only stored to the XML file when it changes so it doesn't add much overhead but will allow us to display some deco information on dive computers like the Atomic Aquatics Cobalt or many of the Suuntos (among others). The commit also removes the old event based deco code that was commented out already. And fixes the code so that the deco / ndl information is stored for the very last sample as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-30Add time stamp to the debugging printout of vendor specific samplesGravatar Dirk Hohndel
They are useful for debugging things in libdivecomputer and this way it's easier to match the data to specific points in the dive profile. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-29Make the tooltip text for gaschange events more informativeGravatar Dirk Hohndel
We now print out "air", "nn% O2", or "(nn/xx)" for trimix. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>