#2632 Export Completions : Use common entry point for completion export

This commit is contained in:
Magne Sjaastad 2018-04-09 10:08:10 +02:00
parent f71563cb1e
commit c759ef71b9
4 changed files with 54 additions and 127 deletions

View File

@ -18,22 +18,11 @@
#include "RicExportCompletionsForVisibleSimWellsFeature.h" #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 "RimSimWellInView.h"
#include "RimSimWellInViewCollection.h" #include "RimSimWellInViewCollection.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "Riu3DMainWindowTools.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include <QAction> #include <QAction>
@ -63,42 +52,10 @@ void RicExportCompletionsForVisibleSimWellsFeature::onActionTriggered(bool isChe
std::vector<RimSimWellInView*> simWells = visibleSimWells(); std::vector<RimSimWellInView*> simWells = visibleSimWells();
CVF_ASSERT(!simWells.empty()); CVF_ASSERT(!simWells.empty());
RiaApplication* app = RiaApplication::instance(); std::vector<RimWellPath*> wellPaths;
RimProject* project = app->project(); QString dialogTitle = "Export Completion Data for Visible Simulation Wells";
QString projectFolder = app->currentProjectPath(); RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions(dialogTitle, wellPaths, simWells);
QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("COMPLETIONS", projectFolder);
RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData();
exportSettings->showForSimWells();
if (!exportSettings->caseToApply())
{
std::vector<RimCase*> cases;
app->project()->allCases(cases);
for (auto c : cases)
{
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(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<RimWellPath*> wellPaths;
RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings);
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -115,7 +72,7 @@ void RicExportCompletionsForVisibleSimWellsFeature::setupActionLook(QAction* act
std::vector<RimSimWellInView*> RicExportCompletionsForVisibleSimWellsFeature::visibleSimWells() std::vector<RimSimWellInView*> RicExportCompletionsForVisibleSimWellsFeature::visibleSimWells()
{ {
std::vector<RimSimWellInView*> simWells; std::vector<RimSimWellInView*> simWells;
{ {
std::vector<RimSimWellInViewCollection*> simWellCollection; std::vector<RimSimWellInViewCollection*> simWellCollection;
caf::SelectionManager::instance()->objectsByType(&simWellCollection); caf::SelectionManager::instance()->objectsByType(&simWellCollection);
@ -150,7 +107,6 @@ std::vector<RimSimWellInView*> RicExportCompletionsForVisibleSimWellsFeature::vi
std::set<RimSimWellInView*> uniqueWellPaths(simWells.begin(), simWells.end()); std::set<RimSimWellInView*> uniqueWellPaths(simWells.begin(), simWells.end());
simWells.assign(uniqueWellPaths.begin(), uniqueWellPaths.end()); simWells.assign(uniqueWellPaths.begin(), uniqueWellPaths.end());
return simWells; return simWells;
} }

View File

@ -18,22 +18,11 @@
#include "RicExportCompletionsForVisibleWellPathsFeature.h" #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 "RimWellPath.h"
#include "RimWellPathCollection.h" #include "RimWellPathCollection.h"
#include "Riu3DMainWindowTools.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include <QAction> #include <QAction>
@ -45,7 +34,7 @@ CAF_CMD_SOURCE_INIT(RicExportCompletionsForVisibleWellPathsFeature, "RicExportCo
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RicExportCompletionsForVisibleWellPathsFeature::isCommandEnabled() bool RicExportCompletionsForVisibleWellPathsFeature::isCommandEnabled()
{ {
std::vector<RimWellPath*> wellPaths = visibleWellPaths(); std::vector<RimWellPath*> wellPaths = visibleWellPaths();
if (wellPaths.empty()) if (wellPaths.empty())
{ {
@ -60,46 +49,13 @@ bool RicExportCompletionsForVisibleWellPathsFeature::isCommandEnabled()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicExportCompletionsForVisibleWellPathsFeature::onActionTriggered(bool isChecked) void RicExportCompletionsForVisibleWellPathsFeature::onActionTriggered(bool isChecked)
{ {
std::vector<RimWellPath*> wellPaths = visibleWellPaths(); std::vector<RimWellPath*> wellPaths = visibleWellPaths();
CVF_ASSERT(wellPaths.size() > 0); CVF_ASSERT(wellPaths.size() > 0);
std::vector<RimSimWellInView*> simWells; std::vector<RimSimWellInView*> simWells;
QString dialogTitle = "Export Completion Data for Visible Well Paths";
RiaApplication* app = RiaApplication::instance(); RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions(dialogTitle, wellPaths, simWells);
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<RimCase*> cases;
app->project()->allCases(cases);
for (auto c : cases)
{
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(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);
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -116,7 +72,7 @@ void RicExportCompletionsForVisibleWellPathsFeature::setupActionLook(QAction* ac
std::vector<RimWellPath*> RicExportCompletionsForVisibleWellPathsFeature::visibleWellPaths() std::vector<RimWellPath*> RicExportCompletionsForVisibleWellPathsFeature::visibleWellPaths()
{ {
std::vector<RimWellPath*> wellPaths; std::vector<RimWellPath*> wellPaths;
{ {
std::vector<RimWellPathCollection*> wellPathCollections; std::vector<RimWellPathCollection*> wellPathCollections;
caf::SelectionManager::instance()->objectsByType(&wellPathCollections); caf::SelectionManager::instance()->objectsByType(&wellPathCollections);
@ -151,7 +107,6 @@ std::vector<RimWellPath*> RicExportCompletionsForVisibleWellPathsFeature::visibl
std::set<RimWellPath*> uniqueWellPaths(wellPaths.begin(), wellPaths.end()); std::set<RimWellPath*> uniqueWellPaths(wellPaths.begin(), wellPaths.end());
wellPaths.assign(uniqueWellPaths.begin(), uniqueWellPaths.end()); wellPaths.assign(uniqueWellPaths.begin(), uniqueWellPaths.end());
return wellPaths; return wellPaths;
} }

View File

@ -42,26 +42,11 @@ CAF_CMD_SOURCE_INIT(RicWellPathExportCompletionDataFeature, "RicWellPathExportCo
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RicWellPathExportCompletionDataFeature::isCommandEnabled() void RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions(
const QString& dialogTitle,
const std::vector<RimWellPath*>& wellPaths,
const std::vector<RimSimWellInView*>& simWells)
{ {
std::vector<RimWellPath*> wellPaths = selectedWellPaths();
if (wellPaths.empty())
{
return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked)
{
std::vector<RimWellPath*> wellPaths = selectedWellPaths();
CVF_ASSERT(!wellPaths.empty());
RiaApplication* app = RiaApplication::instance(); RiaApplication* app = RiaApplication::instance();
RimProject* project = app->project(); RimProject* project = app->project();
@ -96,20 +81,46 @@ void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked)
if (exportSettings->folder().isEmpty()) exportSettings->folder = defaultDir; if (exportSettings->folder().isEmpty()) exportSettings->folder = defaultDir;
caf::PdmUiPropertyViewDialog propertyDialog( caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), exportSettings, dialogTitle, "");
Riu3DMainWindowTools::mainWindowWidget(), exportSettings, "Export Completion Data", "");
RicExportFeatureImpl::configureForExport(&propertyDialog); RicExportFeatureImpl::configureForExport(&propertyDialog);
if (propertyDialog.exec() == QDialog::Accepted) if (propertyDialog.exec() == QDialog::Accepted)
{ {
RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", exportSettings->folder); RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", exportSettings->folder);
std::vector<RimSimWellInView*> simWells;
RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings); RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings);
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicWellPathExportCompletionDataFeature::isCommandEnabled()
{
std::vector<RimWellPath*> wellPaths = selectedWellPaths();
if (wellPaths.empty())
{
return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked)
{
std::vector<RimWellPath*> wellPaths = selectedWellPaths();
CVF_ASSERT(!wellPaths.empty());
std::vector<RimSimWellInView*> simWells;
QString dialogTitle = "Export Completion Data for Selected Well Paths";
RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions(dialogTitle, wellPaths, simWells);
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -30,11 +30,16 @@ class RicWellPathExportCompletionDataFeature : public caf::CmdFeature
{ {
CAF_CMD_HEADER_INIT; CAF_CMD_HEADER_INIT;
public:
static void prepareExportSettingsAndExportCompletions(const QString& dialogTitle,
const std::vector<RimWellPath*>& wellPaths,
const std::vector<RimSimWellInView*>& simWells);
protected: protected:
virtual bool isCommandEnabled() override; virtual bool isCommandEnabled() override;
virtual void onActionTriggered(bool isChecked) override; virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override; virtual void setupActionLook(QAction* actionToSetup) override;
private: private:
std::vector<RimWellPath*> selectedWellPaths(); std::vector<RimWellPath*> selectedWellPaths();
}; };