From 17f09878d247645b163cdb3645eb9f918330d289 Mon Sep 17 00:00:00 2001 From: jonjenssen <69144954+jonjenssen@users.noreply.github.com> Date: Mon, 5 Jun 2023 07:33:04 +0200 Subject: [PATCH] Enable filters for curve intersections (#10329) * Enable cell filters * Enable property filters * Clean up fault collection interface and use similar setting for controlling filters as in intersection collection * Enable cell/property filters on geomech intersections * Enable cell and property filters for box intersections --- .../RicShowContributingWellsFeatureImpl.cpp | 2 +- .../Commands/RicNewContourMapViewFeature.cpp | 8 +- .../RivGeoMechVizLogic.cpp | 52 +++++ .../GeoMechVisualization/RivGeoMechVizLogic.h | 3 + .../RivBoxIntersectionGeometryGenerator.cpp | 7 +- .../RivBoxIntersectionGeometryGenerator.h | 4 +- .../RivBoxIntersectionPartMgr.cpp | 14 +- .../Intersections/RivBoxIntersectionPartMgr.h | 3 +- ...udedCurveIntersectionGeometryGenerator.cpp | 9 +- ...trudedCurveIntersectionGeometryGenerator.h | 4 +- .../RivExtrudedCurveIntersectionPartMgr.cpp | 16 +- .../RivExtrudedCurveIntersectionPartMgr.h | 5 +- .../ModelVisualization/RivFaultPartMgr.cpp | 4 +- .../RivReservoirFaultsPartMgr.cpp | 56 +++-- .../Faults/RimFaultInViewCollection.cpp | 219 +++++++++++++----- .../Faults/RimFaultInViewCollection.h | 56 +++-- .../Flow/RimFlowCharacteristicsPlot.cpp | 3 +- .../GeoMech/RimGeoMechView.cpp | 25 +- .../ProjectDataModel/GeoMech/RimGeoMechView.h | 2 + .../Intersections/RimBoxIntersection.cpp | 2 +- .../Intersections/RimBoxIntersection.h | 2 +- .../RimExtrudedCurveIntersection.cpp | 2 +- .../RimExtrudedCurveIntersection.h | 2 +- .../RimIntersectionCollection.cpp | 94 ++++++-- .../Intersections/RimIntersectionCollection.h | 18 +- .../Rim2dIntersectionView.cpp | 1 + .../ProjectDataModel/Rim3dView.cpp | 3 - .../ProjectDataModel/Rim3dView.h | 1 - .../ProjectDataModel/RimEclipseCase.cpp | 4 +- .../RimEclipseContourMapView.cpp | 8 +- .../ProjectDataModel/RimEclipseView.cpp | 94 +++++--- .../ProjectDataModel/RimEclipseView.h | 2 + .../ProjectDataModel/RimGridView.cpp | 64 +++++ .../ProjectDataModel/RimGridView.h | 6 + .../RigVisibleCategoriesCalculator.cpp | 5 +- .../UserInterface/RiuMainWindow.cpp | 2 +- 36 files changed, 562 insertions(+), 240 deletions(-) diff --git a/ApplicationLibCode/Commands/FlowCommands/RicShowContributingWellsFeatureImpl.cpp b/ApplicationLibCode/Commands/FlowCommands/RicShowContributingWellsFeatureImpl.cpp index ae2bfdad6b..7c5cd82049 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicShowContributingWellsFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/FlowCommands/RicShowContributingWellsFeatureImpl.cpp @@ -158,7 +158,7 @@ void RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells( Rim Riu3DMainWindowTools::setExpanded( propertyFilterCollection ); - viewToModify->faultCollection()->showFaultCollection = false; + viewToModify->faultCollection()->setActive( false ); viewToModify->faultCollection()->updateConnectedEditors(); viewToModify->updateDisplayModelForCurrentTimeStepAndRedraw(); diff --git a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp index 3d80091fa0..c17ed261a4 100644 --- a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp @@ -242,8 +242,8 @@ RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMapFr contourMap->setBackgroundColor( RiaColorTools::fromQColorTo3f( col ) ); // Ignore original view background contourMap->setDefaultCustomName(); - contourMap->faultCollection()->showFaultCollection = false; - contourMap->wellCollection()->isActive = false; + contourMap->faultCollection()->setActive( false ); + contourMap->wellCollection()->isActive = false; // Set default values RimRegularLegendConfig* legendConfig = contourMap->cellResult()->legendConfig(); @@ -297,8 +297,8 @@ RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMap( contourMap->contourMapProjection()->setSampleSpacingFactor( 1.2 ); } - contourMap->faultCollection()->showFaultCollection = false; - contourMap->wellCollection()->isActive = false; + contourMap->faultCollection()->setActive( false ); + contourMap->wellCollection()->isActive = false; eclipseCase->contourMapCollection()->push_back( contourMap ); diff --git a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp index 08e642d7ce..612eb4d902 100644 --- a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp @@ -334,3 +334,55 @@ void RivGeoMechVizLogic::resetPartMgrs() { m_partMgrCache = new RivGeoMechPartMgrCache; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivGeoMechVizLogic::calculateCellVisibility( cvf::UByteArray* totalVisibility, std::vector geomTypes, int viewerStepIndex ) +{ + if ( !m_geomechView->geoMechCase() ) return; + + int partCount = m_geomechView->femParts()->partCount(); + if ( partCount == 0 ) return; + + int elmCount = 0; + for ( int i = 0; i < partCount; i++ ) + { + RigFemPart* part = m_geomechView->femParts()->part( i ); + elmCount += part->elementCount(); + } + totalVisibility->resize( elmCount ); + totalVisibility->setAll( false ); + + std::vector partMgrs; + + for ( auto geomType : geomTypes ) + { + // skip types not support in geomech + if ( geomType == PROPERTY_FILTERED_WELL_CELLS ) continue; + if ( geomType == RANGE_FILTERED_WELL_CELLS ) continue; + + partMgrs.push_back( RivGeoMechPartMgrCache::Key( geomType, viewerStepIndex ) ); + } + + for ( size_t pmIdx = 0; pmIdx < partMgrs.size(); ++pmIdx ) + { + RivGeoMechPartMgr* partMgr = getUpdatedPartMgr( partMgrs[pmIdx] ); + CVF_ASSERT( partMgr ); + if ( partMgr ) + { + int elmOffset = 0; + for ( int i = 0; i < partCount; i++ ) + { + RigFemPart* part = m_geomechView->femParts()->part( i ); + + cvf::ref visibility = partMgr->cellVisibility( i ); + for ( int elmIdx = 0; elmIdx < part->elementCount(); ++elmIdx ) + { + ( *totalVisibility )[elmOffset + elmIdx] |= ( *visibility )[elmIdx]; + } + elmOffset += part->elementCount(); + } + } + } +} diff --git a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.h b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.h index 8bc80aeb2c..26d99713f2 100644 --- a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.h +++ b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.h @@ -48,7 +48,10 @@ public: void updateStaticCellColors( int viewerStepIndex ); void scheduleGeometryRegen( RivCellSetEnum geometryType ); void scheduleGeometryRegenOfVisiblePartMgrs( int viewerStepIndex ); + void calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int viewerStepIndex ); + void calculateCellVisibility( cvf::UByteArray* totalVisibility, std::vector geomTypes, int viewerStepIndex ); + void resetPartMgrs(); std::vector keysToVisiblePartMgrs( int viewerStepIndex ) const; diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.cpp index caaaf5a229..a4c7dfec03 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.cpp @@ -70,9 +70,9 @@ bool RivBoxIntersectionGeometryGenerator::isAnyGeometryPresent() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RivBoxIntersectionGeometryGenerator::generateSurface() +cvf::ref RivBoxIntersectionGeometryGenerator::generateSurface( cvf::UByteArray* visibleCells ) { - calculateArrays(); + calculateArrays( visibleCells ); CVF_ASSERT( m_triangleVxes.notNull() ); @@ -244,7 +244,7 @@ RimBoxIntersection* RivBoxIntersectionGeometryGenerator::intersectionBox() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivBoxIntersectionGeometryGenerator::calculateArrays() +void RivBoxIntersectionGeometryGenerator::calculateArrays( cvf::UByteArray* visibleCells ) { if ( m_triangleVxes->size() ) return; @@ -310,6 +310,7 @@ void RivBoxIntersectionGeometryGenerator::calculateArrays() { size_t globalCellIdx = columnCellCandidates[cccIdx]; + if ( ( visibleCells != nullptr ) && ( ( *visibleCells )[globalCellIdx] == 0 ) ) continue; if ( !m_hexGrid->useCell( globalCellIdx ) ) continue; hexPlaneCutTriangleVxes.clear(); diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.h b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.h index 1caa9dba43..08f41e146b 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.h @@ -46,7 +46,7 @@ public: ~RivBoxIntersectionGeometryGenerator() override; // Generate geometry - cvf::ref generateSurface(); + cvf::ref generateSurface( cvf::UByteArray* visibleCells ); cvf::ref createMeshDrawable(); RimBoxIntersection* intersectionBox() const; @@ -60,7 +60,7 @@ public: const cvf::Vec3fArray* triangleVxes() const override; private: - void calculateArrays(); + void calculateArrays( cvf::UByteArray* visibleCells ); cvf::cref m_hexGrid; diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp index 25a5ec02fa..46e7ca17ca 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp @@ -96,12 +96,12 @@ void RivBoxIntersectionPartMgr::updateCellResultColor( int timeStepIndex ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivBoxIntersectionPartMgr::generatePartGeometry() +void RivBoxIntersectionPartMgr::generatePartGeometry( cvf::UByteArray* visibleCells ) { bool useBufferObjects = true; // Surface geometry { - cvf::ref geo = m_intersectionBoxGenerator->generateSurface(); + cvf::ref geo = m_intersectionBoxGenerator->generateSurface( visibleCells ); if ( geo.notNull() ) { geo->computeNormals(); @@ -187,11 +187,6 @@ void RivBoxIntersectionPartMgr::updatePartEffect() //-------------------------------------------------------------------------------------------------- void RivBoxIntersectionPartMgr::appendNativeIntersectionFacesToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ) { - if ( m_intersectionBoxFaces.isNull() && m_intersectionBoxGridLines.isNull() ) - { - generatePartGeometry(); - } - if ( m_intersectionBoxFaces.notNull() ) { m_intersectionBoxFaces->setTransform( scaleTransform ); @@ -204,11 +199,6 @@ void RivBoxIntersectionPartMgr::appendNativeIntersectionFacesToModel( cvf::Model //-------------------------------------------------------------------------------------------------- void RivBoxIntersectionPartMgr::appendMeshLinePartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ) { - if ( m_intersectionBoxFaces.isNull() && m_intersectionBoxGridLines.isNull() ) - { - generatePartGeometry(); - } - if ( m_intersectionBoxGridLines.notNull() ) { m_intersectionBoxGridLines->setTransform( scaleTransform ); diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.h b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.h index 90f94c9ea1..05b8fc841c 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.h @@ -63,9 +63,10 @@ public: const RivIntersectionGeometryGeneratorInterface* intersectionGeometryGenerator() const; + void generatePartGeometry( cvf::UByteArray* visibleCells ); + private: void updatePartEffect(); - void generatePartGeometry(); private: RimBoxIntersection* m_rimIntersectionBox; diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp index 70883913f5..5ef707e4c9 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp @@ -265,7 +265,7 @@ private: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays() +void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays( cvf::UByteArray* visibleCells ) { if ( m_triangleVxes->size() ) return; @@ -386,6 +386,7 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays() for ( auto globalCellIdx : columnCellCandidates ) { + if ( ( visibleCells != nullptr ) && ( ( *visibleCells )[globalCellIdx] == 0 ) ) continue; if ( !m_hexGrid->useCell( globalCellIdx ) ) continue; hexPlaneCutTriangleVxes.clear(); @@ -618,9 +619,9 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays() /// Generate surface drawable geo from the specified region /// //-------------------------------------------------------------------------------------------------- -cvf::ref RivExtrudedCurveIntersectionGeometryGenerator::generateSurface() +cvf::ref RivExtrudedCurveIntersectionGeometryGenerator::generateSurface( cvf::UByteArray* visibleCells ) { - calculateArrays(); + calculateArrays( visibleCells ); CVF_ASSERT( m_triangleVxes.notNull() ); @@ -781,7 +782,7 @@ const cvf::Vec3fArray* RivExtrudedCurveIntersectionGeometryGenerator::faultMeshV //-------------------------------------------------------------------------------------------------- void RivExtrudedCurveIntersectionGeometryGenerator::ensureGeometryIsCalculated() { - calculateArrays(); + calculateArrays( nullptr ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.h b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.h index d65025d35b..ba381e45b0 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.h @@ -60,7 +60,7 @@ public: ~RivExtrudedCurveIntersectionGeometryGenerator() override; // Generate geometry - cvf::ref generateSurface(); + cvf::ref generateSurface( cvf::UByteArray* visibleCells ); cvf::ref createMeshDrawable(); cvf::ref createFaultMeshDrawable(); @@ -87,7 +87,7 @@ public: void ensureGeometryIsCalculated(); private: - void calculateArrays(); + void calculateArrays( cvf::UByteArray* visibleCells ); void calculateLineSegementTransforms(); void calculateTransformedPolyline(); void calculateSurfaceIntersectionPoints(); diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp index b65fe64b2a..555352e941 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp @@ -231,7 +231,7 @@ void RivIntersectionResultsColoringTools::calculateNodeOrElementNodeBasedGeoMech //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivExtrudedCurveIntersectionPartMgr::generatePartGeometry() +void RivExtrudedCurveIntersectionPartMgr::generatePartGeometry( cvf::UByteArray* visibleCells ) { if ( m_intersectionGenerator.isNull() ) return; @@ -242,7 +242,7 @@ void RivExtrudedCurveIntersectionPartMgr::generatePartGeometry() bool useBufferObjects = true; // Surface geometry { - cvf::ref geo = m_intersectionGenerator->generateSurface(); + cvf::ref geo = m_intersectionGenerator->generateSurface( visibleCells ); if ( geo.notNull() ) { geo->computeNormals(); @@ -772,11 +772,6 @@ cvf::ref RivExtrudedCurveIntersectionPartMgr::createCurvePart( const //-------------------------------------------------------------------------------------------------- void RivExtrudedCurveIntersectionPartMgr::appendIntersectionFacesToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ) { - if ( m_intersectionFaces.isNull() ) - { - generatePartGeometry(); - } - if ( m_intersectionFaces.notNull() ) { m_intersectionFaces->setTransform( scaleTransform ); @@ -789,11 +784,6 @@ void RivExtrudedCurveIntersectionPartMgr::appendIntersectionFacesToModel( cvf::M //-------------------------------------------------------------------------------------------------- void RivExtrudedCurveIntersectionPartMgr::appendMeshLinePartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ) { - if ( m_intersectionGridLines.isNull() ) - { - generatePartGeometry(); - } - if ( m_intersectionGridLines.notNull() ) { m_intersectionGridLines->setTransform( scaleTransform ); @@ -873,7 +863,7 @@ void RivExtrudedCurveIntersectionPartMgr::appendPolylinePartsToModel( Rim3dView& for ( size_t i = 0; i < m_annotationParts.size(); i++ ) { - auto part = m_annotationParts[i]; + auto& part = m_annotationParts[i]; if ( part.notNull() ) { part->setTransform( scaleTransform ); diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h index f5d00599f8..a5f626a365 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h @@ -20,13 +20,13 @@ #pragma once #include "cvfArray.h" +#include "cvfCollection.h" #include "cvfColor4.h" #include "cvfMatrix4.h" #include "cvfObject.h" #include "cvfVector3.h" #include "cafPdmPointer.h" -#include "cvfCollection.h" #include @@ -81,8 +81,9 @@ public: const RivIntersectionGeometryGeneratorInterface* intersectionGeometryGenerator() const; + void generatePartGeometry( cvf::UByteArray* visibleCells ); + private: - void generatePartGeometry(); void createFaultLabelParts( const std::vector>& labelAndAnchors ); void createPolyLineParts( bool useBufferObjects ); void createExtrusionDirParts( bool useBufferObjects ); diff --git a/ApplicationLibCode/ModelVisualization/RivFaultPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivFaultPartMgr.cpp index 370dc568dc..6f54527f4d 100644 --- a/ApplicationLibCode/ModelVisualization/RivFaultPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivFaultPartMgr.cpp @@ -859,7 +859,7 @@ void RivFaultPartMgr::updateNNCColors( size_t timeStepIndex, RimEclipseCellColor cvf::ref nncEffect; - if ( m_rimFaultCollection->showFaultFaces || m_rimFaultCollection->showOppositeFaultFaces ) + if ( m_rimFaultCollection->showFaultFaces() || m_rimFaultCollection->showOppositeFaultFaces() ) { // Move NNC closer to camera to avoid z-fighting with grid surface caf::ScalarMapperEffectGenerator nncEffgen( mapper, caf::PO_NEG_LARGE ); @@ -901,7 +901,7 @@ void RivFaultPartMgr::updateNNCColors( size_t timeStepIndex, RimEclipseCellColor CVF_ASSERT( nncColor.isValid() ); cvf::ref nncEffect; - if ( m_rimFaultCollection->showFaultFaces || m_rimFaultCollection->showOppositeFaultFaces ) + if ( m_rimFaultCollection->showFaultFaces() || m_rimFaultCollection->showOppositeFaultFaces() ) { // Move NNC closer to camera to avoid z-fighting with grid surface caf::SurfaceEffectGenerator nncEffgen( nncColor, caf::PO_NEG_LARGE ); diff --git a/ApplicationLibCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp index 7cee3adaa9..cd8570da7c 100644 --- a/ApplicationLibCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp @@ -54,9 +54,9 @@ RivReservoirFaultsPartMgr::RivReservoirFaultsPartMgr( const RigMainGrid* grid, R RimFaultInViewCollection* faultCollection = reservoirView->faultCollection(); if ( faultCollection ) { - for ( size_t i = 0; i < faultCollection->faults.size(); i++ ) + for ( auto fault : faultCollection->faults() ) { - m_faultParts.push_back( new RivFaultPartMgr( grid, faultCollection, faultCollection->faults[i] ) ); + m_faultParts.push_back( new RivFaultPartMgr( grid, faultCollection, fault ) ); } } } @@ -86,9 +86,9 @@ void RivReservoirFaultsPartMgr::setCellVisibility( cvf::UByteArray* cellVisibili { CVF_ASSERT( cellVisibilities ); - for ( size_t i = 0; i < m_faultParts.size(); i++ ) + for ( auto& faultPart : m_faultParts ) { - m_faultParts.at( i )->setCellVisibility( cellVisibilities ); + faultPart->setCellVisibility( cellVisibilities ); } } @@ -103,14 +103,14 @@ void RivReservoirFaultsPartMgr::appendPartsToModel( cvf::ModelBasicList* model ) if ( !faultCollection ) return; bool isShowingGrid = m_reservoirView->isMainGridVisible(); - if ( !faultCollection->showFaultCollection() && !isShowingGrid ) return; + if ( !faultCollection->isActive() && !isShowingGrid ) return; // Check match between model fault count and fault parts - CVF_ASSERT( faultCollection->faults.size() == m_faultParts.size() ); + CVF_ASSERT( faultCollection->faults().size() == m_faultParts.size() ); // Parts that is overridden by the grid settings bool forceDisplayOfFault = false; - if ( !faultCollection->isShowingFaultsAndFaultsOutsideFilters() ) + if ( faultCollection->shouldApplyCellFiltersToFaults() ) { forceDisplayOfFault = isShowingGrid; } @@ -122,14 +122,13 @@ void RivReservoirFaultsPartMgr::appendPartsToModel( cvf::ModelBasicList* model ) cvf::ModelBasicList parts; - for ( size_t i = 0; i < faultCollection->faults.size(); i++ ) + int i = 0; + for ( const auto rimFault : faultCollection->faults() ) { - const RimFaultInView* rimFault = faultCollection->faults[i]; - - cvf::ref rivFaultPart = m_faultParts[i]; + cvf::ref rivFaultPart = m_faultParts[i++]; CVF_ASSERT( rivFaultPart.notNull() ); - if ( ( faultCollection->showFaultCollection() && rimFault->showFault() ) || forceDisplayOfFault ) + if ( ( faultCollection->isActive() && rimFault->showFault() ) || forceDisplayOfFault ) { if ( faultCollection->showFaultFaces() || forceDisplayOfFault ) { @@ -152,7 +151,7 @@ void RivReservoirFaultsPartMgr::appendPartsToModel( cvf::ModelBasicList* model ) RimEclipseFaultColors* faultResultColors = m_reservoirView->faultResultSettings(); RimEclipseCellColors* cellResultColors = m_reservoirView->cellResult(); - if ( rimFault->showFault() && faultCollection->showFaultCollection() ) + if ( rimFault->showFault() && faultCollection->isActive() ) { if ( faultCollection->showNNCs() ) { @@ -190,7 +189,7 @@ void RivReservoirFaultsPartMgr::appendPartsToModel( cvf::ModelBasicList* model ) } } - if ( faultCollection->hideNncsWhenNoResultIsAvailable() ) + if ( faultCollection->hideNNCsWhenNoResultIsAvailable() ) { RigMainGrid* mainGrid = m_reservoirView->mainGrid(); if ( !( mainGrid && mainGrid->nncData()->hasScalarValues( eclipseResultAddress ) ) ) @@ -231,9 +230,9 @@ void RivReservoirFaultsPartMgr::appendPartsToModel( cvf::ModelBasicList* model ) //-------------------------------------------------------------------------------------------------- void RivReservoirFaultsPartMgr::applySingleColorEffect() { - for ( size_t i = 0; i < m_faultParts.size(); i++ ) + for ( auto& faultPart : m_faultParts ) { - m_faultParts[i]->applySingleColorEffect(); + faultPart->applySingleColorEffect(); } } @@ -247,15 +246,15 @@ void RivReservoirFaultsPartMgr::updateColors( size_t timeStepIndex, RimEclipseCe RimFaultInViewCollection* faultCollection = m_reservoirView->faultCollection(); CVF_ASSERT( faultCollection ); - for ( size_t i = 0; i < faultCollection->faults.size(); i++ ) + for ( auto& faultPart : m_faultParts ) { if ( cellResultColors && ( cellResultColors->hasResult() || cellResultColors->isTernarySaturationSelected() ) ) { - m_faultParts[i]->updateCellResultColor( timeStepIndex, cellResultColors ); + faultPart->updateCellResultColor( timeStepIndex, cellResultColors ); } else { - m_faultParts[i]->applySingleColorEffect(); + faultPart->applySingleColorEffect(); } } } @@ -267,9 +266,9 @@ void RivReservoirFaultsPartMgr::updateCellEdgeResultColor( size_t RimEclipseCellColors* cellResultColors, RimCellEdgeColors* cellEdgeResultColors ) { - for ( size_t i = 0; i < m_faultParts.size(); i++ ) + for ( auto& faultPart : m_faultParts ) { - m_faultParts[i]->updateCellEdgeResultColor( timeStepIndex, cellResultColors, cellEdgeResultColors ); + faultPart->updateCellEdgeResultColor( timeStepIndex, cellResultColors, cellEdgeResultColors ); } } @@ -284,20 +283,19 @@ void RivReservoirFaultsPartMgr::appendLabelPartsToModel( cvf::ModelBasicList* mo RimFaultInViewCollection* faultCollection = m_reservoirView->faultCollection(); CVF_ASSERT( faultCollection ); - if ( !faultCollection->showFaultCollection() ) return; + if ( !faultCollection->isActive() ) return; if ( !faultCollection->showFaultLabel() ) return; // Check match between model fault count and fault parts - CVF_ASSERT( faultCollection->faults.size() == m_faultParts.size() ); + CVF_ASSERT( faultCollection->faults().size() == m_faultParts.size() ); cvf::ModelBasicList parts; - for ( size_t i = 0; i < faultCollection->faults.size(); i++ ) + int i = 0; + for ( const auto rimFault : faultCollection->faults() ) { - const RimFaultInView* rimFault = faultCollection->faults[i]; - - cvf::ref rivFaultPart = m_faultParts[i]; + cvf::ref rivFaultPart = m_faultParts[i++]; CVF_ASSERT( rivFaultPart.notNull() ); if ( rimFault->showFault() ) @@ -336,8 +334,8 @@ void RivReservoirFaultsPartMgr::clearWatertightGeometryFlag() //-------------------------------------------------------------------------------------------------- void RivReservoirFaultsPartMgr::setOpacityLevel( float opacity ) { - for ( size_t i = 0; i < m_faultParts.size(); i++ ) + for ( auto& faultPart : m_faultParts ) { - m_faultParts[i]->setOpacityLevel( opacity ); + faultPart->setOpacityLevel( opacity ); } } diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp index 165a876bad..644a6d7aa7 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp @@ -62,40 +62,42 @@ RimFaultInViewCollection::RimFaultInViewCollection() { CAF_PDM_InitObject( "Faults", ":/draw_style_faults_24x24.png" ); - CAF_PDM_InitField( &showFaultCollection, "Active", true, "Active" ); - showFaultCollection.uiCapability()->setUiHidden( true ); + CAF_PDM_InitField( &m_showFaultCollection, "Active", true, "Active" ); + m_showFaultCollection.uiCapability()->setUiHidden( true ); - CAF_PDM_InitField( &showFaultFaces, "ShowFaultFaces", true, "Show Defined faces" ); - caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &showFaultFaces ); + CAF_PDM_InitField( &m_showFaultFaces, "ShowFaultFaces", true, "Show Defined faces" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showFaultFaces ); - CAF_PDM_InitField( &showOppositeFaultFaces, "ShowOppositeFaultFaces", true, "Show Opposite Faces" ); - caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &showOppositeFaultFaces ); + CAF_PDM_InitField( &m_showOppositeFaultFaces, "ShowOppositeFaultFaces", true, "Show Opposite Faces" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showOppositeFaultFaces ); - CAF_PDM_InitField( &m_showFaultsOutsideFilters, "ShowFaultsOutsideFilters", true, "Show Faults Outside Filters" ); - caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showFaultsOutsideFilters ); + CAF_PDM_InitField( &m_applyCellFilters, "ApplyCellFilters", true, "Use Cell Filters for Faults" ); CAF_PDM_InitField( &m_onlyShowWithNeighbor, "OnlyShowWithDefNeighbor", false, "Show Only Faces with Juxtaposition" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_onlyShowWithNeighbor ); - CAF_PDM_InitField( &faultResult, + CAF_PDM_InitField( &m_faultResult, "FaultFaceCulling", caf::AppEnum( RimFaultInViewCollection::FAULT_BACK_FACE_CULLING ), "Dynamic Face Selection" ); - CAF_PDM_InitField( &showFaultLabel, "ShowFaultLabel", false, "Show Labels" ); - caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &showFaultLabel ); + CAF_PDM_InitField( &m_showFaultLabel, "ShowFaultLabel", false, "Show Labels" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showFaultLabel ); cvf::Color3f defWellLabelColor = RiaPreferences::current()->defaultWellLabelColor(); - CAF_PDM_InitField( &faultLabelColor, "FaultLabelColor", defWellLabelColor, "Label Color" ); + CAF_PDM_InitField( &m_faultLabelColor, "FaultLabelColor", defWellLabelColor, "Label Color" ); - CAF_PDM_InitField( &showNNCs, "ShowNNCs", true, "Show NNCs" ); - caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &showNNCs ); + CAF_PDM_InitField( &m_showNNCs, "ShowNNCs", true, "Show NNCs" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_showNNCs ); - CAF_PDM_InitField( &hideNncsWhenNoResultIsAvailable, "HideNncsWhenNoResultIsAvailable", true, "Hide NNC Geometry if No NNC Result is Available" ); - caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &hideNncsWhenNoResultIsAvailable ); + CAF_PDM_InitField( &m_hideNNCsWhenNoResultIsAvailable, + "HideNncsWhenNoResultIsAvailable", + true, + "Hide NNC Geometry if No NNC Result is Available" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_hideNNCsWhenNoResultIsAvailable ); - CAF_PDM_InitFieldNoDefault( &faults, "Faults", "Faults" ); - faults.uiCapability()->setUiTreeHidden( true ); + CAF_PDM_InitFieldNoDefault( &m_faults, "Faults", "Faults" ); + m_faults.uiCapability()->setUiTreeHidden( true ); } //-------------------------------------------------------------------------------------------------- @@ -103,7 +105,79 @@ RimFaultInViewCollection::RimFaultInViewCollection() //-------------------------------------------------------------------------------------------------- RimFaultInViewCollection::~RimFaultInViewCollection() { - faults.deleteChildren(); + m_faults.deleteChildren(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimFaultInViewCollection::isActive() const +{ + return m_showFaultCollection; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultInViewCollection::setActive( bool bActive ) +{ + m_showFaultCollection = bActive; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RimFaultInViewCollection::faultLabelColor() const +{ + return m_faultLabelColor(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::AppEnum RimFaultInViewCollection::faultResult() const +{ + return m_faultResult(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimFaultInViewCollection::showFaultFaces() const +{ + return m_showFaultFaces(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimFaultInViewCollection::showFaultLabel() const +{ + return m_showFaultLabel(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimFaultInViewCollection::showOppositeFaultFaces() const +{ + return m_showOppositeFaultFaces(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimFaultInViewCollection::showNNCs() const +{ + return m_showOppositeFaultFaces(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimFaultInViewCollection::hideNNCsWhenNoResultIsAvailable() const +{ + return m_hideNNCsWhenNoResultIsAvailable(); } //-------------------------------------------------------------------------------------------------- @@ -113,7 +187,7 @@ void RimFaultInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* chan { this->updateUiIconFromToggleField(); - if ( &faultLabelColor == changedField ) + if ( &m_faultLabelColor == changedField ) { parentView()->scheduleReservoirGridGeometryRegen(); parentView()->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); @@ -124,16 +198,16 @@ void RimFaultInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* chan parentView()->scheduleReservoirGridGeometryRegen(); } - if ( &showFaultFaces == changedField || &showOppositeFaultFaces == changedField || &showFaultCollection == changedField || - &showFaultLabel == changedField || &m_showFaultsOutsideFilters == changedField || &faultLabelColor == changedField || - &m_onlyShowWithNeighbor == changedField || &faultResult == changedField || &showNNCs == changedField || - &hideNncsWhenNoResultIsAvailable == changedField ) + if ( &m_showFaultFaces == changedField || &m_showOppositeFaultFaces == changedField || &m_showFaultCollection == changedField || + &m_showFaultLabel == changedField || &m_applyCellFilters == changedField || &m_faultLabelColor == changedField || + &m_onlyShowWithNeighbor == changedField || &m_faultResult == changedField || &m_showNNCs == changedField || + &m_hideNNCsWhenNoResultIsAvailable == changedField ) { parentView()->scheduleCreateDisplayModelAndRedraw(); parentView()->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } - if ( &showFaultLabel == changedField ) + if ( &m_showFaultLabel == changedField ) { RiuMainWindow::instance()->refreshDrawStyleActions(); } @@ -144,7 +218,7 @@ void RimFaultInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* chan //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimFaultInViewCollection::objectToggleField() { - return &showFaultCollection; + return &m_showFaultCollection; } //-------------------------------------------------------------------------------------------------- @@ -152,12 +226,9 @@ caf::PdmFieldHandle* RimFaultInViewCollection::objectToggleField() //-------------------------------------------------------------------------------------------------- RimFaultInView* RimFaultInViewCollection::findFaultByName( QString name ) { - for ( size_t i = 0; i < this->faults().size(); ++i ) + for ( auto& fault : m_faults ) { - if ( this->faults()[i]->name() == name ) - { - return this->faults()[i]; - } + if ( fault->name() == name ) return fault; } return nullptr; } @@ -250,8 +321,8 @@ void RimFaultInViewCollection::syncronizeFaults() newFaults.push_back( rimFault ); } - this->faults().clearWithoutDelete(); - this->faults().insert( 0, newFaults ); + m_faults().clearWithoutDelete(); + m_faults().insert( 0, newFaults ); QString toolTip = QString( "Fault count (%1)" ).arg( newFaults.size() ); setUiToolTip( toolTip ); @@ -272,21 +343,21 @@ void RimFaultInViewCollection::uiOrderingFaults( QString uiConfigName, caf::PdmU { bool isGridVizMode = isGridVisualizationMode(); - faultResult.uiCapability()->setUiReadOnly( isGridVizMode ); - showFaultFaces.uiCapability()->setUiReadOnly( isGridVizMode ); - showOppositeFaultFaces.uiCapability()->setUiReadOnly( isGridVizMode ); + m_faultResult.uiCapability()->setUiReadOnly( isGridVizMode ); + m_showFaultFaces.uiCapability()->setUiReadOnly( isGridVizMode ); + m_showOppositeFaultFaces.uiCapability()->setUiReadOnly( isGridVizMode ); caf::PdmUiGroup* ffviz = uiOrdering.addNewGroup( "Fault Face Visibility" ); ffviz->setCollapsedByDefault(); - ffviz->add( &showFaultFaces ); - ffviz->add( &showOppositeFaultFaces ); - ffviz->add( &faultResult ); + ffviz->add( &m_showFaultFaces ); + ffviz->add( &m_showOppositeFaultFaces ); + ffviz->add( &m_faultResult ); ffviz->add( &m_onlyShowWithNeighbor ); caf::PdmUiGroup* nncViz = uiOrdering.addNewGroup( "NNC Visibility" ); nncViz->setCollapsedByDefault(); - nncViz->add( &showNNCs ); - nncViz->add( &hideNncsWhenNoResultIsAvailable ); + nncViz->add( &m_showNNCs ); + nncViz->add( &m_hideNNCsWhenNoResultIsAvailable ); } //-------------------------------------------------------------------------------------------------- @@ -294,12 +365,12 @@ void RimFaultInViewCollection::uiOrderingFaults( QString uiConfigName, caf::PdmU //-------------------------------------------------------------------------------------------------- void RimFaultInViewCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { - caf::PdmUiGroup* labs = uiOrdering.addNewGroup( "Fault Labels" ); - labs->add( &showFaultLabel ); - labs->add( &faultLabelColor ); + caf::PdmUiGroup* general = uiOrdering.addNewGroup( "General" ); + general->add( &m_applyCellFilters ); - caf::PdmUiGroup* adv = uiOrdering.addNewGroup( "Fault Options" ); - adv->add( &m_showFaultsOutsideFilters ); + caf::PdmUiGroup* labs = uiOrdering.addNewGroup( "Fault Labels" ); + labs->add( &m_showFaultLabel ); + labs->add( &m_faultLabelColor ); uiOrderingFaults( uiConfigName, uiOrdering ); } @@ -316,7 +387,7 @@ void RimFaultInViewCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiT uiTreeOrdering.appendChild( uiTree ); } - for ( const auto& fault : faults ) + for ( const auto& fault : m_faults ) { uiTreeOrdering.add( fault ); } @@ -335,19 +406,11 @@ RimEclipseView* RimFaultInViewCollection::parentView() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimFaultInViewCollection::isShowingFaultsAndFaultsOutsideFilters() const +bool RimFaultInViewCollection::shouldApplyCellFiltersToFaults() const { - if ( !showFaultCollection ) return false; + if ( !m_showFaultCollection() ) return false; - return m_showFaultsOutsideFilters; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimFaultInViewCollection::setShowFaultsOutsideFilter( bool show ) -{ - m_showFaultsOutsideFilters = show; + return m_applyCellFilters; } //-------------------------------------------------------------------------------------------------- @@ -357,3 +420,43 @@ bool RimFaultInViewCollection::onlyShowFacesWithDefinedNeighbor() const { return m_onlyShowWithNeighbor; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimFaultInViewCollection::faults() const +{ + return m_faults.childrenByType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultInViewCollection::setFaultResult( caf::AppEnum resultType ) +{ + m_faultResult = resultType; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultInViewCollection::setShouldApplyCellFiltersToFaults( bool bEnabled ) +{ + m_applyCellFilters = bEnabled; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultInViewCollection::setShowOppositeFaultFaces( bool bEnabled ) +{ + m_showOppositeFaultFaces = bEnabled; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultInViewCollection::setShowFaultLabelWithFieldChanged( bool bEnabled ) +{ + m_showFaultLabel.setValueWithFieldChanged( bEnabled ); +} diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h index 3871060993..ab840a7da0 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h @@ -31,6 +31,8 @@ #include +#include + class RimEclipseView; class RimFaultInView; @@ -54,29 +56,30 @@ public: RimFaultInViewCollection(); ~RimFaultInViewCollection() override; + bool isActive() const; + void setActive( bool bActive ); + + std::vector faults() const; + cvf::Color3f faultLabelColor() const; + caf::AppEnum faultResult() const; + bool showFaultFaces() const; + bool showFaultLabel() const; + bool showOppositeFaultFaces() const; + bool showNNCs() const; + bool hideNNCsWhenNoResultIsAvailable() const; + + void setFaultResult( caf::AppEnum resultType ); + void setShouldApplyCellFiltersToFaults( bool bEnabled ); + void setShowOppositeFaultFaces( bool bEnabled ); + void setShowFaultLabelWithFieldChanged( bool bEnabled ); + void syncronizeFaults(); bool isGridVisualizationMode() const; - - bool isShowingFaultsAndFaultsOutsideFilters() const; - void setShowFaultsOutsideFilter( bool show ); - + bool shouldApplyCellFiltersToFaults() const; bool onlyShowFacesWithDefinedNeighbor() const; - caf::PdmField showFaultFaces; - caf::PdmField showOppositeFaultFaces; - - caf::PdmField> faultResult; - - caf::PdmField showFaultLabel; - caf::PdmField faultLabelColor; - - caf::PdmField showFaultCollection; - caf::PdmField showNNCs; - caf::PdmField hideNncsWhenNoResultIsAvailable; - - caf::PdmChildArrayField faults; - RimFaultInView* findFaultByName( QString name ); + RimFaultInView* findFaultByName( QString name ); void uiOrderingFaults( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); @@ -90,6 +93,19 @@ private: RimEclipseView* parentView() const; private: - caf::PdmField m_showFaultsOutsideFilters; - caf::PdmField m_onlyShowWithNeighbor; + caf::PdmField m_showFaultsOutsideFilters_obsolete; + + caf::PdmField m_applyCellFilters; + caf::PdmField m_onlyShowWithNeighbor; + caf::PdmField m_showFaultFaces; + caf::PdmField m_showOppositeFaultFaces; + caf::PdmField m_showFaultLabel; + caf::PdmField m_faultLabelColor; + caf::PdmField m_showFaultCollection; + caf::PdmField m_showNNCs; + caf::PdmField m_hideNNCsWhenNoResultIsAvailable; + + caf::PdmField> m_faultResult; + + caf::PdmChildArrayField m_faults; }; diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp index 540ff6c7f6..5a5937511d 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimFlowCharacteristicsPlot.cpp @@ -537,7 +537,7 @@ void RimFlowCharacteristicsPlot::fieldChangedByUi( const caf::PdmFieldHandle* ch if ( view != nullptr ) { - view->faultCollection()->showFaultCollection = false; + view->faultCollection()->setActive( false ); view->cellResult()->setResultType( RiaDefines::ResultCatType::FLOW_DIAGNOSTICS ); view->cellResult()->setFlowDiagTracerSelectionType( RimEclipseResultDefinition::FlowTracerSelectionType::FLOW_TR_BY_SELECTION ); @@ -667,7 +667,6 @@ void RimFlowCharacteristicsPlot::onLoadDataAndUpdate() if ( m_cellFilter() == RigFlowDiagResults::CELLS_VISIBLE ) { cvf::UByteArray visibleCells; - m_case()->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); if ( m_cellFilterView ) { diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp index 9901319020..a60df05fdb 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp @@ -318,12 +318,9 @@ void RimGeoMechView::onCreateDisplayModel() nativeOrOverrideViewer()->addStaticModelOnce( m_wellPathPipeVizModel.p(), isUsingOverrideViewer() ); - // Cross sections + // Intersections - m_intersectionVizModel->removeAllParts(); - m_intersectionCollection->rebuildGeometry(); - m_intersectionCollection->appendPartsToModel( *this, m_intersectionVizModel.p(), scaleTransform() ); - nativeOrOverrideViewer()->addStaticModelOnce( m_intersectionVizModel.p(), isUsingOverrideViewer() ); + appendIntersectionsToModel( cellFilterCollection()->hasActiveFilters(), propertyFilterCollection()->hasActiveDynamicFilters() ); // Seismic sections @@ -480,13 +477,14 @@ void RimGeoMechView::onUpdateDisplayModelForCurrentTimeStep() m_vizLogic->updateStaticCellColors( m_currentTimeStep() ); // Intersections + if ( intersectionCollection()->shouldApplyCellFiltersToIntersections() && propertyFilterCollection()->hasActiveDynamicFilters() ) { - m_intersectionVizModel->removeAllParts(); - m_intersectionCollection->rebuildGeometry(); - m_intersectionCollection->appendPartsToModel( *this, m_intersectionVizModel.p(), scaleTransform() ); - m_intersectionCollection->updateCellResultColor( hasGeneralCellResult, m_currentTimeStep ); + m_intersectionCollection->clearGeometry(); + appendIntersectionsForCurrentTimeStep(); } + m_intersectionCollection->updateCellResultColor( hasGeneralCellResult, m_currentTimeStep ); + if ( m_surfaceCollection ) { m_surfaceCollection->updateCellResultColor( hasGeneralCellResult, m_currentTimeStep ); @@ -1133,3 +1131,12 @@ void RimGeoMechView::resetVizLogic() m_vizLogic->resetPartMgrs(); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::calculateCellVisibility( cvf::UByteArray* visibility, std::vector geomTypes, int viewerTimeStep ) +{ + CAF_ASSERT( m_vizLogic.notNull() ); + m_vizLogic->calculateCellVisibility( visibility, geomTypes, viewerTimeStep ); +} diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.h b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.h index d6842831cd..cfd4d96458 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.h +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.h @@ -128,6 +128,8 @@ protected: RimPropertyFilterCollection* nativePropertyFilterCollection(); + void calculateCellVisibility( cvf::UByteArray* visibility, std::vector geomTypes, int timeStep = 0 ) override; + private: QString createAutoName() const override; diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp index 45eef2146d..7980edff87 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp @@ -267,7 +267,7 @@ void RimBoxIntersection::appendManipulatorPartsToModel( cvf::ModelBasicList* mod //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimBoxIntersection::rebuildGeometry() +void RimBoxIntersection::clearGeometry() { m_intersectionBoxPartMgr = nullptr; } diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.h index 7a3bd1aad0..251a7bafe7 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.h @@ -73,7 +73,7 @@ public: RivBoxIntersectionPartMgr* intersectionBoxPartMgr(); void appendManipulatorPartsToModel( cvf::ModelBasicList* model ); - void rebuildGeometry(); + void clearGeometry(); void setToDefaultSizeBox(); void setToDefaultSizeSlice( SinglePlaneState plane, const cvf::Vec3d& position ); diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp index 8a8f93bb40..f4fe0d64fd 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp @@ -844,7 +844,7 @@ RivExtrudedCurveIntersectionPartMgr* RimExtrudedCurveIntersection::intersectionP //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimExtrudedCurveIntersection::rebuildGeometry() +void RimExtrudedCurveIntersection::clearGeometry() { m_crossSectionPartMgr = nullptr; } diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h index eefadad7e4..f4de75e8ae 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h @@ -109,7 +109,7 @@ public: Rim2dIntersectionView* correspondingIntersectionView() const; RivExtrudedCurveIntersectionPartMgr* intersectionPartMgr(); - void rebuildGeometry(); + void clearGeometry(); const RivIntersectionGeometryGeneratorInterface* intersectionGeometryGenerator() const override; std::vector polyLinesForExtrusionDirection() const; diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp index 96dfac44a1..126864ea6d 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp @@ -42,6 +42,7 @@ #include "cafPdmUiCheckBoxEditor.h" #include "cafPdmUiDoubleSliderEditor.h" #include "cafPdmUiTreeOrdering.h" + #include "cvfModelBasicList.h" CAF_PDM_SOURCE_INIT( RimIntersectionCollection, "IntersectionCollection", "CrossSectionCollection" ); @@ -59,8 +60,8 @@ RimIntersectionCollection::RimIntersectionCollection() CAF_PDM_InitFieldNoDefault( &m_intersectionBoxes, "IntersectionBoxes", "IntersectionBoxes" ); m_intersectionBoxes.uiCapability()->setUiTreeHidden( true ); - CAF_PDM_InitField( &isActive, "Active", true, "Active" ); - isActive.uiCapability()->setUiHidden( true ); + CAF_PDM_InitField( &m_isActive, "Active", true, "Active" ); + m_isActive.uiCapability()->setUiHidden( true ); CAF_PDM_InitFieldNoDefault( &m_depthUpperThreshold, "UpperDepthThreshold", "Upper Threshold" ); m_depthUpperThreshold.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); @@ -75,6 +76,8 @@ RimIntersectionCollection::RimIntersectionCollection() CAF_PDM_InitField( &m_kFilterOverridden, "OverrideKFilter", false, "Override K Range Filter" ); CAF_PDM_InitFieldNoDefault( &m_kFilterStr, "KRangeFilter", "K Range Filter", "", "Example: 2,4-6,10-30:2", "" ); + + CAF_PDM_InitField( &m_applyCellFilters, "ApplyCellFilters", true, "Use Cell Filters" ); } //-------------------------------------------------------------------------------------------------- @@ -91,7 +94,15 @@ RimIntersectionCollection::~RimIntersectionCollection() //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimIntersectionCollection::objectToggleField() { - return &isActive; + return &m_isActive; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimIntersectionCollection::isActive() const +{ + return m_isActive(); } //-------------------------------------------------------------------------------------------------- @@ -209,9 +220,36 @@ void RimIntersectionCollection::appendPartsToModel( Rim3dView& view, cvf::ModelB { if ( cs->isActive() ) { + cs->intersectionPartMgr()->appendPolylinePartsToModel( view, model, scaleTransform ); + } + } + + for ( RimBoxIntersection* cs : m_intersectionBoxes ) + { + if ( cs->isActive() && cs->show3dManipulator() ) + { + cs->appendManipulatorPartsToModel( model ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionCollection::appendDynamicPartsToModel( cvf::ModelBasicList* model, + cvf::Transform* scaleTransform, + size_t timeStepIndex, + cvf::UByteArray* visibleCells ) +{ + if ( !isActive() ) return; + + for ( RimExtrudedCurveIntersection* cs : m_intersections ) + { + if ( cs->isActive() ) + { + cs->intersectionPartMgr()->generatePartGeometry( visibleCells ); cs->intersectionPartMgr()->appendIntersectionFacesToModel( model, scaleTransform ); cs->intersectionPartMgr()->appendMeshLinePartsToModel( model, scaleTransform ); - cs->intersectionPartMgr()->appendPolylinePartsToModel( view, model, scaleTransform ); } } @@ -219,32 +257,26 @@ void RimIntersectionCollection::appendPartsToModel( Rim3dView& view, cvf::ModelB { if ( cs->isActive() ) { + cs->intersectionBoxPartMgr()->generatePartGeometry( visibleCells ); cs->intersectionBoxPartMgr()->appendNativeIntersectionFacesToModel( model, scaleTransform ); cs->intersectionBoxPartMgr()->appendMeshLinePartsToModel( model, scaleTransform ); - - if ( cs->show3dManipulator() ) - { - cs->appendManipulatorPartsToModel( model ); - } } } - - model->updateBoundingBoxesRecursive(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimIntersectionCollection::rebuildGeometry() +void RimIntersectionCollection::clearGeometry() { for ( RimExtrudedCurveIntersection* intersection : m_intersections ) { - intersection->rebuildGeometry(); + intersection->clearGeometry(); } for ( RimBoxIntersection* intersectionBox : m_intersectionBoxes ) { - intersectionBox->rebuildGeometry(); + intersectionBox->clearGeometry(); } } @@ -354,12 +386,12 @@ void RimIntersectionCollection::fieldChangedByUi( const caf::PdmFieldHandle* cha { bool rebuildView = false; - if ( changedField == &isActive ) + if ( changedField == &m_isActive ) { updateUiIconFromToggleField(); rebuildView = true; } - if ( changedField == &m_depthThresholdOverridden ) + else if ( changedField == &m_depthThresholdOverridden ) { for ( RimExtrudedCurveIntersection* cs : m_intersections ) { @@ -372,8 +404,8 @@ void RimIntersectionCollection::fieldChangedByUi( const caf::PdmFieldHandle* cha } rebuildView = true; } - - if ( ( changedField == &m_depthUpperThreshold ) || ( changedField == &m_depthLowerThreshold ) || ( changedField == &m_depthFilterType ) ) + else if ( ( changedField == &m_depthUpperThreshold ) || ( changedField == &m_depthLowerThreshold ) || + ( changedField == &m_depthFilterType ) ) { for ( RimExtrudedCurveIntersection* cs : m_intersections ) { @@ -382,8 +414,7 @@ void RimIntersectionCollection::fieldChangedByUi( const caf::PdmFieldHandle* cha } rebuildView = true; } - - if ( changedField == &m_kFilterOverridden || changedField == &m_kFilterStr ) + else if ( changedField == &m_kFilterOverridden || changedField == &m_kFilterStr ) { for ( RimExtrudedCurveIntersection* cs : m_intersections ) { @@ -392,6 +423,10 @@ void RimIntersectionCollection::fieldChangedByUi( const caf::PdmFieldHandle* cha } rebuildView = true; } + else if ( changedField == &m_applyCellFilters ) + { + rebuildView = true; + } if ( rebuildView ) { @@ -452,7 +487,11 @@ void RimIntersectionCollection::updateIntersectionBoxGeometry() //-------------------------------------------------------------------------------------------------- void RimIntersectionCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { + caf::PdmUiGroup* genGroup = uiOrdering.addNewGroup( "General" ); + genGroup->add( &m_applyCellFilters ); + caf::PdmUiGroup* filterGroup = uiOrdering.addNewGroup( "Depth Filter - Curve Intersections" ); + filterGroup->setCollapsedByDefault(); m_depthFilterType.uiCapability()->setUiReadOnly( !m_depthThresholdOverridden() ); m_depthUpperThreshold.uiCapability()->setUiReadOnly( !m_depthThresholdOverridden() ); @@ -486,12 +525,13 @@ void RimIntersectionCollection::defineUiOrdering( QString uiConfigName, caf::Pdm } if ( eclipseView() ) { - caf::PdmUiGroup* filterGroup = uiOrdering.addNewGroup( "K Filter - Curve Intersections" ); + caf::PdmUiGroup* kfilterGroup = uiOrdering.addNewGroup( "K Filter - Curve Intersections" ); + kfilterGroup->setCollapsedByDefault(); m_kFilterStr.uiCapability()->setUiReadOnly( !m_kFilterOverridden() ); - filterGroup->add( &m_kFilterOverridden ); - filterGroup->add( &m_kFilterStr ); + kfilterGroup->add( &m_kFilterOverridden ); + kfilterGroup->add( &m_kFilterStr ); } uiOrdering.skipRemainingFields( true ); @@ -539,3 +579,11 @@ void RimIntersectionCollection::rebuild3dView() const rimView->scheduleCreateDisplayModelAndRedraw(); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimIntersectionCollection::shouldApplyCellFiltersToIntersections() const +{ + return m_applyCellFilters(); +} diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h index f73c200c8a..d92baabdbd 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h @@ -23,6 +23,8 @@ #include "cafPdmField.h" #include "cafPdmObject.h" +#include "cvfArray.h" + #include "RimIntersectionEnums.h" class Rim3dView; @@ -53,8 +55,6 @@ public: RimIntersectionCollection(); ~RimIntersectionCollection() override; - caf::PdmField isActive; - void appendIntersectionAndUpdate( RimExtrudedCurveIntersection* intersection, bool allowActiveViewChange = true ); void appendIntersectionNoUpdate( RimExtrudedCurveIntersection* intersection ); @@ -70,12 +70,18 @@ public: void scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); void recomputeSimWellBranchData(); + bool shouldApplyCellFiltersToIntersections() const; + // Visualization interface void applySingleColorEffect(); void updateCellResultColor( bool hasGeneralCellResult, int timeStepIndex ); void appendPartsToModel( Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); - void rebuildGeometry(); + void appendDynamicPartsToModel( cvf::ModelBasicList* model, + cvf::Transform* scaleTransform, + size_t timeStepIndex, + cvf::UByteArray* visibleCells = nullptr ); + void clearGeometry(); std::vector intersections() const; std::vector intersectionBoxes() const; @@ -84,6 +90,8 @@ public: void onChildAdded( caf::PdmFieldHandle* containerForNewObject ) override; + bool isActive() const; + protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; caf::PdmFieldHandle* objectToggleField() override; @@ -96,6 +104,8 @@ private: RimEclipseView* eclipseView() const; void rebuild3dView() const; + caf::PdmField m_isActive; + caf::PdmChildArrayField m_intersections; caf::PdmChildArrayField m_intersectionBoxes; @@ -104,6 +114,8 @@ private: caf::PdmField m_depthLowerThreshold; caf::PdmField> m_depthFilterType; + caf::PdmField m_applyCellFilters; + caf::PdmField m_kFilterOverridden; caf::PdmField m_kFilterStr; }; diff --git a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp index f0f7c8f8ef..7016aba9be 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -539,6 +539,7 @@ void Rim2dIntersectionView::onCreateDisplayModel() m_intersectionVizModel->removeAllParts(); + m_flatIntersectionPartMgr->generatePartGeometry( nullptr ); m_flatIntersectionPartMgr->appendIntersectionFacesToModel( m_intersectionVizModel.p(), scaleTransform() ); m_flatIntersectionPartMgr->appendMeshLinePartsToModel( m_intersectionVizModel.p(), scaleTransform() ); m_flatIntersectionPartMgr->appendPolylinePartsToModel( *this, m_intersectionVizModel.p(), scaleTransform() ); diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp index 2a3d09c90e..e99f7f7159 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp @@ -150,9 +150,6 @@ Rim3dView::Rim3dView() CAF_PDM_InitFieldNoDefault( &m_fontSize, "FontSize", "Font Size" ); - m_intersectionVizModel = new cvf::ModelBasicList; - m_intersectionVizModel->setName( "CrossSectionModel" ); - m_seismicVizModel = new cvf::ModelBasicList; m_seismicVizModel->setName( "SeismicSectionModel" ); diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dView.h b/ApplicationLibCode/ProjectDataModel/Rim3dView.h index b7baae4074..af1ca70e7f 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationLibCode/ProjectDataModel/Rim3dView.h @@ -257,7 +257,6 @@ protected: // 3D display model data cvf::ref m_wellPathPipeVizModel; - cvf::ref m_intersectionVizModel; cvf::ref m_seismicVizModel; cvf::ref m_wellPathsPartManager; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp index 6c57ced1a8..f9c75e30dc 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp @@ -311,8 +311,8 @@ RimEclipseView* RimEclipseCase::createAndAddReservoirView() rimEclipseView->cellResult()->setFromEclipseResultAddress( defaultResult ); } - auto prefs = RiaPreferences::current(); - rimEclipseView->faultCollection()->showFaultCollection = prefs->enableFaultsByDefault(); + auto prefs = RiaPreferences::current(); + rimEclipseView->faultCollection()->setActive( prefs->enableFaultsByDefault() ); rimEclipseView->cellEdgeResult()->setResultVariable( "MULT" ); rimEclipseView->cellEdgeResult()->setActive( false ); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp index c4ce90ea85..031fffa5bc 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp @@ -291,9 +291,9 @@ void RimEclipseContourMapView::updateGeometry() //-------------------------------------------------------------------------------------------------- void RimEclipseContourMapView::setFaultVisParameters() { - faultCollection()->setShowFaultsOutsideFilter( false ); - faultCollection()->showOppositeFaultFaces = true; - faultCollection()->faultResult = RimFaultInViewCollection::FAULT_NO_FACE_CULLING; + faultCollection()->setShouldApplyCellFiltersToFaults( true ); + faultCollection()->setShowOppositeFaultFaces( true ); + faultCollection()->setFaultResult( RimFaultInViewCollection::FAULT_NO_FACE_CULLING ); faultResultSettings()->showCustomFaultResult = true; faultResultSettings()->customFaultResult()->setResultVariable( "None" ); } @@ -507,7 +507,7 @@ std::set RimEclipseContourMapView::allVisibleFaultGeometryTypes( { std::set faultGeoTypes; // Normal eclipse views always shows faults for active and visible eclipse cells. - if ( faultCollection()->showFaultCollection() ) + if ( faultCollection()->isActive() ) { faultGeoTypes = RimEclipseView::allVisibleFaultGeometryTypes(); } diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index 5234e4b340..00a405d1a3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -439,6 +439,9 @@ void RimEclipseView::onCreateDisplayModel() if ( !( m_eclipseCase && m_eclipseCase->eclipseCaseData() ) ) return; + const bool cellFiltersActive = cellFilterCollection()->hasActiveFilters(); + const bool propertyFiltersActive = eclipsePropertyFilterCollection()->hasActiveFilters(); + // Define a vector containing time step indices to produce geometry for. // First entry in this vector is used to define the geometry only result mode with no results. std::vector timeStepIndices; @@ -458,9 +461,9 @@ void RimEclipseView::onCreateDisplayModel() timeStepIndices.push_back( i ); } } - else if ( this->cellResult()->hasStaticResult() || this->cellEdgeResult()->hasResult() || - this->eclipsePropertyFilterCollection()->hasActiveFilters() || this->intersectionCollection()->hasAnyActiveSeparateResults() || - ( this->surfaceInViewCollection() && this->surfaceInViewCollection()->hasAnyActiveSeparateResults() ) ) + else if ( cellResult()->hasStaticResult() || cellEdgeResult()->hasResult() || propertyFiltersActive || + intersectionCollection()->hasAnyActiveSeparateResults() || + ( surfaceInViewCollection() && surfaceInViewCollection()->hasAnyActiveSeparateResults() ) ) { // The one and only static result entry timeStepIndices.push_back( 0 ); @@ -480,7 +483,7 @@ void RimEclipseView::onCreateDisplayModel() wellCollection()->scheduleIsWellPipesVisibleRecalculation(); // Create vector of grid indices to render - std::vector gridIndices = this->indicesToVisibleGrids(); + std::vector gridIndices = indicesToVisibleGrids(); /// // Get or create the parts for "static" type geometry. The same geometry is used @@ -488,36 +491,35 @@ void RimEclipseView::onCreateDisplayModel() // For property filtered geometry : just set all the models as empty scenes // updateCurrentTimeStep requests the actual parts - if ( !this->eclipsePropertyFilterCollection()->hasActiveFilters() || - ( this->viewController() && this->viewController()->isVisibleCellsOveridden() ) ) + if ( !propertyFiltersActive || ( viewController() && viewController()->isVisibleCellsOveridden() ) ) { std::vector geometryTypesToAdd; - if ( this->viewController() && this->viewController()->isVisibleCellsOveridden() ) + if ( viewController() && viewController()->isVisibleCellsOveridden() ) { geometryTypesToAdd.push_back( OVERRIDDEN_CELL_VISIBILITY ); } - else if ( this->cellFilterCollection()->hasActiveFilters() && this->wellCollection()->hasVisibleWellCells() ) + else if ( cellFiltersActive && wellCollection()->hasVisibleWellCells() ) { geometryTypesToAdd.push_back( RANGE_FILTERED ); geometryTypesToAdd.push_back( RANGE_FILTERED_WELL_CELLS ); geometryTypesToAdd.push_back( VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER ); geometryTypesToAdd.push_back( VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER ); - if ( this->showInactiveCells() ) + if ( showInactiveCells() ) { geometryTypesToAdd.push_back( RANGE_FILTERED_INACTIVE ); } } - else if ( !this->cellFilterCollection()->hasActiveFilters() && this->wellCollection()->hasVisibleWellCells() ) + else if ( !cellFiltersActive && wellCollection()->hasVisibleWellCells() ) { geometryTypesToAdd.push_back( VISIBLE_WELL_CELLS ); geometryTypesToAdd.push_back( VISIBLE_WELL_FENCE_CELLS ); } - else if ( this->cellFilterCollection()->hasActiveFilters() && !this->wellCollection()->hasVisibleWellCells() ) + else if ( cellFiltersActive && !wellCollection()->hasVisibleWellCells() ) { geometryTypesToAdd.push_back( RANGE_FILTERED ); geometryTypesToAdd.push_back( RANGE_FILTERED_WELL_CELLS ); - if ( this->showInactiveCells() ) + if ( showInactiveCells() ) { geometryTypesToAdd.push_back( RANGE_FILTERED_INACTIVE ); } @@ -527,7 +529,7 @@ void RimEclipseView::onCreateDisplayModel() geometryTypesToAdd.push_back( ALL_WELL_CELLS ); // Should be all well cells geometryTypesToAdd.push_back( ACTIVE ); - if ( this->showInactiveCells() ) + if ( showInactiveCells() ) { geometryTypesToAdd.push_back( INACTIVE ); } @@ -555,7 +557,7 @@ void RimEclipseView::onCreateDisplayModel() } } // Set static colors - this->onUpdateStaticCellColors(); + onUpdateStaticCellColors(); } else { @@ -565,14 +567,14 @@ void RimEclipseView::onCreateDisplayModel() m_reservoirGridPartManager->clearWatertightGeometryFlags(); - if ( faultCollection()->showFaultCollection() || !this->eclipsePropertyFilterCollection()->hasActiveFilters() ) + if ( faultCollection()->isActive() || !propertyFiltersActive ) { setVisibleGridPartsWatertight(); std::set faultGeometryTypesToAppend = allVisibleFaultGeometryTypes(); RivCellSetEnum faultLabelType = m_reservoirGridPartManager->geometryTypeForFaultLabels( faultGeometryTypesToAppend, - faultCollection()->isShowingFaultsAndFaultsOutsideFilters() ); + !faultCollection()->shouldApplyCellFiltersToFaults() ); for ( size_t frameIdx = 0; frameIdx < frameModels.size(); ++frameIdx ) { @@ -587,22 +589,16 @@ void RimEclipseView::onCreateDisplayModel() } } - // Cross sections - - m_intersectionVizModel->removeAllParts(); - m_intersectionCollection->rebuildGeometry(); - m_intersectionCollection->appendPartsToModel( *this, m_intersectionVizModel.p(), m_reservoirGridPartManager->scaleTransform() ); - nativeOrOverrideViewer()->addStaticModelOnce( m_intersectionVizModel.p(), isUsingOverrideViewer() ); + // Intersections + appendIntersectionsToModel( cellFiltersActive, propertyFiltersActive ); // Seismic sections - cvf::ref transform = displayCoordTransform(); m_seismicVizModel->removeAllParts(); m_seismicSectionCollection->appendPartsToModel( this, m_seismicVizModel.p(), transform.p(), ownerCase()->allCellsBoundingBox() ); nativeOrOverrideViewer()->addStaticModelOnce( m_seismicVizModel.p(), isUsingOverrideViewer() ); // Surfaces - m_surfaceVizModel->removeAllParts(); if ( surfaceInViewCollection() ) { @@ -611,7 +607,6 @@ void RimEclipseView::onCreateDisplayModel() } // Well path model - m_wellPathPipeVizModel->removeAllParts(); // NB! StimPlan legend colors must be updated before well path geometry is added to the model @@ -659,7 +654,7 @@ void RimEclipseView::onCreateDisplayModel() updateFaultColors(); } - std::vector characteristicsPlots = this->objectsWithReferringPtrFieldsOfType(); + std::vector characteristicsPlots = objectsWithReferringPtrFieldsOfType(); for ( auto plot : characteristicsPlots ) { if ( plot != nullptr ) @@ -711,8 +706,6 @@ void RimEclipseView::onUpdateDisplayModelForCurrentTimeStep() { clearReservoirCellVisibilities(); - // m_surfaceCollection->clearGeometry(); - m_propertyFilterCollection()->updateFromCurrentTimeStep(); m_streamlineCollection()->updateFromCurrentTimeStep( currentTimeStep() ); @@ -720,6 +713,12 @@ void RimEclipseView::onUpdateDisplayModelForCurrentTimeStep() onUpdateLegends(); // To make sure the scalar mappers are set up correctly + if ( intersectionCollection()->shouldApplyCellFiltersToIntersections() && eclipsePropertyFilterCollection()->hasActiveFilters() ) + { + m_intersectionCollection->clearGeometry(); + appendIntersectionsForCurrentTimeStep(); + } + updateVisibleCellColors(); wellCollection()->scaleWellDisks(); @@ -787,7 +786,7 @@ void RimEclipseView::updateVisibleGeometries() RivCellSetEnum faultLabelType = m_reservoirGridPartManager->geometryTypeForFaultLabels( faultGeometryTypesToAppend, - faultCollection()->isShowingFaultsAndFaultsOutsideFilters() ); + !faultCollection()->shouldApplyCellFiltersToFaults() ); if ( faultLabelType == PROPERTY_FILTERED ) { m_reservoirGridPartManager->appendFaultLabelsDynamicGeometryPartsToModel( frameParts.p(), faultLabelType, m_currentTimeStep ); @@ -810,7 +809,7 @@ void RimEclipseView::updateVisibleGeometries() { m_reservoirGridPartManager->appendStaticGeometryPartsToModel( frameParts.p(), RANGE_FILTERED_INACTIVE, gridIndices ); - if ( !faultCollection()->isShowingFaultsAndFaultsOutsideFilters() ) + if ( faultCollection()->shouldApplyCellFiltersToFaults() ) { m_reservoirGridPartManager->appendFaultsStaticGeometryPartsToModel( frameParts.p(), RANGE_FILTERED_INACTIVE ); } @@ -819,7 +818,7 @@ void RimEclipseView::updateVisibleGeometries() { m_reservoirGridPartManager->appendStaticGeometryPartsToModel( frameParts.p(), INACTIVE, gridIndices ); - if ( !faultCollection()->isShowingFaultsAndFaultsOutsideFilters() ) + if ( faultCollection()->shouldApplyCellFiltersToFaults() ) { m_reservoirGridPartManager->appendFaultsStaticGeometryPartsToModel( frameParts.p(), INACTIVE ); } @@ -1934,7 +1933,7 @@ std::set RimEclipseView::allVisibleFaultGeometryTypes() const std::set faultGeoTypes; faultGeoTypes.insert( m_visibleGridParts.begin(), m_visibleGridParts.end() ); - if ( faultCollection()->isShowingFaultsAndFaultsOutsideFilters() ) + if ( !faultCollection()->shouldApplyCellFiltersToFaults() ) { faultGeoTypes.insert( ACTIVE ); faultGeoTypes.insert( ALL_WELL_CELLS ); @@ -2208,6 +2207,37 @@ void RimEclipseView::calculateCurrentTotalCellVisibility( cvf::UByteArray* total } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseView::calculateCellVisibility( cvf::UByteArray* visibility, std::vector geomTypes, int timeStep ) +{ + size_t cellCount = this->mainGrid()->globalCellArray().size(); + + visibility->resize( cellCount ); + visibility->setAll( false ); + + std::vector gridIndices = this->indicesToVisibleGrids(); + + const auto gridCount = this->eclipseCase()->eclipseCaseData()->gridCount(); + + for ( size_t gridIdx = 0; gridIdx < gridCount; gridIdx++ ) + { + RigGridBase* grid = this->eclipseCase()->eclipseCaseData()->grid( gridIdx ); + int gridCellCount = static_cast( grid->cellCount() ); + + for ( auto vizType : geomTypes ) + { + const cvf::UByteArray* gridVisibility = m_reservoirGridPartManager->cellVisibility( vizType, gridIdx, timeStep ); + + for ( int lcIdx = 0; lcIdx < gridCellCount; ++lcIdx ) + { + ( *visibility )[grid->reservoirCellIndex( lcIdx )] |= ( *gridVisibility )[lcIdx]; + } + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.h b/ApplicationLibCode/ProjectDataModel/RimEclipseView.h index 7a3855bc0b..17a2c7b12b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.h @@ -155,6 +155,8 @@ public: void calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int timeStep ) override; + void calculateCellVisibility( cvf::UByteArray* visibility, std::vector geomTypes, int timeStep = 0 ) override; + std::vector legendConfigs() const override; cvf::Color4f colorFromCellCategory( RivCellSetEnum geometryType ) const; diff --git a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp index 7689e7f45a..1c5ee5ca66 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridView.cpp @@ -46,6 +46,7 @@ #include "Riu3DMainWindowTools.h" #include "Riu3dSelectionManager.h" #include "RiuMainWindow.h" +#include "RiuViewer.h" #include "RivSingleCellPartGenerator.h" @@ -112,6 +113,9 @@ RimGridView::RimGridView() m_surfaceVizModel = new cvf::ModelBasicList; m_surfaceVizModel->setName( "SurfaceModel" ); + + m_intersectionVizModel = new cvf::ModelBasicList; + m_intersectionVizModel->setName( "CrossSectionModel" ); } //-------------------------------------------------------------------------------------------------- @@ -493,3 +497,63 @@ void RimGridView::updateSurfacesInViewTreeItems() this->updateConnectedEditors(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::appendIntersectionsForCurrentTimeStep() +{ + if ( nativeOrOverrideViewer() ) + { + cvf::Scene* frameScene = nativeOrOverrideViewer()->frame( m_currentTimeStep, isUsingOverrideViewer() ); + if ( frameScene ) + { + cvf::String name = "IntersectionDynamicModel"; + Rim3dView::removeModelByName( frameScene, name ); + + cvf::ref frameParts = new cvf::ModelBasicList; + frameParts->setName( name ); + + cvf::UByteArray visibility; + + calculateCellVisibility( &visibility, { PROPERTY_FILTERED, PROPERTY_FILTERED_WELL_CELLS }, m_currentTimeStep ); + + m_intersectionCollection->appendDynamicPartsToModel( frameParts.p(), scaleTransform(), m_currentTimeStep, &visibility ); + + frameParts->updateBoundingBoxesRecursive(); + + frameScene->addModel( frameParts.p() ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::appendIntersectionsToModel( bool cellFiltersActive, bool propertyFiltersActive ) +{ + m_intersectionVizModel->removeAllParts(); + if ( m_intersectionCollection->isActive() ) + { + m_intersectionCollection->clearGeometry(); + + if ( m_intersectionCollection->shouldApplyCellFiltersToIntersections() && ( cellFiltersActive || propertyFiltersActive ) ) + { + m_intersectionCollection->appendPartsToModel( *this, m_intersectionVizModel.p(), scaleTransform() ); + + if ( !propertyFiltersActive ) + { + cvf::UByteArray visibleCells; + calculateCellVisibility( &visibleCells, { RANGE_FILTERED_WELL_CELLS, RANGE_FILTERED } ); + m_intersectionCollection->appendDynamicPartsToModel( m_intersectionVizModel.p(), scaleTransform(), currentTimeStep(), &visibleCells ); + } + } + else + { + m_intersectionCollection->appendPartsToModel( *this, m_intersectionVizModel.p(), scaleTransform() ); + m_intersectionCollection->appendDynamicPartsToModel( m_intersectionVizModel.p(), scaleTransform(), currentTimeStep() ); + } + m_intersectionVizModel->updateBoundingBoxesRecursive(); + nativeOrOverrideViewer()->addStaticModelOnce( m_intersectionVizModel.p(), isUsingOverrideViewer() ); + } +} diff --git a/ApplicationLibCode/ProjectDataModel/RimGridView.h b/ApplicationLibCode/ProjectDataModel/RimGridView.h index bbc3a1c2f6..58d3cea41b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridView.h +++ b/ApplicationLibCode/ProjectDataModel/RimGridView.h @@ -84,8 +84,14 @@ protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void initAfterRead() override; + void appendIntersectionsForCurrentTimeStep(); + void appendIntersectionsToModel( bool cellFiltersActive, bool propertyFiltersActive ); + + virtual void calculateCellVisibility( cvf::UByteArray* visibility, std::vector geomTypes, int timeStep = 0 ) = 0; + protected: cvf::ref m_surfaceVizModel; + cvf::ref m_intersectionVizModel; // Fields caf::PdmChildField m_intersectionCollection; diff --git a/ApplicationLibCode/ReservoirDataModel/RigVisibleCategoriesCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/RigVisibleCategoriesCalculator.cpp index 2106194561..19f6723940 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigVisibleCategoriesCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigVisibleCategoriesCalculator.cpp @@ -146,7 +146,7 @@ std::set RigVisibleCategoriesCalculator::visibleCategories( RimEclipseView* //-------------------------------------------------------------------------------------------------- std::set RigVisibleCategoriesCalculator::visibleNncConnectionIndices( RimEclipseView* eclView ) { - if ( !eclView->faultCollection() || !eclView->faultCollection()->showFaultCollection ) return {}; + if ( !eclView->faultCollection() || !eclView->faultCollection()->isActive() ) return {}; std::set visibleConnectionIndices; @@ -173,8 +173,7 @@ std::set RigVisibleCategoriesCalculator::visibleNncConnectionIndices( Ri //-------------------------------------------------------------------------------------------------- void RigVisibleCategoriesCalculator::appendVisibleFaultCells( RimEclipseView* eclView, std::set& visibleCells ) { - if ( eclView->faultCollection() && eclView->faultCollection()->showFaultCollection && - !eclView->faultResultSettings()->showCustomFaultResult() ) + if ( eclView->faultCollection() && eclView->faultCollection()->isActive() && !eclView->faultResultSettings()->showCustomFaultResult() ) { for ( const auto& f : eclView->faultCollection()->faults() ) { diff --git a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp index 6055d64979..1aee631a65 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp @@ -1613,7 +1613,7 @@ void RiuMainWindow::slotToggleFaultLabelsAction( bool showLabels ) if ( !activeRiv ) return; - activeRiv->faultCollection()->showFaultLabel.setValueWithFieldChanged( showLabels ); + activeRiv->faultCollection()->setShowFaultLabelWithFieldChanged( showLabels ); refreshDrawStyleActions(); }