diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsemble.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsemble.cpp index 633d6ff53a..b9c7ed443a 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsemble.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsemble.cpp @@ -53,6 +53,7 @@ #include #include +#include CAF_PDM_SOURCE_INIT( RimSummaryEnsemble, "SummaryCaseSubCollection" ); @@ -118,7 +119,8 @@ RimSummaryEnsemble::~RimSummaryEnsemble() { m_cases.deleteChildren(); - updateReferringCurveSets(); + // The cases are gone at this point, so the referring curve sets are cleared and their plots redrawn without data. + clearReferringCurveSets(); } //-------------------------------------------------------------------------------------------------- @@ -787,6 +789,37 @@ void RimSummaryEnsemble::updateReferringCurveSets() updateReferringCurveSets( false ); } +//-------------------------------------------------------------------------------------------------- +/// Clear the curves of the curve sets referring to this ensemble, and redraw the affected plots. +/// +/// Used when the summary cases have been deleted. Reloading the curve data has nothing to read at that point, so this +/// deletes the curves directly instead of going through loadDataAndUpdate(). Each plot is updated once, even when it +/// holds several curve sets referring to this ensemble. +//-------------------------------------------------------------------------------------------------- +void RimSummaryEnsemble::clearReferringCurveSets() +{ + std::set plotsToUpdate; + + for ( auto curveSet : objectsWithReferringPtrFieldsOfType() ) + { + if ( !curveSet ) continue; + + curveSet->deleteEnsembleCurves(); + curveSet->deleteStatisticsCurves(); + curveSet->filterChanged.send(); + + if ( auto parentPlot = curveSet->firstAncestorOrThisOfType() ) + { + plotsToUpdate.insert( parentPlot ); + } + } + + for ( auto plot : plotsToUpdate ) + { + plot->updateAll(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsemble.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsemble.h index 2a84c41a9a..ce17ef3ad0 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsemble.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsemble.h @@ -113,6 +113,7 @@ public: void updateReferringCurveSets(); void updateReferringCurveSetsZoomAll(); + void clearReferringCurveSets(); RiaSummaryAddressAnalyzer* addressAnalyzer();