Grid Property Calculator: Improve UI to allow only one filter.

This commit is contained in:
Kristian Bendiksen 2022-06-10 11:55:41 +02:00
parent 5ea621d36f
commit c177e51c45
3 changed files with 41 additions and 3 deletions

View File

@ -385,3 +385,21 @@ std::pair<bool, QString> RimGridCalculation::validateVariables()
return std::make_pair( true, "" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridCalculation::onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& updatedObjects )
{
if ( childArray == &m_variables )
{
// Update the editors of all the variables if a variable changes.
// This makes the read-only state of the filter parameters consistent:
// only one filter is allowed at a time.
for ( auto v : m_variables )
{
v->updateConnectedEditors();
}
}
}

View File

@ -43,6 +43,9 @@ public:
void removeDependentObjects() override;
protected:
void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& updatedObjects ) override;
RimGridCalculationVariable* createVariable() const override;
std::pair<bool, QString> validateVariables();

View File

@ -23,6 +23,7 @@
#include "RiaPorosityModel.h"
#include "RiaResultNames.h"
#include "RimGridCalculation.h"
#include "RiuDragDrop.h"
#include "RigCaseCellResultsData.h"
@ -94,10 +95,26 @@ void RimGridCalculationVariable::defineUiOrdering( QString uiConfigName, caf::Pd
m_resultType.uiCapability()->setUiReadOnly( m_eclipseCase == nullptr );
m_timeStep.uiCapability()->setUiReadOnly( m_resultType == RiaDefines::ResultCatType::STATIC_NATIVE );
m_cellFilterView.uiCapability()->setUiReadOnly( m_eclipseCase == nullptr );
m_defaultValueType.uiCapability()->setUiReadOnly( m_cellFilterView == nullptr );
// Can have only one variable with cell filter at a time.
// Set read-only state based on the state of the sibling variables.
RimGridCalculation* calculation = nullptr;
firstAncestorOfType( calculation );
bool hasOtherVariableWithFilter = false;
for ( auto variable : calculation->allVariables() )
{
auto v = dynamic_cast<RimGridCalculationVariable*>( variable );
if ( variable != this && v->cellFilterView() )
{
hasOtherVariableWithFilter = true;
}
}
m_cellFilterView.uiCapability()->setUiReadOnly( m_eclipseCase == nullptr || hasOtherVariableWithFilter );
m_defaultValueType.uiCapability()->setUiReadOnly( m_cellFilterView == nullptr || hasOtherVariableWithFilter );
m_defaultValue.uiCapability()->setUiReadOnly(
m_cellFilterView == nullptr || defaultValueType() != RimGridCalculationVariable::DefaultValueType::USER_DEFINED );
m_cellFilterView == nullptr ||
defaultValueType() != RimGridCalculationVariable::DefaultValueType::USER_DEFINED || hasOtherVariableWithFilter );
}
//--------------------------------------------------------------------------------------------------