summaryrefslogtreecommitdiffstats
path: root/stats/regressionitem.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-01-19 11:18:10 +0100
committerGravatar bstoeger <32835590+bstoeger@users.noreply.github.com>2021-01-20 08:47:18 +0100
commitba259fb1d66c242d9503ba9695ce55826370267e (patch)
tree440524313df74c492c35d02dbcbe209abd5e3566 /stats/regressionitem.cpp
parentff536e98fc3e88c3c4fd769229cf901a9f272be0 (diff)
downloadsubsurface-ba259fb1d66c242d9503ba9695ce55826370267e.tar.gz
statistics: make confidence area and regression line opt-in
This is not perfect - the polygon of the confidence area is calculated even if it is not shown. Oh well. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'stats/regressionitem.cpp')
-rw-r--r--stats/regressionitem.cpp31
1 files changed, 23 insertions, 8 deletions
diff --git a/stats/regressionitem.cpp b/stats/regressionitem.cpp
index db02cf688..cd817c9eb 100644
--- a/stats/regressionitem.cpp
+++ b/stats/regressionitem.cpp
@@ -11,7 +11,8 @@ static const double regressionLineWidth = 2.0;
RegressionItem::RegressionItem(StatsView &view, regression_data reg,
StatsAxis *xAxis, StatsAxis *yAxis) :
ChartPixmapItem(view, ChartZValue::ChartFeatures),
- xAxis(xAxis), yAxis(yAxis), reg(reg)
+ xAxis(xAxis), yAxis(yAxis), reg(reg),
+ regression(true), confidence(true)
{
}
@@ -19,6 +20,16 @@ RegressionItem::~RegressionItem()
{
}
+void RegressionItem::setFeatures(bool regressionIn, bool confidenceIn)
+{
+ if (regressionIn == regression && confidenceIn == confidence)
+ return;
+ regression = regressionIn;
+ confidence = confidenceIn;
+ updatePosition();
+}
+
+// Note: this calculates the confidence area, even if it isn't shown. Might want to optimize this.
void RegressionItem::updatePosition()
{
if (!xAxis || !yAxis)
@@ -74,14 +85,18 @@ void RegressionItem::updatePosition()
ChartPixmapItem::resize(QSizeF(screenMaxX - screenMinX, screenMaxY - screenMinY));
img->fill(Qt::transparent);
- QColor col(regressionItemColor);
- col.setAlphaF(reg.r2);
- painter->setPen(Qt::NoPen);
- painter->setBrush(QBrush(col));
- painter->drawPolygon(poly);
+ if (confidence) {
+ QColor col(regressionItemColor);
+ col.setAlphaF(reg.r2);
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(QBrush(col));
+ painter->drawPolygon(poly);
+ }
- painter->setPen(QPen(regressionItemColor, regressionLineWidth));
- painter->drawLine(QPointF(linePolygon[0]), QPointF(linePolygon[1]));
+ if (regression) {
+ painter->setPen(QPen(regressionItemColor, regressionLineWidth));
+ painter->drawLine(QPointF(linePolygon[0]), QPointF(linePolygon[1]));
+ }
ChartPixmapItem::setPos(offset);
}