diff --git a/ApplicationCode/Commands/RicCloseCaseFeature.cpp b/ApplicationCode/Commands/RicCloseCaseFeature.cpp index e29ff33586..d76087faf1 100644 --- a/ApplicationCode/Commands/RicCloseCaseFeature.cpp +++ b/ApplicationCode/Commands/RicCloseCaseFeature.cpp @@ -2,17 +2,17 @@ // // Copyright (C) 2015- Statoil ASA // Copyright (C) 2015- Ceetron Solutions AS -// +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -49,7 +49,7 @@ CAF_CMD_SOURCE_INIT(RicCloseCaseFeature, "RicCloseCaseFeature"); //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RicCloseCaseFeature::isCommandEnabled() { @@ -57,7 +57,7 @@ bool RicCloseCaseFeature::isCommandEnabled() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicCloseCaseFeature::onActionTriggered(bool isChecked) { @@ -91,7 +91,7 @@ void RicCloseCaseFeature::onActionTriggered(bool isChecked) RiuMainWindow::instance()->cleanupGuiCaseClose(); } } - + if (!geoMechCases.empty()) { for (RimGeoMechCase* geoMechCase : geoMechCases) @@ -103,7 +103,7 @@ void RicCloseCaseFeature::onActionTriggered(bool isChecked) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicCloseCaseFeature::setupActionLook(QAction* actionToSetup) { @@ -111,9 +111,8 @@ void RicCloseCaseFeature::setupActionLook(QAction* actionToSetup) actionToSetup->setIcon(QIcon(":/Erase.png")); } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RicCloseCaseFeature::selectedCases() const { @@ -123,14 +122,14 @@ std::vector RicCloseCaseFeature::selectedCases() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicCloseCaseFeature::removeCaseFromAllGroups(RimEclipseCase* eclipseCase) { CVF_ASSERT(eclipseCase); - RimProject* proj = RiaApplication::instance()->project(); - RimOilField* activeOilField = proj ? proj->activeOilField() : nullptr; + RimProject* proj = RiaApplication::instance()->project(); + RimOilField* activeOilField = proj ? proj->activeOilField() : nullptr; RimEclipseCaseCollection* analysisModels = (activeOilField) ? activeOilField->analysisModels() : nullptr; if (analysisModels) { @@ -140,7 +139,7 @@ void RicCloseCaseFeature::removeCaseFromAllGroups(RimEclipseCase* eclipseCase) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicCloseCaseFeature::deleteEclipseCase(RimEclipseCase* eclipseCase) { @@ -190,8 +189,9 @@ void RicCloseCaseFeature::deleteEclipseCase(RimEclipseCase* eclipseCase) RimEclipseResultCase* resultCase = dynamic_cast(eclipseCase); if (resultCase) { - RimProject* project = RiaApplication::instance()->project(); - RimSummaryCaseMainCollection* sumCaseColl = project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr; + RimProject* project = RiaApplication::instance()->project(); + RimSummaryCaseMainCollection* sumCaseColl = + project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr; if (sumCaseColl) { RimSummaryCase* summaryCase = sumCaseColl->findSummaryCaseFromEclipseResultCase(resultCase); @@ -208,14 +208,14 @@ void RicCloseCaseFeature::deleteEclipseCase(RimEclipseCase* eclipseCase) { RimProject* project = RiaApplication::instance()->project(); - std::vector cases; + std::vector cases; project->allCases(cases); - if (cases.empty()) - { + if (cases.empty()) + { project->multiSnapshotDefinitions.deleteAllChildObjects(); - } - else + } + else { for (RimAdvancedSnapshotExportDefinition* msd : project->multiSnapshotDefinitions()) { @@ -226,15 +226,15 @@ void RicCloseCaseFeature::deleteEclipseCase(RimEclipseCase* eclipseCase) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicCloseCaseFeature::deleteGeoMechCase(RimGeoMechCase* geoMechCase) { CVF_ASSERT(geoMechCase); - RimProject* proj = RiaApplication::instance()->project(); - RimOilField* activeOilField = proj ? proj->activeOilField() : nullptr; - RimGeoMechModels* models = (activeOilField) ? activeOilField->geoMechModels() : nullptr; + RimProject* proj = RiaApplication::instance()->project(); + RimOilField* activeOilField = proj ? proj->activeOilField() : nullptr; + RimGeoMechModels* models = (activeOilField) ? activeOilField->geoMechModels() : nullptr; if (models) { models->cases.removeChildObject(geoMechCase); @@ -245,7 +245,7 @@ void RicCloseCaseFeature::deleteGeoMechCase(RimGeoMechCase* geoMechCase) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RicCloseCaseFeature::hasAnyStatisticsResults(RimIdenticalGridCaseGroup* gridCaseGroup) { @@ -253,7 +253,8 @@ bool RicCloseCaseFeature::hasAnyStatisticsResults(RimIdenticalGridCaseGroup* gri for (size_t i = 0; i < gridCaseGroup->statisticsCaseCollection()->reservoirs().size(); i++) { - RimEclipseStatisticsCase* rimStaticsCase = dynamic_cast(gridCaseGroup->statisticsCaseCollection()->reservoirs[i]); + RimEclipseStatisticsCase* rimStaticsCase = + dynamic_cast(gridCaseGroup->statisticsCaseCollection()->reservoirs[i]); if (rimStaticsCase) { if (rimStaticsCase->hasComputedStatistics()) @@ -266,18 +267,17 @@ bool RicCloseCaseFeature::hasAnyStatisticsResults(RimIdenticalGridCaseGroup* gri return false; } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RicCloseCaseFeature::userConfirmedGridCaseGroupChange(const std::vector& casesToBeDeleted) { std::vector gridCaseGroups; - for (size_t i = 0; i < casesToBeDeleted.size(); i++) + for (auto caseToDelete : casesToBeDeleted) { RimIdenticalGridCaseGroup* gridCaseGroup = nullptr; - casesToBeDeleted[i]->firstAncestorOrThisOfType(gridCaseGroup); + caseToDelete->firstAncestorOrThisOfType(gridCaseGroup); if (gridCaseGroup && hasAnyStatisticsResults(gridCaseGroup)) { @@ -285,7 +285,7 @@ bool RicCloseCaseFeature::userConfirmedGridCaseGroupChange(const std::vector 0) + if (!gridCaseGroups.empty()) { RiuMainWindow* mainWnd = RiuMainWindow::instance(); @@ -295,15 +295,16 @@ bool RicCloseCaseFeature::userConfirmedGridCaseGroupChange(const std::vectorname()); + questionText = QString("This operation will invalidate statistics results in grid case group\n\"%1\".\n") + .arg(gridCaseGroups[0]->name()); questionText += "Computed results in this group will be deleted if you continue."; } else { questionText = "This operation will invalidate statistics results in grid case groups\n"; - for (size_t i = 0; i < gridCaseGroups.size(); i++) + for (auto& gridCaseGroup : gridCaseGroups) { - questionText += QString("\"%1\"\n").arg(gridCaseGroups[i]->name()); + questionText += QString("\"%1\"\n").arg(gridCaseGroup->name()); } questionText += "Computed results in these groups will be deleted if you continue."; diff --git a/ApplicationCode/Commands/RicCloseCaseFeature.h b/ApplicationCode/Commands/RicCloseCaseFeature.h index e7d370e8f5..ad048f7a08 100644 --- a/ApplicationCode/Commands/RicCloseCaseFeature.h +++ b/ApplicationCode/Commands/RicCloseCaseFeature.h @@ -2,17 +2,17 @@ // // Copyright (C) 2015- Statoil ASA // Copyright (C) 2015- Ceetron Solutions AS -// +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -29,7 +29,7 @@ class RimCase; class RimIdenticalGridCaseGroup; //================================================================================================== -/// +/// //================================================================================================== class RicCloseCaseFeature : public caf::CmdFeature { @@ -42,16 +42,14 @@ public: protected: // Overrides bool isCommandEnabled() override; - void onActionTriggered( bool isChecked ) override; - void setupActionLook( QAction* actionToSetup ) override; + void onActionTriggered(bool isChecked) override; + void setupActionLook(QAction* actionToSetup) override; private: std::vector selectedCases() const; void deleteGeoMechCase(RimGeoMechCase* geoMechCase); - + static bool hasAnyStatisticsResults(RimIdenticalGridCaseGroup* gridCaseGroup); static void removeCaseFromAllGroups(RimEclipseCase* eclipseCase); }; - -