From 9fdec77c94fea880e3cb761ed5a7e57253dfbfb7 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 21 Dec 2018 09:35:41 +0100 Subject: [PATCH] #3919 Contrast colors for contour lines --- .../Application/Tools/RiaColorTools.cpp | 24 +++++++++++++++++-- .../Application/Tools/RiaColorTools.h | 4 +++- .../RivContourMapProjectionPartMgr.cpp | 4 ++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaColorTools.cpp b/ApplicationCode/Application/Tools/RiaColorTools.cpp index 9e8389348d..41053db453 100644 --- a/ApplicationCode/Application/Tools/RiaColorTools.cpp +++ b/ApplicationCode/Application/Tools/RiaColorTools.cpp @@ -81,13 +81,33 @@ cvf::Color3f RiaColorTools::brightContrastColor() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Color3f RiaColorTools::constrastColor(cvf::Color3f backgroundColor) +cvf::Color3f RiaColorTools::darkContrastColorSofter() +{ + return cvf::Color3f::fromByteColor(30, 30, 30); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RiaColorTools::brightContrastColorSofter() +{ + return cvf::Color3f::fromByteColor(200, 200, 200); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RiaColorTools::constrastColor(cvf::Color3f backgroundColor, bool softerContrast) { if (isBrightnessAboveThreshold(backgroundColor)) { + if (softerContrast) + return darkContrastColorSofter(); return darkContrastColor(); } - + if (softerContrast) + return brightContrastColorSofter(); return brightContrastColor(); } diff --git a/ApplicationCode/Application/Tools/RiaColorTools.h b/ApplicationCode/Application/Tools/RiaColorTools.h index cbd15ecf6b..a47338462e 100644 --- a/ApplicationCode/Application/Tools/RiaColorTools.h +++ b/ApplicationCode/Application/Tools/RiaColorTools.h @@ -36,7 +36,9 @@ public: static cvf::Color3f computeOffsetColor(cvf::Color3f color, float offsetFactor); static cvf::Color3f darkContrastColor(); static cvf::Color3f brightContrastColor(); - static cvf::Color3f constrastColor(cvf::Color3f backgroundColor); + static cvf::Color3f darkContrastColorSofter(); + static cvf::Color3f brightContrastColorSofter(); + static cvf::Color3f constrastColor(cvf::Color3f backgroundColor, bool softerContrast = false); static QColor toQColor(cvf::Color3f color, float alpha = 1.0f); static QColor toQColor(cvf::Color4f color); static float contrastRatio(cvf::Color3f color1, cvf::Color3f color2); diff --git a/ApplicationCode/ModelVisualization/RivContourMapProjectionPartMgr.cpp b/ApplicationCode/ModelVisualization/RivContourMapProjectionPartMgr.cpp index f316d4e66d..9210c2cb3b 100644 --- a/ApplicationCode/ModelVisualization/RivContourMapProjectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivContourMapProjectionPartMgr.cpp @@ -62,7 +62,7 @@ void RivContourMapProjectionPartMgr::appendProjectionToModel(cvf::ModelBasicList std::vector> contourDrawables = contourDrawablesForAllLevels[i]; cvf::Color3f backgroundColor(mapper->mapToColor(tickValues[i])); - cvf::Color3f lineColor = RiaColorTools::constrastColor(backgroundColor); + cvf::Color3f lineColor = RiaColorTools::constrastColor(backgroundColor, true); for (cvf::ref contourDrawable : contourDrawables) { @@ -175,7 +175,7 @@ cvf::ref RivContourMapProjectionPartMgr::createTextLabel(cons cvf::ref labelDrawable = new cvf::DrawableText(); labelDrawable->setFont(font.p()); labelDrawable->setCheckPosVisible(true); - labelDrawable->setUseDepthBuffer(false); + labelDrawable->setUseDepthBuffer(true); labelDrawable->setDrawBorder(true); labelDrawable->setDrawBackground(true); labelDrawable->setBackgroundColor(backgroundColor);