diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-01-14 08:48:56 +0100 |
---|---|---|
committer | bstoeger <32835590+bstoeger@users.noreply.github.com> | 2021-01-20 08:47:18 +0100 |
commit | 790d2b2ddb36fd39fe8f002290288603ba1f0065 (patch) | |
tree | 95382527bd02bb60be9ebf8c22e577d74b41d8c7 /stats/quartilemarker.cpp | |
parent | b1c0d424081530161c1637a1a24ff07a4b021097 (diff) | |
download | subsurface-790d2b2ddb36fd39fe8f002290288603ba1f0065.tar.gz |
statistics: convert QuartileMarkers to QSGNodes
Slowly converting the QGraphicsScene items to QSGNodes to
avoid full replot of the scene.
This adds a new abstraction for line-nodes. Since the render()
function here is fundamentally different from the pixmap-nodes
we had so far, this has to be made virtual.
Also, move the quartile markers to their own source file,
since the StatsView source file is quite huge already.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'stats/quartilemarker.cpp')
-rw-r--r-- | stats/quartilemarker.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/stats/quartilemarker.cpp b/stats/quartilemarker.cpp new file mode 100644 index 000000000..ace019df5 --- /dev/null +++ b/stats/quartilemarker.cpp @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "quartilemarker.h" +#include "statsaxis.h" +#include "zvalues.h" + +static const QColor quartileMarkerColor(Qt::red); +static const double quartileMarkerSize = 15.0; + +QuartileMarker::QuartileMarker(StatsView &view, double pos, double value, StatsAxis *xAxis, StatsAxis *yAxis) : + ChartLineItem(view, ChartZValue::ChartFeatures, quartileMarkerColor, 2.0), + xAxis(xAxis), yAxis(yAxis), + pos(pos), + value(value) +{ + updatePosition(); +} + +QuartileMarker::~QuartileMarker() +{ +} + +void QuartileMarker::updatePosition() +{ + if (!xAxis || !yAxis) + return; + double x = xAxis->toScreen(pos); + double y = yAxis->toScreen(value); + setLine(QPointF(x - quartileMarkerSize / 2.0, y), + QPointF(x + quartileMarkerSize / 2.0, y)); +} |