Commit graph

11 commits

Author SHA1 Message Date
Berthold Stoeger
144e81e8f8 statistics: make fonts themeable
Move the various font objects the the StatsTheme structure to enable
different font weights for different themes.

For the dark theme, switch to a bold font, because the thin white
font was barely visible.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-03-16 15:26:54 -07:00
Berthold Stoeger
5f91c69f9c statistics: create themes on demand
Create the themes only when needed (singleton pattern). If
the themes should do more than colors, such as for example
fonts, it is not clear whether that can be done before main()
runs. By creating the themes on demand, the Qt UI should
be initialized in the constructors of the themes.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-03-16 15:26:54 -07:00
Berthold Stoeger
b5aac29cea statistics: collect colors in a StatsTheme class
To enable rudimentary theming, collect all colors in a new
theme class. The class has to be passed down to the various
items.

In general the items save a reference to the them in the
constructor. Alternatively, they might also just query
the StatsView everytime they need to access a color.
For now, it's hard the say what is preferred: a reference
per item or a function call per invokation?

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-03-16 15:26:54 -07:00
Berthold Stoeger
06a091643e statistics: highlight selected bar
When all items of a bar in a bar chart are selected, highlight them
by overlaying with a checkerboard pattern. A gray checkerboard seems to
work reasonably well, regardless of base color.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-02-13 13:02:54 -08:00
Berthold Stoeger
d63d4cd3c3 statistics: implement rectangle selection in scatter plot
Allow the user to select regions of the scatter plot using
a rectangular selection. When shift is pressed, do an
incremental selection.

Unfortunately, the list-selection code is so slow that this
becomes unusable for a large number of selected dives.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-13 13:02:54 -08:00
Berthold Stoeger
d85b321784 statistics: show selected dives in scatter plot
As a visual feedback, show the selected dives in the scatter
plot. React to application-wide selection changes. Currently,
the dive list is deactivated while in statistics mode, but
that may change.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-13 13:02:54 -08:00
Berthold Stoeger
2e2019dea7 statistics: move colors to statscolors.h
Most colors were already collected there, but a few were dispersed
throughout the source files.

For future themeability, move the remaining colors to this common
place.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20 08:47:18 +01:00
Berthold Stoeger
e7907c494f statistics: convert chart to QQuickItem
It turns out that the wrong base class was used for the chart.
QQuickWidget can only be used on desktop, not in a mobile UI.

Therefore, turn this into a QQuickItem and move the container
QQuickWidget into desktop-only code.

Currently, this code is insane: The chart is rendered onto a
QGraphicsScene (as it was before), which is then rendered into
a QImage, which is transformed into a QSGTexture, which is then
projected onto the device. This is performed on every mouse
move event, since these events in general change the position
of the info-box.

The plan is to slowly convert elements such as the info-box into
QQuickItems. Browsing the QtQuick documentation, this will
not be much fun.

Also note that the rendering currently tears, flickers and has
antialiasing artifacts, most likely owing to integer (QImage)
to floating point (QGraphicsScene, QQuickItem) conversion
problems. The data flow is
QGraphicsScene (float) -> QImage (int) -> QQuickItem (float).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10 15:16:52 -08:00
Berthold Stoeger
ab324ed769 statistics: paint custom grid
With removal of QtCharts' axes, the grid was lost. Readd it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-06 12:31:22 -08:00
Berthold Stoeger
4ab9f1c6b0 statistics: replace QtCharts' axes
Replace by custom implementation, with the ultimate goal to
remove the QtCharts module. This doesn't yet display axis
titles or a grid.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-06 12:31:22 -08:00
Dirk Hohndel
7339dc28ae statistics: add color-related functions
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-01 21:10:10 +01:00