2021-01-01 20:54:35 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
// Base class for all series. Defines a small virtual interface
|
|
|
|
// concerning highlighting of series items.
|
|
|
|
#ifndef STATS_SERIES_H
|
|
|
|
#define STATS_SERIES_H
|
|
|
|
|
2021-02-08 16:07:37 +00:00
|
|
|
#include "statsselection.h"
|
|
|
|
|
2021-02-01 22:17:04 +00:00
|
|
|
#include <vector>
|
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-07 13:38:37 +00:00
|
|
|
#include <QPointF>
|
2021-01-01 20:54:35 +00:00
|
|
|
|
|
|
|
class StatsAxis;
|
2021-01-13 13:56:48 +00:00
|
|
|
class StatsView;
|
2021-01-31 19:48:12 +00:00
|
|
|
struct dive;
|
2021-02-01 22:17:04 +00:00
|
|
|
class QRectF;
|
2021-01-01 20:54:35 +00:00
|
|
|
|
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-07 13:38:37 +00:00
|
|
|
class StatsSeries {
|
2021-01-01 20:54:35 +00:00
|
|
|
public:
|
2021-01-18 11:35:22 +00:00
|
|
|
StatsSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis);
|
2021-01-01 20:54:35 +00:00
|
|
|
virtual ~StatsSeries();
|
|
|
|
virtual void updatePositions() = 0; // Called if chart geometry changes.
|
|
|
|
virtual bool hover(QPointF pos) = 0; // Called on mouse movement. Return true if an item of this series is highlighted.
|
|
|
|
virtual void unhighlight() = 0; // Unhighlight any highlighted item.
|
2021-02-01 22:17:04 +00:00
|
|
|
// Returns true if an item was under the mouse.
|
2021-02-08 16:07:37 +00:00
|
|
|
virtual bool selectItemsUnderMouse(const QPointF &pos, SelectionModifier modifier) = 0;
|
2021-02-01 22:17:04 +00:00
|
|
|
virtual bool supportsLassoSelection() const;
|
|
|
|
// Needs only be defined if supportsLassoSelection() returns true.
|
2021-02-08 16:07:37 +00:00
|
|
|
virtual void selectItemsInRect(const QRectF &rect, SelectionModifier modifier, const std::vector<dive *> &oldSelection);
|
2021-02-07 19:48:43 +00:00
|
|
|
virtual void divesSelected(const QVector<dive *> &dives) = 0;
|
2021-01-17 12:34:18 +00:00
|
|
|
|
2021-01-04 19:34:44 +00:00
|
|
|
protected:
|
2021-01-13 13:56:48 +00:00
|
|
|
StatsView &view;
|
2021-01-04 19:34:44 +00:00
|
|
|
StatsAxis *xAxis, *yAxis; // May be zero for charts without axes (pie charts).
|
2021-01-05 11:11:46 +00:00
|
|
|
QPointF toScreen(QPointF p);
|
2021-01-01 20:54:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|