diff --git a/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.cpp index ddb5120560..5db936b6f7 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.cpp @@ -91,10 +91,12 @@ void RivReservoirPipesPartMgr::setScaleTransform(cvf::Transform * scaleTransform //-------------------------------------------------------------------------------------------------- void RivReservoirPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) { - if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::PIPES_FORCE_ALL_OFF) return; + if (!m_reservoirView->wellCollection()->showWells() ) return; - if (m_reservoirView->wellCollection()->wells.size() != m_wellPipesPartMgrs.size()) - { + if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::PIPES_FORCE_ALL_OFF) return; + + if (m_reservoirView->wellCollection()->wells.size() != m_wellPipesPartMgrs.size()) + { clearGeometryCache(); for (size_t i = 0; i < m_reservoirView->wellCollection()->wells.size(); ++i) @@ -107,13 +109,13 @@ void RivReservoirPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasic m_wellHeadPartMgrs.push_back(wellHeadMgr); wellHeadMgr->setScaleTransform(m_scaleTransform.p()); } - } + } - for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx) - { - m_wellPipesPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, frameIndex); - m_wellHeadPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, frameIndex); - } + for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx) + { + m_wellPipesPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, frameIndex); + m_wellHeadPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, frameIndex); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellCollection.cpp index b040ad1deb..71b41c70e2 100644 --- a/ApplicationCode/ProjectDataModel/RimWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellCollection.cpp @@ -73,6 +73,9 @@ RimWellCollection::RimWellCollection() { CAF_PDM_InitObject("Wells", ":/WellCollection.png", "", ""); + CAF_PDM_InitField(&showWells, "ShowWells", true, "Show well", "", "", ""); + showWells.setUiHidden(true); + CAF_PDM_InitField(&showWellHead, "ShowWellHead", true, "Show well heads", "", "", ""); CAF_PDM_InitField(&showWellLabel, "ShowWellLabel", true, "Show well labels", "", "", ""); CAF_PDM_InitField(&wellHeadScaleFactor, "WellHeadScale", 1.0, "Well head scale", "", "", ""); @@ -158,6 +161,7 @@ bool RimWellCollection::hasVisibleWellCells() //-------------------------------------------------------------------------------------------------- bool RimWellCollection::hasVisibleWellPipes() { + if (!this->showWells()) return false; if (this->wellPipeVisibility() == PIPES_FORCE_ALL_OFF) return false; if (this->wells().size() == 0 ) return false; if (this->wellPipeVisibility() == PIPES_FORCE_ALL_ON) return true; @@ -171,7 +175,7 @@ bool RimWellCollection::hasVisibleWellPipes() //-------------------------------------------------------------------------------------------------- void RimWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { - if (&showWellLabel == changedField) + if (&showWellLabel == changedField || &showWells == changedField) { if (m_reservoirView) { @@ -261,3 +265,11 @@ void RimWellCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin advancedGroup->add(&wellCellTransparencyLevel); advancedGroup->add(&isAutoDetectingBranches); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimWellCollection::objectToggleField() +{ + return &showWells; +} diff --git a/ApplicationCode/ProjectDataModel/RimWellCollection.h b/ApplicationCode/ProjectDataModel/RimWellCollection.h index f802a2383f..e739fcc5bb 100644 --- a/ApplicationCode/ProjectDataModel/RimWellCollection.h +++ b/ApplicationCode/ProjectDataModel/RimWellCollection.h @@ -68,6 +68,7 @@ public: typedef caf::AppEnum WellFenceEnum; caf::PdmField showWellLabel; + caf::PdmField showWells; caf::PdmField wellCellsToRangeFilterMode; caf::PdmField showWellCellFences; @@ -91,7 +92,7 @@ public: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); - + virtual caf::PdmFieldHandle* objectToggleField(); private: RimReservoirView* m_reservoirView; };