From 6e4449960f6d5e2cd36933b0e84a87185923e6a7 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Tue, 12 Dec 2017 08:37:56 +0100 Subject: [PATCH] #2227 Well formatins: Clear well path if it does not have well picks --- ApplicationCode/ProjectDataModel/RimTools.cpp | 22 +++++++++++++++---- ApplicationCode/ProjectDataModel/RimTools.h | 3 +++ .../ProjectDataModel/RimWellLogTrack.cpp | 16 ++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimTools.cpp b/ApplicationCode/ProjectDataModel/RimTools.cpp index 155c84a0d6..4047cc1108 100644 --- a/ApplicationCode/ProjectDataModel/RimTools.cpp +++ b/ApplicationCode/ProjectDataModel/RimTools.cpp @@ -248,17 +248,31 @@ void RimTools::wellPathWithFormationsOptionItems(QList* CVF_ASSERT(options); if (!options) return; + std::vector wellPaths; + RimTools::wellPathWithFormations(&wellPaths); + + QIcon wellIcon(":/Well.png"); + for (RimWellPath* wellPath : wellPaths) + { + options->push_back(caf::PdmOptionItemInfo(wellPath->name(), wellPath, false, wellIcon)); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTools::wellPathWithFormations(std::vector* wellPaths) +{ RimProject* proj = RiaApplication::instance()->project(); if (proj && proj->activeOilField() && proj->activeOilField()->wellPathCollection()) { - caf::PdmChildArrayField& wellPaths = proj->activeOilField()->wellPathCollection()->wellPaths; + caf::PdmChildArrayField& allWellPaths = proj->activeOilField()->wellPathCollection()->wellPaths; - QIcon wellIcon(":/Well.png"); - for (RimWellPath* wellPath : wellPaths) + for (RimWellPath* wellPath : allWellPaths) { if (wellPath->hasFormations()) { - options->push_back(caf::PdmOptionItemInfo(wellPath->name(), wellPath, false, wellIcon)); + wellPaths->push_back(wellPath); } } } diff --git a/ApplicationCode/ProjectDataModel/RimTools.h b/ApplicationCode/ProjectDataModel/RimTools.h index dc4d60ae89..54e5e16788 100644 --- a/ApplicationCode/ProjectDataModel/RimTools.h +++ b/ApplicationCode/ProjectDataModel/RimTools.h @@ -20,6 +20,8 @@ #pragma once +#include "RimWellPath.h" + #include #include @@ -43,6 +45,7 @@ public: static void wellPathOptionItems(QList* options); static void wellPathWithFormationsOptionItems(QList* options); + static void wellPathWithFormations(std::vector* wellPaths); static void caseOptionItems(QList* options); static QString createTimeFormatStringFromDates(const std::vector& dates); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp index ea2b619dc0..c7cf0722a9 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -277,6 +277,22 @@ void RimWellLogTrack::fieldChangedByUi(const caf::PdmFieldHandle* changedField, pltPlot->updateConnectedEditors(); } } + + bool validWellPathChosen = false; + std::vector wellPaths; + RimTools::wellPathWithFormations(&wellPaths); + for (RimWellPath* wellPath : wellPaths) + { + if (wellPath == m_formationWellPath) + { + validWellPathChosen = true; + break; + } + } + if (!validWellPathChosen) + { + m_formationWellPath = nullptr; + } } else if (changedField == &m_formationCase) {