aboutsummaryrefslogtreecommitdiffstats
path: root/stats/histogrammarker.cpp
blob: e7b2512e307b4469fdfb2094ecf5c6cec42eb487 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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));
	}
}