2021-01-01 21:30:30 +00: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 21:29:34 +00:00
|
|
|
#include "statshelper.h"
|
2021-01-01 21:30:30 +00:00
|
|
|
#include "statsseries.h"
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
2021-01-17 21:03:27 +00:00
|
|
|
class ChartScatterItem;
|
2021-01-11 12:22:39 +00:00
|
|
|
struct InformationBox;
|
2021-01-01 21:30:30 +00:00
|
|
|
struct StatsVariable;
|
|
|
|
struct dive;
|
|
|
|
|
|
|
|
class ScatterSeries : public StatsSeries {
|
|
|
|
public:
|
2021-01-18 11:35:22 +00:00
|
|
|
ScatterSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis,
|
2021-01-01 21:30:30 +00: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);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Get items under mouse.
|
2021-01-05 11:11:46 +00:00
|
|
|
std::vector<int> getItemsUnderMouse(const QPointF &f) const;
|
2021-01-01 21:30:30 +00:00
|
|
|
|
|
|
|
struct Item {
|
2021-01-18 21:29:34 +00:00
|
|
|
ChartItemPtr<ChartScatterItem> item;
|
2021-01-01 21:30:30 +00:00
|
|
|
dive *d;
|
|
|
|
double pos, value;
|
2021-01-17 21:03:27 +00:00
|
|
|
Item(StatsView &view, ScatterSeries *series, dive *d, double pos, double value);
|
2021-01-05 11:11:46 +00:00
|
|
|
void updatePosition(ScatterSeries *series);
|
2021-01-01 21:30:30 +00:00
|
|
|
void highlight(bool highlight);
|
|
|
|
};
|
|
|
|
|
2021-01-18 21:29:34 +00:00
|
|
|
ChartItemPtr<InformationBox> information;
|
2021-01-01 21:30:30 +00:00
|
|
|
std::vector<Item> items;
|
|
|
|
std::vector<int> highlighted;
|
|
|
|
const StatsVariable &varX;
|
|
|
|
const StatsVariable &varY;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|