Merge pull request #4620 from OPM/bug-#4617

#4617 Disallow creating ensemble curve sets if you have no ensemble
This commit is contained in:
Magne Sjaastad 2019-08-22 14:16:12 +02:00 committed by GitHub
commit 8c7d7e8711
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,7 +78,7 @@ RimEnsembleCurveSet* RicNewSummaryEnsembleCurveSetFeature::addDefaultCurveSet(Ri
void RicNewSummaryEnsembleCurveSetFeature::createPlotForCurveSetAndUpdate(RimSummaryCaseCollection* ensemble)
{
RiaGuiApplication* app = RiaGuiApplication::instance();
RimProject* proj = app->project();
RimProject* proj = app->project();
RimSummaryPlotCollection* summaryPlotCollection = proj->mainPlotCollection->summaryPlotCollection();
RimSummaryPlot* plot = summaryPlotCollection->createSummaryPlotWithAutoTitle();
@ -100,7 +100,17 @@ void RicNewSummaryEnsembleCurveSetFeature::createPlotForCurveSetAndUpdate(RimSum
//--------------------------------------------------------------------------------------------------
bool RicNewSummaryEnsembleCurveSetFeature::isCommandEnabled()
{
return (selectedSummaryPlot());
bool summaryPlotSelected = selectedSummaryPlot();
if (summaryPlotSelected)
{
RimProject* project = RiaApplication::instance()->project();
CVF_ASSERT(project);
if (!project->summaryGroups().empty())
{
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
@ -114,6 +124,7 @@ void RicNewSummaryEnsembleCurveSetFeature::onActionTriggered(bool isChecked)
RimSummaryPlot* plot = selectedSummaryPlot();
if (plot)
{
CVF_ASSERT(!project->summaryGroups().empty());
auto ensemble = project->summaryGroups().back();
RicNewSummaryEnsembleCurveSetFeature::createPlotForCurveSetAndUpdate(ensemble);