From d097aa861f390c947a39f76400db06acecb419a6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 23 Feb 2024 14:57:03 +0100 Subject: [PATCH 1/8] Only reload calculation data --- .../FileInterface/RifMultipleSummaryReaders.cpp | 2 +- .../FileInterface/RifMultipleSummaryReaders.h | 2 +- .../FileInterface/RifSummaryReaderInterface.cpp | 7 +++++++ .../FileInterface/RifSummaryReaderInterface.h | 2 ++ .../Summary/RimCalculatedSummaryCurveReader.cpp | 2 +- .../Summary/RimCalculatedSummaryCurveReader.h | 2 +- 6 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.cpp b/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.cpp index 785220b1f2..b05bc0f927 100644 --- a/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.cpp +++ b/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.cpp @@ -109,7 +109,7 @@ void RifMultipleSummaryReaders::rebuildMetaData() { // TODO: hack. Find a better way to rebuild calculated summary meta data. auto calcReader = dynamic_cast( reader.p() ); - if ( calcReader ) calcReader->buildMetaData(); + if ( calcReader ) calcReader->rebuildMetaData(); { auto resultAddresses = reader->allResultAddresses(); diff --git a/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.h b/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.h index a18d91fa09..41b82dc426 100644 --- a/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.h +++ b/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.h @@ -40,7 +40,7 @@ class RifMultipleSummaryReaders : public RifSummaryReaderInterface std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override; RiaDefines::EclipseUnitSystem unitSystem() const override; - void rebuildMetaData(); + void rebuildMetaData() override; private: cvf::Collection m_readers; diff --git a/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.cpp b/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.cpp index 599ab33b0e..1cbf835f22 100644 --- a/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.cpp +++ b/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.cpp @@ -49,6 +49,13 @@ RifEclipseSummaryAddress RifSummaryReaderInterface::errorAddress( const RifEclip return m_allErrorAddresses.find( errAddr ) != m_allErrorAddresses.end() ? errAddr : RifEclipseSummaryAddress(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifSummaryReaderInterface::rebuildMetaData() +{ +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.h b/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.h index 1c7c3b32a4..970ead77e3 100644 --- a/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.h +++ b/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.h @@ -51,6 +51,8 @@ class RifSummaryReaderInterface : public cvf::Object virtual std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const = 0; virtual RiaDefines::EclipseUnitSystem unitSystem() const = 0; + virtual void rebuildMetaData(); + protected: std::set m_allResultAddresses; // Result and error addresses std::set m_allErrorAddresses; // Error addresses diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp index e5efa6f85e..d1902a9553 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp @@ -81,7 +81,7 @@ std::string RifCalculatedSummaryCurveReader::unitName( const RifEclipseSummaryAd //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifCalculatedSummaryCurveReader::buildMetaData() +void RifCalculatedSummaryCurveReader::rebuildMetaData() { m_allResultAddresses.clear(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.h b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.h index b8f036a5f2..8846c34f22 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.h @@ -39,7 +39,7 @@ class RifCalculatedSummaryCurveReader : public RifSummaryReaderInterface std::pair> values( const RifEclipseSummaryAddress& resultAddress ) const override; std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override; - void buildMetaData(); + void rebuildMetaData() override; RiaDefines::EclipseUnitSystem unitSystem() const override; From a7254ff9a3b56b62876f5e98766d6cec0222451a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 23 Feb 2024 16:06:59 +0100 Subject: [PATCH 2/8] Avoid potential costly update --- ApplicationLibCode/Commands/RicUserDefinedCalculatorUi.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/ApplicationLibCode/Commands/RicUserDefinedCalculatorUi.cpp b/ApplicationLibCode/Commands/RicUserDefinedCalculatorUi.cpp index a8f09f924d..7c555cf1f6 100644 --- a/ApplicationLibCode/Commands/RicUserDefinedCalculatorUi.cpp +++ b/ApplicationLibCode/Commands/RicUserDefinedCalculatorUi.cpp @@ -90,8 +90,6 @@ bool RicUserDefinedCalculatorUi::parseExpression() const { notifyCalculatedNameChanged( m_currentCalculation()->id(), currentCurveName ); } - - m_currentCalculation()->updateDependentObjects(); } return true; From aace5fd4d73713c00a077a0a951a05115c292639 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 23 Feb 2024 16:09:11 +0100 Subject: [PATCH 3/8] Make sure performance is good when a calculated object is added or changed - avoid recreation of summary file readers - delete all nodes in address tree representing calculated curves - build address nodes for calculated curves --- .../RimSummaryCalculation.cpp | 28 ++++++++++++------- .../Summary/RimSummaryAddressCollection.cpp | 28 ++++++++++++++++++- .../Summary/RimSummaryAddressCollection.h | 1 + .../Summary/RimSummaryCase.cpp | 17 +++++++++++ .../ProjectDataModel/Summary/RimSummaryCase.h | 1 + .../Summary/RimSummaryCaseCollection.cpp | 11 ++++++++ .../Summary/RimSummaryCaseCollection.h | 1 + 7 files changed, 76 insertions(+), 11 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp index 111c7b7bad..72a8fb0804 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp @@ -402,33 +402,41 @@ std::optional, std::vector>> //-------------------------------------------------------------------------------------------------- void RimSummaryCalculation::updateDependentObjects() { - RimSummaryCalculationCollection* calcColl = firstAncestorOrThisOfTypeAsserted(); + auto calcColl = firstAncestorOrThisOfTypeAsserted(); calcColl->rebuildCaseMetaData(); - // Refresh data sources tree. - // TODO: refresh too much: would be enough to only refresh calculated resutls. + // 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 ) { - summaryCase->createSummaryReaderInterface(); - summaryCase->createRftReaderInterface(); - summaryCase->refreshMetaData(); + if ( !summaryCase ) continue; + + if ( auto reader = summaryCase->summaryReader() ) + { + reader->rebuildMetaData(); + summaryCase->onCalculationUpdated(); + } } RimObservedDataCollection* observedDataCollection = RiaSummaryTools::observedDataCollection(); auto observedData = observedDataCollection->allObservedSummaryData(); for ( auto obs : observedData ) { - obs->createSummaryReaderInterface(); - obs->createRftReaderInterface(); - obs->refreshMetaData(); + if ( !obs ) continue; + + if ( auto reader = obs->summaryReader() ) + { + reader->rebuildMetaData(); + obs->onCalculationUpdated(); + } } auto summaryCaseCollections = summaryCaseCollection->summaryCaseCollections(); for ( RimSummaryCaseCollection* summaryCaseCollection : summaryCaseCollections ) { - summaryCaseCollection->refreshMetaData(); + summaryCaseCollection->onCalculationUpdated(); } RimSummaryMultiPlotCollection* summaryPlotCollection = RiaSummaryTools::summaryMultiPlotCollection(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp index fceb1e0f5a..c27e0140a6 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp @@ -99,7 +99,7 @@ RimSummaryAddressCollection::~RimSummaryAddressCollection() //-------------------------------------------------------------------------------------------------- bool RimSummaryAddressCollection::hasDataVector( const QString quantityName ) const { - for ( auto& address : m_adresses ) + for ( const auto& address : m_adresses ) { if ( address->quantityName() == quantityName ) return true; } @@ -346,6 +346,32 @@ void RimSummaryAddressCollection::deleteChildren() m_subfolders.deleteChildren(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressCollection::deleteCalculatedObjects() +{ + std::vector toDelete; + for ( const auto& a : m_adresses ) + { + if ( a->address().isCalculated() ) + { + toDelete.push_back( a ); + } + } + + for ( auto a : toDelete ) + { + m_adresses.removeChild( a ); + delete a; + } + + for ( auto& folder : m_subfolders ) + { + folder->deleteCalculatedObjects(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h index b0b2f02a92..9381c94813 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h @@ -66,6 +66,7 @@ class RimSummaryAddressCollection : public RimNamedObject void updateFolderStructure( const std::set& addresses, int caseId, int ensembleId = -1 ); void deleteChildren(); + void deleteCalculatedObjects(); bool isEmpty() const; bool isEnsemble() const; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp index dd301f6d83..7171f50e21 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp @@ -400,3 +400,20 @@ void RimSummaryCase::refreshMetaData() buildChildNodes(); updateConnectedEditors(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCase::onCalculationUpdated() +{ + // Delete all calculated address objects + m_dataVectorFolders->deleteCalculatedObjects(); + + if ( auto reader = summaryReader() ) + { + auto addresses = reader->allResultAddresses(); + m_dataVectorFolders->updateFolderStructure( addresses, m_caseId ); + } + + updateConnectedEditors(); +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h index 1ea198777a..d305e9d73c 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h @@ -66,6 +66,7 @@ class RimSummaryCase : public caf::PdmObject int caseId() const; void refreshMetaData(); + void onCalculationUpdated(); virtual void createSummaryReaderInterface() = 0; virtual void createRftReaderInterface() {} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index cc93a84820..b9a5d3544a 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -1162,6 +1162,17 @@ void RimSummaryCaseCollection::refreshMetaData() updateConnectedEditors(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::onCalculationUpdated() +{ + m_dataVectorFolders->deleteCalculatedObjects(); + m_dataVectorFolders->updateFolderStructure( ensembleSummaryAddresses(), -1, m_ensembleId ); + + updateConnectedEditors(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h index 725f7d376a..5e56a574d6 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h @@ -104,6 +104,7 @@ class RimSummaryCaseCollection : public caf::PdmObject RiaDefines::EclipseUnitSystem unitSystem() const; void refreshMetaData(); + void onCalculationUpdated(); void updateReferringCurveSets(); From f78042144f2c46e6bd182374de5d2cc06cd2ddfe Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 23 Feb 2024 17:07:41 +0100 Subject: [PATCH 4/8] Move meta data updates to summarycalculationcollection --- .../RimSummaryCalculation.cpp | 49 +------------------ .../RimSummaryCalculationCollection.cpp | 49 +++++++++++++++++++ .../RimSummaryCalculationCollection.h | 1 + .../RimUserDefinedCalculationCollection.cpp | 4 +- .../RimCalculatedSummaryCurveReader.cpp | 4 +- 5 files changed, 57 insertions(+), 50 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp index 72a8fb0804..c83a240de3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculation.cpp @@ -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" @@ -402,43 +393,6 @@ std::optional, std::vector>> //-------------------------------------------------------------------------------------------------- void RimSummaryCalculation::updateDependentObjects() { - auto calcColl = firstAncestorOrThisOfTypeAsserted(); - 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() ) { @@ -446,7 +400,7 @@ void RimSummaryCalculation::updateDependentObjects() { bool plotContainsCalculatedCurves = false; - for ( RimSummaryCurve* sumCurve : sumPlot->summaryCurves() ) + for ( RimSummaryCurve* sumCurve : sumPlot->summaryAndEnsembleCurves() ) { if ( sumCurve->summaryAddressY().isCalculated() ) { @@ -469,6 +423,7 @@ void RimSummaryCalculation::updateDependentObjects() //-------------------------------------------------------------------------------------------------- void RimSummaryCalculation::removeDependentObjects() { + updateDependentObjects(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp index e8e8cf5eda..3d8be32f7c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp @@ -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" ); //-------------------------------------------------------------------------------------------------- @@ -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(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.h b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.h index 8d7f21d06c..e4953189ba 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.h +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.h @@ -42,5 +42,6 @@ class RimSummaryCalculationCollection : public RimUserDefinedCalculationCollecti RimSummaryCalculation* createCalculation() const override; private: + void updateDataDependingOnCalculations(); void initAfterRead() override; }; diff --git a/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationCollection.cpp index b30dcf0ec4..b8572c84b1 100644 --- a/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimUserDefinedCalculationCollection.cpp @@ -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; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp index d1902a9553..e0da1ecc65 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp @@ -87,11 +87,11 @@ void RifCalculatedSummaryCurveReader::rebuildMetaData() for ( RimUserDefinedCalculation* calc : m_calculationCollection->calculations() ) { - RimSummaryCalculation* sumCalc = dynamic_cast( calc ); + auto* sumCalc = dynamic_cast( calc ); CAF_ASSERT( sumCalc ); const auto& allAddresses = sumCalc->allAddressesForSummaryCase( m_summaryCase ); - for ( auto calculationAddress : allAddresses ) + for ( const auto& calculationAddress : allAddresses ) { if ( calculationAddress.address().isValid() ) { From 86ddf4b4d08a396fb95e33d4a351947cccd930c7 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 25 Feb 2024 09:02:21 +0100 Subject: [PATCH 5/8] Rename --- .../FileInterface/RifMultipleSummaryReaders.cpp | 8 ++++---- .../FileInterface/RifMultipleSummaryReaders.h | 2 +- .../FileInterface/RifReaderEclipseSummary.h | 3 +-- .../FileInterface/RifSummaryReaderInterface.cpp | 2 +- .../FileInterface/RifSummaryReaderInterface.h | 2 +- .../RimSummaryCalculationCollection.cpp | 4 ++-- .../Summary/RimCalculatedSummaryCurveReader.cpp | 2 +- .../Summary/RimCalculatedSummaryCurveReader.h | 2 +- .../Summary/RimSummaryCaseCollection.cpp | 13 +++---------- .../Summary/RimSummaryCaseCollection.h | 7 ++----- 10 files changed, 17 insertions(+), 28 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.cpp b/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.cpp index b05bc0f927..98df37a642 100644 --- a/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.cpp +++ b/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.cpp @@ -36,7 +36,7 @@ void RifMultipleSummaryReaders::addReader( RifSummaryReaderInterface* reader ) m_readers.push_back( reader ); - rebuildMetaData(); + buildMetaData(); } //-------------------------------------------------------------------------------------------------- @@ -45,7 +45,7 @@ void RifMultipleSummaryReaders::addReader( RifSummaryReaderInterface* reader ) void RifMultipleSummaryReaders::removeReader( RifSummaryReaderInterface* reader ) { m_readers.erase( reader ); - rebuildMetaData(); + buildMetaData(); } //-------------------------------------------------------------------------------------------------- @@ -100,7 +100,7 @@ RiaDefines::EclipseUnitSystem RifMultipleSummaryReaders::unitSystem() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifMultipleSummaryReaders::rebuildMetaData() +void RifMultipleSummaryReaders::buildMetaData() { m_allErrorAddresses.clear(); m_allResultAddresses.clear(); @@ -109,7 +109,7 @@ void RifMultipleSummaryReaders::rebuildMetaData() { // TODO: hack. Find a better way to rebuild calculated summary meta data. auto calcReader = dynamic_cast( reader.p() ); - if ( calcReader ) calcReader->rebuildMetaData(); + if ( calcReader ) calcReader->buildMetaData(); { auto resultAddresses = reader->allResultAddresses(); diff --git a/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.h b/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.h index 41b82dc426..996fa4e66a 100644 --- a/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.h +++ b/ApplicationLibCode/FileInterface/RifMultipleSummaryReaders.h @@ -40,7 +40,7 @@ class RifMultipleSummaryReaders : public RifSummaryReaderInterface std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override; RiaDefines::EclipseUnitSystem unitSystem() const override; - void rebuildMetaData() override; + void buildMetaData() override; private: cvf::Collection m_readers; diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.h b/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.h index 7028e384d3..769aaf1251 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.h +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.h @@ -54,10 +54,9 @@ class RifReaderEclipseSummary : public RifSummaryReaderInterface std::pair> values( const RifEclipseSummaryAddress& resultAddress ) const override; std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override; RiaDefines::EclipseUnitSystem unitSystem() const override; + void buildMetaData() override; private: - void buildMetaData(); - RifSummaryReaderInterface* currentSummaryReader() const; private: diff --git a/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.cpp b/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.cpp index 1cbf835f22..01ee289adb 100644 --- a/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.cpp +++ b/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.cpp @@ -52,7 +52,7 @@ RifEclipseSummaryAddress RifSummaryReaderInterface::errorAddress( const RifEclip //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifSummaryReaderInterface::rebuildMetaData() +void RifSummaryReaderInterface::buildMetaData() { } diff --git a/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.h b/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.h index 970ead77e3..efdd2973c6 100644 --- a/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.h +++ b/ApplicationLibCode/FileInterface/RifSummaryReaderInterface.h @@ -51,7 +51,7 @@ class RifSummaryReaderInterface : public cvf::Object virtual std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const = 0; virtual RiaDefines::EclipseUnitSystem unitSystem() const = 0; - virtual void rebuildMetaData(); + virtual void buildMetaData(); protected: std::set m_allResultAddresses; // Result and error addresses diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp index 3d8be32f7c..f2de3ba444 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp @@ -60,7 +60,7 @@ void RimSummaryCalculationCollection::updateDataDependingOnCalculations() if ( auto reader = summaryCase->summaryReader() ) { - reader->rebuildMetaData(); + reader->buildMetaData(); summaryCase->onCalculationUpdated(); } } @@ -73,7 +73,7 @@ void RimSummaryCalculationCollection::updateDataDependingOnCalculations() if ( auto reader = obs->summaryReader() ) { - reader->rebuildMetaData(); + reader->buildMetaData(); obs->onCalculationUpdated(); } } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp index e0da1ecc65..22f0a32fca 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.cpp @@ -81,7 +81,7 @@ std::string RifCalculatedSummaryCurveReader::unitName( const RifEclipseSummaryAd //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifCalculatedSummaryCurveReader::rebuildMetaData() +void RifCalculatedSummaryCurveReader::buildMetaData() { m_allResultAddresses.clear(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.h b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.h index 8846c34f22..5eb786d75a 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimCalculatedSummaryCurveReader.h @@ -39,7 +39,7 @@ class RifCalculatedSummaryCurveReader : public RifSummaryReaderInterface std::pair> values( const RifEclipseSummaryAddress& resultAddress ) const override; std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override; - void rebuildMetaData() override; + void buildMetaData() override; RiaDefines::EclipseUnitSystem unitSystem() const override; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index b9a5d3544a..6e5fc541e7 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -22,30 +22,23 @@ #include "RiaFieldHandleTools.h" #include "RiaLogging.h" #include "RiaStatisticsTools.h" -#include "RiaStdStringTools.h" #include "RiaSummaryAddressAnalyzer.h" -#include "RiaWeightedMeanCalculator.h" - -#include "RicfCommandObject.h" #include "RifReaderRftInterface.h" #include "RifSummaryReaderInterface.h" -#include "RimAnalysisPlotDataEntry.h" #include "RimDerivedEnsembleCaseCollection.h" #include "RimEnsembleCurveSet.h" #include "RimProject.h" #include "RimSummaryAddressCollection.h" -#include "RimSummaryCalculationCollection.h" #include "RimSummaryCase.h" #include "cafPdmFieldScriptingCapability.h" +#include "cafPdmObjectScriptingCapability.h" #include "cafPdmUiTreeOrdering.h" -#include #include -#include #include CAF_PDM_SOURCE_INIT( RimSummaryCaseCollection, "SummaryCaseSubCollection" ); @@ -284,7 +277,7 @@ void RimSummaryCaseCollection::setAsEnsemble( bool isEnsemble ) calculateEnsembleParametersIntersectionHash(); } - refreshMetaData(); + buildMetaData(); } } @@ -1155,7 +1148,7 @@ void RimSummaryCaseCollection::buildChildNodes() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseCollection::refreshMetaData() +void RimSummaryCaseCollection::buildMetaData() { clearChildNodes(); buildChildNodes(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h index 5e56a574d6..b2798c954e 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h @@ -19,20 +19,17 @@ #pragma once #include "RiaDefines.h" + #include "RifEclipseSummaryAddress.h" #include "RigEnsembleParameter.h" -#include "RimObjectiveFunction.h" - #include "cafPdmChildArrayField.h" #include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmProxyValueField.h" -#include "cvfObject.h" - #include #include @@ -103,7 +100,6 @@ class RimSummaryCaseCollection : public caf::PdmObject RiaDefines::EclipseUnitSystem unitSystem() const; - void refreshMetaData(); void onCalculationUpdated(); void updateReferringCurveSets(); @@ -128,6 +124,7 @@ class RimSummaryCaseCollection : public caf::PdmObject void onCaseNameChanged( const SignalEmitter* emitter ); + void buildMetaData(); void buildChildNodes(); void clearChildNodes(); From fd617f665986a80c760fdcbc80ec8e308344b434 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 26 Feb 2024 08:29:22 +0100 Subject: [PATCH 6/8] Add missing overrides --- ApplicationLibCode/FileInterface/RifEclEclipseSummary.h | 2 +- ApplicationLibCode/FileInterface/RifOpmCommonSummary.h | 2 +- ApplicationLibCode/FileInterface/RifOpmHdf5Summary.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifEclEclipseSummary.h b/ApplicationLibCode/FileInterface/RifEclEclipseSummary.h index d6d51ac789..da75646132 100644 --- a/ApplicationLibCode/FileInterface/RifEclEclipseSummary.h +++ b/ApplicationLibCode/FileInterface/RifEclEclipseSummary.h @@ -56,7 +56,7 @@ class RifEclEclipseSummary : public RifSummaryReaderInterface private: int indexFromAddress( const RifEclipseSummaryAddress& resultAddress ) const; - void buildMetaData(); + void buildMetaData() override; private: ecl_sum_type* m_ecl_sum; diff --git a/ApplicationLibCode/FileInterface/RifOpmCommonSummary.h b/ApplicationLibCode/FileInterface/RifOpmCommonSummary.h index 8dc0de8232..570e7e9d73 100644 --- a/ApplicationLibCode/FileInterface/RifOpmCommonSummary.h +++ b/ApplicationLibCode/FileInterface/RifOpmCommonSummary.h @@ -78,7 +78,7 @@ class RifOpmCommonEclipseSummary : public RifSummaryReaderInterface RiaDefines::EclipseUnitSystem unitSystem() const override; private: - void buildMetaData(); + void buildMetaData() override; bool openFileReader( const QString& fileName, bool includeRestartFiles, RiaThreadSafeLogger* threadSafeLogger ); static void increaseEsmryFileCount(); diff --git a/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.h b/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.h index 8c08ba11bf..dc2727171f 100644 --- a/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.h +++ b/ApplicationLibCode/FileInterface/RifOpmHdf5Summary.h @@ -62,7 +62,7 @@ class RifOpmHdf5Summary : public RifSummaryReaderInterface RiaDefines::EclipseUnitSystem unitSystem() const override; private: - void buildMetaData(); + void buildMetaData() override; bool openESmryFile( const QString& headerFileName, bool includeRestartFiles, RiaThreadSafeLogger* threadSafeLogger ); private: From 6c3d168efa79ddc7255c1be5beaa10c88185fd48 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 26 Feb 2024 13:27:12 +0100 Subject: [PATCH 7/8] Make sure rebuildCaseMetaData is always called --- .../Commands/RicUserDefinedCalculatorUi.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/ApplicationLibCode/Commands/RicUserDefinedCalculatorUi.cpp b/ApplicationLibCode/Commands/RicUserDefinedCalculatorUi.cpp index 7c555cf1f6..af596fcd5c 100644 --- a/ApplicationLibCode/Commands/RicUserDefinedCalculatorUi.cpp +++ b/ApplicationLibCode/Commands/RicUserDefinedCalculatorUi.cpp @@ -90,6 +90,10 @@ bool RicUserDefinedCalculatorUi::parseExpression() const { notifyCalculatedNameChanged( m_currentCalculation()->id(), currentCurveName ); } + + // Always rebuild the case meta data after parsing the expression. A change in name or change in result type will require rebuild of + // case metadata. The rebuild is considered lightweight and should not be a performance issue. + calculationCollection()->rebuildCaseMetaData(); } return true; @@ -218,17 +222,7 @@ bool RicUserDefinedCalculatorUi::calculate() const { if ( m_currentCalculation() ) { - QString previousCurveName = m_currentCalculation->description(); - if ( !m_currentCalculation()->parseExpression() ) - { - return false; - } - - QString currentCurveName = m_currentCalculation->description(); - if ( previousCurveName != currentCurveName ) - { - notifyCalculatedNameChanged( m_currentCalculation()->id(), currentCurveName ); - } + if ( !parseExpression() ) return false; if ( !m_currentCalculation()->preCalculate() ) { From 5165bc584ebaea14f205a2984629eff60246fd40 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 26 Feb 2024 13:53:39 +0100 Subject: [PATCH 8/8] Bump to dev.22 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index bf3399a258..bd82396262 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".21") +set(RESINSIGHT_DEV_VERSION ".22") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f")