From 2404cf15826966cb28d337129d0f2b93fde9480a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 7 Feb 2017 15:07:11 +0100 Subject: [PATCH] #1189 Visibility of well cells now follow visible range filtered cells --- .../RimCellRangeFilterCollection.cpp | 1 + .../ProjectDataModel/RimEclipseView.cpp | 2 +- .../ProjectDataModel/RimEclipseWell.cpp | 114 ++++++++++++++++++ .../ProjectDataModel/RimEclipseWell.h | 2 + .../RimEclipseWellCollection.cpp | 7 +- 5 files changed, 124 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp index eb9d292eba..d9456c54ca 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp @@ -159,6 +159,7 @@ void RimCellRangeFilterCollection::updateDisplayModeNotifyManagedViews(RimCellRa } } + view->scheduleGeometryRegen(VISIBLE_WELL_CELLS); view->scheduleGeometryRegen(RANGE_FILTERED); view->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index ce8f155e1f..b49239e2ac 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1149,7 +1149,7 @@ void RimEclipseView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleC for (size_t wIdx = 0; wIdx < this->wellCollection()->wells().size(); ++wIdx) { RimEclipseWell* well = this->wellCollection()->wells()[wIdx]; - if (well->showWell() && well->showWellCells()) + if (well->isWellCellsVisible()) { RigSingleWellResultsData* wres = well->wellResults(); if (!wres) continue; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp index 3ae4b5f543..4c0c7bb285 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp @@ -23,6 +23,7 @@ #include "RigSimulationWellCenterLineCalculator.h" #include "RigSingleWellResultsData.h" +#include "RimCellRangeFilterCollection.h" #include "RimEclipseView.h" #include "RimEclipseWellCollection.h" #include "RimIntersectionCollection.h" @@ -217,6 +218,78 @@ bool RimEclipseWell::intersectsVisibleCells(size_t frameIndex) const return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseWell::intersectsStaticWellCellsRangeFilteredCells() const +{ + if (this->wellResults() == nullptr) return false; + + RimEclipseView* m_reservoirView = nullptr; + this->firstAncestorOrThisOfType(m_reservoirView); + + const std::vector& visGridParts = m_reservoirView->visibleGridParts(); + cvf::cref rvMan = m_reservoirView->reservoirGridPartManager(); + + // NOTE: Read out static well cells, union of well cells across all time steps + const RigWellResultFrame& wrsf = this->wellResults()->m_staticWellCells; + + for (const RivCellSetEnum& visGridPart : visGridParts) + { + if (visGridPart == ALL_WELL_CELLS + || visGridPart == VISIBLE_WELL_CELLS + || visGridPart == VISIBLE_WELL_FENCE_CELLS + || visGridPart == VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER + || visGridPart == VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER + ) + { + // Exclude all cells related to well cells + continue; + } + + // NOTE: Use first time step for visibility evaluation + size_t frameIndex = 0; + + // First check the wellhead: + + size_t gridIndex = wrsf.m_wellHead.m_gridIndex; + size_t gridCellIndex = wrsf.m_wellHead.m_gridCellIndex; + + if (gridIndex != cvf::UNDEFINED_SIZE_T && gridCellIndex != cvf::UNDEFINED_SIZE_T) + { + cvf::cref cellVisibility = rvMan->cellVisibility(visGridPart, gridIndex, frameIndex); + if (gridCellIndex < cellVisibility->size() && (*cellVisibility)[gridCellIndex]) + { + return true; + } + } + + // Then check the rest of the well, with all the branches + + const std::vector& wellResSegments = wrsf.m_wellResultBranches; + for (const RigWellResultBranch& branchSegment : wellResSegments) + { + const std::vector& wsResCells = branchSegment.m_branchResultPoints; + for (const RigWellResultPoint& wellResultPoint : wsResCells) + { + if (wellResultPoint.isCell()) + { + gridIndex = wellResultPoint.m_gridIndex; + gridCellIndex = wellResultPoint.m_gridCellIndex; + + cvf::cref cellVisibility = rvMan->cellVisibility(visGridPart, gridIndex, frameIndex); + if (gridCellIndex < cellVisibility->size() && (*cellVisibility)[gridCellIndex]) + { + return true; + } + } + } + } + } + + return false; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -251,6 +324,13 @@ void RimEclipseWell::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering this->firstAncestorOrThisOfType(reservoirView); if (!reservoirView) return; + if (reservoirView->rangeFilterCollection() && !reservoirView->rangeFilterCollection()->hasActiveFilters()) + { + this->uiCapability()->setUiReadOnly(false); + + return; + } + const RimEclipseWellCollection* wellColl = nullptr; this->firstAncestorOrThisOfType(wellColl); if (!wellColl) return; @@ -267,6 +347,40 @@ void RimEclipseWell::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseWell::isWellCellsVisible() const +{ + const RimEclipseView* reservoirView = nullptr; + this->firstAncestorOrThisOfType(reservoirView); + + if (reservoirView == nullptr) return false; + if (this->wellResults() == nullptr) return false; + + if (!reservoirView->wellCollection()->isActive()) + return false; + + if (!this->showWell()) + return false; + + if (!this->showWellCells()) + return false; + + if (reservoirView->crossSectionCollection()->hasActiveIntersectionForSimulationWell(this)) + return true; + + if (reservoirView->wellCollection()->showWellsIntersectingVisibleCells()) + { + return intersectsStaticWellCellsRangeFilteredCells(); + } + else + { + return true; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWell.h b/ApplicationCode/ProjectDataModel/RimEclipseWell.h index f74b1aa82b..751cdf8ca8 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWell.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.h @@ -49,6 +49,7 @@ public: const RigSingleWellResultsData* wellResults() const; size_t resultWellIndex() const; + bool isWellCellsVisible() const; bool isWellPipeVisible(size_t frameIndex) const; bool isWellSpheresVisible(size_t frameIndex) const; bool isUsingCellCenterForPipe() const; @@ -88,6 +89,7 @@ protected: private: bool intersectsVisibleCells(size_t frameIndex) const; + bool intersectsStaticWellCellsRangeFilteredCells() const; private: cvf::ref m_wellResults; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp index c63d34a61d..460f31b5ae 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp @@ -399,13 +399,18 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang || &isAutoDetectingBranches == changedField || &wellHeadPosition == changedField || &wellLabelColor == changedField - || &showWellsIntersectingVisibleCells == changedField || &wellPipeCoordType == changedField || &m_showWellPipe == changedField) { m_reservoirView->schedulePipeGeometryRegen(); m_reservoirView->scheduleCreateDisplayModelAndRedraw(); } + else if (&showWellsIntersectingVisibleCells == changedField) + { + m_reservoirView->scheduleGeometryRegen(VISIBLE_WELL_CELLS); + m_reservoirView->schedulePipeGeometryRegen(); + m_reservoirView->scheduleCreateDisplayModelAndRedraw(); + } } if (&m_applyIndividualColorsToWells == changedField)