Skip to content

Commit

Permalink
Performance: Slow performance for some plot and curve operations
Browse files Browse the repository at this point in the history
* Performance: Cache registry value
* Performance: Avoid recursive update
Early return if values are identical
updateConnectedEditors is handled by setValueFromUiEditor
Avoid fieldChanged in analyzePlotsAndAdjustAppearanceSettings
  • Loading branch information
magnesj authored Aug 25, 2023
1 parent d198dc8 commit 3800246
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 13 deletions.
10 changes: 8 additions & 2 deletions ApplicationLibCode/Application/RiaApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,14 @@ const char* RiaApplication::getVersionStringApp( bool includeCrtInfo )
//--------------------------------------------------------------------------------------------------
bool RiaApplication::enableDevelopmentFeatures()
{
QString environmentVar = QProcessEnvironment::systemEnvironment().value( "RESINSIGHT_DEVEL", QString( "0" ) );
return environmentVar.toInt() == 1;
static int envValue = -999;
if ( envValue == -999 )
{
QString environmentVar = QProcessEnvironment::systemEnvironment().value( "RESINSIGHT_DEVEL", QString( "0" ) );
envValue = environmentVar.toInt();
}

return envValue == 1;
}

//--------------------------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,11 +648,11 @@ void RimPlotAxisProperties::setMajorTickmarkCount( LegendTickmarkCount count )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisProperties::setAutoValueForMajorTickmarkCount( LegendTickmarkCount count )
void RimPlotAxisProperties::setAutoValueForMajorTickmarkCount( LegendTickmarkCount count, bool notifyFieldChanged )
{
auto enumValue = static_cast<std::underlying_type_t<LegendTickmarkCount>>( count );

m_majorTickmarkCount.uiCapability()->setAutoValue( enumValue );
m_majorTickmarkCount.uiCapability()->setAutoValue( enumValue, notifyFieldChanged );
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class RimPlotAxisProperties : public RimPlotAxisPropertiesInterface

LegendTickmarkCount majorTickmarkCount() const override;
void setMajorTickmarkCount( LegendTickmarkCount count ) override;
void setAutoValueForMajorTickmarkCount( LegendTickmarkCount count );
void setAutoValueForMajorTickmarkCount( LegendTickmarkCount count, bool notifyFieldChanged );
void enableAutoValueForMajorTickmarkCount( bool enable );

void enableAutoValueForAllFields( bool enable );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1269,14 +1269,16 @@ void RimSummaryMultiPlot::analyzePlotsAndAdjustAppearanceSettings()

bool canShowOneAxisTitlePerRow = analyzer.isSingleQuantityIgnoreHistory() && ( m_axisRangeAggregation() != AxisRangeAggregation::NONE );

const bool notifyFieldChanged = false;

for ( auto p : summaryPlots() )
{
auto timeAxisProp = p->timeAxisProperties();

auto tickMarkCount = ( columnCount() < 3 ) ? RimPlotAxisProperties::LegendTickmarkCount::TICKMARK_DEFAULT
: RimPlotAxisProperties::LegendTickmarkCount::TICKMARK_FEW;

timeAxisProp->setAutoValueForMajorTickmarkCount( tickMarkCount );
timeAxisProp->setAutoValueForMajorTickmarkCount( tickMarkCount, notifyFieldChanged );

for ( auto* axisProp : p->plotYAxes() )
{
Expand All @@ -1285,7 +1287,7 @@ void RimSummaryMultiPlot::analyzePlotsAndAdjustAppearanceSettings()
auto tickMarkCount = ( rowsPerPage() == 1 ) ? RimPlotAxisProperties::LegendTickmarkCount::TICKMARK_DEFAULT
: RimPlotAxisProperties::LegendTickmarkCount::TICKMARK_FEW;

axisProp->setAutoValueForMajorTickmarkCount( tickMarkCount );
axisProp->setAutoValueForMajorTickmarkCount( tickMarkCount, notifyFieldChanged );

axisProp->computeAndSetAutoValueForScaleFactor();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1924,8 +1924,6 @@ void RimSummaryPlot::updateZoomFromParentPlot()

axisProperties->setVisibleRangeMax( axisMax );
axisProperties->setVisibleRangeMin( axisMin );

axisProperties->updateConnectedEditors();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,11 @@ void RimSummaryTimeAxisProperties::setMajorTickmarkCount( LegendTickmarkCount co
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryTimeAxisProperties::setAutoValueForMajorTickmarkCount( LegendTickmarkCount count )
void RimSummaryTimeAxisProperties::setAutoValueForMajorTickmarkCount( LegendTickmarkCount count, bool notifyFieldChanged )
{
auto enumValue = static_cast<std::underlying_type_t<LegendTickmarkCount>>( count );

m_majorTickmarkCount.uiCapability()->setAutoValue( enumValue );
m_majorTickmarkCount.uiCapability()->setAutoValue( enumValue, notifyFieldChanged );
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class RimSummaryTimeAxisProperties : public RimPlotAxisPropertiesInterface

LegendTickmarkCount majorTickmarkCount() const override;
void setMajorTickmarkCount( LegendTickmarkCount count ) override;
void setAutoValueForMajorTickmarkCount( LegendTickmarkCount count );
void setAutoValueForMajorTickmarkCount( LegendTickmarkCount count, bool notifyFieldChanged );
void enableAutoValueForMajorTickmarkCount( bool enable );

const QString objectName() const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ void PdmUiFieldHandle::enableAndSetAutoValue( const QVariant& autoValue )
//--------------------------------------------------------------------------------------------------
void PdmUiFieldHandle::setAutoValue( const QVariant& autoValue, bool notifyFieldChanged )
{
if ( m_autoValue == autoValue ) return;

m_autoValue = autoValue;

applyAutoValueAndUpdateEditors( notifyFieldChanged );
Expand Down Expand Up @@ -257,7 +259,6 @@ void PdmUiFieldHandle::applyAutoValueAndUpdateEditors( bool notifyFieldChanged )
if ( m_useAutoValue && m_autoValue.isValid() )
{
setValueFromUiEditor( m_autoValue, notifyFieldChanged );
updateConnectedEditors();
}
}

Expand Down

0 comments on commit 3800246

Please sign in to comment.