mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
3D Cross Plot: Improve colors and symbols in legend
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user