#8409 NNC : Make sure user defined legend ranges work

This commit is contained in:
Magne Sjaastad 2022-01-05 12:30:59 +01:00
parent f99bfb04b9
commit f028491bb9
2 changed files with 12 additions and 9 deletions

View File

@ -96,13 +96,14 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode
double characteristicCellSize = eclipseCase->characteristicCellSize();
float arrowConstantScaling = 10.0 * result->sizeScale() * characteristicCellSize;
double min, max;
result->mappingRange( min, max );
double maxAbsResult = 1.0;
if ( min != cvf::UNDEFINED_DOUBLE && max != cvf::UNDEFINED_DOUBLE )
{
maxAbsResult = std::max( cvf::Math::abs( max ), cvf::Math::abs( min ) );
double min, max;
result->mappingRange( min, max );
if ( min != cvf::UNDEFINED_DOUBLE && max != cvf::UNDEFINED_DOUBLE )
{
maxAbsResult = std::max( cvf::Math::abs( max ), cvf::Math::abs( min ) );
}
}
float arrowScaling = arrowConstantScaling / maxAbsResult;

View File

@ -335,10 +335,12 @@ void RimElementVectorResult::mappingRange( double& min, double& max ) const
{
resultsData->minMaxCellScalarValues( resVarAddr, localMin, localMax );
}
else if ( m_legendConfig->rangeMode() == RimRegularLegendConfig::RangeModeType::AUTOMATIC_CURRENT_TIMESTEP )
else if ( m_legendConfig->rangeMode() == RimRegularLegendConfig::RangeModeType::AUTOMATIC_CURRENT_TIMESTEP ||
m_legendConfig->rangeMode() == RimRegularLegendConfig::RangeModeType::USER_DEFINED )
{
resultsData->minMaxCellScalarValues( resVarAddr, currentTimeStep, localMin, localMax );
}
if ( vectorView() == RimElementVectorResult::VectorView::CELL_CENTER_TOTAL )
{
aggregatedVectorMax += unitVectors.at( dir ) * localMax;
@ -400,7 +402,8 @@ void RimElementVectorResult::mappingRange( double& min, double& max ) const
}
}
else if ( m_legendConfig->rangeMode() ==
RimRegularLegendConfig::RangeModeType::AUTOMATIC_CURRENT_TIMESTEP )
RimRegularLegendConfig::RangeModeType::AUTOMATIC_CURRENT_TIMESTEP ||
m_legendConfig->rangeMode() == RimRegularLegendConfig::RangeModeType::USER_DEFINED )
{
const std::vector<double>* nncResultVals =
nncData->dynamicConnectionScalarResult( combinedAddresses[flIdx],
@ -444,9 +447,8 @@ void RimElementVectorResult::updateLegendRangesTextAndVisibility( RiuViewer* nat
double minResultValue;
double maxResultValue;
mappingRange( minResultValue, maxResultValue );
m_legendConfig->setAutomaticRanges( minResultValue, maxResultValue, minResultValue, maxResultValue );
m_legendConfig->setMappingMode( RimRegularLegendConfig::MappingType::LINEAR_CONTINUOUS );
m_legendConfig->setAutomaticRanges( minResultValue, maxResultValue, minResultValue, maxResultValue );
double posClosestToZero = HUGE_VAL;
double negClosestToZero = -HUGE_VAL;