Use set to get unique plots for update

This commit is contained in:
Magne Sjaastad 2022-05-25 21:40:52 +02:00
parent 4a1a2fe2be
commit 3545d16fbb
2 changed files with 5 additions and 8 deletions

View File

@ -79,7 +79,7 @@ void RiaPlotWindowRedrawScheduler::scheduleMultiPlotPageUpdate( RiuMultiPlotPage
//--------------------------------------------------------------------------------------------------
void RiaPlotWindowRedrawScheduler::schedulePlotWidgetReplot( RiuPlotWidget* plotWidget )
{
m_plotWidgetsToReplot.push_back( plotWidget );
m_plotWidgetsToReplot.insert( plotWidget );
startTimer( 0 );
}
@ -107,15 +107,13 @@ void RiaPlotWindowRedrawScheduler::clearAllScheduledUpdates()
void RiaPlotWindowRedrawScheduler::performScheduledUpdatesAndReplots()
{
std::map<QPointer<RiuMultiPlotBook>, RiaDefines::MultiPlotPageUpdateType> plotBooksToUpdate;
std::vector<QPointer<RiuPlotWidget>> plotWidgetsToReplot;
std::set<QPointer<RiuPlotWidget>> plotWidgetsToReplot;
std::map<QPointer<RiuMultiPlotPage>, RiaDefines::MultiPlotPageUpdateType> pagesToUpdate;
pagesToUpdate.swap( m_plotPagesToUpdate );
plotBooksToUpdate.swap( m_plotBooksToUpdate );
plotWidgetsToReplot.swap( m_plotWidgetsToReplot );
std::set<QPointer<RiuPlotWidget>> updatedPlots;
for ( auto& [plotBook, updateType] : plotBooksToUpdate )
{
if ( plotBook.isNull() ) continue;
@ -137,12 +135,11 @@ void RiaPlotWindowRedrawScheduler::performScheduledUpdatesAndReplots()
page->performUpdate( updateType );
}
for ( QPointer<RiuPlotWidget> plot : plotWidgetsToReplot )
for ( const QPointer<RiuPlotWidget>& plot : plotWidgetsToReplot )
{
if ( !plot.isNull() && !updatedPlots.count( plot ) )
if ( !plot.isNull() )
{
plot->replot();
updatedPlots.insert( plot );
}
}
}

View File

@ -63,7 +63,7 @@ private:
std::map<QPointer<RiuMultiPlotPage>, RiaDefines::MultiPlotPageUpdateType> m_plotPagesToUpdate;
std::map<QPointer<RiuMultiPlotBook>, RiaDefines::MultiPlotPageUpdateType> m_plotBooksToUpdate;
std::vector<QPointer<RiuPlotWidget>> m_plotWidgetsToReplot;
std::set<QPointer<RiuPlotWidget>> m_plotWidgetsToReplot;
QScopedPointer<QTimer> m_plotWindowUpdateTimer;
};