From 218c844ad4fa3f562c375b97694025f6cdaa3ca1 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 14 Jan 2021 09:48:44 +0100 Subject: statistics: convert HistogramMarkers to QSGNodes This is in analogy to the quartile markers. Signed-off-by: Berthold Stoeger --- stats/histogrammarker.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 stats/histogrammarker.cpp (limited to 'stats/histogrammarker.cpp') diff --git a/stats/histogrammarker.cpp b/stats/histogrammarker.cpp new file mode 100644 index 000000000..e7b2512e3 --- /dev/null +++ b/stats/histogrammarker.cpp @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "histogrammarker.h" +#include "statsaxis.h" +#include "zvalues.h" + +static const double histogramMarkerWidth = 2.0; + +HistogramMarker::HistogramMarker(StatsView &view, double val, bool horizontal, + QColor color, StatsAxis *xAxis, StatsAxis *yAxis) : + ChartLineItem(view, ChartZValue::ChartFeatures, color, histogramMarkerWidth), + xAxis(xAxis), yAxis(yAxis), + val(val), horizontal(horizontal) +{ +} + +void HistogramMarker::updatePosition() +{ + if (!xAxis || !yAxis) + return; + if (horizontal) { + double y = yAxis->toScreen(val); + auto [x1, x2] = xAxis->minMaxScreen(); + setLine(QPointF(x1, y), QPointF(x2, y)); + } else { + double x = xAxis->toScreen(val); + auto [y1, y2] = yAxis->minMaxScreen(); + setLine(QPointF(x, y1), QPointF(x, y2)); + } +} -- cgit v1.2.3-70-g09d2