summaryrefslogtreecommitdiffstats
path: root/stats/barseries.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-01-20 14:36:59 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-02-13 13:02:54 -0800
commit18a5b5b5930247ed880cfbe8f94778b4c19b0bb2 (patch)
treecdaf28e252a7e512774379e2f12e981e1f68ccb3 /stats/barseries.h
parent622e9ba373f898a0d51fc009f3615d83ffd3a7fc (diff)
downloadsubsurface-18a5b5b5930247ed880cfbe8f94778b4c19b0bb2.tar.gz
statistics: use dive instead of count bins
If we want to make bar charts selectable (when clicking on a bar select the dives the bar represents), then we must store the dives behind bars. Therefore, use dive-based bins instead of count based bins in bar charts and pie charts. This gave some churn because every structure where a count is stored has to be changed to store a vector of dives. Try to use move semantics where possible to avoid duplication of dive lists. On a positive note, the count_dives() function of the binners can now be removed, since it is unused. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'stats/barseries.h')
-rw-r--r--stats/barseries.h26
1 files changed, 18 insertions, 8 deletions
diff --git a/stats/barseries.h b/stats/barseries.h
index 9f9586fe8..8c83648ea 100644
--- a/stats/barseries.h
+++ b/stats/barseries.h
@@ -25,7 +25,7 @@ public:
// based charts and for stacked bar charts with multiple items.
struct CountItem {
double lowerBound, upperBound;
- int count;
+ std::vector<dive *> dives;
std::vector<QString> label;
QString binName;
int total;
@@ -35,11 +35,15 @@ public:
double value;
std::vector<QString> label;
QString binName;
- StatsOperationResults res;
+ StatsOperationResults res; // Contains the dives
};
struct MultiItem {
+ struct Item {
+ std::vector<dive *> dives;
+ std::vector<QString> label;
+ };
double lowerBound, upperBound;
- std::vector<std::pair<int, std::vector<QString>>> countLabels;
+ std::vector<Item> items;
QString binName;
};
@@ -52,14 +56,14 @@ public:
// are ordered identically.
BarSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis,
bool horizontal, const QString &categoryName,
- const std::vector<CountItem> &items);
+ std::vector<CountItem> items);
BarSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis,
bool horizontal, const QString &categoryName, const StatsVariable *valueVariable,
- const std::vector<ValueItem> &items);
+ std::vector<ValueItem> items);
BarSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis,
bool horizontal, bool stacked, const QString &categoryName, const StatsVariable *valueVariable,
std::vector<QString> valueBinNames,
- const std::vector<MultiItem> &items);
+ std::vector<MultiItem> items);
~BarSeries();
void updatePositions() override;
@@ -93,6 +97,7 @@ private:
struct SubItem {
ChartItemPtr<ChartBarItem> item;
+ std::vector<dive *> dives;
std::unique_ptr<BarLabel> label;
double value_from;
double value_to;
@@ -127,8 +132,13 @@ private:
const StatsVariable *valueVariable; // null: this is count based
std::vector<QString> valueBinNames;
Index highlighted;
- std::vector<SubItem> makeSubItems(double value, const std::vector<QString> &label) const;
- std::vector<SubItem> makeSubItems(const std::vector<std::pair<double, std::vector<QString>>> &values) const;
+ struct SubItemDesc {
+ double v;
+ std::vector<dive *> dives;
+ std::vector<QString> label;
+ };
+ std::vector<SubItem> makeSubItems(SubItemDesc item) const;
+ std::vector<SubItem> makeSubItems(std::vector<SubItemDesc> items) const;
void add_item(double lowerBound, double upperBound, std::vector<SubItem> subitems,
const QString &binName, const StatsOperationResults &res, int total, bool horizontal,
bool stacked);