statistics: render regression item using QSGNode

Render the confidence area and the regression line into a pixmap
and show that using a QSGNode.

It is unclear whether it is preferred to do it this way or to
triangulate the confidence area into triangles to be drawn by
the shader.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-01-15 18:39:14 +01:00 committed by bstoeger
parent faf3e7079d
commit 2008857660
6 changed files with 124 additions and 75 deletions

View file

@ -9,7 +9,6 @@
#include <QImage>
#include <QPainter>
#include <QQuickItem>
#include <QGraphicsPolygonItem>
struct dive;
struct StatsBinner;
@ -17,7 +16,6 @@ struct StatsBin;
struct StatsState;
struct StatsVariable;
class QGraphicsLineItem;
class QGraphicsSimpleTextItem;
class StatsSeries;
class CategoryAxis;
@ -26,6 +24,7 @@ class CountAxis;
class HistogramAxis;
class HistogramMarker;
class QuartileMarker;
class RegressionItem;
class StatsAxis;
class StatsGrid;
class Legend;
@ -36,13 +35,6 @@ enum class ChartSubType : int;
enum class ChartZValue : int;
enum class StatsOperation : int;
struct regression_data {
double a,b;
double res2, r2, sx2, xavg;
int n;
};
class StatsView : public QQuickItem {
Q_OBJECT
public:
@ -127,17 +119,6 @@ private:
// Helper functions to add feature to the chart
void addLineMarker(double pos, double low, double high, const QPen &pen, bool isHorizontal);
// A regression line
struct RegressionLine {
std::unique_ptr<QGraphicsPolygonItem> item;
std::unique_ptr<QGraphicsPolygonItem> central;
StatsAxis *xAxis, *yAxis;
const struct regression_data reg;
void updatePosition();
RegressionLine(const struct regression_data reg, QBrush brush, QGraphicsScene *scene, StatsAxis *xAxis, StatsAxis *yAxis);
};
void addLinearRegression(const struct regression_data reg, StatsAxis *xAxis, StatsAxis *yAxis);
void addHistogramMarker(double pos, QColor color, bool isHorizontal, StatsAxis *xAxis, StatsAxis *yAxis);
StatsState state;
@ -147,9 +128,9 @@ private:
std::vector<std::unique_ptr<StatsSeries>> series;
std::unique_ptr<Legend> legend;
std::vector<std::unique_ptr<QuartileMarker>> quartileMarkers;
std::vector<RegressionLine> regressionLines;
std::vector<std::unique_ptr<HistogramMarker>> histogramMarkers;
std::unique_ptr<QGraphicsSimpleTextItem> title;
std::unique_ptr<RegressionItem> regressionItem;
StatsSeries *highlightedSeries;
StatsAxis *xAxis, *yAxis;
Legend *draggedItem;