It appears that the QML object that is created when assigning the source
to the StatsView in the ui can be garbage collected and therefore
destroyed and re-instantiated without our knowledge. So instead of
trying to keep a pointer around, we end up looking up the object address
when needed.
We still ask the JS code to not garbage collect the object - but that
clearly isn't enough to prevent it from being destroyed when the parent
widget changes.
Without this fix opening the statistics will crash with Qt6.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This was a user request: Sort bar charts by height of the bars.
Obviously, this can only work for categorical charts, not for
histograms.
The UI is a break from the old concept: the sorting is chosen
based on the chart, whereas for the rest of the features, the
viable charts are presented based on the binning, etc.
I found it confusing to have the possible charts be selected
based on sorting. I.e. if a non-bin sort mode is selected,
the histogram charts disappear. On the flip side, this would
be more consistent. We can change it later.
For value-based bar charts, there are three sort modes: by
bin, by count (i.e. number of dives in that bar) and by
value (i.e. length of the bar). This hopefully satisfies all
needs.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Apparently, the visibility flag of the view is not inherited
from the statistics widget. Therefore, the statistics is
redrawn on every action even if not visible.
Set the visibility explicitly in the show- and hide-events.
This is crazy.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Allow the user to restrict the analyzed dives based on the
current selection. One button restricts to the current selection
and one button resets the restriction.
Thus, the user can for example select bars in the bar chart
or a range in the scatter plot and perform statistics on
these sets.
The restriction works on top of the filter.
The UI can certainly be improved, but it is a start.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Turn the background grid into QSGNodes. Each grid line is
represented by a QSG line item. An alternative would be
drawing the grid into a QImage and blasting that onto the
screen. It is unclear which one is preferred.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>
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>