diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-02-01 23:17:04 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-02-13 13:02:54 -0800 |
commit | d63d4cd3c357a4294e4810ad320acf519b37882d (patch) | |
tree | 3659929714d26a32cca8b2501a609ef2a6b55be2 /stats/chartitem.h | |
parent | e38b78b2aa787e3d1de97fb737601dc30a7fad6b (diff) | |
download | subsurface-d63d4cd3c357a4294e4810ad320acf519b37882d.tar.gz |
statistics: implement rectangle selection in scatter plot
Allow the user to select regions of the scatter plot using
a rectangular selection. When shift is pressed, do an
incremental selection.
Unfortunately, the list-selection code is so slow that this
becomes unusable for a large number of selected dives.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'stats/chartitem.h')
-rw-r--r-- | stats/chartitem.h | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/stats/chartitem.h b/stats/chartitem.h index c700cb421..038054c39 100644 --- a/stats/chartitem.h +++ b/stats/chartitem.h @@ -112,23 +112,35 @@ private: double borderWidth; }; -class ChartLineItem : public HideableChartItem<HideableQSGNode<QSGGeometryNode>> { +// Common data for line and rect items. Both are represented by two points. +class ChartLineItemBase : public HideableChartItem<HideableQSGNode<QSGGeometryNode>> { public: - ChartLineItem(StatsView &v, ChartZValue z, QColor color, double width); - ~ChartLineItem(); + ChartLineItemBase(StatsView &v, ChartZValue z, QColor color, double width); + ~ChartLineItemBase(); void setLine(QPointF from, QPointF to); - void render() override; // Only call on render thread! -private: +protected: QPointF from, to; QColor color; double width; - bool horizontal; bool positionDirty; bool materialDirty; std::unique_ptr<QSGFlatColorMaterial> material; std::unique_ptr<QSGGeometry> geometry; }; +class ChartLineItem : public ChartLineItemBase { +public: + using ChartLineItemBase::ChartLineItemBase; + void render() override; // Only call on render thread! +}; + +// A simple rectangle without fill. Specified by any two opposing vertices. +class ChartRectLineItem : public ChartLineItemBase { +public: + using ChartLineItemBase::ChartLineItemBase; + void render() override; // Only call on render thread! +}; + // A bar in a bar chart: a rectangle bordered by lines. class ChartBarItem : public HideableChartProxyItem<QSGRectangleNode> { public: @@ -185,6 +197,7 @@ public: void render() override; // Only call on render thread! QRectF getRect() const; bool contains(QPointF point) const; + bool inRect(const QRectF &rect) const; private: QSGTexture *getTexture() const; QRectF rect; |