aboutsummaryrefslogtreecommitdiffstats
path: root/stats/chartitem.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-01-18 12:08:46 +0100
committerGravatar bstoeger <32835590+bstoeger@users.noreply.github.com>2021-01-20 08:47:18 +0100
commitb068b2b0e70c131ee146cc7962979684a0b3a527 (patch)
tree949c2a4b4ca0d7b219af435e29286e26fc65e4ee /stats/chartitem.h
parentb07a7fe5f10529f7fde0b7d5f614aa311b18dcc7 (diff)
downloadsubsurface-b068b2b0e70c131ee146cc7962979684a0b3a527.tar.gz
statistics: replace PieSeries by QSG nodes
Since there are no disk-segment QSG primitives (one could draw a triangle fan, but that doesn't seem optimal), this draws into a pixmap and blits that as a QSG node. Since this is the only series without axis, it needs a function that returns the size of the plot area. This didn't exist, so add it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'stats/chartitem.h')
-rw-r--r--stats/chartitem.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/stats/chartitem.h b/stats/chartitem.h
index 338c23b8b..44caae9cc 100644
--- a/stats/chartitem.h
+++ b/stats/chartitem.h
@@ -62,8 +62,8 @@ protected:
std::unique_ptr<QImage> img;
void setTextureDirty();
void setPositionDirty();
-private:
QRectF rect;
+private:
bool positionDirty; // true if the position changed since last render
bool textureDirty; // true if the pixmap changed since last render
std::unique_ptr<QSGTexture> texture;
@@ -85,6 +85,7 @@ private:
class ChartTextItem : public ChartPixmapItem {
public:
ChartTextItem(StatsView &v, ChartZValue z, const QFont &f, const std::vector<QString> &text, bool center);
+ ChartTextItem(StatsView &v, ChartZValue z, const QFont &f, const QString &text);
void setColor(const QColor &color);
private:
QFont f;
@@ -97,6 +98,16 @@ private:
std::vector<Item> items;
};
+// A pie chart item: draws disk segments onto a pixmap.
+class ChartPieItem : public ChartPixmapItem {
+public:
+ ChartPieItem(StatsView &v, ChartZValue z, double borderWidth);
+ void drawSegment(double from, double to, QColor fill, QColor border); // from and to are relative (0-1 is full disk).
+ void resize(QSizeF size); // As in base class, but clears the canvas
+private:
+ double borderWidth;
+};
+
class ChartLineItem : public HideableChartItem<HideableQSGNode<QSGGeometryNode>> {
public:
ChartLineItem(StatsView &v, ChartZValue z, QColor color, double width);