Merge pull request #8765 from OPM/summarymultiplot_performance2

Summary Multiplot performance improvements and fixes
This commit is contained in:
jonjenssen 2022-04-01 19:23:27 +02:00 committed by GitHub
parent 46a8bd58b2
commit 22d6e3f853
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 175 additions and 70 deletions

View File

@ -118,7 +118,8 @@ void RiaPlotWindowRedrawScheduler::performScheduledUpdatesAndReplots()
if ( pagesToUpdate.count( page ) > 0 ) pagesToUpdate.erase( page );
}
plotWindow->performUpdate();
const bool regeneratePages = true;
plotWindow->performUpdate( regeneratePages );
updatedPlotWindows.insert( plotWindow );
}
}

View File

@ -336,7 +336,14 @@ RimMultiPlot* RicSummaryPlotBuilder::createAndAppendMultiPlot( const std::vector
plotCollection->updateAllRequiredEditors();
plotWindow->loadDataAndUpdate();
RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow, true );
if ( !plots.empty() )
{
RiuPlotMainWindowTools::selectAsCurrentItem( plots[0], true );
}
else
{
RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow, true );
}
return plotWindow;
}
@ -360,8 +367,16 @@ RimSummaryMultiPlot*
plotCollection->updateAllRequiredEditors();
plotWindow->loadDataAndUpdate();
RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow );
RiuPlotMainWindowTools::setExpanded( plotWindow, true );
if ( plotWindow->summaryPlots().size() == 1 )
{
RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow->summaryPlots()[0] );
RiuPlotMainWindowTools::setExpanded( plotWindow->summaryPlots()[0], true );
}
else
{
RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow );
RiuPlotMainWindowTools::setExpanded( plotWindow, true );
}
return plotWindow;
}
@ -425,7 +440,7 @@ RimSummaryMultiPlot*
plotWindow->loadDataAndUpdate();
plotWindow->updateAllRequiredEditors();
RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow );
RiuPlotMainWindowTools::selectAsCurrentItem( plot );
return plotWindow;
}
@ -448,7 +463,14 @@ RimSummaryMultiPlot* RicSummaryPlotBuilder::createAndAppendSummaryMultiPlot( con
plotWindow->loadDataAndUpdate();
plotWindow->updateAllRequiredEditors();
RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow );
if ( !plots.empty() )
{
RiuPlotMainWindowTools::selectAsCurrentItem( plots[0] );
}
else
{
RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow );
}
return plotWindow;
}

View File

@ -75,7 +75,7 @@ void RicDeleteSubPlotFeature::onActionTriggered( bool isChecked )
std::vector<RimPlot*> selection;
caf::SelectionManager::instance()->objectsByType( &selection );
std::set<RimPlotWindow*> alteredPlotWindows;
std::set<RimMultiPlot*> alteredPlotWindows;
for ( RimPlot* plot : selection )
{
@ -94,18 +94,22 @@ void RicDeleteSubPlotFeature::onActionTriggered( bool isChecked )
if ( multiPlot )
{
alteredPlotWindows.insert( multiPlot );
multiPlot->removePlot( plot );
multiPlot->removePlotNoUpdate( plot );
multiPlot->updateConnectedEditors();
delete plot;
}
else if ( wellLogPlot )
{
alteredPlotWindows.insert( wellLogPlot );
wellLogPlot->removePlot( plot );
wellLogPlot->updateConnectedEditors();
delete plot;
}
}
for ( auto mainplot : alteredPlotWindows )
{
mainplot->updateAfterPlotRemove();
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -190,10 +190,9 @@ void RimMultiPlot::insertPlot( RimPlot* plot, size_t index )
if ( m_viewer )
{
plot->createPlotWidget();
plot->createPlotWidget( m_viewer );
m_viewer->insertPlot( plot->plotWidget(), index );
}
plot->setShowWindow( true );
plot->updateAfterInsertingIntoMultiPlot();
onPlotAdditionOrRemoval();
@ -217,6 +216,29 @@ void RimMultiPlot::removePlot( RimPlot* plot )
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMultiPlot::removePlotNoUpdate( RimPlot* plot )
{
if ( plot )
{
if ( m_viewer )
{
m_viewer->removePlotNoUpdate( plot->plotWidget() );
}
m_plots.removeChildObject( plot );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMultiPlot::updateAfterPlotRemove()
{
onPlotAdditionOrRemoval();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -851,7 +873,7 @@ void RimMultiPlot::recreatePlotWidgets()
for ( size_t tIdx = 0; tIdx < plotVector.size(); ++tIdx )
{
plotVector[tIdx]->createPlotWidget();
plotVector[tIdx]->createPlotWidget( m_viewer );
m_viewer->addPlot( plotVector[tIdx]->plotWidget() );
}
}

View File

@ -69,6 +69,9 @@ public:
void removePlot( RimPlot* plot ) override;
void movePlotsToThis( const std::vector<RimPlot*>& plots, int insertAtPosition );
virtual void removePlotNoUpdate( RimPlot* plot );
virtual void updateAfterPlotRemove();
void deleteAllPlots() override;
size_t plotCount() const override;
@ -122,8 +125,10 @@ protected:
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
void onLoadDataAndUpdate() override;
void initAfterRead() override;
void onLoadDataAndUpdate() override;
void initAfterRead() override;
void applyPlotWindowTitleToWidgets();
void updatePlots();
@ -131,6 +136,7 @@ protected:
void recreatePlotWidgets();
virtual void updatePlotWindowTitle();
void onPlotAdditionOrRemoval();
bool isMouseCursorInsidePlot();
@ -140,7 +146,6 @@ private:
void doUpdateLayout() override;
void updateSubPlotNames();
void doRenderWindowContent( QPaintDevice* paintDevice ) override;
void onPlotAdditionOrRemoval();
void onPlotsReordered( const caf::SignalEmitter* emitter );
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects ) override;

View File

@ -159,9 +159,6 @@ void RimPlot::removeFromMdiAreaAndCollection()
void RimPlot::updateAfterInsertingIntoMultiPlot()
{
loadDataAndUpdate();
/* updateLegend();
updateAxes();
updateLayout(); */
}
//--------------------------------------------------------------------------------------------------

View File

@ -93,13 +93,21 @@ void RimEnsembleCurveSetCollection::loadDataAndUpdate( bool updateParentPlot )
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSetCollection::setParentPlotAndReplot( RiuPlotWidget* plot )
{
setParentPlotNoReplot( plot );
if ( plot ) plot->replot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSetCollection::setParentPlotNoReplot( RiuPlotWidget* plot )
{
for ( RimEnsembleCurveSet* curveSet : m_curveSets )
{
curveSet->setParentPlotNoReplot( plot );
}
if ( plot ) plot->replot();
}
//--------------------------------------------------------------------------------------------------

View File

@ -44,6 +44,7 @@ public:
void loadDataAndUpdate( bool updateParentPlot );
void setParentPlotAndReplot( RiuPlotWidget* plot );
void setParentPlotNoReplot( RiuPlotWidget* plot );
void detachPlotCurves();
void reattachPlotCurves();

View File

@ -125,13 +125,21 @@ void RimSummaryCurveCollection::loadDataAndUpdate( bool updateParentPlot )
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCurveCollection::setParentPlotAndReplot( RiuPlotWidget* plot )
{
setParentPlotNoReplot( plot );
if ( plot ) plot->replot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCurveCollection::setParentPlotNoReplot( RiuPlotWidget* plot )
{
for ( RimSummaryCurve* curve : m_curves )
{
curve->setParentPlotNoReplot( plot );
}
if ( plot ) plot->replot();
}
//--------------------------------------------------------------------------------------------------

View File

@ -64,6 +64,7 @@ public:
private:
void setParentPlotAndReplot( RiuPlotWidget* plot );
void setParentPlotNoReplot( RiuPlotWidget* plot );
void detachPlotCurves();
void reattachPlotCurves();

View File

@ -52,7 +52,6 @@ CAF_PDM_SOURCE_INIT( RimSummaryMultiPlot, "MultiSummaryPlot" );
//--------------------------------------------------------------------------------------------------
RimSummaryMultiPlot::RimSummaryMultiPlot()
: duplicatePlot( this )
, refreshTree( this )
{
CAF_PDM_InitObject( "Multi Summary Plot" );
this->setDeletable( true );
@ -117,7 +116,6 @@ void RimSummaryMultiPlot::insertPlot( RimPlot* plot, size_t index )
{
sumPlot->curvesChanged.connect( this, &RimSummaryMultiPlot::onSubPlotChanged );
RimMultiPlot::insertPlot( plot, index );
signalRefresh();
}
}
@ -150,10 +148,30 @@ void RimSummaryMultiPlot::removePlot( RimPlot* plot )
if ( sumPlot )
{
RimMultiPlot::removePlot( plot );
signalRefresh();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryMultiPlot::removePlotNoUpdate( RimPlot* plot )
{
RimSummaryPlot* sumPlot = dynamic_cast<RimSummaryPlot*>( plot );
CVF_ASSERT( sumPlot != nullptr );
if ( sumPlot )
{
RimMultiPlot::removePlotNoUpdate( plot );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryMultiPlot::updateAfterPlotRemove()
{
onPlotAdditionOrRemoval();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -387,6 +405,21 @@ std::vector<RimSummaryPlot*> RimSummaryMultiPlot::summaryPlots() const
return typedPlots;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimSummaryPlot*> RimSummaryMultiPlot::visibleSummaryPlots() const
{
std::vector<RimSummaryPlot*> visiblePlots;
for ( auto plot : summaryPlots() )
{
if ( plot->showWindow() ) visiblePlots.push_back( plot );
}
return visiblePlots;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -535,14 +568,6 @@ void RimSummaryMultiPlot::duplicate()
duplicatePlot.send( this );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryMultiPlot::signalRefresh()
{
refreshTree.send( this );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -46,7 +46,6 @@ class RimSummaryMultiPlot : public RimMultiPlot, public RimSummaryDataSourceStep
public:
caf::Signal<RimSummaryMultiPlot*> duplicatePlot;
caf::Signal<RimSummaryMultiPlot*> refreshTree;
public:
RimSummaryMultiPlot();
@ -66,6 +65,9 @@ public:
void insertPlot( RimPlot* plot, size_t index ) override;
void removePlot( RimPlot* plot ) override;
void removePlotNoUpdate( RimPlot* plot ) override;
void updateAfterPlotRemove() override;
std::vector<caf::PdmFieldHandle*> fieldsToShowInToolbar();
void syncAxisRanges();
@ -75,6 +77,7 @@ public:
void summaryPlotItemInfos( QList<caf::PdmOptionItemInfo>* optionInfos ) const;
std::vector<RimSummaryPlot*> summaryPlots() const;
std::vector<RimSummaryPlot*> visibleSummaryPlots() const;
protected:
bool handleGlobalKeyEvent( QKeyEvent* keyEvent ) override;
@ -93,7 +96,6 @@ private:
void updatePlotWindowTitle() override;
void duplicate();
void signalRefresh();
void onSubPlotChanged( const caf::SignalEmitter* emitter );

View File

@ -55,7 +55,6 @@ void RimSummaryMultiPlotCollection::initAfterRead()
for ( auto& plot : m_summaryMultiPlots )
{
plot->duplicatePlot.connect( this, &RimSummaryMultiPlotCollection::onDuplicatePlot );
plot->refreshTree.connect( this, &RimSummaryMultiPlotCollection::onRefreshTree );
}
}
@ -82,7 +81,6 @@ void RimSummaryMultiPlotCollection::addSummaryMultiPlot( RimSummaryMultiPlot* pl
{
m_summaryMultiPlots().push_back( plot );
plot->duplicatePlot.connect( this, &RimSummaryMultiPlotCollection::onDuplicatePlot );
plot->refreshTree.connect( this, &RimSummaryMultiPlotCollection::onRefreshTree );
}
//--------------------------------------------------------------------------------------------------
@ -141,14 +139,7 @@ void RimSummaryMultiPlotCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering
{
for ( auto& plot : m_summaryMultiPlots() )
{
if ( plot->summaryPlots().size() == 1 )
{
uiTreeOrdering.add( plot->summaryPlots()[0] );
}
else
{
uiTreeOrdering.add( plot );
}
uiTreeOrdering.add( plot );
}
uiTreeOrdering.skipRemainingChildren( true );
}

View File

@ -1586,7 +1586,10 @@ void RimSummaryPlot::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
void RimSummaryPlot::onLoadDataAndUpdate()
{
updatePlotTitle();
updateMdiWindowVisibility();
RimMultiPlot* plotWindow = nullptr;
firstAncestorOrThisOfType( plotWindow );
if ( plotWindow == nullptr ) updateMdiWindowVisibility();
if ( m_summaryCurveCollection )
{
@ -1623,18 +1626,17 @@ void RimSummaryPlot::onLoadDataAndUpdate()
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateZoomInParentPlot()
{
if ( plotWidget() )
{
for ( const auto& axisProperty : m_axisProperties )
{
updateZoomForAxis( axisProperty->plotAxisType() );
}
if ( !plotWidget() ) return;
plotWidget()->updateAxes();
updateZoomFromParentPlot();
plotWidget()->updateZoomDependentCurveProperties();
plotWidget()->scheduleReplot();
for ( const auto& axisProperty : m_axisProperties )
{
updateZoomForAxis( axisProperty->plotAxisType() );
}
plotWidget()->updateAxes();
updateZoomFromParentPlot();
plotWidget()->updateZoomDependentCurveProperties();
plotWidget()->scheduleReplot();
}
//--------------------------------------------------------------------------------------------------
@ -2180,7 +2182,7 @@ RiuPlotWidget* RimSummaryPlot::doCreatePlotViewWidget( QWidget* mainWindowParent
if ( useQtCharts )
{
m_summaryPlot = std::make_unique<RiuSummaryQtChartsPlot>( this );
m_summaryPlot = std::make_unique<RiuSummaryQtChartsPlot>( this, mainWindowParent );
}
else
{
@ -2207,12 +2209,12 @@ RiuPlotWidget* RimSummaryPlot::doCreatePlotViewWidget( QWidget* mainWindowParent
if ( m_summaryCurveCollection )
{
m_summaryCurveCollection->setParentPlotAndReplot( plotWidget() );
m_summaryCurveCollection->setParentPlotNoReplot( plotWidget() );
}
if ( m_ensembleCurveSetCollection )
{
m_ensembleCurveSetCollection->setParentPlotAndReplot( plotWidget() );
m_ensembleCurveSetCollection->setParentPlotNoReplot( plotWidget() );
}
this->connect( plotWidget(), SIGNAL( plotZoomed() ), SLOT( onPlotZoomed() ) );
@ -2220,6 +2222,8 @@ RiuPlotWidget* RimSummaryPlot::doCreatePlotViewWidget( QWidget* mainWindowParent
updatePlotTitle();
}
plotWidget()->setParent( mainWindowParent );
return plotWidget();
}

View File

@ -183,6 +183,15 @@ void RiuMultiPlotBook::insertPlot( RiuPlotWidget* plotWidget, size_t index )
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotBook::removePlot( RiuPlotWidget* plotWidget )
{
removePlotNoUpdate( plotWidget );
scheduleUpdate();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotBook::removePlotNoUpdate( RiuPlotWidget* plotWidget )
{
if ( !plotWidget ) return;
@ -190,8 +199,6 @@ void RiuMultiPlotBook::removePlot( RiuPlotWidget* plotWidget )
CVF_ASSERT( plotWidgetIdx >= 0 );
m_plotWidgets.removeAt( plotWidgetIdx );
scheduleUpdate();
}
//--------------------------------------------------------------------------------------------------
@ -383,7 +390,8 @@ void RiuMultiPlotBook::showEvent( QShowEvent* event )
{
m_goToPageAfterUpdate = true;
QWidget::showEvent( event );
performUpdate();
const bool regeneratePages = false;
performUpdate( regeneratePages );
if ( m_previewMode )
{
applyPagePreviewBookSize( width() );
@ -473,16 +481,19 @@ bool RiuMultiPlotBook::showYAxis( int row, int column ) const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotBook::performUpdate()
void RiuMultiPlotBook::performUpdate( bool regeneratePages )
{
applyLook();
deleteAllPages();
createPages();
if ( regeneratePages || m_pages.size() == 0 )
{
deleteAllPages();
createPages();
}
updateGeometry();
// use a timer to trigger a viewer page change, if needed
if ( m_goToPageAfterUpdate )
{
m_pageTimerId = startTimer( 100 );
m_pageTimerId = startTimer( 50 );
m_goToPageAfterUpdate = false;
}
}

View File

@ -62,6 +62,7 @@ public:
void addPlot( RiuPlotWidget* plotWidget );
void insertPlot( RiuPlotWidget* plotWidget, size_t index );
void removePlot( RiuPlotWidget* plotWidget );
void removePlotNoUpdate( RiuPlotWidget* plotWidget );
void removeAllPlots();
void setPlotTitle( const QString& plotTitle );
@ -120,7 +121,7 @@ private:
void changeCurrentPage( int pageNumber );
private slots:
virtual void performUpdate();
virtual void performUpdate( bool regeneratePages );
protected:
friend class RiaPlotWindowRedrawScheduler;

View File

@ -62,6 +62,7 @@
#include <QPainter>
#include <QScrollBar>
#include <QTimer>
#include <QWidget>
#include <cmath>

View File

@ -30,10 +30,10 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuSummaryQtChartsPlot::RiuSummaryQtChartsPlot( RimSummaryPlot* plot )
RiuSummaryQtChartsPlot::RiuSummaryQtChartsPlot( RimSummaryPlot* plot, QWidget* parent )
: RiuSummaryPlot( plot )
{
m_plotWidget = new RiuQtChartsPlotWidget( plot, nullptr, new RimEnsembleCurveInfoTextProvider );
m_plotWidget = new RiuQtChartsPlotWidget( plot, parent, new RimEnsembleCurveInfoTextProvider );
m_plotWidget->setContextMenuPolicy( Qt::CustomContextMenu );
connect( m_plotWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( showContextMenu( QPoint ) ) );

View File

@ -25,6 +25,7 @@
#include <QPointer>
class QWidget;
class RimSummaryPlot;
class RimPlotAxisPropertiesInterface;
@ -38,7 +39,7 @@ class RiuSummaryQtChartsPlot : public RiuSummaryPlot
Q_OBJECT;
public:
RiuSummaryQtChartsPlot( RimSummaryPlot* plot );
RiuSummaryQtChartsPlot( RimSummaryPlot* plot, QWidget* parent );
~RiuSummaryQtChartsPlot() override;
void useDateBasedTimeAxis(