diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.cpp index a3a8f32081..fe82fa65b4 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.cpp @@ -18,22 +18,11 @@ #include "RicExportCompletionsForVisibleSimWellsFeature.h" -#include "RiaApplication.h" +#include "RicWellPathExportCompletionDataFeature.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 @@ -63,42 +52,10 @@ void RicExportCompletionsForVisibleSimWellsFeature::onActionTriggered(bool isChe std::vector simWells = visibleSimWells(); CVF_ASSERT(!simWells.empty()); - RiaApplication* app = RiaApplication::instance(); - RimProject* project = app->project(); + std::vector wellPaths; + QString dialogTitle = "Export Completion Data for Visible Simulation Wells"; - QString projectFolder = app->currentProjectPath(); - QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("COMPLETIONS", projectFolder); - - RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(); - exportSettings->showForSimWells(); - - 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); - - std::vector wellPaths; - RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings); - } + RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions(dialogTitle, wellPaths, simWells); } //-------------------------------------------------------------------------------------------------- @@ -115,7 +72,7 @@ void RicExportCompletionsForVisibleSimWellsFeature::setupActionLook(QAction* act std::vector RicExportCompletionsForVisibleSimWellsFeature::visibleSimWells() { std::vector simWells; - + { std::vector simWellCollection; caf::SelectionManager::instance()->objectsByType(&simWellCollection); @@ -150,7 +107,6 @@ std::vector RicExportCompletionsForVisibleSimWellsFeature::vi std::set uniqueWellPaths(simWells.begin(), simWells.end()); simWells.assign(uniqueWellPaths.begin(), uniqueWellPaths.end()); - + return simWells; } - diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp index 5f452b6f08..5d2787da80 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp @@ -18,22 +18,11 @@ #include "RicExportCompletionsForVisibleWellPathsFeature.h" -#include "RiaApplication.h" +#include "RicWellPathExportCompletionDataFeature.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 @@ -45,7 +34,7 @@ CAF_CMD_SOURCE_INIT(RicExportCompletionsForVisibleWellPathsFeature, "RicExportCo //-------------------------------------------------------------------------------------------------- bool RicExportCompletionsForVisibleWellPathsFeature::isCommandEnabled() { - std::vector wellPaths = visibleWellPaths(); + std::vector wellPaths = visibleWellPaths(); if (wellPaths.empty()) { @@ -60,46 +49,13 @@ bool RicExportCompletionsForVisibleWellPathsFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicExportCompletionsForVisibleWellPathsFeature::onActionTriggered(bool isChecked) { - std::vector wellPaths = visibleWellPaths(); + std::vector wellPaths = visibleWellPaths(); CVF_ASSERT(wellPaths.size() > 0); - + std::vector simWells; + QString dialogTitle = "Export Completion Data for Visible Well Paths"; - 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); - } + RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions(dialogTitle, wellPaths, simWells); } //-------------------------------------------------------------------------------------------------- @@ -116,7 +72,7 @@ void RicExportCompletionsForVisibleWellPathsFeature::setupActionLook(QAction* ac std::vector RicExportCompletionsForVisibleWellPathsFeature::visibleWellPaths() { std::vector wellPaths; - + { std::vector wellPathCollections; caf::SelectionManager::instance()->objectsByType(&wellPathCollections); @@ -151,7 +107,6 @@ std::vector RicExportCompletionsForVisibleWellPathsFeature::visibl std::set uniqueWellPaths(wellPaths.begin(), wellPaths.end()); wellPaths.assign(uniqueWellPaths.begin(), uniqueWellPaths.end()); - + return wellPaths; } - diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp index d97b83377a..986cf1110a 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp @@ -42,26 +42,11 @@ CAF_CMD_SOURCE_INIT(RicWellPathExportCompletionDataFeature, "RicWellPathExportCo //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicWellPathExportCompletionDataFeature::isCommandEnabled() +void RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions( + const QString& dialogTitle, + const std::vector& wellPaths, + const std::vector& simWells) { - std::vector wellPaths = selectedWellPaths(); - - if (wellPaths.empty()) - { - return false; - } - - return true; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) -{ - std::vector wellPaths = selectedWellPaths(); - CVF_ASSERT(!wellPaths.empty()); - RiaApplication* app = RiaApplication::instance(); RimProject* project = app->project(); @@ -96,20 +81,46 @@ void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) if (exportSettings->folder().isEmpty()) exportSettings->folder = defaultDir; - caf::PdmUiPropertyViewDialog propertyDialog( - Riu3DMainWindowTools::mainWindowWidget(), exportSettings, "Export Completion Data", ""); + caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), exportSettings, dialogTitle, ""); RicExportFeatureImpl::configureForExport(&propertyDialog); if (propertyDialog.exec() == QDialog::Accepted) { RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", exportSettings->folder); - std::vector simWells; - RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings); } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicWellPathExportCompletionDataFeature::isCommandEnabled() +{ + std::vector wellPaths = selectedWellPaths(); + + if (wellPaths.empty()) + { + return false; + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) +{ + std::vector wellPaths = selectedWellPaths(); + CVF_ASSERT(!wellPaths.empty()); + + std::vector simWells; + QString dialogTitle = "Export Completion Data for Selected Well Paths"; + + RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions(dialogTitle, wellPaths, simWells); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h index c589a3af0a..d5595e5b00 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h @@ -30,11 +30,16 @@ class RicWellPathExportCompletionDataFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; +public: + static void prepareExportSettingsAndExportCompletions(const QString& dialogTitle, + const std::vector& wellPaths, + const std::vector& simWells); + protected: virtual bool isCommandEnabled() override; virtual void onActionTriggered(bool isChecked) override; virtual void setupActionLook(QAction* actionToSetup) override; private: - std::vector selectedWellPaths(); + std::vector selectedWellPaths(); };