From 7877cdf62d75ef6d2526fcb70d072b1ee2af4414 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 17 Dec 2024 08:55:17 +0100 Subject: [PATCH] #11994 GeoMech: Allow property filter to be linked to cell result --- .../RicGeoMechPropertyFilterFeatureImpl.cpp | 6 +- .../RivFemElmVisibilityCalculator.cpp | 6 +- .../CellFilters/RimGeoMechPropertyFilter.cpp | 122 +++++++++++++----- .../CellFilters/RimGeoMechPropertyFilter.h | 15 ++- .../RimGeoMechPropertyFilterCollection.cpp | 34 ++++- .../RimGeoMechPropertyFilterCollection.h | 3 + .../GeoMech/RimGeoMechCase.cpp | 6 +- .../GeoMech/RimGeoMechView.cpp | 8 ++ .../ProjectDataModel/GeoMech/RimGeoMechView.h | 2 + 9 files changed, 150 insertions(+), 52 deletions(-) diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterFeatureImpl.cpp b/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterFeatureImpl.cpp index 337970eb90..9e9abb5e45 100644 --- a/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicGeoMechPropertyFilterFeatureImpl.cpp @@ -124,9 +124,9 @@ void RicGeoMechPropertyFilterFeatureImpl::setDefaults( RimGeoMechPropertyFilter* RimGeoMechView* reservoirView = propertyFilterCollection->reservoirView(); CVF_ASSERT( reservoirView ); - propertyFilter->resultDefinition->setGeoMechCase( reservoirView->geoMechCase() ); - propertyFilter->resultDefinition->setResultAddress( reservoirView->cellResultResultDefinition()->resultAddress() ); - propertyFilter->resultDefinition->loadResult(); + propertyFilter->resultDefinition()->setGeoMechCase( reservoirView->geoMechCase() ); + propertyFilter->resultDefinition()->setResultAddress( reservoirView->cellResultResultDefinition()->resultAddress() ); + propertyFilter->resultDefinition()->loadResult(); propertyFilter->setToDefaultValues(); propertyFilter->updateFilterName(); } diff --git a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp index 02791790cc..2271e733b6 100644 --- a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp @@ -157,19 +157,19 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility( cvf::UByteArray* RigGeoMechCaseData* caseData = propFilterColl->reservoirView()->geoMechCase()->geoMechData(); - RigFemResultAddress resVarAddress = RigFemAddressDefines::getResultLookupAddress( propertyFilter->resultDefinition->resultAddress() ); + RigFemResultAddress resVarAddress = RigFemAddressDefines::getResultLookupAddress( propertyFilter->resultDefinition()->resultAddress() ); const std::vector& resVals = caseData->femPartResults()->resultValues( resVarAddress, part->elementPartId(), timeStepIndex, frameIndex ); if ( !propertyFilter->isActive() ) continue; - if ( !propertyFilter->resultDefinition->hasResult() ) continue; + if ( !propertyFilter->resultDefinition()->hasResult() ) continue; if ( resVals.empty() ) continue; const double lowerBound = propertyFilter->lowerBound(); const double upperBound = propertyFilter->upperBound(); - if ( propertyFilter->resultDefinition->resultAddress().resultPosType == RIG_FORMATION_NAMES ) + if ( propertyFilter->resultDefinition()->resultAddress().resultPosType == RIG_FORMATION_NAMES ) { std::vector integerVector = propertyFilter->selectedCategoryValues(); std::set integerSet; diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilter.cpp index 3d9b8cee90..cefba8d9c0 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilter.cpp @@ -30,6 +30,7 @@ #include "RiuMainWindow.h" +#include "cafPdmUiCheckBoxEditor.h" #include "cafPdmUiDoubleSliderEditor.h" #include "cvfAssert.h" @@ -44,18 +45,25 @@ RimGeoMechPropertyFilter::RimGeoMechPropertyFilter() { CAF_PDM_InitObject( "Property Filter", ":/CellFilter_Values.png" ); - CAF_PDM_InitFieldNoDefault( &resultDefinition, "ResultDefinition", "Result Definition" ); - resultDefinition = new RimGeoMechResultDefinition(); + CAF_PDM_InitFieldNoDefault( &m_resultDefinition, "ResultDefinition", "Result Definition" ); + m_resultDefinition = new RimGeoMechResultDefinition(); // Set to hidden to avoid this item to been displayed as a child item // Fields in this object are displayed using defineUiOrdering() - resultDefinition.uiCapability()->setUiTreeChildrenHidden( true ); + m_resultDefinition.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitField( &lowerBound, "LowerBound", 0.0, "Min" ); - lowerBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); + CAF_PDM_InitFieldNoDefault( &m_linkedWithCellResult, + "LinkedWithCellResult", + "Linked With Cell Result", + "", + "The selected cell result is automatically used to update the property filter." ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_linkedWithCellResult ); - CAF_PDM_InitField( &upperBound, "UpperBound", 0.0, "Max" ); - upperBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); + CAF_PDM_InitField( &m_lowerBound, "LowerBound", 0.0, "Min" ); + m_lowerBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); + + CAF_PDM_InitField( &m_upperBound, "UpperBound", 0.0, "Max" ); + m_upperBound.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); updateIconState(); @@ -68,7 +76,47 @@ RimGeoMechPropertyFilter::RimGeoMechPropertyFilter() //-------------------------------------------------------------------------------------------------- RimGeoMechPropertyFilter::~RimGeoMechPropertyFilter() { - delete resultDefinition; + delete m_resultDefinition; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechResultDefinition* RimGeoMechPropertyFilter::resultDefinition() const +{ + return m_resultDefinition; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimGeoMechPropertyFilter::isLinkedWithCellResult() const +{ + return m_linkedWithCellResult; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilter::setLinkedWithCellResult( bool linkedWithCellResult ) +{ + m_linkedWithCellResult = linkedWithCellResult; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimGeoMechPropertyFilter::lowerBound() const +{ + return m_lowerBound; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimGeoMechPropertyFilter::upperBound() const +{ + return m_upperBound; } //-------------------------------------------------------------------------------------------------- @@ -76,8 +124,8 @@ RimGeoMechPropertyFilter::~RimGeoMechPropertyFilter() //-------------------------------------------------------------------------------------------------- void RimGeoMechPropertyFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) { - if ( &lowerBound == changedField || &upperBound == changedField || &m_isActive == changedField || &m_filterMode == changedField || - &m_selectedCategoryValues == changedField ) + if ( &m_lowerBound == changedField || &m_upperBound == changedField || &m_isActive == changedField || &m_filterMode == changedField || + &m_selectedCategoryValues == changedField || &m_linkedWithCellResult == changedField ) { updateIconState(); updateFilterName(); @@ -112,8 +160,8 @@ void RimGeoMechPropertyFilter::setToDefaultValues() computeResultValueRange(); - lowerBound = m_minimumResultValue; - upperBound = m_maximumResultValue; + m_lowerBound = m_minimumResultValue; + m_upperBound = m_maximumResultValue; m_selectedCategoryValues = m_categoryValues; @@ -126,22 +174,28 @@ void RimGeoMechPropertyFilter::setToDefaultValues() void RimGeoMechPropertyFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { uiOrdering.add( &m_name ); + uiOrdering.add( &m_linkedWithCellResult ); + if ( m_linkedWithCellResult() ) + { + uiOrdering.skipRemainingFields( true ); + return; + } caf::PdmUiGroup* group1 = uiOrdering.addNewGroup( "Result" ); - resultDefinition->uiOrdering( uiConfigName, *group1 ); + m_resultDefinition->uiOrdering( uiConfigName, *group1 ); caf::PdmUiGroup& group2 = *( uiOrdering.addNewGroup( "Filter Settings" ) ); group2.add( &m_filterMode ); - if ( resultDefinition->hasCategoryResult() ) + if ( m_resultDefinition->hasCategoryResult() ) { group2.add( &m_selectedCategoryValues ); } else { - group2.add( &lowerBound ); - group2.add( &upperBound ); + group2.add( &m_lowerBound ); + group2.add( &m_upperBound ); } updateReadOnlyStateOfAllFields(); @@ -169,9 +223,9 @@ void RimGeoMechPropertyFilter::updateReadOnlyStateOfAllFields() std::vector objFields = fields(); // Include fields declared in RimResultDefinition - objFields.push_back( &( resultDefinition->m_resultPositionTypeUiField ) ); - objFields.push_back( &( resultDefinition->m_resultVariableUiField ) ); - objFields.push_back( &( resultDefinition->m_timeLapseBaseTimestep ) ); + objFields.push_back( &( m_resultDefinition->m_resultPositionTypeUiField ) ); + objFields.push_back( &( m_resultDefinition->m_resultVariableUiField ) ); + objFields.push_back( &( m_resultDefinition->m_timeLapseBaseTimestep ) ); for ( size_t i = 0; i < objFields.size(); i++ ) { @@ -212,7 +266,7 @@ void RimGeoMechPropertyFilter::updateActiveState() //-------------------------------------------------------------------------------------------------- bool RimGeoMechPropertyFilter::isActiveAndHasResult() { - return isActive() && resultDefinition->hasResult(); + return isActive() && m_resultDefinition->hasResult(); } //-------------------------------------------------------------------------------------------------- @@ -225,7 +279,7 @@ void RimGeoMechPropertyFilter::defineEditorAttribute( const caf::PdmFieldHandle* return; } - if ( field == &lowerBound || field == &upperBound ) + if ( field == &m_lowerBound || field == &m_upperBound ) { caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast( attribute ); if ( !myAttr ) @@ -250,25 +304,25 @@ void RimGeoMechPropertyFilter::computeResultValueRange() clearCategories(); - RigFemResultAddress resultAddress = resultDefinition->resultAddress(); - if ( resultAddress.isValid() && resultDefinition->ownerCaseData() ) + RigFemResultAddress resultAddress = m_resultDefinition->resultAddress(); + if ( resultAddress.isValid() && m_resultDefinition->ownerCaseData() ) { - if ( resultDefinition->hasCategoryResult() ) + if ( m_resultDefinition->hasCategoryResult() ) { - std::vector fnVector = resultDefinition->ownerCaseData()->femPartResults()->formationNames(); + std::vector fnVector = m_resultDefinition->ownerCaseData()->femPartResults()->formationNames(); setCategoryNames( fnVector ); } else { - resultDefinition->ownerCaseData()->femPartResults()->minMaxScalarValues( resultAddress, &min, &max ); + m_resultDefinition->ownerCaseData()->femPartResults()->minMaxScalarValues( resultAddress, &min, &max ); } } m_maximumResultValue = max; m_minimumResultValue = min; - lowerBound.uiCapability()->setUiName( QString( "Min (%1)" ).arg( min ) ); - upperBound.uiCapability()->setUiName( QString( "Max (%1)" ).arg( max ) ); + m_lowerBound.uiCapability()->setUiName( QString( "Min (%1)" ).arg( min ) ); + m_upperBound.uiCapability()->setUiName( QString( "Max (%1)" ).arg( max ) ); } //-------------------------------------------------------------------------------------------------- @@ -276,12 +330,12 @@ void RimGeoMechPropertyFilter::computeResultValueRange() //-------------------------------------------------------------------------------------------------- void RimGeoMechPropertyFilter::updateFilterName() { - RigFemResultAddress resultAddress = resultDefinition->resultAddress(); + RigFemResultAddress resultAddress = m_resultDefinition->resultAddress(); QString newFiltername; if ( resultAddress.resultPosType == RIG_FORMATION_NAMES ) { - newFiltername = resultDefinition->resultFieldName(); + newFiltername = m_resultDefinition->resultFieldName(); } else { @@ -303,11 +357,11 @@ void RimGeoMechPropertyFilter::updateFilterName() break; } - QString fieldUiName = resultDefinition->resultFieldUiName(); - QString compoUiName = resultDefinition->resultComponentUiName(); + QString fieldUiName = m_resultDefinition->resultFieldUiName(); + QString compoUiName = m_resultDefinition->resultComponentUiName(); - newFiltername = posName + ", " + fieldUiName + ", " + compoUiName + " (" + QString::number( lowerBound() ) + " .. " + - QString::number( upperBound ) + ")"; + newFiltername = posName + ", " + fieldUiName + ", " + compoUiName + " (" + QString::number( m_lowerBound() ) + " .. " + + QString::number( m_upperBound ) + ")"; } m_name = newFiltername; diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilter.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilter.h index e4fcfd165c..71af1e1da1 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilter.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilter.h @@ -38,10 +38,13 @@ public: RimGeoMechPropertyFilter(); ~RimGeoMechPropertyFilter() override; - caf::PdmChildField resultDefinition; + RimGeoMechResultDefinition* resultDefinition() const; - caf::PdmField lowerBound; - caf::PdmField upperBound; + bool isLinkedWithCellResult() const; + void setLinkedWithCellResult( bool linkedWithCellResult ); + + double lowerBound() const; + double upperBound() const; void setParentContainer( RimGeoMechPropertyFilterCollection* parentContainer ); RimGeoMechPropertyFilterCollection* parentContainer(); @@ -63,6 +66,12 @@ private: bool isPropertyFilterControlled(); private: + caf::PdmChildField m_resultDefinition; + caf::PdmField m_linkedWithCellResult; + + caf::PdmField m_lowerBound; + caf::PdmField m_upperBound; + RimGeoMechPropertyFilterCollection* m_parentContainer; double m_minimumResultValue; double m_maximumResultValue; diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.cpp index 7b24077c07..0ed8cc4d8a 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.cpp @@ -25,6 +25,8 @@ #include "RimViewController.h" #include "RimViewLinker.h" +#include "RigFemResultAddress.h" + #include "cvfAssert.h" CAF_PDM_SOURCE_INIT( RimGeoMechPropertyFilterCollection, "GeoMechPropertyFilters" ); @@ -55,8 +57,8 @@ void RimGeoMechPropertyFilterCollection::loadAndInitializePropertyFilters() for ( size_t i = 0; i < propertyFilters.size(); i++ ) { RimGeoMechPropertyFilter* propertyFilter = propertyFilters[i]; - propertyFilter->resultDefinition->setGeoMechCase( reservoirView()->geoMechCase() ); - propertyFilter->resultDefinition->loadResult(); + propertyFilter->resultDefinition()->setGeoMechCase( reservoirView()->geoMechCase() ); + propertyFilter->resultDefinition()->loadResult(); propertyFilter->computeResultValueRange(); } } @@ -71,7 +73,7 @@ void RimGeoMechPropertyFilterCollection::initAfterRead() RimGeoMechPropertyFilter* propertyFilter = propertyFilters[i]; propertyFilter->setParentContainer( this ); - propertyFilter->resultDefinition->setGeoMechCase( reservoirView()->geoMechCase() ); + propertyFilter->resultDefinition()->setGeoMechCase( reservoirView()->geoMechCase() ); propertyFilter->updateIconState(); } @@ -88,7 +90,7 @@ bool RimGeoMechPropertyFilterCollection::hasActiveFilters() const for ( size_t i = 0; i < propertyFilters.size(); i++ ) { RimGeoMechPropertyFilter* propertyFilter = propertyFilters[i]; - if ( propertyFilter->isActive() && propertyFilter->resultDefinition->hasResult() ) return true; + if ( propertyFilter->isActive() && propertyFilter->resultDefinition()->hasResult() ) return true; } return false; @@ -112,8 +114,8 @@ bool RimGeoMechPropertyFilterCollection::isUsingFormationNames() const for ( size_t i = 0; i < propertyFilters.size(); i++ ) { RimGeoMechPropertyFilter* propertyFilter = propertyFilters[i]; - if ( propertyFilter->isActive() && propertyFilter->resultDefinition->resultPositionType() == RIG_FORMATION_NAMES && - propertyFilter->resultDefinition->resultFieldName() != "" ) + if ( propertyFilter->isActive() && propertyFilter->resultDefinition()->resultPositionType() == RIG_FORMATION_NAMES && + propertyFilter->resultDefinition()->resultFieldName() != "" ) return true; } @@ -150,3 +152,23 @@ void RimGeoMechPropertyFilterCollection::updateIconState() propFilter->updateIconState(); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilterCollection::updateFromResult( const RimGeoMechResultDefinition* resultDefinition ) +{ + if ( !resultDefinition ) return; + + for ( auto filter : propertyFilters ) + { + if ( filter->isLinkedWithCellResult() ) + { + filter->resultDefinition()->setResultAddress( resultDefinition->resultAddress() ); + filter->setToDefaultValues(); + filter->updateFilterName(); + + updateDisplayModelNotifyManagedViews( filter ); + } + } +} diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.h index 5b9bf413fb..1a4dd61626 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimGeoMechPropertyFilterCollection.h @@ -27,6 +27,7 @@ class RimGeoMechPropertyFilter; class RimGeoMechView; +class RimGeoMechResultDefinition; //================================================================================================== /// @@ -52,6 +53,8 @@ public: void loadAndInitializePropertyFilters() override; void updateIconState() override; + void updateFromResult( const RimGeoMechResultDefinition* resultDefinition ); + protected: // Overridden methods void initAfterRead() override; diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp index 8800ce7ec4..6c69d191d5 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp @@ -922,7 +922,7 @@ void RimGeoMechCase::updateFormationNamesData() RimGeoMechPropertyFilterCollection* eclFilColl = geomView->geoMechPropertyFilterCollection(); for ( RimGeoMechPropertyFilter* propFilter : eclFilColl->propertyFilters ) { - if ( propFilter->resultDefinition->resultPositionType() == RIG_FORMATION_NAMES ) + if ( propFilter->resultDefinition()->resultPositionType() == RIG_FORMATION_NAMES ) { propFilter->setToDefaultValues(); propFilter->updateConnectedEditors(); @@ -1021,9 +1021,9 @@ void RimGeoMechCase::closeSelectedElementPropertyFiles() for ( RimGeoMechPropertyFilter* propertyFilter : view->geoMechPropertyFilterCollection()->propertyFilters() ) { - if ( address == propertyFilter->resultDefinition->resultAddress() ) + if ( address == propertyFilter->resultDefinition()->resultAddress() ) { - propertyFilter->resultDefinition->setResultAddress( RigFemResultAddress() ); + propertyFilter->resultDefinition()->setResultAddress( RigFemResultAddress() ); } } } diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp index 7b9777b9b6..f48e5e05d5 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp @@ -504,6 +504,14 @@ void RimGeoMechView::onUpdateStaticCellColors() m_vizLogic->updateStaticCellColors( -1 ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) +{ + m_propertyFilterCollection->updateFromResult( cellResult() ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.h b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.h index edbe419717..d0906e8b1b 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.h +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.h @@ -138,6 +138,8 @@ private: void onUpdateDisplayModelForCurrentTimeStep() override; void onUpdateStaticCellColors() override; + void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override; + void onUpdateLegends() override; void updateTensorLegendTextAndRanges( RimRegularLegendConfig* legendConfig, int viewerTimeStep );