Skip to content

Commit

Permalink
Move meta data updates to summarycalculationcollection
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Feb 24, 2024
1 parent a9475bb commit fe58976
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 48 deletions.
49 changes: 2 additions & 47 deletions ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,17 @@

#include "RifSummaryReaderInterface.h"
#include "RimDataSourceSteppingTools.h"
#include "RimObservedDataCollection.h"
#include "RimObservedSummaryData.h"
#include "RimProject.h"
#include "RimSummaryAddress.h"
#include "RimSummaryCalculationCollection.h"
#include "RimSummaryCalculationVariable.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryCurve.h"
#include "RimSummaryMultiPlot.h"
#include "RimSummaryMultiPlotCollection.h"
#include "RimSummaryPlot.h"

#include "RiuExpressionContextMenuManager.h"

#include "cafPdmUiCheckBoxEditor.h"
#include "cafPdmUiLineEditor.h"
#include "cafPdmUiTableViewEditor.h"
#include "cafPdmUiTextEditor.h"

#include "expressionparser/ExpressionParser.h"

Expand Down Expand Up @@ -402,51 +393,14 @@ std::optional<std::pair<std::vector<double>, std::vector<time_t>>>
//--------------------------------------------------------------------------------------------------
void RimSummaryCalculation::updateDependentObjects()
{
auto calcColl = firstAncestorOrThisOfTypeAsserted<RimSummaryCalculationCollection>();
calcColl->rebuildCaseMetaData();

// Refresh data sources tree
// Refresh meta data for all summary cases and rebuild AddressNodes in the summary tree
RimSummaryCaseMainCollection* summaryCaseCollection = RiaSummaryTools::summaryCaseMainCollection();
auto summaryCases = summaryCaseCollection->allSummaryCases();
for ( RimSummaryCase* summaryCase : summaryCases )
{
if ( !summaryCase ) continue;

if ( auto reader = summaryCase->summaryReader() )
{
reader->rebuildMetaData();
summaryCase->onCalculationUpdated();
}
}

RimObservedDataCollection* observedDataCollection = RiaSummaryTools::observedDataCollection();
auto observedData = observedDataCollection->allObservedSummaryData();
for ( auto obs : observedData )
{
if ( !obs ) continue;

if ( auto reader = obs->summaryReader() )
{
reader->rebuildMetaData();
obs->onCalculationUpdated();
}
}

auto summaryCaseCollections = summaryCaseCollection->summaryCaseCollections();
for ( RimSummaryCaseCollection* summaryCaseCollection : summaryCaseCollections )
{
summaryCaseCollection->onCalculationUpdated();
}

RimSummaryMultiPlotCollection* summaryPlotCollection = RiaSummaryTools::summaryMultiPlotCollection();
for ( auto multiPlot : summaryPlotCollection->multiPlots() )
{
for ( RimSummaryPlot* sumPlot : multiPlot->summaryPlots() )
{
bool plotContainsCalculatedCurves = false;

for ( RimSummaryCurve* sumCurve : sumPlot->summaryCurves() )
for ( RimSummaryCurve* sumCurve : sumPlot->summaryAndEnsembleCurves() )
{
if ( sumCurve->summaryAddressY().isCalculated() )
{
Expand All @@ -469,6 +423,7 @@ void RimSummaryCalculation::updateDependentObjects()
//--------------------------------------------------------------------------------------------------
void RimSummaryCalculation::removeDependentObjects()
{
updateDependentObjects();
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@

#include "RimSummaryCalculationCollection.h"

#include "RiaSummaryTools.h"

#include "RifSummaryReaderInterface.h"

#include "RimObservedSummaryData.h"
#include "RimSummaryCalculation.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCaseMainCollection.h"

CAF_PDM_SOURCE_INIT( RimSummaryCalculationCollection, "RimSummaryCalculationCollection" );
//--------------------------------------------------------------------------------------------------
Expand All @@ -37,12 +45,53 @@ RimSummaryCalculation* RimSummaryCalculationCollection::createCalculation() cons
return new RimSummaryCalculation;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCalculationCollection::updateDataDependingOnCalculations()
{
// Refresh data sources tree
// Refresh meta data for all summary cases and rebuild AddressNodes in the summary tree
RimSummaryCaseMainCollection* summaryCaseCollection = RiaSummaryTools::summaryCaseMainCollection();
auto summaryCases = summaryCaseCollection->allSummaryCases();
for ( RimSummaryCase* summaryCase : summaryCases )
{
if ( !summaryCase ) continue;

if ( auto reader = summaryCase->summaryReader() )
{
reader->rebuildMetaData();
summaryCase->onCalculationUpdated();
}
}

RimObservedDataCollection* observedDataCollection = RiaSummaryTools::observedDataCollection();
auto observedData = observedDataCollection->allObservedSummaryData();
for ( auto obs : observedData )
{
if ( !obs ) continue;

if ( auto reader = obs->summaryReader() )
{
reader->rebuildMetaData();
obs->onCalculationUpdated();
}
}

auto summaryCaseCollections = summaryCaseCollection->summaryCaseCollections();
for ( RimSummaryCaseCollection* summaryCaseCollection : summaryCaseCollections )
{
summaryCaseCollection->onCalculationUpdated();
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCalculationCollection::rebuildCaseMetaData()
{
ensureValidCalculationIds();
updateDataDependingOnCalculations();
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ class RimSummaryCalculationCollection : public RimUserDefinedCalculationCollecti
RimSummaryCalculation* createCalculation() const override;

private:
void updateDataDependingOnCalculations();
void initAfterRead() override;
};
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ RimUserDefinedCalculation* RimUserDefinedCalculationCollection::addCalculationCo
//--------------------------------------------------------------------------------------------------
void RimUserDefinedCalculationCollection::deleteCalculation( RimUserDefinedCalculation* calculation )
{
calculation->removeDependentObjects();
m_calculations.removeChild( calculation );

// Call this function after the object is removed from the collection
calculation->removeDependentObjects();

rebuildCaseMetaData();

delete calculation;
Expand Down

0 comments on commit fe58976

Please sign in to comment.