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..5beb83479e 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 ); } //-------------------------------------------------------------------------------------------------- @@ -85,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/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..e22f15f046 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp @@ -19,12 +19,15 @@ #include "RicSavePlotTemplateFeature.h" #include "RicReloadPlotTemplatesFeature.h" +#include "RicSummaryPlotTemplateTools.h" #include "RiaGuiApplication.h" #include "RiaLogging.h" #include "RiaPreferences.h" #include "RiaSummaryTools.h" +#include "RimEnsembleCurveSet.h" +#include "RimEnsembleCurveSetCollection.h" #include "RimProject.h" #include "RimSummaryCurve.h" #include "RimSummaryPlot.h" @@ -140,24 +143,53 @@ 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; + + const QString summaryFieldKeyword = RicSummaryPlotTemplateTools::summaryCaseFieldKeyword(); + for ( const auto& curve : newSummaryPlot->summaryCurves() ) { - auto reference = fieldHandle->xmlCapability()->referenceString(); - caseReferenceStrings.insert( reference ); + auto fieldHandle = curve->findField( summaryFieldKeyword ); + if ( fieldHandle ) + { + auto reference = fieldHandle->xmlCapability()->referenceString(); + caseReferenceStrings.insert( reference ); + } + } + + size_t index = 0; + for ( const auto& s : caseReferenceStrings ) + { + QString placeholderText = RicSummaryPlotTemplateTools::placeholderTextForSummaryCase(); + QString caseName = QString( "%1 %2" ).arg( placeholderText ).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 ); + const QString summaryGroupFieldKeyword = RicSummaryPlotTemplateTools::summaryGroupFieldKeyword(); + + for ( const auto& curveSet : newSummaryPlot->ensembleCurveSetCollection()->curveSets() ) + { + auto fieldHandle = curveSet->findField( summaryGroupFieldKeyword ); + if ( fieldHandle ) + { + auto reference = fieldHandle->xmlCapability()->referenceString(); + ensembleReferenceStrings.insert( reference ); + } + } + + size_t index = 0; + for ( const auto& s : ensembleReferenceStrings ) + { + 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 c8dcae501a..865f55fbcd 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" @@ -39,8 +41,10 @@ #include "RiuPlotMainWindow.h" #include "cafPdmUiPropertyViewDialog.h" +#include "cafSelectionManager.h" #include +#include //-------------------------------------------------------------------------------------------------- /// @@ -76,62 +80,144 @@ 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 ) - { - RimSummaryPlotCollection* plotColl = - RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection(); + if ( !summaryPlot ) return; - plotColl->summaryPlots.push_back( summaryPlot ); - summaryPlot->resolveReferencesRecursively(); - summaryPlot->initAfterReadRecursively(); + if ( selectedSummaryCases.empty() && selectedEnsembles.empty() ) return; + + RimSummaryPlotCollection* plotColl = RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection(); + + plotColl->summaryPlots.push_back( summaryPlot ); + summaryPlot->resolveReferencesRecursively(); + summaryPlot->initAfterReadRecursively(); + + { + // Replace single summary curves data sources auto summaryCurves = summaryPlot->summaryCurves(); + const QString summaryFieldKeyword = RicSummaryPlotTemplateTools::summaryCaseFieldKeyword(); + + int maximumIndexValue = -1; for ( const auto& curve : summaryCurves ) { - auto fieldHandle = curve->findField( "SummaryCase" ); + 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 ); + + maximumIndexValue = std::max( maximumIndexValue, indexValue ); + + 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 ); } } } } } - // TODO: Create additional curves in selected case count is larger than template count + if ( selectedSummaryCases.size() > static_cast( maximumIndexValue ) ) + { + // Use the curve style of the last curve in template, and duplicate this for remaining data sources - plotColl->updateConnectedEditors(); + if ( !summaryCurves.empty() ) + { + auto lastSummaryCurve = summaryCurves.back(); - summaryPlot->loadDataAndUpdate(); + for ( size_t i = maximumIndexValue; i < selectedSummaryCases.size(); i++ ) + { + auto newCurve = dynamic_cast( + lastSummaryCurve->xmlCapability()->copyByXmlSerialization( + caf::PdmDefaultObjectFactory::instance() ) ); + + auto summaryCaseY = selectedSummaryCases[i]; + newCurve->setSummaryCaseY( summaryCaseY ); + summaryPlot->addCurveAndUpdate( newCurve ); + } + } + } } + + { + // 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 < static_cast( 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(); } //-------------------------------------------------------------------------------------------------- @@ -255,6 +341,60 @@ 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; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicSummaryPlotTemplateTools::summaryCaseFieldKeyword() +{ + return "SummaryCase"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicSummaryPlotTemplateTools::summaryGroupFieldKeyword() +{ + return "SummaryGroup"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicSummaryPlotTemplateTools::placeholderTextForSummaryCase() +{ + return "CASE_NAME"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicSummaryPlotTemplateTools::placeholderTextForSummaryGroup() +{ + return "ENSEMBLE_NAME"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -272,3 +412,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 9d657ed068..93166a6039 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,7 +52,17 @@ public: static QString selectPlotTemplatePath(); + static std::vector selectedSummaryCases(); + static std::vector selectedSummaryCaseCollections(); + + static QString summaryCaseFieldKeyword(); + static QString summaryGroupFieldKeyword(); + static QString placeholderTextForSummaryCase(); + static QString placeholderTextForSummaryGroup(); + private: static RifEclipseSummaryAddress firstAddressByQuantity( const RifEclipseSummaryAddress& sourceAddress, const std::set& allAddresses ); + + static int findValueForKeyword( const QString& keyword, const QString& valueString, bool* ok ); }; 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"; 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() ); + } } } } 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] ); }