blob: a0dbcd82e4a307612e97608fc36b126ea2f3ed16 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// 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
#include "statshelper.h"
#include "statsseries.h"
#include <memory>
#include <vector>
class ChartScatterItem;
struct InformationBox;
struct StatsVariable;
struct dive;
class ScatterSeries : public StatsSeries {
public:
ScatterSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis,
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);
void selectItemsUnderMouse(const QPointF &point) override;
private:
// Get items under mouse.
std::vector<int> getItemsUnderMouse(const QPointF &f) const;
struct Item {
ChartItemPtr<ChartScatterItem> item;
dive *d;
double pos, value;
Item(StatsView &view, ScatterSeries *series, dive *d, double pos, double value);
void updatePosition(ScatterSeries *series);
void highlight(bool highlight);
};
ChartItemPtr<InformationBox> information;
std::vector<Item> items;
std::vector<int> highlighted;
const StatsVariable &varX;
const StatsVariable &varY;
};
#endif
|