#14539 Schedule tree updates and release user defined axis ranges for all plot types

Axis range and auto-zoom setters now schedule the editor update instead of
performing it immediately. Every immediate update rebuilds the tags of the whole
project tree, and zoom-all releases the range and re-enables auto zoom for every
axis of every subplot. Scheduling also avoids deleting the tag whose clicked
signal is still being emitted from onPinnedTagClicked().

Remove the m_isAutoZoom branches in fieldChangedByUi(). The field is not part of
any UI ordering, and both orderings end with skipRemainingFields(), so the
branches were unreachable. Comments referring to a "Set Range Automatically"
checkbox are updated accordingly.

The pinned tag no longer reuses pinned.svg, which is also the Quick Access dock
icon and must keep following the widget palette. The gray tag variant lives in
PinnedAxisRange.svg.

Zoom All is an explicit request for automatic ranges, but only summary plots
released the user defined range. Histogram, grid cross, VFP and analysis plots
share RimPlotAxisProperties and set the range as user defined when a min or max
is typed, so Zoom All left them with a stale pinned tag and permanently blocked
enableAutoValueMinMax().

Release the range for every axis owned by the window in RimViewWindow instead,
which makes the summary specific overrides redundant.
This commit is contained in:
Magne Sjaastad committed 2026-09-09 12:08:10 +02:00
1 parent 3284fd200a
commit 1fc5e424e4
12 files changed
+29 -67

No files matched your search

@@ -46,9 +46,8 @@ void RicToggleAxisAutoZoomFeature::onActionTriggered( bool isChecked )
bool enableAutoZoom = !axisProperties->isAutoZoom();
axisProperties->setAutoZoom( enableAutoZoom );
// The range is defined by the user unless auto-zoom is (re-)enabled, matching the behavior of the
// "Set Range Automatically" checkbox in the property editor. This also makes sure the pinned tag
// in the project tree is updated to reflect the new state.
// Re-enabling auto zoom releases the user-defined range, so the axis follows the data again. This also updates
// the pinned tag in the project tree.
axisProperties->setRangeUserDefined( !enableAutoZoom );
axisProperties->settingsChanged.send();
@@ -420,9 +420,9 @@ void RimPlotAxisProperties::setAutoZoom( bool enableAutoZoom )
m_isAutoZoom = enableAutoZoom;
// Make sure the project tree tag reflecting the auto-zoom state is updated immediately, also when this method
// is called from code paths other than the UI.
updateConnectedEditors();
// Update the project tree tag reflecting the auto-zoom state. Scheduled for the same reasons as in
// RimPlotAxisPropertiesInterface::setRangeUserDefined().
scheduleUpdateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
@@ -731,10 +731,6 @@ void RimPlotAxisProperties::fieldChangedByUi( const caf::PdmFieldHandle* changed
// The range is defined by the user unless the value comes from the auto value of the field
setRangeUserDefined( !m_visibleRangeMin.uiCapability()->isAutoValueEnabled() );
}
else if ( changedField == &m_isAutoZoom )
{
setRangeUserDefined( !m_isAutoZoom() );
}
if ( changedField == &m_isLogarithmicScaleEnabled )
{
@@ -801,7 +797,7 @@ void RimPlotAxisProperties::defineObjectEditorAttribute( QString uiConfigName, c
// Indicate that the axis range is fixed by the user, and will not be updated by auto-zoom.
// Clicking the tag releases the user-defined range, so the axis follows the data again.
auto tag = caf::PdmUiTreeViewItemAttribute::createTag();
tag->icon = caf::IconProvider( ":/pinned.svg" );
tag->icon = caf::IconProvider( ":/PinnedAxisRange.svg" );
tag->clicked.connect( this, &RimPlotAxisProperties::onPinnedTagClicked );
@@ -814,8 +810,7 @@ void RimPlotAxisProperties::defineObjectEditorAttribute( QString uiConfigName, c
//--------------------------------------------------------------------------------------------------
void RimPlotAxisProperties::onPinnedTagClicked( const caf::SignalEmitter* emitter, size_t index )
{
// Release the user-defined range and let the axis follow the data again, same as re-enabling
// "Set Range Automatically" from the property editor.
// Release the user-defined range and let the axis follow the data again, same as the Auto Zoom command.
setAutoZoom( true );
setRangeUserDefined( false );
settingsChanged.send();
@@ -58,7 +58,7 @@ RimPlotAxisPropertiesInterface::RimPlotAxisPropertiesInterface()
//--------------------------------------------------------------------------------------------------
/// A user defined axis range is kept when the data source of a plot is changed, and is released when the user asks for
/// automatic range computation (Zoom All or "Set Range Automatically").
/// automatic range computation (Zoom All, the Auto Zoom command, or clicking the pinned tag in the project tree).
//--------------------------------------------------------------------------------------------------
bool RimPlotAxisPropertiesInterface::isRangeUserDefined() const
{
@@ -74,10 +74,11 @@ void RimPlotAxisPropertiesInterface::setRangeUserDefined( bool isUserDefined )
m_isRangeUserDefined = isUserDefined;
// Make sure the project tree tag reflecting the range state (see defineObjectEditorAttribute() in derived
// classes) is updated immediately, also when this method is called from code paths other than the UI (e.g.
// zoom-all, data source changes, axis linking).
updateConnectedEditors();
// Update the project tree tag reflecting the range state (see defineObjectEditorAttribute() in derived classes).
// Scheduled rather than immediate: zoom-all and axis linking call this once per axis per subplot, and every
// immediate update rebuilds the tags of the entire project tree. The tag click handler also ends up here, where an
// immediate update would delete the tag whose signal is being emitted.
scheduleUpdateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
@@ -26,6 +26,7 @@
#include "RicfCommandObject.h"
#include "RimDockWindowController.h"
#include "RimPlotAxisPropertiesInterface.h"
#include "RiuDockWidgetTools.h"
@@ -231,6 +232,13 @@ QImage RimViewWindow::snapshotWindowContent()
//--------------------------------------------------------------------------------------------------
void RimViewWindow::zoomAllAndReleaseUserDefinedRanges()
{
// Zoom All is an explicit request for automatic ranges, so release the user defined range of every axis owned by
// this window before zooming. Several plot types share RimPlotAxisProperties, so this is done for all of them.
for ( auto axisProperties : descendantsOfType<RimPlotAxisPropertiesInterface>() )
{
axisProperties->setRangeUserDefined( false );
}
zoomAll();
}
@@ -807,19 +807,6 @@ void RimSummaryMultiPlot::zoomAll()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryMultiPlot::zoomAllAndReleaseUserDefinedRanges()
{
for ( auto p : summaryPlots() )
{
p->releaseUserDefinedAxisRanges();
}
zoomAll();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -98,7 +98,6 @@ public:
std::pair<int, int> gridLayoutInfoForSubPlot( RimSummaryPlot* summaryPlot ) const;
void zoomAll() override;
void zoomAllAndReleaseUserDefinedRanges() override;
void setDefaultRangeAggregationSteppingDimension();
void analyzePlotsAndAdjustAppearanceSettings();
@@ -1404,28 +1404,6 @@ void RimSummaryPlot::zoomAll()
axisChanged.send( this );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::zoomAllAndReleaseUserDefinedRanges()
{
releaseUserDefinedAxisRanges();
zoomAll();
}
//--------------------------------------------------------------------------------------------------
/// Axis ranges defined by the user are kept when the data source of the plot is changed. Release the user defined
/// ranges to make the axes follow the data again.
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::releaseUserDefinedAxisRanges()
{
for ( const auto& ap : m_axisPropertiesArray )
{
ap->setRangeUserDefined( false );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -186,8 +186,6 @@ public:
RiuPlotWidget* plotWidget() override;
RiuSummaryPlot* summaryPlotWidget() const;
void zoomAll() override;
void zoomAllAndReleaseUserDefinedRanges() override;
void releaseUserDefinedAxisRanges();
void updatePlotWidgetFromAxisRanges() override;
void updateAxisRangesFromPlotWidget() override;
@@ -252,7 +252,7 @@ void RimSummaryTimeAxisProperties::defineObjectEditorAttribute( QString uiConfig
// Indicate that the axis range is fixed by the user, and will not be updated by auto-zoom.
// Clicking the tag releases the user-defined range, so the axis follows the data again.
auto tag = caf::PdmUiTreeViewItemAttribute::createTag();
tag->icon = caf::IconProvider( ":/pinned.svg" );
tag->icon = caf::IconProvider( ":/PinnedAxisRange.svg" );
tag->clicked.connect( this, &RimSummaryTimeAxisProperties::onPinnedTagClicked );
@@ -265,8 +265,7 @@ void RimSummaryTimeAxisProperties::defineObjectEditorAttribute( QString uiConfig
//--------------------------------------------------------------------------------------------------
void RimSummaryTimeAxisProperties::onPinnedTagClicked( const caf::SignalEmitter* emitter, size_t index )
{
// Release the user-defined range and let the axis follow the data again, same as re-enabling
// "Set Range Automatically" from the property editor.
// Release the user-defined range and let the axis follow the data again, same as the Auto Zoom command.
setAutoZoom( true );
setRangeUserDefined( false );
settingsChanged.send();
@@ -353,9 +352,9 @@ void RimSummaryTimeAxisProperties::setAutoZoom( bool enableAutoZoom )
m_isAutoZoom = enableAutoZoom;
// Make sure the project tree tag reflecting the auto-zoom state is updated immediately, also when this method
// is called from code paths other than the UI.
updateConnectedEditors();
// Update the project tree tag reflecting the auto-zoom state. Scheduled for the same reasons as in
// RimPlotAxisPropertiesInterface::setRangeUserDefined().
scheduleUpdateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
@@ -1017,10 +1016,6 @@ void RimSummaryTimeAxisProperties::fieldChangedByUi( const caf::PdmFieldHandle*
m_isAutoZoom = false;
setRangeUserDefined( true );
}
else if ( changedField == &m_isAutoZoom )
{
setRangeUserDefined( !m_isAutoZoom() );
}
else if ( changedField == &m_timeMode )
{
if ( m_timeMode() == TimeModeType::TIME_FROM_SIMULATION_START )