Skip to content

Commit

Permalink
#1138 - pre-proto - Using legend config for controlling colors of sti…
Browse files Browse the repository at this point in the history
…mPlan fracture
  • Loading branch information
astridkbjorke committed Feb 16, 2017
1 parent 3ae816a commit 8a603c7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
36 changes: 20 additions & 16 deletions ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "cvfPrimitiveSetIndexedUInt.h"
#include "cvfScalarMapperContinuousLinear.h"
#include "RimStimPlanFractureTemplate.h"
#include "RimLegendConfig.h"


//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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<cvf::Vec3f>& nodeCoords = m_rimFracture->nodeCoords();
const std::vector<cvf::uint>& triangleIndices = m_rimFracture->triangleIndices();
Expand All @@ -151,19 +152,20 @@ void RivWellFracturePartMgr::updatePartGeometryTexture(caf::DisplayCoordTransfor
m_part = new cvf::Part;
m_part->setDrawable(geo.p());


cvf::ref<cvf::ScalarMapperContinuousLinear> 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<cvf::ScalarMapperContinuousLinear> 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;

Expand All @@ -186,8 +188,8 @@ void RivWellFracturePartMgr::updatePartGeometryTexture(caf::DisplayCoordTransfor

geo->setTextureCoordArray(textureCoords.p());

caf::ScalarMapperEffectGenerator nncEffgen(scalarMapper.p(), caf::PO_NEG_LARGE);
cvf::ref<cvf::Effect> eff = nncEffgen.generateUnCachedEffect();
caf::ScalarMapperEffectGenerator scalarMapperEffectGenerator(scalarMapper, caf::PO_NEG_LARGE);
cvf::ref<cvf::Effect> eff = scalarMapperEffectGenerator.generateUnCachedEffect();

m_part->setEffect(eff.p());
}
Expand Down Expand Up @@ -217,6 +219,8 @@ std::vector<double> RivWellFracturePartMgr::mirrorDataAtSingleDepth(std::vector<
//--------------------------------------------------------------------------------------------------
void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* model, caf::DisplayCoordTransform* displayCoordTransform)
{
clearGeometryCache();

if (m_part.isNull())
{
if (m_rimFracture->attachedFractureDefinition())
Expand Down
19 changes: 15 additions & 4 deletions ApplicationCode/ProjectDataModel/RimFracture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions ApplicationCode/ProjectDataModel/RimFracture.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class RimFracture : public caf::PdmObject
RimFractureTemplate* attachedFractureDefinition() const;

RivWellFracturePartMgr* fracturePartManager();
RimLegendConfig* activeLegend();

bool hasValidGeometry() const;
void computeGeometry();
Expand Down

0 comments on commit 8a603c7

Please sign in to comment.