3D Cross Plot: Improve colors and symbols in legend

This commit is contained in:
Gaute Lindkvist
2019-02-21 15:42:02 +01:00
parent 6b3808b696
commit 7e57ec39ea
10 changed files with 93 additions and 15 deletions

View File

@@ -17,6 +17,9 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RiaColorTables.h"
#include "RiaColorTools.h"
#include "cvfAssert.h"
#include <QColor>
@@ -538,6 +541,32 @@ RiaColorTables::WellPathComponentColors RiaColorTables::wellPathComponentColors(
{RiaDefines::UNDEFINED_COMPONENT, cvf::Color3::MAGENTA}};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::ColorTable RiaColorTables::createBrightnessBasedColorTable(cvf::Color3ub baseColor, int brightnessLevelCount)
{
CVF_ASSERT(brightnessLevelCount >= 1);
QColor baseRGB(baseColor.r(), baseColor.g(), baseColor.b());
float hueF = baseRGB.hslHueF();
float satF = baseRGB.hslSaturationF();
std::vector<cvf::Color3ub> colors;
if (brightnessLevelCount == 1)
{
colors.push_back(cvf::Color3ub(RiaColorTools::fromQColorTo3f(QColor::fromHslF(hueF, satF, 0.5))));
}
else
{
for (int i = 0; i < brightnessLevelCount; ++i)
{
float brightness = static_cast<float>(i) / static_cast<float>(brightnessLevelCount - 1);
colors.push_back(cvf::Color3ub(RiaColorTools::fromQColorTo3f(QColor::fromHslF(hueF, satF, brightness))));
}
}
return caf::ColorTable(colors);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -64,6 +64,7 @@ public:
static WellPathComponentColors wellPathComponentColors();
static caf::ColorTable createBrightnessBasedColorTable(cvf::Color3ub baseColor, int brightnessLevelCount);
private:
static std::vector<cvf::Color3ub> categoryColors();
static std::vector<cvf::Color3ub> contrastCategoryColors();

View File

@@ -133,6 +133,14 @@ QColor RiaColorTools::toQColor(cvf::Color4f color)
return toQColor(color.toColor3f(), color.a());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Color3f RiaColorTools::fromQColorTo3f(QColor color)
{
return cvf::Color3f(color.redF(), color.greenF(), color.blueF());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -41,6 +41,7 @@ public:
static cvf::Color3f contrastColor(cvf::Color3f backgroundColor, bool softerContrast = false);
static QColor toQColor(cvf::Color3f color, float alpha = 1.0f);
static QColor toQColor(cvf::Color4f color);
static cvf::Color3f fromQColorTo3f(QColor);
static float contrastRatio(cvf::Color3f color1, cvf::Color3f color2);
private:
static float relativeLuminance(cvf::Color3f backgroundColor);