From 2c73b2ed029ac45a613ec0ce041f2a51341a061e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 4 Oct 2019 18:46:30 +0200 Subject: [PATCH 1/7] #4828 Summary Plot Templates : Support ensembles as plot data sources --- .../RicCreatePlotFromSelectionFeature.cpp | 23 ++-- .../RicCreatePlotFromSelectionFeature.h | 3 - ...reatePlotFromTemplateByShortcutFeature.cpp | 10 +- .../RicCreatePlotFromTemplateFeature.cpp | 25 ++--- .../RicCreatePlotFromTemplateFeature.h | 4 +- .../RicSavePlotTemplateFeature.cpp | 48 ++++++-- .../RicSummaryPlotTemplateTools.cpp | 106 +++++++++++++----- .../RicSummaryPlotTemplateTools.h | 9 +- .../RimContextCommandBuilder.cpp | 2 +- 9 files changed, 152 insertions(+), 78 deletions(-) diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.cpp b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.cpp index 46f80f8873..a2705891e9 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.cpp +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.cpp @@ -40,7 +40,10 @@ CAF_CMD_SOURCE_INIT( RicCreatePlotFromSelectionFeature, "RicCreatePlotFromSelect //-------------------------------------------------------------------------------------------------- bool RicCreatePlotFromSelectionFeature::isCommandEnabled() { - return !selectedSummaryCases().empty(); + bool anySummaryCases = !RicSummaryPlotTemplateTools::selectedSummaryCases().empty(); + bool anySummaryCaseCollections = !RicSummaryPlotTemplateTools::selectedSummaryCaseCollections().empty(); + + return ( anySummaryCases || anySummaryCaseCollections ); } //-------------------------------------------------------------------------------------------------- @@ -48,11 +51,12 @@ bool RicCreatePlotFromSelectionFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicCreatePlotFromSelectionFeature::onActionTriggered( bool isChecked ) { - QString fileName = RicSummaryPlotTemplateTools::selectPlotTemplatePath(); - std::vector sumCases = selectedSummaryCases(); + QString fileName = RicSummaryPlotTemplateTools::selectPlotTemplatePath(); + auto sumCases = RicSummaryPlotTemplateTools::selectedSummaryCases(); + auto sumCaseCollections = RicSummaryPlotTemplateTools::selectedSummaryCaseCollections(); RimSummaryPlot* newSummaryPlot = RicSummaryPlotTemplateTools::createPlotFromTemplateFile( fileName ); - RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases ); + RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases, sumCaseCollections ); } //-------------------------------------------------------------------------------------------------- @@ -63,14 +67,3 @@ void RicCreatePlotFromSelectionFeature::setupActionLook( QAction* actionToSetup actionToSetup->setText( "Create Plot from Template" ); actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) ); } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RicCreatePlotFromSelectionFeature::selectedSummaryCases() const -{ - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - - return objects; -} diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.h b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.h index 65a18dcfef..b8e17a84b9 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.h +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.h @@ -33,7 +33,4 @@ protected: bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; - -private: - std::vector selectedSummaryCases() const; }; diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateByShortcutFeature.cpp b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateByShortcutFeature.cpp index 656b3042c9..3fe5c91479 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateByShortcutFeature.cpp +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateByShortcutFeature.cpp @@ -40,7 +40,10 @@ CAF_CMD_SOURCE_INIT( RicCreatePlotFromTemplateByShortcutFeature, "RicCreatePlotF //-------------------------------------------------------------------------------------------------- bool RicCreatePlotFromTemplateByShortcutFeature::isCommandEnabled() { - return !selectedSummaryCases().empty(); + bool anySummaryCases = !RicSummaryPlotTemplateTools::selectedSummaryCases().empty(); + bool anySummaryCaseCollections = !RicSummaryPlotTemplateTools::selectedSummaryCaseCollections().empty(); + + return ( anySummaryCases || anySummaryCaseCollections ); } //-------------------------------------------------------------------------------------------------- @@ -68,10 +71,11 @@ void RicCreatePlotFromTemplateByShortcutFeature::onActionTriggered( bool isCheck RiaApplication::instance()->preferences()->setDefaultPlotTemplatePath( fileName ); } - std::vector sumCases = selectedSummaryCases(); + auto sumCases = RicSummaryPlotTemplateTools::selectedSummaryCases(); + auto sumCaseCollections = RicSummaryPlotTemplateTools::selectedSummaryCaseCollections(); RimSummaryPlot* newSummaryPlot = RicSummaryPlotTemplateTools::createPlotFromTemplateFile( fileName ); - RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases ); + RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases, sumCaseCollections ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateFeature.cpp b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateFeature.cpp index d78f3b9b30..0107fa75bc 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateFeature.cpp +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateFeature.cpp @@ -20,6 +20,7 @@ #include "RicSummaryPlotTemplateTools.h" #include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" #include "cafSelectionManager.h" @@ -32,7 +33,10 @@ CAF_CMD_SOURCE_INIT( RicCreatePlotFromTemplateFeature, "RicCreatePlotFromTemplat //-------------------------------------------------------------------------------------------------- bool RicCreatePlotFromTemplateFeature::isCommandEnabled() { - return !selectedSummaryCases().empty(); + bool anySummaryCases = !RicSummaryPlotTemplateTools::selectedSummaryCases().empty(); + bool anySummaryCaseCollections = !RicSummaryPlotTemplateTools::selectedSummaryCaseCollections().empty(); + + return ( anySummaryCases || anySummaryCaseCollections ); } //-------------------------------------------------------------------------------------------------- @@ -40,11 +44,13 @@ bool RicCreatePlotFromTemplateFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicCreatePlotFromTemplateFeature::onActionTriggered( bool isChecked ) { - QString fileName = userData().toString(); - std::vector sumCases = selectedSummaryCases(); + QString fileName = userData().toString(); + auto sumCases = RicSummaryPlotTemplateTools::selectedSummaryCases(); + auto sumCaseCollections = RicSummaryPlotTemplateTools::selectedSummaryCaseCollections(); RimSummaryPlot* newSummaryPlot = RicSummaryPlotTemplateTools::createPlotFromTemplateFile( fileName ); - RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases ); + + RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases, sumCaseCollections ); } //-------------------------------------------------------------------------------------------------- @@ -55,14 +61,3 @@ void RicCreatePlotFromTemplateFeature::setupActionLook( QAction* actionToSetup ) actionToSetup->setText( "Create Plot from Template" ); actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) ); } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RicCreatePlotFromTemplateFeature::selectedSummaryCases() const -{ - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - - return objects; -} diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateFeature.h b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateFeature.h index a3194b4412..e06ae25ab8 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateFeature.h +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateFeature.h @@ -23,6 +23,7 @@ #include class RimSummaryCase; +class RimSummaryCaseCollection; //================================================================================================== /// @@ -35,7 +36,4 @@ protected: bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; - -private: - std::vector selectedSummaryCases() const; }; diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp b/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp index 7e3f28de66..9c1a53717e 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp @@ -25,6 +25,8 @@ #include "RiaPreferences.h" #include "RiaSummaryTools.h" +#include "RimEnsembleCurveSet.h" +#include "RimEnsembleCurveSetCollection.h" #include "RimProject.h" #include "RimSummaryCurve.h" #include "RimSummaryPlot.h" @@ -140,24 +142,48 @@ QString RicSavePlotTemplateFeature::createTextFromObject( RimSummaryPlot* summar RimSummaryPlot* newSummaryPlot = dynamic_cast( obj ); if ( newSummaryPlot ) { - std::set caseReferenceStrings; - - for ( const auto& curve : newSummaryPlot->summaryCurves() ) { - auto fieldHandle = curve->findField( "SummaryCase" ); - if ( fieldHandle ) + std::set caseReferenceStrings; + + for ( const auto& curve : newSummaryPlot->summaryCurves() ) { - auto reference = fieldHandle->xmlCapability()->referenceString(); - caseReferenceStrings.insert( reference ); + auto fieldHandle = curve->findField( "SummaryCase" ); + if ( fieldHandle ) + { + auto reference = fieldHandle->xmlCapability()->referenceString(); + caseReferenceStrings.insert( reference ); + } + } + + size_t index = 0; + for ( const auto& s : caseReferenceStrings ) + { + QString caseName = QString( "CASE_NAME %1" ).arg( index++ ); + + objectAsText.replace( s, caseName ); } } - size_t index = 0; - for ( const auto& s : caseReferenceStrings ) { - QString caseName = QString( "CASE_NAME %1" ).arg( index++ ); + std::set ensembleReferenceStrings; - objectAsText.replace( s, caseName ); + for ( const auto& curveSet : newSummaryPlot->ensembleCurveSetCollection()->curveSets() ) + { + auto fieldHandle = curveSet->findField( "SummaryGroup" ); + if ( fieldHandle ) + { + auto reference = fieldHandle->xmlCapability()->referenceString(); + ensembleReferenceStrings.insert( reference ); + } + } + + size_t index = 0; + for ( const auto& s : ensembleReferenceStrings ) + { + QString ensembleName = QString( "ENSEMBLE_NAME %1" ).arg( index++ ); + + objectAsText.replace( s, ensembleName ); + } } } diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp index c8dcae501a..d699963711 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp @@ -29,6 +29,8 @@ #include "PlotTemplates/RimPlotTemplateFileItem.h" #include "RimDialogData.h" +#include "RimEnsembleCurveSet.h" +#include "RimEnsembleCurveSetCollection.h" #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimSummaryCase.h" @@ -40,6 +42,7 @@ #include "cafPdmUiPropertyViewDialog.h" +#include "cafSelectionManager.h" #include //-------------------------------------------------------------------------------------------------- @@ -76,7 +79,9 @@ RimSummaryPlot* RicSummaryPlotTemplateTools::createPlotFromTemplateFile( const Q /// //-------------------------------------------------------------------------------------------------- void RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( - RimSummaryPlot* summaryPlot, const std::vector& selectedSummaryCases ) + RimSummaryPlot* summaryPlot, + const std::vector& selectedSummaryCases, + const std::vector& selectedEnsembles ) { if ( summaryPlot ) { @@ -87,38 +92,40 @@ void RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( summaryPlot->resolveReferencesRecursively(); summaryPlot->initAfterReadRecursively(); - auto summaryCurves = summaryPlot->summaryCurves(); - - for ( const auto& curve : summaryCurves ) { - auto fieldHandle = curve->findField( "SummaryCase" ); - if ( fieldHandle ) + auto summaryCurves = summaryPlot->summaryCurves(); + + for ( const auto& curve : summaryCurves ) { - auto referenceString = fieldHandle->xmlCapability()->referenceString(); - auto stringList = referenceString.split( " " ); - if ( stringList.size() == 2 ) + auto fieldHandle = curve->findField( "SummaryCase" ); + if ( fieldHandle ) { - QString indexAsString = stringList[1]; - - bool conversionOk = false; - auto index = indexAsString.toUInt( &conversionOk ); - - if ( conversionOk && index < selectedSummaryCases.size() ) + auto referenceString = fieldHandle->xmlCapability()->referenceString(); + auto stringList = referenceString.split( " " ); + if ( stringList.size() == 2 ) { - auto summaryCaseY = selectedSummaryCases[index]; - curve->setSummaryCaseY( summaryCaseY ); + QString indexAsString = stringList[1]; - auto currentAddressY = curve->summaryAddressY(); - if ( summaryCaseY->summaryReader() && - !summaryCaseY->summaryReader()->hasAddress( currentAddressY ) ) + bool conversionOk = false; + auto index = indexAsString.toUInt( &conversionOk ); + + if ( conversionOk && index < selectedSummaryCases.size() ) { - auto allAddresses = summaryCaseY->summaryReader()->allResultAddresses(); + auto summaryCaseY = selectedSummaryCases[index]; + curve->setSummaryCaseY( summaryCaseY ); - auto candidate = RicSummaryPlotTemplateTools::firstAddressByQuantity( currentAddressY, - allAddresses ); - if ( candidate.category() != RifEclipseSummaryAddress::SUMMARY_INVALID ) + auto currentAddressY = curve->summaryAddressY(); + if ( summaryCaseY->summaryReader() && + !summaryCaseY->summaryReader()->hasAddress( currentAddressY ) ) { - curve->setSummaryAddressY( candidate ); + auto allAddresses = summaryCaseY->summaryReader()->allResultAddresses(); + + auto candidate = RicSummaryPlotTemplateTools::firstAddressByQuantity( currentAddressY, + allAddresses ); + if ( candidate.category() != RifEclipseSummaryAddress::SUMMARY_INVALID ) + { + curve->setSummaryAddressY( candidate ); + } } } } @@ -126,6 +133,33 @@ void RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( } } + { + auto summaryCurves = summaryPlot->ensembleCurveSetCollection()->curveSets(); + + for ( const auto& curveSet : summaryCurves ) + { + auto fieldHandle = curveSet->findField( "SummaryGroup" ); + if ( fieldHandle ) + { + auto referenceString = fieldHandle->xmlCapability()->referenceString(); + auto stringList = referenceString.split( " " ); + if ( stringList.size() == 2 ) + { + QString indexAsString = stringList[1]; + + bool conversionOk = false; + auto index = indexAsString.toUInt( &conversionOk ); + + if ( conversionOk && index < selectedEnsembles.size() ) + { + auto summaryCaseY = selectedEnsembles[index]; + curveSet->setSummaryCaseCollection( summaryCaseY ); + } + } + } + } + } + // TODO: Create additional curves in selected case count is larger than template count plotColl->updateConnectedEditors(); @@ -255,6 +289,28 @@ QString RicSummaryPlotTemplateTools::selectPlotTemplatePath() return QString(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicSummaryPlotTemplateTools::selectedSummaryCases() +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType( &objects ); + + return objects; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicSummaryPlotTemplateTools::selectedSummaryCaseCollections() +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType( &objects ); + + return objects; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h index 9d657ed068..570494c2d5 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h @@ -30,6 +30,7 @@ class PdmObject; class RimSummaryPlot; class RimSummaryCase; +class RimSummaryCaseCollection; class RifEclipseSummaryAddress; //================================================================================================== @@ -39,8 +40,9 @@ class RicSummaryPlotTemplateTools { public: static RimSummaryPlot* createPlotFromTemplateFile( const QString& fileName ); - static void appendSummaryPlotToPlotCollection( RimSummaryPlot* summaryPlot, - const std::vector& selectedSummaryCases ); + static void appendSummaryPlotToPlotCollection( RimSummaryPlot* summaryPlot, + const std::vector& selectedSummaryCases, + const std::vector& selectedEnsembles ); static QString htmlTextFromPlotAndSelection( const RimSummaryPlot* templatePlot, const std::set& selectedSummaryAddresses, @@ -50,6 +52,9 @@ public: static QString selectPlotTemplatePath(); + static std::vector selectedSummaryCases(); + static std::vector selectedSummaryCaseCollections(); + private: static RifEclipseSummaryAddress firstAddressByQuantity( const RifEclipseSummaryAddress& sourceAddress, const std::set& allAddresses ); diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index af3fb0cc1f..42f9c524af 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -845,7 +845,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicCutReferencesToClipboardFeature"; menuBuilder << "Separator"; - if ( dynamic_cast( uiItem ) ) + if ( dynamic_cast( uiItem ) || dynamic_cast( uiItem ) ) { menuBuilder << "RicCreatePlotFromSelectionFeature"; menuBuilder << "RicCreatePlotFromTemplateByShortcutFeature"; From cd12b3ad4b77e2832cca68d7798f7aa70cfb479e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 4 Oct 2019 18:50:01 +0200 Subject: [PATCH 2/7] Guard null pointer access --- .../Summary/RimSummaryPlotSourceStepping.cpp | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp index 42006636df..3b14fc4faf 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp @@ -615,28 +615,35 @@ std::set RimSummaryPlotSourceStepping::adressesForSour auto curveSets = ensembleCollection->curveSetsForSourceStepping(); for ( const RimEnsembleCurveSet* curveSet : curveSets ) { - auto addresses = curveSet->summaryCaseCollection()->ensembleSummaryAddresses(); - addressSet.insert( addresses.begin(), addresses.end() ); + if ( curveSet && curveSet->summaryCaseCollection() ) + { + 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 ) ) + RimSummaryCurveCollection* curveCollection = nullptr; + this->firstAncestorOrThisOfType( curveCollection ); + if ( curveCollection ) { - if ( isYAxisStepping() && curve->summaryCaseY() && curve->summaryCaseY()->summaryReader() ) + for ( auto curve : curveCollection->curvesForSourceStepping( m_sourceSteppingType ) ) { - auto addresses = curve->summaryCaseY()->summaryReader()->allResultAddresses(); - addressSet.insert( addresses.begin(), addresses.end() ); - } + if ( !curve ) continue; - if ( isXAxisStepping() && curve->summaryCaseX() && curve->summaryCaseX()->summaryReader() ) - { - auto addresses = curve->summaryCaseX()->summaryReader()->allResultAddresses(); - addressSet.insert( addresses.begin(), addresses.end() ); + 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() ); + } } } } From 9365511f3d2111034b74ee0bc9a6219e7aedb08c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 7 Oct 2019 07:47:44 +0200 Subject: [PATCH 3/7] #4828 Summary Plot Templates : Remove unused function --- .../RicCreatePlotFromTemplateByShortcutFeature.cpp | 11 ----------- .../RicCreatePlotFromTemplateByShortcutFeature.h | 3 --- .../RicSummaryPlotTemplateTools.cpp | 2 +- 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateByShortcutFeature.cpp b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateByShortcutFeature.cpp index 3fe5c91479..5beb83479e 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateByShortcutFeature.cpp +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateByShortcutFeature.cpp @@ -89,14 +89,3 @@ void RicCreatePlotFromTemplateByShortcutFeature::setupActionLook( QAction* actio QKeySequence keySeq( Qt::CTRL + Qt::Key_T ); actionToSetup->setShortcut( keySeq ); } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RicCreatePlotFromTemplateByShortcutFeature::selectedSummaryCases() const -{ - std::vector objects; - caf::SelectionManager::instance()->objectsByType( &objects ); - - return objects; -} diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateByShortcutFeature.h b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateByShortcutFeature.h index bc13567d54..2b7cc00fa6 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateByShortcutFeature.h +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromTemplateByShortcutFeature.h @@ -35,7 +35,4 @@ protected: bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; - -private: - std::vector selectedSummaryCases() const; }; diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp index d699963711..68be9aec8b 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp @@ -41,8 +41,8 @@ #include "RiuPlotMainWindow.h" #include "cafPdmUiPropertyViewDialog.h" - #include "cafSelectionManager.h" + #include //-------------------------------------------------------------------------------------------------- From 56a5a750f2813adafce92b7aad9bff54d03fe850 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 7 Oct 2019 10:30:17 +0200 Subject: [PATCH 4/7] #4828 Summary Plot Templates : Improve robustness --- .../RicSavePlotTemplateFeature.cpp | 14 +++++-- .../RicSummaryPlotTemplateTools.cpp | 40 ++++++++++++++++++- .../RicSummaryPlotTemplateTools.h | 5 +++ 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp b/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp index 9c1a53717e..6861c72f24 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp @@ -19,6 +19,7 @@ #include "RicSavePlotTemplateFeature.h" #include "RicReloadPlotTemplatesFeature.h" +#include "RicSummaryPlotTemplateTools.h" #include "RiaGuiApplication.h" #include "RiaLogging.h" @@ -145,9 +146,10 @@ QString RicSavePlotTemplateFeature::createTextFromObject( RimSummaryPlot* summar { std::set caseReferenceStrings; + const QString summaryFieldKeyword = RicSummaryPlotTemplateTools::summaryCaseFieldKeyword(); for ( const auto& curve : newSummaryPlot->summaryCurves() ) { - auto fieldHandle = curve->findField( "SummaryCase" ); + auto fieldHandle = curve->findField( summaryFieldKeyword ); if ( fieldHandle ) { auto reference = fieldHandle->xmlCapability()->referenceString(); @@ -158,7 +160,8 @@ QString RicSavePlotTemplateFeature::createTextFromObject( RimSummaryPlot* summar size_t index = 0; for ( const auto& s : caseReferenceStrings ) { - QString caseName = QString( "CASE_NAME %1" ).arg( index++ ); + QString placeholderText = RicSummaryPlotTemplateTools::placeholderTextForSummaryCase(); + QString caseName = QString( "%1 %2" ).arg( placeholderText ).arg( index++ ); objectAsText.replace( s, caseName ); } @@ -167,9 +170,11 @@ QString RicSavePlotTemplateFeature::createTextFromObject( RimSummaryPlot* summar { std::set ensembleReferenceStrings; + const QString summaryGroupFieldKeyword = RicSummaryPlotTemplateTools::summaryGroupFieldName(); + for ( const auto& curveSet : newSummaryPlot->ensembleCurveSetCollection()->curveSets() ) { - auto fieldHandle = curveSet->findField( "SummaryGroup" ); + auto fieldHandle = curveSet->findField( summaryGroupFieldKeyword ); if ( fieldHandle ) { auto reference = fieldHandle->xmlCapability()->referenceString(); @@ -180,7 +185,8 @@ QString RicSavePlotTemplateFeature::createTextFromObject( RimSummaryPlot* summar size_t index = 0; for ( const auto& s : ensembleReferenceStrings ) { - QString ensembleName = QString( "ENSEMBLE_NAME %1" ).arg( index++ ); + QString placeholderText = RicSummaryPlotTemplateTools::placeholderTextForSummaryGroup(); + QString ensembleName = QString( "%1 %2" ).arg( placeholderText ).arg( index++ ); objectAsText.replace( s, ensembleName ); } diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp index 68be9aec8b..fc8e096fb8 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp @@ -95,9 +95,11 @@ void RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( { auto summaryCurves = summaryPlot->summaryCurves(); + const QString summaryFieldKeyword = RicSummaryPlotTemplateTools::summaryCaseFieldKeyword(); + for ( const auto& curve : summaryCurves ) { - auto fieldHandle = curve->findField( "SummaryCase" ); + auto fieldHandle = curve->findField( summaryFieldKeyword ); if ( fieldHandle ) { auto referenceString = fieldHandle->xmlCapability()->referenceString(); @@ -136,9 +138,11 @@ void RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( { auto summaryCurves = summaryPlot->ensembleCurveSetCollection()->curveSets(); + const QString summaryGroupFieldKeyword = RicSummaryPlotTemplateTools::summaryGroupFieldName(); + for ( const auto& curveSet : summaryCurves ) { - auto fieldHandle = curveSet->findField( "SummaryGroup" ); + auto fieldHandle = curveSet->findField( summaryGroupFieldKeyword ); if ( fieldHandle ) { auto referenceString = fieldHandle->xmlCapability()->referenceString(); @@ -311,6 +315,38 @@ std::vector RicSummaryPlotTemplateTools::selectedSumm return objects; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicSummaryPlotTemplateTools::summaryCaseFieldKeyword() +{ + return "SummaryCase"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicSummaryPlotTemplateTools::summaryGroupFieldName() +{ + return "SummaryGroup"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicSummaryPlotTemplateTools::placeholderTextForSummaryCase() +{ + return "SUMMARY_CASE"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicSummaryPlotTemplateTools::placeholderTextForSummaryGroup() +{ + return "ENSEMBLE"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h index 570494c2d5..7dac745479 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h @@ -55,6 +55,11 @@ public: static std::vector selectedSummaryCases(); static std::vector selectedSummaryCaseCollections(); + static QString summaryCaseFieldKeyword(); + static QString summaryGroupFieldName(); + static QString placeholderTextForSummaryCase(); + static QString placeholderTextForSummaryGroup(); + private: static RifEclipseSummaryAddress firstAddressByQuantity( const RifEclipseSummaryAddress& sourceAddress, const std::set& allAddresses ); From 5a410ca8be01fa4de2416d26beb8de24d1795ed4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 7 Oct 2019 12:05:14 +0200 Subject: [PATCH 5/7] #4828 Summary Plot Templates : Use regexp to match case and index --- .../RicSummaryPlotTemplateTools.cpp | 77 ++++++++++++++----- .../RicSummaryPlotTemplateTools.h | 2 + 2 files changed, 58 insertions(+), 21 deletions(-) diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp index fc8e096fb8..389dfacffa 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp @@ -44,6 +44,7 @@ #include "cafSelectionManager.h" #include +#include //-------------------------------------------------------------------------------------------------- /// @@ -102,32 +103,30 @@ void RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( auto fieldHandle = curve->findField( summaryFieldKeyword ); if ( fieldHandle ) { + bool conversionOk = false; + const QString placeholderString = RicSummaryPlotTemplateTools::placeholderTextForSummaryCase(); + auto referenceString = fieldHandle->xmlCapability()->referenceString(); - auto stringList = referenceString.split( " " ); - if ( stringList.size() == 2 ) + int indexValue = RicSummaryPlotTemplateTools::findValueForKeyword( placeholderString, + referenceString, + &conversionOk ); + + if ( conversionOk && indexValue >= 0 && indexValue < static_cast( selectedSummaryCases.size() ) ) { - QString indexAsString = stringList[1]; + auto summaryCaseY = selectedSummaryCases[static_cast( indexValue )]; + curve->setSummaryCaseY( summaryCaseY ); - bool conversionOk = false; - auto index = indexAsString.toUInt( &conversionOk ); - - if ( conversionOk && index < selectedSummaryCases.size() ) + auto currentAddressY = curve->summaryAddressY(); + if ( summaryCaseY->summaryReader() && + !summaryCaseY->summaryReader()->hasAddress( currentAddressY ) ) { - auto summaryCaseY = selectedSummaryCases[index]; - curve->setSummaryCaseY( summaryCaseY ); + auto allAddresses = summaryCaseY->summaryReader()->allResultAddresses(); - auto currentAddressY = curve->summaryAddressY(); - if ( summaryCaseY->summaryReader() && - !summaryCaseY->summaryReader()->hasAddress( currentAddressY ) ) + auto candidate = RicSummaryPlotTemplateTools::firstAddressByQuantity( currentAddressY, + allAddresses ); + if ( candidate.category() != RifEclipseSummaryAddress::SUMMARY_INVALID ) { - auto allAddresses = summaryCaseY->summaryReader()->allResultAddresses(); - - auto candidate = RicSummaryPlotTemplateTools::firstAddressByQuantity( currentAddressY, - allAddresses ); - if ( candidate.category() != RifEclipseSummaryAddress::SUMMARY_INVALID ) - { - curve->setSummaryAddressY( candidate ); - } + curve->setSummaryAddressY( candidate ); } } } @@ -336,7 +335,7 @@ QString RicSummaryPlotTemplateTools::summaryGroupFieldName() //-------------------------------------------------------------------------------------------------- QString RicSummaryPlotTemplateTools::placeholderTextForSummaryCase() { - return "SUMMARY_CASE"; + return "CASE_NAME"; } //-------------------------------------------------------------------------------------------------- @@ -364,3 +363,39 @@ RifEclipseSummaryAddress return RifEclipseSummaryAddress(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RicSummaryPlotTemplateTools::findValueForKeyword( const QString& keyword, const QString& valueString, bool* ok ) +{ + // Example string : "CASE_NAME 1" + // Will match the string specified by keyword, and return the value captured by the regexp + + QString regexpString = QString( "%1 (\\d++)" ).arg( keyword ); + QRegularExpression rx( regexpString ); + + auto match = rx.match( valueString ); + if ( match.hasMatch() ) + { + QString integerAsText = match.captured( 1 ); + + if ( !integerAsText.isEmpty() ) + { + int integerValue = integerAsText.toInt(); + + if ( ok ) + { + *ok = true; + } + return integerValue; + } + } + + if ( ok ) + { + *ok = false; + } + + return -1; +} diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h index 7dac745479..17f2507afc 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h @@ -63,4 +63,6 @@ public: private: static RifEclipseSummaryAddress firstAddressByQuantity( const RifEclipseSummaryAddress& sourceAddress, const std::set& allAddresses ); + + static int findValueForKeyword( const QString& keyword, const QString& valueString, bool* ok ); }; From cc746a20cb779025849d3e3090def5ec63e2fafd Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 8 Oct 2019 07:27:45 +0200 Subject: [PATCH 6/7] #4828 Summary Plot Templates : Robustification --- .../RicSavePlotTemplateFeature.cpp | 2 +- .../RicSummaryPlotTemplateTools.cpp | 173 +++++++++++------- .../RicSummaryPlotTemplateTools.h | 2 +- 3 files changed, 113 insertions(+), 64 deletions(-) diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp b/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp index 6861c72f24..e22f15f046 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp @@ -170,7 +170,7 @@ QString RicSavePlotTemplateFeature::createTextFromObject( RimSummaryPlot* summar { std::set ensembleReferenceStrings; - const QString summaryGroupFieldKeyword = RicSummaryPlotTemplateTools::summaryGroupFieldName(); + const QString summaryGroupFieldKeyword = RicSummaryPlotTemplateTools::summaryGroupFieldKeyword(); for ( const auto& curveSet : newSummaryPlot->ensembleCurveSetCollection()->curveSets() ) { diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp index 389dfacffa..37ac2f025e 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp @@ -84,91 +84,140 @@ void RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( const std::vector& selectedSummaryCases, const std::vector& selectedEnsembles ) { - if ( summaryPlot ) + if ( !summaryPlot ) return; + + if ( selectedSummaryCases.empty() && selectedEnsembles.empty() ) return; + + RimSummaryPlotCollection* plotColl = RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection(); + + plotColl->summaryPlots.push_back( summaryPlot ); + summaryPlot->resolveReferencesRecursively(); + summaryPlot->initAfterReadRecursively(); + { - RimSummaryPlotCollection* plotColl = - RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection(); + // Replace single summary curves data sources - plotColl->summaryPlots.push_back( summaryPlot ); - summaryPlot->resolveReferencesRecursively(); - summaryPlot->initAfterReadRecursively(); + auto summaryCurves = summaryPlot->summaryCurves(); + const QString summaryFieldKeyword = RicSummaryPlotTemplateTools::summaryCaseFieldKeyword(); + + int maximumIndexValue = -1; + for ( const auto& curve : summaryCurves ) { - auto summaryCurves = summaryPlot->summaryCurves(); - - const QString summaryFieldKeyword = RicSummaryPlotTemplateTools::summaryCaseFieldKeyword(); - - for ( const auto& curve : summaryCurves ) + auto fieldHandle = curve->findField( summaryFieldKeyword ); + if ( fieldHandle ) { - auto fieldHandle = curve->findField( summaryFieldKeyword ); - if ( fieldHandle ) + bool conversionOk = false; + const QString placeholderString = RicSummaryPlotTemplateTools::placeholderTextForSummaryCase(); + + auto referenceString = fieldHandle->xmlCapability()->referenceString(); + int indexValue = RicSummaryPlotTemplateTools::findValueForKeyword( placeholderString, + referenceString, + &conversionOk ); + + maximumIndexValue = std::max( maximumIndexValue, indexValue ); + + if ( conversionOk && indexValue >= 0 && indexValue < static_cast( selectedSummaryCases.size() ) ) { - bool conversionOk = false; - const QString placeholderString = RicSummaryPlotTemplateTools::placeholderTextForSummaryCase(); + auto summaryCaseY = selectedSummaryCases[static_cast( indexValue )]; + curve->setSummaryCaseY( summaryCaseY ); - auto referenceString = fieldHandle->xmlCapability()->referenceString(); - int indexValue = RicSummaryPlotTemplateTools::findValueForKeyword( placeholderString, - referenceString, - &conversionOk ); - - if ( conversionOk && indexValue >= 0 && indexValue < static_cast( selectedSummaryCases.size() ) ) + auto currentAddressY = curve->summaryAddressY(); + if ( summaryCaseY->summaryReader() && !summaryCaseY->summaryReader()->hasAddress( currentAddressY ) ) { - auto summaryCaseY = selectedSummaryCases[static_cast( indexValue )]; - curve->setSummaryCaseY( summaryCaseY ); + auto allAddresses = summaryCaseY->summaryReader()->allResultAddresses(); - auto currentAddressY = curve->summaryAddressY(); - if ( summaryCaseY->summaryReader() && - !summaryCaseY->summaryReader()->hasAddress( currentAddressY ) ) + auto candidate = RicSummaryPlotTemplateTools::firstAddressByQuantity( currentAddressY, + allAddresses ); + if ( candidate.category() != RifEclipseSummaryAddress::SUMMARY_INVALID ) { - auto allAddresses = summaryCaseY->summaryReader()->allResultAddresses(); - - auto candidate = RicSummaryPlotTemplateTools::firstAddressByQuantity( currentAddressY, - allAddresses ); - if ( candidate.category() != RifEclipseSummaryAddress::SUMMARY_INVALID ) - { - curve->setSummaryAddressY( candidate ); - } + curve->setSummaryAddressY( candidate ); } } } } } + if ( selectedSummaryCases.size() > static_cast( maximumIndexValue ) ) { - auto summaryCurves = summaryPlot->ensembleCurveSetCollection()->curveSets(); + // Use the curve style of the last curve in template, and duplicate this for remaining data sources - const QString summaryGroupFieldKeyword = RicSummaryPlotTemplateTools::summaryGroupFieldName(); - - for ( const auto& curveSet : summaryCurves ) + if ( !summaryCurves.empty() ) { - auto fieldHandle = curveSet->findField( summaryGroupFieldKeyword ); - if ( fieldHandle ) + auto lastSummaryCurve = summaryCurves.back(); + + for ( size_t i = maximumIndexValue; i < selectedSummaryCases.size(); i++ ) { - auto referenceString = fieldHandle->xmlCapability()->referenceString(); - auto stringList = referenceString.split( " " ); - if ( stringList.size() == 2 ) - { - QString indexAsString = stringList[1]; + auto newCurve = dynamic_cast( + lastSummaryCurve->xmlCapability()->copyByXmlSerialization( + caf::PdmDefaultObjectFactory::instance() ) ); - bool conversionOk = false; - auto index = indexAsString.toUInt( &conversionOk ); - - if ( conversionOk && index < selectedEnsembles.size() ) - { - auto summaryCaseY = selectedEnsembles[index]; - curveSet->setSummaryCaseCollection( summaryCaseY ); - } - } + auto summaryCaseY = selectedSummaryCases[i]; + newCurve->setSummaryCaseY( summaryCaseY ); + summaryPlot->addCurveAndUpdate( newCurve ); } } } - - // TODO: Create additional curves in selected case count is larger than template count - - plotColl->updateConnectedEditors(); - - summaryPlot->loadDataAndUpdate(); } + + { + // Replace ensemble data sources + + auto summaryCurveSets = summaryPlot->ensembleCurveSetCollection()->curveSets(); + + const QString summaryGroupFieldKeyword = RicSummaryPlotTemplateTools::summaryGroupFieldKeyword(); + + int maximumIndexValue = -1; + + for ( const auto& curveSet : summaryCurveSets ) + { + auto fieldHandle = curveSet->findField( summaryGroupFieldKeyword ); + if ( fieldHandle ) + { + bool conversionOk = false; + const QString placeholderString = RicSummaryPlotTemplateTools::placeholderTextForSummaryGroup(); + + auto referenceString = fieldHandle->xmlCapability()->referenceString(); + int indexValue = RicSummaryPlotTemplateTools::findValueForKeyword( placeholderString, + referenceString, + &conversionOk ); + + maximumIndexValue = std::max( maximumIndexValue, indexValue ); + + if ( conversionOk && indexValue < selectedEnsembles.size() ) + { + auto summaryCaseY = selectedEnsembles[indexValue]; + curveSet->setSummaryCaseCollection( summaryCaseY ); + } + } + } + + if ( selectedEnsembles.size() > static_cast( maximumIndexValue ) ) + { + // Use the curve style of the last curve in template, and duplicate this for remaining data sources + + if ( !summaryCurveSets.empty() ) + { + auto lastSummaryCurveSet = summaryCurveSets.back(); + + for ( size_t i = maximumIndexValue; i < selectedEnsembles.size(); i++ ) + { + auto newCurveSet = dynamic_cast( + lastSummaryCurveSet->xmlCapability()->copyByXmlSerialization( + caf::PdmDefaultObjectFactory::instance() ) ); + + auto ensembleDataSource = selectedEnsembles[i]; + newCurveSet->setSummaryCaseCollection( ensembleDataSource ); + + summaryPlot->ensembleCurveSetCollection()->addCurveSet( newCurveSet ); + } + } + } + } + + plotColl->updateConnectedEditors(); + + summaryPlot->loadDataAndUpdate(); } //-------------------------------------------------------------------------------------------------- @@ -325,7 +374,7 @@ QString RicSummaryPlotTemplateTools::summaryCaseFieldKeyword() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RicSummaryPlotTemplateTools::summaryGroupFieldName() +QString RicSummaryPlotTemplateTools::summaryGroupFieldKeyword() { return "SummaryGroup"; } @@ -343,7 +392,7 @@ QString RicSummaryPlotTemplateTools::placeholderTextForSummaryCase() //-------------------------------------------------------------------------------------------------- QString RicSummaryPlotTemplateTools::placeholderTextForSummaryGroup() { - return "ENSEMBLE"; + return "ENSEMBLE_NAME"; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h index 17f2507afc..93166a6039 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.h @@ -56,7 +56,7 @@ public: static std::vector selectedSummaryCaseCollections(); static QString summaryCaseFieldKeyword(); - static QString summaryGroupFieldName(); + static QString summaryGroupFieldKeyword(); static QString placeholderTextForSummaryCase(); static QString placeholderTextForSummaryGroup(); From 55224bed3d023ec8c01839c002fe423cb8864d88 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 8 Oct 2019 08:18:09 +0200 Subject: [PATCH 7/7] Fix signed/unsigned compare --- .../PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp | 2 +- ApplicationCode/UserInterface/RiuQwtPlotCurve.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp index 37ac2f025e..865f55fbcd 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicSummaryPlotTemplateTools.cpp @@ -184,7 +184,7 @@ void RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( maximumIndexValue = std::max( maximumIndexValue, indexValue ); - if ( conversionOk && indexValue < selectedEnsembles.size() ) + if ( conversionOk && indexValue < static_cast( selectedEnsembles.size() ) ) { auto summaryCaseY = selectedEnsembles[indexValue]; curveSet->setSummaryCaseCollection( summaryCaseY ); diff --git a/ApplicationCode/UserInterface/RiuQwtPlotCurve.cpp b/ApplicationCode/UserInterface/RiuQwtPlotCurve.cpp index 5e9bc93a50..dc0cd7fb24 100644 --- a/ApplicationCode/UserInterface/RiuQwtPlotCurve.cpp +++ b/ApplicationCode/UserInterface/RiuQwtPlotCurve.cpp @@ -308,9 +308,9 @@ void RiuQwtPlotCurve::drawSymbols( QPainter* painter, if ( sym ) { - if ( m_perPointLabels.size() == pointsToDisplay.size() ) + if ( m_perPointLabels.size() == static_cast( pointsToDisplay.size() ) ) { - for ( int i = 0; i < (int)pointsToDisplay.size(); ++i ) + for ( int i = 0; i < pointsToDisplay.size(); ++i ) { sym->renderSymbolLabel( painter, pointsToDisplay[i], m_perPointLabels[i] ); }