From 64684f6bec8c080071b46caa1ec58022a0b22f3d Mon Sep 17 00:00:00 2001 From: astridkbjorke Date: Thu, 2 Feb 2017 11:38:55 +0100 Subject: [PATCH] #1145 - pre-proto - Export of fracture data for selected wells (either SimWells or WellPaths) --- .../Commands/CMakeLists_files.cmake | 2 + ...edSimWellFractureWellCompletionFeature.cpp | 14 +- ...dWellPathFractureWellCompletionFeature.cpp | 129 ++++++++++++++++++ ...tedWellPathFractureWellCompletionFeature.h | 39 ++++++ ...tWellPathFractureWellCompletionFeature.cpp | 1 - .../RimContextCommandBuilder.cpp | 7 +- 6 files changed, 180 insertions(+), 12 deletions(-) create mode 100644 ApplicationCode/Commands/RicExportSelectedWellPathFractureWellCompletionFeature.cpp create mode 100644 ApplicationCode/Commands/RicExportSelectedWellPathFractureWellCompletionFeature.h diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index 34bc2aa429..b28c3e4fdb 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -49,6 +49,7 @@ ${CEE_CURRENT_LIST_DIR}RicSimWellFracturesDeleteAllFeature.h ${CEE_CURRENT_LIST_DIR}RicExportSimWellFractureWellCompletionFeature.h ${CEE_CURRENT_LIST_DIR}RicExportSelectedSimWellFractureWellCompletionFeature.h ${CEE_CURRENT_LIST_DIR}RicExportWellPathFractureWellCompletionFeature.h +${CEE_CURRENT_LIST_DIR}RicExportSelectedWellPathFractureWellCompletionFeature.h @@ -102,6 +103,7 @@ ${CEE_CURRENT_LIST_DIR}RicSimWellFracturesDeleteAllFeature.cpp ${CEE_CURRENT_LIST_DIR}RicExportSimWellFractureWellCompletionFeature.cpp ${CEE_CURRENT_LIST_DIR}RicExportSelectedSimWellFractureWellCompletionFeature.cpp ${CEE_CURRENT_LIST_DIR}RicExportWellPathFractureWellCompletionFeature.cpp +${CEE_CURRENT_LIST_DIR}RicExportSelectedWellPathFractureWellCompletionFeature.cpp diff --git a/ApplicationCode/Commands/RicExportSelectedSimWellFractureWellCompletionFeature.cpp b/ApplicationCode/Commands/RicExportSelectedSimWellFractureWellCompletionFeature.cpp index 4ce1dc8a5c..69c1ec7f64 100644 --- a/ApplicationCode/Commands/RicExportSelectedSimWellFractureWellCompletionFeature.cpp +++ b/ApplicationCode/Commands/RicExportSelectedSimWellFractureWellCompletionFeature.cpp @@ -21,6 +21,8 @@ #include "RiaApplication.h" +#include "EclipseWell\RicEclipseWellFeatureImpl.h" + #include "RifEclipseExportTools.h" #include "RifEclipseExportTools.h" @@ -52,15 +54,11 @@ CAF_CMD_SOURCE_INIT(RicExportSelectedSimWellFractureWellCompletionFeature, "RicE void RicExportSelectedSimWellFractureWellCompletionFeature::onActionTriggered(bool isChecked) { - std::vector selection; - caf::SelectionManager::instance()->objectsByType(&selection); - - + std::vector selection = RicEclipseWellFeatureImpl::selectedWells(); std::vector fractures; for (RimEclipseWell* well : selection) { - std::vector fracListForWell; well->descendantsIncludingThisOfType(fracListForWell); for (RimFracture* fracture : fracListForWell) @@ -69,11 +67,7 @@ void RicExportSelectedSimWellFractureWellCompletionFeature::onActionTriggered(bo } } - - caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem(); - if (!pdmUiItem) return; - - caf::PdmObjectHandle* objHandle = dynamic_cast(pdmUiItem); + caf::PdmObjectHandle* objHandle = dynamic_cast(selection[0]); if (!objHandle) return; RimEclipseView* eclipseWiew = nullptr; diff --git a/ApplicationCode/Commands/RicExportSelectedWellPathFractureWellCompletionFeature.cpp b/ApplicationCode/Commands/RicExportSelectedWellPathFractureWellCompletionFeature.cpp new file mode 100644 index 0000000000..a88a9ffdd7 --- /dev/null +++ b/ApplicationCode/Commands/RicExportSelectedWellPathFractureWellCompletionFeature.cpp @@ -0,0 +1,129 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicExportSelectedWellPathFractureWellCompletionFeature.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 "RimWellPath.h" + +#include "RiuMainWindow.h" + +#include "cafPdmObjectHandle.h" +#include "cafPdmUiPropertyViewDialog.h" +#include "cafSelectionManager.h" + +#include "cvfAssert.h" + +#include +#include +#include +#include + +CAF_CMD_SOURCE_INIT(RicExportSelectedWellPathFractureWellCompletionFeature, "RicExportSelectedWellPathFractureWellCompletionFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportSelectedWellPathFractureWellCompletionFeature::onActionTriggered(bool isChecked) +{ + + std::vector selection; + caf::SelectionManager::instance()->objectsByType(&selection); + + + std::vector fractures; + for (RimWellPath* well : selection) + { + std::vector fracListForWell; + well->descendantsIncludingThisOfType(fracListForWell); + for (RimFracture* fracture : fracListForWell) + { + fractures.push_back(fracture); + } + } + + RimFractureExportSettings exportSettings; + + RiaApplication* app = RiaApplication::instance(); + QString projectFolder = app->currentProjectPath(); + + RimView* view = app->activeReservoirView(); + caf::PdmObjectHandle* objHandle = dynamic_cast(view); + if (!objHandle) return; + + RimEclipseCase* caseToApply; + objHandle->firstAncestorOrThisOfType(caseToApply); + exportSettings.caseToApply = caseToApply; + + if (projectFolder.isEmpty()) + { + RimView* activeView = RiaApplication::instance()->activeReservoirView(); + if (!activeView) return; + RimEclipseView * activeRiv = dynamic_cast(activeView); + if (!activeRiv) return; + projectFolder = activeRiv->eclipseCase()->locationOnDisc(); + } + + QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("FRACTURE_EXPORT_DIR", projectFolder); + + QString outputFileName = defaultDir + "/Fractures"; + exportSettings.fileName = outputFileName; + + caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Fracture Well Completion Data", ""); + if (propertyDialog.exec() == QDialog::Accepted) + { + RiaApplication::instance()->setLastUsedDialogDirectory("FRACTURE_EXPORT_DIR", QFileInfo(exportSettings.fileName).absolutePath()); + + bool isOk = RifEclipseExportTools::writeFracturesToTextFile(exportSettings.fileName, fractures, exportSettings.caseToApply); + + if (!isOk) + { + QMessageBox::critical(NULL, "File export", "Failed to exported current result to " + exportSettings.fileName); + } + } + + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportSelectedWellPathFractureWellCompletionFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/FractureTemplate16x16.png")); + actionToSetup->setText("Export Fracture Well Completion Data for Selected wells"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicExportSelectedWellPathFractureWellCompletionFeature::isCommandEnabled() +{ + return true; +} diff --git a/ApplicationCode/Commands/RicExportSelectedWellPathFractureWellCompletionFeature.h b/ApplicationCode/Commands/RicExportSelectedWellPathFractureWellCompletionFeature.h new file mode 100644 index 0000000000..30f831eeb0 --- /dev/null +++ b/ApplicationCode/Commands/RicExportSelectedWellPathFractureWellCompletionFeature.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 RicExportSelectedWellPathFractureWellCompletionFeature : 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/RicExportWellPathFractureWellCompletionFeature.cpp b/ApplicationCode/Commands/RicExportWellPathFractureWellCompletionFeature.cpp index 1cda08bf60..13309ae21a 100644 --- a/ApplicationCode/Commands/RicExportWellPathFractureWellCompletionFeature.cpp +++ b/ApplicationCode/Commands/RicExportWellPathFractureWellCompletionFeature.cpp @@ -50,7 +50,6 @@ CAF_CMD_SOURCE_INIT(RicExportWellPathFractureWellCompletionFeature, "RicExportWe //-------------------------------------------------------------------------------------------------- void RicExportWellPathFractureWellCompletionFeature::onActionTriggered(bool isChecked) { - caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem(); if (!pdmUiItem) return; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 8b09c073e2..548eb2ef91 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -343,7 +343,6 @@ QStringList RimContextCommandBuilder::commandsFromSelection() else if (dynamic_cast(uiItem)) { commandIds << "RicNewSimWellIntersectionFeature"; - commandIds << "RicExportSelectedSimWellFractureWellCompletionFeature"; } else if (dynamic_cast(uiItem)) { @@ -440,7 +439,13 @@ QStringList RimContextCommandBuilder::commandsFromSelection() commandIds << "RicEclipseWellShowHeadFeature"; commandIds << "RicEclipseWellShowPipeFeature"; commandIds << "RicEclipseWellShowSpheresFeature"; + commandIds << "RicExportSelectedSimWellFractureWellCompletionFeature"; } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicExportSelectedWellPathFractureWellCompletionFeature"; + } + }