diff --git a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp index e8c894f4d4..66dcfef3ce 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp @@ -58,7 +58,7 @@ RicfExportSimWellCompletions::RicfExportSimWellCompletions() void RicfExportSimWellCompletions::execute() { RimProject* project = RiaApplication::instance()->project(); - RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(false); + RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(); exportSettings->timeStep = m_timeStep; exportSettings->fileSplit = m_fileSplit; exportSettings->compdatExport = m_compdatExport; diff --git a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp index 07a21c5a12..a87959f6aa 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp @@ -57,7 +57,7 @@ RicfExportWellPathCompletions::RicfExportWellPathCompletions() void RicfExportWellPathCompletions::execute() { RimProject* project = RiaApplication::instance()->project(); - RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(false); + RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(); exportSettings->timeStep = m_timeStep; exportSettings->fileSplit = m_fileSplit; exportSettings->compdatExport = m_compdatExport; diff --git a/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake index 01b1fc3696..23eae5d246 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake @@ -7,6 +7,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicFishbonesTransmissibilityCalculationFeatureImp.h ${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesWellSegmentsFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicCaseAndFileExportSettingsUi.h ${CMAKE_CURRENT_LIST_DIR}/RicExportFractureCompletionsImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionsForVisibleWellPathsFeature.h ) @@ -18,6 +19,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicFishbonesTransmissibilityCalculationFeatureImp.cpp ${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesWellSegmentsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicCaseAndFileExportSettingsUi.cpp ${CMAKE_CURRENT_LIST_DIR}/RicExportFractureCompletionsImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionsForVisibleWellPathsFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp new file mode 100644 index 0000000000..5f452b6f08 --- /dev/null +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp @@ -0,0 +1,157 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicExportCompletionsForVisibleWellPathsFeature.h" + +#include "RiaApplication.h" + +#include "RicExportFeatureImpl.h" +#include "RicExportCompletionDataSettingsUi.h" +#include "RicWellPathExportCompletionDataFeatureImpl.h" + +#include "RimDialogData.h" +#include "RimProject.h" +#include "RimSimWellInView.h" +#include "RimSimWellInViewCollection.h" +#include "RimWellPath.h" +#include "RimWellPathCollection.h" + +#include "Riu3DMainWindowTools.h" + +#include "cafPdmUiPropertyViewDialog.h" +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT(RicExportCompletionsForVisibleWellPathsFeature, "RicExportCompletionsForVisibleWellPathsFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicExportCompletionsForVisibleWellPathsFeature::isCommandEnabled() +{ + std::vector wellPaths = visibleWellPaths(); + + if (wellPaths.empty()) + { + return false; + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionsForVisibleWellPathsFeature::onActionTriggered(bool isChecked) +{ + std::vector wellPaths = visibleWellPaths(); + CVF_ASSERT(wellPaths.size() > 0); + + std::vector simWells; + + RiaApplication* app = RiaApplication::instance(); + RimProject* project = app->project(); + + QString projectFolder = app->currentProjectPath(); + QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("COMPLETIONS", projectFolder); + + RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(); + exportSettings->showForWellPath(); + + if (!exportSettings->caseToApply()) + { + std::vector cases; + app->project()->allCases(cases); + for (auto c : cases) + { + RimEclipseCase* eclipseCase = dynamic_cast(c); + if (eclipseCase != nullptr) + { + exportSettings->caseToApply = eclipseCase; + break; + } + } + } + + if (exportSettings->folder().isEmpty()) exportSettings->folder = defaultDir; + + caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), exportSettings, "Export Completion Data", ""); + RicExportFeatureImpl::configureForExport(&propertyDialog); + + if (propertyDialog.exec() == QDialog::Accepted) + { + RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", exportSettings->folder); + + RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionsForVisibleWellPathsFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Export Completion Data for Visible Well Paths"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicExportCompletionsForVisibleWellPathsFeature::visibleWellPaths() +{ + std::vector wellPaths; + + { + std::vector wellPathCollections; + caf::SelectionManager::instance()->objectsByType(&wellPathCollections); + + if (wellPathCollections.empty()) + { + std::vector selectedWellPaths; + caf::SelectionManager::instance()->objectsByType(&selectedWellPaths); + + if (!selectedWellPaths.empty()) + { + RimWellPathCollection* parent = nullptr; + selectedWellPaths[0]->firstAncestorOrThisOfType(parent); + if (parent) + { + wellPathCollections.push_back(parent); + } + } + } + + for (auto wellPathCollection : wellPathCollections) + { + for (auto wellPath : wellPathCollection->wellPaths()) + { + if (wellPath->showWellPath()) + { + wellPaths.push_back(wellPath); + } + } + } + } + + std::set uniqueWellPaths(wellPaths.begin(), wellPaths.end()); + wellPaths.assign(uniqueWellPaths.begin(), uniqueWellPaths.end()); + + return wellPaths; +} + diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.h new file mode 100644 index 0000000000..c80ba540ca --- /dev/null +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.h @@ -0,0 +1,40 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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" + +class RimSimWellInView; +class RimWellPath; + +//================================================================================================== +/// +//================================================================================================== +class RicExportCompletionsForVisibleWellPathsFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; + +private: + std::vector visibleWellPaths(); +}; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp index e8f8225ef0..71b5c33253 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp @@ -88,9 +88,7 @@ void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) QString projectFolder = app->currentProjectPath(); QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("COMPLETIONS", projectFolder); - bool onlyWellPathCollectionSelected = noWellPathsSelectedDirectly(); - RicExportCompletionDataSettingsUi* exportSettings = - project->dialogData()->exportCompletionData(onlyWellPathCollectionSelected); + RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(); if (wellPaths.empty()) { diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 6833e6c3f9..cbbe790455 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -241,6 +241,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicReloadWellPathFormationNamesFeature"; menuBuilder << "RicWellPathImportPerforationIntervalsFeature"; menuBuilder.subMenuEnd(); + + menuBuilder << "RicExportCompletionsForVisibleWellPathsFeature"; } else if (dynamic_cast(uiItem)) { @@ -282,6 +284,9 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder.subMenuEnd(); menuBuilder << "Separator"; + + menuBuilder << "RicExportCompletionsForVisibleWellPathsFeature"; + menuBuilder << "RicWellPathExportCompletionDataFeature"; } else if (dynamic_cast(uiItem)) { @@ -615,7 +620,6 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicEditPerforationCollectionFeature"; menuBuilder << "RicExportFishbonesLateralsFeature"; menuBuilder << "RicExportFishbonesWellSegmentsFeature"; - menuBuilder << "RicWellPathExportCompletionDataFeature"; menuBuilder << "RicWellPathImportCompletionsFileFeature"; menuBuilder << "RicFlyToObjectFeature"; menuBuilder << "RicExportCarfin"; diff --git a/ApplicationCode/ProjectDataModel/RimDialogData.cpp b/ApplicationCode/ProjectDataModel/RimDialogData.cpp index 2f2b350930..79138b2a90 100644 --- a/ApplicationCode/ProjectDataModel/RimDialogData.cpp +++ b/ApplicationCode/ProjectDataModel/RimDialogData.cpp @@ -65,7 +65,7 @@ void RimDialogData::setExportCarfinDataFromString(const QString& data) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicExportCompletionDataSettingsUi* RimDialogData::exportCompletionData(bool onlyWellPathCollectionSelected) const +RicExportCompletionDataSettingsUi* RimDialogData::exportCompletionData() const { return m_exportCompletionData; } diff --git a/ApplicationCode/ProjectDataModel/RimDialogData.h b/ApplicationCode/ProjectDataModel/RimDialogData.h index 257a78621a..a03131c48d 100644 --- a/ApplicationCode/ProjectDataModel/RimDialogData.h +++ b/ApplicationCode/ProjectDataModel/RimDialogData.h @@ -39,7 +39,7 @@ public: QString exportCarfinDataAsString() const; void setExportCarfinDataFromString(const QString& data); - RicExportCompletionDataSettingsUi* exportCompletionData(bool onlyWellPathCollectionSelected) const; + RicExportCompletionDataSettingsUi* exportCompletionData() const; private: caf::PdmChildField m_exportCarfin;