#2819 Ensemble curves. Distinguish between summary case group and ensemble

This commit is contained in:
Bjørn Erik Jensen 2018-05-08 15:22:38 +02:00
parent 9d51b91931
commit 98daab46a3
16 changed files with 222 additions and 13 deletions

View File

@ -67,6 +67,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicShowGridStatisticsFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicFileHierarchyDialog.h
${CMAKE_CURRENT_LIST_DIR}/RicSummaryCaseRestartDialog.h
${CMAKE_CURRENT_LIST_DIR}/RicImportEnsembleFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryGroupFeature.h
)
@ -132,6 +133,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicShowGridStatisticsFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicFileHierarchyDialog.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSummaryCaseRestartDialog.cpp
${CMAKE_CURRENT_LIST_DIR}/RicImportEnsembleFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryGroupFeature.cpp
)

View File

@ -36,14 +36,14 @@ CAF_CMD_SOURCE_INIT(RicCreateSummaryCaseCollectionFeature, "RicCreateSummaryCase
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreateSummaryCaseCollectionFeature::groupSummaryCases(std::vector<RimSummaryCase*> cases, const QString& groupName)
void RicCreateSummaryCaseCollectionFeature::groupSummaryCases(std::vector<RimSummaryCase*> cases, const QString& groupName, bool isEnsemble)
{
RimSummaryCaseMainCollection* summaryCaseMainCollection = nullptr;
if (!cases.empty())
{
cases[0]->firstAncestorOrThisOfTypeAsserted(summaryCaseMainCollection);
summaryCaseMainCollection->addCaseCollection(cases, groupName);
summaryCaseMainCollection->addCaseCollection(cases, groupName, isEnsemble);
summaryCaseMainCollection->updateConnectedEditors();
RiuPlotMainWindowTools::showPlotMainWindow();
@ -92,5 +92,5 @@ void RicCreateSummaryCaseCollectionFeature::onActionTriggered(bool isChecked)
void RicCreateSummaryCaseCollectionFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Group Summary Cases");
actionToSetup->setIcon(QIcon(":/SummaryEnsemble16x16.png"));
actionToSetup->setIcon(QIcon(":/SummaryGroup16x16.png"));
}

View File

@ -31,7 +31,7 @@ class RicCreateSummaryCaseCollectionFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
static void groupSummaryCases(std::vector<RimSummaryCase*> cases, const QString& groupName);
static void groupSummaryCases(std::vector<RimSummaryCase*> cases, const QString& groupName, bool isEnsemble = false);
private:
virtual bool isCommandEnabled() override;

View File

@ -125,7 +125,7 @@ void RicDeleteSummaryCaseCollectionFeature::onActionTriggered(bool isChecked)
//--------------------------------------------------------------------------------------------------
void RicDeleteSummaryCaseCollectionFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Delete Summary Case Group");
actionToSetup->setText("Delete Summary Case Group/Ensemble");
actionToSetup->setIcon(QIcon(":/Erase.png"));
}

View File

@ -31,6 +31,7 @@
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryPlotCollection.h"
@ -74,7 +75,7 @@ void RicImportEnsembleFeature::onActionTriggered(bool isChecked)
validateEnsembleCases(cases);
RicImportSummaryCasesFeature::addSummaryCases(cases);
RicCreateSummaryCaseCollectionFeature::groupSummaryCases(cases, ensembleName);
RicCreateSummaryCaseCollectionFeature::groupSummaryCases(cases, ensembleName, true);
RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow();
if (mainPlotWindow && !cases.empty())
@ -162,13 +163,15 @@ bool RicImportEnsembleFeature::validateEnsembleCases(std::vector<RimSummaryCase*
QString RicImportEnsembleFeature::askForEnsembleName()
{
RimProject* project = RiaApplication::instance()->project();
int groupCount = (int)project->summaryGroups().size() + 1;
std::vector<RimSummaryCaseCollection*> groups = project->summaryGroups();
int ensembleCount = std::count_if(groups.begin(), groups.end(), [](RimSummaryCaseCollection* group) { return group->isEnsemble(); });
ensembleCount += 1;
QInputDialog dialog;
dialog.setInputMode(QInputDialog::TextInput);
dialog.setWindowTitle("Ensemble Name");
dialog.setLabelText("Ensemble Name");
dialog.setTextValue(QString("Ensemble %1").arg(groupCount));
dialog.setTextValue(QString("Ensemble %1").arg(ensembleCount));
dialog.resize(300, 50);
dialog.exec();
return dialog.result() == QDialog::Accepted ? dialog.textValue() : QString("");

View File

@ -0,0 +1,98 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicImportSummaryGroupFeature.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RicImportSummaryCasesFeature.h"
#include "RicCreateSummaryCaseCollectionFeature.h"
#include "RifSummaryCaseRestartSelector.h"
#include "RimGridSummaryCase.h"
#include "RimMainPlotCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryPlotCollection.h"
#include "RiuPlotMainWindow.h"
#include "RiuMainWindow.h"
#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h"
#include <QAction>
#include <QFileDialog>
#include <QMessageBox>
#include <QInputDialog>
CAF_CMD_SOURCE_INIT(RicImportSummaryGroupFeature, "RicImportSummaryGroupFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicImportSummaryGroupFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicImportSummaryGroupFeature::onActionTriggered(bool isChecked)
{
RiaApplication* app = RiaApplication::instance();
QStringList fileNames = RicImportSummaryCasesFeature::runRecursiveSummaryCaseFileSearchDialog("Import Ensemble");
if (fileNames.isEmpty()) return;
std::vector<RimSummaryCase*> cases;
RicImportSummaryCasesFeature::createSummaryCasesFromFiles(fileNames, &cases);
RicImportSummaryCasesFeature::addSummaryCases(cases);
RicCreateSummaryCaseCollectionFeature::groupSummaryCases(cases, "", false);
RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow();
if (mainPlotWindow && !cases.empty())
{
mainPlotWindow->selectAsCurrentItem(cases.back());
mainPlotWindow->updateSummaryPlotToolBar();
}
std::vector<RimCase*> allCases;
app->project()->allCases(allCases);
if (allCases.size() == 0)
{
RiuMainWindow::instance()->close();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicImportSummaryGroupFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setIcon(QIcon(":/SummaryGroup16x16.png"));
actionToSetup->setText("Import Summary Case Group");
}

View File

@ -0,0 +1,45 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RiaPreferences.h"
#include "cafCmdFeature.h"
#include <QString>
class RimSummaryCase;
//==================================================================================================
///
//==================================================================================================
class RicImportSummaryGroupFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
};

View File

@ -85,7 +85,7 @@ void RicNewSummaryEnsembleCurveSetFeature::onActionTriggered(bool isChecked)
//--------------------------------------------------------------------------------------------------
void RicNewSummaryEnsembleCurveSetFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("New Summary Ensemble Curve Set");
actionToSetup->setText("New Ensemble Curve Set");
actionToSetup->setIcon(QIcon(":/EnsembleCurveSet16x16.png"));
}

View File

@ -480,6 +480,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
{
menuBuilder << "RicImportSummaryCaseFeature";
menuBuilder << "RicImportSummaryCasesFeature";
menuBuilder << "RicImportSummaryGroupFeature";
menuBuilder << "RicImportEnsembleFeature";
}
else if (dynamic_cast<RimSummaryCaseCollection*>(uiItem))
@ -487,6 +488,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder.subMenuStart("Import");
menuBuilder << "RicImportSummaryCaseFeature";
menuBuilder << "RicImportSummaryCasesFeature";
menuBuilder << "RicImportSummaryGroupFeature";
menuBuilder << "RicImportEnsembleFeature";
menuBuilder.subMenuEnd();
menuBuilder.addSeparator();
@ -499,6 +501,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder.subMenuStart("Import");
menuBuilder << "RicImportSummaryCaseFeature";
menuBuilder << "RicImportSummaryCasesFeature";
menuBuilder << "RicImportSummaryGroupFeature";
menuBuilder << "RicImportEnsembleFeature";
menuBuilder.subMenuEnd();
menuBuilder.addSeparator();

View File

@ -84,7 +84,7 @@ RimEnsembleCurveSet::RimEnsembleCurveSet()
m_showCurves.uiCapability()->setUiHidden(true);
// Y Values
CAF_PDM_InitFieldNoDefault(&m_yValuesSummaryGroup, "SummaryGroup", "Group", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_yValuesSummaryGroup, "SummaryGroup", "Ensemble", "", "", "");
m_yValuesSummaryGroup.uiCapability()->setUiTreeChildrenHidden(true);
m_yValuesSummaryGroup.uiCapability()->setAutoAddingOptionFromValue(false);
@ -539,7 +539,7 @@ QList<caf::PdmOptionItemInfo> RimEnsembleCurveSet::calculateValueOptions(const c
for (RimSummaryCaseCollection* group : groups)
{
options.push_back(caf::PdmOptionItemInfo(group->name(), group));
if(group->isEnsemble()) options.push_back(caf::PdmOptionItemInfo(group->name(), group));
}
options.push_front(caf::PdmOptionItemInfo("None", nullptr));

View File

@ -41,6 +41,9 @@ RimSummaryCaseCollection::RimSummaryCaseCollection()
m_nameAndItemCount.registerGetMethod(this, &RimSummaryCaseCollection::nameAndItemCount);
m_nameAndItemCount.uiCapability()->setUiReadOnly(true);
m_nameAndItemCount.xmlCapability()->setIOWritable(false);
CAF_PDM_InitField(&m_isEnsemble, "IsEnsemble", false, "Is Ensemble", "", "", "");
m_isEnsemble.uiCapability()->setUiHidden(true);
}
//--------------------------------------------------------------------------------------------------
@ -94,6 +97,23 @@ QString RimSummaryCaseCollection::name() const
return m_name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryCaseCollection::isEnsemble() const
{
return m_isEnsemble();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCaseCollection::setAsEnsemble(bool isEnsemble)
{
m_isEnsemble = isEnsemble;
updateIcon();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -131,3 +151,31 @@ QString RimSummaryCaseCollection::nameAndItemCount() const
return m_name();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCaseCollection::updateIcon()
{
if (m_isEnsemble) setUiIcon(QIcon(":/SummaryEnsemble16x16.png"));
else setUiIcon(QIcon(":/SummaryGroup16x16.png"));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCaseCollection::initAfterRead()
{
updateIcon();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCaseCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if (changedField == &m_isEnsemble)
{
updateIcon();
}
}

View File

@ -40,14 +40,21 @@ public:
std::vector<RimSummaryCase*> allSummaryCases();
void setName(const QString& name);
QString name() const;
bool isEnsemble() const;
void setAsEnsemble(bool isEnsemble);
private:
caf::PdmFieldHandle* userDescriptionField() override;
void updateReferringCurveSets() const;
QString nameAndItemCount() const;
void updateIcon();
virtual void initAfterRead() override;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
private:
caf::PdmChildArrayField<RimSummaryCase*> m_cases;
caf::PdmField<QString> m_name;
caf::PdmProxyValueField<QString> m_nameAndItemCount;
caf::PdmField<bool> m_isEnsemble;
};

View File

@ -205,10 +205,11 @@ void RimSummaryCaseMainCollection::removeCase(RimSummaryCase* summaryCase)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCaseMainCollection::addCaseCollection(std::vector<RimSummaryCase*> summaryCases, const QString& collectionName)
void RimSummaryCaseMainCollection::addCaseCollection(std::vector<RimSummaryCase*> summaryCases, const QString& collectionName, bool isEnsemble)
{
RimSummaryCaseCollection* summaryCaseCollection = new RimSummaryCaseCollection();
if(!collectionName.isEmpty()) summaryCaseCollection->setName(collectionName);
summaryCaseCollection->setAsEnsemble(isEnsemble);
for (RimSummaryCase* summaryCase : summaryCases)
{

View File

@ -55,7 +55,7 @@ public:
void addCase(RimSummaryCase* summaryCase);
void removeCase(RimSummaryCase* summaryCase);
void addCaseCollection(std::vector<RimSummaryCase*> summaryCases, const QString& coolectionName);
void addCaseCollection(std::vector<RimSummaryCase*> summaryCases, const QString& coolectionName, bool isEnsemble);
void removeCaseCollection(RimSummaryCaseCollection* caseCollection);
void loadAllSummaryCaseData();

View File

@ -392,6 +392,7 @@ void RiuMainWindow::createMenus()
QMenu* importSummaryMenu = importMenu->addMenu(QIcon(":/SummaryCase48x48.png"), "Summary Cases");
importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature"));
importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature"));
importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryGroupFeature"));
importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature"));
importMenu->addSeparator();

View File

@ -196,6 +196,7 @@ void RiuPlotMainWindow::createMenus()
QMenu* importSummaryMenu = importMenu->addMenu(QIcon(":/SummaryCase48x48.png"), "Summary Cases");
importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature"));
importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature"));
importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryGroupFeature"));
importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature"));
importMenu->addSeparator();