mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 15:10:22 -05:00
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.
71 lines
2.8 KiB
C++
71 lines
2.8 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2026- Equinor ASA
|
|
//
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
//
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
// for more details.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RicToggleAxisAutoZoomFeature.h"
|
|
|
|
#include "RimPlotAxisPropertiesInterface.h"
|
|
|
|
#include "cafSelectionManagerTools.h"
|
|
|
|
#include <QAction>
|
|
|
|
CAF_CMD_SOURCE_INIT( RicToggleAxisAutoZoomFeature, "RicToggleAxisAutoZoomFeature" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicToggleAxisAutoZoomFeature::isCommandEnabled() const
|
|
{
|
|
auto* axisProperties = caf::firstAncestorOfTypeFromSelectedObject<RimPlotAxisPropertiesInterface>();
|
|
return ( axisProperties != nullptr );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicToggleAxisAutoZoomFeature::onActionTriggered( bool isChecked )
|
|
{
|
|
auto* axisProperties = caf::firstAncestorOfTypeFromSelectedObject<RimPlotAxisPropertiesInterface>();
|
|
if ( !axisProperties ) return;
|
|
|
|
bool enableAutoZoom = !axisProperties->isAutoZoom();
|
|
axisProperties->setAutoZoom( enableAutoZoom );
|
|
|
|
// 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();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicToggleAxisAutoZoomFeature::setupActionLook( QAction* actionToSetup )
|
|
{
|
|
actionToSetup->setText( "Auto Zoom" );
|
|
actionToSetup->setIcon( QIcon( ":/ZoomAll.svg" ) );
|
|
actionToSetup->setCheckable( true );
|
|
|
|
auto* axisProperties = caf::firstAncestorOfTypeFromSelectedObject<RimPlotAxisPropertiesInterface>();
|
|
if ( axisProperties )
|
|
{
|
|
actionToSetup->setChecked( axisProperties->isAutoZoom() );
|
|
}
|
|
}
|