From c31bc3e50e83b6bd5573534dc915b6737b101d53 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 25 Aug 2022 12:51:56 +0200 Subject: [PATCH] Add multiple selected cell edge results --- .../Commands/RicCreateEnsembleWellLogUi.cpp | 25 +- .../Commands/RicCreateEnsembleWellLogUi.h | 5 + .../RivCellEdgeGeometryUtils.cpp | 56 ++-- .../ProjectDataModel/RimCellEdgeColors.cpp | 285 +++++++++--------- .../ProjectDataModel/RimCellEdgeColors.h | 24 +- .../RimEclipseResultDefinition.cpp | 1 - .../ProjectDataModel/RimEclipseView.cpp | 21 -- .../UserInterface/RiuMainWindow.cpp | 7 - .../UserInterface/RiuResultTextBuilder.cpp | 64 ++-- 9 files changed, 230 insertions(+), 258 deletions(-) diff --git a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.cpp b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.cpp index 5c0686474b..a3cc814f93 100644 --- a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.cpp +++ b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.cpp @@ -190,33 +190,40 @@ bool RicCreateEnsembleWellLogUi::autoCreateEnsembleWellLogs() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector> RicCreateEnsembleWellLogUi::properties() const +std::vector> + RicCreateEnsembleWellLogUi::properties( const std::vector& resultNames, + const std::vector& resultCategories, + const RigEclipseCaseData* caseData ) { - std::vector selectedKeyWords = m_selectedKeywords(); - auto findResultCategory = []( const QString& keyword, const std::vector& categories, - RigEclipseCaseData* caseData ) { + const RigEclipseCaseData* caseData ) { // Find the result category for a given keyword - RigCaseCellResultsData* resultData = caseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL ); + auto resultData = caseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL ); for ( auto category : categories ) if ( resultData->hasResultEntry( RigEclipseResultAddress( category, keyword ) ) ) return category; return RiaDefines::ResultCatType::UNDEFINED; }; - std::vector resultCategories = validResultCategories(); - std::vector> props; - for ( auto keyword : selectedKeyWords ) + for ( auto keyword : resultNames ) { - auto resultCategory = findResultCategory( keyword, resultCategories, m_caseData ); + auto resultCategory = findResultCategory( keyword, resultCategories, caseData ); props.push_back( std::make_pair( keyword, resultCategory ) ); } return props; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector> RicCreateEnsembleWellLogUi::properties() const +{ + return properties( m_selectedKeywords.value(), validResultCategories(), m_caseData ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.h b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.h index 518aeb63a4..55dbf968fb 100644 --- a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.h +++ b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.h @@ -61,6 +61,11 @@ public: std::vector> properties() const; + static std::vector> + properties( const std::vector& resultNames, + const std::vector& resultCategories, + const RigEclipseCaseData* caseData ); + void setCaseData( RigEclipseCaseData* caseData ); protected: diff --git a/ApplicationLibCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp b/ApplicationLibCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp index 19a4ef5d9b..73100d7994 100644 --- a/ApplicationLibCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp +++ b/ApplicationLibCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp @@ -316,47 +316,29 @@ cvf::ref RivCellEdgeGeometryUtils::createCellEdgeResultAccess { cvf::ref cellEdgeResultAccessor = new RigCellEdgeResultAccessor(); - if ( cellEdgeResultColors->propertyType() == RimCellEdgeColors::ANY_SINGLE_PROPERTY ) + auto resultAddresses = cellEdgeResultColors->resultAddresses(); + + std::vector metaData; + cellEdgeResultColors->cellEdgeMetaData( &metaData ); + + size_t cubeFaceIdx; + for ( cubeFaceIdx = 0; cubeFaceIdx < 6; cubeFaceIdx++ ) { - cvf::ref daObj = - RivCellEdgeGeometryUtils::createCellCenterResultAccessor( cellEdgeResultColors->singleVarEdgeResultColors(), - timeStepIndex, - eclipseCase, - grid ); - - for ( size_t cubeFaceIdx = 0; cubeFaceIdx < 6; cubeFaceIdx++ ) + size_t adjustedTimeStep = timeStepIndex; + if ( metaData[cubeFaceIdx].m_isStatic ) { - cellEdgeResultAccessor->setDataAccessObjectForFace( static_cast( cubeFaceIdx ), - daObj.p() ); + adjustedTimeStep = 0; } - } - else - { - RigEclipseResultAddress resultAddresses[6]; - cellEdgeResultColors->gridScalarIndices( resultAddresses ); - std::vector metaData; - cellEdgeResultColors->cellEdgeMetaData( &metaData ); - - size_t cubeFaceIdx; - for ( cubeFaceIdx = 0; cubeFaceIdx < 6; cubeFaceIdx++ ) - { - size_t adjustedTimeStep = timeStepIndex; - if ( metaData[cubeFaceIdx].m_isStatic ) - { - adjustedTimeStep = 0; - } - - RiaDefines::PorosityModelType porosityModel = cellResultColors->porosityModel(); - cvf::ref daObj = - RigResultAccessorFactory::createFromResultAddress( eclipseCase, - grid->gridIndex(), - porosityModel, - adjustedTimeStep, - resultAddresses[cubeFaceIdx] ); - cellEdgeResultAccessor->setDataAccessObjectForFace( static_cast( cubeFaceIdx ), - daObj.p() ); - } + RiaDefines::PorosityModelType porosityModel = cellResultColors->porosityModel(); + cvf::ref daObj = + RigResultAccessorFactory::createFromResultAddress( eclipseCase, + grid->gridIndex(), + porosityModel, + adjustedTimeStep, + resultAddresses[cubeFaceIdx] ); + cellEdgeResultAccessor->setDataAccessObjectForFace( static_cast( cubeFaceIdx ), + daObj.p() ); } return cellEdgeResultAccessor; diff --git a/ApplicationLibCode/ProjectDataModel/RimCellEdgeColors.cpp b/ApplicationLibCode/ProjectDataModel/RimCellEdgeColors.cpp index 1aceb4f3d4..d3c319e14e 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCellEdgeColors.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimCellEdgeColors.cpp @@ -20,9 +20,12 @@ #include "RimCellEdgeColors.h" -#include "RigCaseCellResultsData.h" -#include "RigFlowDiagResults.h" +#include "RicCreateEnsembleWellLogUi.h" +#include "RigCaseCellResultsData.h" +#include "RigEclipseResultAddress.h" + +#include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipseView.h" #include "RimRegularLegendConfig.h" @@ -30,8 +33,11 @@ #include "cafPdmUiListEditor.h" #include "cafPdmUiTreeOrdering.h" +#include "cafPdmUiTreeSelectionEditor.h" #include "cvfMath.h" + +#include "RiaLogging.h" #include namespace caf @@ -40,7 +46,8 @@ template <> void AppEnum::setUp() { addItem( RimCellEdgeColors::MULTI_AXIS_STATIC_PROPERTY, "MULTI_AXIS_STATIC_PROPERTY", "Multi Axis Static Property" ); - addItem( RimCellEdgeColors::ANY_SINGLE_PROPERTY, "ANY_SINGLE_PROPERTY", "Any Single Property" ); + QStringList aliasList = { "ANY_SINGLE_PROPERTY" }; + addItem( RimCellEdgeColors::CUSTOM_PROPERTIES, "CUSTOM_PROPERTIES", "Selected Properties", aliasList ); setDefault( RimCellEdgeColors::MULTI_AXIS_STATIC_PROPERTY ); } } // namespace caf @@ -65,13 +72,28 @@ RimCellEdgeColors::RimCellEdgeColors() CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend", ":/Legend.png" ); - CAF_PDM_InitFieldNoDefault( &m_singleVarEdgeResultColors, "SingleVarEdgeResult", "Result Property", ":/CellResult.png" ); - m_singleVarEdgeResultColors = new RimEclipseCellColors(); + CAF_PDM_InitFieldNoDefault( &m_selectedKeywords, "SelectedProperties", "Selected Properties" ); + m_selectedKeywords.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); + + CAF_PDM_InitField( &m_showTextValuesIfItemIsUnchecked, + "ShowTextValuesIfItemIsUnchecked", + false, + "Always Show Values in Result Info Window", + "", + "Allow display of result values in Result Info window if the Cell Edge object is unchecked in " + "Property Editor." ); m_resultVariable.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); m_legendConfig = new RimRegularLegendConfig(); + CAF_PDM_InitFieldNoDefault( &m_singleVarEdgeResultColors_OBSOLETE, + "SingleVarEdgeResult", + "Result Property", + ":/CellResult.png" ); + m_singleVarEdgeResultColors_OBSOLETE = new RimEclipseCellColors(); + m_singleVarEdgeResultColors_OBSOLETE.uiCapability()->setUiHidden( true ); + m_ignoredResultScalar = cvf::UNDEFINED_DOUBLE; resetResultAddresses(); } @@ -89,7 +111,6 @@ RimCellEdgeColors::~RimCellEdgeColors() void RimCellEdgeColors::setReservoirView( RimEclipseView* ownerReservoirView ) { m_reservoirView = ownerReservoirView; - m_singleVarEdgeResultColors->setReservoirView( ownerReservoirView ); } //-------------------------------------------------------------------------------------------------- @@ -97,24 +118,47 @@ void RimCellEdgeColors::setReservoirView( RimEclipseView* ownerReservoirView ) //-------------------------------------------------------------------------------------------------- void RimCellEdgeColors::loadResult() { - if ( !m_enableCellEdgeColors ) return; if ( !m_reservoirView->currentGridCellResults() ) return; - if ( isUsingSingleVariable() ) - { - m_singleVarEdgeResultColors->loadResult(); - ; + resetResultAddresses(); - RigEclipseResultAddress resultAddr = m_singleVarEdgeResultColors->eclipseResultAddress(); - for ( int cubeFaceIdx = 0; cubeFaceIdx < 6; ++cubeFaceIdx ) + if ( isUserDefinedPropertiesActive() ) + { + std::vector categories = { RiaDefines::ResultCatType::STATIC_NATIVE, + RiaDefines::ResultCatType::DYNAMIC_NATIVE, + RiaDefines::ResultCatType::INPUT_PROPERTY }; + + std::vector resultNames = m_selectedKeywords(); + if ( resultNames.size() > 6 ) { - m_resultNameToAddressPairs[cubeFaceIdx] = - std::make_pair( m_singleVarEdgeResultColors->resultVariable(), resultAddr ); + QString title = "Cell Edge Results"; + + QString text = + QString( "Selected Cell Edge result property count is %1. Up to 6 results are supported, no " + "data will be loaded.\n\nPlease select equal to or less than 6 properties to show data." ) + .arg( resultNames.size() ); + + RiaLogging::errorInMessageBox( nullptr, title, text ); + + return; + } + + auto properties = RicCreateEnsembleWellLogUi::properties( resultNames, + categories, + m_reservoirView->eclipseCase()->eclipseCaseData() ); + + for ( size_t i = 0; i < properties.size(); i++ ) + { + auto [name, category] = properties[i]; + RigEclipseResultAddress adr = RigEclipseResultAddress( category, name ); + + m_reservoirView->currentGridCellResults()->ensureKnownResultLoaded( adr ); + + m_resultNameToAddressPairs[i] = std::make_pair( name, adr ); } } else { - resetResultAddresses(); QStringList vars = findResultVariableNames(); updateIgnoredScalarValue(); @@ -151,8 +195,12 @@ void RimCellEdgeColors::loadResult() //-------------------------------------------------------------------------------------------------- void RimCellEdgeColors::initAfterRead() { - m_singleVarEdgeResultColors->initAfterRead(); this->updateUiIconFromToggleField(); + + if ( m_singleVarEdgeResultColors_OBSOLETE->resultVariableUiName() != RiaResultNames::undefinedResultName() ) + { + m_selectedKeywords.v().push_back( m_singleVarEdgeResultColors_OBSOLETE->resultVariableUiName() ); + } } //-------------------------------------------------------------------------------------------------- @@ -192,6 +240,8 @@ void RimCellEdgeColors::EdgeFaceEnum::setUp() QList RimCellEdgeColors::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { + QList options; + if ( fieldNeedingOptions == &m_resultVariable ) { if ( m_reservoirView && m_reservoirView->currentGridCellResults() ) @@ -202,8 +252,6 @@ QList RimCellEdgeColors::calculateValueOptions( const ca // TODO: Must also handle input properties // varList += m_reservoirView->gridCellResults()->resultNames(RiaDefines::INPUT_PROPERTY); - QList options; - std::map> varBaseNameToVarsMap; int i; @@ -258,6 +306,41 @@ QList RimCellEdgeColors::calculateValueOptions( const ca } } + if ( fieldNeedingOptions == &m_selectedKeywords ) + { + RigCaseCellResultsData* resultData = m_reservoirView->currentGridCellResults(); + + std::vector resultCategories = { RiaDefines::ResultCatType::STATIC_NATIVE, + RiaDefines::ResultCatType::DYNAMIC_NATIVE, + RiaDefines::ResultCatType::INPUT_PROPERTY }; + + for ( auto catType : resultCategories ) + { + QList allOptions = + RimEclipseResultDefinition::calcOptionsForVariableUiFieldStandard( catType, resultData ); + + bool isFirstOfCategory = true; + for ( const caf::PdmOptionItemInfo& option : allOptions ) + { + if ( resultData->hasResultEntry( RigEclipseResultAddress( catType, option.optionUiText() ) ) ) + { + if ( isFirstOfCategory ) + { + // Add the category title only when there is at least one valid result + options.push_back( + caf::PdmOptionItemInfo::createHeader( caf::AppEnum::uiText( catType ), + true ) ); + isFirstOfCategory = false; + } + + options.push_back( option ); + } + } + } + + return options; + } + return QList(); } @@ -266,11 +349,12 @@ QList RimCellEdgeColors::calculateValueOptions( const ca //-------------------------------------------------------------------------------------------------- void RimCellEdgeColors::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { + uiOrdering.add( &m_showTextValuesIfItemIsUnchecked ); uiOrdering.add( &m_propertyType ); - if ( isUsingSingleVariable() ) + if ( isUserDefinedPropertiesActive() ) { - m_singleVarEdgeResultColors->uiOrdering( uiConfigName, uiOrdering ); + uiOrdering.add( &m_selectedKeywords ); } else { @@ -323,13 +407,15 @@ QStringList RimCellEdgeColors::findResultVariableNames() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellEdgeColors::gridScalarIndices( RigEclipseResultAddress resultIndices[6] ) +std::array RimCellEdgeColors::resultAddresses() const { - int cubeFaceIndex; - for ( cubeFaceIndex = 0; cubeFaceIndex < 6; ++cubeFaceIndex ) + std::array adr; + for ( int cubeFaceIndex = 0; cubeFaceIndex < 6; ++cubeFaceIndex ) { - resultIndices[cubeFaceIndex] = RigEclipseResultAddress( m_resultNameToAddressPairs[cubeFaceIndex].second ); + adr[cubeFaceIndex] = RigEclipseResultAddress( m_resultNameToAddressPairs[cubeFaceIndex].second ); } + + return adr; } //-------------------------------------------------------------------------------------------------- @@ -349,9 +435,9 @@ void RimCellEdgeColors::gridScalarResultNames( std::vector* resultNames //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimCellEdgeColors::isUsingSingleVariable() const +bool RimCellEdgeColors::isUserDefinedPropertiesActive() const { - return ( m_propertyType == ANY_SINGLE_PROPERTY ); + return ( m_propertyType == CUSTOM_PROPERTIES ); } //-------------------------------------------------------------------------------------------------- @@ -361,22 +447,22 @@ void RimCellEdgeColors::cellEdgeMetaData( std::vector* meta { CVF_ASSERT( metaDataVector ); - RigEclipseResultAddress resultIndices[6]; - this->gridScalarIndices( resultIndices ); + auto addresses = this->resultAddresses(); std::vector resultNames; this->gridScalarResultNames( &resultNames ); bool isStatic = true; - if ( isUsingSingleVariable() ) - { - isStatic = m_singleVarEdgeResultColors->resultType() == RiaDefines::ResultCatType::STATIC_NATIVE; - } for ( size_t i = 0; i < 6; i++ ) { + if ( isUserDefinedPropertiesActive() ) + { + isStatic = addresses[i].resultCatType() == RiaDefines::ResultCatType::STATIC_NATIVE; + } + RimCellEdgeMetaData metaData; - metaData.m_eclipseResultAddress = resultIndices[i]; + metaData.m_eclipseResultAddress = addresses[i]; metaData.m_resultVariable = resultNames[i]; metaData.m_isStatic = isStatic; @@ -403,7 +489,17 @@ bool RimCellEdgeColors::hasResult() const { if ( !m_enableCellEdgeColors() ) return false; - if ( isUsingSingleVariable() && m_singleVarEdgeResultColors->isFlowDiagOrInjectionFlooding() ) + return showTextResult(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimCellEdgeColors::showTextResult() const +{ + if ( !m_enableCellEdgeColors && !m_showTextValuesIfItemIsUnchecked ) return false; + + if ( isUserDefinedPropertiesActive() ) { return true; } @@ -444,32 +540,19 @@ void RimCellEdgeColors::minMaxCellEdgeValues( double& min, double& max ) if ( m_reservoirView->currentGridCellResults() ) { - if ( isUsingSingleVariable() && singleVarEdgeResultColors()->isFlowDiagOrInjectionFlooding() ) + auto resultAddresses = this->resultAddresses(); + + size_t faceIdx; + for ( faceIdx = 0; faceIdx < 6; faceIdx++ ) { - int currentTimeStep = m_reservoirView->currentTimeStep(); + if ( !resultAddresses[faceIdx].isValid() ) continue; - RigFlowDiagResults* fldResults = singleVarEdgeResultColors()->flowDiagSolution()->flowDiagResults(); - RigFlowDiagResultAddress resAddr = singleVarEdgeResultColors()->flowDiagResAddress(); - - fldResults->minMaxScalarValues( resAddr, currentTimeStep, &globalMin, &globalMax ); - } - else - { - RigEclipseResultAddress resultAddresses[6]; - this->gridScalarIndices( resultAddresses ); - - size_t faceIdx; - for ( faceIdx = 0; faceIdx < 6; faceIdx++ ) { - if ( !resultAddresses[faceIdx].isValid() ) continue; + double cMin, cMax; + m_reservoirView->currentGridCellResults()->minMaxCellScalarValues( resultAddresses[faceIdx], cMin, cMax ); - { - double cMin, cMax; - m_reservoirView->currentGridCellResults()->minMaxCellScalarValues( resultAddresses[faceIdx], cMin, cMax ); - - globalMin = std::min( globalMin, cMin ); - globalMax = std::max( globalMax, cMax ); - } + globalMin = std::min( globalMin, cMin ); + globalMax = std::max( globalMax, cMax ); } } } @@ -486,8 +569,7 @@ void RimCellEdgeColors::posNegClosestToZero( double& pos, double& neg ) pos = HUGE_VAL; neg = -HUGE_VAL; - RigEclipseResultAddress resultAddresses[6]; - this->gridScalarIndices( resultAddresses ); + auto resultAddresses = this->resultAddresses(); size_t faceIdx; for ( faceIdx = 0; faceIdx < 6; faceIdx++ ) @@ -504,22 +586,6 @@ void RimCellEdgeColors::posNegClosestToZero( double& pos, double& neg ) } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCellEdgeColors::updateUiFieldsFromActiveResult() -{ - m_singleVarEdgeResultColors->updateUiFieldsFromActiveResult(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCellEdgeColors::setEclipseCase( RimEclipseCase* eclipseCase ) -{ - m_singleVarEdgeResultColors->setEclipseCase( eclipseCase ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -528,49 +594,21 @@ void RimCellEdgeColors::setResultVariable( const QString& variableName ) m_resultVariable = variableName; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimCellEdgeColors::resultVariable() const -{ - if ( isUsingSingleVariable() ) - { - return m_singleVarEdgeResultColors->resultVariable(); - } - else - { - return m_resultVariable; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimCellEdgeColors::resultVariableUiName() const -{ - if ( isUsingSingleVariable() ) - { - return m_singleVarEdgeResultColors->resultVariableUiName(); - } - else - { - return m_resultVariable; - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QString RimCellEdgeColors::resultVariableUiShortName() const { - if ( isUsingSingleVariable() ) + if ( isUserDefinedPropertiesActive() ) { - return m_singleVarEdgeResultColors->resultVariableUiShortName(); - } - else - { - return m_resultVariable; + if ( m_selectedKeywords().empty() ) return ""; + + if ( m_selectedKeywords().size() == 1 ) return m_selectedKeywords().front(); + + return "Multiple Properties"; } + + return m_resultVariable; } //-------------------------------------------------------------------------------------------------- @@ -589,35 +627,12 @@ caf::PdmFieldHandle* RimCellEdgeColors::objectToggleField() return &m_enableCellEdgeColors; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimCellEdgeColors::hasCategoryResult() const -{ - return isUsingSingleVariable() && m_singleVarEdgeResultColors->hasCategoryResult(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimEclipseCellColors* RimCellEdgeColors::singleVarEdgeResultColors() -{ - return m_singleVarEdgeResultColors; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimRegularLegendConfig* RimCellEdgeColors::legendConfig() { - if ( isUsingSingleVariable() ) - { - return m_singleVarEdgeResultColors->legendConfig(); - } - else - { - return m_legendConfig; - } + return m_legendConfig(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimCellEdgeColors.h b/ApplicationLibCode/ProjectDataModel/RimCellEdgeColors.h index e58adccb6d..05aae4d8da 100644 --- a/ApplicationLibCode/ProjectDataModel/RimCellEdgeColors.h +++ b/ApplicationLibCode/ProjectDataModel/RimCellEdgeColors.h @@ -68,39 +68,33 @@ public: enum PropertyType { MULTI_AXIS_STATIC_PROPERTY, - ANY_SINGLE_PROPERTY + CUSTOM_PROPERTIES }; typedef caf::AppEnum EdgeFaceEnum; void setReservoirView( RimEclipseView* ownerReservoirView ); - void setEclipseCase( RimEclipseCase* eclipseCase ); void setResultVariable( const QString& variableName ); - QString resultVariable() const; - QString resultVariableUiName() const; QString resultVariableUiShortName() const; void setActive( bool active ); - double ignoredScalarValue() { return m_ignoredResultScalar; } - void gridScalarIndices( RigEclipseResultAddress resultIndices[6] ); - void cellEdgeMetaData( std::vector* metaData ); + double ignoredScalarValue() { return m_ignoredResultScalar; } + std::array resultAddresses() const; + void cellEdgeMetaData( std::vector* metaData ); void loadResult(); bool hasResult() const; - bool hasCategoryResult() const; - bool isUsingSingleVariable() const; + bool showTextResult() const; + bool isUserDefinedPropertiesActive() const; - RimEclipseCellColors* singleVarEdgeResultColors(); RimRegularLegendConfig* legendConfig(); PropertyType propertyType() const; void minMaxCellEdgeValues( double& min, double& max ); void posNegClosestToZero( double& pos, double& neg ); - void updateUiFieldsFromActiveResult(); - protected: void initAfterRead() override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; @@ -130,5 +124,9 @@ private: caf::PdmField> m_propertyType; caf::PdmChildField m_legendConfig; - caf::PdmChildField m_singleVarEdgeResultColors; + caf::PdmField> m_selectedKeywords; + caf::PdmField m_showTextValuesIfItemIsUnchecked; + + // Obsolete fields + caf::PdmChildField m_singleVarEdgeResultColors_OBSOLETE; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp index 32a6ee546e..619ef591a7 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -609,7 +609,6 @@ void RimEclipseResultDefinition::loadDataAndUpdate() this->firstAncestorOrThisOfType( cellEdgeColors ); if ( cellEdgeColors ) { - cellEdgeColors->singleVarEdgeResultColors()->updateLegendCategorySettings(); cellEdgeColors->loadResult(); if ( view ) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index f403c5f8c8..089ed6de2b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -1400,11 +1400,6 @@ void RimEclipseView::onUpdateLegends() { if ( this->cellEdgeResult()->hasResult() ) { - if ( this->cellEdgeResult()->isUsingSingleVariable() ) - { - this->cellEdgeResult()->singleVarEdgeResultColors()->updateRangesForEmbeddedLegends( m_currentTimeStep ); - } - else { double globalMin, globalMax; double globalPosClosestToZero, globalNegClosestToZero; @@ -1416,21 +1411,6 @@ void RimEclipseView::onUpdateLegends() globalPosClosestToZero, globalNegClosestToZero ); this->cellEdgeResult()->legendConfig()->setAutomaticRanges( globalMin, globalMax, globalMin, globalMax ); - - if ( this->cellEdgeResult()->hasCategoryResult() ) - { - if ( cellEdgeResult()->singleVarEdgeResultColors()->resultType() != - RiaDefines::ResultCatType::FORMATION_NAMES ) - { - cellEdgeResult()->legendConfig()->setIntegerCategories( results->uniqueCellScalarValues( - cellEdgeResult()->singleVarEdgeResultColors()->eclipseResultAddress() ) ); - } - else - { - const std::vector fnVector = eclipseCase->formationNames(); - cellEdgeResult()->legendConfig()->setNamedCategories( fnVector ); - } - } } this->cellEdgeResult()->legendConfig()->setTitle( QString( "Edge Results: \n" ) + @@ -1557,7 +1537,6 @@ void RimEclipseView::setEclipseCase( RimEclipseCase* reservoir ) faultResultSettings()->customFaultResult()->setEclipseCase( reservoir ); cellFilterCollection()->setCase( reservoir ); m_streamlineCollection->setEclipseCase( reservoir ); - cellEdgeResult()->setEclipseCase( reservoir ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp index 15dc699382..709856a471 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp @@ -1703,13 +1703,6 @@ void RiuMainWindow::updateUiFieldsFromActiveResult( caf::PdmObjectHandle* object { eclFaultColors->updateUiFieldsFromActiveResult(); } - - RimCellEdgeColors* cellEdgeColors = nullptr; - cellEdgeColors = dynamic_cast( objectToUpdate ); - if ( cellEdgeColors ) - { - cellEdgeColors->updateUiFieldsFromActiveResult(); - } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp b/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp index 26c0dde78e..1e862ce447 100644 --- a/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp +++ b/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp @@ -732,49 +732,43 @@ QString RiuResultTextBuilder::cellEdgeResultDetails() { QString text; - if ( m_viewWithFaultsSettings && m_viewWithFaultsSettings->cellEdgeResult()->hasResult() ) + if ( m_viewWithFaultsSettings && m_viewWithFaultsSettings->cellEdgeResult()->showTextResult() ) { + m_viewWithFaultsSettings->cellEdgeResult()->loadResult(); + text += "-- Cell edge result data --\n"; - if ( m_viewWithFaultsSettings->cellEdgeResult()->isUsingSingleVariable() ) - { - text += cellResultText( m_viewWithFaultsSettings->cellEdgeResult()->singleVarEdgeResultColors() ); - text += "\n"; - } - else - { - std::vector metaData; - m_viewWithFaultsSettings->cellEdgeResult()->cellEdgeMetaData( &metaData ); + std::vector metaData; + m_viewWithFaultsSettings->cellEdgeResult()->cellEdgeMetaData( &metaData ); - std::set uniqueResultIndices; + std::set uniqueResultAddresses; - for ( int idx = 0; idx < 6; idx++ ) + for ( int idx = 0; idx < 6; idx++ ) + { + RigEclipseResultAddress resultAddr = metaData[idx].m_eclipseResultAddress; + if ( !resultAddr.isValid() ) continue; + + if ( uniqueResultAddresses.find( resultAddr ) != uniqueResultAddresses.end() ) continue; + + size_t adjustedTimeStep = m_timeStepIndex; + if ( metaData[idx].m_isStatic ) { - RigEclipseResultAddress resultAddr = metaData[idx].m_eclipseResultAddress; - if ( !resultAddr.isValid() ) continue; + adjustedTimeStep = 0; + } - if ( uniqueResultIndices.find( resultAddr ) != uniqueResultIndices.end() ) continue; + RiaDefines::PorosityModelType porosityModel = m_eclResDef->porosityModel(); + cvf::ref resultAccessor = + RigResultAccessorFactory::createFromResultAddress( m_eclResDef->eclipseCase()->eclipseCaseData(), + m_gridIndex, + porosityModel, + adjustedTimeStep, + resultAddr ); + if ( resultAccessor.notNull() ) + { + double scalarValue = resultAccessor->cellScalar( m_cellIndex ); + text.append( QString( "%1 : %2\n" ).arg( metaData[idx].m_resultVariable ).arg( scalarValue ) ); - size_t adjustedTimeStep = m_timeStepIndex; - if ( metaData[idx].m_isStatic ) - { - adjustedTimeStep = 0; - } - - RiaDefines::PorosityModelType porosityModel = m_eclResDef->porosityModel(); - cvf::ref resultAccessor = - RigResultAccessorFactory::createFromResultAddress( m_eclResDef->eclipseCase()->eclipseCaseData(), - m_gridIndex, - porosityModel, - adjustedTimeStep, - resultAddr ); - if ( resultAccessor.notNull() ) - { - double scalarValue = resultAccessor->cellScalar( m_cellIndex ); - text.append( QString( "%1 : %2\n" ).arg( metaData[idx].m_resultVariable ).arg( scalarValue ) ); - - uniqueResultIndices.insert( resultAddr ); - } + uniqueResultAddresses.insert( resultAddr ); } } }