mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Performance updates (#9082)
* Avoid creation of curve legend widgets during construction of a multi plot * Make sure default z-value is correct to avoid expensive Qwt updates * Avoid duplicate plot updates * Do not create internal Qwt legend by default * RFT import: Avoid expensive method throwing exception if no data is found
This commit is contained in:
parent
5078f4072f
commit
b706192ea3
@ -107,12 +107,10 @@ void RiaPlotWindowRedrawScheduler::clearAllScheduledUpdates()
|
||||
void RiaPlotWindowRedrawScheduler::performScheduledUpdatesAndReplots()
|
||||
{
|
||||
std::map<QPointer<RiuMultiPlotBook>, RiaDefines::MultiPlotPageUpdateType> plotBooksToUpdate;
|
||||
std::set<QPointer<RiuPlotWidget>> plotWidgetsToReplot;
|
||||
std::map<QPointer<RiuMultiPlotPage>, RiaDefines::MultiPlotPageUpdateType> pagesToUpdate;
|
||||
|
||||
pagesToUpdate.swap( m_plotPagesToUpdate );
|
||||
plotBooksToUpdate.swap( m_plotBooksToUpdate );
|
||||
plotWidgetsToReplot.swap( m_plotWidgetsToReplot );
|
||||
|
||||
for ( auto& [plotBook, updateType] : plotBooksToUpdate )
|
||||
{
|
||||
@ -135,6 +133,12 @@ void RiaPlotWindowRedrawScheduler::performScheduledUpdatesAndReplots()
|
||||
page->performUpdate( updateType );
|
||||
}
|
||||
|
||||
// PERFORMANCE NOTE
|
||||
// As the book and page updates can trigger widget updates, make sure to get the list of widgets to replot after
|
||||
// these updates
|
||||
std::set<QPointer<RiuPlotWidget>> plotWidgetsToReplot;
|
||||
plotWidgetsToReplot.swap( m_plotWidgetsToReplot );
|
||||
|
||||
for ( const QPointer<RiuPlotWidget>& plot : plotWidgetsToReplot )
|
||||
{
|
||||
if ( !plot.isNull() )
|
||||
|
@ -95,12 +95,11 @@ void RicAppendSummaryPlotsForObjectsFeature::appendPlots( RimSummaryMultiPlot* s
|
||||
summaryMultiPlot->addPlot( duplicatedPlot );
|
||||
|
||||
duplicatedPlot->resolveReferencesRecursively();
|
||||
duplicatedPlot->loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
info.incrementProgress();
|
||||
}
|
||||
|
||||
summaryMultiPlot->loadDataAndUpdate();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -520,9 +520,14 @@ void RifReaderOpmRft::buildSegmentBranchTypes( const RftSegmentKey& segmentKey )
|
||||
std::vector<int>
|
||||
RifReaderOpmRft::importWellData( const std::string& wellName, const std::string& propertyName, const RftDate& date ) const
|
||||
{
|
||||
// PERFORMANCE NOTE
|
||||
// Use method hasRft() that do not throw exception if RFT data is not available. Using this method and avoid
|
||||
// try/catch and exceptions is way faster.
|
||||
if ( !m_opm_rft->hasRft( wellName, date ) ) return {};
|
||||
|
||||
try
|
||||
{
|
||||
// THe hasArray method can throw, so we must use a try/catch block here
|
||||
// The hasArray method can throw, so we must use a try/catch block here
|
||||
if ( m_opm_rft->hasArray( propertyName, wellName, date ) )
|
||||
{
|
||||
return m_opm_rft->getRft<int>( propertyName, wellName, date );
|
||||
|
@ -797,12 +797,21 @@ QList<caf::PdmOptionItemInfo> RimMultiPlot::calculateValueOptions( const caf::Pd
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimMultiPlot::onLoadDataAndUpdate()
|
||||
{
|
||||
// PERFORMANCE NOTE
|
||||
// Creation and update of the legend widgets is expensive. Disable display of legends during construction of the
|
||||
// multi plot and creation of widgets. The legends will be made visible due to redraw operations always scheduled
|
||||
// after this method.
|
||||
bool originalShowState = m_showPlotLegends();
|
||||
m_showPlotLegends = false;
|
||||
|
||||
updateMdiWindowVisibility();
|
||||
updatePlotWindowTitle();
|
||||
applyPlotWindowTitleToWidgets();
|
||||
updatePlots();
|
||||
updateLayout();
|
||||
RiuPlotMainWindowTools::refreshToolbars();
|
||||
|
||||
m_showPlotLegends = originalShowState;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -76,7 +76,7 @@ QWidget* RimPlot::createViewWidget( QWidget* parent /*= nullptr */ )
|
||||
RiuPlotWidget* plotWidget = doCreatePlotViewWidget( parent );
|
||||
|
||||
updateWindowVisibility();
|
||||
plotWidget->scheduleReplot();
|
||||
if ( showWindow() ) plotWidget->scheduleReplot();
|
||||
|
||||
return plotWidget;
|
||||
}
|
||||
|
@ -718,6 +718,14 @@ void RimPlotCurve::setSamplesFromTimeTAndYValues( const std::vector<time_t>& dat
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimPlotCurve::computeCurveZValue()
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -996,6 +1004,12 @@ void RimPlotCurve::setParentPlotNoReplot( RiuPlotWidget* plotWidget )
|
||||
}
|
||||
|
||||
m_plotCurve = m_parentPlot->createPlotCurve( this, "", RiaColorTools::toQColor( m_curveAppearance->color() ) );
|
||||
|
||||
// PERFORMANCE NOTE
|
||||
// When the z-value of a curve is changed, several update calls are made to the plot. Make sure that the default
|
||||
// z-value is correct to avoid these calls.
|
||||
m_plotCurve->setZ( computeCurveZValue() );
|
||||
|
||||
m_plotCurve->attachToPlot( plotWidget );
|
||||
}
|
||||
|
||||
@ -1005,6 +1019,9 @@ void RimPlotCurve::setParentPlotNoReplot( RiuPlotWidget* plotWidget )
|
||||
void RimPlotCurve::setParentPlotAndReplot( RiuPlotWidget* plotWidget )
|
||||
{
|
||||
CAF_ASSERT( plotWidget );
|
||||
|
||||
if ( m_parentPlot == plotWidget ) return;
|
||||
|
||||
setParentPlotNoReplot( plotWidget );
|
||||
plotWidget->replot();
|
||||
}
|
||||
@ -1035,7 +1052,7 @@ void RimPlotCurve::detach( bool deletePlotCurve )
|
||||
}
|
||||
}
|
||||
|
||||
replotParentPlot();
|
||||
m_parentPlot->scheduleReplot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -157,6 +157,8 @@ protected:
|
||||
const std::vector<double>& yValues,
|
||||
bool useLogarithmicScale );
|
||||
|
||||
virtual double computeCurveZValue();
|
||||
|
||||
protected:
|
||||
// Overridden PDM methods
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
|
@ -302,8 +302,7 @@ void RimEnsembleCurveSet::setParentPlotNoReplot( RiuPlotWidget* plot )
|
||||
{
|
||||
for ( RimSummaryCurve* curve : m_curves )
|
||||
{
|
||||
// TODO: attach without replotting
|
||||
curve->attach( plot );
|
||||
curve->setParentPlotNoReplot( plot );
|
||||
}
|
||||
|
||||
if ( !m_plotCurveForLegendText )
|
||||
@ -315,11 +314,11 @@ void RimEnsembleCurveSet::setParentPlotNoReplot( RiuPlotWidget* plot )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleCurveSet::detachPlotCurves( bool deletePlotCurve )
|
||||
void RimEnsembleCurveSet::deletePlotCurves()
|
||||
{
|
||||
for ( RimSummaryCurve* curve : m_curves )
|
||||
{
|
||||
curve->detach( deletePlotCurve );
|
||||
curve->deletePlotCurve();
|
||||
}
|
||||
|
||||
if ( m_plotCurveForLegendText )
|
||||
@ -1361,7 +1360,7 @@ void RimEnsembleCurveSet::updateFilterLegend()
|
||||
plot->plotWidget()->removeOverlayFrame( m_filterOverlayFrame );
|
||||
}
|
||||
}
|
||||
plot->plotWidget()->scheduleReplot();
|
||||
plot->scheduleReplotIfVisible();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1423,7 +1422,7 @@ void RimEnsembleCurveSet::updateObjectiveFunctionLegend()
|
||||
}
|
||||
}
|
||||
}
|
||||
plot->plotWidget()->scheduleReplot();
|
||||
plot->scheduleReplotIfVisible();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1612,7 +1611,7 @@ void RimEnsembleCurveSet::updateCurveColors()
|
||||
plot->plotWidget()->removeOverlayFrame( m_legendOverlayFrame );
|
||||
}
|
||||
}
|
||||
plot->plotWidget()->scheduleReplot();
|
||||
plot->scheduleReplotIfVisible();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1708,7 +1707,6 @@ void RimEnsembleCurveSet::updateEnsembleCurves( const std::vector<RimSummaryCase
|
||||
addCurve( curve );
|
||||
|
||||
curve->setLeftOrRightAxisY( axisY() );
|
||||
curve->updateCurveVisibility();
|
||||
|
||||
newSummaryCurves.push_back( curve );
|
||||
}
|
||||
@ -1733,7 +1731,7 @@ void RimEnsembleCurveSet::updateEnsembleCurves( const std::vector<RimSummaryCase
|
||||
if ( plot->plotWidget() )
|
||||
{
|
||||
if ( plot->legendsVisible() ) plot->plotWidget()->updateLegend();
|
||||
plot->plotWidget()->scheduleReplot();
|
||||
plot->scheduleReplotIfVisible();
|
||||
plot->updateAxes();
|
||||
plot->updatePlotInfoLabel();
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
|
||||
void loadDataAndUpdate( bool updateParentPlot );
|
||||
void setParentPlotNoReplot( RiuPlotWidget* plot );
|
||||
void detachPlotCurves( bool deletePlotCurve = false );
|
||||
void deletePlotCurves();
|
||||
void reattachPlotCurves();
|
||||
|
||||
void addCurve( RimSummaryCurve* curve );
|
||||
|
@ -117,7 +117,7 @@ void RimEnsembleCurveSetCollection::detachPlotCurves()
|
||||
{
|
||||
for ( const auto& curveSet : m_curveSets )
|
||||
{
|
||||
curveSet->detachPlotCurves();
|
||||
curveSet->deletePlotCurves();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -786,6 +786,44 @@ void RimSummaryCurve::initAfterRead()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimSummaryCurve::computeCurveZValue()
|
||||
{
|
||||
auto sumAddr = summaryAddressY();
|
||||
auto sumCase = summaryCaseY();
|
||||
|
||||
double zOrder = 0.0;
|
||||
|
||||
if ( sumCase && sumAddr.isValid() )
|
||||
{
|
||||
if ( sumCase->isObservedData() )
|
||||
{
|
||||
zOrder = RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_SINGLE_CURVE_OBSERVED );
|
||||
}
|
||||
else if ( sumAddr.category() == RifEclipseSummaryAddress::SUMMARY_ENSEMBLE_STATISTICS )
|
||||
{
|
||||
zOrder = RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_ENSEMBLE_STAT_CURVE );
|
||||
}
|
||||
else if ( sumCase->ensemble() )
|
||||
{
|
||||
zOrder = RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_ENSEMBLE_CURVE );
|
||||
}
|
||||
else
|
||||
{
|
||||
zOrder = RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_SINGLE_CURVE_NON_OBSERVED );
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_isTopZWithinCategory )
|
||||
{
|
||||
zOrder += 1.0;
|
||||
}
|
||||
|
||||
return zOrder;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -894,37 +932,9 @@ void RimSummaryCurve::setResampling( RiaDefines::DateTimePeriodEnum resampling )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurve::setZIndexFromCurveInfo()
|
||||
{
|
||||
auto sumAddr = summaryAddressY();
|
||||
auto sumCase = summaryCaseY();
|
||||
auto zValue = computeCurveZValue();
|
||||
|
||||
double zOrder = 0.0;
|
||||
|
||||
if ( sumCase && sumAddr.isValid() )
|
||||
{
|
||||
if ( sumCase->isObservedData() )
|
||||
{
|
||||
zOrder = RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_SINGLE_CURVE_OBSERVED );
|
||||
}
|
||||
else if ( sumAddr.category() == RifEclipseSummaryAddress::SUMMARY_ENSEMBLE_STATISTICS )
|
||||
{
|
||||
zOrder = RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_ENSEMBLE_STAT_CURVE );
|
||||
}
|
||||
else if ( sumCase->ensemble() )
|
||||
{
|
||||
zOrder = RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_ENSEMBLE_CURVE );
|
||||
}
|
||||
else
|
||||
{
|
||||
zOrder = RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_SINGLE_CURVE_NON_OBSERVED );
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_isTopZWithinCategory )
|
||||
{
|
||||
zOrder += 1.0;
|
||||
}
|
||||
|
||||
setZOrder( zOrder );
|
||||
setZOrder( zValue );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -107,8 +107,9 @@ protected:
|
||||
|
||||
void updateLegendsInPlot() override;
|
||||
|
||||
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
|
||||
void initAfterRead() override;
|
||||
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
|
||||
void initAfterRead() override;
|
||||
double computeCurveZValue() override;
|
||||
|
||||
private:
|
||||
RifSummaryReaderInterface* valuesSummaryReaderX() const;
|
||||
|
@ -237,12 +237,6 @@ void RimSummaryPlot::updateAxes()
|
||||
updateTimeAxis( timeAxisProperties() );
|
||||
}
|
||||
|
||||
if ( plotWidget() )
|
||||
{
|
||||
plotWidget()->updateAxes();
|
||||
plotWidget()->scheduleReplot();
|
||||
}
|
||||
|
||||
updateZoomInParentPlot();
|
||||
}
|
||||
|
||||
@ -584,7 +578,7 @@ void RimSummaryPlot::updatePlotTitle()
|
||||
QString plotTitle = description();
|
||||
plotWidget()->setPlotTitle( plotTitle );
|
||||
plotWidget()->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() );
|
||||
plotWidget()->scheduleReplot();
|
||||
scheduleReplotIfVisible();
|
||||
}
|
||||
}
|
||||
|
||||
@ -869,11 +863,28 @@ void RimSummaryPlot::updateAxis( RiaDefines::PlotAxis plotAxis )
|
||||
timeHistoryQuantities.insert( c->quantityName() );
|
||||
}
|
||||
|
||||
std::vector<RiaSummaryCurveDefinition> curveDefs;
|
||||
for ( auto summaryCurve : summaryCurves() )
|
||||
{
|
||||
if ( summaryCurve->axisY() != riuPlotAxis ) continue;
|
||||
|
||||
curveDefs.push_back( summaryCurve->curveDefinitionY() );
|
||||
}
|
||||
|
||||
for ( auto curveSet : ensembleCurveSetCollection()->curveSets() )
|
||||
{
|
||||
if ( curveSet->axisY() != riuPlotAxis ) continue;
|
||||
|
||||
RiaSummaryCurveDefinition def( curveSet->summaryCaseCollection(), curveSet->summaryAddress() );
|
||||
curveDefs.push_back( def );
|
||||
}
|
||||
|
||||
RimSummaryPlotAxisFormatter calc( axisProperties,
|
||||
visibleSummaryCurvesForAxis( riuPlotAxis ),
|
||||
{},
|
||||
curveDefs,
|
||||
visibleAsciiDataCurvesForAxis( riuPlotAxis ),
|
||||
timeHistoryQuantities );
|
||||
|
||||
calc.applyAxisPropertiesToPlot( plotWidget() );
|
||||
}
|
||||
}
|
||||
@ -971,6 +982,14 @@ bool RimSummaryPlot::isOnlyWaterCutCurvesVisible( RiuPlotAxis plotAxis )
|
||||
return ( waterCutCurveCount == curves.size() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::scheduleReplotIfVisible()
|
||||
{
|
||||
if ( showWindow() && plotWidget() ) plotWidget()->scheduleReplot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1465,7 +1484,7 @@ void RimSummaryPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
|
||||
for ( auto& curveSet : this->ensembleCurveSetCollection()->curveSets() )
|
||||
{
|
||||
curveSet->detachPlotCurves( true );
|
||||
curveSet->deletePlotCurves();
|
||||
}
|
||||
|
||||
// Destroy viewer
|
||||
@ -1498,7 +1517,7 @@ void RimSummaryPlot::updateStackedCurveData()
|
||||
if ( plotWidget() && anyStackedCurvesPresent )
|
||||
{
|
||||
reattachAllCurves();
|
||||
plotWidget()->scheduleReplot();
|
||||
scheduleReplotIfVisible();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1686,7 +1705,7 @@ void RimSummaryPlot::updateZoomInParentPlot()
|
||||
plotWidget()->updateAxes();
|
||||
updateZoomFromParentPlot();
|
||||
plotWidget()->updateZoomDependentCurveProperties();
|
||||
plotWidget()->scheduleReplot();
|
||||
scheduleReplotIfVisible();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1775,10 +1794,7 @@ void RimSummaryPlot::curveVisibilityChanged( const caf::SignalEmitter* emitter,
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::curveAppearanceChanged( const caf::SignalEmitter* emitter )
|
||||
{
|
||||
if ( plotWidget() )
|
||||
{
|
||||
plotWidget()->scheduleReplot();
|
||||
}
|
||||
scheduleReplotIfVisible();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -2651,7 +2667,7 @@ bool RimSummaryPlot::handleGlobalKeyEvent( QKeyEvent* keyEvent )
|
||||
void RimSummaryPlot::onCurveCollectionChanged( const SignalEmitter* emitter )
|
||||
{
|
||||
updateStackedCurveData();
|
||||
if ( plotWidget() ) plotWidget()->scheduleReplot();
|
||||
scheduleReplotIfVisible();
|
||||
|
||||
updateAllRequiredEditors();
|
||||
}
|
||||
@ -2923,7 +2939,7 @@ void RimSummaryPlot::onChildDeleted( caf::PdmChildArrayFieldHandle* childAr
|
||||
|
||||
plotWidget()->pruneAxes( usedPlotAxis );
|
||||
updateAxes();
|
||||
plotWidget()->scheduleReplot();
|
||||
scheduleReplotIfVisible();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,6 +206,7 @@ public:
|
||||
std::vector<RimPlotCurve*> visibleCurvesForLegend() override;
|
||||
|
||||
RimSummaryPlotSourceStepping* sourceStepper();
|
||||
void scheduleReplotIfVisible();
|
||||
|
||||
public:
|
||||
// RimViewWindow overrides
|
||||
|
@ -491,7 +491,7 @@ bool RiuMultiPlotBook::showYAxis( int row, int column ) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotBook::performUpdate( RiaDefines::MultiPlotPageUpdateType whatToUpdate )
|
||||
{
|
||||
if ( !m_plotDefinition || !m_plotDefinition->isValid() ) return;
|
||||
if ( !m_plotDefinition || !m_plotDefinition->isValid() || !m_plotDefinition->showWindow() ) return;
|
||||
|
||||
applyLook();
|
||||
if ( ( ( whatToUpdate & RiaDefines::MultiPlotPageUpdateType::PLOT ) == RiaDefines::MultiPlotPageUpdateType::PLOT ) ||
|
||||
|
@ -108,7 +108,9 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent /*=
|
||||
RiuQwtPlotTools::setCommonPlotBehaviour( m_plotWidget->qwtPlot() );
|
||||
RiuQwtPlotTools::setDefaultAxes( m_plotWidget->qwtPlot() );
|
||||
|
||||
m_plotWidget->setInternalLegendVisible( true );
|
||||
// PERFORMANCE NOTE
|
||||
// Do not set internal legends visible, as this will cause a performance hit.
|
||||
m_plotWidget->setInternalLegendVisible( false );
|
||||
|
||||
m_annotationTool = std::unique_ptr<RiuPlotAnnotationTool>( new RiuPlotAnnotationTool() );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user