From 8a603c7f7340b4c38f6833bafa9a5bfe2e96c0e9 Mon Sep 17 00:00:00 2001 From: astridkbjorke Date: Thu, 16 Feb 2017 09:15:23 +0100 Subject: [PATCH] #1138 - pre-proto - Using legend config for controlling colors of stimPlan fracture --- .../RivWellFracturePartMgr.cpp | 36 ++++++++++--------- .../ProjectDataModel/RimFracture.cpp | 19 +++++++--- .../ProjectDataModel/RimFracture.h | 1 + 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 4f82b878fa..21d47e7c50 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -32,6 +32,7 @@ #include "cvfPrimitiveSetIndexedUInt.h" #include "cvfScalarMapperContinuousLinear.h" #include "RimStimPlanFractureTemplate.h" +#include "RimLegendConfig.h" //-------------------------------------------------------------------------------------------------- @@ -133,7 +134,7 @@ void RivWellFracturePartMgr::updatePartGeometryTexture(caf::DisplayCoordTransfor dataToPlot = stimPlanFracTemplate->getWidthsAtTimeStep(timeStepIndex); } - if (dataToPlot.empty()) return; + if (dataToPlot.empty()) return; //TODO: Set all values to undefined if no data available... const std::vector& nodeCoords = m_rimFracture->nodeCoords(); const std::vector& triangleIndices = m_rimFracture->triangleIndices(); @@ -151,19 +152,20 @@ void RivWellFracturePartMgr::updatePartGeometryTexture(caf::DisplayCoordTransfor m_part = new cvf::Part; m_part->setDrawable(geo.p()); - - cvf::ref scalarMapper = new cvf::ScalarMapperContinuousLinear; - { - cvf::Color3ubArray legendColors; - legendColors.resize(4); - legendColors[0] = cvf::Color3::GRAY; - legendColors[1] = cvf::Color3::GREEN; - legendColors[2] = cvf::Color3::BLUE; - legendColors[3] = cvf::Color3::RED; - scalarMapper->setColors(legendColors); - scalarMapper->setRange(0.0, 4.0); - scalarMapper->setLevelCount(4, true); - } + RimLegendConfig* legend = m_rimFracture->activeLegend(); + cvf::ScalarMapper* scalarMapper = legend->scalarMapper(); +// cvf::ref scalarMapper = new cvf::ScalarMapperContinuousLinear; +// { +// cvf::Color3ubArray legendColors; +// legendColors.resize(4); +// legendColors[0] = cvf::Color3::GRAY; +// legendColors[1] = cvf::Color3::GREEN; +// legendColors[2] = cvf::Color3::BLUE; +// legendColors[3] = cvf::Color3::RED; +// scalarMapper->setColors(legendColors); +// scalarMapper->setRange(0.0, 4.0); +// scalarMapper->setLevelCount(4, true); +// } //double scalarValue = i % 4; @@ -186,8 +188,8 @@ void RivWellFracturePartMgr::updatePartGeometryTexture(caf::DisplayCoordTransfor geo->setTextureCoordArray(textureCoords.p()); - caf::ScalarMapperEffectGenerator nncEffgen(scalarMapper.p(), caf::PO_NEG_LARGE); - cvf::ref eff = nncEffgen.generateUnCachedEffect(); + caf::ScalarMapperEffectGenerator scalarMapperEffectGenerator(scalarMapper, caf::PO_NEG_LARGE); + cvf::ref eff = scalarMapperEffectGenerator.generateUnCachedEffect(); m_part->setEffect(eff.p()); } @@ -217,6 +219,8 @@ std::vector RivWellFracturePartMgr::mirrorDataAtSingleDepth(std::vector< //-------------------------------------------------------------------------------------------------- void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* model, caf::DisplayCoordTransform* displayCoordTransform) { + clearGeometryCache(); + if (m_part.isNull()) { if (m_rimFracture->attachedFractureDefinition()) diff --git a/ApplicationCode/ProjectDataModel/RimFracture.cpp b/ApplicationCode/ProjectDataModel/RimFracture.cpp index 14dd845697..4a185ee1ef 100644 --- a/ApplicationCode/ProjectDataModel/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/RimFracture.cpp @@ -705,10 +705,9 @@ void RimFracture::defineEditorAttribute(const caf::PdmFieldHandle* field, QStrin //-------------------------------------------------------------------------------------------------- void RimFracture::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) { - // TODO: Based on selected result, show correct legend - if (RimFracture::CONDUCTIVITY) uiTreeOrdering.add(m_legendConfigConductivity); - if (RimFracture::PERMEABILITY) uiTreeOrdering.add(m_legendConfigPermeability); - if (RimFracture::WIDTH) uiTreeOrdering.add(m_legendConfigWidth); + if (stimPlanParameterToPlot == RimFracture::CONDUCTIVITY) uiTreeOrdering.add(m_legendConfigConductivity); + else if (stimPlanParameterToPlot == RimFracture::PERMEABILITY) uiTreeOrdering.add(m_legendConfigPermeability); + else if (stimPlanParameterToPlot == RimFracture::WIDTH) uiTreeOrdering.add(m_legendConfigWidth); uiTreeOrdering.setForgetRemainingFields(true); } @@ -794,6 +793,18 @@ RivWellFracturePartMgr* RimFracture::fracturePartManager() return m_rivFracture.p(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimLegendConfig* RimFracture::activeLegend() +{ + if (stimPlanParameterToPlot == RimFracture::CONDUCTIVITY) return m_legendConfigConductivity; + else if (stimPlanParameterToPlot == RimFracture::PERMEABILITY) return m_legendConfigPermeability; + else if (stimPlanParameterToPlot == RimFracture::WIDTH) return m_legendConfigWidth; + + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimFracture.h b/ApplicationCode/ProjectDataModel/RimFracture.h index 91a57a0ddf..34252eca75 100644 --- a/ApplicationCode/ProjectDataModel/RimFracture.h +++ b/ApplicationCode/ProjectDataModel/RimFracture.h @@ -80,6 +80,7 @@ class RimFracture : public caf::PdmObject RimFractureTemplate* attachedFractureDefinition() const; RivWellFracturePartMgr* fracturePartManager(); + RimLegendConfig* activeLegend(); bool hasValidGeometry() const; void computeGeometry();