diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index 79edf81b8f..651c5b3dbd 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -399,7 +399,8 @@ void RivReservoirViewPartMgr::createPropertyFilteredNoneWellCellGeometry(size_t std::vector grids; res->allGrids(&grids); - bool hasActiveRangeFilters = m_reservoirView->rangeFilterCollection()->hasActiveIncludeFilters() || m_reservoirView->wellCollection()->hasVisibleWellCells(); + bool hasActiveRangeFilters = m_reservoirView->rangeFilterCollection()->hasActiveFilters(); + bool hasVisibleWellCells = m_reservoirView->wellCollection()->hasVisibleWellCells(); for (size_t gIdx = 0; gIdx < grids.size(); ++gIdx) { @@ -408,11 +409,35 @@ void RivReservoirViewPartMgr::createPropertyFilteredNoneWellCellGeometry(size_t cvf::ref fenceVisibility; cvf::cref isWellCell = res->wellCellsInGrid(gIdx); - if (m_geometriesNeedsRegen[RANGE_FILTERED]) createGeometry(RANGE_FILTERED); - if (m_geometriesNeedsRegen[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER]) createGeometry(VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); + if (hasActiveRangeFilters && hasVisibleWellCells) + { + if (m_geometriesNeedsRegen[RANGE_FILTERED]) createGeometry(RANGE_FILTERED); + if (m_geometriesNeedsRegen[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER]) createGeometry(VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); - rangeVisibility = m_geometries[RANGE_FILTERED].cellVisibility(gIdx); - fenceVisibility = m_geometries[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER].cellVisibility(gIdx); + rangeVisibility = m_geometries[RANGE_FILTERED].cellVisibility(gIdx); + fenceVisibility = m_geometries[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER].cellVisibility(gIdx); + } + else if (hasActiveRangeFilters && !hasVisibleWellCells) + { + if (m_geometriesNeedsRegen[RANGE_FILTERED]) createGeometry(RANGE_FILTERED); + + rangeVisibility = m_geometries[RANGE_FILTERED].cellVisibility(gIdx); + fenceVisibility = m_geometries[RANGE_FILTERED].cellVisibility(gIdx); + } + else if (!hasActiveRangeFilters && hasVisibleWellCells) + { + if (m_geometriesNeedsRegen[VISIBLE_WELL_FENCE_CELLS]) createGeometry(VISIBLE_WELL_FENCE_CELLS); + + rangeVisibility = m_geometries[VISIBLE_WELL_FENCE_CELLS].cellVisibility(gIdx); + fenceVisibility = m_geometries[VISIBLE_WELL_FENCE_CELLS].cellVisibility(gIdx); + } + else if (!hasActiveRangeFilters && !hasVisibleWellCells) + { + if (m_geometriesNeedsRegen[ACTIVE]) createGeometry(ACTIVE); + + rangeVisibility = m_geometries[ACTIVE].cellVisibility(gIdx); + fenceVisibility = m_geometries[ACTIVE].cellVisibility(gIdx); + } cellVisibility->resize(rangeVisibility->size()); @@ -421,6 +446,7 @@ void RivReservoirViewPartMgr::createPropertyFilteredNoneWellCellGeometry(size_t { (*cellVisibility)[cellIdx] = (*rangeVisibility)[cellIdx] || (*fenceVisibility)[cellIdx]; } + computePropertyVisibility(cellVisibility.p(), grids[gIdx], frameIndex, cellVisibility.p(), m_reservoirView->propertyFilterCollection()); m_propFilteredGeometryFrames[frameIndex]->setCellVisibility(gIdx, cellVisibility.p()); @@ -450,29 +476,63 @@ void RivReservoirViewPartMgr::createPropertyFilteredWellGeometry(size_t frameInd std::vector grids; res->allGrids(&grids); - bool hasActiveRangeFilters = m_reservoirView->rangeFilterCollection()->hasActiveFilters() || m_reservoirView->wellCollection()->hasVisibleWellCells(); + bool hasActiveRangeFilters = m_reservoirView->rangeFilterCollection()->hasActiveFilters(); + bool hasVisibleWellCells = m_reservoirView->wellCollection()->hasVisibleWellCells(); for (size_t gIdx = 0; gIdx < grids.size(); ++gIdx) { cvf::ref cellVisibility = m_propFilteredWellGeometryFrames[frameIndex]->cellVisibility(gIdx); cvf::ref rangeVisibility; - cvf::ref wellCellsOutsideVisibility; - cvf::cref cellIsWellCellStatuses = res->wellCellsInGrid(gIdx); + cvf::ref wellCellsOutsideRange; + cvf::ref wellFenceCells; + if (hasActiveRangeFilters && hasVisibleWellCells) + { + if (m_geometriesNeedsRegen[RANGE_FILTERED_WELL_CELLS]) createGeometry(RANGE_FILTERED_WELL_CELLS); + rangeVisibility = m_geometries[RANGE_FILTERED_WELL_CELLS].cellVisibility(gIdx); - if (m_geometriesNeedsRegen[RANGE_FILTERED_WELL_CELLS]) createGeometry(RANGE_FILTERED_WELL_CELLS); - rangeVisibility = m_geometries[RANGE_FILTERED_WELL_CELLS].cellVisibility(gIdx); + if (m_geometriesNeedsRegen[VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER]) createGeometry(VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER); + wellCellsOutsideRange = m_geometries[VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER].cellVisibility(gIdx); - if (m_geometriesNeedsRegen[VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER]) createGeometry(VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER); - wellCellsOutsideVisibility = m_geometries[VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER].cellVisibility(gIdx); + if (m_geometriesNeedsRegen[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER]) createGeometry(VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); + wellFenceCells = m_geometries[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER].cellVisibility(gIdx); + + } + else if (hasActiveRangeFilters && !hasVisibleWellCells) + { + if (m_geometriesNeedsRegen[RANGE_FILTERED_WELL_CELLS]) createGeometry(RANGE_FILTERED_WELL_CELLS); + rangeVisibility = m_geometries[RANGE_FILTERED_WELL_CELLS].cellVisibility(gIdx); + wellCellsOutsideRange = rangeVisibility; + wellFenceCells = rangeVisibility; + } + else if (!hasActiveRangeFilters && hasVisibleWellCells) + { + if (m_geometriesNeedsRegen[VISIBLE_WELL_CELLS]) createGeometry(VISIBLE_WELL_CELLS); + wellCellsOutsideRange = m_geometries[VISIBLE_WELL_CELLS].cellVisibility(gIdx); + + if (m_geometriesNeedsRegen[VISIBLE_WELL_FENCE_CELLS]) createGeometry(VISIBLE_WELL_FENCE_CELLS); + wellFenceCells = m_geometries[VISIBLE_WELL_FENCE_CELLS].cellVisibility(gIdx); + + rangeVisibility = wellCellsOutsideRange; + } + else if (!hasActiveRangeFilters && !hasVisibleWellCells) + { + if (m_geometriesNeedsRegen[ALL_WELL_CELLS]) createGeometry(ALL_WELL_CELLS); + wellFenceCells = m_geometries[ALL_WELL_CELLS].cellVisibility(gIdx); + wellCellsOutsideRange = wellFenceCells; + rangeVisibility = wellFenceCells; + } cellVisibility->resize(rangeVisibility->size()); + #pragma omp parallel for for (int cellIdx = 0; cellIdx < static_cast(cellVisibility->size()); ++cellIdx) { - (*cellVisibility)[cellIdx] = (!hasActiveRangeFilters && (*cellIsWellCellStatuses)[cellIdx]) || (*rangeVisibility)[cellIdx] || (*wellCellsOutsideVisibility)[cellIdx]; + (*cellVisibility)[cellIdx] = (*wellFenceCells)[cellIdx] || (*rangeVisibility)[cellIdx] || (*wellCellsOutsideRange)[cellIdx]; } + computePropertyVisibility(cellVisibility.p(), grids[gIdx], frameIndex, cellVisibility.p(), m_reservoirView->propertyFilterCollection()); + m_propFilteredWellGeometryFrames[frameIndex]->setCellVisibility(gIdx, cellVisibility.p()); } diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index 9bbf759a23..0894bb109c 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -560,8 +560,8 @@ void RimReservoirView::createDisplayModel() if (! this->propertyFilterCollection()->hasActiveFilters()) { std::vector geometryTypesToAdd; - - if (this->rangeFilterCollection()->hasActiveFilters() || this->wellCollection()->hasVisibleWellCells()) + + if (this->rangeFilterCollection()->hasActiveFilters() && this->wellCollection()->hasVisibleWellCells()) { geometryTypesToAdd.push_back(RivReservoirViewPartMgr::RANGE_FILTERED); geometryTypesToAdd.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_WELL_CELLS); @@ -572,6 +572,20 @@ void RimReservoirView::createDisplayModel() geometryTypesToAdd.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); } } + else if (!this->rangeFilterCollection()->hasActiveFilters() && this->wellCollection()->hasVisibleWellCells()) + { + geometryTypesToAdd.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS); + geometryTypesToAdd.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_FENCE_CELLS); + } + else if (this->rangeFilterCollection()->hasActiveFilters() && !this->wellCollection()->hasVisibleWellCells()) + { + geometryTypesToAdd.push_back(RivReservoirViewPartMgr::RANGE_FILTERED); + geometryTypesToAdd.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_WELL_CELLS); + if (this->showInactiveCells()) + { + geometryTypesToAdd.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); + } + } else { geometryTypesToAdd.push_back(RivReservoirViewPartMgr::ALL_WELL_CELLS); // Should be all well cells @@ -657,7 +671,6 @@ void RimReservoirView::createDisplayModel() //-------------------------------------------------------------------------------------------------- void RimReservoirView::updateCurrentTimeStep() { - //printf("########## updateCurrentTimeStep for frame %i ##########\n", m_currentTimeStep.v()); std::vector geometriesToRecolor; if (this->propertyFilterCollection()->hasActiveFilters()) @@ -667,7 +680,6 @@ void RimReservoirView::updateCurrentTimeStep() std::vector gridIndices; this->indicesToVisibleGrids(&gridIndices); - geometriesToRecolor.push_back( RivReservoirViewPartMgr::PROPERTY_FILTERED); m_reservoirGridPartManager->appendDynamicGeometryPartsToModel(frameParts.p(), RivReservoirViewPartMgr::PROPERTY_FILTERED, m_currentTimeStep, gridIndices); @@ -683,8 +695,8 @@ void RimReservoirView::updateCurrentTimeStep() { std::vector gridIndices; this->indicesToVisibleGrids(&gridIndices); - - if (this->rangeFilterCollection()->hasActiveFilters() || this->wellCollection()->hasVisibleWellCells()) + + if (this->rangeFilterCollection()->hasActiveFilters() ) // Wells not considered, because we do not have a INACTIVE_WELL_CELLS group yet. { m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameParts.p(), RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE, gridIndices); } @@ -707,19 +719,28 @@ void RimReservoirView::updateCurrentTimeStep() m_visibleGridParts = geometriesToRecolor; } - else if (rangeFilterCollection->hasActiveFilters() || this->wellCollection()->hasVisibleWellCells()) + else if (this->rangeFilterCollection()->hasActiveFilters() && this->wellCollection()->hasVisibleWellCells()) { geometriesToRecolor.push_back(RivReservoirViewPartMgr::RANGE_FILTERED); geometriesToRecolor.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_WELL_CELLS); geometriesToRecolor.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER); geometriesToRecolor.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); } + else if (!this->rangeFilterCollection()->hasActiveFilters() && this->wellCollection()->hasVisibleWellCells()) + { + geometriesToRecolor.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS); + geometriesToRecolor.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_FENCE_CELLS); + } + else if (this->rangeFilterCollection()->hasActiveFilters() && !this->wellCollection()->hasVisibleWellCells()) + { + geometriesToRecolor.push_back(RivReservoirViewPartMgr::RANGE_FILTERED); + geometriesToRecolor.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_WELL_CELLS); + } else { geometriesToRecolor.push_back(RivReservoirViewPartMgr::ACTIVE); geometriesToRecolor.push_back(RivReservoirViewPartMgr::ALL_WELL_CELLS); } - for (size_t i = 0; i < geometriesToRecolor.size(); ++i) @@ -1392,7 +1413,7 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl for (size_t wIdx = 0; wIdx < this->wellCollection()->wells().size(); ++wIdx) { RimWell* well = this->wellCollection()->wells()[wIdx]; - if (this->wellCollection()->wellCellsToRangeFilterMode() == RimWellCollection::RANGE_ADD_ALL || well->showWellCells()) + if (this->wellCollection()->wellCellsToRangeFilterMode() == RimWellCollection::RANGE_ADD_ALL || (well->showWell() && well->showWellCells()) ) { RigSingleWellResultsData* wres = well->wellResults(); if (!wres) continue; diff --git a/ApplicationCode/ProjectDataModel/RimWell.cpp b/ApplicationCode/ProjectDataModel/RimWell.cpp index 2a30ee7b50..ae2b39d148 100644 --- a/ApplicationCode/ProjectDataModel/RimWell.cpp +++ b/ApplicationCode/ProjectDataModel/RimWell.cpp @@ -43,6 +43,8 @@ RimWell::RimWell() CAF_PDM_InitObject("Well", ":/Well.png", "", ""); CAF_PDM_InitFieldNoDefault(&name, "WellName", "Name", "", "", ""); + CAF_PDM_InitField(&showWell, "ShowWell", true, "Show well ", "", "", ""); + showWell.setUiHidden(true); CAF_PDM_InitField(&showWellLabel, "ShowWellLabel", true, "Show well label", "", "", ""); @@ -96,6 +98,14 @@ void RimWell::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV m_reservoirView->createDisplayModelAndRedraw(); } } + else if (&showWell == changedField) + { + if (m_reservoirView) + { + m_reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS); + m_reservoirView->createDisplayModelAndRedraw(); + } + } else if (&showWellCells == changedField) { if (m_reservoirView) @@ -137,7 +147,7 @@ void RimWell::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimWell::objectToggleField() { - return &showWellPipes; + return &showWell; } //-------------------------------------------------------------------------------------------------- @@ -168,6 +178,9 @@ bool RimWell::calculateWellPipeVisibility(size_t frameIndex) if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::PIPES_FORCE_ALL_OFF) return false; + if ( this->showWell() == false ) + return false; + if ( this->showWellPipes() == false ) return false; diff --git a/ApplicationCode/ProjectDataModel/RimWell.h b/ApplicationCode/ProjectDataModel/RimWell.h index a888fdb6e8..32e724e536 100644 --- a/ApplicationCode/ProjectDataModel/RimWell.h +++ b/ApplicationCode/ProjectDataModel/RimWell.h @@ -55,6 +55,8 @@ public: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); + caf::PdmField showWell; + caf::PdmField name; caf::PdmField showWellLabel; diff --git a/ApplicationCode/ProjectDataModel/RimWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellCollection.cpp index daca4824c0..5d1b2ba712 100644 --- a/ApplicationCode/ProjectDataModel/RimWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellCollection.cpp @@ -149,7 +149,7 @@ bool RimWellCollection::hasVisibleWellCells() for (size_t i = 0 ; !hasCells && i < this->wells().size(); ++i) { RimWell* well = this->wells()[i]; - if ( well && well->wellResults() && (well->showWellCells() || this->wellCellsToRangeFilterMode() == RANGE_ADD_ALL) ) + if ( well && well->wellResults() && ((well->showWell() && well->showWellCells()) || this->wellCellsToRangeFilterMode() == RANGE_ADD_ALL) ) { for (size_t tIdx = 0; !hasCells && tIdx < well->wellResults()->m_wellCellsTimeSteps.size(); ++tIdx ) { @@ -275,6 +275,7 @@ void RimWellCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin wellHeadGroup->add(&showWellHead); wellHeadGroup->add(&wellHeadScaleFactor); wellHeadGroup->add(&showWellLabel); + wellHeadGroup->add(&wellHeadPosition); caf::PdmUiGroup* wellPipe = uiOrdering.addNewGroup("Well pipe"); wellPipe->add(&wellPipeVisibility);