Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void RicCloseObservedDataFeature::deleteObservedSummaryData( const std::vector<R
{
for ( RimSummaryPlot* summaryPlot : multiPlot->summaryPlots() )
{
summaryPlot->deleteCurvesAssosiatedWithCase( observedData );
summaryPlot->deleteCurvesAssosiatedWithCases( { observedData } );
}
multiPlot->updateConnectedEditors();
}
Expand Down
15 changes: 8 additions & 7 deletions ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

#include <QAction>

#include <set>

CAF_CMD_SOURCE_INIT( RicCloseSummaryCaseFeature, "RicCloseSummaryCaseFeature" );

//--------------------------------------------------------------------------------------------------
Expand All @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,34 @@
#include <QAction>
#include <QMessageBox>

#include <set>

CAF_CMD_SOURCE_INIT( RicDeleteSummaryCaseCollectionFeature, "RicDeleteSummaryCaseCollectionFeature" );

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ std::vector<RimSummaryCurve*> RimSummaryCurveCollection::curves() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCurveCollection::deleteCurvesAssosiatedWithCase( RimSummaryCase* summaryCase )
bool RimSummaryCurveCollection::deleteCurvesAssosiatedWithCases( const std::set<RimSummaryCase*>& summaryCases )
{
std::vector<RimSummaryCurve*> summaryCurvesToDelete;

Expand All @@ -238,7 +238,7 @@ void RimSummaryCurveCollection::deleteCurvesAssosiatedWithCase( RimSummaryCase*
if ( !summaryCurve ) continue;
if ( !summaryCurve->summaryCaseY() ) continue;

if ( summaryCurve->summaryCaseY() == summaryCase )
if ( summaryCases.contains( summaryCurve->summaryCaseY() ) )
{
summaryCurvesToDelete.push_back( summaryCurve );
}
Expand All @@ -248,6 +248,8 @@ void RimSummaryCurveCollection::deleteCurvesAssosiatedWithCase( RimSummaryCase*
m_curves.removeChild( summaryCurve );
delete summaryCurve;
}

return !summaryCurvesToDelete.empty();
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "cafPdmField.h"
#include "cafPdmObject.h"

#include <set>

class RimSummaryCase;
class RimSummaryCurve;
class RimSummaryPlot;
Expand Down Expand Up @@ -75,7 +77,8 @@ class RimSummaryCurveCollection : public caf::PdmObject
void deleteCurve( RimSummaryCurve* curve );
void removeCurve( RimSummaryCurve* curve );

void deleteCurvesAssosiatedWithCase( RimSummaryCase* summaryCase );
/// Delete the curves associated with any of the given cases. Returns true if any curve was deleted.
bool deleteCurvesAssosiatedWithCases( const std::set<RimSummaryCase*>& summaryCases );
void deleteAllCurves();
void updateCaseNameHasChanged();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include <QFileInfo>

#include <cmath>
#include <set>

CAF_PDM_SOURCE_INIT( RimSummaryEnsemble, "SummaryCaseSubCollection" );

Expand Down Expand Up @@ -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();
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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<RimSummaryPlot*> plotsToUpdate;

for ( auto curveSet : objectsWithReferringPtrFieldsOfType<RimEnsembleCurveSet>() )
{
if ( !curveSet ) continue;

curveSet->deleteEnsembleCurves();
curveSet->deleteStatisticsCurves();
curveSet->filterChanged.send();

if ( auto parentPlot = curveSet->firstAncestorOrThisOfType<RimSummaryPlot>() )
{
plotsToUpdate.insert( parentPlot );
}
}

for ( auto plot : plotsToUpdate )
{
plot->updateAll();
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class RimSummaryEnsemble : public caf::PdmObject

void updateReferringCurveSets();
void updateReferringCurveSetsZoomAll();
void clearReferringCurveSets();

RiaSummaryAddressAnalyzer* addressAnalyzer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1497,12 +1497,14 @@ void RimSummaryPlot::deleteCurves( const std::vector<RimSummaryCurve*>& curves )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::deleteCurvesAssosiatedWithCase( RimSummaryCase* summaryCase )
bool RimSummaryPlot::deleteCurvesAssosiatedWithCases( const std::set<RimSummaryCase*>& summaryCases )
{
if ( m_summaryCurveCollection )
{
m_summaryCurveCollection->deleteCurvesAssosiatedWithCase( summaryCase );
return m_summaryCurveCollection->deleteCurvesAssosiatedWithCases( summaryCases );
}

return false;
}

//--------------------------------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ class RimSummaryPlot : public RimPlot, public RimSummaryDataSourceStepping, publ

void deleteCurves( const std::vector<RimSummaryCurve*>& curves );

void deleteCurvesAssosiatedWithCase( RimSummaryCase* summaryCase );
/// Delete the curves associated with any of the given cases. Returns true if any curve was deleted.
bool deleteCurvesAssosiatedWithCases( const std::set<RimSummaryCase*>& summaryCases );

RimEnsembleCurveSetCollection* ensembleCurveSetCollection() const;

Expand Down