From f028491bb9bfca8d57021ba8f6eb7bb2b117bf41 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 5 Jan 2022 12:30:59 +0100 Subject: [PATCH] #8409 NNC : Make sure user defined legend ranges work --- .../RivElementVectorResultPartMgr.cpp | 11 ++++++----- .../ProjectDataModel/RimElementVectorResult.cpp | 10 ++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/ApplicationLibCode/ModelVisualization/RivElementVectorResultPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivElementVectorResultPartMgr.cpp index 9238f42511..b06dd55172 100644 --- a/ApplicationLibCode/ModelVisualization/RivElementVectorResultPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivElementVectorResultPartMgr.cpp @@ -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; diff --git a/ApplicationLibCode/ProjectDataModel/RimElementVectorResult.cpp b/ApplicationLibCode/ProjectDataModel/RimElementVectorResult.cpp index 5cb36dcc89..979109d89b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimElementVectorResult.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimElementVectorResult.cpp @@ -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* 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;