mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3919 Apply contrast colours to contour lines as well.
This commit is contained in:
@@ -35,6 +35,8 @@ RivContourMapProjectionPartMgr::RivContourMapProjectionPartMgr(RimContourMapProj
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivContourMapProjectionPartMgr::appendProjectionToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform) const
|
||||
{
|
||||
cvf::ScalarMapper* mapper = m_contourMapProjection->legendConfig()->scalarMapper();
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> drawable = createProjectionMapDrawable(displayCoordTransform);
|
||||
if (drawable.notNull() && drawable->boundingBox().isValid())
|
||||
{
|
||||
@@ -42,7 +44,6 @@ void RivContourMapProjectionPartMgr::appendProjectionToModel(cvf::ModelBasicList
|
||||
part->setDrawable(drawable.p());
|
||||
|
||||
cvf::ref<cvf::Vec2fArray> textureCoords = createTextureCoords();
|
||||
cvf::ScalarMapper* mapper = m_contourMapProjection->legendConfig()->scalarMapper();
|
||||
RivScalarMapperUtils::applyTextureResultsToPart(part.p(), textureCoords.p(), mapper, 1.0f, caf::FC_NONE, true, m_parentContourMap->backgroundColor());
|
||||
|
||||
part->setSourceInfo(new RivObjectSourceInfo(m_contourMapProjection.p()));
|
||||
@@ -52,14 +53,25 @@ void RivContourMapProjectionPartMgr::appendProjectionToModel(cvf::ModelBasicList
|
||||
|
||||
if (m_contourMapProjection->showContourLines())
|
||||
{
|
||||
std::vector<cvf::ref<cvf::Drawable>> contourDrawables = createContourPolygons(displayCoordTransform);
|
||||
std::vector<double> tickValues;
|
||||
mapper->majorTickValues(&tickValues);
|
||||
|
||||
std::vector<std::vector<cvf::ref<cvf::Drawable>>> contourDrawablesForAllLevels = createContourPolygons(displayCoordTransform);
|
||||
for (size_t i = 0; i < contourDrawablesForAllLevels.size(); ++i)
|
||||
{
|
||||
std::vector<cvf::ref<cvf::Drawable>> contourDrawables = contourDrawablesForAllLevels[i];
|
||||
|
||||
cvf::Color3f backgroundColor(mapper->mapToColor(tickValues[i]));
|
||||
cvf::Color3f lineColor = RiaColorTools::constrastColor(backgroundColor);
|
||||
|
||||
for (cvf::ref<cvf::Drawable> contourDrawable : contourDrawables)
|
||||
{
|
||||
if (contourDrawable.notNull() && contourDrawable->boundingBox().isValid())
|
||||
{
|
||||
caf::MeshEffectGenerator meshEffectGen(cvf::Color3::BLACK);
|
||||
caf::MeshEffectGenerator meshEffectGen(lineColor);
|
||||
meshEffectGen.setLineWidth(1.0f);
|
||||
meshEffectGen.createAndConfigurePolygonOffsetRenderState(caf::PO_1);
|
||||
|
||||
cvf::ref<cvf::Effect> effect = meshEffectGen.generateCachedEffect();
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
@@ -71,6 +83,7 @@ void RivContourMapProjectionPartMgr::appendProjectionToModel(cvf::ModelBasicList
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -155,7 +168,7 @@ cvf::ref<cvf::Vec2fArray> RivContourMapProjectionPartMgr::createTextureCoords()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableText> RivContourMapProjectionPartMgr::createTextLabel(const cvf::Color3f& backgroundColor)
|
||||
cvf::ref<cvf::DrawableText> RivContourMapProjectionPartMgr::createTextLabel(const cvf::Color3f& textColor, const cvf::Color3f& backgroundColor)
|
||||
{
|
||||
auto font = RiaFontCache::getFont(RiaFontCache::FONT_SIZE_8);
|
||||
|
||||
@@ -167,7 +180,6 @@ cvf::ref<cvf::DrawableText> RivContourMapProjectionPartMgr::createTextLabel(cons
|
||||
labelDrawable->setDrawBackground(true);
|
||||
labelDrawable->setBackgroundColor(backgroundColor);
|
||||
labelDrawable->setVerticalAlignment(cvf::TextDrawer::BASELINE);
|
||||
cvf::Color3f textColor = RiaColorTools::constrastColor(backgroundColor);
|
||||
labelDrawable->setTextColor(textColor);
|
||||
|
||||
return labelDrawable;
|
||||
@@ -206,7 +218,7 @@ cvf::ref<cvf::DrawableGeo> RivContourMapProjectionPartMgr::createProjectionMapDr
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<cvf::ref<cvf::Drawable>> RivContourMapProjectionPartMgr::createContourPolygons(const caf::DisplayCoordTransform* displayCoordTransform) const
|
||||
std::vector<std::vector<cvf::ref<cvf::Drawable>>> RivContourMapProjectionPartMgr::createContourPolygons(const caf::DisplayCoordTransform* displayCoordTransform) const
|
||||
{
|
||||
m_contourMapProjection->generateContourPolygons();
|
||||
const std::vector<RimContourMapProjection::ContourPolygons>& contourPolygons = m_contourMapProjection->contourPolygons();
|
||||
@@ -215,11 +227,14 @@ std::vector<cvf::ref<cvf::Drawable>> RivContourMapProjectionPartMgr::createConto
|
||||
std::vector<double> tickValues;
|
||||
mapper->majorTickValues(&tickValues);
|
||||
|
||||
std::vector<cvf::ref<cvf::Drawable>> contourDrawables;
|
||||
std::vector<std::vector<cvf::ref<cvf::Drawable>>> contourDrawablesForAllLevels;
|
||||
std::vector<cvf::ref<cvf::Drawable>> labelDrawables;
|
||||
for (int64_t i = (int64_t) contourPolygons.size() - 1; i > 0; --i)
|
||||
{
|
||||
std::vector<cvf::ref<cvf::Drawable>> contourDrawables;
|
||||
|
||||
cvf::Color3f backgroundColor(mapper->mapToColor(tickValues[i]));
|
||||
cvf::Color3f textColor = RiaColorTools::constrastColor(backgroundColor);
|
||||
|
||||
for (size_t j = 0; j < contourPolygons[i].size(); ++j)
|
||||
{
|
||||
@@ -229,7 +244,7 @@ std::vector<cvf::ref<cvf::Drawable>> RivContourMapProjectionPartMgr::createConto
|
||||
size_t nLabels = m_contourMapProjection->showContourLabels() ? std::max((size_t)1, nVertices / 150u) : 0u;
|
||||
for (size_t l = 0; l < nLabels; ++l)
|
||||
{
|
||||
cvf::ref<cvf::DrawableText> label = createTextLabel(backgroundColor);
|
||||
cvf::ref<cvf::DrawableText> label = createTextLabel(textColor, backgroundColor);
|
||||
cvf::Vec3f labelVertex(displayCoordTransform->transformToDisplayCoord(contourPolygons[i][j].vertices[(nVertices * l) / nLabels]));
|
||||
labelVertex.z() += 3.0f;
|
||||
label->addText(contourPolygons[i][j].label, labelVertex);
|
||||
@@ -274,13 +289,15 @@ std::vector<cvf::ref<cvf::Drawable>> RivContourMapProjectionPartMgr::createConto
|
||||
geo->setVertexArray(vertexArray.p());
|
||||
contourDrawables.push_back(geo);
|
||||
}
|
||||
}
|
||||
for (cvf::ref<cvf::Drawable> labelDrawable : labelDrawables)
|
||||
{
|
||||
contourDrawables.push_back(labelDrawable);
|
||||
}
|
||||
|
||||
return contourDrawables;
|
||||
contourDrawablesForAllLevels.push_back(contourDrawables);
|
||||
}
|
||||
|
||||
return contourDrawablesForAllLevels;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -43,9 +43,9 @@ public:
|
||||
cvf::ref<cvf::Vec2fArray> createTextureCoords() const;
|
||||
|
||||
private:
|
||||
static cvf::ref<cvf::DrawableText> createTextLabel(const cvf::Color3f& backgroundColor);
|
||||
static cvf::ref<cvf::DrawableText> createTextLabel(const cvf::Color3f& textColor, const cvf::Color3f& backgroundColor);
|
||||
cvf::ref<cvf::DrawableGeo> createProjectionMapDrawable(const caf::DisplayCoordTransform* displayCoordTransform) const;
|
||||
std::vector<cvf::ref<cvf::Drawable>> createContourPolygons(const caf::DisplayCoordTransform* displayCoordTransform) const;
|
||||
std::vector<std::vector<cvf::ref<cvf::Drawable>>> createContourPolygons(const caf::DisplayCoordTransform* displayCoordTransform) const;
|
||||
cvf::ref<cvf::DrawableGeo> createPickPointVisDrawable(const caf::DisplayCoordTransform* displayCoordTransform) const;
|
||||
private:
|
||||
caf::PdmPointer<RimContourMapProjection> m_contourMapProjection;
|
||||
|
||||
Reference in New Issue
Block a user