From 311dd5b5c4307bd5bbfd77c214fa8d3262850797 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 4 Oct 2019 09:09:22 +0200 Subject: [PATCH] #4811 Source Stepping : Fix well stepping for ensembles --- .../Tools/RiaSummaryCurveAnalyzer.cpp | 4 +- .../Tools/RiaSummaryCurveAnalyzer.h | 4 +- .../RicSummaryPlotTemplateTools.cpp | 4 +- .../Summary/RimSummaryPlotNameHelper.cpp | 2 +- .../Summary/RimSummaryPlotSourceStepping.cpp | 189 ++++++++---------- .../Summary/RimSummaryPlotSourceStepping.h | 7 +- .../RiaSummaryCurveAnalyzer-Test.cpp | 6 +- 7 files changed, 101 insertions(+), 115 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.cpp b/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.cpp index c7faa110c9..9c9c10690f 100644 --- a/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.cpp +++ b/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.cpp @@ -34,7 +34,7 @@ RiaSummaryCurveAnalyzer::RiaSummaryCurveAnalyzer() {} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaSummaryCurveAnalyzer::appendAdresses( const std::vector& allAddresses ) +void RiaSummaryCurveAnalyzer::appendAddresses( const std::vector& allAddresses ) { for ( const auto& adr : allAddresses ) { @@ -45,7 +45,7 @@ void RiaSummaryCurveAnalyzer::appendAdresses( const std::vector& allAddresses ) +void RiaSummaryCurveAnalyzer::appendAddresses( const std::set& allAddresses ) { for ( const auto& adr : allAddresses ) { diff --git a/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.h b/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.h index 4a01eed988..cbe1a67b33 100644 --- a/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.h +++ b/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.h @@ -37,8 +37,8 @@ class RiaSummaryCurveAnalyzer public: RiaSummaryCurveAnalyzer(); - void appendAdresses( const std::set& allAddresses ); - void appendAdresses( const std::vector& allAddresses ); + void appendAddresses( const std::set& allAddresses ); + void appendAddresses( const std::vector& allAddresses ); void clear(); diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp index f0b2c676a7..c8dcae501a 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp @@ -146,7 +146,7 @@ QString RicSummaryPlotTemplateTools::htmlTextFromPlotAndSelection( RiaSummaryCurveAnalyzer selectionAnalyzer; - selectionAnalyzer.appendAdresses( selectedSummaryAddresses ); + selectionAnalyzer.appendAddresses( selectedSummaryAddresses ); if ( templatePlot ) { @@ -169,7 +169,7 @@ QString RicSummaryPlotTemplateTools::htmlTextFromPlotAndSelection( } } - templateAnalyzer.appendAdresses( templateAddresses ); + templateAnalyzer.appendAddresses( templateAddresses ); } text += " Requirements
"; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp index 6f3913c606..396707e64d 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp @@ -47,7 +47,7 @@ void RimSummaryPlotNameHelper::clear() //-------------------------------------------------------------------------------------------------- void RimSummaryPlotNameHelper::appendAddresses( const std::vector& addresses ) { - m_analyzer.appendAdresses( addresses ); + m_analyzer.appendAddresses( addresses ); extractPlotTitleSubStrings(); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp index 5cf5c8d540..22d0e31d3c 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp @@ -19,6 +19,7 @@ #include "RimSummaryPlotSourceStepping.h" #include "RiaGuiApplication.h" +#include "RiaStdStringTools.h" #include "RiaSummaryCurveAnalyzer.h" #include "RiaSummaryCurveDefinition.h" @@ -37,7 +38,6 @@ #include "RiuPlotMainWindow.h" -#include "RiaStdStringTools.h" #include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiItem.h" #include "cafPdmUiListEditor.h" @@ -50,36 +50,33 @@ CAF_PDM_SOURCE_INIT( RimSummaryPlotSourceStepping, "RimSummaryCurveCollectionMod RimSummaryPlotSourceStepping::RimSummaryPlotSourceStepping() : m_sourceSteppingType( Y_AXIS ) { - // clang-format off - CAF_PDM_InitObject("Summary Curves Modifier", "", "", ""); + CAF_PDM_InitObject( "Summary Curves Modifier", "", "", "" ); - CAF_PDM_InitFieldNoDefault(&m_summaryCase, "CurveCase", "Case", "", "", ""); + CAF_PDM_InitFieldNoDefault( &m_summaryCase, "CurveCase", "Case", "", "", "" ); - CAF_PDM_InitField(&m_includeEnsembleCasesForCaseStepping, - "IncludeEnsembleCasesForCaseStepping", - false, - "Allow Stepping on Ensemble cases", - "", - "", - ""); + CAF_PDM_InitField( &m_includeEnsembleCasesForCaseStepping, + "IncludeEnsembleCasesForCaseStepping", + false, + "Allow Stepping on Ensemble cases", + "", + "", + "" ); - CAF_PDM_InitFieldNoDefault(&m_wellName, "WellName", "Well Name", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_wellGroupName, "GroupName", "Group Name", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_region, "Region", "Region", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_quantity, "Quantities", "Quantity", "", "", ""); + CAF_PDM_InitFieldNoDefault( &m_wellName, "WellName", "Well Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellGroupName, "GroupName", "Group Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_region, "Region", "Region", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_quantity, "Quantities", "Quantity", "", "", "" ); - CAF_PDM_InitFieldNoDefault(&m_cellBlock, "CellBlock", "Block", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_segment, "Segment", "Segment", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_completion, "Completion", "Completion", "", "", ""); + CAF_PDM_InitFieldNoDefault( &m_cellBlock, "CellBlock", "Block", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_segment, "Segment", "Segment", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_completion, "Completion", "Completion", "", "", "" ); - CAF_PDM_InitFieldNoDefault(&m_ensemble, "Ensemble", "Ensemble", "", "", ""); + CAF_PDM_InitFieldNoDefault( &m_ensemble, "Ensemble", "Ensemble", "", "", "" ); - CAF_PDM_InitFieldNoDefault(&m_placeholderForLabel, "Placeholder", "", "", "", ""); + CAF_PDM_InitFieldNoDefault( &m_placeholderForLabel, "Placeholder", "", "", "", "" ); m_placeholderForLabel = "No common identifiers detected"; - m_placeholderForLabel.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); - m_placeholderForLabel.uiCapability()->setUiReadOnly(true); - - // clang-format on + m_placeholderForLabel.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); + m_placeholderForLabel.uiCapability()->setUiReadOnly( true ); } //-------------------------------------------------------------------------------------------------- @@ -164,7 +161,7 @@ std::vector RimSummaryPlotSourceStepping::fieldsToShowInTo void RimSummaryPlotSourceStepping::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { auto visible = computeVisibleFieldsAndSetFieldVisibility(); - if ( visible.size() == 0 ) + if ( visible.empty() ) { m_placeholderForLabel.uiCapability()->setUiHidden( false ); } @@ -189,7 +186,7 @@ QList } else if ( fieldNeedingOptions == &m_placeholderForLabel ) { - options; + return options; } else if ( fieldNeedingOptions == &m_summaryCase ) { @@ -215,17 +212,17 @@ QList return options; } - std::vector readers = summaryReadersForCurves(); - if ( !readers.empty() ) + auto addresses = adressesForSourceStepping(); + if ( !addresses.empty() ) { if ( fieldNeedingOptions == &m_quantity ) { RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::SUMMARY_FIELD; - auto addresses = addressesCurveCollection(); - if ( !addresses.empty() ) + auto visibleCurveAddresses = addressesForCurvesInPlot(); + if ( !visibleCurveAddresses.empty() ) { - category = addresses.begin()->category(); + category = visibleCurveAddresses.begin()->category(); } std::map displayAndValueStrings; @@ -233,20 +230,13 @@ QList { RiaSummaryCurveAnalyzer quantityAnalyzer; - for ( auto reader : readers ) - { - if ( reader != nullptr ) - { - auto subset = RiaSummaryCurveAnalyzer::addressesForCategory( reader->allResultAddresses(), - category ); - quantityAnalyzer.appendAdresses( subset ); - } - } + auto subset = RiaSummaryCurveAnalyzer::addressesForCategory( addresses, category ); + quantityAnalyzer.appendAddresses( subset ); - RiaSummaryCurveAnalyzer analyzerForCurves; - analyzerForCurves.appendAdresses( addressesCurveCollection() ); + RiaSummaryCurveAnalyzer analyzerForVisibleCurves; + analyzerForVisibleCurves.appendAddresses( visibleCurveAddresses ); - if ( analyzerForCurves.quantityNamesWithHistory().empty() ) + if ( analyzerForVisibleCurves.quantityNamesWithHistory().empty() ) { auto quantities = quantityAnalyzer.quantities(); for ( const auto& s : quantities ) @@ -258,6 +248,9 @@ QList } else { + // The plot displays a mix of simulated and observed vectors + // Create a combined item for source stepping + auto quantitiesWithHistory = quantityAnalyzer.quantityNamesWithHistory(); for ( const auto& s : quantitiesWithHistory ) { @@ -323,15 +316,10 @@ QList if ( category != RifEclipseSummaryAddress::SUMMARY_INVALID ) { - for ( auto reader : readers ) - { - auto analyzer = analyzerForReader( reader ); + RiaSummaryCurveAnalyzer analyzer; + analyzer.appendAddresses( addresses ); - if ( analyzer ) - { - identifierTexts = analyzer->identifierTexts( category, secondaryIdentifier ); - } - } + identifierTexts = analyzer.identifierTexts( category, secondaryIdentifier ); } if ( !identifierTexts.empty() ) @@ -558,8 +546,8 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle* RimSummaryCrossPlot* summaryCrossPlot = dynamic_cast( summaryPlot ); if ( summaryCrossPlot ) { - // Trigger update of curve collection (and summary toolbar in main window), as the visibility of combo boxes - // might have been changed due to the updates in this function + // Trigger update of curve collection (and summary toolbar in main window), as the visibility of combo + // boxes might have been changed due to the updates in this function if ( curveCollection ) { curveCollection->updateConnectedEditors(); @@ -571,58 +559,13 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle* } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimSummaryPlotSourceStepping::summaryReadersForCurves() const -{ - std::vector readers; - RimSummaryCurveCollection* curveCollection = nullptr; - this->firstAncestorOrThisOfType( curveCollection ); - - if ( curveCollection ) - { - for ( auto curve : curveCollection->curves() ) - { - if ( isYAxisStepping() && curve->summaryCaseY() && curve->summaryCaseY()->summaryReader() ) - { - readers.push_back( curve->summaryCaseY()->summaryReader() ); - } - - if ( isXAxisStepping() && curve->summaryCaseX() && curve->summaryCaseX()->summaryReader() ) - { - readers.push_back( curve->summaryCaseX()->summaryReader() ); - } - } - } - - RimEnsembleCurveSetCollection* ensembleCollection = nullptr; - this->firstAncestorOrThisOfType( ensembleCollection ); - if ( ensembleCollection ) - { - auto curveSets = ensembleCollection->curveSets(); - for ( const RimEnsembleCurveSet* curveSet : curveSets ) - { - for ( auto curve : curveSet->curves() ) - { - if ( isYAxisStepping() && curve->summaryCaseY() && curve->summaryCaseY()->summaryReader() ) - { - readers.push_back( curve->summaryCaseY()->summaryReader() ); - } - } - } - } - - return readers; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- caf::PdmValueField* RimSummaryPlotSourceStepping::fieldToModify() { RiaSummaryCurveAnalyzer analyzer; - analyzer.appendAdresses( addressesCurveCollection() ); + analyzer.appendAddresses( addressesForCurvesInPlot() ); if ( analyzer.wellNames().size() == 1 ) { @@ -660,7 +603,49 @@ caf::PdmValueField* RimSummaryPlotSourceStepping::fieldToModify() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RimSummaryPlotSourceStepping::addressesCurveCollection() const +std::set RimSummaryPlotSourceStepping::adressesForSourceStepping() const +{ + std::set addressSet; + + RimEnsembleCurveSetCollection* ensembleCollection = nullptr; + this->firstAncestorOrThisOfType( ensembleCollection ); + if ( ensembleCollection ) + { + auto curveSets = ensembleCollection->curveSetsForSourceStepping(); + for ( const RimEnsembleCurveSet* curveSet : curveSets ) + { + auto addresses = curveSet->summaryCaseCollection()->ensembleSummaryAddresses(); + addressSet.insert( addresses.begin(), addresses.end() ); + } + } + + RimSummaryCurveCollection* curveCollection = nullptr; + this->firstAncestorOrThisOfType( curveCollection ); + if ( curveCollection ) + { + for ( auto curve : curveCollection->curvesForSourceStepping( m_sourceSteppingType ) ) + { + if ( isYAxisStepping() && curve->summaryCaseY() && curve->summaryCaseY()->summaryReader() ) + { + auto addresses = curve->summaryCaseY()->summaryReader()->allResultAddresses(); + addressSet.insert( addresses.begin(), addresses.end() ); + } + + if ( isXAxisStepping() && curve->summaryCaseX() && curve->summaryCaseX()->summaryReader() ) + { + auto addresses = curve->summaryCaseX()->summaryReader()->allResultAddresses(); + addressSet.insert( addresses.begin(), addresses.end() ); + } + } + } + + return addressSet; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RimSummaryPlotSourceStepping::addressesForCurvesInPlot() const { std::set addresses; @@ -781,7 +766,7 @@ std::vector RimSummaryPlotSourceStepping::computeVisibleFi { RiaSummaryCurveAnalyzer analyzer; - analyzer.appendAdresses( addressesCurveCollection() ); + analyzer.appendAddresses( addressesForCurvesInPlot() ); RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::SUMMARY_INVALID; @@ -942,7 +927,7 @@ RiaSummaryCurveAnalyzer* RimSummaryPlotSourceStepping::analyzerForReader( RifSum m_curveAnalyzerForReader = std::make_pair( reader, analyzer ); } - m_curveAnalyzerForReader.second.appendAdresses( reader->allResultAddresses() ); + m_curveAnalyzerForReader.second.appendAddresses( reader->allResultAddresses() ); return &m_curveAnalyzerForReader.second; } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h index 4610b43ca3..c93218d52a 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h @@ -81,10 +81,11 @@ private: caf::PdmUiEditorAttribute* attribute ) override; private: - std::vector summaryReadersForCurves() const; - caf::PdmValueField* fieldToModify(); + caf::PdmValueField* fieldToModify(); - std::set addressesCurveCollection() const; + std::set adressesForSourceStepping() const; + + std::set addressesForCurvesInPlot() const; std::set summaryCasesCurveCollection() const; std::vector computeVisibleFieldsAndSetFieldVisibility(); std::set ensembleCollection() const; diff --git a/ApplicationCode/UnitTests/RiaSummaryCurveAnalyzer-Test.cpp b/ApplicationCode/UnitTests/RiaSummaryCurveAnalyzer-Test.cpp index dcb96d00a6..e57861f356 100644 --- a/ApplicationCode/UnitTests/RiaSummaryCurveAnalyzer-Test.cpp +++ b/ApplicationCode/UnitTests/RiaSummaryCurveAnalyzer-Test.cpp @@ -44,7 +44,7 @@ TEST( RiaSummaryCurveAnalyzer, WellCompletions ) } RiaSummaryCurveAnalyzer analyzer; - analyzer.appendAdresses( addresses ); + analyzer.appendAddresses( addresses ); EXPECT_EQ( 2u, analyzer.wellNames().size() ); @@ -95,7 +95,7 @@ TEST( RiaSummaryCurveAnalyzer, WellSegments ) } RiaSummaryCurveAnalyzer analyzer; - analyzer.appendAdresses( addresses ); + analyzer.appendAddresses( addresses ); EXPECT_EQ( 2u, analyzer.wellNames().size() ); @@ -131,7 +131,7 @@ TEST( RiaSummaryCurveAnalyzer, CellBlocks ) } RiaSummaryCurveAnalyzer analyzer; - analyzer.appendAdresses( addresses ); + analyzer.appendAddresses( addresses ); auto blocks = analyzer.blocks(); EXPECT_EQ( 3u, blocks.size() );