summaryrefslogtreecommitdiffstats
path: root/stats/chartitem.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-01-17 21:07:57 +0100
committerGravatar bstoeger <32835590+bstoeger@users.noreply.github.com>2021-01-20 08:47:18 +0100
commit409f159e1d8875f72f50d371860d4aef1975f065 (patch)
treef7a5a3c140ef318b48bb09b74429c8c79239e6f0 /stats/chartitem.h
parent5d5ebfcf3c737aa8c36192eb7bf7d7dee6b33099 (diff)
downloadsubsurface-409f159e1d8875f72f50d371860d4aef1975f065.tar.gz
statistics: convert box-and-whiskers plot to QSG
This is lazy: Derive from the bar chart item and add whiskers in the subclassed render() function. The code is ugly, because the base class function clears the dirty flags and therefore the derived class has to remember them. Oh well. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'stats/chartitem.h')
-rw-r--r--stats/chartitem.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/stats/chartitem.h b/stats/chartitem.h
index a87d5fe10..650c45d53 100644
--- a/stats/chartitem.h
+++ b/stats/chartitem.h
@@ -123,7 +123,7 @@ public:
void setRect(const QRectF &rect);
QRectF getRect() const;
void render() override; // Only call on render thread!
-private:
+protected:
QColor color, borderColor;
double borderWidth;
QRectF rect;
@@ -135,6 +135,22 @@ private:
std::unique_ptr<QSGGeometry> borderGeometry;
};
+// A box-and-whiskers item. This is a bit lazy: derive from the bar item and add whiskers.
+class ChartBoxItem : public ChartBarItem {
+public:
+ ChartBoxItem(StatsView &v, ChartZValue z, double borderWidth);
+ ~ChartBoxItem();
+ void setBox(const QRectF &rect, double min, double max, double median); // The rect describes Q1, Q3.
+ QRectF getRect() const; // Note: this extends the center rectangle to include the whiskers.
+ void render() override; // Only call on render thread!
+private:
+ double min, max, median;
+ std::unique_ptr<QSGGeometryNode> whiskersNode;
+ std::unique_ptr<QSGFlatColorMaterial> whiskersMaterial;
+ std::unique_ptr<QSGGeometry> whiskersGeometry;
+};
+
+
// Implementation detail of templates - move to serparate header file
template <typename Node>
void HideableChartItem<Node>::setVisible(bool visibleIn)