From fad0974b3f8413f527e1b08b422f302729c776ab Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 2 Feb 2017 08:26:27 +0100 Subject: [PATCH] #1148 Use tristate for well cell visibility --- .../ProjectDataModel/RimEclipseView.cpp | 5 +- .../ProjectDataModel/RimEclipseWell.cpp | 64 ++++++++++------- .../RimEclipseWellCollection.cpp | 68 +++++++++++++++---- .../RimEclipseWellCollection.h | 8 ++- .../UserInterface/RiuMainWindow.cpp | 3 +- 5 files changed, 103 insertions(+), 45 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 6b7406a2d7..da02b4e166 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1141,9 +1141,6 @@ void RimEclipseView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleC } visibleCells->setAll(false); - // If all wells are forced off, return - if (!this->wellCollection()->showWellCells()) return; - RigActiveCellInfo* activeCellInfo = this->currentActiveCellInfo(); CVF_ASSERT(activeCellInfo); @@ -1152,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 (this->wellCollection()->showWellCells() && well->showWell() && well->showWellCells()) + if (well->showWell() && well->showWellCells()) { RigSingleWellResultsData* wres = well->wellResults(); if (!wres) continue; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp index b694aa9622..8b254b2ee2 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp @@ -27,6 +27,8 @@ #include "RimEclipseWellCollection.h" #include "RimIntersectionCollection.h" +#include "RiuMainWindow.h" + #include "cvfMath.h" CAF_PDM_SOURCE_INIT(RimEclipseWell, "Well"); @@ -51,7 +53,7 @@ RimEclipseWell::RimEclipseWell() CAF_PDM_InitField(&pipeScaleFactor, "WellPipeRadiusScale", 1.0, "Pipe Scale Factor", "", "", ""); CAF_PDM_InitField(&wellPipeColor, "WellPipeColor", cvf::Color3f(0.588f, 0.588f, 0.804f), "Pipe color", "", "", ""); - CAF_PDM_InitField(&showWellCells, "ShowWellCells", true, "Well Cells", "", "", ""); + CAF_PDM_InitField(&showWellCells, "ShowWellCells", false, "Well Cells", "", "", ""); CAF_PDM_InitField(&showWellCellFence, "ShowWellCellFence", false, "Well Cell Fence", "", "", ""); m_resultWellIndex = cvf::UNDEFINED_SIZE_T; @@ -77,34 +79,44 @@ caf::PdmFieldHandle* RimEclipseWell::userDescriptionField() //-------------------------------------------------------------------------------------------------- void RimEclipseWell::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { - RimEclipseView* m_reservoirView = nullptr; - this->firstAncestorOrThisOfType(m_reservoirView); - if (!m_reservoirView) return; - - if (&showWellLabel == changedField || - &showWellHead == changedField || - &showWellPipe == changedField || - &showWellSpheres == changedField || - &wellPipeColor == changedField) + RimEclipseView* reservoirView = nullptr; + this->firstAncestorOrThisOfType(reservoirView); + if (reservoirView) { - m_reservoirView->scheduleCreateDisplayModelAndRedraw(); - } - else if (&showWell == changedField || - &showWellCells == changedField || - &showWellCellFence == changedField) - - { - m_reservoirView->scheduleGeometryRegen(VISIBLE_WELL_CELLS); - m_reservoirView->scheduleCreateDisplayModelAndRedraw(); - } - else if ( &pipeScaleFactor == changedField - || &wellHeadScaleFactor == changedField) - { - if (m_reservoirView) + if (&showWellLabel == changedField || + &showWellHead == changedField || + &showWellPipe == changedField || + &showWellSpheres == changedField || + &wellPipeColor == changedField) { - m_reservoirView->schedulePipeGeometryRegen(); - m_reservoirView->scheduleCreateDisplayModelAndRedraw(); + reservoirView->scheduleCreateDisplayModelAndRedraw(); } + else if (&showWell == changedField || + &showWellCells == changedField || + &showWellCellFence == changedField) + + { + reservoirView->scheduleGeometryRegen(VISIBLE_WELL_CELLS); + reservoirView->scheduleCreateDisplayModelAndRedraw(); + } + else if ( &pipeScaleFactor == changedField + || &wellHeadScaleFactor == changedField) + { + if (reservoirView) + { + reservoirView->schedulePipeGeometryRegen(); + reservoirView->scheduleCreateDisplayModelAndRedraw(); + } + } + } + + RimEclipseWellCollection* wellColl = nullptr; + this->firstAncestorOrThisOfType(wellColl); + if (wellColl) + { + wellColl->updateStateForVisibilityCheckboxes(); + + RiuMainWindow::instance()->refreshDrawStyleActions(); } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp index 0faffc650f..e149f8d7e7 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp @@ -161,7 +161,11 @@ RimEclipseWellCollection::RimEclipseWellCollection() pipeCrossSectionVertexCount.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&wellPipeCoordType, "WellPipeCoordType", WellPipeCoordEnum(WELLPIPE_INTERPOLATED), "Type", "", "", ""); - CAF_PDM_InitField(&showWellCells, "ShowWellCells", false, "Show Well Cells", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_showWellCells, "ShowWellCells", "Show Well Cells", "", "", ""); + m_showWellCells.uiCapability()->setUiEditorTypeName(caf::PdmUiCheckBoxTristateEditor::uiEditorTypeName()); + m_showWellCells.xmlCapability()->setIOReadable(false); + m_showWellCells.xmlCapability()->setIOWritable(false); + CAF_PDM_InitField(&showWellCellFence, "ShowWellFences", false, "Show Well Cell Fence", "", "", ""); CAF_PDM_InitField(&wellCellFenceType, "DefaultWellFenceDirection", WellFenceEnum(K_DIRECTION), "Well Fence Direction", "", "", ""); @@ -191,6 +195,40 @@ RimEclipseWellCollection::~RimEclipseWellCollection() wells.deleteAllChildObjects(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseWellCollection::setShowWellCellsState(bool enable) +{ + for (RimEclipseWell* w : wells) + { + w->showWellCells = enable; + } + + updateConnectedEditors(); + + if (m_reservoirView) + { + m_reservoirView->scheduleGeometryRegen(VISIBLE_WELL_CELLS); + m_reservoirView->scheduleCreateDisplayModelAndRedraw(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseWellCollection::showWellCells() +{ + if (m_showWellCells().isFalse()) + { + return false; + } + else + { + return true; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -212,7 +250,6 @@ RimEclipseWell* RimEclipseWellCollection::findWell(QString name) bool RimEclipseWellCollection::hasVisibleWellCells() { if (!this->isActive()) return false; - if (!this->showWellCells()) return false; if (this->wells().size() == 0 ) return false; bool hasCells = false; @@ -292,12 +329,19 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang } } + if (&m_showWellCells == changedField) + { + for (RimEclipseWell* w : wells) + { + w->showWellCells = !(m_showWellCells().isFalse()); + } + } if (m_reservoirView) { if ( &isActive == changedField || &m_showWellLabel == changedField - || &showWellCells == changedField + || &m_showWellCells == changedField || &showWellCellFence == changedField || &wellCellFenceType == changedField) { @@ -372,7 +416,7 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang m_applySingleColorToWells = false; } - if (&showWellCells == changedField) + if (&m_showWellCells == changedField) { RiuMainWindow::instance()->refreshDrawStyleActions(); } @@ -425,7 +469,7 @@ void RimEclipseWellCollection::defineUiOrdering(QString uiConfigName, caf::PdmUi caf::PdmUiGroup* filterGroup = uiOrdering.addNewGroup("Well Cells"); filterGroup->add(&obsoleteField_wellCellsToRangeFilterMode); - filterGroup->add(&showWellCells); + filterGroup->add(&m_showWellCells); filterGroup->add(&showWellCellFence); filterGroup->add(&wellCellFenceType); @@ -442,6 +486,7 @@ void RimEclipseWellCollection::updateStateForVisibilityCheckboxes() size_t showWellHeadCount = 0; size_t showPipeCount = 0; size_t showSphereCount = 0; + size_t showWellCellsCount = 0; for (RimEclipseWell* w : wells) { @@ -449,12 +494,14 @@ void RimEclipseWellCollection::updateStateForVisibilityCheckboxes() if (w->showWellHead()) showWellHeadCount++; if (w->showWellPipe()) showPipeCount++; if (w->showWellSpheres()) showSphereCount++; + if (w->showWellCells()) showWellCellsCount++; } updateStateFromEnabledChildCount(showLabelCount, &m_showWellLabel); updateStateFromEnabledChildCount(showWellHeadCount, &m_showWellHead); updateStateFromEnabledChildCount(showPipeCount, &m_showWellPipe); updateStateFromEnabledChildCount(showSphereCount, &m_showWellSpheres); + updateStateFromEnabledChildCount(showWellCellsCount, &m_showWellCells); } //-------------------------------------------------------------------------------------------------- @@ -523,21 +570,18 @@ void RimEclipseWellCollection::initAfterRead() if (obsoleteField_wellCellsToRangeFilterMode() == RANGE_ADD_NONE) { - showWellCells = false; + for (RimEclipseWell* w : wells) + { + w->showWell = false; + } } else if (obsoleteField_wellCellsToRangeFilterMode() == RANGE_ADD_ALL) { - showWellCells = true; - for (RimEclipseWell* w : wells) { w->showWellCells = true; } } - else if (obsoleteField_wellCellsToRangeFilterMode() == RANGE_ADD_INDIVIDUAL) - { - showWellCells = true; - } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h index 3a46d4b4fc..fa9d5a05d9 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h @@ -95,7 +95,9 @@ public: caf::PdmField wellLabelColor; caf::PdmField showConnectionStatusColors; - caf::PdmField showWellCells; + void setShowWellCellsState(bool enable); + bool showWellCells(); + caf::PdmField showWellCellFence; caf::PdmField wellCellFenceType; caf::PdmField wellCellTransparencyLevel; @@ -116,6 +118,8 @@ public: const std::vector& resultWellGeometryVisibilities(size_t frameIndex); void scheduleIsWellPipesVisibleRecalculation(); + void updateStateForVisibilityCheckboxes(); + static cvf::Color3f cycledPaletteColor(size_t colorIndex); @@ -130,7 +134,6 @@ protected: private: void calculateWellGeometryVisibility(size_t frameIndex); - void updateStateForVisibilityCheckboxes(); void updateStateFromEnabledChildCount(size_t showLabelCount, caf::PdmField* fieldToUpdate); private: @@ -146,6 +149,7 @@ private: caf::PdmField m_showWellHead; caf::PdmField m_showWellPipe; caf::PdmField m_showWellSpheres; + caf::PdmField m_showWellCells; // Obsolete fields caf::PdmField obsoleteField_wellPipeVisibility; diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index eff8cd68cb..e2f9925e76 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -1384,6 +1384,7 @@ void RiuMainWindow::refreshDrawStyleActions() m_toggleFaultsLabelAction->blockSignals(false); m_showWellCellsAction->blockSignals(true); + eclView->wellCollection()->updateStateForVisibilityCheckboxes(); m_showWellCellsAction->setChecked(eclView->wellCollection()->showWellCells()); m_showWellCellsAction->blockSignals(false); } @@ -1577,7 +1578,7 @@ void RiuMainWindow::slotShowWellCellsAction(bool doAdd) RimEclipseView* riv = dynamic_cast(RiaApplication::instance()->activeReservoirView()); if (riv) { - riv->wellCollection()->showWellCells.setValueWithFieldChanged(doAdd); + riv->wellCollection()->setShowWellCellsState(doAdd); } }