#14493 Delete curves for all cases in one pass when deleting a summary ensemble

deleteSummaryCaseCollection() looped over every case in the ensemble, and for each case scanned every summary plot and called updateConnectedEditors() on every multi plot. For an ensemble with many realizations this scanned each plot once per realization, and updated the connected editors once per realization and multi plot. This showed up as a hot spot in the profiler.

Replace deleteCurvesAssosiatedWithCase() with deleteCurvesAssosiatedWithCases(), which takes a set of cases and returns whether anything was deleted. Each plot is now scanned once, and the connected editors of a multi plot are updated only when that multi plot actually lost a curve.

RicCloseSummaryCaseFeature and RicCloseObservedDataFeature are updated to the new signature. RicCloseSummaryCaseFeature also scans each plot once instead of once per case.
This commit is contained in:
Magne Sjaastad committed 2026-08-10 12:38:41 +02:00
1 parent 1d4a15fd89
commit 1660e333ff
7 files changed
+39 -21

No files matched your search

@@ -60,7 +60,7 @@ void RicCloseObservedDataFeature::deleteObservedSummaryData( const std::vector<R
{
for ( RimSummaryPlot* summaryPlot : multiPlot->summaryPlots() )
{
summaryPlot->deleteCurvesAssosiatedWithCase( observedData );
summaryPlot->deleteCurvesAssosiatedWithCases( { observedData } );
}
multiPlot->updateConnectedEditors();
}
@@ -42,6 +42,8 @@
#include <QAction>
#include <set>
CAF_CMD_SOURCE_INIT( RicCloseSummaryCaseFeature, "RicCloseSummaryCaseFeature" );
//--------------------------------------------------------------------------------------------------
@@ -66,16 +68,15 @@ void RicCloseSummaryCaseFeature::deleteSummaryCases( std::vector<RimSummaryCase*
auto depthTrackPlots = caf::PdmObjectHandleTools::referringAncestorOfType<RimDepthTrackPlot, RimSummaryCase>( cases );
for ( RimSummaryCase* summaryCase : cases )
const std::set<RimSummaryCase*> casesToDelete( cases.begin(), cases.end() );
for ( RimSummaryMultiPlot* multiPlot : summaryPlotColl->multiPlots() )
{
for ( RimSummaryMultiPlot* multiPlot : summaryPlotColl->multiPlots() )
for ( RimSummaryPlot* summaryPlot : multiPlot->summaryPlots() )
{
for ( RimSummaryPlot* summaryPlot : multiPlot->summaryPlots() )
{
summaryPlot->deleteCurvesAssosiatedWithCase( summaryCase );
}
plotsToUpdate.insert( multiPlot );
summaryPlot->deleteCurvesAssosiatedWithCases( casesToDelete );
}
plotsToUpdate.insert( multiPlot );
}
summaryCaseMainCollection->removeCases( cases );
@@ -41,6 +41,8 @@
#include <QAction>
#include <QMessageBox>
#include <set>
CAF_CMD_SOURCE_INIT( RicDeleteSummaryCaseCollectionFeature, "RicDeleteSummaryCaseCollectionFeature" );
//--------------------------------------------------------------------------------------------------
@@ -48,18 +50,25 @@ CAF_CMD_SOURCE_INIT( RicDeleteSummaryCaseCollectionFeature, "RicDeleteSummaryCas
//--------------------------------------------------------------------------------------------------
void RicDeleteSummaryCaseCollectionFeature::deleteSummaryCaseCollection( RimSummaryEnsemble* caseCollection )
{
auto cases = caseCollection->allSummaryCases();
if ( cases.empty() ) return;
// Delete the curves for all the cases in one pass per plot, and update each multi plot only if it actually lost a
// curve. Doing this per case meant scanning every plot once per realization and updating the connected editors
// once per realization and multi plot.
const std::set<RimSummaryCase*> casesToDelete( cases.begin(), cases.end() );
RimSummaryMultiPlotCollection* summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection();
for ( RimSummaryCase* summaryCase : caseCollection->allSummaryCases() )
for ( RimSummaryMultiPlot* multiPlot : summaryPlotColl->multiPlots() )
{
for ( RimSummaryMultiPlot* multiPlot : summaryPlotColl->multiPlots() )
bool curvesDeleted = false;
for ( RimSummaryPlot* summaryPlot : multiPlot->summaryPlots() )
{
for ( RimSummaryPlot* summaryPlot : multiPlot->summaryPlots() )
{
summaryPlot->deleteCurvesAssosiatedWithCase( summaryCase );
}
multiPlot->updateConnectedEditors();
if ( summaryPlot->deleteCurvesAssosiatedWithCases( casesToDelete ) ) curvesDeleted = true;
}
if ( curvesDeleted ) multiPlot->updateConnectedEditors();
}
}