mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 07:00:17 -05:00
Improves zoom behavior in multi-plots
Refactors zoom handling in multi-plot scenarios to ensure consistent axis ranges and proper synchronization between subplots, especially when linking subplot axes. Removes direct zoom event handling from subplots and centralizes zoom logic in the multi-plot container. This ensures that the 'Zoom All' operation correctly adjusts the Y-axis ranges based on the configured aggregation method and linked axes settings.
This commit is contained in:
1 parent
dfd89ae8c0
commit
5f0dd58de9
7 files changed
+68
-51
No files matched your search
@@ -308,6 +308,16 @@ std::any RimPlot::valueForKey( std::string key ) const
|
||||
return {};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlot::zoomAllForMultiPlot()
|
||||
{
|
||||
// Default behavior is to call zoomAll() on the current plot. Override this function to find the parent multi plot and do zoomAll(). See
|
||||
// RimSummaryPlot::zoomAllForMultiPlot()
|
||||
zoomAll();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -108,6 +108,8 @@ public:
|
||||
|
||||
virtual std::any valueForKey( std::string key ) const;
|
||||
|
||||
virtual void zoomAllForMultiPlot();
|
||||
|
||||
protected:
|
||||
virtual RiuPlotWidget* doCreatePlotViewWidget( QWidget* parent ) = 0;
|
||||
|
||||
|
||||
@@ -209,7 +209,6 @@ void RimSummaryMultiPlot::insertPlot( RimPlot* plot, size_t index )
|
||||
{
|
||||
sumPlot->axisChanged.connect( this, &RimSummaryMultiPlot::onSubPlotAxisChanged );
|
||||
sumPlot->curvesChanged.connect( this, &RimSummaryMultiPlot::onSubPlotChanged );
|
||||
sumPlot->plotZoomedByUser.connect( this, &RimSummaryMultiPlot::onSubPlotZoomed );
|
||||
sumPlot->titleChanged.connect( this, &RimSummaryMultiPlot::onSubPlotChanged );
|
||||
sumPlot->axisChangedReloadRequired.connect( this, &RimSummaryMultiPlot::onSubPlotAxisReloadRequired );
|
||||
sumPlot->autoTitleChanged.connect( this, &RimSummaryMultiPlot::onSubPlotAutoTitleChanged );
|
||||
@@ -450,7 +449,20 @@ void RimSummaryMultiPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
|
||||
{
|
||||
updateTimeAxisRangesFromFirstTimePlot();
|
||||
}
|
||||
else if ( changedField == &m_linkSubPlotAxes || changedField == &m_axisRangeAggregation || changedField == &m_linkTimeAxis )
|
||||
else if ( changedField == &m_linkSubPlotAxes )
|
||||
{
|
||||
if ( m_linkSubPlotAxes() )
|
||||
{
|
||||
// Set the range aggregation to all sub plots when linking. This will ensure that the ZoomAll operation works on all sub plots.
|
||||
m_axisRangeAggregation = AxisRangeAggregation::SUB_PLOTS;
|
||||
}
|
||||
|
||||
setAutoValueStates();
|
||||
syncAxisRanges();
|
||||
analyzePlotsAndAdjustAppearanceSettings();
|
||||
zoomAll();
|
||||
}
|
||||
else if ( changedField == &m_axisRangeAggregation )
|
||||
{
|
||||
setAutoValueStates();
|
||||
syncAxisRanges();
|
||||
@@ -726,7 +738,6 @@ void RimSummaryMultiPlot::initAfterRead()
|
||||
{
|
||||
plot->axisChanged.connect( this, &RimSummaryMultiPlot::onSubPlotAxisChanged );
|
||||
plot->curvesChanged.connect( this, &RimSummaryMultiPlot::onSubPlotChanged );
|
||||
plot->plotZoomedByUser.connect( this, &RimSummaryMultiPlot::onSubPlotZoomed );
|
||||
plot->titleChanged.connect( this, &RimSummaryMultiPlot::onSubPlotChanged );
|
||||
plot->axisChangedReloadRequired.connect( this, &RimSummaryMultiPlot::onSubPlotAxisReloadRequired );
|
||||
plot->autoTitleChanged.connect( this, &RimSummaryMultiPlot::onSubPlotAutoTitleChanged );
|
||||
@@ -742,7 +753,10 @@ void RimSummaryMultiPlot::onLoadDataAndUpdate()
|
||||
RimMultiPlot::onLoadDataAndUpdate();
|
||||
updatePlotTitles();
|
||||
|
||||
analyzePlotsAndAdjustAppearanceSettings();
|
||||
for ( auto p : summaryPlots() )
|
||||
{
|
||||
p->updateAxes();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -752,6 +766,13 @@ void RimSummaryMultiPlot::zoomAll()
|
||||
{
|
||||
setAutoValueStates();
|
||||
|
||||
// Reset zoom to make sure the complete range for min/max is available
|
||||
RimMultiPlot::zoomAll();
|
||||
|
||||
syncAxisRanges();
|
||||
|
||||
updateTimeAxisRangesFromFirstTimePlot();
|
||||
|
||||
if ( m_linkSubPlotAxes() )
|
||||
{
|
||||
// Disable auto scaling for Y axis, use the axis values from the first plot
|
||||
@@ -761,20 +782,7 @@ void RimSummaryMultiPlot::zoomAll()
|
||||
{
|
||||
onSubPlotAxisChanged( nullptr, summaryPlots().front() );
|
||||
}
|
||||
|
||||
updateZoom();
|
||||
|
||||
updateTimeAxisRangesFromFirstTimePlot();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset zoom to make sure the complete range for min/max is available
|
||||
RimMultiPlot::zoomAll();
|
||||
|
||||
syncAxisRanges();
|
||||
|
||||
updateTimeAxisRangesFromFirstTimePlot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -865,7 +873,7 @@ void RimSummaryMultiPlot::setDefaultRangeAggregationSteppingDimension()
|
||||
// have now changed the default setting to use visible subplots to determine the y-range aggregation.
|
||||
// https://github.com/OPM/ResInsight/issues/10543
|
||||
|
||||
m_axisRangeAggregation = AxisRangeAggregation::SUB_PLOTS;
|
||||
m_axisRangeAggregation = AxisRangeAggregation::NONE;
|
||||
|
||||
setAutoValueStates();
|
||||
}
|
||||
@@ -875,11 +883,6 @@ void RimSummaryMultiPlot::setDefaultRangeAggregationSteppingDimension()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryMultiPlot::syncAxisRanges()
|
||||
{
|
||||
if ( m_linkSubPlotAxes() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_axisRangeAggregation() == AxisRangeAggregation::NONE )
|
||||
{
|
||||
return;
|
||||
@@ -1282,8 +1285,11 @@ void RimSummaryMultiPlot::analyzePlotsAndAdjustAppearanceSettings()
|
||||
{
|
||||
if ( m_autoAdjustAppearance )
|
||||
{
|
||||
// Required to sync axis ranges before computing the auto scale
|
||||
syncAxisRanges();
|
||||
if ( !m_linkSubPlotAxes )
|
||||
{
|
||||
// Required to sync axis ranges before computing the auto scale
|
||||
syncAxisRanges();
|
||||
}
|
||||
|
||||
RiaSummaryAddressAnalyzer analyzer;
|
||||
|
||||
@@ -1410,14 +1416,6 @@ void RimSummaryMultiPlot::onSubPlotChanged( const caf::SignalEmitter* emitter )
|
||||
applyPlotWindowTitleToWidgets();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryMultiPlot::onSubPlotZoomed( const caf::SignalEmitter* emitter )
|
||||
{
|
||||
m_axisRangeAggregation = AxisRangeAggregation::NONE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1425,22 +1423,21 @@ void RimSummaryMultiPlot::onSubPlotAxisChanged( const caf::SignalEmitter* emitte
|
||||
{
|
||||
syncTimeAxisRanges( summaryPlot );
|
||||
|
||||
if ( !m_linkSubPlotAxes() )
|
||||
if ( m_linkSubPlotAxes() )
|
||||
{
|
||||
syncAxisRanges();
|
||||
return;
|
||||
}
|
||||
|
||||
for ( auto plot : summaryPlots() )
|
||||
{
|
||||
if ( plot != summaryPlot )
|
||||
for ( auto plot : summaryPlots() )
|
||||
{
|
||||
plot->copyMatchingAxisPropertiesFromOther( *summaryPlot );
|
||||
plot->updateAll();
|
||||
if ( plot != summaryPlot )
|
||||
{
|
||||
plot->copyMatchingAxisPropertiesFromOther( *summaryPlot );
|
||||
plot->updateAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
syncAxisRanges();
|
||||
else
|
||||
{
|
||||
syncAxisRanges();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -149,7 +149,6 @@ private:
|
||||
void appendCurveByStepping( int direction );
|
||||
|
||||
void onSubPlotChanged( const caf::SignalEmitter* emitter );
|
||||
void onSubPlotZoomed( const caf::SignalEmitter* emitter );
|
||||
void onSubPlotAxisChanged( const caf::SignalEmitter* emitter, RimSummaryPlot* summaryPlot );
|
||||
void onSubPlotAxisReloadRequired( const caf::SignalEmitter* emitter, RimSummaryPlot* summaryPlot );
|
||||
void onSubPlotAutoTitleChanged( const caf::SignalEmitter* emitter, bool isEnabled );
|
||||
|
||||
@@ -118,7 +118,6 @@ struct RimSummaryPlot::CurveInfo
|
||||
RimSummaryPlot::RimSummaryPlot()
|
||||
: curvesChanged( this )
|
||||
, axisChanged( this )
|
||||
, plotZoomedByUser( this )
|
||||
, titleChanged( this )
|
||||
, m_isValid( true )
|
||||
, axisChangedReloadRequired( this )
|
||||
@@ -1608,6 +1607,17 @@ caf::PdmFieldHandle* RimSummaryPlot::userDescriptionField()
|
||||
return &m_description;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::zoomAllForMultiPlot()
|
||||
{
|
||||
if ( auto multiPlot = firstAncestorOrThisOfType<RimMultiPlot>() )
|
||||
{
|
||||
multiPlot->zoomAll();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -2625,8 +2635,6 @@ void RimSummaryPlot::onPlotZoomed()
|
||||
p->enableAutoValueMinMax( false );
|
||||
}
|
||||
|
||||
plotZoomedByUser.send();
|
||||
|
||||
updateAxisRangesFromPlotWidget();
|
||||
|
||||
timeAxisSettingsChanged( nullptr );
|
||||
|
||||
@@ -83,7 +83,6 @@ class RimSummaryPlot : public RimPlot, public RimSummaryDataSourceStepping
|
||||
public:
|
||||
caf::Signal<> curvesChanged;
|
||||
caf::Signal<RimSummaryPlot*> axisChanged;
|
||||
caf::Signal<> plotZoomedByUser;
|
||||
caf::Signal<> titleChanged;
|
||||
caf::Signal<RimSummaryPlot*> axisChangedReloadRequired;
|
||||
caf::Signal<bool> autoTitleChanged;
|
||||
@@ -224,6 +223,8 @@ public:
|
||||
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
|
||||
void zoomAllForMultiPlot() override;
|
||||
|
||||
private:
|
||||
RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
|
||||
|
||||
|
||||
@@ -566,7 +566,7 @@ bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event )
|
||||
|
||||
if ( mouseEvent->type() == QMouseEvent::MouseButtonDblClick )
|
||||
{
|
||||
if ( m_plotDefinition ) m_plotDefinition->zoomAll();
|
||||
if ( m_plotDefinition ) m_plotDefinition->zoomAllForMultiPlot();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user