Improve performance when creating multiple plots

This commit is contained in:
Magne Sjaastad 2024-10-20 14:24:22 +02:00
parent cf7f00880a
commit 317c737a22
3 changed files with 53 additions and 2 deletions

View File

@ -146,11 +146,33 @@ void RiaPlotWindowRedrawScheduler::performScheduledUpdatesAndReplots()
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaPlotWindowRedrawScheduler::blockScheduledUpdatesAndReplots()
{
m_blockScheduledUpdatesAndReplots = true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaPlotWindowRedrawScheduler::unblockScheduledUpdatesAndReplots()
{
m_blockScheduledUpdatesAndReplots = false;
startTimer( 0 );
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiaPlotWindowRedrawScheduler::slotUpdateAndReplotScheduledItemsWhenReady() void RiaPlotWindowRedrawScheduler::slotUpdateAndReplotScheduledItemsWhenReady()
{ {
if ( m_blockScheduledUpdatesAndReplots )
{
return;
}
if ( caf::ProgressState::isActive() ) if ( caf::ProgressState::isActive() )
{ {
startTimer( 100 ); startTimer( 100 );

View File

@ -48,6 +48,9 @@ public:
void clearAllScheduledUpdates(); void clearAllScheduledUpdates();
void performScheduledUpdatesAndReplots(); void performScheduledUpdatesAndReplots();
void blockScheduledUpdatesAndReplots();
void unblockScheduledUpdatesAndReplots();
private slots: private slots:
void slotUpdateAndReplotScheduledItemsWhenReady(); void slotUpdateAndReplotScheduledItemsWhenReady();
@ -64,4 +67,5 @@ private:
std::set<QPointer<RiuPlotWidget>> m_plotWidgetsToReplot; std::set<QPointer<RiuPlotWidget>> m_plotWidgetsToReplot;
QScopedPointer<QTimer> m_plotWindowUpdateTimer; QScopedPointer<QTimer> m_plotWindowUpdateTimer;
bool m_blockScheduledUpdatesAndReplots = false;
}; };

View File

@ -20,6 +20,7 @@
#include "RiaGuiApplication.h" #include "RiaGuiApplication.h"
#include "RiaLogging.h" #include "RiaLogging.h"
#include "RiaPlotWindowRedrawScheduler.h"
#include "RiaStdStringTools.h" #include "RiaStdStringTools.h"
#include "RiaSummaryAddressAnalyzer.h" #include "RiaSummaryAddressAnalyzer.h"
#include "RiaSummaryTools.h" #include "RiaSummaryTools.h"
@ -68,6 +69,9 @@ void RicAppendSummaryPlotsForObjectsFeature::appendPlots( RimSummaryMultiPlot*
caf::ProgressInfo info( sumAddressCollections.size(), "Appending plots..." ); caf::ProgressInfo info( sumAddressCollections.size(), "Appending plots..." );
summaryMultiPlot->startBatchAddOperation();
RiaPlotWindowRedrawScheduler::instance()->blockScheduledUpdatesAndReplots();
for ( auto summaryAdrCollection : sumAddressCollections ) for ( auto summaryAdrCollection : sumAddressCollections )
{ {
auto duplicatedPlots = RicSummaryPlotBuilder::duplicateSummaryPlots( plotsForOneInstance ); auto duplicatedPlots = RicSummaryPlotBuilder::duplicateSummaryPlots( plotsForOneInstance );
@ -108,11 +112,16 @@ void RicAppendSummaryPlotsForObjectsFeature::appendPlots( RimSummaryMultiPlot*
summaryMultiPlot->addPlot( duplicatedPlot ); summaryMultiPlot->addPlot( duplicatedPlot );
duplicatedPlot->resolveReferencesRecursively(); duplicatedPlot->resolveReferencesRecursively();
} }
duplicatedPlot->loadDataAndUpdate();
} }
info.incrementProgress(); info.incrementProgress();
} }
summaryMultiPlot->endBatchAddOperation();
RiaPlotWindowRedrawScheduler::instance()->clearAllScheduledUpdates();
RiaPlotWindowRedrawScheduler::instance()->unblockScheduledUpdatesAndReplots();
summaryMultiPlot->loadDataAndUpdate();
summaryMultiPlot->updatePlotTitles(); summaryMultiPlot->updatePlotTitles();
} }
@ -273,6 +282,13 @@ bool RicAppendSummaryPlotsForObjectsFeature::isSelectionCompatibleWithPlot( cons
errorText = "Source plot must contain at least one region to be able to duplicate a selection of regions"; errorText = "Source plot must contain at least one region to be able to duplicate a selection of regions";
} }
} }
else if ( selectionType == RimSummaryAddressCollection::CollectionContentType::NETWORK )
{
if ( analyzer.networkNames().empty() )
{
errorText = "Source plot must contain at least one network to be able to duplicate a selection of networks";
}
}
if ( !errorText.isEmpty() ) if ( !errorText.isEmpty() )
{ {
@ -294,6 +310,7 @@ std::vector<RimSummaryPlot*>
std::string wellNameToMatch; std::string wellNameToMatch;
std::string groupNameToMatch; std::string groupNameToMatch;
std::string networkNameToMatch;
int regionToMatch = -1; int regionToMatch = -1;
int caseIdToMatch = -1; int caseIdToMatch = -1;
int ensembleIdToMatch = -1; int ensembleIdToMatch = -1;
@ -317,6 +334,10 @@ std::vector<RimSummaryPlot*>
{ {
if ( !myAnalyser.regionNumbers().empty() ) regionToMatch = *( myAnalyser.regionNumbers().begin() ); if ( !myAnalyser.regionNumbers().empty() ) regionToMatch = *( myAnalyser.regionNumbers().begin() );
} }
else if ( objectType == RimSummaryAddressCollection::CollectionContentType::NETWORK )
{
if ( !myAnalyser.networkNames().empty() ) networkNameToMatch = *( myAnalyser.networkNames().begin() );
}
else if ( objectType == RimSummaryAddressCollection::CollectionContentType::SUMMARY_CASE ) else if ( objectType == RimSummaryAddressCollection::CollectionContentType::SUMMARY_CASE )
{ {
if ( !sourcePlots.empty() ) if ( !sourcePlots.empty() )
@ -368,6 +389,10 @@ std::vector<RimSummaryPlot*>
{ {
isMatching = true; isMatching = true;
} }
else if ( !networkNameToMatch.empty() && a.networkName() == networkNameToMatch )
{
isMatching = true;
}
else if ( regionToMatch != -1 && a.regionNumber() == regionToMatch ) else if ( regionToMatch != -1 && a.regionNumber() == regionToMatch )
{ {
isMatching = true; isMatching = true;