mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge pull request #8754 from OPM/multiplot_improvements
Summary Multiplot: add new plot from a single curve in an ensemble plot and improve general plot performance
This commit is contained in:
@@ -204,4 +204,24 @@ enum class RowCount
|
||||
ROWS_4 = 4,
|
||||
};
|
||||
|
||||
enum class MultiPlotPageUpdateType : uint32_t
|
||||
{
|
||||
NONE = 0b0000,
|
||||
LEGEND = 0b0001,
|
||||
PLOT = 0b0010,
|
||||
ALL = 0b0011
|
||||
};
|
||||
|
||||
constexpr enum MultiPlotPageUpdateType operator|( const enum MultiPlotPageUpdateType selfValue,
|
||||
const enum MultiPlotPageUpdateType inValue )
|
||||
{
|
||||
return ( enum MultiPlotPageUpdateType )( uint32_t( selfValue ) | uint32_t( inValue ) );
|
||||
}
|
||||
|
||||
constexpr enum MultiPlotPageUpdateType operator&( const enum MultiPlotPageUpdateType selfValue,
|
||||
const enum MultiPlotPageUpdateType inValue )
|
||||
{
|
||||
return ( enum MultiPlotPageUpdateType )( uint32_t( selfValue ) & uint32_t( inValue ) );
|
||||
}
|
||||
|
||||
}; // namespace RiaDefines
|
||||
|
||||
@@ -51,9 +51,17 @@ void RiaPlotWindowRedrawScheduler::scheduleMultiPlotWindowUpdate( RiuMultiPlotBo
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaPlotWindowRedrawScheduler::scheduleMultiPlotPageUpdate( RiuMultiPlotPage* plotPage )
|
||||
void RiaPlotWindowRedrawScheduler::scheduleMultiPlotPageUpdate( RiuMultiPlotPage* plotPage,
|
||||
RiaDefines::MultiPlotPageUpdateType updateType )
|
||||
{
|
||||
m_plotPagesToUpdate.push_back( plotPage );
|
||||
if ( m_plotPagesToUpdate.count( plotPage ) == 0 )
|
||||
{
|
||||
m_plotPagesToUpdate[plotPage] = updateType;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_plotPagesToUpdate[plotPage] = m_plotPagesToUpdate[plotPage] | updateType;
|
||||
}
|
||||
|
||||
startTimer( 0 );
|
||||
}
|
||||
@@ -90,17 +98,16 @@ void RiaPlotWindowRedrawScheduler::clearAllScheduledUpdates()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaPlotWindowRedrawScheduler::performScheduledUpdatesAndReplots()
|
||||
{
|
||||
std::vector<QPointer<RiuMultiPlotBook>> plotWindowsToUpdate;
|
||||
std::vector<QPointer<RiuMultiPlotPage>> plotPagesToUpdate;
|
||||
std::vector<QPointer<RiuPlotWidget>> plotWidgetsToReplot;
|
||||
std::vector<QPointer<RiuMultiPlotBook>> plotWindowsToUpdate;
|
||||
std::vector<QPointer<RiuPlotWidget>> plotWidgetsToReplot;
|
||||
std::map<QPointer<RiuMultiPlotPage>, RiaDefines::MultiPlotPageUpdateType> pagesToUpdate;
|
||||
|
||||
pagesToUpdate.swap( m_plotPagesToUpdate );
|
||||
plotWindowsToUpdate.swap( m_plotWindowsToUpdate );
|
||||
plotPagesToUpdate.swap( m_plotPagesToUpdate );
|
||||
plotWidgetsToReplot.swap( m_plotWidgetsToReplot );
|
||||
|
||||
std::set<QPointer<RiuPlotWidget>> updatedPlots;
|
||||
std::set<QPointer<RiuMultiPlotBook>> updatedPlotWindows;
|
||||
std::set<QPointer<RiuMultiPlotPage>> updatedPlotPages;
|
||||
|
||||
for ( QPointer<RiuMultiPlotBook> plotWindow : plotWindowsToUpdate )
|
||||
{
|
||||
@@ -108,8 +115,7 @@ void RiaPlotWindowRedrawScheduler::performScheduledUpdatesAndReplots()
|
||||
{
|
||||
for ( RiuMultiPlotPage* page : plotWindow->pages() )
|
||||
{
|
||||
plotPagesToUpdate.erase( std::remove( plotPagesToUpdate.begin(), plotPagesToUpdate.end(), page ),
|
||||
plotPagesToUpdate.end() );
|
||||
if ( pagesToUpdate.count( page ) > 0 ) pagesToUpdate.erase( page );
|
||||
}
|
||||
|
||||
plotWindow->performUpdate();
|
||||
@@ -117,16 +123,13 @@ void RiaPlotWindowRedrawScheduler::performScheduledUpdatesAndReplots()
|
||||
}
|
||||
}
|
||||
|
||||
for ( QPointer<RiuMultiPlotPage> plotPage : plotPagesToUpdate )
|
||||
for ( auto& [page, updateType] : pagesToUpdate )
|
||||
{
|
||||
if ( !plotPage.isNull() && !updatedPlotPages.count( plotPage ) )
|
||||
{
|
||||
plotPage->performUpdate();
|
||||
updatedPlotPages.insert( plotPage );
|
||||
}
|
||||
if ( page.isNull() ) continue;
|
||||
|
||||
page->performUpdate( updateType );
|
||||
}
|
||||
|
||||
// Perform update and replot. Make sure we handle legend update
|
||||
for ( QPointer<RiuPlotWidget> plot : plotWidgetsToReplot )
|
||||
{
|
||||
if ( !plot.isNull() && !updatedPlots.count( plot ) )
|
||||
|
||||
@@ -19,11 +19,14 @@
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include "RiaDefines.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include <QScopedPointer>
|
||||
#include <QTimer>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
class RiuMultiPlotPage;
|
||||
@@ -36,11 +39,14 @@ class RiaPlotWindowRedrawScheduler : public QObject
|
||||
|
||||
public:
|
||||
static RiaPlotWindowRedrawScheduler* instance();
|
||||
void scheduleMultiPlotWindowUpdate( RiuMultiPlotBook* plotWindow );
|
||||
void scheduleMultiPlotPageUpdate( RiuMultiPlotPage* plotWindow );
|
||||
void schedulePlotWidgetReplot( RiuPlotWidget* plotWidget );
|
||||
void clearAllScheduledUpdates();
|
||||
void performScheduledUpdatesAndReplots();
|
||||
|
||||
void scheduleMultiPlotWindowUpdate( RiuMultiPlotBook* plotWindow );
|
||||
void scheduleMultiPlotPageUpdate(
|
||||
RiuMultiPlotPage* plotWindow,
|
||||
RiaDefines::MultiPlotPageUpdateType updateType = RiaDefines::MultiPlotPageUpdateType::ALL );
|
||||
void schedulePlotWidgetReplot( RiuPlotWidget* plotWidget );
|
||||
void clearAllScheduledUpdates();
|
||||
void performScheduledUpdatesAndReplots();
|
||||
|
||||
private slots:
|
||||
void slotUpdateAndReplotScheduledItemsWhenReady();
|
||||
@@ -52,8 +58,10 @@ private:
|
||||
void startTimer( int msecs );
|
||||
|
||||
private:
|
||||
std::map<QPointer<RiuMultiPlotPage>, RiaDefines::MultiPlotPageUpdateType> m_plotPagesToUpdate;
|
||||
|
||||
std::vector<QPointer<RiuPlotWidget>> m_plotWidgetsToReplot;
|
||||
std::vector<QPointer<RiuMultiPlotBook>> m_plotWindowsToUpdate;
|
||||
std::vector<QPointer<RiuMultiPlotPage>> m_plotPagesToUpdate;
|
||||
QScopedPointer<QTimer> m_plotWindowUpdateTimer;
|
||||
|
||||
QScopedPointer<QTimer> m_plotWindowUpdateTimer;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user