From 3a12c3514272ca8d731ed5753621d1e75df6557f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 27 Oct 2023 15:45:15 +0200 Subject: [PATCH] Use a time based summary plot as source for time axis linking If a summary plot is created with a cross plot curve, the time axis object might not be configured. Always use a time based summary plot as source for linking of time axis. --- .../Summary/RimSummaryMultiPlot.cpp | 27 ++++++++++++++----- .../Summary/RimSummaryMultiPlot.h | 2 +- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp index 3947ddc59c..3dccfeb4c4 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp @@ -456,7 +456,7 @@ void RimSummaryMultiPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedFi } else if ( changedField == &m_linkTimeAxis ) { - updateTimeAxisRangesFromFirstPlot(); + updateTimeAxisRangesFromFirstTimePlot(); } else if ( changedField == &m_linkSubPlotAxes || changedField == &m_axisRangeAggregation || changedField == &m_linkTimeAxis ) { @@ -760,7 +760,7 @@ void RimSummaryMultiPlot::zoomAll() updateZoom(); - updateTimeAxisRangesFromFirstPlot(); + updateTimeAxisRangesFromFirstTimePlot(); return; } @@ -770,18 +770,31 @@ void RimSummaryMultiPlot::zoomAll() syncAxisRanges(); - updateTimeAxisRangesFromFirstPlot(); + updateTimeAxisRangesFromFirstTimePlot(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryMultiPlot::updateTimeAxisRangesFromFirstPlot() +void RimSummaryMultiPlot::updateTimeAxisRangesFromFirstTimePlot() { - if ( m_linkTimeAxis && !summaryPlots().empty() ) + if ( m_linkTimeAxis ) { - setAutoScaleXEnabled( false ); - syncTimeAxisRanges( summaryPlots().front() ); + auto allPlots = summaryPlots(); + for ( auto plot : allPlots ) + { + auto curves = plot->summaryAndEnsembleCurves(); + for ( auto curve : curves ) + { + if ( curve->axisTypeX() == RiaDefines::HorizontalAxisType::TIME ) + { + setAutoScaleXEnabled( false ); + syncTimeAxisRanges( plot ); + + return; + } + } + } } } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.h index a36d17f1bd..ec16511e61 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.h @@ -148,7 +148,7 @@ class RimSummaryMultiPlot : public RimMultiPlot, public RimSummaryDataSourceStep void onSubPlotAxisReloadRequired( const caf::SignalEmitter* emitter, RimSummaryPlot* summaryPlot ); void onSubPlotAutoTitleChanged( const caf::SignalEmitter* emitter, bool isEnabled ); - void updateTimeAxisRangesFromFirstPlot(); + void updateTimeAxisRangesFromFirstTimePlot(); void updateReadOnlyState();