From 406c371682c08135986d3cfa04f6308f8c55a982 Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Mon, 11 Dec 2017 10:46:29 +0100 Subject: [PATCH] #2227 Well formation: Make level filter dynamic --- .../ProjectDataModel/RimWellLogTrack.cpp | 34 +++- .../RigWellPathFormations.cpp | 149 ++++++++++-------- .../RigWellPathFormations.h | 10 +- 3 files changed, 123 insertions(+), 70 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp index 21ffad7bd2..58208b9618 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -94,7 +94,9 @@ namespace caf addItem(RigWellPathFormation::LEVEL1, "LEVEL1", "Level 1"); addItem(RigWellPathFormation::LEVEL2, "LEVEL2", "Level 2"); addItem(RigWellPathFormation::LEVEL3, "LEVEL3", "Level 3"); - setDefault(RigWellPathFormation::ALL); + addItem(RigWellPathFormation::LEVEL4, "LEVEL4", "Level 4"); + addItem(RigWellPathFormation::LEVEL5, "LEVEL5", "Level 5"); + addItem(RigWellPathFormation::LEVEL6, "LEVEL6", "Level 6"); } } @@ -349,6 +351,27 @@ QList RimWellLogTrack::calculateValueOptions(const caf:: auto simulationWellBranches = RiaSimWellBranchTools::simulationWellBranches(m_formationSimWellName(), m_formationBranchDetection); options = RiaSimWellBranchTools::valueOptionsForBranchIndexField(simulationWellBranches); } + else if (fieldNeedingOptions == &m_formationLevel) + { + if (m_formationWellPath) + { + const RigWellPathFormations* formations = m_formationWellPath->formationsGeometry(); + if (formations) + { + options.push_back(caf::PdmOptionItemInfo(caf::AppEnum::uiText(RigWellPathFormation::ALL), + caf::AppEnum::fromText("All"))); + + for (const RigWellPathFormation::FormationLevel& level : formations->formationsLevelsPresent()) + { + size_t index = caf::AppEnum::index(level); + if (index >= caf::AppEnum::size()) continue; + + options.push_back(caf::PdmOptionItemInfo(caf::AppEnum::uiTextFromIndex(index), + caf::AppEnum::fromIndex(index))); + } + } + } + } return options; } @@ -768,8 +791,11 @@ void RimWellLogTrack::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& else if (m_formationSource() == WELL_PICK_FILTER) { formationGroup->add(&m_formationWellPath); - formationGroup->add(&m_formationLevel); - formationGroup->add(&m_showformationFluids); + if (m_formationWellPath()) + { + formationGroup->add(&m_formationLevel); + formationGroup->add(&m_showformationFluids); + } } uiOrderingForVisibleXRange(uiOrdering); @@ -1106,6 +1132,8 @@ void RimWellLogTrack::setFormationFieldsUiReadOnly(bool readOnly /*= true*/) m_formationCase.uiCapability()->setUiReadOnly(readOnly); m_formationWellPath.uiCapability()->setUiReadOnly(readOnly); m_formationBranchIndex.uiCapability()->setUiReadOnly(readOnly); + m_formationLevel.uiCapability()->setUiReadOnly(readOnly); + m_showformationFluids.uiCapability()->setUiReadOnly(readOnly); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp index 8f3c65906b..d0ec66879e 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp @@ -31,16 +31,12 @@ RigWellPathFormations::RigWellPathFormations(std::vector f m_filePath = filePath; m_keyInFile = key; m_formations = formations; - m_maxLevelDetected = RigWellPathFormation::ALL; for (RigWellPathFormation& formation : m_formations) { RigWellPathFormation::FormationLevel level = detectLevel(formation.formationName); - formation.level = level; - if (level > m_maxLevelDetected) - { - m_maxLevelDetected = level; - } + formation.level = level; + m_formationsLevelsPresent[level] = true; } } @@ -88,90 +84,112 @@ void RigWellPathFormations::measuredDepthAndFormationNamesWithoutDuplicatesOnDep } } -struct NameAndMD +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +struct LevelAndName { - NameAndMD(RigWellPathFormation::FormationLevel level, QString name, double md) : m_level(level), m_name(name), m_md(md) {} - NameAndMD() {} - RigWellPathFormation::FormationLevel m_level; - QString m_name; - double m_md; + LevelAndName() {} + LevelAndName(RigWellPathFormation::FormationLevel level, QString name) : level(level), name(name) {} + + RigWellPathFormation::FormationLevel level; + QString name; }; +enum PICK_POSITION +{ + TOP, + BASE +}; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void evaluateFormations(const std::vector& formations, const RigWellPathFormation::FormationLevel& maxLevel, + bool includeFluids, const PICK_POSITION& position, + std::map* uniqueListMaker) +{ + QString postFix; + + if (position == TOP) + { + postFix = " Top"; + } + else + { + postFix = " Base"; + } + + for (const RigWellPathFormation& formation : formations) + { + double md; + if (position == TOP) + { + md = formation.mdTop; + } + else + { + md = formation.mdBase; + } + + if (formation.level == RigWellPathFormation::FLUIDS) + { + if (includeFluids) + { + (*uniqueListMaker)[md] = LevelAndName(formation.level, formation.formationName + postFix); + } + continue; + } + + if (formation.level > maxLevel) continue; + + if (!uniqueListMaker->count(md) || uniqueListMaker->at(md).level < formation.level) + { + (*uniqueListMaker)[md] = LevelAndName(formation.level, formation.formationName + postFix); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigWellPathFormations::measuredDepthAndFormationNamesUpToLevel(RigWellPathFormation::FormationLevel level, +void RigWellPathFormations::measuredDepthAndFormationNamesUpToLevel(RigWellPathFormation::FormationLevel maxLevel, std::vector* names, std::vector* measuredDepths, bool includeFluids) const { names->clear(); measuredDepths->clear(); - if (level == RigWellPathFormation::ALL) + if (maxLevel == RigWellPathFormation::ALL) { measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(names, measuredDepths); return; } - std::map tempMakeVectorUniqueOnMeasuredDepth; + std::map tempMakeVectorUniqueOnMeasuredDepth; - for (RigWellPathFormation formation : m_formations) - { - if (formation.level == RigWellPathFormation::FLUIDS) - { - if (includeFluids) - { - tempMakeVectorUniqueOnMeasuredDepth[formation.mdTop] = - NameAndMD(formation.level, formation.formationName + " Top", formation.mdTop); - } - else continue; - } + evaluateFormations(m_formations, maxLevel, includeFluids, PICK_POSITION::TOP, &tempMakeVectorUniqueOnMeasuredDepth); - if (level < formation.level) continue; - - if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.mdTop) || - tempMakeVectorUniqueOnMeasuredDepth.at(formation.mdTop).m_level < formation.level) - { - tempMakeVectorUniqueOnMeasuredDepth[formation.mdTop] = - NameAndMD(formation.level, formation.formationName + " Top", formation.mdTop); - } - } - - for (RigWellPathFormation formation : m_formations) - { - if (formation.level == RigWellPathFormation::FLUIDS) - { - if (includeFluids) - { - tempMakeVectorUniqueOnMeasuredDepth[formation.mdTop] = - NameAndMD(formation.level, formation.formationName + " Base", formation.mdTop); - } - else continue; - } - - if (level < formation.level) continue; - - if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.mdBase) || - tempMakeVectorUniqueOnMeasuredDepth.at(formation.mdBase).m_level < formation.level) - { - tempMakeVectorUniqueOnMeasuredDepth[formation.mdBase] = - NameAndMD(formation.level, formation.formationName + " Base", formation.mdBase); - } - } + evaluateFormations(m_formations, maxLevel, includeFluids, PICK_POSITION::BASE, &tempMakeVectorUniqueOnMeasuredDepth); for (auto it = tempMakeVectorUniqueOnMeasuredDepth.begin(); it != tempMakeVectorUniqueOnMeasuredDepth.end(); it++) { - names->push_back(it->second.m_name); - measuredDepths->push_back(it->second.m_md); + measuredDepths->push_back(it->first); + names->push_back(it->second.name); } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -RigWellPathFormation::FormationLevel RigWellPathFormations::maxFormationLevel() const +std::vector RigWellPathFormations::formationsLevelsPresent() const { - return m_maxLevelDetected; + std::vector formationLevels; + + for (auto it = m_formationsLevelsPresent.begin(); it != m_formationsLevelsPresent.end(); it++) + { + formationLevels.push_back(it->first); + } + return formationLevels; } //-------------------------------------------------------------------------------------------------- @@ -257,7 +275,7 @@ RigWellPathFormation::FormationLevel RigWellPathFormations::detectLevel(QString } } } - if (levelDesctiptorCandidates.size() != 1) return RigWellPathFormation::ALL; + if (levelDesctiptorCandidates.size() != 1) return RigWellPathFormation::UNKNOWN; QString levelDescriptor = levelDesctiptorCandidates[0]; @@ -270,7 +288,10 @@ RigWellPathFormation::FormationLevel RigWellPathFormations::detectLevel(QString case 0: return RigWellPathFormation::LEVEL1; case 1: return RigWellPathFormation::LEVEL2; case 2: return RigWellPathFormation::LEVEL3; + case 3: return RigWellPathFormation::LEVEL4; + case 4: return RigWellPathFormation::LEVEL5; + case 5: return RigWellPathFormation::LEVEL6; default: break; } - return RigWellPathFormation::ALL; + return RigWellPathFormation::UNKNOWN; } diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h index 11ac386949..97268081a9 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h @@ -36,8 +36,12 @@ struct RigWellPathFormation LEVEL1, LEVEL2, LEVEL3, + LEVEL4, + LEVEL5, + LEVEL6, ALL, - FLUIDS + FLUIDS, + UNKNOWN }; double mdTop; @@ -57,7 +61,7 @@ public: void measuredDepthAndFormationNamesUpToLevel(RigWellPathFormation::FormationLevel level, std::vector* names, std::vector* measuredDepths, bool includeFluids) const; - RigWellPathFormation::FormationLevel maxFormationLevel() const; + std::vector formationsLevelsPresent() const; QString filePath() const; QString keyInFile() const; @@ -71,7 +75,7 @@ private: QString m_filePath; QString m_keyInFile; - RigWellPathFormation::FormationLevel m_maxLevelDetected; + std::map m_formationsLevelsPresent; std::vector m_formations; };