#811 Setting default legend type for category results

This commit is contained in:
Jacob Støren 2016-09-06 14:03:02 +02:00
parent 3e8873c870
commit e4e3c37f89
6 changed files with 49 additions and 2 deletions

View File

@ -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);
}
}
}

View File

@ -43,4 +43,7 @@ public:
void updateIconState();
virtual void initAfterRead();
protected:
void updateLegendCategorySettings() override;
};

View File

@ -187,6 +187,8 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha
if (dynamic_cast<RimGeoMechCellColors*>(this))
{
this->updateLegendCategorySettings();
if (view)
{
RimViewLinker* viewLinker = view->assosiatedViewLinker();

View File

@ -63,7 +63,8 @@ public:
bool hasCategoryResult() { return m_resultPositionType() == RIG_FORMATION_NAMES; }
protected:
virtual void updateLegendCategorySettings() {};
private:
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool * useOptionsOnly);
@ -82,6 +83,7 @@ private:
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;

View File

@ -549,6 +549,15 @@ void RimLegendConfig::setColorRangeMode(ColorRangesType colorMode)
updateLegend();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimLegendConfig::setMappingMode(MappingType mappingType)
{
m_mappingMode = mappingType;
updateLegend();
}
/*
//--------------------------------------------------------------------------------------------------
///
@ -705,6 +714,7 @@ void RimLegendConfig::setCategories(const std::set<int>& globalCategories, const
m_localCategories.set(i++, val);
}
}
updateLegend();
}
//--------------------------------------------------------------------------------------------------
@ -749,6 +759,8 @@ void RimLegendConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
mappingGr->add(&m_userDefinedMaxValue);
mappingGr->add(&m_userDefinedMinValue);
}
updateFieldVisibility();
}
//--------------------------------------------------------------------------------------------------

View File

@ -97,7 +97,12 @@ public:
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);
@ -107,7 +112,6 @@ public:
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();