#1840 Summary case: Delete a summary collection with or without its contents

This commit is contained in:
Rebecca Cox
2017-09-08 15:26:13 +02:00
parent 788ac2c8a8
commit c60465b380
14 changed files with 273 additions and 68 deletions

View File

@@ -178,7 +178,7 @@ bool RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl(const QStr
curveFilter->updateConnectedEditors();
}
sumCaseColl->deleteCase(existingFileSummaryCase);
sumCaseColl->removeCase(existingFileSummaryCase);
delete existingFileSummaryCase;

View File

@@ -7,7 +7,7 @@ endif()
set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RicCloseCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseCollectionFeature.h
${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseInCollectionFeature.h
${CEE_CURRENT_LIST_DIR}RicCreateSummaryCaseCollectionFeature.h
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterFeatureImpl.h
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertFeature.h
@@ -43,6 +43,7 @@ ${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.h
${CEE_CURRENT_LIST_DIR}RicDeleteItemExecData.h
${CEE_CURRENT_LIST_DIR}RicDeleteItemFeature.h
${CEE_CURRENT_LIST_DIR}RicDeleteSubItemsFeature.h
${CEE_CURRENT_LIST_DIR}RicDeleteSummaryCaseCollectionFeature.h
${CEE_CURRENT_LIST_DIR}RicCloseSourSimDataFeature.h
@@ -73,7 +74,7 @@ endif()
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RicCloseCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseCollectionFeature.cpp
${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseInCollectionFeature.cpp
${CEE_CURRENT_LIST_DIR}RicCreateSummaryCaseCollectionFeature.cpp
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterFeatureImpl.cpp
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertFeature.cpp
@@ -106,6 +107,7 @@ ${CEE_CURRENT_LIST_DIR}RicDeleteItemExecData.cpp
${CEE_CURRENT_LIST_DIR}RicDeleteItemFeature.cpp
${CEE_CURRENT_LIST_DIR}RicDeleteSubItemsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicDeleteSummaryCaseCollectionFeature.cpp
${CEE_CURRENT_LIST_DIR}RicCloseSourSimDataFeature.cpp

View File

@@ -49,13 +49,7 @@ void RicCloseSummaryCaseFeature::setupActionLook(QAction* actionToSetup)
//--------------------------------------------------------------------------------------------------
void RicCloseSummaryCaseFeature::deleteSummaryCases(const std::vector<RimSummaryCase*>& cases)
{
RimProject* project = RiaApplication::instance()->project();
CVF_ASSERT(project);
RimMainPlotCollection* mainPlotColl = project->mainPlotCollection();
CVF_ASSERT(mainPlotColl);
RimSummaryPlotCollection* summaryPlotColl = mainPlotColl->summaryPlotCollection();
RimSummaryPlotCollection* summaryPlotColl = RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection();
CVF_ASSERT(summaryPlotColl);
for (RimSummaryCase* summaryCase : cases)
@@ -69,7 +63,7 @@ void RicCloseSummaryCaseFeature::deleteSummaryCases(const std::vector<RimSummary
RimSummaryCaseMainCollection* summaryCaseMainCollection = nullptr;
summaryCase->firstAncestorOrThisOfTypeAsserted(summaryCaseMainCollection);
summaryCaseMainCollection->deleteCase(summaryCase);
summaryCaseMainCollection->removeCase(summaryCase);
delete summaryCase;
summaryCaseMainCollection->updateConnectedEditors();
}

View File

@@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicCloseSummaryCaseCollectionFeature.h"
#include "RicCloseSummaryCaseInCollectionFeature.h"
#include "RiaApplication.h"
@@ -38,21 +38,21 @@
#include <vector>
CAF_CMD_SOURCE_INIT(RicCloseSummaryCaseCollectionFeature, "RicCloseSummaryCaseCollectionFeature");
CAF_CMD_SOURCE_INIT(RicCloseSummaryCaseInCollectionFeature, "RicCloseSummaryCaseInCollectionFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCloseSummaryCaseCollectionFeature::setupActionLook(QAction* actionToSetup)
void RicCloseSummaryCaseInCollectionFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Close Sub Items");
actionToSetup->setText("Close Summary Cases");
actionToSetup->setIcon(QIcon(":/Erase.png"));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicCloseSummaryCaseCollectionFeature::isCommandEnabled()
bool RicCloseSummaryCaseInCollectionFeature::isCommandEnabled()
{
std::vector<RimSummaryCaseMainCollection*> summaryCaseMainCollections;
caf::SelectionManager::instance()->objectsByType(&summaryCaseMainCollections);
@@ -66,7 +66,7 @@ bool RicCloseSummaryCaseCollectionFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCloseSummaryCaseCollectionFeature::onActionTriggered(bool isChecked)
void RicCloseSummaryCaseInCollectionFeature::onActionTriggered(bool isChecked)
{
std::vector<RimSummaryCaseMainCollection*> summaryCaseMainCollections;
caf::SelectionManager::instance()->objectsByType(&summaryCaseMainCollections);

View File

@@ -23,7 +23,7 @@
//==================================================================================================
///
//==================================================================================================
class RicCloseSummaryCaseCollectionFeature : public caf::CmdFeature
class RicCloseSummaryCaseInCollectionFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;

View File

@@ -37,14 +37,7 @@ bool RicCreateSummaryCaseCollectionFeature::isCommandEnabled()
std::vector<RimSummaryCase*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
RimSummaryCaseCollection* summaryCaseCollection = nullptr;
if (selection.size() > 0)
{
selection[0]->firstAncestorOrThisOfType(summaryCaseCollection);
}
return (selection.size() > 0 && !summaryCaseCollection);
return (selection.size() > 0);
}
//--------------------------------------------------------------------------------------------------

View File

@@ -0,0 +1,163 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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 "RicDeleteSummaryCaseCollectionFeature.h"
#include "RiaApplication.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "cafPdmObject.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include <QAction>
#include <QMessageBox>
CAF_CMD_SOURCE_INIT(RicDeleteSummaryCaseCollectionFeature, "RicDeleteSummaryCaseCollectionFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDeleteSummaryCaseCollectionFeature::deleteSummaryCaseCollection(RimSummaryCaseCollection* caseCollection)
{
RimSummaryPlotCollection* summaryPlotColl = RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection();
for (RimSummaryCase* summaryCase : caseCollection->allSummaryCases())
{
for (RimSummaryPlot* summaryPlot : summaryPlotColl->summaryPlots)
{
summaryPlot->removeCurvesAssosiatedWithCase(summaryCase);
}
}
summaryPlotColl->updateConnectedEditors();
/*RimSummaryCaseMainCollection* summaryCaseMainCollection = nullptr;
caseCollection->firstAncestorOrThisOfTypeAsserted(summaryCaseMainCollection);
summaryCaseMainCollection->removeCaseCollection(caseCollection);
delete caseCollection;*/
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicDeleteSummaryCaseCollectionFeature::isCommandEnabled()
{
std::vector<RimSummaryCaseCollection*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
return (selection.size() > 0);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDeleteSummaryCaseCollectionFeature::onActionTriggered(bool isChecked)
{
std::vector<RimSummaryCaseCollection*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
bool userConfirmedClosingOfGroup = askUserWhereToPutTheSummaryCases(selection);
if (userConfirmedClosingOfGroup)
{
RimSummaryCaseMainCollection* summaryCaseMainCollection = nullptr;
selection[0]->firstAncestorOrThisOfTypeAsserted(summaryCaseMainCollection);
for (RimSummaryCaseCollection* caseCollection : selection)
{
summaryCaseMainCollection->removeCaseCollection(caseCollection);
delete caseCollection;
}
summaryCaseMainCollection->updateConnectedEditors();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDeleteSummaryCaseCollectionFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Delete Summary Case Group");
actionToSetup->setIcon(QIcon(":/Erase.png"));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicDeleteSummaryCaseCollectionFeature::askUserWhereToPutTheSummaryCases(std::vector<RimSummaryCaseCollection*> selectedSummaryCases)
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
QString questionText;
questionText = QString("Do you also want to close the summary cases in the group?");
msgBox.setText(questionText);
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
int ret = msgBox.exec();
if (ret == QMessageBox::Yes)
{
for (RimSummaryCaseCollection* summaryCaseCollection : selectedSummaryCases)
{
RicDeleteSummaryCaseCollectionFeature::deleteSummaryCaseCollection(summaryCaseCollection);
}
return true;
}
else if (ret == QMessageBox::No)
{
for (RimSummaryCaseCollection* summaryCaseCollection : selectedSummaryCases)
{
RicDeleteSummaryCaseCollectionFeature::moveSummaryCasesFromSummaryCollectionToMainSummaryCollection(summaryCaseCollection);
}
return true;
}
else
{
return false;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDeleteSummaryCaseCollectionFeature::moveSummaryCasesFromSummaryCollectionToMainSummaryCollection(RimSummaryCaseCollection* summaryCaseCollection)
{
std::vector<RimSummaryCase*> summaryCases = summaryCaseCollection->allSummaryCases();
if (summaryCases.size() < 0) return;
RimSummaryCaseMainCollection* summaryCaseMainCollection = nullptr;
summaryCaseCollection->firstAncestorOrThisOfType(summaryCaseMainCollection);
for (RimSummaryCase* summaryCase : summaryCases)
{
summaryCaseCollection->removeCase(summaryCase);
summaryCaseMainCollection->addCase(summaryCase);
}
}

View File

@@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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 "cafCmdFeature.h"
#include <vector>
class RimSummaryCaseCollection;
//==================================================================================================
///
//==================================================================================================
class RicDeleteSummaryCaseCollectionFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static void deleteSummaryCaseCollection(RimSummaryCaseCollection* caseCollection);
static void moveSummaryCasesFromSummaryCollectionToMainSummaryCollection(RimSummaryCaseCollection* summaryCaseCollection);
private:
bool askUserWhereToPutTheSummaryCases(std::vector<RimSummaryCaseCollection*> selectedSummaryCases);
protected:
// Overrides
virtual bool isCommandEnabled() override;
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
};

View File

@@ -51,13 +51,7 @@ bool RicReloadSummaryCaseFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicReloadSummaryCaseFeature::onActionTriggered(bool isChecked)
{
RimProject* project = RiaApplication::instance()->project();
CVF_ASSERT(project);
RimMainPlotCollection* mainPlotColl = project->mainPlotCollection();
CVF_ASSERT(mainPlotColl);
RimSummaryPlotCollection* summaryPlotColl = mainPlotColl->summaryPlotCollection();
RimSummaryPlotCollection* summaryPlotColl = RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection();
CVF_ASSERT(summaryPlotColl);
std::vector<RimSummaryCase*> caseSelection = selectedSummaryCases();
@@ -104,10 +98,8 @@ std::vector<RimSummaryCase*> RicReloadSummaryCaseFeature::selectedSummaryCases()
for (auto collection : collectionSelection)
{
for (size_t i = 0; i < collection->summaryCaseCount(); i++)
{
caseSelection.push_back(collection->summaryCase(i));
}
std::vector<RimSummaryCase*> summaryCaseCollection = collection->allSummaryCases();
caseSelection.insert(caseSelection.end(), summaryCaseCollection.begin(), summaryCaseCollection.end());
}
return caseSelection;

View File

@@ -443,10 +443,12 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
commandIds << "RicWellPathImportCompletionsFileFeature";
commandIds << "RicFlyToObjectFeature";
commandIds << "RicExportCarfin";
commandIds << "RicCloseSummaryCaseFeature";
commandIds << "RicCloseSummaryCaseCollectionFeature";
commandIds << "RicReloadSummaryCaseFeature";
commandIds << "RicCreateSummaryCaseCollectionFeature";
commandIds << "Separator";
commandIds << "RicCloseSummaryCaseFeature";
commandIds << "RicCloseSummaryCaseInCollectionFeature";
commandIds << "RicDeleteSummaryCaseCollectionFeature";
// Fracture commands

View File

@@ -36,7 +36,7 @@ RimSummaryCaseCollection::RimSummaryCaseCollection()
CAF_PDM_InitFieldNoDefault(&m_cases, "SummaryCases", "", "", "", "");
m_cases.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_name, "CollectionName", QString("Case Group"), "Name", "", "", "");
CAF_PDM_InitField(&m_name, "SummaryCollectionName", QString("Case Group"), "Name", "", "", "");
}
//--------------------------------------------------------------------------------------------------
@@ -50,7 +50,7 @@ RimSummaryCaseCollection::~RimSummaryCaseCollection()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCaseCollection::deleteCase(RimSummaryCase* summaryCase)
void RimSummaryCaseCollection::removeCase(RimSummaryCase* summaryCase)
{
m_cases.removeChildObject(summaryCase);
}
@@ -83,20 +83,4 @@ caf::PdmFieldHandle* RimSummaryCaseCollection::userDescriptionField()
return &m_name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCase* RimSummaryCaseCollection::summaryCase(size_t idx)
{
return m_cases[idx];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RimSummaryCaseCollection::summaryCaseCount()
{
return m_cases.size();
}

View File

@@ -31,16 +31,14 @@ class RimSummaryCaseCollection : public caf::PdmObject
public:
RimSummaryCaseCollection();
virtual ~RimSummaryCaseCollection();
RimSummaryCase* summaryCase(size_t idx);
size_t summaryCaseCount();
void deleteCase(RimSummaryCase* summaryCase);
void removeCase(RimSummaryCase* summaryCase);
void addCase(RimSummaryCase* summaryCase);
std::vector<RimSummaryCase*> allSummaryCases();
virtual caf::PdmFieldHandle* userDescriptionField() override;
private:
virtual caf::PdmFieldHandle* userDescriptionField() override;
private:
caf::PdmChildArrayField<RimSummaryCase*> m_cases;

View File

@@ -146,29 +146,58 @@ RimSummaryCase* RimSummaryCaseMainCollection::findSummaryCaseFromFileName(const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCaseMainCollection::deleteCase(RimSummaryCase* summaryCase)
void RimSummaryCaseMainCollection::removeCase(RimSummaryCase* summaryCase)
{
m_cases.removeChildObject(summaryCase);
for (RimSummaryCaseCollection* summaryCaseCollection : m_caseCollections)
{
summaryCaseCollection->deleteCase(summaryCase);
summaryCaseCollection->removeCase(summaryCase);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCaseMainCollection::addCase(RimSummaryCase* summaryCase)
{
m_cases.push_back(summaryCase);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCaseMainCollection::addCaseCollection(std::vector<RimSummaryCase*> summaryCases)
{
RimSummaryCaseCollection* summaryCaseCollection = new RimSummaryCaseCollection();
for (RimSummaryCase* summaryCase : summaryCases)
{
m_cases.removeChildObject(summaryCase);
RimSummaryCaseCollection* currentSummaryCaseCollection = nullptr;
summaryCase->firstAncestorOrThisOfType(currentSummaryCaseCollection);
if (currentSummaryCaseCollection)
{
currentSummaryCaseCollection->removeCase(summaryCase);
}
else
{
m_cases.removeChildObject(summaryCase);
}
summaryCaseCollection->addCase(summaryCase);
}
m_caseCollections.push_back(summaryCaseCollection);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCaseMainCollection::removeCaseCollection(RimSummaryCaseCollection* caseCollection)
{
m_caseCollections.removeChildObject(caseCollection);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -180,7 +209,7 @@ RimSummaryCase* RimSummaryCaseMainCollection::summaryCase(size_t idx)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RimSummaryCaseMainCollection::summaryCaseCount()
size_t RimSummaryCaseMainCollection::summaryCaseCount() const
{
return m_cases.size();
}

View File

@@ -34,7 +34,7 @@ public:
virtual ~RimSummaryCaseMainCollection();
RimSummaryCase* summaryCase(size_t idx);
size_t summaryCaseCount();
size_t summaryCaseCount() const;
std::vector<RimSummaryCase*> allSummaryCases();
@@ -45,9 +45,11 @@ public:
RimSummaryCase* findSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase) const;
RimSummaryCase* findSummaryCaseFromFileName(const QString& fileName) const;
void deleteCase(RimSummaryCase* summaryCase);
void removeCase(RimSummaryCase* summaryCase);
void addCase(RimSummaryCase* summaryCase);
void addCaseCollection(std::vector<RimSummaryCase*> summaryCases);
void removeCaseCollection(RimSummaryCaseCollection* caseCollection);
void loadAllSummaryCaseData();