aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2021-01-03build-system/AppImage: ensure stats dependencies get bundledGravatar Dirk Hohndel
This will make sure QtCharts is part of the AppImage. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-03statistics: don't crash if the QCharts QML modules aren't foundGravatar Dirk Hohndel
We don't really give a user visible error message which is kind of a problem, but at least we don't crash anymore. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-03statistics: don't reset binner if binner is setGravatar Berthold Stoeger
Recently code was added to reset variable 1 binner if the second variable does not support an unbinned first variable. It forgot to check whether a binner was already set. Do this. But validate the old binner first! This code is extremely fragile and will have to be redone. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03desktop: rename Statistics tab to SummaryGravatar Dirk Hohndel
We now have three different things that are kinda like statistics: - the summary tab (reasonably useful when looking at selected dives) - the yearly statistics (Ctrl/CMD-Y) - the full statistics (Ctrl/CMD-T) I'd argue that's at least one too many. But I'm sure some people will disagree. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-03statistics: add CHANGELOGGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-03build-system/Windows: package the QtCharts QML resourcesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-03statistics: clip regression lineGravatar Berthold Stoeger
A steep regression line would shoot out of the chart. Therefore, clip to the y = minY and y = maxY lines. QtGraphicsScene has its own clipping routines, but they are very general, so let's do this trivial case by hand. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03statistics: use RoundRectItem for legend and info-boxGravatar Berthold Stoeger
Dirk says rounded corners look better. This now looks a bit extreme to me and probably the border size should be increased. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03ui: create a RoundRectItem classGravatar Berthold Stoeger
Factor out code from ProfileWidget's ToolTipItem, but make the radius of the corners dynamic. Move into backend-shared, though a new ui-shared might be preferred. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03statistics: add parentheses around percentage in horizontal barsGravatar Berthold Stoeger
For better visual guidance, format labels as "count (percentage)" in horizontal bar charts. In vertical bar charts two lines are used anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03statistics: charts drop down looks better with smaller iconsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-03statistics: chart icons look better with rounded cornersGravatar Dirk Hohndel
This is certainly a ridiculous bike shedding effort, but I do like this better. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-03statistics: fix silly typo in legend codeGravatar Berthold Stoeger
After each column, instead of setting the new x-variable, the new value was added to the old value. This led to ever increasing gaps. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03statistics: reverse chart selection logicGravatar Berthold Stoeger
The old ways was to select the chart first, then depending on the chart choose the binning. Willem says that it should work the other way round: select the binning (or operation) and make the charts depend on that. I'm not arguing one way or the other, just note that the new way is much more tricky, because it is easy to get unsupported combinations. For example, there is no chart where the first variable is unbinned, but the second axis is binned or has an operation. This makes things distinctly more tricky and this code still needs a thorough audit. Since this is all more tricky, implement a "invalid" chart state. Ideally that should be never shown to the user, but let's try to be defensive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03desktop: add statistics widget dummy and application stateGravatar Berthold Stoeger
Add a new "statistics" application state. In the statistics state show the statistics widget and the filter in the top quadrants. The idea is to allow filtering and doing statistics at the same time. Sadly, we can't use the filter-widget in different quadrants, because Qt's ownership model is completely broken / inflexible. It does not support a widget having different parents and thus a widget can only belong to one QStackedWidget. Hiding the map in the statistics view is quite hacky: Since the view of the quadrants is not determined by the "ApplicationState", we have to restore the original quadrant visibility when exiting the stats mode. Therefore, set the original visibility-state when changing application state. The MainWindow-quadrant code really needs to be rewritten! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03statistics: implement a statistics widget on desktopGravatar Berthold Stoeger
Implement a widget that shows the statistics state as comboboxes and the statistics chart. Calls into the statistics code if any of the comboboxes changes. The hardest part here is the formatting of the charts list with its icons and with headings. Sadly, it is not trivial to arrange icons horizontally. Therefore we would have to fully reimplement the ComboBox view, which is probably not fun. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03statistics: add a model that describes a list of chartsGravatar Berthold Stoeger
Qt's comboboxes are controlled by models, there's no way around that. To customize the chart-selection widget this must therefore be abstracted into a model. On the upside, this hopefully can be used for desktop and mobile. The model provides icons and paints a warning-symbol on it if the statistics core code deems the chart to be not recommended. Notably, when plotting a categorical bar chart against a numerical value (in such a case histograms are preferred). Includes a fix for a silly oversight in CMakelist.txt: add the statstranslations.h header. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03statistics: add SVG icons representing chart-typesGravatar Berthold Stoeger
Add a few icons representing chart type (in internal terms: chart subtypes): bar (grouped, stacked, single), box-and-whisker, data points, pie. These should be shown in the chart selection box. Yes, the "artwork" is not pretty, so see these as a placeholder. Morover, add a "warning" icon. This icon already existed as SVG, but was not references (its png render was). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03statistics: silence two Coverity warningsGravatar Berthold Stoeger
Two warnings concerning division by zero and non-initialization of a member variable, respectively. Both are false positives. However, Coverity is excused because it probably doesn't understand std::vector<> and also can't know whether the object in question is generated in a different source file. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03cleanup: get the Ubuntu names rightGravatar Dirk Hohndel
Kinda silly, but it bugged me. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-02mobile: replace locationProvider with calls to GpsLocation::instance()Gravatar Dirk Hohndel
This makes it more obvious what we are doing. And won't make any difference from a performance perspective. Also converted the last call to connect using the old syntax to the new syntax. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-02mobile: turn GpsLocation into a regular singleton constructGravatar Dirk Hohndel
Simply move the initialization of the logging function into its own method and call that in the QMLManager constructor. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-02mobile: don't connect to applicationStateChanged signal earlyGravatar Dirk Hohndel
We don't want to connect to this until all parts of the QMLManager object are set up. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-02statistics: implement StatsViewGravatar Berthold Stoeger
The StatsView shows the chart described by the StatsState structure. It is based on a QML ChartView. This should make it possible to easily port to mobile. It does not include any of the UI around the chart, viz. the variable and chart selection, etc. The code checking for the statistical significance of the regression line was written by Willem. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2021-01-02statistics: implement a structure representing the chart stateGravatar Berthold Stoeger
The StatsState structure fully describes the current state of the chart: the selected axes, operations and additional chart features, such as legend or labels. The code implements sanity checks and reacts accordingly, if an invalid combination of variables and charts is chosen. The chart and variable lists to be displayed can be queried and are encapsulated in the StatsState::UIState structure. Some variable / chart combinations are possible, but not recommended, which is represented by a warning flag. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02statistics: implement scatter seriesGravatar Berthold Stoeger
Implement a simple scatter series for plotting two numerical variables agains each other. Since the scatter symbols may overlap, on hover multiple dives are shown in the information box. If the box would become too large, only the first few dives are shown followed by "and X more". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02statistics: implement pie seriesGravatar Berthold Stoeger
Implement a simple count-based pie chart. Percentage labels are shown in the pie slices, the names outside the pie slices. On hovering over a slice, the actual counts are shown. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02statistics: implement a box-and-whisker seriesGravatar Berthold Stoeger
Implements a simple box-and-whisker series to display quartile based data. When hovering over a box-and-whiskers item the precise data of the quartiles is shown. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02statistics: implement a bar seriesGravatar Berthold Stoeger
Implement a bar series, which can plot stacked, grouped and single bar charts in horizontal or vertical ways. On hovering over a bar, an information is shown. The shown information depends on whether the chart is count or value based, or is a multi-bin chart. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02statistics: implement a simple information boxGravatar Berthold Stoeger
When the user hovers over features in the chart, they should be presented with more information. For example in bar charts on the dives the bar represents and the exact value that the bar represents, etc. The InformationBox is a simple QGraphicsWidget, which can be placed on top of QCharts and can show a number of arbitrary text lines. When placing the box on the chart, the code attempts to stay inside the plot area of the chart. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02statistics: add series interface classGravatar Berthold Stoeger
Add a interface class for the chart series used by the statistics module. Abstract virtual functions are declared for replotting and selecting items. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02statistics: implement axesGravatar Berthold Stoeger
Implement five kinds of axes: - ValueAxis: a standard axis for plotting numerical linear data. - CountAxis: a ValueAxis for plotting counts of dives. - CategoryAxis: an axis for plotting discrete variables without any notion of distance. - HistogramAxis: an axis for plotting bins with a numeric value. - DateAxis: a HistogramAxis that formats dates. The axes derive from a common virtual base class that defines a small interface, notably, returning the minimum and maximum displayed value and redrawing the axis. The mapping and painting is performed by QtCharts' axes. On the one hand, using QtCharts turned out to be too inflexible. On the other hand it allowed us to quickly prototype the charts. Ultimately, we should do our own drawing of the axis. As a testament to the inflexibility, QtCharts' axes do not allow for repeated labels is needed for quarter-based date charts (year, Q2, Q3, Q4, year, Q2, Q3, ...). Therefore the code disambiguates labels by adding unicode zero-width spaces. Wonderful. When omitting labels due to space reasons, the histogram axis attempts to show "preferred" labels. In the quarter example above, it tries to show full years. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02statistics: add a header file defining z-valuesGravatar Berthold Stoeger
z-values determine the order in which objects on the chart are painted. To reduce chaos, collect all z-values in a header file. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02cleanup: move pref related structs and functions to pref.cGravatar Berthold Stoeger
These were declared in pref.h and defined in subsurfacestartup.c. pref.c didn't even exist. Create it and move preferences-related structs and functions there. setup_system_prefs() is left in subsurfacestartup.c, since it works with environment variables. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02cleanup: move definition of get_units() to core/unit.cGravatar Berthold Stoeger
The function is declared in core/unit.h, therefore it seems logical to define it in the corresponding source file. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02cleanup: remove support for PASCAL in get_pressure_units()Gravatar Berthold Stoeger
The user preferences can never end up with PASCAL pressure units. The only place that uses these units is the XML parser. Therefore, remove the PASCAL case in get_pressure_units(). This will remove an unused translation string. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02cleanup: don't save PASCAL pressure units to gitGravatar Berthold Stoeger
The way I understand, the PASCAL pressure unit is used to parse obscure dive logs. However, there is no support in the UI for using Pa as pressure unit. Therefore remove reading / writing this unit to git divelogs. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01cleanup: remove "GpsLocation *locationProvider" from MainWindowGravatar Berthold Stoeger
This is mobile only and not used on desktop. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01mobile: update version to 3.1.3Gravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-01cleanup: ensure DiveFilter is consistent when createdGravatar Dirk Hohndel
Otherwise we might access an uninitialized member. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-01fix potential crash in GPS codeGravatar Dirk Hohndel
If we don't have a GpsLocation instance, we shouldn't dereference it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-01statistics: implement a legend boxGravatar Berthold Stoeger
For some chart (e.g. pie charts or stacked bar charts), we want to display a legend. QtCharts' legend interface happens to be private and therefore is of no use. This introduces a legend box which is implemented using QGraphicItems, which can be placed on top of QCharts. It's very unfancy, but works for now. If there are too many items, not all are shown. Currently, the legend is configured to fill at most half of the width and half of the height of the chart. This might need some optimization. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01statistics: add color-related functionsGravatar Dirk Hohndel
Add a source file and a header file, which implement the color scheme used by the statistics module. Besides a few color constants, the centerpiece is a function that returns the color representing a bin and an appropriate label color. It picks a roughly equi-distant set of colors out of an already balanced set of 50 candidate colors. And it also picks white as text color when adding a label to a segment with a dark color. The color list was created using a tool by Gregor Aisch that is available on GitHub as https://github.com/gka/palettes to create multi-hued, multi-stop color scales that are safe for color blind people. This commit contains code from three authors. Dirk (main author): adaptive color scheme. Willem: Colors of single-bin charts and lines. Berthold: Infrastructure. Signed-off-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01statistics: add statistic variablesGravatar Berthold Stoeger
The StatisticVariable class hierarchy encapsulates the concept of a dive-variable, which can be plotted in charts either as dependend or independend variable. There are three types of these variables: 1) discrete: For example dive buddies or suit type. 2) continuous: Has a notion of linear metric - can be used as histogram or scatter plot axis. 3) numeric: Like continuous, but allows for operations such as calculating the mean or the sum over numerous dives. All variables support binning. The bins are defined per variable. Continuous variables can be converted into an arbitrary double value, which is used to be plotted on a continuous axis. Moreover, numeric variables support a number of operations, which depend on the variable. Since binning is based on different types, the code is rather template-heavy. Of course, this could be solved with unions/variants and runtime-polymorphism, but using templates was just much quicker. Notably, this uses the CRTP (curiously recurring template pattern) where a subclass passes itself as argument to the baseclass. This is a weird kind of "reverse inheritance". The StatsTranslations class is a dummy class which will be used to collect all translations of the statistics module. This includes changes by Dirk to fix compilation of the downloader. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-01core: add get_*_unit functions with explicit unit systemGravatar Berthold Stoeger
The get_*_unit() functions return the unit-name as set in the preferences. Add versions with a "metric" parameter. This will be used by the statistics code, which may in the future allow for binning with alternative units. All the unit-formatting functions should probably be moved away from qthelper to their own source file. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01core: move formatting of day-of-week to string-format.cppGravatar Berthold Stoeger
This was only used by the filter, but will also be used by the statistics module. To avoid duplicate translation strings, move to a common place. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01core: add "transparent" parameter to renderSVGIconGravatar Berthold Stoeger
The start-selection widget will need icons with a transparent background so that the icons don't stick out like a sore thumb. So far the icons rendered by this function were only used by the images on the profile and were perfectly rectangular. Therefore there was no need for this. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01core: make gasmix_is_invalid globally accessibleGravatar Berthold Stoeger
The statistics module will use that to bin dives by gasmix. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01core: add notion of gas-type to core/gas.cGravatar Berthold Stoeger
Create a gastype enum, which describes the type of a gas. For now: air, nitrox, normoxic, trimix and oxygen. This probably should be made configurable. The gas types will be used to bin gasses in the statistics module. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01core: move renderSVGIcon() to qthelper.cppGravatar Berthold Stoeger
The renderIcon() function was used by the thumbnailer to render SVG-based icons. Move it to the global qthelper.cpp so that it can also be used by the statistics module. Add "SVG" to the name to emphasize what it is used for. For consistency also move the renderSVGIconWidth() function, which renders to a fixed width, to qthelper.cpp Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>