aboutsummaryrefslogtreecommitdiffstats
path: root/profile.c
AgeCommit message (Collapse)Author
2012-10-11Conversion to gettext to allow localizationGravatar Dirk Hohndel
This is just the first step - convert the string literals, try to catch all the places where this isn't possible and the program needs to convert string constants at runtime (those are the N_ macros). Add a very rough first German localization so I can at least test what I have done. Seriously, I have never used a localized OS, so I am certain that I have many of the 'standard' translations wrong. Someone please take over :-) Major issues with this: - right now it hardcodes the search path for the message catalog to be ./locale - that's of course bogus, but it works well while doing initial testing. Once the tooling support is there we just should use the OS default. - even though de_DE defaults to ISO-8859-15 (or ISO-8859-1 - the internets can't seem to agree) I went with UTF-8 as that is what Gtk appears to want to use internally. ISO-8859-15 encoded .mo files create funny looking artefacts instead of Umlaute. - no support at all in the Makefile - I was hoping someone with more experience in how to best set this up would contribute a good set of Makefile rules - likely this will help fix the first issue in that it will also install the .mo file(s) in the correct place(s) For now simply run msgfmt -c -o subsurface.mo deutsch.po to create the subsurface.mo file and then move it to ./locale/de_DE.UTF-8/LC_MESSAGES/subsurface.mo If you make changes to the sources and need to add new strings to be translated, this is what seems to work (again, should be tooled through the Makefile): xgettext -o subsurface-new.pot -s -k_ -kN_ --add-comments="++GETTEXT" *.c msgmerge -s -U po/deutsch.po subsurface-new.pot If you do this PLEASE do one commit that just has the new msgid as changes in line numbers create a TON of diff-noise. Do changes to translations in a SEPARATE commit. - no testing at all on Windows or Mac It builds on Windows :-) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-11Use GTK_UNIT_INCH when printing to provide consistency across OSGravatar Lubomir I. Ivanov
Tests have shown that the most multi-platform way to do printing with GTK is to use GTK_UNIT_INCH (or GTK_UNIT_MM) with GtkPrintOperation. Tested on Linux, OSX, Windows. However this requires the appropriate scaling for Pango and Cairo to be done, with separate plotting logic for printing and drawing on the screen. To achieve that, profile.c:plot() now accepts a scaling parameter from type "scale_mode_t" defined in "display.h". Also due to new scale, small decimal numbers (such as 6.12345) cannot be well stored in "cairo_rectangle_int_t" therefore it is replaced with "cairo_rectangle_t", which uses doubles to provide Cairo with a drawing area. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Minor whitespace cleanup. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-29Fix profile and average depth for freedivesGravatar Mikko Rasa
Freedives can easily exceed the assumed ascent/descent rate, which results in wacky dive profiles. Add a check to make the ascent and descent fit within the duration of the dive.
2012-08-28Merge branch 'freediving-tweaks' of git://github.com/mguentner/subsurfaceGravatar Linus Torvalds
Merge freediving tweaks (zoom in on short dives etc) from Maximilian Güntner. Trivial conflicts in display.h due to unrelated printing stuff just happening to be added nearby. * 'freediving-tweaks' of git://github.com/mguentner/subsurface: moved zoomed_plot to display.h plot the time with a fixed padding (leading zero) updated/corrected comment added "Zoom" button and improved scaling fixed indentation use increments that make sense for 600 seconds Plot shorter (apnea) dives with a reasonable scale
2012-08-26Do some whitespace cleanupGravatar Linus Torvalds
The previous commit was a patch from Lubomir, which also had some whitespace fixes (to go with some new whitespace bugs to replace them) in it. I removed the whitespace changes from that patch (don't mix whitespace fixes with other fixes, unless they are on the same lines!) but decided to look for other whitespace issues, and this is the result. I left the non-C files alone, some of the spec and script files also have whitespace at the end of lines etc. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-22plot the time with a fixed padding (leading zero)Gravatar Maximilian Güntner
Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2012-08-22Merge branch 'master' into freediving-tweaksGravatar Maximilian Güntner
Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2012-08-20Rework dive selection logicGravatar Linus Torvalds
This completely changes how we keep track of selected dives: instead of having an array listing the selection ("selectiontracker") or trusting the gtk selection information, just save the information about whether a dive is selected in the dive itself. That makes it trivial to keep track of the state of selection across group collapse/expand events, or when changing the tree view model. It also ends up simplifying the code and logic in other ways. HOWEVER, it does currently (re-)introduce an annoying oddity with gtk: if you collapse a dive trip that has individual selections, gtk will forget those selections ("out of sight, out of mind"), and when you do *new* selections, the old hidden ones remain. So there's some games required to make gtk do sane things. We may need to either explicitly drop selections when collapsing trips, or make sure the group entry gets selected when collapsing a group that has selections in it. Or something. There may be other issues introduced by this too. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-18Make fill_missing_tank_pressures robust against missing cylinder infoGravatar Linus Torvalds
The code iterates over a list that can be NULL, but happily dereferenced it anyway. Oops. This function really should be split up and commented more. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-17Merge branch 'misc-fixes' of git://github.com/DataBeaver/subsurfaceGravatar Linus Torvalds
Pull miscellaneous fixes, mostly UI stuff from Mikko Rasa. Both this and the pull from Pierre-Yves Chibon created a "Save As" menu entry and logic. As a result, there were a fair number of conflicts, but I tried to make the end result somewhat reasonable. I might have missed some semantic conflict, though. Series-acked-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> * 'misc-fixes' of git://github.com/DataBeaver/subsurface: Add a separate "Save as" entry to the menu Changes to menu icons Improved depth info for dives without samples Divide the panes evenly in view_three
2012-08-16Fix right click edit in Dive Notes area for multiple divesGravatar Dirk Hohndel
This fixes the bug that triggered the SIGSEGV that Linus worked around earlier. I had forgotten to update this call path to the edit_multi_dive_info function. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-07-31Improved depth info for dives without samplesGravatar Mikko Rasa
This calculates a mean depth for the dive with a fixed ascent/descent rate and an assumption that all of the bottom time is at the maximum depth. It's not much, but it allows some derived values such as SAC to make more sense. The depth profile for such dives is now also generated with the same assumptions instead of putting the samples at fixed percentages of the dive duration. Signed-off-by: Mikko Rasa <tdb@tdb.fi>
2012-06-11updated/corrected commentGravatar Maximilian Güntner
Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2012-06-11added "Zoom" button and improved scalingGravatar Maximilian Güntner
It should be possible to have a certain limit where we stop zooming so that short dives are visible as such at first glance. Therefore a "Zoom" button has been added to the "Log" menu along with a shortcut (Ctrl + "0"). The user can now zoom/unzoom the plot and is still able to quickly distinguish short dives from normal ones when browsing the log. Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2012-06-09fixed indentationGravatar Maximilian Güntner
Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2012-06-09use increments that make sense for 600 secondsGravatar Maximilian Güntner
599/12 = 50, no need to use 5*60. Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2012-06-08Plot shorter (apnea) dives with a reasonable scaleGravatar Maximilian Güntner
The time marker increments have also been changed to better values. Also, display more time information for short dives. Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2012-01-05More removal of unused argumentsGravatar Dirk Hohndel
Just trying to clean up the code a bit. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-12-12Small improvement to plot info debugging codeGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-12-06Merge branch 'grid-to-back' of git://github.com/henrik242/subsurfaceGravatar Linus Torvalds
* 'grid-to-back' of git://github.com/henrik242/subsurface: Move depth/time grid back
2011-12-06Move depth/time grid backGravatar Henrik Brautaset Aronsen
The temperature profile was behind the white depth/time grid. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
2011-12-01Remove commented codeGravatar Henrik Brautaset Aronsen
I left some printer-spesific commented code in there. Away with it. Signed-Off-By: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
2011-12-01Clean up color definitionsGravatar Henrik Brautaset Aronsen
Fix ugly printout, give colors proper names, make grid lines and alert marker easier to see, and specify printer colors independently. Signed-Off-By: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
2011-11-28Define all colors in one placeGravatar Henrik Brautaset Aronsen
The profile colors were defined all over the place, so I put them all in one spot. I'm unsure if this is the best solution to that problem, but I guess it's a step in the right direction. Signed-Off-By: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
2011-11-28Prettier profile colorsGravatar Henrik Brautaset Aronsen
The profile colors aren't very pretty, and the grid lines are too thick. This commit tries to improve that. Signed-Off-By: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
2011-11-21Don't colorize the pressure plot when printingGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-21Add debugging function to dump tank pressure tracking dataGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-20Do proper rounding in interpolated pressure calculationsGravatar Linus Torvalds
We do all the pressures in mbar, which has plenty of precision for interpolated pressures - even when we then do our discrete integration over many samples. However, when we calculate those interpolated pressure points, we should make sure that we round the result correctly, otherwise the consistent rounding errors (from truncating the FP value into our integer mbar values) will result in a final pressure that is noticeably off in ugly ways (ie "end pressure set by hand to 750 mbar, but shown as 748"). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-20Revert "Correctly plot the tank end pressure if it was set manually"Gravatar Linus Torvalds
This reverts commit abdee5b1b8a97c641bca9bc2ebac9555c3e2ea54. There's no point in doing random hacks. Instead, do the intermediate pressure calculations with proper rounding instead of always truncating to mbar. With the math done correctly we have enough precision that the end result of the pressure interpolation doesn't have the kind of errors that caused Dirk to try to fix things up later. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-19Fix error when gaschange event is one second before next sampleGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-19Correctly plot the tank end pressure if it was set manuallyGravatar Dirk Hohndel
While printing the last pressure in the calculated sequence may seem more logical, given that the discrete series will create some amount of error this simply looks wrong. Instead we pick the end pressure that was manually set. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-19Make pressure plot shading by sac rate consistentGravatar Dirk Hohndel
Some parts of the existing code used the depth at the time of the sample to calculate the sac rate - it makes much more sense to use the average depth. But that requires us to loop over the entries and average the individual sac rates per segment instead of just using the beginning and end depth of the multi-segment interval we use for smoothing purposes. This may seem like a subtle detail, but it does in fact matter when we plot the synthetic tank pressure values that we create when we have no tank pressure data in the samples. Another detail we change here is to not artificially start with a forward looking segment of the full SAC_WINDOW but instead just start with the first two data points and then simply let the time window grow until it hits SAC_WINDOW - at which point it becomes a sliding window. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-19Improve tank pressure sac coloringGravatar Dirk Hohndel
This changes the algorithm that picks the sac color to consider +/- 1 l/min to be the same color (before the color changed every time you crossed above or below the average which looked silly with our synthetic "constant sac" values as those are discrete and oscilate around the average. This also changes the order in which things are drawn so so that the pressure plot goes over the depth profile plot (so the red shading of the dive no longer changes the color of the tank pressure plot). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-19Be more consistent in our handling of rgb value tablesGravatar Dirk Hohndel
Use rgb_t for the sac colors, create a new set_source_rgb_struct function and use that for the velocity values (in the depth plot) as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-18Color tank pressure plot based on relative sacGravatar Dirk Hohndel
Linus suggested that instead of using absolute SAC values to base the color on (which forced us to pre-define which SAC rates are green and which are red) we should color the tank pressure plot relative to the avg SAC rate of that dive - which I think makes the coloring much more useful to spot when on your dive you were doing well and when you were not. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-17Color pressure plot according to current SAC rateGravatar Dirk Hohndel
Similar to color indicating vertical speed in the profile plot we now use color in the tank pressure plot to indicate current SAC rate. We use a 45 sec sliding window to make sure we cover at least two breaths for each current SAC sample to avoid artificial oscillation based on breathing rhythm for corputers with high sample resolution. Not sure about the color coding that I'm using right now - it's green-ish for SAC rates under 15l/min ~= .55cuft/min and turns yellow and red as you go higher. That seems to work well for me, but for other divers this may be way off (or at least not as useful). Maybe this should be configurable? This is a lot more diver specific than the vertical velocity where there are clear recommendations based on safety considerations on what is good and bad. As a side effect, this removes the color coding that showed you whether you were looking at pressure data from samples (green) vs. interpolated pressure data (yellow). Not sure if people really want to see that. We might be able to indicate this differently (I am thinking different line width or transparency or something along those line) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-09This should fix the missing end pressure for broken dive computersGravatar Dirk Hohndel
Some dive computers randomly drop samples. That was no problem unless it was the LAST sample. We work around that now Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-09Remove unused 'minpressure/endpressure' fields from plot infoGravatar Linus Torvalds
.. and fix the maxpressure to actually look at *all* the cylinders, so that if you don't have sample data, but rely onmanually set cylinder pressures, it now really is the max of all the cylinders. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-09Merge branch 'bugfixes' of git://github.com/dirkhh/subsurfaceGravatar Linus Torvalds
* 'bugfixes' of git://github.com/dirkhh/subsurface: Fix breakage caused by Linus' changes to tank pressure handling
2011-11-09Fix breakage caused by Linus' changes to tank pressure handlingGravatar Dirk Hohndel
We no longer look at the start and end pressure for a tank, if the tank has valid pressure data in its samples (which makes sense). Sadly that breaks the current pressure interpolation code. With this patch most of those problems should be fixed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-09Improve temperature text plotting in profile displayGravatar Dirk Hohndel
- make the text a lighter color so it stands out more - change the heuristic when we print text to include both relative change in temperature and time since the last text was printed - print the first temperature we encounter - allow an ending temperature to be printed if the last printed temperature was before the 75% mark of the dive Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-09Correctly plot dives ending below the surfaceGravatar Dirk Hohndel
I thought we had fixed this before - but I guess it got broken again somewhere. We now make sure that the plot_info ends on an entry with depth 0. Added test14 to verify the fix. Also fixed cut'n'paste errors in a few test dive files. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-04Fix missing pressure plot at start of the dive in some situationsGravatar Dirk Hohndel
In some situations we could end up with no sample pressure and no interpolated pressure at time = 0. This is now fixed. Fix notes in test dive the exposed the issue. Also change the code in create_plot_info to keep the number of samples and the number of corresponding pi entries in separate variables. This avoids future changes from breaking if they assume they can access dive->sample[nr_samples - 1] (which is a reasonable assumption to make). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-04Improve tank pressure plot for computers that create "gaschange" eventsGravatar Dirk Hohndel
This was exposed by the test dives, but it shows up in small ways with real dives from some dive computers like the Suunto Vyper Air. We now insert synthetic plot_info entries that match the gas change event; to make this look smoother we insert either two events (one for the old tank, one a second later for the new tank) if there is no sample at the time of the event, or one additional event (and move the real sample back by one second) if there is a sample at the time of the event. This does expose another issue with some dives from Linus' computer where the pressure in the samples dips below the end pressure noted for the tank - which creates an odd "yellow up-tick" at the end of using the first tank in the plot. Maybe we should not insert a synthetic "last of old tank" event if we have a sample with valid pressure in the last NN seconds before the gas change? Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-04Don't repeat redundant minima or maxima in the profile plotGravatar Dirk Hohndel
If we have more than four identical depth readings, the old code would see those as local maxima and minima and print spurious depth values in the profile plot. Yes, in real sample data identical readings won't happen - but in synthetic data they can and there this looks really bogus. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-01Use unit functions to get column headers, add unit function for pressureGravatar Dirk Hohndel
Finally getting more consistent overall in how we convert between the different units and how we decide which units to display. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-01Add new helper function to get temperature and unitGravatar Dirk Hohndel
Designed along the lines of get_depth_units - except we don't define a specific number of digits to show. Use this in the one spot we need it right now in profile.c Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-29Fix up end conditions for divesGravatar Linus Torvalds
We used to have the dive plot have two "filler" entries at the beginning and the end, and indeed that is how they are allocated. However, we fix up "pi->nr" later to be "lastindex+1", where "lastindex" is the index of the time we surface. So when we loop over the plot entries, we actually need to loop all the way to the end: use "i < pi->nr" instead of "i < pi->nr-2". We still do have the two extra filler entries at the beginning, though. So depending on the loop, we might want to start at entry 2. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-29Plot fake profile for non-sample divesGravatar Linus Torvalds
Right now it just plots something ridiculous, the code is really just meant to be an example. We migth be able to plot a traditional staircase plot and make it look somewhat saner by taking mean depth into account (if it exists). Right now it just plots a (skewed) rectangular dive profile using the max depth and total time. Which is obviously insane. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-29Fix use of uninitialized variable if there are no samplesGravatar Linus Torvalds
When creating the plot_info, the 'entry' variable pointing to the last plot_info data was not initialized (because there was no data to fill in), and was then incorrectly used to fill in the last tank pressure. We also used to look at 'dive->sample[0].cylinderindex' even if no sample[0] necessarily existed. Reported-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>