Add flag to optionally distribute a summary calculation to all cases

This commit is contained in:
Magne Sjaastad 2023-11-09 12:37:40 +01:00
parent 319dc2ab9b
commit eea56e4818
2 changed files with 19 additions and 1 deletions

View File

@ -61,8 +61,11 @@ RimSummaryCalculation::RimSummaryCalculation()
{
CAF_PDM_InitObject( "RimSummaryCalculation", ":/octave.png", "Calculation", "" );
CAF_PDM_InitField( &m_distributeToOtherItems, "DistributeToOtherItems", true, "Distribute to other items (wells, groups, ..)" );
CAF_PDM_InitField( &m_distributeToOtherItems, "DistributeToOtherItems", true, "Distribute to other items (wells, groups, ...)" );
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_distributeToOtherItems );
CAF_PDM_InitField( &m_distributeToAllCases, "DistributeToAllCases", true, "Distribute to All Cases" );
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_distributeToAllCases );
}
//--------------------------------------------------------------------------------------------------
@ -465,6 +468,20 @@ void RimSummaryCalculation::removeDependentObjects()
//--------------------------------------------------------------------------------------------------
std::vector<RimSummaryCalculationAddress> RimSummaryCalculation::allAddressesForSummaryCase( RimSummaryCase* summaryCase ) const
{
if ( !m_distributeToAllCases )
{
for ( auto& v : m_variables )
{
if ( auto variable = dynamic_cast<RimSummaryCalculationVariable*>( v.p() ) )
{
if ( variable->summaryCase() != summaryCase )
{
return {};
}
}
}
}
auto variables = getVariables();
if ( variables && !variables.value().empty() )
{

View File

@ -91,4 +91,5 @@ protected:
private:
caf::PdmField<bool> m_distributeToOtherItems;
caf::PdmField<bool> m_distributeToAllCases;
};