From 238b803dce00049e1031dbefb053292ed284a5b6 Mon Sep 17 00:00:00 2001 From: astridkbjorke Date: Tue, 31 Jan 2017 09:56:16 +0100 Subject: [PATCH] #1145 - pre-proto - Adding command feature for export of fractures only from selected wells. So far only fractures from one well can be exported each time. --- .../Commands/CMakeLists_files.cmake | 3 + ...edSimWellFractureWellCompletionFeature.cpp | 122 ++++++++++++++++++ ...ctedSimWellFractureWellCompletionFeature.h | 39 ++++++ ...rtSimWellFractureWellCompletionFeature.cpp | 2 +- .../RimContextCommandBuilder.cpp | 1 + 5 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 ApplicationCode/Commands/RicExportSelectedSimWellFractureWellCompletionFeature.cpp create mode 100644 ApplicationCode/Commands/RicExportSelectedSimWellFractureWellCompletionFeature.h diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index 2effe5478e..34bc2aa429 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -47,9 +47,11 @@ ${CEE_CURRENT_LIST_DIR}RicFracturesDeleteAllFeature.h ${CEE_CURRENT_LIST_DIR}RicWellPathFracturesDeleteAllFeature.h ${CEE_CURRENT_LIST_DIR}RicSimWellFracturesDeleteAllFeature.h ${CEE_CURRENT_LIST_DIR}RicExportSimWellFractureWellCompletionFeature.h +${CEE_CURRENT_LIST_DIR}RicExportSelectedSimWellFractureWellCompletionFeature.h ${CEE_CURRENT_LIST_DIR}RicExportWellPathFractureWellCompletionFeature.h + # General delete of any object in a child array field ${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.h ${CEE_CURRENT_LIST_DIR}RicDeleteItemExecData.h @@ -98,6 +100,7 @@ ${CEE_CURRENT_LIST_DIR}RicFractureDefinitionsDeleteAllFeature.cpp ${CEE_CURRENT_LIST_DIR}RicWellPathFracturesDeleteAllFeature.cpp ${CEE_CURRENT_LIST_DIR}RicSimWellFracturesDeleteAllFeature.cpp ${CEE_CURRENT_LIST_DIR}RicExportSimWellFractureWellCompletionFeature.cpp +${CEE_CURRENT_LIST_DIR}RicExportSelectedSimWellFractureWellCompletionFeature.cpp ${CEE_CURRENT_LIST_DIR}RicExportWellPathFractureWellCompletionFeature.cpp diff --git a/ApplicationCode/Commands/RicExportSelectedSimWellFractureWellCompletionFeature.cpp b/ApplicationCode/Commands/RicExportSelectedSimWellFractureWellCompletionFeature.cpp new file mode 100644 index 0000000000..49f1c7f133 --- /dev/null +++ b/ApplicationCode/Commands/RicExportSelectedSimWellFractureWellCompletionFeature.cpp @@ -0,0 +1,122 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicExportSelectedSimWellFractureWellCompletionFeature.h" + + +#include "RiaApplication.h" + +#include "RifEclipseExportTools.h" +#include "RifEclipseExportTools.h" + +#include "RimEclipseCase.h" +#include "RimEclipseView.h" +#include "RimEclipseWell.h" +#include "RimEclipseWellCollection.h" +#include "RimFracture.h" +#include "RimFractureExportSettings.h" + +#include "RiuMainWindow.h" + +#include "cafPdmObjectHandle.h" +#include "cafPdmUiPropertyViewDialog.h" +#include "cafSelectionManager.h" + +#include "cvfAssert.h" + +#include +#include +#include + +CAF_CMD_SOURCE_INIT(RicExportSelectedSimWellFractureWellCompletionFeature, "RicExportSelectedSimWellFractureWellCompletionFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportSelectedSimWellFractureWellCompletionFeature::onActionTriggered(bool isChecked) +{ + + std::vector selection; + caf::SelectionManager::instance()->objectsByType(&selection); + + + + std::vector fractures; + for (RimEclipseWell* well : selection) + { + + std::vector fracListForWell; + well->descendantsIncludingThisOfType(fracListForWell); + for (RimFracture* fracture : fracListForWell) + { + fractures.push_back(fracture); + } + } + + + caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem(); + if (!pdmUiItem) return; + + caf::PdmObjectHandle* objHandle = dynamic_cast(pdmUiItem); + if (!objHandle) return; + + RimEclipseView* eclipseWiew = nullptr; + objHandle->firstAncestorOrThisOfType(eclipseWiew); + + RimFractureExportSettings exportSettings; + + RiaApplication* app = RiaApplication::instance(); + QString projectFolder = app->currentProjectPath(); + if (projectFolder.isEmpty()) + { + projectFolder = eclipseWiew->eclipseCase()->locationOnDisc(); + } + + QString outputFileName = projectFolder + "/Fractures"; + exportSettings.fileName = outputFileName; + + caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Fracture Well Completion Data", ""); + if (propertyDialog.exec() == QDialog::Accepted) + { + bool isOk = RifEclipseExportTools::writeFracturesToTextFile(exportSettings.fileName, fractures); + + if (!isOk) + { + QMessageBox::critical(NULL, "File export", "Failed to exported current result to " + exportSettings.fileName); + } + } + + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportSelectedSimWellFractureWellCompletionFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/FractureTemplate16x16.png")); + actionToSetup->setText("Export Fracture Well Completion Data for Selected wells"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicExportSelectedSimWellFractureWellCompletionFeature::isCommandEnabled() +{ + return true; +} diff --git a/ApplicationCode/Commands/RicExportSelectedSimWellFractureWellCompletionFeature.h b/ApplicationCode/Commands/RicExportSelectedSimWellFractureWellCompletionFeature.h new file mode 100644 index 0000000000..1c8f75dae1 --- /dev/null +++ b/ApplicationCode/Commands/RicExportSelectedSimWellFractureWellCompletionFeature.h @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + + +//================================================================================================== +/// +//================================================================================================== +class RicExportSelectedSimWellFractureWellCompletionFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; +protected: + + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; + virtual bool isCommandEnabled() override; + + +}; diff --git a/ApplicationCode/Commands/RicExportSimWellFractureWellCompletionFeature.cpp b/ApplicationCode/Commands/RicExportSimWellFractureWellCompletionFeature.cpp index 4c05f626db..ec0f7639cf 100644 --- a/ApplicationCode/Commands/RicExportSimWellFractureWellCompletionFeature.cpp +++ b/ApplicationCode/Commands/RicExportSimWellFractureWellCompletionFeature.cpp @@ -27,6 +27,7 @@ #include "RimEclipseCase.h" #include "RimEclipseView.h" #include "RimEclipseWellCollection.h" +#include "RimFracture.h" #include "RimFractureExportSettings.h" #include "RiuMainWindow.h" @@ -40,7 +41,6 @@ #include #include #include -#include "RimFracture.h" CAF_CMD_SOURCE_INIT(RicExportSimWellFractureWellCompletionFeature, "RicExportSimWellFractureWellCompletionFeature"); diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 1bbbc97e3e..8b09c073e2 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -343,6 +343,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection() else if (dynamic_cast(uiItem)) { commandIds << "RicNewSimWellIntersectionFeature"; + commandIds << "RicExportSelectedSimWellFractureWellCompletionFeature"; } else if (dynamic_cast(uiItem)) {