#7304 Color Legend : Use inverted color legend for SWAT

This commit is contained in:
Magne Sjaastad
2021-02-01 08:09:30 +01:00
parent 55cbe69222
commit 1a8f36373c
2 changed files with 55 additions and 29 deletions

View File

@@ -150,36 +150,8 @@ void RimEclipseCellColors::changeLegendConfig( QString resultVarNameOfNewLegend
if ( !found ) if ( !found )
{ {
RimRegularLegendConfig* newLegend = new RimRegularLegendConfig; auto newLegend = createLegendForResult( resultVarNameOfNewLegend, this->hasCategoryResult() );
newLegend->resultVariableName = resultVarNameOfNewLegend;
bool useLog = false;
{
QStringList subStringsToMatch{ "TRAN", "MULT", "PERM" };
for ( const auto& s : subStringsToMatch )
{
if ( resultVarNameOfNewLegend.contains( s, Qt::CaseInsensitive ) )
{
useLog = true;
}
}
}
if ( useLog )
{
newLegend->setMappingMode( RimRegularLegendConfig::MappingType::LOG10_DISCRETE );
newLegend->setTickNumberFormat( RimRegularLegendConfig::NumberFormatType::AUTO );
newLegend->setRangeMode( RimLegendConfig::RangeModeType::USER_DEFINED );
newLegend->resetUserDefinedValues();
}
if ( this->hasCategoryResult() )
{
newLegend->setMappingMode( RimRegularLegendConfig::MappingType::CATEGORY_INTEGER );
newLegend->setColorLegend(
RimRegularLegendConfig::mapToColorLegend( RimRegularLegendConfig::ColorRangesType::CATEGORY ) );
}
m_legendConfigData.push_back( newLegend ); m_legendConfigData.push_back( newLegend );
this->m_legendConfigPtrField = newLegend; this->m_legendConfigPtrField = newLegend;
@@ -201,6 +173,59 @@ void RimEclipseCellColors::onLegendConfigChanged( const caf::SignalEmitter* emit
legendConfigChanged.send( changeType ); legendConfigChanged.send( changeType );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimRegularLegendConfig* RimEclipseCellColors::createLegendForResult( const QString& resultName, bool isCategoryResult )
{
bool useLog = false;
{
QStringList subStringsToMatch{ "TRAN", "MULT", "PERM" };
for ( const auto& s : subStringsToMatch )
{
if ( resultName.contains( s, Qt::CaseInsensitive ) )
{
useLog = true;
}
}
}
RimRegularLegendConfig::ColorRangesType colorRangeType = RimRegularLegendConfig::ColorRangesType::UNDEFINED;
if ( isCategoryResult )
{
colorRangeType = RimRegularLegendConfig::ColorRangesType::CATEGORY;
}
else if ( resultName == "SWAT" )
{
colorRangeType = RimRegularLegendConfig::ColorRangesType::OPPOSITE_NORMAL;
}
RimRegularLegendConfig* newLegend = new RimRegularLegendConfig;
newLegend->resultVariableName = resultName;
if ( useLog )
{
newLegend->setMappingMode( RimRegularLegendConfig::MappingType::LOG10_DISCRETE );
newLegend->setTickNumberFormat( RimRegularLegendConfig::NumberFormatType::AUTO );
newLegend->setRangeMode( RimLegendConfig::RangeModeType::USER_DEFINED );
newLegend->resetUserDefinedValues();
}
if ( colorRangeType != RimRegularLegendConfig::ColorRangesType::UNDEFINED )
{
RimColorLegend* colorLegend = RimRegularLegendConfig::mapToColorLegend( colorRangeType );
if ( isCategoryResult )
{
newLegend->setMappingMode( RimRegularLegendConfig::MappingType::CATEGORY_INTEGER );
}
newLegend->setColorLegend( colorLegend );
}
return newLegend;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -74,6 +74,7 @@ protected:
private: private:
void changeLegendConfig( QString resultVarNameOfNewLegend ); void changeLegendConfig( QString resultVarNameOfNewLegend );
void onLegendConfigChanged( const caf::SignalEmitter* emitter, RimLegendConfigChangeType changeType ); void onLegendConfigChanged( const caf::SignalEmitter* emitter, RimLegendConfigChangeType changeType );
static RimRegularLegendConfig* createLegendForResult( const QString& resultName, bool isCategoryResult );
caf::PdmChildArrayField<RimRegularLegendConfig*> m_legendConfigData; caf::PdmChildArrayField<RimRegularLegendConfig*> m_legendConfigData;
caf::PdmPtrField<RimRegularLegendConfig*> m_legendConfigPtrField; caf::PdmPtrField<RimRegularLegendConfig*> m_legendConfigPtrField;