From a4484579e2475768694a05295777855f3795e947 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Sun, 12 Nov 2017 21:57:25 +0100 Subject: [PATCH] Select last imported wellPath on import, not last wellPath in collection --- .../RicWellPathsImportFileFeature.cpp | 12 ++++++++++-- .../ProjectDataModel/RimWellPathCollection.cpp | 6 ++++++ .../ProjectDataModel/RimWellPathCollection.h | 3 +++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathsImportFileFeature.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathsImportFileFeature.cpp index 052003e36a..2f8b9e76f1 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathsImportFileFeature.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathsImportFileFeature.cpp @@ -70,8 +70,16 @@ void RicWellPathsImportFileFeature::onActionTriggered(bool isChecked) if (oilField->wellPathCollection->wellPaths().size() > 0) { - RimWellPath* wellPath = oilField->wellPathCollection->wellPaths()[oilField->wellPathCollection->wellPaths().size() - 1]; - RiuMainWindow::instance()->selectAsCurrentItem(wellPath); + + RimWellPath* wellPath = nullptr; + QString wellPathName = oilField->wellPathCollection->newestAddedWellName(); + + wellPath = oilField->wellPathCollection->wellPathByName(wellPathName); + + if (wellPath) + { + RiuMainWindow::instance()->selectAsCurrentItem(wellPath); + } } } } diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp index a1c9a29a75..4a42bfda7b 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp @@ -96,6 +96,7 @@ RimWellPathCollection::RimWellPathCollection() wellPaths.uiCapability()->setUiHidden(true); m_wellPathImporter = new RifWellPathImporter; + m_newestAddedWellName = QString(); } @@ -273,6 +274,11 @@ void RimWellPathCollection::readAndAddWellPaths(std::vector& wellP progress.incrementProgress(); } + if (!wellPathArray.empty()) + { + m_newestAddedWellName = wellPathArray.back()->name(); + } + this->sortWellsByName(); } diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.h b/ApplicationCode/ProjectDataModel/RimWellPathCollection.h index fa7f7b62bf..3b3b3cc1c2 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.h +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.h @@ -66,6 +66,8 @@ public: void setProject(RimProject* project); + QString newestAddedWellName() { return m_newestAddedWellName; } + enum WellVisibilityType { FORCE_ALL_OFF, @@ -129,4 +131,5 @@ private: RiaEclipseUnitTools::UnitSystemType findUnitSystemForWellPath(const RimWellPath* wellPath); RifWellPathImporter* m_wellPathImporter; + QString m_newestAddedWellName; };