diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp index 237ab76f87..42b00f7241 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp @@ -32,7 +32,6 @@ #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechView.h" -#include "RimIntersectionResultDefinition.h" #include "RivBoxIntersectionSourceInfo.h" #include "RivExtrudedCurveIntersectionPartMgr.h" diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp index 7ec149ace0..c56728c5e7 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp @@ -29,8 +29,6 @@ #include "RimEclipseView.h" #include "RimExtrudedCurveIntersection.h" #include "RimGridView.h" -#include "RimIntersectionResultDefinition.h" -#include "RimIntersectionResultsDefinitionCollection.h" #include "RimSimWellInView.h" #include "Riu3DMainWindowTools.h" diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultDefinition.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultDefinition.cpp index c57b807dfd..f9c4716407 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultDefinition.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultDefinition.cpp @@ -387,6 +387,24 @@ void RimIntersectionResultDefinition::update2dIntersectionViews() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionResultDefinition::setDefaultEclipseLegendConfig() +{ + bool useDiscreteLogLevels = false; + bool isCategoryResult = m_eclipseResultDefinition->hasCategoryResult(); + + auto eclResultDef = this->eclipseResultDefinition(); + eclResultDef->updateRangesForExplicitLegends( this->regularLegendConfig(), + this->ternaryLegendConfig(), + this->timeStep() ); + + m_legendConfig->setDefaultConfigForResultName( m_eclipseResultDefinition->resultVariable(), + useDiscreteLogLevels, + isCategoryResult ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultDefinition.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultDefinition.h index 706c3a9ce6..c23a3fdd5b 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultDefinition.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionResultDefinition.h @@ -59,18 +59,17 @@ public: bool isUsingOverrideViewer ); void update2dIntersectionViews(); + void setDefaultEclipseLegendConfig(); protected: caf::PdmFieldHandle* userDescriptionField() override; caf::PdmFieldHandle* objectToggleField() override; - void fieldChangedByUi( const caf::PdmFieldHandle* changedField, - const QVariant& oldValue, - const QVariant& newValue ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; - void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + bool* useOptionsOnly ) override; + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; void initAfterRead() override; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCellColors.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCellColors.cpp index 3219429b31..5c8fd69434 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCellColors.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCellColors.cpp @@ -181,49 +181,10 @@ RimRegularLegendConfig* RimEclipseCellColors::createLegendForResult( const QStri bool useDiscreteLogLevels, bool isCategoryResult ) { - bool useLog = RiaResultNames::isLogarithmicResult( resultName ); + auto* newLegend = new RimRegularLegendConfig; + newLegend->resultVariableName = resultName; - RimRegularLegendConfig::ColorRangesType colorRangeType = RimRegularLegendConfig::ColorRangesType::UNDEFINED; - if ( isCategoryResult ) - { - colorRangeType = RimRegularLegendConfig::ColorRangesType::CATEGORY; - } - else if ( resultName == RiaResultNames::swat() ) - { - colorRangeType = RimRegularLegendConfig::ColorRangesType::OPPOSITE_NORMAL; - } - - RimRegularLegendConfig* newLegend = new RimRegularLegendConfig; - newLegend->resultVariableName = resultName; - - if ( useLog ) - { - if ( useDiscreteLogLevels ) - newLegend->setMappingMode( RimRegularLegendConfig::MappingType::LOG10_DISCRETE ); - else - newLegend->setMappingMode( RimRegularLegendConfig::MappingType::LOG10_CONTINUOUS ); - - newLegend->setTickNumberFormat( RiaNumberFormat::NumberFormatType::AUTO ); - newLegend->setRangeMode( RimLegendConfig::RangeModeType::USER_DEFINED ); - newLegend->resetUserDefinedValues(); - } - - if ( RiaResultNames::isFlowResultWithBothPosAndNegValues( resultName ) ) - { - colorRangeType = RimRegularLegendConfig::ColorRangesType::BLUE_WHITE_RED; - newLegend->setCenterLegendAroundZero( true ); - } - - if ( colorRangeType != RimRegularLegendConfig::ColorRangesType::UNDEFINED ) - { - RimColorLegend* colorLegend = RimRegularLegendConfig::mapToColorLegend( colorRangeType ); - if ( isCategoryResult ) - { - newLegend->setMappingMode( RimRegularLegendConfig::MappingType::CATEGORY_INTEGER ); - } - - newLegend->setColorLegend( colorLegend ); - } + newLegend->setDefaultConfigForResultName( resultName, useDiscreteLogLevels, isCategoryResult ); return newLegend; } diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp index 9bca264a1f..7e60133811 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -478,6 +478,7 @@ void RimEclipseResultDefinition::updateAnyFieldHasChanged() this->firstAncestorOrThisOfType( intersectResDef ); if ( intersectResDef ) { + intersectResDef->setDefaultEclipseLegendConfig(); intersectResDef->updateConnectedEditors(); } diff --git a/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.cpp index f2d5a44827..1e6ebf5531 100644 --- a/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -404,25 +404,7 @@ void RimRegularLegendConfig::updateLegend() if ( m_resetUserDefinedValues && m_globalAutoMax != cvf::UNDEFINED_DOUBLE ) { - if ( m_mappingMode() == MappingType::LOG10_CONTINUOUS || m_mappingMode() == MappingType::LOG10_DISCRETE ) - { - double exponentMax = computeTenExponentCeil( m_globalAutoMax ); - double exponentMin = computeTenExponentFloor( m_globalAutoPosClosestToZero ); - - m_userDefinedMaxValue = pow( 10, exponentMax ); - m_userDefinedMinValue = pow( 10, exponentMin ); - - int numLevels = exponentMax - exponentMin; - if ( numLevels > 0 ) - { - m_numLevels = numLevels; - } - } - else if ( m_mappingMode() == MappingType::LINEAR_CONTINUOUS || m_mappingMode() == MappingType::LINEAR_DISCRETE ) - { - m_userDefinedMaxValue = m_globalAutoMax; - m_userDefinedMinValue = m_globalAutoMin; - } + updateTickCountAndUserDefinedRange(); m_resetUserDefinedValues = false; } @@ -881,6 +863,36 @@ void RimRegularLegendConfig::configureCategoryMapper() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::updateTickCountAndUserDefinedRange() +{ + if ( m_globalAutoMax != cvf::UNDEFINED_DOUBLE ) + { + if ( m_mappingMode() == MappingType::LOG10_CONTINUOUS || m_mappingMode() == MappingType::LOG10_DISCRETE ) + { + double exponentMax = computeTenExponentCeil( m_globalAutoMax ); + double exponentMin = computeTenExponentFloor( m_globalAutoPosClosestToZero ); + + m_userDefinedMaxValue = pow( 10, exponentMax ); + m_userDefinedMinValue = pow( 10, exponentMin ); + + int numLevels = exponentMax - exponentMin; + if ( numLevels > 0 ) + { + m_numLevels = numLevels; + } + } + else if ( m_mappingMode() == MappingType::LINEAR_CONTINUOUS || m_mappingMode() == MappingType::LINEAR_DISCRETE ) + { + m_userDefinedMaxValue = m_globalAutoMax; + m_userDefinedMinValue = m_globalAutoMin; + m_numLevels = 8; + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1206,6 +1218,67 @@ QString RimRegularLegendConfig::valueToText( double value ) const return RiaNumberFormat::valueToText( value, m_tickNumberFormat(), m_significantDigitsInData ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::setDefaultConfigForResultName( const QString& resultName, + bool useDiscreteLogLevels, + bool isCategoryResult ) +{ + bool useLog = RiaResultNames::isLogarithmicResult( resultName ); + + RimRegularLegendConfig::MappingType mappingType = MappingType::LINEAR_CONTINUOUS; + RimLegendConfig::RangeModeType rangeType = RimLegendConfig::RangeModeType::AUTOMATIC_ALLTIMESTEPS; + RiaNumberFormat::NumberFormatType numberFormat = RiaNumberFormat::NumberFormatType::FIXED; + + if ( useLog ) + { + if ( useDiscreteLogLevels ) + mappingType = RimRegularLegendConfig::MappingType::LOG10_DISCRETE; + else + mappingType = RimRegularLegendConfig::MappingType::LOG10_CONTINUOUS; + + numberFormat = RiaNumberFormat::NumberFormatType::AUTO; + rangeType = RimLegendConfig::RangeModeType::USER_DEFINED; + } + + bool centerLegendAroundZero = false; + RimRegularLegendConfig::ColorRangesType colorRangeType = RimRegularLegendConfig::ColorRangesType::UNDEFINED; + + if ( isCategoryResult ) + { + colorRangeType = RimRegularLegendConfig::ColorRangesType::CATEGORY; + mappingType = RimRegularLegendConfig::MappingType::CATEGORY_INTEGER; + } + else if ( resultName == RiaResultNames::swat() ) + { + colorRangeType = RimRegularLegendConfig::ColorRangesType::OPPOSITE_NORMAL; + } + else if ( RiaResultNames::isFlowResultWithBothPosAndNegValues( resultName ) ) + { + colorRangeType = RimRegularLegendConfig::ColorRangesType::BLUE_WHITE_RED; + centerLegendAroundZero = true; + } + else if ( resultName != RiaResultNames::undefinedResultName() ) + { + colorRangeType = RimRegularLegendConfig::ColorRangesType::NORMAL; + } + + resetUserDefinedValues(); + setRangeMode( rangeType ); + setMappingMode( mappingType ); + setCenterLegendAroundZero( centerLegendAroundZero ); + setTickNumberFormat( numberFormat ); + updateTickCountAndUserDefinedRange(); + + if ( colorRangeType != RimRegularLegendConfig::ColorRangesType::UNDEFINED ) + { + RimColorLegend* colorLegend = RimRegularLegendConfig::mapToColorLegend( colorRangeType ); + + setColorLegend( colorLegend ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.h b/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.h index e65f95cb18..71775bde93 100644 --- a/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.h +++ b/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.h @@ -170,6 +170,8 @@ public: QString valueToText( double value ) const; + void setDefaultConfigForResultName( const QString& resultName, bool useDiscreteLogLevels, bool isCategoryResult ); + private: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void sendChangedSignal( const caf::PdmFieldHandle* changedField ); @@ -189,6 +191,7 @@ private: void updateCategoryItems(); void configureCategoryMapper(); + void updateTickCountAndUserDefinedRange(); friend class RimViewLinker; diff --git a/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp b/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp index 6754da2b70..26c0dde78e 100644 --- a/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp +++ b/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp @@ -19,6 +19,7 @@ #include "RiuResultTextBuilder.h" +#include "RigAllanDiagramData.h" #include "RigCaseCellResultsData.h" #include "RigEclipseCaseData.h" #include "RigFormationNames.h" @@ -37,13 +38,12 @@ #include "RimEclipseView.h" #include "RimExtrudedCurveIntersection.h" #include "RimFormationNames.h" +#include "RimIntersectionResultDefinition.h" #include "RimRegularLegendConfig.h" #include "RimReservoirCellResultsStorage.h" #include "RivExtrudedCurveIntersectionPartMgr.h" -#include "RigAllanDiagramData.h" -#include "RimIntersectionResultDefinition.h" #include "cafDisplayCoordTransform.h" //--------------------------------------------------------------------------------------------------