#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 "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 <QAction>
@ -63,42 +52,10 @@ void RicExportCompletionsForVisibleSimWellsFeature::onActionTriggered(bool isChe
std::vector<RimSimWellInView*> simWells = visibleSimWells();
CVF_ASSERT(!simWells.empty());
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->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);
}
QString dialogTitle = "Export Completion Data for Visible Simulation Wells";
RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions(dialogTitle, wellPaths, simWells);
}
//--------------------------------------------------------------------------------------------------
@ -153,4 +110,3 @@ std::vector<RimSimWellInView*> RicExportCompletionsForVisibleSimWellsFeature::vi
return simWells;
}

View File

@ -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 <QAction>
@ -64,42 +53,9 @@ void RicExportCompletionsForVisibleWellPathsFeature::onActionTriggered(bool isCh
CVF_ASSERT(wellPaths.size() > 0);
std::vector<RimSimWellInView*> 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<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);
}
RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions(dialogTitle, wellPaths, simWells);
}
//--------------------------------------------------------------------------------------------------
@ -154,4 +110,3 @@ std::vector<RimWellPath*> RicExportCompletionsForVisibleWellPathsFeature::visibl
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();
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<RimSimWellInView*> simWells;
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,6 +30,11 @@ class RicWellPathExportCompletionDataFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static void prepareExportSettingsAndExportCompletions(const QString& dialogTitle,
const std::vector<RimWellPath*>& wellPaths,
const std::vector<RimSimWellInView*>& simWells);
protected:
virtual bool isCommandEnabled() override;
virtual void onActionTriggered(bool isChecked) override;