diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-01-18 12:35:22 +0100 |
---|---|---|
committer | bstoeger <32835590+bstoeger@users.noreply.github.com> | 2021-01-20 08:47:18 +0100 |
commit | 2480d3b7e0280e34377c2cd1840c0a7770bf18ef (patch) | |
tree | 36daa5a199c9024367ecb0997c51d75a1682ca19 /stats | |
parent | b068b2b0e70c131ee146cc7962979684a0b3a527 (diff) | |
download | subsurface-2480d3b7e0280e34377c2cd1840c0a7770bf18ef.tar.gz |
statistics: remove QGraphicsView from StatSeries
All series are converted to QSG. Thus, the pointer to the
QGraphicsView can be removed from the common base class.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'stats')
-rw-r--r-- | stats/barseries.cpp | 16 | ||||
-rw-r--r-- | stats/barseries.h | 9 | ||||
-rw-r--r-- | stats/boxseries.cpp | 4 | ||||
-rw-r--r-- | stats/boxseries.h | 3 | ||||
-rw-r--r-- | stats/pieseries.cpp | 4 | ||||
-rw-r--r-- | stats/pieseries.h | 3 | ||||
-rw-r--r-- | stats/scatterseries.cpp | 4 | ||||
-rw-r--r-- | stats/scatterseries.h | 3 | ||||
-rw-r--r-- | stats/statsseries.cpp | 4 | ||||
-rw-r--r-- | stats/statsseries.h | 4 | ||||
-rw-r--r-- | stats/statsview.cpp | 2 |
11 files changed, 25 insertions, 31 deletions
diff --git a/stats/barseries.cpp b/stats/barseries.cpp index 7218c3255..84a5ba967 100644 --- a/stats/barseries.cpp +++ b/stats/barseries.cpp @@ -29,19 +29,19 @@ bool BarSeries::Index::operator==(const Index &i2) const return std::tie(bar, subitem) == std::tie(i2.bar, i2.subitem); } -BarSeries::BarSeries(QGraphicsScene *scene, StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, +BarSeries::BarSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, bool horizontal, bool stacked, const QString &categoryName, const StatsVariable *valueVariable, std::vector<QString> valueBinNames) : - StatsSeries(scene, view, xAxis, yAxis), + StatsSeries(view, xAxis, yAxis), horizontal(horizontal), stacked(stacked), categoryName(categoryName), valueVariable(valueVariable), valueBinNames(std::move(valueBinNames)) { } -BarSeries::BarSeries(QGraphicsScene *scene, StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, +BarSeries::BarSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, bool horizontal, const QString &categoryName, const std::vector<CountItem> &items) : - BarSeries(scene, view, xAxis, yAxis, horizontal, false, categoryName, nullptr, std::vector<QString>()) + BarSeries(view, xAxis, yAxis, horizontal, false, categoryName, nullptr, std::vector<QString>()) { for (const CountItem &item: items) { StatsOperationResults res; @@ -52,10 +52,10 @@ BarSeries::BarSeries(QGraphicsScene *scene, StatsView &view, StatsAxis *xAxis, S } } -BarSeries::BarSeries(QGraphicsScene *scene, StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, +BarSeries::BarSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, bool horizontal, const QString &categoryName, const StatsVariable *valueVariable, const std::vector<ValueItem> &items) : - BarSeries(scene, view, xAxis, yAxis, horizontal, false, categoryName, valueVariable, std::vector<QString>()) + BarSeries(view, xAxis, yAxis, horizontal, false, categoryName, valueVariable, std::vector<QString>()) { for (const ValueItem &item: items) { add_item(item.lowerBound, item.upperBound, makeSubItems(item.value, item.label), @@ -63,11 +63,11 @@ BarSeries::BarSeries(QGraphicsScene *scene, StatsView &view, StatsAxis *xAxis, S } } -BarSeries::BarSeries(QGraphicsScene *scene, StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, +BarSeries::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) : - BarSeries(scene, view, xAxis, yAxis, horizontal, stacked, categoryName, valueVariable, std::move(valueBinNames)) + BarSeries(view, xAxis, yAxis, horizontal, stacked, categoryName, valueVariable, std::move(valueBinNames)) { for (const MultiItem &item: items) { StatsOperationResults res; diff --git a/stats/barseries.h b/stats/barseries.h index 5655bc977..5f030ad76 100644 --- a/stats/barseries.h +++ b/stats/barseries.h @@ -12,7 +12,6 @@ #include <vector> #include <QRectF> -class QGraphicsScene; class ChartBarItem; class ChartTextItem; struct InformationBox; @@ -49,13 +48,13 @@ public: // Note: this expects that all items are added with increasing pos // and that no bar is inside another bar, i.e. lowerBound and upperBound // are ordered identically. - BarSeries(QGraphicsScene *scene, StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, + BarSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, bool horizontal, const QString &categoryName, const std::vector<CountItem> &items); - BarSeries(QGraphicsScene *scene, StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, + BarSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, bool horizontal, const QString &categoryName, const StatsVariable *valueVariable, const std::vector<ValueItem> &items); - BarSeries(QGraphicsScene *scene, StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, + 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); @@ -65,7 +64,7 @@ public: bool hover(QPointF pos) override; void unhighlight() override; private: - BarSeries(QGraphicsScene *scene, StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, + BarSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, bool horizontal, bool stacked, const QString &categoryName, const StatsVariable *valueVariable, std::vector<QString> valueBinNames); diff --git a/stats/boxseries.cpp b/stats/boxseries.cpp index 2d6800e05..4d3b90f21 100644 --- a/stats/boxseries.cpp +++ b/stats/boxseries.cpp @@ -14,9 +14,9 @@ static const double boxWidth = 0.8; // 1.0 = full width of category static const int boxBorderWidth = 2.0; -BoxSeries::BoxSeries(QGraphicsScene *scene, StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, +BoxSeries::BoxSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, const QString &variable, const QString &unit, int decimals) : - StatsSeries(scene, view, xAxis, yAxis), + StatsSeries(view, xAxis, yAxis), variable(variable), unit(unit), decimals(decimals), highlighted(-1) { } diff --git a/stats/boxseries.h b/stats/boxseries.h index 487870701..41248688b 100644 --- a/stats/boxseries.h +++ b/stats/boxseries.h @@ -13,11 +13,10 @@ #include <vector> struct InformationBox; -class QGraphicsScene; class BoxSeries : public StatsSeries { public: - BoxSeries(QGraphicsScene *scene, StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, + BoxSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, const QString &variable, const QString &unit, int decimals); ~BoxSeries(); diff --git a/stats/pieseries.cpp b/stats/pieseries.cpp index 09e74961a..83b1645f1 100644 --- a/stats/pieseries.cpp +++ b/stats/pieseries.cpp @@ -74,9 +74,9 @@ void PieSeries::Item::highlight(ChartPieItem &item, int bin_nr, bool highlight, highlight ? highlightedBorderColor : ::borderColor); } -PieSeries::PieSeries(QGraphicsScene *scene, StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, const QString &categoryName, +PieSeries::PieSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, const QString &categoryName, const std::vector<std::pair<QString, int>> &data, bool keepOrder, bool labels) : - StatsSeries(scene, view, xAxis, yAxis), + StatsSeries(view, xAxis, yAxis), item(view.createChartItem<ChartPieItem>(ChartZValue::Series, pieBorderWidth)), categoryName(categoryName), highlighted(-1) diff --git a/stats/pieseries.h b/stats/pieseries.h index d9dd1b5fb..da1886500 100644 --- a/stats/pieseries.h +++ b/stats/pieseries.h @@ -12,7 +12,6 @@ struct InformationBox; struct ChartPieItem; struct ChartTextItem; -class QGraphicsScene; class QRectF; class PieSeries : public StatsSeries { @@ -20,7 +19,7 @@ public: // The pie series is initialized with (name, count) pairs. // If keepOrder is false, bins will be sorted by size, otherwise the sorting // of the shown bins will be retained. Small bins are omitted for clarity. - PieSeries(QGraphicsScene *scene, StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, const QString &categoryName, + PieSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, const QString &categoryName, const std::vector<std::pair<QString, int>> &data, bool keepOrder, bool labels); ~PieSeries(); diff --git a/stats/scatterseries.cpp b/stats/scatterseries.cpp index 5453b8ee5..e522ce81f 100644 --- a/stats/scatterseries.cpp +++ b/stats/scatterseries.cpp @@ -12,9 +12,9 @@ #include "core/divelist.h" #include "core/qthelper.h" -ScatterSeries::ScatterSeries(QGraphicsScene *scene, StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, +ScatterSeries::ScatterSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, const StatsVariable &varX, const StatsVariable &varY) : - StatsSeries(scene, view, xAxis, yAxis), + StatsSeries(view, xAxis, yAxis), varX(varX), varY(varY) { } diff --git a/stats/scatterseries.h b/stats/scatterseries.h index b83b6bcad..d747f3c8d 100644 --- a/stats/scatterseries.h +++ b/stats/scatterseries.h @@ -9,7 +9,6 @@ #include <memory> #include <vector> -class QGraphicsScene; class ChartScatterItem; struct InformationBox; struct StatsVariable; @@ -17,7 +16,7 @@ struct dive; class ScatterSeries : public StatsSeries { public: - ScatterSeries(QGraphicsScene *scene, StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, + ScatterSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, const StatsVariable &varX, const StatsVariable &varY); ~ScatterSeries(); diff --git a/stats/statsseries.cpp b/stats/statsseries.cpp index ae12c7403..60e54e127 100644 --- a/stats/statsseries.cpp +++ b/stats/statsseries.cpp @@ -2,8 +2,8 @@ #include "statsseries.h" #include "statsaxis.h" -StatsSeries::StatsSeries(QGraphicsScene *scene, StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis) : - scene(scene), view(view), xAxis(xAxis), yAxis(yAxis) +StatsSeries::StatsSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis) : + view(view), xAxis(xAxis), yAxis(yAxis) { } diff --git a/stats/statsseries.h b/stats/statsseries.h index b24be7a79..360396601 100644 --- a/stats/statsseries.h +++ b/stats/statsseries.h @@ -6,19 +6,17 @@ #include <QPointF> -class QGraphicsScene; class StatsAxis; class StatsView; class StatsSeries { public: - StatsSeries(QGraphicsScene *scene, StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis); + StatsSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis); 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. protected: - QGraphicsScene *scene; StatsView &view; StatsAxis *xAxis, *yAxis; // May be zero for charts without axes (pie charts). QPointF toScreen(QPointF p); diff --git a/stats/statsview.cpp b/stats/statsview.cpp index e616c3e12..5acf3ecaf 100644 --- a/stats/statsview.cpp +++ b/stats/statsview.cpp @@ -298,7 +298,7 @@ void StatsView::hoverMoveEvent(QHoverEvent *event) template <typename T, class... Args> T *StatsView::createSeries(Args&&... args) { - T *res = new T(&scene, *this, xAxis, yAxis, std::forward<Args>(args)...); + T *res = new T(*this, xAxis, yAxis, std::forward<Args>(args)...); series.emplace_back(res); series.back()->updatePositions(); return res; |