mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
b068b2b0e7
commit
2480d3b7e0
11 changed files with 25 additions and 31 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue