From 675acaf0a2a907e579406304105ebaf0968ea20d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 26 Sep 2023 14:12:31 +0200 Subject: [PATCH] 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 );