summaryrefslogtreecommitdiffstats
path: root/profile.c
AgeCommit message (Collapse)Author
2012-12-26Add settings section to XML file format and store dive computer IDsGravatar Dirk Hohndel
We only store the model/deviceid/nickname for those dive computers that are mentioned in the XML file. This should make the XML files nicely selfcontained. This also changes the code to consistently use model & deviceid to identify a dive computer. The deviceid is NOT guaranteed to be collision free between different libdivecomputer backends... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-21Remove nickname from divecomputer data structureGravatar Dirk Hohndel
Having it there with the model information seemed to make sense but on second thought it's the wrong spot to keep that information, especially since we were storing it in the XML file in every single dive. This change removes the nickname member from the divecomputer and makes the rest of the code reasonably self consistent. It does not add much of the new code for the new design to handle nicknames. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-17Add a "View next dive computer" menu itemGravatar Linus Torvalds
This adds the capability to actually view all your dive computers, by adding a menu item under "Log"->"View"->"Next DC" to show the next dive computer. Realistically, if you actually commonly use this, you'd use the accelerator shortcut. Which right now is Ctrl-C ("C for Computer"), which is probably a horrible choice. I really would want to have nice "next/prev dive" accelerators too, because the cursor keys don't work very well with the gtk focus issues. Being able to switch between dives would also make the "just the dive profile, maam" view (ctrl-2) much more useful. The prev/next dive in the profile view should probably be done with a keyboard action callback, which also avoids some of the limitations of accelerators (ie you can make any key do the action). Some gtk person, please? Anyway, this commit only does the dive computer choice thing, and only using the accelerators. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16Improve visual appearance of horizontal marker linesGravatar Dirk Hohndel
This changes two things to improve the appearance of the profile: - the partial pressure scale is now in 0.5 increments if the total is <= 4 and in 1.0 increments if it is > 4. - the depth marker lines end slightly below the depth chart so that we no longer have overlap between the depth scale and the partial pressure scale. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-16Attempt to free plot data entries in each call to create_plot_info()Gravatar Lubomir I. Ivanov
In profile.c:create_plot_info(), store the last address in which memory was allocated for the plot data entries in the static variable "last_pi_entry". If "last_pi_entry" isn't a NULL pointer in each call to create_plot_info(), free memory at that address. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-13Add the ability to set a nickname for a dive computerGravatar Dirk Hohndel
We maintain a list of dive computers that we know about (by deviceid) and their nicknames in our config. If the user downloads dive from a dive computer that we haven't seen before, we give them the option to set a nickname for that dive computer. That nickname is displayed in the profile (and stored in the XML file, assuming it is not the same as the model). This implementation attempts to make sure that it correctly deals with utf8 nicknames. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-11Only display a depth scale appropriate for the depth of the diveGravatar Dirk Hohndel
Showing the depth scale all the way to the bottom of the profile plot looks strange when there are partial pressure graphs down there. So instead we only plot down to the next marker below the maximum depth of the actual dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-11Show CNS value in the profile mouseoverGravatar Dirk Hohndel
If we have per-sample CNS values, then show them in the profile tooltip. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-11Merge branch 'cns' into cns-mergeGravatar Dirk Hohndel
I foolishly changed visible_columns in both the (ill-named) cns branch and master... Signed-off-by: Dirk Hohndel <dirk@hohndel.org> Conflicts: divelist.c gtk-gui.c profile.c
2012-12-11Calculate dive maxima/minima independent of dive computerGravatar Linus Torvalds
This splits the dive time, depth, pressure and temperature maxima and minima setup from the per-dive-computer "create_plot_info()" function into one setup function that walks _all_ the dive computers, so that we have a global maxima and minima. That way the graph scaling we set up will now fit the data from all dive computers rather than just the particular one we are plotting. So if you switch back-and-forth between computers, the scale (which is defined by the extremes) remains the same. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-10Don't draw tooltips if no profile is displayedGravatar Dirk Hohndel
This fixes ticket 33 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-10Move global variables covered by Preferences into one structureGravatar Dirk Hohndel
Now we can simply remember the state of all the preferences at the beginning of preferences_dialog() and restore them if the user presses 'Cancel'. Fixes #21 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-09Don't print partial pressure values in the profileGravatar Dirk Hohndel
Instead provide a scale on the right in a highly transparent grey and rely on the tooltip available with mouse-over to pinpoint the value at certain spots with much better accuracy. Fixes #30 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-08Don't print an initial gaschange event that just tells us the gas usedGravatar Dirk Hohndel
Some dive computers appear to tell us the gas used in a gaschange event right at the beginning of the dive. We arbitrary have a cut-off that says "a gas change in the first 30 seconds shouldn't get a marker". Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-08Correct partial pressure calculationsGravatar Dirk Hohndel
Regardless what the dive computer tells us, don't believe that pO2 was higher than the ambient pressure. This gives much more realistic values. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-08Correctly parse the two different gas change eventsGravatar Dirk Hohndel
This now takes the He percentage into account when matching tanks. Given the encoding of fO2 and fHe in the GASCHANGE2 event, we can simply mask and shift as if we have a GASCHANGE2 event and things will automatically work correctly for the regular GASCHANGE event. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-08Draw pO2 profile lastGravatar Dirk Hohndel
This way it sits on top of the other partial pressure plots and is a bit easier to read. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-08Show two decimal digits in pO2, pN2 and pHe in the tooltipGravatar Dirk Hohndel
Tec divers seem to like a little bit more precision - and the dive computers certainly provide it (or we can calculate it). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-07Plot pO2 graph based on sample information, if availableGravatar Dirk Hohndel
This should give closed circuit divers with a supported dive computer correct partial pressure plots. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-07Add option to make ceiling visually stand out more in the profileGravatar Dirk Hohndel
While having the background "come down" seemed like a good visualization of the ceiling, some divers appear to prefer something more dramatic. This adds an option to the Tec Settings to have the ceiling shown in red instead of the default background color. Suggested-by: Jan Schubert <Jan.Schubert@GMX.li> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-07Move partial pressure plots up slightlyGravatar Dirk Hohndel
This way they don't clash with the dive computer model information that was added by commit a23ec27ca7bb "Add dive computer name to the dive plot". Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-07Move 'plot_info' into 'struct graphics_context'Gravatar Linus Torvalds
.. and then allocate just the plot-info entry array dynamically. We want to have a longer lifetime for the basic plot_info data structure, because we want to do computer selection and maximum time/depth/temperature computations *before* we start plotting anything, and before we allocate the plot entry array. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-07Add dive computer name to the dive plotGravatar Linus Torvalds
I want to have some way to show multiple dive computers, so start off by adding the name of the current one. So if we change dive computers, we'll see it. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-04Improve deco handling and add NDL supportGravatar Dirk Hohndel
This commit changes the code that was recently introduced to deal with deco ceilings. Instead of handling these through events we now store the ceiling (which in reality is the deepest deco stop with all known dive computers) and the stop time at that ceiling in the samples. This also adds support for NDL (non stop dive limit) which both dive computers that appear to give us ceiling / deco information appear to give us as well (when the diver isn't in deco). If the mouse hovers over the profile we now add support for displaying the NDL, the current deco obligation and (if we are able to tell from the data) whether we are at a safety stop. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-28Updating events for libdivecomputer 0.3 (and tracking uemis support)Gravatar Dirk Hohndel
I was a little too eager to add the deco feature to Subsurface. Jef and I went back and forth a few more times and the definition of those events changed. I guess I shouldn't have commited that code until the corresponding libdivecomputer code had been pushed. This commit now brings us in sync with the current master of libdivecomputer (but should compile with 0.2 as well - only deco events won't work then). One issue that I see is that deco / ndl aren't really a good fit for the event model. I actually disabled the drawing of the little yellow triangles for ndl events as for example on the Uemis those events are created whenever the remaining non stop time changes - and that can be every few seconds. The correct solution may be to treat this as a function of the samples, but for now this works and is tested with both OSTC and Uemis SDA. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-26Fix dive computer event handling if there are no samplesGravatar Linus Torvalds
This actually triggers for one of our insane test dives (test15): it has no samples, so we created a fake dive computer entry with the a fake profile in it, but we didn't copy the events over. Having a dive with no samples, yet having events from the dive computer, sounds pretty bogus. But that test-case did show that when that bogus situation happens, we had two independent buglets: (a) we didn't insert the entries in the fake dive computer entry we used and (b) we would then mix up the events of the fake dive computer entry with the first dive computer of a dive. Fix this, just to make test15 happy again. And eventually, when we actually plot the information for multiple dive computers, fixing case (b) would become necessary even for real dives. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-23Move events and samples into a 'struct divecomputer'Gravatar Linus Torvalds
For now we only have one fixed divecomputer associated with each dive, so this doesn't really change any current semantics. But it will make it easier for us to associate a dive with multiple dive computers. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-12Tweak partial pressure plot to avoid printing values ontop of eachh otherGravatar Dirk Hohndel
This still can look too busy on shallow long dives with moderate vertical movement. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-12Improve visual appearance of temperature plotGravatar Dirk Hohndel
Prervent tiny temperature changes from being exaggerated in the plot. Also, shift pressure plot around a bit (if necessary) to prevent it from ending in the same space as the temperature plato on the profile graph. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-11Handle dives without samples correctlyGravatar Dirk Hohndel
The code in commit f99e1b476b18 "Trim the dive to exclude surface time at beginning and end" failed rather badly if a dive has no samples at all - which is true for many of our test dives. This makes sure that we don't exclude data points if we never set up start and end times. Reported-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-11Add back mysteriously deleted "} else {" lineGravatar Linus Torvalds
Commit 6c52e8a2e516 ("Add plotting of the deco ceiling") for some totally unexplained reason deleted one "else" statement, resulting in some plot events not having a time at all. Which causes various really odd issues if you hit that situation, including divide-by-zero etc due to the difference in times between events being nonsensical. It's just some odd mistake that was entirely unrelated to the other changes in that commit. Add the missing line back in. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-11Add more data to our tool-tip display in the profile windowGravatar Dirk Hohndel
This shows the values for all the graphs that are shown (depth, temperature, tank pressure, pO2, pN2m pHe), but also correctly doesn't display them when they are turned off or no data is available (prior to this commit, tank pressure was always shown, even if no pressure samples were available for the dive). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-11Fix possible array bound violation for insanely long divesGravatar Linus Torvalds
When we calculate the interval for the tick-marks for the dive, we need to limit 'i' to be within the size of the array. The code does that with a "i < 8" check, but the fact is, we must never increment past the last entry, which is 7 (the size of the array is 8, but the last valid index is 7). This only happens for unrealistically long dives. Which you can trigger either by inputting insane values for a manually created dive, or by merging two dives that are consecutive, but not close to each other time-wise (eg on different days ;) Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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-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-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-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-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-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-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-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-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-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>