aboutsummaryrefslogtreecommitdiffstats
path: root/statistics.c
AgeCommit message (Collapse)Author
2012-11-11Fix average temperature statisticsGravatar Linus Torvalds
We generate the average temperature statistics by adding up the (converted to user unites - not in millikelvin) temperatures and then dividing by the number of dives we've added up over. HOWEVER. We did that summing of the temperatures into an integer variable, even though the converted temperatures are floating point. So things got rounded down to integers and the average temperature was just bogus (although reasonably close). We could do the summing of the temperatures in millikelvin and only doing the conversion to the user at the very end. But the smaller patch is to just change the accumulator to a double value. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-28Add support for visibility tracking and allow manual entry air tempGravatar Dirk Hohndel
Turns out we had a data field for visibility as a length unit - but never used it. I can never guess how much visibility we actually had on a dive - but I think most everyone can assign a rating between abysmal (zero stars, "I couldn't read my dive computer even right in front of my mask" - trust me, I had some of those dives) to amazing ("five stars, I could see farther than I though possible" - and I had one or two of those, too). So I changed this to an integer and am re-using the star infrastructure we have for the overall dive rating. When displaying this I was dismayed that we are running out of space in the "Dive Notes" notbook. So I moved this to the "Dive Info" notebook. This is not consistent and not logical. I think we need to revisit the notebooks and think about what we want to display where. While adding the infrastructure to manually enter the visibility I went ahead and added the ability to manually enter the air temperature as well (that was one of the things missing in the previous commit). Fixes #7 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-28Display air temperature in the info notebook pageGravatar Dirk Hohndel
So far we don't parse air temperature data via libdivecomputer. Nor are we set up to allow the user to manually enter it. We can parse it when downloading from a Uemis Zurich, though. This feature was suggested via trac.hohndel.org; this commit implements only part of what is requested there, so I simply reference the ticket here without closing it. References ticket #7 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-17Translate the SAC value in 'Dive Info'Gravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-17Handle dates and a "calculated plural" in translationsGravatar Dirk Hohndel
This looks like a massive commit mainly because of the line number changes in the .po files. That sadly hides what really happened here: - the places where we manually build dates have now been localized - the one place where we did the English "calculated plural" has been modified so that it now can be correctly translated (in English this just adds an 's' to the noun if the number is != 1 - in other languages this tends to be much more complicated) I then updated the two German translations to take advantage of the new constructs. And while I was at it, I changed the translation Trip->Gruppe to Trip->Reise as that seemed much more appropriate. I also fixed another error in the German translation where I translated "dive time" as "Startzeit" - but in the context it was "Dauer". Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-16Avoid zero degrees Kelvin in yearly statisticsGravatar Henrik Brautaset Aronsen
Maximum and minimum degrees in the yearly statistics were displayed as -273.1°C if no temperature info was present. H From 7d9aad01133bc03980f66a2d109c9ef909e518ad Mon Sep 17 00:00:00 2001 From: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Date: Tue, 16 Oct 2012 18:13:16 +0200 Subject: [PATCH] Avoid zero degrees Kelvin in yearly statistics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Maximum and minimum degrees in the yearly statistics were displayed as -273.1°C if no temperature info was present. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-14Improve translationsGravatar Dirk Hohndel
- fix two missing strings in equipment.c (thanks to Tommi Saviranta for pointing this out) - add context for the translations of the Yearly/monthly statistics. The code for this ended up being incredibly ugly, but the gettext infrastructure really clashed with the way this is implemented. What I have now at least works (tested with the German translation) - merge the new strings into all the po files. The non-German translations need to be updated. Make sure you remove the "# , fuzzy" lines or the current Makefile will ignore those additions. - some minor cleanup of the po files (many listed the wrong language, all of them copied my incorrect use of PACKAGE (instead of saying "Subsurface"). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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-20Fix yearly statistics after 64-bit time changesGravatar Miika Turkia
One of the "+1900" cases got incorrectly dropped. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> [ I really wanted the utc_mkdate/mktime functions to use proper years, rather than the idiotic "offset by 1900". However, we still mix things with "localtime()" in one place, so for now we have to be compatible with the insane tm_year semantics. - Linus ] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-09-19Use a 64-bit 'timestamp_t' for all timestamps, rather than 'time_t'Gravatar Linus Torvalds
This makes the time type unambiguous, and we can use G_TYPE_INT64 for it in the divelist too. It also implements a portable (and thread-safe) "utc_mkdate()" function that acts kind of like gmtime_r(), but using the 64-bit timestamp_t. It matches our original "utc_mktime()". Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-09-17Merge branch 'defaultfile'Gravatar Dirk Hohndel
By now the default file code seems quite matured, so in preparation for 2.0 we'll bring it back into master. I made a few small clean-ups during the merge, but the merge itself is very much straight forward. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-14Changing Miika's code to avoid global iterGravatar Dirk Hohndel
Two things I disliked in Miika's code in commit cbb5bd125b03: Having an integer variable named "something_iter" with all the GtkTreeIter around was really confusing. And having the yearly_iter as a global variable instead of cleanly passing it around really seemed suboptimal. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-14Improving the yearly statistics codeGravatar Miika Turkia
This will update the yearly statistics window (if open) whenever there are changes to the dive list. I also added a check not to open multiple statistics windows. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Reworded commit message Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-11Display yearly/monthly statisticsGravatar Miika Turkia
Display yearly statistics in a statistics window with option to expand the viewing on monthly level. The amount of dives along with basic information like duration, depth, water temperature and air consumption is displayed in yearly and monthly level. Thus you are able to compare e.g. development of air consumption or diving activity from year to year. Using already existing macro for splitting seconds into minutes:seconds. Moving repetitive code to a function (couldn't think of the suggested clever macro, but this should pretty much do the trick). Now the statistics are updated every time the process_all_dives function is called. It might make sense to actually verify the structures need to be re-allocated, but such optimization is currently not implemented. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Combined two commits. Minor cleanups for white space and boolean values. Significant changes to use the correct units for volumes vs. depths and to avoid unneccesary lookups of the model storage based on the tree. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-10Implement Close menu option that allows closing the data fileGravatar Dirk Hohndel
This requires some helper routines that allow us to clear out all the widgets. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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-21Add helper 'for_each_dive()' dive iteratorGravatar Linus Torvalds
It's an easy thing to do, but the for-loop ends up being pretty ugly, so hide it behind the macro. It would be even prettier with one of the (few) useful C99 features: local for-loop variables. However, gcc needs special command line options, and other compilers may not do it at all. So instead of doing #define for_each_dive(_x) \ for (int _i = 0; ((_x) = get_dive(_i)) != NULL; _i++) we require that the user declare the index iterator too, and the use syntax becomes for_each_dive(idx, dive) { ... use idx/dive here ... } And hey, maybe somebody actually will want to use the index, so maybe that's not all bad. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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-18Change default behavior for Stats to show selected divesGravatar Dirk Hohndel
Previously when only one dive was selected, the Stats notebook page would show the statistics for all dive. That creates a very illogical behavior when clicking on the different dive groups in the dive list. The stats page would always show how many dives where in a group when the group was selected, except when there was only one dive in the group, in which case the statistics for all the dives were shown. With this change we also show the statistics for the selected dives, even if it is just one. If you want the statistics for all dives, simply select them all (Ctrl-A or Command-A on a Mac). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-16Stop relying on gtk to track which dives are selectedGravatar Dirk Hohndel
We spend way too much effort trying to get gtk to manage the dives that are selected. The straw that broke the camel's back is that gtk forces us to expand any nodes that we want to select - so selecting a summary entry for a dive trip forced us to expand all the dives in the dive trip. Which as Linus pointed out really sucked from a user experience. So instead we now completeley ignore gtk's weird idea of what is selected and what isn't and simply track things ourselves. We still need to play some games with gtk to make sure that the correct rows are SHOWN as selected, but still, the overall code seems much cleaner. This commit contains a bunch of debugging code that is ifdef'ed out - this is extremely useful to make sure I didn't mess anything up, but eventually I'll want to remove that again as it just looks ugly in the code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-14Fix selecting and unselecting summary itemsGravatar Dirk Hohndel
The dive list now seems to behave intuitively. In order to do this we had to intercept the select function in addition to having a selection-changed callback. That way we can simulate the multi-level selection and unselection that was missing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-14Maintain selected rows when switching between list model and tree modelGravatar Dirk Hohndel
We keep track of the DIVE_INDEX of all selected dives and simply re-select those dives after changing model (date based sort or sort by other column). There are a few TODOs left. We lose the sort direction (ascending / descending) when switching models. We also don't correctly deal with the user selecting summary rows in the tree model. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-06-30Fix a couple of possible divide-by-zero conditions in statisticsGravatar Linus Torvalds
Several people reported the average time problem, but there's another one lurking there too: if the dive duration is zero, you get bogus average depth information too (but because that one was a floating point divide, and by default they are unsignalling on x86, it didn't crash, it just resulted in bogus results). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-03-29Fix broken average SAC calculationGravatar Miika Turkia
old_sac_time was always 0 when calculating average air consumption. Thus the results were incorrect. Move the counter to stats_t structure as suggested by Linus. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-03-16Show statistics of selected divesGravatar Miika Turkia
If at least 2 dives are selected, show statistics of these dives on Overall Stats. Otherwise, show the statistics of all dives. Temperature is also added to the shown statistics. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Minor change to avoid adding statistics.h (moved the global variable and external function declaration to display-gtk.h). Another minor change to the text displayed for the "Stats" notebook page. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-15Add statistics for longest, shortest, and shallowest diveGravatar Dirk Hohndel
I don't really like calling the shallowest dive "min depth", but all other texts that I could come up with that were reasonably short weren't any better... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-15Create separate single dive and total stats pagesGravatar Dirk Hohndel
No additional statistics added, yet. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-15Separate out single dive statistics and total statisticsGravatar Dirk Hohndel
Right now this just changes the infrastructure - nothing outside of statistics.c is modified. This is simply in preparation to split out the single dive info and the total dive statistics in the future (as we are creating more info and more stats and they will overflow the screen area available - so this will turn into two notebook tabs). This commit does not change any functionality. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-12-31Define O2 permille for air in one spotGravatar Henrik Brautaset Aronsen
Having the O2 permille defined once is more readable. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
2011-12-09Use common helper function for the "no cylinder info" caseGravatar Linus Torvalds
Miika fixed the statistics code that didn't properly check for the "no cylinder info" case - this cleans it up and just uses the helper function in equipment.c. Rename the helper to be slightly better named while at it. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-12-09Show O2 per cent if given in cylinder infoGravatar Miika Turkia
O2 per cent from dive computer should be shown in Dive Info if one is given even without pressure information for the cylinder. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-09Fix up the statistics page use of pressure dataGravatar Linus Torvalds
The statistics page calculates air use separately, and also needs to be fixed up for the split of the pressures into sample-vs-start/end. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-07don't use strftime() due to locale issuesGravatar Lubomir I. Ivanov
Make statistics.c use snprintf() with weekday(), monthname() instead of strftime(). The mingw strftime() ends up having lots of problems at least on Windows unless you set the locale just right, so just avoid the problem by doing the simple function by hand. We already did that in other places anyway. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-04Don't test for liquid HeliumGravatar Dirk Hohndel
Simply accept temperatures that are above absolute zero. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-04Clear O2/H2 field if there is no tank informationGravatar Dirk Hohndel
Found using the new test dives Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-04Don't display a water temperature of absolute 0 in info/stats pageGravatar Dirk Hohndel
Found using the new test dives Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-02Exclude obviously bogus SAC values from statistics calculationsGravatar Dirk Hohndel
Random cutoff is 2.8l/min (or about 0.1cuft/min) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-02Fix typo that broke min SAC calculationGravatar Dirk Hohndel
Actually more of a cut'n'paste-o Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-02Surface interval is calculated from the END of previous diveGravatar Dirk Hohndel
Silly mistake Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-02Add Info & Stats page to the notebookGravatar Dirk Hohndel
This provides the relevant information for the currently selected dive plus a bunch of statistics over all dives in the dive_table. The visual design has lots of room for improvement - right now the different fields change size - it might be nice to have a more modern look for the entries - the O2/He field is odd - for most divers the He value will always be 0, so maybe we should only show He if there's at least one dive that uses He? Also, we simply do a comma separated list of gases for all the tanks used Signed-off-by: Dirk Hohndel <dirk@hohndel.org>