2021-01-01 22:30:30 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
// A small custom scatter series, where every item represents a dive
|
|
|
|
// The original QScatterSeries was buggy and distinctly slower
|
|
|
|
#ifndef SCATTER_SERIES_H
|
|
|
|
#define SCATTER_SERIES_H
|
|
|
|
|
2021-01-18 22:29:34 +01:00
|
|
|
#include "statshelper.h"
|
2021-01-01 22:30:30 +01:00
|
|
|
#include "statsseries.h"
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
2021-01-17 22:03:27 +01:00
|
|
|
class ChartScatterItem;
|
2021-01-11 13:22:39 +01:00
|
|
|
struct InformationBox;
|
2021-01-01 22:30:30 +01:00
|
|
|
struct StatsVariable;
|
|
|
|
struct dive;
|
|
|
|
|
|
|
|
class ScatterSeries : public StatsSeries {
|
|
|
|
public:
|
2021-01-18 12:35:22 +01:00
|
|
|
ScatterSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis,
|
2021-01-01 22:30:30 +01:00
|
|
|
const StatsVariable &varX, const StatsVariable &varY);
|
|
|
|
~ScatterSeries();
|
|
|
|
|
|
|
|
void updatePositions() override;
|
|
|
|
bool hover(QPointF pos) override;
|
|
|
|
void unhighlight() override;
|
|
|
|
|
|
|
|
// Note: this expects that all items are added with increasing pos!
|
|
|
|
void append(dive *d, double pos, double value);
|
2021-02-08 17:07:37 +01:00
|
|
|
bool selectItemsUnderMouse(const QPointF &point, SelectionModifier modifier) override;
|
2021-02-01 23:17:04 +01:00
|
|
|
bool supportsLassoSelection() const override;
|
2021-02-08 17:07:37 +01:00
|
|
|
void selectItemsInRect(const QRectF &rect, SelectionModifier modifier, const std::vector<dive *> &oldSelection) override;
|
2021-01-01 22:30:30 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Get items under mouse.
|
2021-01-05 12:11:46 +01:00
|
|
|
std::vector<int> getItemsUnderMouse(const QPointF &f) const;
|
2021-02-01 23:17:04 +01:00
|
|
|
std::vector<int> getItemsInRect(const QRectF &f) const;
|
2021-01-01 22:30:30 +01:00
|
|
|
|
|
|
|
struct Item {
|
2021-01-18 22:29:34 +01:00
|
|
|
ChartItemPtr<ChartScatterItem> item;
|
2021-01-01 22:30:30 +01:00
|
|
|
dive *d;
|
2021-01-31 20:48:12 +01:00
|
|
|
bool selected;
|
2021-01-01 22:30:30 +01:00
|
|
|
double pos, value;
|
2021-01-17 22:03:27 +01:00
|
|
|
Item(StatsView &view, ScatterSeries *series, dive *d, double pos, double value);
|
2021-01-05 12:11:46 +01:00
|
|
|
void updatePosition(ScatterSeries *series);
|
2021-01-01 22:30:30 +01:00
|
|
|
void highlight(bool highlight);
|
|
|
|
};
|
|
|
|
|
2021-01-18 22:29:34 +01:00
|
|
|
ChartItemPtr<InformationBox> information;
|
2021-01-01 22:30:30 +01:00
|
|
|
std::vector<Item> items;
|
|
|
|
std::vector<int> highlighted;
|
|
|
|
const StatsVariable &varX;
|
|
|
|
const StatsVariable &varY;
|
2021-01-31 20:48:12 +01:00
|
|
|
void divesSelected(const QVector<dive *> &) override;
|
2021-01-01 22:30:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|