diff --git a/ApplicationLibCode/ProjectDataModel/RimPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimPlot.cpp index 4759dde0f2..6ac0f39dbb 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPlot.cpp @@ -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(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimPlot.h b/ApplicationLibCode/ProjectDataModel/RimPlot.h index c0a80e1560..cbbd4b365d 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlot.h +++ b/ApplicationLibCode/ProjectDataModel/RimPlot.h @@ -108,6 +108,8 @@ public: virtual std::any valueForKey( std::string key ) const; + virtual void zoomAllForMultiPlot(); + protected: virtual RiuPlotWidget* doCreatePlotViewWidget( QWidget* parent ) = 0; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp index 827458696a..deb6fb7359 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp @@ -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(); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.h index 57f0001c2e..0b957899b2 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.h @@ -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 ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index be3f3e65da..c12a2bd557 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -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() ) + { + multiPlot->zoomAll(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -2625,8 +2635,6 @@ void RimSummaryPlot::onPlotZoomed() p->enableAutoValueMinMax( false ); } - plotZoomedByUser.send(); - updateAxisRangesFromPlotWidget(); timeAxisSettingsChanged( nullptr ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h index e054e7e57b..4e4a853f38 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -83,7 +83,6 @@ class RimSummaryPlot : public RimPlot, public RimSummaryDataSourceStepping public: caf::Signal<> curvesChanged; caf::Signal axisChanged; - caf::Signal<> plotZoomedByUser; caf::Signal<> titleChanged; caf::Signal axisChangedReloadRequired; caf::Signal autoTitleChanged; @@ -224,6 +223,8 @@ public: caf::PdmFieldHandle* userDescriptionField() override; + void zoomAllForMultiPlot() override; + private: RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override; diff --git a/ApplicationLibCode/UserInterface/RiuQwtPlotWidget.cpp b/ApplicationLibCode/UserInterface/RiuQwtPlotWidget.cpp index a7b0bb9a38..4271a4c1be 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtPlotWidget.cpp +++ b/ApplicationLibCode/UserInterface/RiuQwtPlotWidget.cpp @@ -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; }