mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
statistics: paint custom grid
With removal of QtCharts' axes, the grid was lost. Readd it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
8dfa3f6db3
commit
ab324ed769
9 changed files with 81 additions and 0 deletions
36
stats/statsgrid.cpp
Normal file
36
stats/statsgrid.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "statsgrid.h"
|
||||
#include "statsaxis.h"
|
||||
#include "statscolors.h"
|
||||
#include "zvalues.h"
|
||||
|
||||
#include <QChart>
|
||||
#include <QGraphicsLineItem>
|
||||
|
||||
static const double gridWidth = 1.0;
|
||||
static const Qt::PenStyle gridStyle = Qt::SolidLine;
|
||||
|
||||
StatsGrid::StatsGrid(QtCharts::QChart *chart, const StatsAxis &xAxis, const StatsAxis &yAxis)
|
||||
: chart(chart), xAxis(xAxis), yAxis(yAxis)
|
||||
{
|
||||
}
|
||||
|
||||
void StatsGrid::updatePositions()
|
||||
{
|
||||
std::vector<double> xtics = xAxis.ticksPositions();
|
||||
std::vector<double> ytics = yAxis.ticksPositions();
|
||||
lines.clear();
|
||||
if (xtics.empty() || ytics.empty())
|
||||
return;
|
||||
|
||||
for (double x: xtics) {
|
||||
lines.emplace_back(new QGraphicsLineItem(x, ytics.front(), x, ytics.back(), chart));
|
||||
lines.back()->setPen(QPen(gridColor, gridWidth, gridStyle));
|
||||
lines.back()->setZValue(ZValues::grid);
|
||||
}
|
||||
for (double y: ytics) {
|
||||
lines.emplace_back(new QGraphicsLineItem(xtics.front(), y, xtics.back(), y, chart));
|
||||
lines.back()->setPen(QPen(gridColor, gridWidth, gridStyle));
|
||||
lines.back()->setZValue(ZValues::grid);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue