mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
statistics: collect colors in a StatsTheme class
To enable rudimentary theming, collect all colors in a new theme class. The class has to be passed down to the various items. In general the items save a reference to the them in the constructor. Alternatively, they might also just query the StatsView everytime they need to access a color. For now, it's hard the say what is preferred: a reference per item or a function call per invokation? Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
56e02dbcc0
commit
b5aac29cea
25 changed files with 272 additions and 166 deletions
|
@ -2,6 +2,7 @@
|
|||
#include "regressionitem.h"
|
||||
#include "statsaxis.h"
|
||||
#include "statscolors.h"
|
||||
#include "statsview.h"
|
||||
#include "zvalues.h"
|
||||
|
||||
#include <cmath>
|
||||
|
@ -11,6 +12,7 @@ static const double regressionLineWidth = 2.0;
|
|||
RegressionItem::RegressionItem(StatsView &view, regression_data reg,
|
||||
StatsAxis *xAxis, StatsAxis *yAxis) :
|
||||
ChartPixmapItem(view, ChartZValue::ChartFeatures),
|
||||
theme(view.getCurrentTheme()),
|
||||
xAxis(xAxis), yAxis(yAxis), reg(reg),
|
||||
regression(true), confidence(true)
|
||||
{
|
||||
|
@ -86,7 +88,7 @@ void RegressionItem::updatePosition()
|
|||
|
||||
img->fill(Qt::transparent);
|
||||
if (confidence) {
|
||||
QColor col(regressionItemColor);
|
||||
QColor col(theme.regressionItemColor);
|
||||
col.setAlphaF((float)reg.r2);
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->setBrush(QBrush(col));
|
||||
|
@ -94,7 +96,7 @@ void RegressionItem::updatePosition()
|
|||
}
|
||||
|
||||
if (regression) {
|
||||
painter->setPen(QPen(regressionItemColor, regressionLineWidth));
|
||||
painter->setPen(QPen(theme.regressionItemColor, regressionLineWidth));
|
||||
painter->drawLine(QPointF(linePolygon[0]), QPointF(linePolygon[1]));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue