Skip to content

Commit

Permalink
#811 Setting default legend type for category results
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobStoren committed Sep 6, 2016
1 parent 3e8873c commit e4e3c37
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 2 deletions.
24 changes: 24 additions & 0 deletions ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp
Expand Up @@ -75,3 +75,27 @@ void RimGeoMechCellColors::initAfterRead()
{
updateIconState();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechCellColors::updateLegendCategorySettings()
{
if(this->hasCategoryResult())
{
legendConfig->setMappingMode(RimLegendConfig::CATEGORY_INTEGER);
legendConfig->setColorRangeMode(RimLegendConfig::CATEGORY);
}
else
{
if(legendConfig->mappingMode() == RimLegendConfig::CATEGORY_INTEGER)
{
legendConfig->setMappingMode(RimLegendConfig::LINEAR_CONTINUOUS);
}

if(legendConfig->colorRangeMode() == RimLegendConfig::CATEGORY)
{
legendConfig->setColorRangeMode(RimLegendConfig::NORMAL);
}
}
}
3 changes: 3 additions & 0 deletions ApplicationCode/ProjectDataModel/RimGeoMechCellColors.h
Expand Up @@ -43,4 +43,7 @@ class RimGeoMechCellColors : public RimGeoMechResultDefinition

void updateIconState();
virtual void initAfterRead();

protected:
void updateLegendCategorySettings() override;
};
Expand Up @@ -187,6 +187,8 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha

if (dynamic_cast<RimGeoMechCellColors*>(this))
{
this->updateLegendCategorySettings();

if (view)
{
RimViewLinker* viewLinker = view->assosiatedViewLinker();
Expand Down
Expand Up @@ -63,7 +63,8 @@ class RimGeoMechResultDefinition : public caf::PdmObject
bool hasCategoryResult() { return m_resultPositionType() == RIG_FORMATION_NAMES; }

protected:

virtual void updateLegendCategorySettings() {};

private:
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool * useOptionsOnly);
Expand All @@ -82,6 +83,7 @@ class RimGeoMechResultDefinition : public caf::PdmObject

friend class RimGeoMechPropertyFilter; // Property filter needs the ui fields
friend class RimWellLogExtractionCurve; // Curve needs the ui fields
friend class RimGeoMechCellColors; // Needs the ui fields

caf::PdmField<caf::AppEnum<RigFemResultPosEnum> > m_resultPositionTypeUiField;
caf::PdmField<QString> m_resultVariableUiField;
Expand Down
12 changes: 12 additions & 0 deletions ApplicationCode/ProjectDataModel/RimLegendConfig.cpp
Expand Up @@ -549,6 +549,15 @@ void RimLegendConfig::setColorRangeMode(ColorRangesType colorMode)
updateLegend();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimLegendConfig::setMappingMode(MappingType mappingType)
{
m_mappingMode = mappingType;
updateLegend();
}

/*
//--------------------------------------------------------------------------------------------------
///
Expand Down Expand Up @@ -705,6 +714,7 @@ void RimLegendConfig::setCategories(const std::set<int>& globalCategories, const
m_localCategories.set(i++, val);
}
}
updateLegend();
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -749,6 +759,8 @@ void RimLegendConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
mappingGr->add(&m_userDefinedMaxValue);
mappingGr->add(&m_userDefinedMinValue);
}

updateFieldVisibility();
}

//--------------------------------------------------------------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion ApplicationCode/ProjectDataModel/RimLegendConfig.h
Expand Up @@ -97,7 +97,12 @@ class RimLegendConfig: public caf::PdmObject

typedef caf::AppEnum<MappingType> MappingEnum;
void recreateLegend();

void setColorRangeMode(ColorRangesType colorMode);
ColorRangesType colorRangeMode() { return m_colorRangeMode();}
void setMappingMode(MappingType mappingType);
MappingType mappingMode() { return m_mappingMode();}

void setAutomaticRanges(double globalMin, double globalMax, double localMin, double localMax);
void setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero);
void setCategories(const std::set<int>& globalCategories, const std::set<int>& localCategories);
Expand All @@ -107,7 +112,6 @@ class RimLegendConfig: public caf::PdmObject
cvf::ScalarMapper* scalarMapper() { return m_currentScalarMapper.p(); }
cvf::OverlayItem* legend();


protected:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual void initAfterRead();
Expand Down

0 comments on commit e4e3c37

Please sign in to comment.