mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Make sure onChildrenUpdated is called in RicToggleItemsOnOthersOffFeature
This commit is contained in:
@@ -55,12 +55,16 @@ void RicToggleItemsOnOthersOffFeature::onActionTriggered( bool isChecked )
|
||||
// First toggle off all siblings
|
||||
caf::PdmFieldHandle* commonParent = commonParentForAllSelections( selectedObjects );
|
||||
|
||||
caf::PdmFieldHandle* firstField = nullptr;
|
||||
|
||||
for ( caf::PdmObjectHandle* child : childObjects( commonParent ) )
|
||||
{
|
||||
caf::PdmField<bool>* field = objectToggleField( child );
|
||||
|
||||
if ( field )
|
||||
{
|
||||
if ( !firstField ) firstField = field;
|
||||
|
||||
// Avoid calling setValueWithFieldChanged() here, as this potentially can trigger heavy computations. Assume
|
||||
// that the update logic is sufficient when setting the selected objects.
|
||||
field->setValue( false );
|
||||
@@ -74,6 +78,15 @@ void RicToggleItemsOnOthersOffFeature::onActionTriggered( bool isChecked )
|
||||
|
||||
field->setValueWithFieldChanged( true );
|
||||
}
|
||||
|
||||
// If multiple fields are updated, we call onChildrenUpdated() on the owner of the first field
|
||||
// Example: Trigger replot of curves when multiple curves are toggled
|
||||
auto [ownerOfChildArrayField, childArrayFieldHandle] = RicToggleItemsFeatureImpl::findOwnerAndChildArrayField( firstField );
|
||||
if ( ownerOfChildArrayField && childArrayFieldHandle )
|
||||
{
|
||||
std::vector<caf::PdmObjectHandle*> objs;
|
||||
ownerOfChildArrayField->onChildrenUpdated( childArrayFieldHandle, objs );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user