From ce2430ac2d12ae52f6477d68f0504c221891ece4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Thu, 11 Oct 2018 09:31:06 +0200 Subject: [PATCH] LGR Export. Add time step to LGR dialog --- .../ExportCommands/RicExportLgrFeature.cpp | 18 +++++---- .../ExportCommands/RicExportLgrFeature.h | 2 +- .../ExportCommands/RicExportLgrUi.cpp | 39 +++++++++++++++++++ .../Commands/ExportCommands/RicExportLgrUi.h | 3 ++ 4 files changed, 54 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.cpp index e754f3128e..e9d059e8c3 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.cpp @@ -62,7 +62,7 @@ CAF_CMD_SOURCE_INIT(RicExportLgrFeature, "RicExportLgrFeature"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicExportLgrUi* RicExportLgrFeature::openDialog() +RicExportLgrUi* RicExportLgrFeature::openDialog(RimEclipseCase* defaultCase, int defaultTimeStep) { RiaApplication* app = RiaApplication::instance(); RimProject* proj = app->project(); @@ -80,7 +80,7 @@ RicExportLgrUi* RicExportLgrFeature::openDialog() featureUi->setExportFolder(startPath); } - if (!featureUi->caseToApply()) + if (!featureUi->caseToApply() && !defaultCase) { std::vector cases; app->project()->allCases(cases); @@ -94,9 +94,11 @@ RicExportLgrUi* RicExportLgrFeature::openDialog() } } } + if (defaultCase) featureUi->setCase(defaultCase); + featureUi->setTimeStep(defaultTimeStep); caf::PdmUiPropertyViewDialog propertyDialog(nullptr, featureUi, "LGR Export", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - propertyDialog.resize(QSize(600, 250)); + propertyDialog.resize(QSize(600, 255)); if (propertyDialog.exec() == QDialog::Accepted && !featureUi->exportFolder().isEmpty()) { @@ -342,15 +344,17 @@ void RicExportLgrFeature::onActionTriggered(bool isChecked) std::vector simWells; QString dialogTitle = "LGR Export"; - auto dialogData = openDialog(); + int defaultTimeStep = 0; + auto activeView = dynamic_cast(RiaApplication::instance()->activeGridView()); + if (activeView) defaultTimeStep = activeView->currentTimeStep(); + + auto dialogData = openDialog(nullptr, defaultTimeStep); if (dialogData) { - auto activeView = dynamic_cast(RiaApplication::instance()->activeGridView()); - if (!activeView) return; auto eclipseCase = dialogData->caseToApply(); auto lgrCellCounts = dialogData->lgrCellCount(); - size_t timeStep = activeView->currentTimeStep(); + size_t timeStep = dialogData->timeStep(); bool lgrIntersected = false; for (const auto& wellPath : wellPaths) diff --git a/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.h b/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.h index 494f0f54e3..7d14cd4789 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.h +++ b/ApplicationCode/Commands/ExportCommands/RicExportLgrFeature.h @@ -64,7 +64,7 @@ class RicExportLgrFeature : public caf::CmdFeature typedef std::pair Range; static Range initRange() { return std::make_pair(std::numeric_limits::max(), 0); } - static RicExportLgrUi* openDialog(); + static RicExportLgrUi* openDialog(RimEclipseCase* defaultCase = nullptr, int defaultTimeStep = 0); static bool openFileForExport(const QString& folderName, const QString& fileName, QFile* exportFile); static void exportLgrs(QTextStream& stream, const std::vector& lgrInfos); diff --git a/ApplicationCode/Commands/ExportCommands/RicExportLgrUi.cpp b/ApplicationCode/Commands/ExportCommands/RicExportLgrUi.cpp index 8d4b690c1e..96ce8b68b3 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportLgrUi.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicExportLgrUi.cpp @@ -55,6 +55,7 @@ RicExportLgrUi::RicExportLgrUi() m_exportFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); CAF_PDM_InitFieldNoDefault(&m_caseToApply, "CaseToApply", "Source Case", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_timeStep, "TimeStepIndex", "Time Step", "", "", ""); CAF_PDM_InitField(&m_cellCountI, "CellCountI", 2, "Cell Count I", "", "", ""); CAF_PDM_InitField(&m_cellCountJ, "CellCountJ", 2, "Cell Count J", "", "", ""); @@ -77,6 +78,20 @@ void RicExportLgrUi::setCase(RimEclipseCase* rimCase) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportLgrUi::setTimeStep(int timeStep) +{ + bool isDifferent = timeStep != m_timeStep; + + if (isDifferent) + { + m_timeStep = timeStep; + setDefaultValuesFromCase(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -101,6 +116,14 @@ RimEclipseCase* RicExportLgrUi::caseToApply() const return m_caseToApply(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RicExportLgrUi::timeStep() const +{ + return m_timeStep; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -144,6 +167,19 @@ QList RicExportLgrUi::calculateValueOptions(const caf::P { RimTools::caseOptionItems(&options); } + else if (fieldNeedingOptions == &m_timeStep) + { + QStringList timeStepNames; + + if (m_caseToApply) + { + timeStepNames = m_caseToApply->timeStepStrings(); + } + for (int i = 0; i < timeStepNames.size(); i++) + { + options.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i)); + } + } return options; } @@ -165,12 +201,15 @@ void RicExportLgrUi::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c void RicExportLgrUi::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { uiOrdering.add(&m_caseToApply); + uiOrdering.add(&m_timeStep); uiOrdering.add(&m_exportFolder); caf::PdmUiGroup* gridRefinement = uiOrdering.addNewGroup("Grid Refinement"); gridRefinement->add(&m_cellCountI); gridRefinement->add(&m_cellCountJ); gridRefinement->add(&m_cellCountK); + + uiOrdering.skipRemainingFields(true); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/ExportCommands/RicExportLgrUi.h b/ApplicationCode/Commands/ExportCommands/RicExportLgrUi.h index 99b99e88be..c8acd533ea 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportLgrUi.h +++ b/ApplicationCode/Commands/ExportCommands/RicExportLgrUi.h @@ -44,10 +44,12 @@ public: RicExportLgrUi(); void setCase(RimEclipseCase* rimCase); + void setTimeStep(int timeStep); caf::VecIjk lgrCellCount() const; QString exportFolder() const; RimEclipseCase* caseToApply() const; + int timeStep() const; bool singleLgrSplit() const; void setExportFolder(const QString& folder); @@ -64,6 +66,7 @@ private: private: caf::PdmField m_exportFolder; caf::PdmPtrField m_caseToApply; + caf::PdmField m_timeStep; caf::PdmField m_cellCountI; caf::PdmField m_cellCountJ;