From 5d4286371609f897ea1b6d236b4da32a93963543 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 25 Sep 2023 16:00:44 +0200 Subject: [PATCH 01/11] Verify vector size only for cross plot regression curves --- .../RimSummaryRegressionAnalysisCurve.cpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.cpp index e64cc7fb0b..5df22e404a 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.cpp @@ -123,19 +123,19 @@ void RimSummaryRegressionAnalysisCurve::onLoadDataAndUpdate( bool updateParentPl auto timeStepsX = RimSummaryCurve::timeStepsX(); auto timeStepsY = RimSummaryCurve::timeStepsY(); - if ( xValues.size() != yValues.size() ) return RiaLogging::error( "X value count and Y value count differs." ); - if ( xValues.size() != timeStepsX.size() ) return RiaLogging::error( "X value count and X time step count differs." ); - if ( xValues.size() != timeStepsY.size() ) return RiaLogging::error( "X value count and Y time step count differs." ); - - if ( timeStepsX != timeStepsY ) - { - return RiaLogging::error( - "Differences in time steps for X and Y axis detected. This is currently not supported. Make sure that the same " - "case is used for both axis." ); - } - if ( axisTypeX() == RiaDefines::HorizontalAxisType::SUMMARY_VECTOR ) { + if ( xValues.size() != yValues.size() ) return RiaLogging::error( "X value count and Y value count differs." ); + if ( xValues.size() != timeStepsX.size() ) return RiaLogging::error( "X value count and X time step count differs." ); + if ( xValues.size() != timeStepsY.size() ) return RiaLogging::error( "X value count and Y time step count differs." ); + + if ( timeStepsX != timeStepsY ) + { + return RiaLogging::error( + "Differences in time steps for X and Y axis detected. This is currently not supported. Make sure that the same " + "case is used for both axis." ); + } + // NB! Assume that time stamps for X and Y are the same std::vector indicesToRemove; From 0abdce2977114e620b0790211722029a73471b72 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 26 Sep 2023 07:12:59 +0200 Subject: [PATCH 02/11] Add filtering on axis orientation Makes it possible to show only horizontal or vertical axes when selecting an axis to attach a curve to. --- .../ProjectDataModel/RimPlotAxisProperties.h | 7 ++++ .../Summary/RimEnsembleCurveSet.cpp | 23 ++++++------- .../Summary/RimEnsembleCurveSet.h | 2 +- .../Summary/RimSummaryAddressSelector.cpp | 15 +++++++-- .../Summary/RimSummaryAddressSelector.h | 5 +++ .../Summary/RimSummaryCurve.cpp | 10 ++---- .../Summary/RimSummaryMultiPlot.cpp | 20 +++++------ .../Summary/RimSummaryPlot.cpp | 33 ++++++++++--------- .../ProjectDataModel/Summary/RimSummaryPlot.h | 6 ++-- 9 files changed, 69 insertions(+), 52 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.h b/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.h index dc9acacd7a..bfde0844d8 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.h +++ b/ApplicationLibCode/ProjectDataModel/RimPlotAxisProperties.h @@ -50,6 +50,13 @@ class RimPlotAxisProperties : public RimPlotAxisPropertiesInterface NUMBER_FORMAT_SCIENTIFIC }; + enum class Orientation + { + HORIZONTAL, + VERTICAL, + ANY + }; + public: caf::Signal logarithmicChanged; caf::Signal axisPositionChanged; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 5aacf58197..71501f8d82 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -147,6 +147,7 @@ RimEnsembleCurveSet::RimEnsembleCurveSet() CAF_PDM_InitFieldNoDefault( &m_xAddressSelector, "XAddressSelector", "" ); m_xAddressSelector = new RimSummaryAddressSelector; + m_xAddressSelector->setAxisOrientation( RimPlotAxisProperties::Orientation::HORIZONTAL ); m_xAddressSelector.uiCapability()->setUiTreeHidden( true ); m_xAddressSelector.uiCapability()->setUiTreeChildrenHidden( true ); @@ -203,7 +204,7 @@ RimEnsembleCurveSet::RimEnsembleCurveSet() CAF_PDM_InitFieldNoDefault( &m_plotAxis_OBSOLETE, "PlotAxis", "Axis" ); m_plotAxis_OBSOLETE.xmlCapability()->setIOWritable( false ); - CAF_PDM_InitFieldNoDefault( &m_plotAxisProperties, "Axis", "Axis" ); + CAF_PDM_InitFieldNoDefault( &m_yPlotAxisProperties, "Axis", "Axis" ); CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendConfig", "" ); m_legendConfig = new RimRegularLegendConfig(); @@ -853,7 +854,7 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi updateCurveColors(); updateTimeAnnotations(); } - else if ( changedField == &m_plotAxisProperties ) + else if ( changedField == &m_yPlotAxisProperties ) { for ( RimSummaryCurve* curve : curves() ) { @@ -1000,7 +1001,7 @@ void RimEnsembleCurveSet::defineUiOrdering( QString uiConfigName, caf::PdmUiOrde curveDataGroup->add( &m_yValuesSummaryAddressUiField ); curveDataGroup->add( &m_yPushButtonSelectSummaryAddress, { false, 1, 0 } ); curveDataGroup->add( &m_resampling ); - curveDataGroup->add( &m_plotAxisProperties ); + curveDataGroup->add( &m_yPlotAxisProperties ); } { @@ -1431,10 +1432,10 @@ QList RimEnsembleCurveSet::calculateValueOptions( const options.push_back( caf::PdmOptionItemInfo( name, objFunc ) ); } } - else if ( fieldNeedingOptions == &m_plotAxisProperties ) + else if ( fieldNeedingOptions == &m_yPlotAxisProperties ) { auto plot = firstAncestorOrThisOfTypeAsserted(); - for ( auto axis : plot->plotAxes() ) + for ( auto axis : plot->plotAxes( RimPlotAxisProperties::Orientation::VERTICAL ) ) { options.push_back( caf::PdmOptionItemInfo( axis->objectName(), axis ) ); } @@ -2391,8 +2392,8 @@ int statisticsCurveSymbolSize( RiuPlotCurveSymbol::PointSymbolEnum symbol ) //-------------------------------------------------------------------------------------------------- RiuPlotAxis RimEnsembleCurveSet::axisY() const { - if ( m_plotAxisProperties ) - return m_plotAxisProperties->plotAxis(); + if ( m_yPlotAxisProperties ) + return m_yPlotAxisProperties->plotAxis(); else return RiuPlotAxis::defaultLeft(); } @@ -2402,8 +2403,8 @@ RiuPlotAxis RimEnsembleCurveSet::axisY() const //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSet::setLeftOrRightAxisY( RiuPlotAxis plotAxis ) { - auto plot = firstAncestorOrThisOfTypeAsserted(); - m_plotAxisProperties = plot->axisPropertiesForPlotAxis( plotAxis ); + auto plot = firstAncestorOrThisOfTypeAsserted(); + m_yPlotAxisProperties = plot->axisPropertiesForPlotAxis( plotAxis ); for ( RimSummaryCurve* curve : curves() ) { @@ -2416,12 +2417,12 @@ void RimEnsembleCurveSet::setLeftOrRightAxisY( RiuPlotAxis plotAxis ) //-------------------------------------------------------------------------------------------------- void RimEnsembleCurveSet::initAfterRead() { - if ( m_plotAxisProperties.value() == nullptr ) + if ( m_yPlotAxisProperties.value() == nullptr ) { auto plot = firstAncestorOrThisOfType(); if ( plot ) { - m_plotAxisProperties = plot->axisPropertiesForPlotAxis( RiuPlotAxis( m_plotAxis_OBSOLETE() ) ); + m_yPlotAxisProperties = plot->axisPropertiesForPlotAxis( RiuPlotAxis( m_plotAxis_OBSOLETE() ) ); } } } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index ce41861608..8fd4823bed 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -261,7 +261,7 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt caf::PdmField> m_selectedTimeSteps; caf::PdmField> m_plotAxis_OBSOLETE; - caf::PdmPtrField m_plotAxisProperties; + caf::PdmPtrField m_yPlotAxisProperties; caf::PdmChildField m_legendConfig; caf::PdmChildField m_curveFilters; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp index c4e5a10cf7..e4a683877b 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp @@ -72,8 +72,9 @@ RimSummaryAddressSelector::RimSummaryAddressSelector() CAF_PDM_InitFieldNoDefault( &m_resamplingPeriod, "Resampling", "Resampling" ); - m_dataSource = SummaryDataSource::SINGLE_CASE; - m_showDataSource = true; + m_dataSource = SummaryDataSource::SINGLE_CASE; + m_showDataSource = true; + m_plotAxisOrientation = RimPlotAxisProperties::Orientation::ANY; } //-------------------------------------------------------------------------------------------------- @@ -126,6 +127,14 @@ void RimSummaryAddressSelector::setShowDataSource( bool enable ) m_showDataSource = enable; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressSelector::setAxisOrientation( RimPlotAxisProperties::Orientation orientation ) +{ + m_plotAxisOrientation = orientation; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -304,7 +313,7 @@ QList RimSummaryAddressSelector::calculateValueOptions( if ( auto plot = firstAncestorOrThisOfTypeAsserted() ) { QList options; - for ( auto axis : plot->plotAxes() ) + for ( auto axis : plot->plotAxes( m_plotAxisOrientation ) ) { options.push_back( caf::PdmOptionItemInfo( axis->objectName(), axis ) ); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h index e3270471a8..f7fb4622c9 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h @@ -23,6 +23,8 @@ #include "RifEclipseSummaryAddress.h" #include "RifEclipseSummaryAddressQMetaType.h" +#include "RimPlotAxisProperties.h" + #include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" @@ -55,6 +57,7 @@ class RimSummaryAddressSelector : public caf::PdmObject void setResamplingPeriod( RiaDefines::DateTimePeriodEnum resampling ); void setPlotAxisProperties( RimPlotAxisPropertiesInterface* plotAxisProperties ); void setShowDataSource( bool enable ); + void setAxisOrientation( RimPlotAxisProperties::Orientation orientation ); RimSummaryCase* summaryCase() const; RimSummaryCaseCollection* ensemble() const; @@ -79,4 +82,6 @@ class RimSummaryAddressSelector : public caf::PdmObject SummaryDataSource m_dataSource; bool m_showDataSource; + + RimPlotAxisProperties::Orientation m_plotAxisOrientation; }; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index 6f7891bd7a..c7e571195d 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -551,20 +551,16 @@ QList RimSummaryCurve::calculateValueOptions( const caf: { auto plot = firstAncestorOrThisOfTypeAsserted(); - for ( auto axis : plot->plotAxes() ) + for ( auto axis : plot->plotAxes( RimPlotAxisProperties::Orientation::VERTICAL ) ) { - // TODO: Should we allow time axis to be used as Y axis? - if ( dynamic_cast( axis ) ) - { - options.push_back( caf::PdmOptionItemInfo( axis->objectName(), axis ) ); - } + options.push_back( caf::PdmOptionItemInfo( axis->objectName(), axis ) ); } } else if ( fieldNeedingOptions == &m_xPlotAxisProperties ) { auto plot = firstAncestorOrThisOfTypeAsserted(); - for ( auto axis : plot->plotAxes() ) + for ( auto axis : plot->plotAxes( RimPlotAxisProperties::Orientation::HORIZONTAL ) ) { options.push_back( caf::PdmOptionItemInfo( axis->objectName(), axis ) ); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp index d3c5ceab67..9007522c4d 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp @@ -864,7 +864,7 @@ void RimSummaryMultiPlot::syncAxisRanges() for ( auto p : summaryPlots() ) { - for ( auto ax : p->plotYAxes() ) + for ( auto ax : p->plotAxes( RimPlotAxisProperties::Orientation::ANY ) ) { ax->setAutoZoomIfNoCustomRangeIsSet(); } @@ -878,7 +878,7 @@ void RimSummaryMultiPlot::syncAxisRanges() // gather current min/max values for each category (axis label) for ( auto plot : summaryPlots() ) { - for ( auto axis : plot->plotYAxes() ) + for ( auto axis : plot->plotAxes( RimPlotAxisProperties::Orientation::ANY ) ) { double minVal = axis->visibleRangeMin(); double maxVal = axis->visibleRangeMax(); @@ -900,7 +900,7 @@ void RimSummaryMultiPlot::syncAxisRanges() // set all plots to use the global min/max values for each category for ( auto plot : summaryPlots() ) { - for ( auto axis : plot->plotYAxes() ) + for ( auto axis : plot->plotAxes( RimPlotAxisProperties::Orientation::ANY ) ) { auto [minVal, maxVal] = axisRanges[axis->objectName()]; if ( axis->isAxisInverted() ) std::swap( minVal, maxVal ); @@ -1080,7 +1080,7 @@ void RimSummaryMultiPlot::computeAggregatedAxisRange() { std::map> axisRanges; - for ( auto axis : plot->plotYAxes() ) + for ( auto axis : plot->plotAxes( RimPlotAxisProperties::Orientation::ANY ) ) { for ( auto curve : plot->summaryCurves() ) { @@ -1146,7 +1146,7 @@ void RimSummaryMultiPlot::computeAggregatedAxisRange() } // set all plots to use the global min/max values for each category - for ( auto axis : plot->plotYAxes() ) + for ( auto axis : plot->plotAxes( RimPlotAxisProperties::Orientation::ANY ) ) { auto [minVal, maxVal] = axisRanges[axis->plotAxis()]; if ( RiaDefines::isVertical( axis->plotAxis().axis() ) && !std::isinf( minVal ) && !std::isinf( maxVal ) ) @@ -1215,7 +1215,7 @@ void RimSummaryMultiPlot::setAutoValueStatesForPlot( RimSummaryPlot* summaryPlot auto timeAxisProp = summaryPlot->timeAxisProperties(); if ( timeAxisProp ) timeAxisProp->enableAutoValueForMajorTickmarkCount( enableAutoValueAppearance ); - for ( auto plotAxis : summaryPlot->plotYAxes() ) + for ( auto plotAxis : summaryPlot->plotAxes( RimPlotAxisProperties::Orientation::ANY ) ) { plotAxis->enableAutoValueMinMax( enableAutoValueMinMax ); plotAxis->enableAutoValueForMajorTickmarkCount( enableAutoValueAppearance ); @@ -1281,10 +1281,8 @@ void RimSummaryMultiPlot::analyzePlotsAndAdjustAppearanceSettings() timeAxisProp->setAutoValueForMajorTickmarkCount( tickMarkCount, notifyFieldChanged ); } - for ( auto* axisProp : p->plotYAxes() ) + for ( auto* axisProp : p->plotAxes( RimPlotAxisProperties::Orientation::ANY ) ) { - if ( !axisProp ) continue; - auto tickMarkCount = ( rowsPerPage() == 1 ) ? RimPlotAxisProperties::LegendTickmarkCount::TICKMARK_DEFAULT : RimPlotAxisProperties::LegendTickmarkCount::TICKMARK_FEW; @@ -1314,10 +1312,8 @@ void RimSummaryMultiPlot::analyzePlotsAndAdjustAppearanceSettings() { for ( auto p : summaryPlots() ) { - for ( auto* axisProp : p->plotYAxes() ) + for ( auto* axisProp : p->plotAxes( RimPlotAxisProperties::Orientation::ANY ) ) { - if ( !axisProp ) continue; - axisProp->computeAndSetAutoValueForScaleFactor(); axisProp->setShowUnitText( true ); axisProp->setShowDescription( true ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 66dfb20a8a..15785a25cf 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -49,7 +49,6 @@ #include "RimGridTimeHistoryCurve.h" #include "RimMultiPlot.h" #include "RimPlotAxisLogRangeCalculator.h" -#include "RimPlotAxisProperties.h" #include "RimProject.h" #include "RimSummaryAddress.h" #include "RimSummaryAddressCollection.h" @@ -621,7 +620,7 @@ const RimSummaryNameHelper* RimSummaryPlot::plotTitleHelper() const //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::copyAxisPropertiesFromOther( const RimSummaryPlot& sourceSummaryPlot ) { - for ( auto ap : sourceSummaryPlot.plotAxes() ) + for ( auto ap : sourceSummaryPlot.allPlotAxes() ) { QString data = ap->writeObjectToXmlString(); @@ -638,7 +637,7 @@ void RimSummaryPlot::copyAxisPropertiesFromOther( const RimSummaryPlot& sourceSu //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::copyAxisPropertiesFromOther( RiaDefines::PlotAxis plotAxisType, const RimSummaryPlot& sourceSummaryPlot ) { - for ( auto ap : sourceSummaryPlot.plotAxes() ) + for ( auto ap : sourceSummaryPlot.allPlotAxes() ) { if ( ap->plotAxis().axis() != plotAxisType ) continue; @@ -657,9 +656,9 @@ void RimSummaryPlot::copyAxisPropertiesFromOther( RiaDefines::PlotAxis plotAxisT //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::copyMatchingAxisPropertiesFromOther( const RimSummaryPlot& summaryPlot ) { - for ( auto apToCopy : summaryPlot.plotAxes() ) + for ( auto apToCopy : summaryPlot.allPlotAxes() ) { - for ( auto ap : plotAxes() ) + for ( auto ap : allPlotAxes() ) { if ( ap->objectName().compare( apToCopy->objectName() ) == 0 ) { @@ -2659,7 +2658,7 @@ void RimSummaryPlot::onPlotZoomed() setAutoScaleYEnabled( false ); // Disable auto value for min/max fields - for ( auto p : plotYAxes() ) + for ( auto p : plotAxes( RimPlotAxisProperties::Orientation::ANY ) ) { p->enableAutoValueMinMax( false ); } @@ -3106,27 +3105,29 @@ bool RimSummaryPlot::isDeletable() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSummaryPlot::plotAxes() const +std::vector RimSummaryPlot::allPlotAxes() const { - std::vector axisProps; - for ( const auto& ap : m_axisPropertiesArray ) - { - axisProps.push_back( ap ); - } - - return axisProps; + return m_axisPropertiesArray.childrenByType(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSummaryPlot::plotYAxes() const +std::vector RimSummaryPlot::plotAxes( RimPlotAxisProperties::Orientation orientation ) const { std::vector axisProps; for ( const auto& ap : m_axisPropertiesArray ) { auto plotAxisProp = dynamic_cast( ap.p() ); - if ( plotAxisProp && plotAxisProp->plotAxis().isVertical() ) + if ( !plotAxisProp ) continue; + + if ( ( orientation == RimPlotAxisProperties::Orientation::ANY ) || + ( orientation == RimPlotAxisProperties::Orientation::VERTICAL && plotAxisProp->plotAxis().isVertical() ) ) + { + axisProps.push_back( plotAxisProp ); + } + else if ( ( orientation == RimPlotAxisProperties::Orientation::ANY ) || + ( orientation == RimPlotAxisProperties::Orientation::HORIZONTAL && plotAxisProp->plotAxis().isHorizontal() ) ) { axisProps.push_back( plotAxisProp ); } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h index 007e127362..94094106ce 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -22,6 +22,7 @@ #include "RiaPlotDefines.h" #include "RimPlot.h" +#include "RimPlotAxisProperties.h" #include "RimSummaryDataSourceStepping.h" #include "RiuQwtPlotWidget.h" @@ -201,8 +202,7 @@ class RimSummaryPlot : public RimPlot, public RimSummaryDataSourceStepping std::vector curveSets() const override; std::vector allCurves( RimSummaryDataSourceStepping::Axis axis ) const override; - std::vector plotAxes() const; - std::vector plotYAxes() const; + std::vector plotAxes( RimPlotAxisProperties::Orientation orientation ) const; RimPlotAxisPropertiesInterface* axisPropertiesForPlotAxis( RiuPlotAxis plotAxis ) const; RimPlotAxisProperties* addNewAxisProperties( RiaDefines::PlotAxis, const QString& name ); @@ -293,6 +293,8 @@ private slots: RiuPlotAxis oldPlotAxis, RiuPlotAxis newPlotAxis ); + std::vector allPlotAxes() const; + void timeAxisSettingsChanged( const caf::SignalEmitter* emitter ); void timeAxisSettingsChangedReloadRequired( const caf::SignalEmitter* emitter ); From 2d25cc02b7dfaf4c571c1f1d314a31a9bc7f91f2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 26 Sep 2023 15:49:14 +0200 Subject: [PATCH 03/11] Send curvesChanged signal to trigger multi plot updates This signal will trigger update of axes and set correct scaling factor --- ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 15785a25cf..5670624c33 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -2046,6 +2046,8 @@ void RimSummaryPlot::disconnectCurveSignals( RimSummaryCurve* curve ) void RimSummaryPlot::curveDataChanged( const caf::SignalEmitter* emitter ) { loadDataAndUpdate(); + + curvesChanged.send(); } //-------------------------------------------------------------------------------------------------- From 4e2662bb0f9e4e4f30430514a2fb5ecb8c60fb9a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 26 Sep 2023 10:03:57 +0200 Subject: [PATCH 04/11] Use object name for axis object --- .../ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.cpp index c51f80dba7..aa1a1de7c6 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotAxisFormatter.cpp @@ -131,7 +131,7 @@ void RimSummaryPlotAxisFormatter::applyAxisPropertiesToPlot( RiuPlotWidget* plot } QString objectName = createAxisObjectName(); - m_axisProperties->setNameAndAxis( objectName + axisTitle, axisTitle, axis.axis(), axis.index() ); + m_axisProperties->setNameAndAxis( objectName, axisTitle, axis.axis(), axis.index() ); plotWidget->setAxisTitleText( axis, axisTitle ); bool titleBold = false; From ab6fb709268df8acfd695fa66bc4ce801442caaa Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 26 Sep 2023 11:21:33 +0200 Subject: [PATCH 05/11] Use address for both x and y axis to create ensemble curve name --- .../ProjectDataModel/Summary/RimEnsembleCurveSet.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 71501f8d82..624049322c 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -2332,9 +2332,7 @@ QString RimEnsembleCurveSet::createAutoName() const { auto plot = firstAncestorOrThisOfTypeAsserted(); - QString curveSetName = m_summaryAddressNameTools->curveName( RiaSummaryCurveAddress( m_yValuesSummaryAddress->address() ), - plot->plotTitleHelper(), - plot->plotTitleHelper() ); + QString curveSetName = m_summaryAddressNameTools->curveName( curveAddress(), plot->plotTitleHelper(), plot->plotTitleHelper() ); if ( curveSetName.isEmpty() ) { From 03fc2688d1d303622e138607bbe06d3e0fcd4ce4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 26 Sep 2023 11:29:51 +0200 Subject: [PATCH 06/11] Fix bug for drag/drop of ensemble object into plot --- .../ProjectDataModel/Summary/RimSummaryPlot.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 5670624c33..92443097ba 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -2365,14 +2365,14 @@ RimSummaryPlot::CurveInfo RimSummaryPlot::handleAddressCollectionDrop( RimSummar { sourceCurveDefs.push_back( curve->curveDefinition() ); } + } - if ( ensembleCase ) + if ( ensembleCase ) + { + auto curveSets = m_ensembleCurveSetCollection->curveSets(); + for ( auto curveSet : curveSets ) { - auto curveSets = m_ensembleCurveSetCollection->curveSets(); - for ( auto curveSet : curveSets ) - { - sourceCurveDefs.push_back( RiaSummaryCurveDefinition( ensembleCase, curveSet->summaryAddress() ) ); - } + sourceCurveDefs.push_back( RiaSummaryCurveDefinition( ensembleCase, curveSet->summaryAddress() ) ); } } From 8d37dd30ab7825dd0bdd89bc591f01175961bcaa Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 26 Sep 2023 14:08:01 +0200 Subject: [PATCH 07/11] Add RiaSummaryCurveAddress to RiaSummaryCurveDefinition --- .../Application/RiaSummaryCurveDefinition.cpp | 30 +++++++++++++++++++ .../Application/RiaSummaryCurveDefinition.h | 17 +++++++---- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/ApplicationLibCode/Application/RiaSummaryCurveDefinition.cpp b/ApplicationLibCode/Application/RiaSummaryCurveDefinition.cpp index 424c5f67b3..a6e5e4a402 100644 --- a/ApplicationLibCode/Application/RiaSummaryCurveDefinition.cpp +++ b/ApplicationLibCode/Application/RiaSummaryCurveDefinition.cpp @@ -18,6 +18,7 @@ #include "RiaSummaryCurveDefinition.h" #include "RiaStdStringTools.h" +#include "RiaSummaryCurveAddress.h" #include "RifSummaryReaderInterface.h" @@ -66,6 +67,19 @@ RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCaseCollection* { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCaseCollection* ensemble, const RiaSummaryCurveAddress& summaryCurveAddress ) + : m_summaryCaseY( nullptr ) + , m_summaryAddressY( summaryCurveAddress.summaryAddressY() ) + , m_summaryCaseX( nullptr ) + , m_summaryAddressX( summaryCurveAddress.summaryAddressX() ) + , m_ensemble( ensemble ) + , m_isEnsembleCurve( true ) +{ +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -82,6 +96,14 @@ RimSummaryCaseCollection* RiaSummaryCurveDefinition::ensemble() const return m_ensemble; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSummaryCurveDefinition::setEnsemble( RimSummaryCaseCollection* ensemble ) +{ + m_ensemble = ensemble; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -138,6 +160,14 @@ RifEclipseSummaryAddress RiaSummaryCurveDefinition::summaryAddressX() const return m_summaryAddressX; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaSummaryCurveAddress RiaSummaryCurveDefinition::summaryCurveAddress() const +{ + return RiaSummaryCurveAddress( m_summaryAddressX, m_summaryAddressY ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaSummaryCurveDefinition.h b/ApplicationLibCode/Application/RiaSummaryCurveDefinition.h index b59a3c4b76..0132dfea77 100644 --- a/ApplicationLibCode/Application/RiaSummaryCurveDefinition.h +++ b/ApplicationLibCode/Application/RiaSummaryCurveDefinition.h @@ -30,6 +30,7 @@ class RimSummaryCase; class RimSummaryCaseCollection; +class RiaSummaryCurveAddress; //================================================================================================== /// @@ -40,13 +41,17 @@ class RiaSummaryCurveDefinition RiaSummaryCurveDefinition(); explicit RiaSummaryCurveDefinition( RimSummaryCase* summaryCaseY, const RifEclipseSummaryAddress& summaryAddressY, bool isEnsembleCurve ); explicit RiaSummaryCurveDefinition( RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& summaryAddressY ); + explicit RiaSummaryCurveDefinition( RimSummaryCaseCollection* ensemble, const RiaSummaryCurveAddress& summaryCurveAddress ); - // Y Axis - RimSummaryCase* summaryCaseY() const; - RifEclipseSummaryAddress summaryAddressY() const; + // X and Y Axis RimSummaryCaseCollection* ensemble() const; - bool isEnsembleCurve() const; - void setSummaryAddressY( const RifEclipseSummaryAddress& address ); + void setEnsemble( RimSummaryCaseCollection* ensemble ); + + // Y Axis + RimSummaryCase* summaryCaseY() const; + RifEclipseSummaryAddress summaryAddressY() const; + bool isEnsembleCurve() const; + void setSummaryAddressY( const RifEclipseSummaryAddress& address ); // X Axis void setSummaryCaseX( RimSummaryCase* summaryCase ); @@ -54,6 +59,8 @@ class RiaSummaryCurveDefinition RimSummaryCase* summaryCaseX() const; RifEclipseSummaryAddress summaryAddressX() const; + RiaSummaryCurveAddress summaryCurveAddress() const; + void setIdentifierText( SummaryCategory category, const std::string& name ); bool operator<( const RiaSummaryCurveDefinition& other ) const; From c6e20def61bef21b09702b638e3720588bf9a5e9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 26 Sep 2023 14:09:43 +0200 Subject: [PATCH 08/11] Remove SummaryDataSource --- .../Summary/RimSummaryAddressSelector.cpp | 39 +++++++++++-------- .../Summary/RimSummaryAddressSelector.h | 11 ++---- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp index e4a683877b..c6af1b2ede 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp @@ -72,7 +72,6 @@ RimSummaryAddressSelector::RimSummaryAddressSelector() CAF_PDM_InitFieldNoDefault( &m_resamplingPeriod, "Resampling", "Resampling" ); - m_dataSource = SummaryDataSource::SINGLE_CASE; m_showDataSource = true; m_plotAxisOrientation = RimPlotAxisProperties::Orientation::ANY; } @@ -83,7 +82,6 @@ RimSummaryAddressSelector::RimSummaryAddressSelector() void RimSummaryAddressSelector::setSummaryCase( RimSummaryCase* summaryCase ) { m_summaryCase = summaryCase; - m_dataSource = SummaryDataSource::SINGLE_CASE; } //-------------------------------------------------------------------------------------------------- @@ -92,7 +90,6 @@ void RimSummaryAddressSelector::setSummaryCase( RimSummaryCase* summaryCase ) void RimSummaryAddressSelector::setEnsemble( RimSummaryCaseCollection* ensemble ) { m_summaryCaseCollection = ensemble; - m_dataSource = SummaryDataSource::ENSEMBLE; } //-------------------------------------------------------------------------------------------------- @@ -184,16 +181,16 @@ void RimSummaryAddressSelector::fieldChangedByUi( const caf::PdmFieldHandle* cha { RiuSummaryVectorSelectionDialog dlg( nullptr ); - if ( m_dataSource == SummaryDataSource::SINGLE_CASE ) - { - dlg.hideEnsembles(); - dlg.setCaseAndAddress( m_summaryCase(), m_summaryAddress->address() ); - } - else if ( m_dataSource == SummaryDataSource::ENSEMBLE ) + if ( isEnsemble() ) { dlg.hideSummaryCases(); dlg.setEnsembleAndAddress( m_summaryCaseCollection(), m_summaryAddress->address() ); } + else + { + dlg.hideEnsembles(); + dlg.setCaseAndAddress( m_summaryCase(), m_summaryAddress->address() ); + } if ( dlg.exec() == QDialog::Accepted ) { @@ -292,7 +289,11 @@ QList RimSummaryAddressSelector::calculateValueOptions( if ( fieldNeedingOptions == &m_summaryAddressUiField ) { std::set addresses; - if ( m_dataSource == SummaryDataSource::SINGLE_CASE && m_summaryCase() ) + if ( isEnsemble() && m_summaryCaseCollection() ) + { + addresses = m_summaryCaseCollection()->ensembleSummaryAddresses(); + } + else if ( m_summaryCase() ) { RifSummaryReaderInterface* reader = m_summaryCase()->summaryReader(); if ( reader ) @@ -300,10 +301,6 @@ QList RimSummaryAddressSelector::calculateValueOptions( addresses = reader->allResultAddresses(); } } - else if ( m_dataSource == SummaryDataSource::ENSEMBLE && m_summaryCaseCollection() ) - { - addresses = m_summaryCaseCollection()->ensembleSummaryAddresses(); - } return createOptionsForAddresses( addresses ); } @@ -332,13 +329,13 @@ void RimSummaryAddressSelector::defineUiOrdering( QString uiConfigName, caf::Pdm { if ( m_showDataSource ) { - if ( m_dataSource == SummaryDataSource::SINGLE_CASE ) + if ( isEnsemble() ) { - uiOrdering.add( &m_summaryCase ); + uiOrdering.add( &m_summaryCaseCollection ); } else { - uiOrdering.add( &m_summaryCaseCollection ); + uiOrdering.add( &m_summaryCase ); } } @@ -367,3 +364,11 @@ void RimSummaryAddressSelector::defineEditorAttribute( const caf::PdmFieldHandle } } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryAddressSelector::isEnsemble() const +{ + return m_summaryCaseCollection() != nullptr; +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h index f7fb4622c9..ca5cb25392 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h @@ -40,12 +40,6 @@ class RimSummaryAddressSelector : public caf::PdmObject CAF_PDM_HEADER_INIT; public: - enum class SummaryDataSource - { - SINGLE_CASE, - ENSEMBLE - }; - caf::Signal<> addressChanged; public: @@ -71,6 +65,8 @@ class RimSummaryAddressSelector : public caf::PdmObject void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + bool isEnsemble() const; + private: caf::PdmPtrField m_summaryCase; caf::PdmPtrField m_summaryCaseCollection; @@ -80,8 +76,7 @@ class RimSummaryAddressSelector : public caf::PdmObject caf::PdmPtrField m_plotAxisProperties; caf::PdmField m_resamplingPeriod; - SummaryDataSource m_dataSource; - bool m_showDataSource; + bool m_showDataSource; RimPlotAxisProperties::Orientation m_plotAxisOrientation; }; From 675acaf0a2a907e579406304105ebaf0968ea20d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 26 Sep 2023 14:12:31 +0200 Subject: [PATCH 09/11] Fix several issues with ensemble cross plots --- .../Summary/RimEnsembleCurveSet.cpp | 35 ++++++++++++++ .../Summary/RimEnsembleCurveSet.h | 2 + .../Summary/RimSummaryPlot.cpp | 48 ++++++++++++++----- .../ProjectDataModel/Summary/RimSummaryPlot.h | 3 +- 4 files changed, 74 insertions(+), 14 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 624049322c..a30526f113 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -426,6 +426,15 @@ void RimEnsembleCurveSet::setCurveAddress( RiaSummaryCurveAddress address ) { setSummaryAddress( address.summaryAddressY() ); setSummaryAddressX( address.summaryAddressX() ); + + if ( address.summaryAddressX().category() == SummaryCategory::SUMMARY_TIME ) + { + m_xAxisType = RiaDefines::HorizontalAxisType::TIME; + } + else + { + m_xAxisType = RiaDefines::HorizontalAxisType::SUMMARY_VECTOR; + } } //-------------------------------------------------------------------------------------------------- @@ -565,6 +574,7 @@ void RimEnsembleCurveSet::onLegendDefinitionChanged() void RimEnsembleCurveSet::setSummaryCaseCollection( RimSummaryCaseCollection* sumCaseCollection ) { m_yValuesSummaryCaseCollection = sumCaseCollection; + m_xAddressSelector->setEnsemble( sumCaseCollection ); } //-------------------------------------------------------------------------------------------------- @@ -2396,6 +2406,17 @@ RiuPlotAxis RimEnsembleCurveSet::axisY() const return RiuPlotAxis::defaultLeft(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuPlotAxis RimEnsembleCurveSet::axisX() const +{ + if ( m_xAddressSelector->plotAxisProperties() ) + return m_xAddressSelector->plotAxisProperties()->plotAxis(); + else + return RiuPlotAxis::defaultBottomForSummaryVectors(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -2410,6 +2431,20 @@ void RimEnsembleCurveSet::setLeftOrRightAxisY( RiuPlotAxis plotAxis ) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::setBottomOrTopAxis( RiuPlotAxis plotAxis ) +{ + auto plot = firstAncestorOrThisOfTypeAsserted(); + m_xAddressSelector->setPlotAxisProperties( plot->axisPropertiesForPlotAxis( plotAxis ) ); + + for ( RimSummaryCurve* curve : curves() ) + { + curve->setTopOrBottomAxisX( axisX() ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 8fd4823bed..97d523a416 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -180,7 +180,9 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt std::vector generateColorsForCases( const std::vector& summaryCases ) const; RiuPlotAxis axisY() const; + RiuPlotAxis axisX() const; void setLeftOrRightAxisY( RiuPlotAxis plotAxis ); + void setBottomOrTopAxis( RiuPlotAxis plotAxis ); protected: void initAfterRead() override; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 92443097ba..35e278ba35 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -924,18 +924,35 @@ void RimSummaryPlot::updateNumericalAxis( RiaDefines::PlotAxis plotAxis ) std::vector curveDefs; for ( auto summaryCurve : summaryCurves() ) { - if ( summaryCurve->axisY() == riuPlotAxis || summaryCurve->axisX() == riuPlotAxis ) + if ( summaryCurve->axisY() == riuPlotAxis ) { - curveDefs.push_back( summaryCurve->curveDefinition() ); + curveDefs.push_back( RiaSummaryCurveDefinition( summaryCurve->summaryCaseY(), + summaryCurve->summaryAddressY(), + summaryCurve->isEnsembleCurve() ) ); + } + if ( summaryCurve->axisX() == riuPlotAxis ) + { + curveDefs.push_back( RiaSummaryCurveDefinition( summaryCurve->summaryCaseX(), + summaryCurve->summaryAddressX(), + summaryCurve->isEnsembleCurve() ) ); } } for ( auto curveSet : ensembleCurveSetCollection()->curveSets() ) { - if ( curveSet->axisY() != riuPlotAxis ) continue; + if ( curveSet->axisY() == riuPlotAxis ) + { + RiaSummaryCurveDefinition def( curveSet->summaryCaseCollection(), curveSet->summaryAddress() ); + curveDefs.push_back( def ); + } + if ( curveSet->axisX() == riuPlotAxis ) + { + RiaSummaryCurveDefinition def; + def.setEnsemble( curveSet->summaryCaseCollection() ); + def.setSummaryAddressX( curveSet->curveAddress().summaryAddressX() ); - RiaSummaryCurveDefinition def( curveSet->summaryCaseCollection(), curveSet->summaryAddress() ); - curveDefs.push_back( def ); + curveDefs.push_back( def ); + } } RimSummaryPlotAxisFormatter calc( axisProps, {}, curveDefs, visibleAsciiDataCurvesForAxis( riuPlotAxis ), timeHistoryQuantities ); @@ -2322,11 +2339,11 @@ RimSummaryPlot::CurveInfo RimSummaryPlot::handleEnsembleDrop( RimSummaryCaseColl int newCurves = 0; std::vector curveSetsToUpdate; - std::map> dataVectorMap; + std::map> dataVectorMap; for ( auto& curve : curveSets() ) { - const auto addr = curve->summaryAddress(); + const auto addr = curve->curveAddress(); dataVectorMap[addr].insert( curve->summaryCaseCollection() ); } @@ -2334,7 +2351,7 @@ RimSummaryPlot::CurveInfo RimSummaryPlot::handleEnsembleDrop( RimSummaryCaseColl { if ( ensembles.count( ensemble ) > 0 ) continue; - auto curveSet = addNewEnsembleCurveY( addr, ensemble ); + auto curveSet = addNewEnsembleCurve( addr, ensemble ); curveSetsToUpdate.push_back( curveSet ); newCurves++; } @@ -2372,7 +2389,7 @@ RimSummaryPlot::CurveInfo RimSummaryPlot::handleAddressCollectionDrop( RimSummar auto curveSets = m_ensembleCurveSetCollection->curveSets(); for ( auto curveSet : curveSets ) { - sourceCurveDefs.push_back( RiaSummaryCurveDefinition( ensembleCase, curveSet->summaryAddress() ) ); + sourceCurveDefs.push_back( RiaSummaryCurveDefinition( ensembleCase, curveSet->curveAddress() ) ); } } @@ -2436,7 +2453,7 @@ RimSummaryPlot::CurveInfo RimSummaryPlot::handleAddressCollectionDrop( RimSummar auto addresses = curveDef.ensemble()->ensembleSummaryAddresses(); if ( addresses.find( curveDef.summaryAddressY() ) != addresses.end() ) { - curveSetsToUpdate.push_back( addNewEnsembleCurveY( curveDef.summaryAddressY(), curveDef.ensemble() ) ); + curveSetsToUpdate.push_back( addNewEnsembleCurve( curveDef.summaryCurveAddress(), curveDef.ensemble() ) ); newCurves++; } } @@ -2506,7 +2523,8 @@ RimSummaryPlot::CurveInfo RimSummaryPlot::handleSummaryAddressDrop( RimSummaryAd if ( !skipAddress ) { - curveSetsToUpdate.push_back( addNewEnsembleCurveY( droppedAddress, ensemble ) ); + curveSetsToUpdate.push_back( + addNewEnsembleCurve( RiaSummaryCurveAddress( RifEclipseSummaryAddress::timeAddress(), droppedAddress ), ensemble ) ); newCurves++; } } @@ -2628,12 +2646,13 @@ RimSummaryCurve* RimSummaryPlot::addNewCurve( const RifEclipseSummaryAddress& ad //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEnsembleCurveSet* RimSummaryPlot::addNewEnsembleCurveY( const RifEclipseSummaryAddress& address, RimSummaryCaseCollection* ensemble ) +RimEnsembleCurveSet* RimSummaryPlot::addNewEnsembleCurve( const RiaSummaryCurveAddress& address, RimSummaryCaseCollection* ensemble ) { auto* curveSet = new RimEnsembleCurveSet(); curveSet->setSummaryCaseCollection( ensemble ); - curveSet->setSummaryAddressAndStatisticsFlag( address ); + curveSet->setSummaryAddressAndStatisticsFlag( address.summaryAddressY() ); + curveSet->setCurveAddress( address ); cvf::Color3f curveColor = RimSummaryCurveAppearanceCalculator::computeTintedCurveColorForAddress( curveSet->summaryAddress(), @@ -2647,6 +2666,9 @@ RimEnsembleCurveSet* RimSummaryPlot::addNewEnsembleCurveY( const RifEclipseSumma ensembleCurveSetCollection()->addCurveSet( curveSet ); + curveSet->setLeftOrRightAxisY( RiuPlotAxis::defaultLeft() ); + curveSet->setBottomOrTopAxis( RiuPlotAxis::defaultBottomForSummaryVectors() ); + return curveSet; } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h index 94094106ce..57001ce9e9 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -62,6 +62,7 @@ class RimSummaryPlotSourceStepping; class RimTimeAxisAnnotation; class RiaSummaryCurveDefinition; class RifEclipseSummaryAddress; +class RiaSummaryCurveAddress; class QwtInterval; class QwtPlotCurve; @@ -307,7 +308,7 @@ private slots: RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& addressX, RimSummaryCase* summaryCaseX ); - RimEnsembleCurveSet* addNewEnsembleCurveY( const RifEclipseSummaryAddress& address, RimSummaryCaseCollection* ensemble ); + RimEnsembleCurveSet* addNewEnsembleCurve( const RiaSummaryCurveAddress& curveAddress, RimSummaryCaseCollection* ensemble ); void updateStackedCurveData(); bool updateStackedCurveDataForAxis( RiuPlotAxis plotAxis ); From 9dd8012a94ee93a5ef007637a0d7c054beb7c98c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 26 Sep 2023 15:35:09 +0200 Subject: [PATCH 10/11] Use childFieldChangedByUi to trigger update of curves and titles --- .../Summary/RimEnsembleCurveSet.cpp | 38 ++++++++++++++----- .../Summary/RimEnsembleCurveSet.h | 2 +- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index a30526f113..5b5a0f5d50 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -52,6 +52,7 @@ #include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveAutoName.h" +#include "RimSummaryMultiPlot.h" #include "RimSummaryPlot.h" #include "RimTimeStepFilter.h" @@ -151,8 +152,6 @@ RimEnsembleCurveSet::RimEnsembleCurveSet() m_xAddressSelector.uiCapability()->setUiTreeHidden( true ); m_xAddressSelector.uiCapability()->setUiTreeChildrenHidden( true ); - m_xAddressSelector->addressChanged.connect( this, &RimEnsembleCurveSet::onXAxisAddressChanged ); - CAF_PDM_InitField( &m_colorMode, "ColorMode", caf::AppEnum( ColorMode::SINGLE_COLOR_WITH_ALPHA ), "Coloring Mode" ); CAF_PDM_InitField( &m_colorForRealizations, "Color", RiaColorTools::textColor3f(), "Color" ); @@ -998,6 +997,33 @@ void RimEnsembleCurveSet::defineObjectEditorAttribute( QString uiConfigName, caf } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) +{ + if ( changedChildField == &m_xAddressSelector ) + { + updateAllCurves(); + + // The recommended way to trigger update in a parent object is by using caf::Signal. Here we need to update two parent classes, and + // they are multiple levels away. To avoid a long signal path that is hard to debug, we use firstAncestorOrThisOfType() + + auto summaryPlot = firstAncestorOrThisOfType(); + if ( summaryPlot ) + { + summaryPlot->updateAll(); + summaryPlot->zoomAll(); + } + + auto multiPlot = firstAncestorOrThisOfType(); + if ( multiPlot ) + { + multiPlot->updatePlotTitles(); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1087,14 +1113,6 @@ void RimEnsembleCurveSet::onCustomObjectiveFunctionChanged( const caf::SignalEmi updateObjectiveFunctionLegend(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEnsembleCurveSet::onXAxisAddressChanged( const caf::SignalEmitter* emitter ) -{ - updateAllCurves(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 97d523a416..2eaaeb6b78 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -206,6 +206,7 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override; void updatePlotAxis(); @@ -221,7 +222,6 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt void onObjectiveFunctionChanged( const caf::SignalEmitter* emitter ); void onCustomObjectiveFunctionChanged( const caf::SignalEmitter* emitter ); - void onXAxisAddressChanged( const caf::SignalEmitter* emitter ); void setTransparentCurveColor(); void onColorTagClicked( const SignalEmitter* emitter, size_t index ); From 905f609faf21366ca8538d0ce1e75d9f18b4ffb5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 27 Sep 2023 10:11:12 +0200 Subject: [PATCH 11/11] Renaming --- .../ProjectDataModel/Summary/RimEnsembleCurveSet.cpp | 2 +- .../ProjectDataModel/Summary/RimEnsembleCurveSet.h | 2 +- ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 5b5a0f5d50..44de8edb10 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -2452,7 +2452,7 @@ void RimEnsembleCurveSet::setLeftOrRightAxisY( RiuPlotAxis plotAxis ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEnsembleCurveSet::setBottomOrTopAxis( RiuPlotAxis plotAxis ) +void RimEnsembleCurveSet::setBottomOrTopAxisX( RiuPlotAxis plotAxis ) { auto plot = firstAncestorOrThisOfTypeAsserted(); m_xAddressSelector->setPlotAxisProperties( plot->axisPropertiesForPlotAxis( plotAxis ) ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 2eaaeb6b78..b8899977d8 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -182,7 +182,7 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt RiuPlotAxis axisY() const; RiuPlotAxis axisX() const; void setLeftOrRightAxisY( RiuPlotAxis plotAxis ); - void setBottomOrTopAxis( RiuPlotAxis plotAxis ); + void setBottomOrTopAxisX( RiuPlotAxis plotAxis ); protected: void initAfterRead() override; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 35e278ba35..faceefb016 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -2667,7 +2667,7 @@ RimEnsembleCurveSet* RimSummaryPlot::addNewEnsembleCurve( const RiaSummaryCurveA ensembleCurveSetCollection()->addCurveSet( curveSet ); curveSet->setLeftOrRightAxisY( RiuPlotAxis::defaultLeft() ); - curveSet->setBottomOrTopAxis( RiuPlotAxis::defaultBottomForSummaryVectors() ); + curveSet->setBottomOrTopAxisX( RiuPlotAxis::defaultBottomForSummaryVectors() ); return curveSet; }