Skip to content

Commit

Permalink
#11994 GeoMech: Allow property filter to be linked to cell result
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Dec 20, 2024
1 parent 0ec9a36 commit 7877cdf
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>& 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<int> integerVector = propertyFilter->selectedCategoryValues();
std::set<int> integerSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "RiuMainWindow.h"

#include "cafPdmUiCheckBoxEditor.h"
#include "cafPdmUiDoubleSliderEditor.h"

#include "cvfAssert.h"
Expand All @@ -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();

Expand All @@ -68,16 +76,56 @@ 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;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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();
Expand Down Expand Up @@ -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;

Expand All @@ -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();
Expand Down Expand Up @@ -169,9 +223,9 @@ void RimGeoMechPropertyFilter::updateReadOnlyStateOfAllFields()
std::vector<caf::PdmFieldHandle*> 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++ )
{
Expand Down Expand Up @@ -212,7 +266,7 @@ void RimGeoMechPropertyFilter::updateActiveState()
//--------------------------------------------------------------------------------------------------
bool RimGeoMechPropertyFilter::isActiveAndHasResult()
{
return isActive() && resultDefinition->hasResult();
return isActive() && m_resultDefinition->hasResult();
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -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<caf::PdmUiDoubleSliderEditorAttribute*>( attribute );
if ( !myAttr )
Expand All @@ -250,38 +304,38 @@ 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<QString> fnVector = resultDefinition->ownerCaseData()->femPartResults()->formationNames();
std::vector<QString> 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 ) );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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
{
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ class RimGeoMechPropertyFilter : public RimPropertyFilter
RimGeoMechPropertyFilter();
~RimGeoMechPropertyFilter() override;

caf::PdmChildField<RimGeoMechResultDefinition*> resultDefinition;
RimGeoMechResultDefinition* resultDefinition() const;

caf::PdmField<double> lowerBound;
caf::PdmField<double> upperBound;
bool isLinkedWithCellResult() const;
void setLinkedWithCellResult( bool linkedWithCellResult );

double lowerBound() const;
double upperBound() const;

void setParentContainer( RimGeoMechPropertyFilterCollection* parentContainer );
RimGeoMechPropertyFilterCollection* parentContainer();
Expand All @@ -63,6 +66,12 @@ class RimGeoMechPropertyFilter : public RimPropertyFilter
bool isPropertyFilterControlled();

private:
caf::PdmChildField<RimGeoMechResultDefinition*> m_resultDefinition;
caf::PdmField<bool> m_linkedWithCellResult;

caf::PdmField<double> m_lowerBound;
caf::PdmField<double> m_upperBound;

RimGeoMechPropertyFilterCollection* m_parentContainer;
double m_minimumResultValue;
double m_maximumResultValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "RimViewController.h"
#include "RimViewLinker.h"

#include "RigFemResultAddress.h"

#include "cvfAssert.h"

CAF_PDM_SOURCE_INIT( RimGeoMechPropertyFilterCollection, "GeoMechPropertyFilters" );
Expand Down Expand Up @@ -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();
}
}
Expand All @@ -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();
}

Expand All @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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 );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

class RimGeoMechPropertyFilter;
class RimGeoMechView;
class RimGeoMechResultDefinition;

//==================================================================================================
///
Expand All @@ -52,6 +53,8 @@ class RimGeoMechPropertyFilterCollection : public RimPropertyFilterCollection
void loadAndInitializePropertyFilters() override;
void updateIconState() override;

void updateFromResult( const RimGeoMechResultDefinition* resultDefinition );

protected:
// Overridden methods
void initAfterRead() override;
Expand Down
Loading

0 comments on commit 7877cdf

Please sign in to comment.