mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
b1c0d42408
commit
790d2b2ddb
8 changed files with 172 additions and 58 deletions
|
@ -4,6 +4,7 @@
|
|||
#include "boxseries.h"
|
||||
#include "legend.h"
|
||||
#include "pieseries.h"
|
||||
#include "quartilemarker.h"
|
||||
#include "scatterseries.h"
|
||||
#include "statsaxis.h"
|
||||
#include "statscolors.h"
|
||||
|
@ -25,8 +26,6 @@
|
|||
#include <QSGTexture>
|
||||
|
||||
// Constants that control the graph layouts
|
||||
static const QColor quartileMarkerColor(Qt::red);
|
||||
static const double quartileMarkerSize = 15.0;
|
||||
static const double sceneBorder = 5.0; // Border between scene edges and statitistics view
|
||||
static const double titleBorder = 2.0; // Border between title and chart
|
||||
|
||||
|
@ -211,8 +210,8 @@ void StatsView::plotAreaChanged(const QSizeF &s)
|
|||
grid->updatePositions();
|
||||
for (auto &series: series)
|
||||
series->updatePositions();
|
||||
for (QuartileMarker &marker: quartileMarkers)
|
||||
marker.updatePosition();
|
||||
for (auto &marker: quartileMarkers)
|
||||
marker->updatePosition();
|
||||
for (RegressionLine &line: regressionLines)
|
||||
line.updatePosition();
|
||||
for (HistogramMarker &marker: histogramMarkers)
|
||||
|
@ -799,36 +798,18 @@ void StatsView::plotDiscreteScatter(const std::vector<dive *> &dives,
|
|||
if (quartiles) {
|
||||
StatsQuartiles quartiles = StatsVariable::quartiles(array);
|
||||
if (quartiles.isValid()) {
|
||||
quartileMarkers.emplace_back(x, quartiles.q1, &scene, catAxis, valAxis);
|
||||
quartileMarkers.emplace_back(x, quartiles.q2, &scene, catAxis, valAxis);
|
||||
quartileMarkers.emplace_back(x, quartiles.q3, &scene, catAxis, valAxis);
|
||||
quartileMarkers.push_back(createChartItem<QuartileMarker>(
|
||||
x, quartiles.q1, catAxis, valAxis));
|
||||
quartileMarkers.push_back(createChartItem<QuartileMarker>(
|
||||
x, quartiles.q2, catAxis, valAxis));
|
||||
quartileMarkers.push_back(createChartItem<QuartileMarker>(
|
||||
x, quartiles.q3, catAxis, valAxis));
|
||||
}
|
||||
}
|
||||
x += 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
StatsView::QuartileMarker::QuartileMarker(double pos, double value, QGraphicsScene *scene, StatsAxis *xAxis, StatsAxis *yAxis) :
|
||||
item(createItemPtr<QGraphicsLineItem>(scene)),
|
||||
xAxis(xAxis), yAxis(yAxis),
|
||||
pos(pos),
|
||||
value(value)
|
||||
{
|
||||
item->setZValue(ZValues::chartFeatures);
|
||||
item->setPen(QPen(quartileMarkerColor, 2.0));
|
||||
updatePosition();
|
||||
}
|
||||
|
||||
void StatsView::QuartileMarker::updatePosition()
|
||||
{
|
||||
if (!xAxis || !yAxis)
|
||||
return;
|
||||
double x = xAxis->toScreen(pos);
|
||||
double y = yAxis->toScreen(value);
|
||||
item->setLine(x - quartileMarkerSize / 2.0, y,
|
||||
x + quartileMarkerSize / 2.0, y);
|
||||
}
|
||||
|
||||
StatsView::RegressionLine::RegressionLine(const struct regression_data reg, QBrush brush, QGraphicsScene *scene, StatsAxis *xAxis, StatsAxis *yAxis) :
|
||||
item(createItemPtr<QGraphicsPolygonItem>(scene)),
|
||||
central(createItemPtr<QGraphicsPolygonItem>(scene)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue