mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-24 22:27:55 -05:00
Replace the chain/padlock icon with a simple two-headed-arrow icon (SharedAxis.svg) for linked time/property axes. Add a pinned-range project-tree tag shown when an axis range is user-defined, using the standard gray pinned.svg icon. The tag refreshes immediately regardless of the code path that changes the range/auto-zoom state (Zoom All, data source changes, axis linking, UI edits), and clicking the tag releases the user-defined range so the axis auto-zooms again. Add RicToggleAxisAutoZoomFeature, a checkable context-menu command on Y-axis and time-axis objects that toggles auto-zoom and keeps the pinned/user-defined-range tag in sync in both directions. Move axis-specific context-menu entries out of RimContextCommandBuilder into appendMenuItems() overrides on RimPlotAxisProperties and RimSummaryTimeAxisProperties, per the project convention of keeping object-specific menu logic in the object. Fix RimSummaryPlot::timeAxisSettingsChanged() to actually re-apply auto-scale to the plot widget when auto-zoom is re-enabled on the time axis; previously only the property was updated, and no recompute of the plotted range was triggered.
77 lines
2.8 KiB
C++
77 lines
2.8 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2022- 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 "RicToggleYAxisLinkingFeature.h"
|
|
|
|
#include "RimSummaryMultiPlot.h"
|
|
#include "RimSummaryPlot.h"
|
|
|
|
#include "cafSelectionManagerTools.h"
|
|
|
|
#include <QAction>
|
|
|
|
CAF_CMD_SOURCE_INIT( RicToggleYAxisLinkingFeature, "RicToggleYAxisLinkingFeature" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicToggleYAxisLinkingFeature::isCommandEnabled() const
|
|
{
|
|
auto* summaryMultiPlot = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryMultiPlot>();
|
|
return ( summaryMultiPlot != nullptr );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicToggleYAxisLinkingFeature::onActionTriggered( bool isChecked )
|
|
{
|
|
auto* summaryMultiPlot = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryMultiPlot>();
|
|
if ( !summaryMultiPlot ) return;
|
|
|
|
bool linkedState = summaryMultiPlot->isSubPlotAxesLinked();
|
|
summaryMultiPlot->setSubPlotAxesLinked( !linkedState );
|
|
|
|
for ( auto plot : summaryMultiPlot->summaryPlots() )
|
|
{
|
|
plot->axisChanged.send( plot );
|
|
plot->updateAxes();
|
|
}
|
|
|
|
summaryMultiPlot->updateAllRequiredEditors();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicToggleYAxisLinkingFeature::setupActionLook( QAction* actionToSetup )
|
|
{
|
|
QString text = "Link";
|
|
auto* summaryMultiPlot = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryMultiPlot>();
|
|
if ( summaryMultiPlot )
|
|
{
|
|
if ( summaryMultiPlot->isSubPlotAxesLinked() )
|
|
{
|
|
text = "Unlink";
|
|
}
|
|
}
|
|
|
|
actionToSetup->setText( text + " Y Axis" );
|
|
actionToSetup->setIcon( QIcon( ":/SharedAxis.svg" ) );
|
|
}
|