mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
statistics: convert HistogramMarkers to QSGNodes
This is in analogy to the quartile markers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
790d2b2ddb
commit
218c844ad4
6 changed files with 65 additions and 46 deletions
29
stats/histogrammarker.cpp
Normal file
29
stats/histogrammarker.cpp
Normal file
|
@ -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));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue