diff --git a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.h b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.h index a4eeac73ab..6bfcae356e 100644 --- a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.h +++ b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.h @@ -52,10 +52,10 @@ public: static QString findCollectionName( SelectionToggleType state ); + static std::pair findOwnerAndChildArrayField( caf::PdmFieldHandle* fieldHandle ); + private: static caf::PdmUiTreeView* findTreeView( const caf::PdmUiItem* uiItem ); static caf::PdmUiTreeOrdering* findTreeItemFromSelectedUiItem( const caf::PdmUiItem* uiItem ); static std::vector*> findToggleFieldsFromSelection( SelectionToggleType state ); - - static std::pair findOwnerAndChildArrayField( caf::PdmFieldHandle* fieldHandle ); }; diff --git a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.cpp b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.cpp index 9d8e7e9b5d..3783e57015 100644 --- a/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.cpp +++ b/ApplicationLibCode/Commands/ToggleCommands/RicToggleItemsOnOthersOffFeature.cpp @@ -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* 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 objs; + ownerOfChildArrayField->onChildrenUpdated( childArrayFieldHandle, objs ); + } } //--------------------------------------------------------------------------------------------------