diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.cpp index e2aa633582..ff458695d7 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.cpp @@ -35,6 +35,7 @@ #include "RimSummaryPlot.h" #include "cafAssert.h" +#include "cafProgressInfo.h" #include "cafSelectionManager.h" #include @@ -63,6 +64,8 @@ void RicAppendSummaryPlotsForObjectsFeature::appendPlots( RimSummaryMultiPlot* s auto sourcePlots = summaryMultiPlot->summaryPlots(); auto plotsForOneInstance = plotsForOneInstanceOfObjectType( sourcePlots, selectionType ); + caf::ProgressInfo info( sumAddressCollections.size(), "Appending plots..." ); + for ( auto summaryAdrCollection : sumAddressCollections ) { auto duplicatedPlots = RicSummaryPlotBuilder::duplicateSummaryPlots( plotsForOneInstance ); @@ -94,6 +97,7 @@ void RicAppendSummaryPlotsForObjectsFeature::appendPlots( RimSummaryMultiPlot* s duplicatedPlot->resolveReferencesRecursively(); } } + info.incrementProgress(); } summaryMultiPlot->loadDataAndUpdate(); diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryAddressesFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryAddressesFeature.cpp index 76f5cce569..7d0b94eb34 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryAddressesFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicAppendSummaryPlotsForSummaryAddressesFeature.cpp @@ -28,6 +28,7 @@ #include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" +#include "cafProgressInfo.h" #include "cafSelectionManager.h" #include @@ -43,6 +44,8 @@ void RicAppendSummaryPlotsForSummaryAddressesFeature::appendPlotsForAddresses( R if ( !summaryMultiPlot ) return; if ( addresses.empty() ) return; + caf::ProgressInfo info( addresses.size(), "Appending plots..." ); + for ( auto adr : addresses ) { auto* plot = new RimSummaryPlot(); @@ -50,6 +53,8 @@ void RicAppendSummaryPlotsForSummaryAddressesFeature::appendPlotsForAddresses( R plot->handleDroppedObjects( { adr } ); summaryMultiPlot->addPlot( plot ); + + info.incrementProgress(); } } diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.cpp index 9c6e6c465f..113655244a 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.cpp @@ -478,11 +478,11 @@ RimSummaryMultiPlot* RicSummaryPlotBuilder::createAndAppendSummaryMultiPlot( con appendPlotsToSummaryMultiPlot( summaryMultiPlot, plots ); summaryMultiPlot->setDefaultRangeAggregationSteppingDimension(); - summaryMultiPlot->zoomAll(); plotCollection->updateAllRequiredEditors(); summaryMultiPlot->loadDataAndUpdate(); summaryMultiPlot->updateAllRequiredEditors(); + summaryMultiPlot->zoomAll(); if ( !plots.empty() ) { @@ -527,6 +527,7 @@ RimSummaryMultiPlot* RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlo void RicSummaryPlotBuilder::appendPlotsToSummaryMultiPlot( RimSummaryMultiPlot* multiPlot, const std::vector& plots ) { + multiPlot->startBatchAddOperation(); for ( auto plot : plots ) { plot->revokeMdiWindowStatus(); @@ -535,9 +536,8 @@ void RicSummaryPlotBuilder::appendPlotsToSummaryMultiPlot( RimSummaryMultiPlot* plot->resolveReferencesRecursively(); plot->setShowWindow( true ); - - plot->loadDataAndUpdate(); } + multiPlot->endBatchAddOperation(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp index 4e28c76f25..48c47c656f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp @@ -46,6 +46,7 @@ CAF_PDM_SOURCE_INIT( RimMultiPlot, "MultiPlot" ); //-------------------------------------------------------------------------------------------------- RimMultiPlot::RimMultiPlot() : m_isValid( true ) + , m_delayPlotUpdatesDuringBatchAdd( false ) { CAF_PDM_InitObject( "Multi Plot", ":/MultiPlot16x16.png" ); @@ -197,9 +198,12 @@ void RimMultiPlot::insertPlot( RimPlot* plot, size_t index ) plot->createPlotWidget( m_viewer ); m_viewer->insertPlot( plot->plotWidget(), index ); } - plot->updateAfterInsertingIntoMultiPlot(); - onPlotAdditionOrRemoval(); + if ( !m_delayPlotUpdatesDuringBatchAdd ) + { + plot->updateAfterInsertingIntoMultiPlot(); + onPlotAdditionOrRemoval(); + } } } @@ -916,3 +920,20 @@ bool RimMultiPlot::isValid() const { return m_isValid; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMultiPlot::startBatchAddOperation() +{ + m_delayPlotUpdatesDuringBatchAdd = true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMultiPlot::endBatchAddOperation() +{ + m_delayPlotUpdatesDuringBatchAdd = false; + onPlotAdditionOrRemoval(); +} diff --git a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.h b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.h index 2aa63fd90a..7de61dcb86 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.h +++ b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.h @@ -69,6 +69,9 @@ public: void removePlot( RimPlot* plot ) override; void movePlotsToThis( const std::vector& plots, int insertAtPosition ); + virtual void startBatchAddOperation(); + virtual void endBatchAddOperation(); + virtual void removePlotNoUpdate( RimPlot* plot ); virtual void updateAfterPlotRemove(); @@ -169,6 +172,8 @@ protected: friend class RiuMultiPlotBook; QPointer m_viewer; + bool m_delayPlotUpdatesDuringBatchAdd; + private: caf::PdmChildArrayField m_plots; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.cpp index d5bf73b064..3b263fe4e5 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.cpp @@ -382,6 +382,8 @@ void RimSummaryPlotManager::replaceCurves() //-------------------------------------------------------------------------------------------------- void RimSummaryPlotManager::createNewPlot() { + if ( m_filterText().trimmed().isEmpty() ) return; + std::vector summaryCases; std::vector ensembles; findFilteredSummaryCasesAndEnsembles( summaryCases, ensembles ); @@ -400,24 +402,8 @@ void RimSummaryPlotManager::createNewPlot() auto plots = plotBuilder.createPlots(); if ( m_createMultiPlot ) { - { - auto summaryPlots = plotBuilder.createPlots(); - RicSummaryPlotBuilder::createAndAppendSummaryMultiPlot( summaryPlots ); - } - - bool createStandardMultiPlot = false; - if ( createStandardMultiPlot ) - { - // Code to generate a standard multi plot - std::vector plotsForMultiPlot; - for ( auto p : plots ) - { - p->loadDataAndUpdate(); - plotsForMultiPlot.push_back( dynamic_cast( p ) ); - } - - RicSummaryPlotBuilder::createAndAppendMultiPlot( plotsForMultiPlot ); - } + auto summaryPlots = plotBuilder.createPlots(); + RicSummaryPlotBuilder::createAndAppendSummaryMultiPlot( summaryPlots ); } else {