diff options
Diffstat (limited to 'stats/barseries.h')
-rw-r--r-- | stats/barseries.h | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/stats/barseries.h b/stats/barseries.h index 0c8c34ffd..9f9586fe8 100644 --- a/stats/barseries.h +++ b/stats/barseries.h @@ -5,14 +5,17 @@ #ifndef BAR_SERIES_H #define BAR_SERIES_H +#include "statshelper.h" #include "statsseries.h" #include "statsvariables.h" #include <memory> #include <vector> -#include <QGraphicsRectItem> +#include <QColor> +#include <QRectF> -class QGraphicsScene; +class ChartBarItem; +class ChartTextItem; struct InformationBox; struct StatsVariable; @@ -47,13 +50,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, StatsAxis *xAxis, StatsAxis *yAxis, + BarSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, bool horizontal, const QString &categoryName, const std::vector<CountItem> &items); - BarSeries(QGraphicsScene *scene, 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, 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); @@ -63,7 +66,7 @@ public: bool hover(QPointF pos) override; void unhighlight() override; private: - BarSeries(QGraphicsScene *scene, 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); @@ -80,21 +83,21 @@ private: // A label that is composed of multiple lines struct BarLabel { - std::vector<std::unique_ptr<QGraphicsSimpleTextItem>> items; - double totalWidth, totalHeight; // Size of the item + ChartItemPtr<ChartTextItem> item; bool isOutside; // Is shown outside of bar - BarLabel(QGraphicsScene *scene, const std::vector<QString> &labels, int bin_nr, int binCount); + BarLabel(StatsView &view, const std::vector<QString> &labels, int bin_nr, int binCount); void setVisible(bool visible); - void updatePosition(bool horizontal, bool center, const QRectF &rect, int bin_nr, int binCount); - void highlight(bool highlight, int bin_nr, int binCount); + void updatePosition(bool horizontal, bool center, const QRectF &rect, int bin_nr, int binCount, const QColor &background); + void highlight(bool highlight, int bin_nr, int binCount, const QColor &background); }; struct SubItem { - std::unique_ptr<QGraphicsRectItem> item; + ChartItemPtr<ChartBarItem> item; std::unique_ptr<BarLabel> label; double value_from; double value_to; int bin_nr; + QColor fill; void updatePosition(BarSeries *series, bool horizontal, bool stacked, double from, double to, int binCount); void highlight(bool highlight, int binCount); @@ -107,7 +110,7 @@ private: const QString binName; StatsOperationResults res; int total; - Item(QGraphicsScene *scene, BarSeries *series, double lowerBound, double upperBound, + Item(BarSeries *series, double lowerBound, double upperBound, std::vector<SubItem> subitems, const QString &binName, const StatsOperationResults &res, int total, bool horizontal, bool stacked, int binCount); @@ -116,9 +119,8 @@ private: int getSubItemUnderMouse(const QPointF &f, bool horizontal, bool stacked) const; }; - std::unique_ptr<InformationBox> information; + ChartItemPtr<InformationBox> information; std::vector<Item> items; - std::vector<BarLabel> barLabels; bool horizontal; bool stacked; QString categoryName; |