diff --git a/ApplicationCode/ModelVisualization/RivReservoirWellSpheresPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirWellSpheresPartMgr.cpp index 42132eab56..d6696066f5 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirWellSpheresPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirWellSpheresPartMgr.cpp @@ -48,9 +48,9 @@ RivReservoirWellSpheresPartMgr::~RivReservoirWellSpheresPartMgr() } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------- +// / +// -------------------------------------------------------------------------------------------------- void RivReservoirWellSpheresPartMgr::setScaleTransform(cvf::Transform * scaleTransform) { m_scaleTransform = scaleTransform; @@ -62,8 +62,8 @@ void RivReservoirWellSpheresPartMgr::setScaleTransform(cvf::Transform * scaleTra //-------------------------------------------------------------------------------------------------- void RivReservoirWellSpheresPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) { - if (!m_reservoirView->wellCollection()->showCellCenterSpheres) return; - + if (m_reservoirView->wellCollection()->wellSphereVisibility == RimEclipseWellCollection::PIPES_FORCE_ALL_OFF) return; + if (!m_reservoirView->wellCollection()->isActive()) return; if (m_reservoirView->wellCollection()->wells.size() != m_wellSpheresPartMgrs.size()) @@ -78,8 +78,33 @@ void RivReservoirWellSpheresPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode for (size_t i = 0; i < m_wellSpheresPartMgrs.size(); i++) { + + bool showGeo = false; + + if (m_reservoirView->wellCollection()->wells[i]->showWell()) { + + if (m_reservoirView->wellCollection->wellSphereVisibility == RimEclipseWellCollection::PIPES_FORCE_ALL_ON) + { + showGeo = true; + } + + else if (m_reservoirView->wellCollection->wellSphereVisibility == RimEclipseWellCollection::PIPES_INDIVIDUALLY && m_reservoirView->wellCollection()->wells[i]->showWellSpheres() ) + { + showGeo = true; + } + + else if (m_reservoirView->wellCollection->wellSphereVisibility == RimEclipseWellCollection::PIPES_OPEN_IN_VISIBLE_CELLS && m_reservoirView->wellCollection->wells[i]->visibleCellsInstersectsWell(frameIndex)) + { + showGeo = true; + } + + } + + + if (showGeo) + { m_wellSpheresPartMgrs.at(i)->appendDynamicGeometryPartsToModel(model, frameIndex); } } diff --git a/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.cpp index 7c162f457a..bd63a38b78 100644 --- a/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.cpp @@ -63,6 +63,7 @@ RivWellSpheresPartMgr::~RivWellSpheresPartMgr() } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -71,7 +72,10 @@ void RivWellSpheresPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLis if (m_rimReservoirView.isNull()) return; if (!m_rimReservoirView->eclipseCase()) return; if (!m_rimReservoirView->eclipseCase()->reservoirData()) return; - if (!m_rimWell->showWellSpheres()) return; + + + // if (!m_rimWell->showWellSpheres() ) return; //TODO: Check that all on is not on... + const RigMainGrid* mainGrid = m_rimReservoirView->eclipseCase()->reservoirData()->mainGrid(); CVF_ASSERT(mainGrid); @@ -115,7 +119,6 @@ void RivWellSpheresPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLis model->addPart(part.p()); } -//TODO: Transparency må være linka til show cell center spheres og All On/Of for well pipes // -------------------------------------------------------------------------------------------------- // / diff --git a/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.h b/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.h index 422be015aa..430e651100 100644 --- a/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.h @@ -59,8 +59,8 @@ public: void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); private: - static cvf::ref createSphere(double radius, const cvf::Vec3d& pos); - cvf::ref createPart(cvf::DrawableGeo* geo, const cvf::Color3f& color); +// static cvf::ref createSphere(double radius, const cvf::Vec3d& pos); +// cvf::ref createPart(cvf::DrawableGeo* geo, const cvf::Color3f& color); cvf::Color3f wellCellColor(const RigWellResultFrame& wellResultFrame, const RigWellResultPoint& wellResultPoint); cvf::ref createPart(std::vector >& centerColorPairs); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp index 1c9f7d2a8d..bd6f71b474 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp @@ -190,55 +190,65 @@ bool RimEclipseWell::calculateWellPipeVisibility(size_t frameIndex) if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimEclipseWellCollection::PIPES_OPEN_IN_VISIBLE_CELLS) { - const std::vector& visGridParts = m_reservoirView->visibleGridParts(); - cvf::cref rvMan = m_reservoirView->reservoirGridPartManager(); - for (size_t gpIdx = 0; gpIdx < visGridParts.size(); ++gpIdx) + return visibleCellsInstersectsWell(frameIndex); + } + + CVF_ASSERT(false); // Never end here. have you added new pipe visibility modes ? + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseWell::visibleCellsInstersectsWell(size_t frameIndex) +{ + //TODO: lag egen funksjon her: + const std::vector& visGridParts = m_reservoirView->visibleGridParts(); + cvf::cref rvMan = m_reservoirView->reservoirGridPartManager(); + + for (size_t gpIdx = 0; gpIdx < visGridParts.size(); ++gpIdx) + { + const RigWellResultFrame& wrsf = this->wellResults()->wellResultFrame(frameIndex); + + // 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) { - const RigWellResultFrame& wrsf = this->wellResults()->wellResultFrame(frameIndex); - - // 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(visGridParts[gpIdx], gridIndex, frameIndex); + if ((*cellVisibility)[gridCellIndex]) { - cvf::cref cellVisibility = rvMan->cellVisibility(visGridParts[gpIdx], gridIndex, frameIndex); - if ((*cellVisibility)[gridCellIndex]) - { - return true; - } + return true; } + } - // Then check the rest of the well, with all the branches + // Then check the rest of the well, with all the branches - const std::vector& wellResSegments = wrsf.m_wellResultBranches; - for (size_t wsIdx = 0; wsIdx < wellResSegments.size(); ++wsIdx) + const std::vector& wellResSegments = wrsf.m_wellResultBranches; + for (size_t wsIdx = 0; wsIdx < wellResSegments.size(); ++wsIdx) + { + const std::vector& wsResCells = wellResSegments[wsIdx].m_branchResultPoints; + for (size_t cIdx = 0; cIdx < wsResCells.size(); ++cIdx) { - const std::vector& wsResCells = wellResSegments[wsIdx].m_branchResultPoints; - for (size_t cIdx = 0; cIdx < wsResCells.size(); ++ cIdx) + if (wsResCells[cIdx].isCell()) { - if (wsResCells[cIdx].isCell()) - { - gridIndex = wsResCells[cIdx].m_gridIndex; - gridCellIndex = wsResCells[cIdx].m_gridCellIndex; + gridIndex = wsResCells[cIdx].m_gridIndex; + gridCellIndex = wsResCells[cIdx].m_gridCellIndex; - cvf::cref cellVisibility = rvMan->cellVisibility(visGridParts[gpIdx], gridIndex, frameIndex); - if ((*cellVisibility)[gridCellIndex]) - { - return true; - } + cvf::cref cellVisibility = rvMan->cellVisibility(visGridParts[gpIdx], gridIndex, frameIndex); + if ((*cellVisibility)[gridCellIndex]) + { + return true; } } } } - - return false; } - CVF_ASSERT(false); // Never end here. have you added new pipe visibility modes ? - return false; } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWell.h b/ApplicationCode/ProjectDataModel/RimEclipseWell.h index 244693a470..a138d76457 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWell.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.h @@ -56,6 +56,10 @@ public: bool calculateWellPipeVisibility(size_t frameIndex); + bool visibleCellsInstersectsWell(size_t frameIndex); + + //Trengs det en calculateWellGeometryVisibility?? + virtual caf::PdmFieldHandle* userDescriptionField(); virtual caf::PdmFieldHandle* objectToggleField(); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp index 676de6ed08..f9f74879d7 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp @@ -108,8 +108,7 @@ RimEclipseWellCollection::RimEclipseWellCollection() CAF_PDM_InitField(&isAutoDetectingBranches, "IsAutoDetectingBranches", true, "Geometry based branch detection", "", "Toggle wether the well pipe visualization will try to detect when a part of the well \nis really a branch, and thus is starting from wellhead", ""); - CAF_PDM_InitField(&showCellCenterSpheres, "showCellCenterSpheres", false, "Show sphere in cell center", "", "", ""); -// CAF_PDM_InitField(&wellSphereVisibility, "wellSphereVisibility", WellVisibilityEnum(PIPES_OPEN_IN_VISIBLE_CELLS), "Global well sphere visibility", "", "", ""); + CAF_PDM_InitField(&wellSphereVisibility, "wellSphereVisibility", WellVisibilityEnum(PIPES_OPEN_IN_VISIBLE_CELLS), "Global well sphere visibility", "", "", ""); CAF_PDM_InitField(&cellCenterSpheresScaleFactor, "CellCenterSphereScale", 0.2, "Cell Center sphere radius", "", "", ""); CAF_PDM_InitFieldNoDefault(&wells, "Wells", "Wells", "", "", ""); @@ -179,7 +178,7 @@ bool RimEclipseWellCollection::hasVisibleWellCells() //-------------------------------------------------------------------------------------------------- /// Used to know if we need animation of timesteps due to the wells //-------------------------------------------------------------------------------------------------- -bool RimEclipseWellCollection::hasVisibleWellPipes() +bool RimEclipseWellCollection::hasVisibleWellPipes() { if (!this->isActive()) return false; if (this->wellPipeVisibility() == PIPES_FORCE_ALL_OFF) return false; @@ -189,7 +188,6 @@ bool RimEclipseWellCollection::hasVisibleWellPipes() return true; } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -228,7 +226,7 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang m_reservoirView->scheduleCreateDisplayModelAndRedraw(); } } - else if ( &showCellCenterSpheres == changedField + else if ( &wellSphereVisibility == changedField || &cellCenterSpheresScaleFactor == changedField) { if (m_reservoirView) @@ -298,7 +296,7 @@ void RimEclipseWellCollection::defineUiOrdering(QString uiConfigName, caf::PdmUi wellPipe->add(&pipeRadiusScaleFactor); caf::PdmUiGroup* cellCenterSpheres = uiOrdering.addNewGroup("Well cell center spheres"); - cellCenterSpheres->add(&showCellCenterSpheres); + cellCenterSpheres->add(&wellSphereVisibility); cellCenterSpheres->add(&cellCenterSpheresScaleFactor); caf::PdmUiGroup* advancedGroup = uiOrdering.addNewGroup("Advanced"); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h index 9c2afd0c8d..eb767274dc 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h @@ -45,7 +45,7 @@ public: RimEclipseWellCollection(); virtual ~RimEclipseWellCollection(); - + void setReservoirView(RimEclipseView* ownerReservoirView); enum WellVisibilityType @@ -102,8 +102,7 @@ public: caf::PdmField isAutoDetectingBranches; - caf::PdmField showCellCenterSpheres; - //caf::PdmField wellSphereVisibility; + caf::PdmField wellSphereVisibility; caf::PdmField cellCenterSpheresScaleFactor;