mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-24 22:27:55 -05:00
#14539 Summary Plot: Preserve user defined axis ranges when the data source changes
An axis range defined by the user is now kept when a summary case or ensemble is added, reloaded or replaced. The range is marked as user defined when the user edits the min/max values, unchecks "Set Range Automatically" or zooms interactively in the plot. The user defined range is released by "Zoom All", by double click in a plot, by checking "Set Range Automatically" or by changing the Y axis range aggregation of a summary multi plot.
This commit is contained in:
1 parent
f38332b2e6
commit
110bdbe0c7
11 files changed
+121
-7
No files matched your search
@@ -51,7 +51,7 @@ void RicViewZoomAllFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
if ( auto activePlotView = plotMainWin->activeViewer() )
|
||||
{
|
||||
activePlotView->zoomAll();
|
||||
activePlotView->zoomAllAndReleaseUserDefinedRanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,14 +586,14 @@ double RimPlotAxisProperties::visibleRangeMax() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotAxisProperties::enableAutoValueMinMax( bool enable )
|
||||
{
|
||||
// Never replace a range defined by the user by an automatically computed range
|
||||
const bool useAutoValue = enable && !isRangeUserDefined();
|
||||
|
||||
m_visibleRangeMin.uiCapability()->enableAutoValueSupport( enable );
|
||||
m_visibleRangeMax.uiCapability()->enableAutoValueSupport( enable );
|
||||
|
||||
if ( enable )
|
||||
{
|
||||
m_visibleRangeMin.uiCapability()->enableAutoValue( enable );
|
||||
m_visibleRangeMax.uiCapability()->enableAutoValue( enable );
|
||||
}
|
||||
m_visibleRangeMin.uiCapability()->enableAutoValue( useAutoValue );
|
||||
m_visibleRangeMax.uiCapability()->enableAutoValue( useAutoValue );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -711,12 +711,22 @@ void RimPlotAxisProperties::fieldChangedByUi( const caf::PdmFieldHandle* changed
|
||||
if ( m_visibleRangeMin > m_visibleRangeMax ) m_visibleRangeMax = oldValue.toDouble();
|
||||
|
||||
m_isAutoZoom = false;
|
||||
|
||||
// The range is defined by the user unless the value comes from the auto value of the field
|
||||
setRangeUserDefined( !m_visibleRangeMax.uiCapability()->isAutoValueEnabled() );
|
||||
}
|
||||
else if ( changedField == &m_visibleRangeMin )
|
||||
{
|
||||
if ( m_visibleRangeMin > m_visibleRangeMax ) m_visibleRangeMin = oldValue.toDouble();
|
||||
|
||||
m_isAutoZoom = false;
|
||||
|
||||
// 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 )
|
||||
|
||||
@@ -51,6 +51,26 @@ RimPlotAxisPropertiesInterface::RimPlotAxisPropertiesInterface()
|
||||
: settingsChanged( this )
|
||||
{
|
||||
CAF_PDM_InitObject( "Plot Axis Properties Interface" );
|
||||
|
||||
CAF_PDM_InitField( &m_isRangeUserDefined, "IsRangeUserDefined", false, "Is Range Defined by User" );
|
||||
m_isRangeUserDefined.uiCapability()->setUiHidden( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// 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").
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimPlotAxisPropertiesInterface::isRangeUserDefined() const
|
||||
{
|
||||
return m_isRangeUserDefined();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotAxisPropertiesInterface::setRangeUserDefined( bool isUserDefined )
|
||||
{
|
||||
m_isRangeUserDefined = isUserDefined;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -65,6 +65,9 @@ public:
|
||||
virtual bool isAutoZoom() const = 0;
|
||||
virtual void setAutoZoom( bool enableAutoZoom ) = 0;
|
||||
|
||||
bool isRangeUserDefined() const;
|
||||
void setRangeUserDefined( bool isUserDefined );
|
||||
|
||||
virtual bool isActive() const = 0;
|
||||
|
||||
virtual const QString objectName() const = 0;
|
||||
@@ -83,4 +86,7 @@ public:
|
||||
virtual AxisTitlePositionType titlePosition() const = 0;
|
||||
virtual int titleFontSize() const = 0;
|
||||
virtual int valuesFontSize() const = 0;
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_isRangeUserDefined;
|
||||
};
|
||||
@@ -226,6 +226,14 @@ QImage RimViewWindow::snapshotWindowContent()
|
||||
return image;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewWindow::zoomAllAndReleaseUserDefinedRanges()
|
||||
{
|
||||
zoomAll();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -72,6 +72,9 @@ public:
|
||||
virtual QImage snapshotWindowContent();
|
||||
virtual void zoomAll() = 0;
|
||||
|
||||
// Zoom all triggered explicitly by the user. This will also release any axis ranges defined by the user.
|
||||
virtual void zoomAllAndReleaseUserDefinedRanges();
|
||||
|
||||
void viewNavigationChanged();
|
||||
|
||||
virtual void updateWindowTitle();
|
||||
|
||||
@@ -470,6 +470,15 @@ void RimSummaryMultiPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
|
||||
}
|
||||
else if ( changedField == &m_axisRangeAggregation )
|
||||
{
|
||||
// The user has asked for a new computation of the Y axis range, release any user defined ranges
|
||||
for ( auto p : summaryPlots() )
|
||||
{
|
||||
for ( auto axis : p->plotAxes( RimPlotAxisProperties::Orientation::VERTICAL ) )
|
||||
{
|
||||
axis->setRangeUserDefined( false );
|
||||
}
|
||||
}
|
||||
|
||||
setAutoValueStates();
|
||||
syncAxisRanges();
|
||||
analyzePlotsAndAdjustAppearanceSettings();
|
||||
@@ -798,6 +807,19 @@ void RimSummaryMultiPlot::zoomAll()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryMultiPlot::zoomAllAndReleaseUserDefinedRanges()
|
||||
{
|
||||
for ( auto p : summaryPlots() )
|
||||
{
|
||||
p->releaseUserDefinedAxisRanges();
|
||||
}
|
||||
|
||||
zoomAll();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -98,6 +98,7 @@ public:
|
||||
std::pair<int, int> gridLayoutInfoForSubPlot( RimSummaryPlot* summaryPlot ) const;
|
||||
|
||||
void zoomAll() override;
|
||||
void zoomAllAndReleaseUserDefinedRanges() override;
|
||||
|
||||
void setDefaultRangeAggregationSteppingDimension();
|
||||
void analyzePlotsAndAdjustAppearanceSettings();
|
||||
|
||||
@@ -1404,6 +1404,28 @@ 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 );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1602,7 +1624,7 @@ void RimSummaryPlot::zoomAllForMultiPlot()
|
||||
{
|
||||
if ( auto multiPlot = firstAncestorOrThisOfType<RimMultiPlot>() )
|
||||
{
|
||||
multiPlot->zoomAll();
|
||||
multiPlot->zoomAllAndReleaseUserDefinedRanges();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2628,6 +2650,13 @@ void RimSummaryPlot::onPlotZoomed()
|
||||
setAutoScaleXEnabled( false );
|
||||
setAutoScaleYEnabled( false );
|
||||
|
||||
// The user has defined the visible range by interactive zoom, and the range is kept when the data source of the
|
||||
// plot is changed
|
||||
for ( const auto& ap : m_axisPropertiesArray )
|
||||
{
|
||||
ap->setRangeUserDefined( true );
|
||||
}
|
||||
|
||||
// Disable auto value for min/max fields
|
||||
for ( auto p : plotAxes( RimPlotAxisProperties::Orientation::ANY ) )
|
||||
{
|
||||
@@ -2998,6 +3027,8 @@ void RimSummaryPlot::setAutoScaleXEnabled( bool enabled )
|
||||
{
|
||||
if ( ap->plotAxis().axis() == RiaDefines::PlotAxis::PLOT_AXIS_TOP || ap->plotAxis().axis() == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM )
|
||||
{
|
||||
if ( enabled && ap->isRangeUserDefined() ) continue;
|
||||
|
||||
ap->setAutoZoom( enabled );
|
||||
}
|
||||
}
|
||||
@@ -3012,6 +3043,8 @@ void RimSummaryPlot::setAutoScaleYEnabled( bool enabled )
|
||||
{
|
||||
if ( ap->plotAxis().axis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT || ap->plotAxis().axis() == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT )
|
||||
{
|
||||
if ( enabled && ap->isRangeUserDefined() ) continue;
|
||||
|
||||
ap->setAutoZoom( enabled );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,6 +186,8 @@ public:
|
||||
RiuPlotWidget* plotWidget() override;
|
||||
RiuSummaryPlot* summaryPlotWidget() const;
|
||||
void zoomAll() override;
|
||||
void zoomAllAndReleaseUserDefinedRanges() override;
|
||||
void releaseUserDefinedAxisRanges();
|
||||
void updatePlotWidgetFromAxisRanges() override;
|
||||
void updateAxisRangesFromPlotWidget() override;
|
||||
|
||||
|
||||
@@ -932,6 +932,7 @@ void RimSummaryTimeAxisProperties::fieldChangedByUi( const caf::PdmFieldHandle*
|
||||
|
||||
updateTimeVisibleRange();
|
||||
m_isAutoZoom = false;
|
||||
setRangeUserDefined( true );
|
||||
}
|
||||
else if ( changedField == &m_visibleTimeRangeMax )
|
||||
{
|
||||
@@ -943,6 +944,7 @@ void RimSummaryTimeAxisProperties::fieldChangedByUi( const caf::PdmFieldHandle*
|
||||
|
||||
updateTimeVisibleRange();
|
||||
m_isAutoZoom = false;
|
||||
setRangeUserDefined( true );
|
||||
}
|
||||
else if ( changedField == &m_visibleDateRangeMin )
|
||||
{
|
||||
@@ -954,6 +956,7 @@ void RimSummaryTimeAxisProperties::fieldChangedByUi( const caf::PdmFieldHandle*
|
||||
|
||||
updateTimeVisibleRange();
|
||||
m_isAutoZoom = false;
|
||||
setRangeUserDefined( true );
|
||||
}
|
||||
else if ( changedField == &m_visibleTimeRangeMin )
|
||||
{
|
||||
@@ -965,11 +968,17 @@ void RimSummaryTimeAxisProperties::fieldChangedByUi( const caf::PdmFieldHandle*
|
||||
|
||||
updateTimeVisibleRange();
|
||||
m_isAutoZoom = false;
|
||||
setRangeUserDefined( true );
|
||||
}
|
||||
else if ( changedField == &m_visibleTimeSinceStartRangeMin || changedField == &m_visibleTimeSinceStartRangeMax )
|
||||
{
|
||||
updateDateVisibleRange();
|
||||
m_isAutoZoom = false;
|
||||
setRangeUserDefined( true );
|
||||
}
|
||||
else if ( changedField == &m_isAutoZoom )
|
||||
{
|
||||
setRangeUserDefined( !m_isAutoZoom() );
|
||||
}
|
||||
else if ( changedField == &m_timeMode )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user