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:
Magne Sjaastad
2022-06-24 16:16:46 +02:00
committed by GitHub
parent 5078f4072f
commit b706192ea3
16 changed files with 133 additions and 69 deletions

View File

@@ -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();
}

View File

@@ -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 );

View File

@@ -117,7 +117,7 @@ void RimEnsembleCurveSetCollection::detachPlotCurves()
{
for ( const auto& curveSet : m_curveSets )
{
curveSet->detachPlotCurves();
curveSet->deletePlotCurves();
}
}

View File

@@ -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 );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -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;

View File

@@ -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();
}
}
}

View File

@@ -206,6 +206,7 @@ public:
std::vector<RimPlotCurve*> visibleCurvesForLegend() override;
RimSummaryPlotSourceStepping* sourceStepper();
void scheduleReplotIfVisible();
public:
// RimViewWindow overrides