diff --git a/ApplicationLibCode/Application/Tools/Summary/RiaSummaryTools.cpp b/ApplicationLibCode/Application/Tools/Summary/RiaSummaryTools.cpp index 060dbaed65..80bbfb11b4 100644 --- a/ApplicationLibCode/Application/Tools/Summary/RiaSummaryTools.cpp +++ b/ApplicationLibCode/Application/Tools/Summary/RiaSummaryTools.cpp @@ -399,7 +399,7 @@ bool RiaSummaryTools::isCalculationRequired( const RimUserDefinedCalculation* su //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaSummaryTools::reloadSummaryCaseAndUpdateConnectedPlots( RimSummaryCase* summaryCase, bool createAddressObjects ) +void RiaSummaryTools::reloadSummaryCaseAndUpdateConnectedPlots( RimSummaryCase* summaryCase ) { if ( !summaryCase ) return; @@ -408,7 +408,8 @@ void RiaSummaryTools::reloadSummaryCaseAndUpdateConnectedPlots( RimSummaryCase* // Recreate the reader interface, but do not create address objects yet. For ensembles, we do not want to create addresses for all cases summaryCase->createSummaryReaderInterface(); - if ( createAddressObjects ) + // Create addresses for cases marked to show tree nodes. Avoid other cases (ensembles) to speed up the process. + if ( summaryCase->showTreeNodes() ) { if ( auto reader = summaryCase->summaryReader() ) { @@ -416,22 +417,16 @@ void RiaSummaryTools::reloadSummaryCaseAndUpdateConnectedPlots( RimSummaryCase* } } summaryCase->createRftReaderInterface(); - summaryCase->refreshMetaData(); + summaryCase->buildTreeNodesIfRequired(); RiaSummaryTools::updateRequiredCalculatedCurves( summaryCase ); RimSummaryMultiPlotCollection* summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection(); for ( RimSummaryMultiPlot* multiPlot : summaryPlotColl->multiPlots() ) { - for ( RimSummaryPlot* summaryPlot : multiPlot->summaryPlots() ) - { - summaryPlot->loadDataAndUpdate(); - - // Consider to make the zoom optional - summaryPlot->zoomAll(); - } - + multiPlot->loadDataAndUpdateAllPlots(); multiPlot->updatePlotTitles(); + multiPlot->zoomAll(); } auto depthTrackPlots = caf::PdmObjectHandleTools::referringAncestorOfType( { summaryCase } ); diff --git a/ApplicationLibCode/Application/Tools/Summary/RiaSummaryTools.h b/ApplicationLibCode/Application/Tools/Summary/RiaSummaryTools.h index 0fe3a174e9..6c18b0d495 100644 --- a/ApplicationLibCode/Application/Tools/Summary/RiaSummaryTools.h +++ b/ApplicationLibCode/Application/Tools/Summary/RiaSummaryTools.h @@ -94,7 +94,7 @@ public: static void copyCurveDataSources( RimSummaryCurve& curve, const RimSummaryCurve& otherCurve ); static void copyCurveAxisData( RimSummaryCurve& curve, const RimSummaryCurve& otherCurve ); - static void reloadSummaryCaseAndUpdateConnectedPlots( RimSummaryCase* summaryCase, bool createAddressObjects = true ); + static void reloadSummaryCaseAndUpdateConnectedPlots( RimSummaryCase* summaryCase ); static void updateConnectedPlots( RimSummaryEnsemble* ensemble ); static time_t calculateTimeThreshold( const time_t& minimum, const time_t& maximum ); diff --git a/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp b/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp index baf3e74c6d..ee7bb4e2e5 100644 --- a/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp +++ b/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp @@ -40,11 +40,8 @@ CAF_CMD_SOURCE_INIT( RicReloadSummaryCaseFeature, "RicReloadSummaryCaseFeature" //-------------------------------------------------------------------------------------------------- bool RicReloadSummaryCaseFeature::isCommandEnabled() const { - auto ensembles = caf::SelectionManager::instance()->objectsByType(); - if ( !ensembles.empty() ) return true; - - std::vector caseSelection = selectedSummaryCases(); - return !caseSelection.empty(); + const auto& [caseSelection, ensembleSelection] = selectedSummarySources(); + return !caseSelection.empty() || !ensembleSelection.empty(); } //-------------------------------------------------------------------------------------------------- @@ -68,25 +65,42 @@ void RicReloadSummaryCaseFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RicReloadSummaryCaseFeature::selectedSummaryCases() +std::pair, std::vector> RicReloadSummaryCaseFeature::selectedSummarySources() { - const auto mainCollectionSelection = caf::SelectionManager::instance()->objectsByType(); - if ( !mainCollectionSelection.empty() ) + std::vector caseSelection; + std::vector ensembleSelection; + + auto ensembles = caf::SelectionManager::instance()->objectsByType(); + for ( RimSummaryEnsemble* ensemble : ensembles ) { - return mainCollectionSelection[0]->allSummaryCases(); + ensembleSelection.push_back( ensemble ); } - std::vector caseSelection = caf::SelectionManager::instance()->objectsByType(); - + std::vector selectionManagerCases = caf::SelectionManager::instance()->objectsByType(); + for ( RimSummaryCase* summaryCase : selectionManagerCases ) { - for ( auto collection : caf::SelectionManager::instance()->objectsByType() ) + caseSelection.push_back( summaryCase ); + } + + for ( auto collection : caf::SelectionManager::instance()->objectsByType() ) + { + std::vector observedCases = collection->allObservedSummaryData(); + caseSelection.insert( caseSelection.end(), observedCases.begin(), observedCases.end() ); + } + + if ( ensembleSelection.empty() && caseSelection.empty() ) + { + // Fallback to all top-level cases and ensembles + if ( auto sumCaseColl = RiaSummaryTools::summaryCaseMainCollection() ) { - std::vector observedCases = collection->allObservedSummaryData(); - caseSelection.insert( caseSelection.end(), observedCases.begin(), observedCases.end() ); + ensembleSelection = sumCaseColl->summaryEnsembles(); + + // Make sure to select top-level cases only, not cases part of ensembles + caseSelection = sumCaseColl->topLevelSummaryCases(); } } - return caseSelection; + return { caseSelection, ensembleSelection }; } //-------------------------------------------------------------------------------------------------- @@ -97,12 +111,20 @@ void RicReloadSummaryCaseFeature::reloadTaggedSummaryCasesAndUpdate() auto proj = RimProject::current(); for ( auto summaryCase : proj->allSummaryCases() ) { - if ( summaryCase->includeInAutoReload() ) RiaSummaryTools::reloadSummaryCaseAndUpdateConnectedPlots( summaryCase ); + if ( summaryCase->includeInAutoReload() ) + { + RiaSummaryTools::reloadSummaryCaseAndUpdateConnectedPlots( summaryCase ); + summaryCase->updateConnectedEditors(); + } } for ( RimSummaryEnsemble* ensemble : proj->summaryEnsembles() ) { - if ( ensemble->includeInAutoReload() ) ensemble->reloadCases(); + if ( ensemble->includeInAutoReload() ) + { + ensemble->reloadCases(); + ensemble->updateConnectedEditors(); + } } } @@ -111,22 +133,18 @@ void RicReloadSummaryCaseFeature::reloadTaggedSummaryCasesAndUpdate() //-------------------------------------------------------------------------------------------------- void RicReloadSummaryCaseFeature::reloadSelectedCasesAndUpdate() { - auto ensembles = caf::SelectionManager::instance()->objectsByType(); - if ( !ensembles.empty() ) - { - for ( RimSummaryEnsemble* ensemble : ensembles ) - { - ensemble->reloadCases(); - } + const auto& [caseSelection, ensembleSelection] = selectedSummarySources(); - return; + for ( RimSummaryEnsemble* ensemble : ensembleSelection ) + { + ensemble->reloadCases(); } - std::vector caseSelection = selectedSummaryCases(); for ( RimSummaryCase* summaryCase : caseSelection ) { RiaSummaryTools::reloadSummaryCaseAndUpdateConnectedPlots( summaryCase ); + summaryCase->updateConnectedEditors(); RiaLogging::info( QString( "Reloaded data for %1" ).arg( summaryCase->summaryHeaderFilename() ) ); } -} \ No newline at end of file +} diff --git a/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.h b/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.h index 61e6c76b16..d309545ec7 100644 --- a/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.h +++ b/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.h @@ -23,6 +23,7 @@ #include class RimSummaryCase; +class RimSummaryEnsemble; class RicReloadSummaryCaseFeature : public caf::CmdFeature { @@ -38,5 +39,5 @@ protected: void setupActionLook( QAction* actionToSetup ) override; private: - static std::vector selectedSummaryCases(); + static std::pair, std::vector> selectedSummarySources(); }; diff --git a/ApplicationLibCode/Commands/RicShowDataSourcesForRealization.cpp b/ApplicationLibCode/Commands/RicShowDataSourcesForRealization.cpp index d95c932e4c..9d38504b04 100644 --- a/ApplicationLibCode/Commands/RicShowDataSourcesForRealization.cpp +++ b/ApplicationLibCode/Commands/RicShowDataSourcesForRealization.cpp @@ -44,7 +44,7 @@ bool RicShowDataSourcesForRealization::isCommandChecked() const const auto selection = caf::SelectionManager::instance()->objectsByType(); if ( !selection.empty() ) { - return selection.front()->showVectorItemsInProjectTree(); + return selection.front()->showTreeNodes(); } return false; @@ -75,10 +75,10 @@ void RicShowDataSourcesForRealization::onActionTriggered( bool isChecked ) const auto selection = caf::SelectionManager::instance()->objectsByType(); if ( selection.empty() ) return; - bool enableDataSources = !selection.front()->showVectorItemsInProjectTree(); + bool enableDataSources = !selection.front()->showTreeNodes(); for ( auto summaryCase : selection ) { - summaryCase->setShowVectorItemsInProjectTree( enableDataSources ); + summaryCase->setShowTreeNodes( enableDataSources ); } } diff --git a/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.cpp b/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.cpp index 26b151939d..a21fdf47c3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.cpp @@ -99,6 +99,7 @@ void RimReloadCaseTools::reloadEclipseData( RimEclipseCase* eclipseCase, bool re { auto summaryCase = RimReloadCaseTools::findSummaryCaseFromEclipseResultCase( dynamic_cast( eclipseCase ) ); RiaSummaryTools::reloadSummaryCaseAndUpdateConnectedPlots( summaryCase ); + summaryCase->updateConnectedEditors(); } updateAllPlots(); diff --git a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp index 62e1f92a81..b6e5a3ee26 100644 --- a/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimSummaryCalculationCollection.cpp @@ -61,7 +61,7 @@ void RimSummaryCalculationCollection::updateDataDependingOnCalculations() { if ( !summaryCase ) continue; - if ( summaryCase->showVectorItemsInProjectTree() ) + if ( summaryCase->showTreeNodes() ) { if ( auto reader = summaryCase->summaryReader() ) { diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Ensemble/RimSummaryFileSetEnsemble.cpp b/ApplicationLibCode/ProjectDataModel/Summary/Ensemble/RimSummaryFileSetEnsemble.cpp index 23e93949e9..dd235e1f1b 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/Ensemble/RimSummaryFileSetEnsemble.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/Ensemble/RimSummaryFileSetEnsemble.cpp @@ -174,7 +174,7 @@ void RimSummaryFileSetEnsemble::createSummaryCasesFromEnsembleFileSet( bool noti // Update name of cases and ensemble after all cases are added for ( auto summaryCase : newCases ) { - summaryCase->setShowVectorItemsInProjectTree( false ); + summaryCase->setShowTreeNodes( false ); summaryCase->setDisplayNameOption( RimCaseDisplayNameTools::DisplayName::SHORT_CASE_NAME ); summaryCase->updateAutoShortName(); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimDeltaSummaryEnsemble.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimDeltaSummaryEnsemble.cpp index 596c037b7a..fa761189c4 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimDeltaSummaryEnsemble.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimDeltaSummaryEnsemble.cpp @@ -482,7 +482,7 @@ RimDeltaSummaryCase* RimDeltaSummaryEnsemble::firstCaseNotInUse() auto newCase = new RimDeltaSummaryCase(); // Show realization data source for the first case. If we create for all, the performance will be bad - newCase->setShowVectorItemsInProjectTree( m_cases.empty() ); + newCase->setShowTreeNodes( m_cases.empty() ); m_cases.push_back( newCase ); return newCase; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 12951a6094..1664e1fee9 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -2165,7 +2165,6 @@ void RimEnsembleCurveSet::updateEnsembleCurves( const std::vectordeleteChildren(); - - RifSummaryReaderInterface* reader = summaryReader(); - if ( !reader ) return; - - auto addresses = reader->allResultAddresses(); - m_dataVectorFolders->updateFolderStructure( addresses, m_caseId ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -337,9 +323,12 @@ void RimSummaryCase::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& //-------------------------------------------------------------------------------------------------- void RimSummaryCase::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ ) { - if ( !ensemble() || m_showSubNodesInTree() ) + if ( showTreeNodes() ) { - if ( m_dataVectorFolders->isEmpty() ) buildChildNodes(); + if ( m_dataVectorFolders->isEmpty() ) + { + buildTreeNodesIfRequired(); + } m_dataVectorFolders->updateUiTreeOrdering( uiTreeOrdering ); } @@ -476,10 +465,17 @@ void RimSummaryCase::setCustomCaseName( const QString& caseName ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCase::refreshMetaData() +void RimSummaryCase::buildTreeNodesIfRequired() { - buildChildNodes(); - updateConnectedEditors(); + m_dataVectorFolders->deleteChildren(); + + if ( !showTreeNodes() ) return; + + RifSummaryReaderInterface* reader = summaryReader(); + if ( !reader ) return; + + auto addresses = reader->allResultAddresses(); + m_dataVectorFolders->updateFolderStructure( addresses, m_caseId ); } //-------------------------------------------------------------------------------------------------- @@ -494,7 +490,8 @@ void RimSummaryCase::onCalculationUpdated() { // Build the child nodes if they are not already built. This function will also create the // calculated objects so we can do a early return. - refreshMetaData(); + buildTreeNodesIfRequired(); + updateConnectedEditors(); return; } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h index dc579500c5..b2c635168d 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h @@ -66,7 +66,7 @@ public: void setCaseId( int caseId ); int caseId() const; - void refreshMetaData(); + void buildTreeNodesIfRequired(); void onCalculationUpdated(); virtual void createSummaryReaderInterface() = 0; @@ -81,8 +81,8 @@ public: bool isObservedData() const; - bool showVectorItemsInProjectTree() const; - void setShowVectorItemsInProjectTree( bool enable ); + bool showTreeNodes() const; + void setShowTreeNodes( bool enable ); void setCaseRealizationParameters( const std::shared_ptr& crlParameters ); std::shared_ptr caseRealizationParameters() const; @@ -109,8 +109,7 @@ protected: void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder, bool showCurveCalculator ) const; private: - void buildChildNodes(); - int serialNumber(); + int serialNumber(); protected: caf::PdmField m_displayName; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsemble.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsemble.cpp index 783e5d8a1c..49ef8b004a 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsemble.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryEnsemble.cpp @@ -153,7 +153,7 @@ void RimSummaryEnsemble::addCase( RimSummaryCase* summaryCase, bool notifyChange { summaryCase->nameChanged.connect( this, &RimSummaryEnsemble::onCaseNameChanged ); - summaryCase->setShowVectorItemsInProjectTree( m_cases.empty() ); + summaryCase->setShowTreeNodes( m_cases.empty() ); m_cases.push_back( summaryCase ); m_cachedSortedEnsembleParameters.clear(); @@ -217,7 +217,7 @@ void RimSummaryEnsemble::replaceCases( const std::vector& summa summaryCase->nameChanged.connect( this, &RimSummaryEnsemble::onCaseNameChanged ); if ( m_cases.empty() ) { - summaryCase->setShowVectorItemsInProjectTree( true ); + summaryCase->setShowTreeNodes( true ); } m_cases.push_back( summaryCase ); } @@ -236,8 +236,7 @@ void RimSummaryEnsemble::reloadCases() { for ( auto summaryCase : allSummaryCases() ) { - bool buildAddressObjects = false; - RiaSummaryTools::reloadSummaryCaseAndUpdateConnectedPlots( summaryCase, buildAddressObjects ); + RiaSummaryTools::reloadSummaryCaseAndUpdateConnectedPlots( summaryCase ); RiaLogging::info( QString( "Reloaded data for %1" ).arg( summaryCase->summaryHeaderFilename() ) ); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp index 2bbca492a8..c42126034c 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/Sumo/RimSummaryEnsembleSumo.cpp @@ -551,7 +551,7 @@ void RimSummaryEnsembleSumo::onLoadDataAndUpdate() realization->setRealizationNumber( realId.toInt() ); realization->updateAutoShortName(); - realization->setShowVectorItemsInProjectTree( m_cases.empty() ); + realization->setShowTreeNodes( m_cases.empty() ); m_cases.push_back( realization ); } diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryCase.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryCase.cpp index dab5477fac..801f727f92 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryCase.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryCase.cpp @@ -265,7 +265,8 @@ std::expected RimSummaryCase_setSummaryVectorVal if ( rebuildUserInterface ) { - fileSummaryCase->refreshMetaData(); + fileSummaryCase->buildTreeNodesIfRequired(); + fileSummaryCase->updateConnectedEditors(); } }