#4517 Implement highlighting function for plot curves

This commit is contained in:
Gaute Lindkvist
2019-08-02 13:13:23 +02:00
parent be40ca25af
commit 25f13122a2
5 changed files with 131 additions and 5 deletions

View File

@@ -19,6 +19,7 @@
#include "RiaColorTools.h"
#include "cvfAssert.h"
#include "cvfMath.h"
#include <algorithm>
@@ -141,6 +142,18 @@ cvf::Color3f RiaColorTools::fromQColorTo3f(QColor color)
return cvf::Color3f(color.redF(), color.greenF(), color.blueF());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QColor RiaColorTools::blendQColors(const QColor& color1, const QColor& color2, int weight1 /*= 1*/, int weight2 /*= 1*/)
{
CVF_ASSERT(weight1 > 0 && weight2 > 0);
int weightsum = weight1 + weight2;
return QColor((color1.red() * weight1 + color2.red() * weight2) / weightsum,
(color1.green() * weight1 + color2.green() * weight2) / weightsum,
(color1.blue() * weight1 + color2.blue() * weight2) / weightsum);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -43,6 +43,8 @@ public:
static QColor toQColor(cvf::Color4f color);
static cvf::Color3f fromQColorTo3f(QColor);
static QColor blendQColors(const QColor& color1, const QColor& color2, int weight1 = 1, int weight2 = 1);
private:
static float relativeLuminance(cvf::Color3f backgroundColor);
static float calculateNonLinearColorValue(float colorFraction);