diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp index d0d5c321cd..fc53751118 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp @@ -842,52 +842,58 @@ void RivExtrudedCurveIntersectionPartMgr::appendMeshLinePartsToModel( cvf::Model //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivExtrudedCurveIntersectionPartMgr::appendPolylinePartsToModel( Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform ) +void RivExtrudedCurveIntersectionPartMgr::appendPolylinePartsToModel( Rim3dView& view, + cvf::ModelBasicList* model, + cvf::Transform* scaleTransform, + bool annotationOnly ) { auto* curr2dView = dynamic_cast( &view ); - if ( m_rimIntersection->inputPolyLineFromViewerEnabled() || ( curr2dView && curr2dView->showDefiningPoints() ) ) + if ( !annotationOnly ) { - if ( m_highlightLineAlongPolyline.notNull() ) + if ( m_rimIntersection->inputPolyLineFromViewerEnabled() || ( curr2dView && curr2dView->showDefiningPoints() ) ) { - m_highlightLineAlongPolyline->setTransform( scaleTransform ); - model->addPart( m_highlightLineAlongPolyline.p() ); + if ( m_highlightLineAlongPolyline.notNull() ) + { + m_highlightLineAlongPolyline->setTransform( scaleTransform ); + model->addPart( m_highlightLineAlongPolyline.p() ); + } + + if ( m_highlightPointsForPolyline.notNull() ) + { + m_highlightPointsForPolyline->setTransform( scaleTransform ); + model->addPart( m_highlightPointsForPolyline.p() ); + } } - if ( m_highlightPointsForPolyline.notNull() ) + if ( m_rimIntersection->inputExtrusionPointsFromViewerEnabled() ) { - m_highlightPointsForPolyline->setTransform( scaleTransform ); - model->addPart( m_highlightPointsForPolyline.p() ); - } - } + if ( m_highlightLineAlongExtrusionDir.notNull() ) + { + m_highlightLineAlongExtrusionDir->setTransform( scaleTransform ); + model->addPart( m_highlightLineAlongExtrusionDir.p() ); + } - if ( m_rimIntersection->inputExtrusionPointsFromViewerEnabled() ) - { - if ( m_highlightLineAlongExtrusionDir.notNull() ) - { - m_highlightLineAlongExtrusionDir->setTransform( scaleTransform ); - model->addPart( m_highlightLineAlongExtrusionDir.p() ); + if ( m_highlightPointsForExtrusionDir.notNull() ) + { + m_highlightPointsForExtrusionDir->setTransform( scaleTransform ); + model->addPart( m_highlightPointsForExtrusionDir.p() ); + } } - if ( m_highlightPointsForExtrusionDir.notNull() ) + if ( m_rimIntersection->inputTwoAzimuthPointsFromViewerEnabled() || ( curr2dView && curr2dView->showDefiningPoints() ) ) { - m_highlightPointsForExtrusionDir->setTransform( scaleTransform ); - model->addPart( m_highlightPointsForExtrusionDir.p() ); - } - } + if ( m_highlightLineAlongPolyline.notNull() ) + { + m_highlightLineAlongPolyline->setTransform( scaleTransform ); + model->addPart( m_highlightLineAlongPolyline.p() ); + } - if ( m_rimIntersection->inputTwoAzimuthPointsFromViewerEnabled() || ( curr2dView && curr2dView->showDefiningPoints() ) ) - { - if ( m_highlightLineAlongPolyline.notNull() ) - { - m_highlightLineAlongPolyline->setTransform( scaleTransform ); - model->addPart( m_highlightLineAlongPolyline.p() ); - } - - if ( m_highlightPointsForPolyline.notNull() ) - { - m_highlightPointsForPolyline->setTransform( scaleTransform ); - model->addPart( m_highlightPointsForPolyline.p() ); + if ( m_highlightPointsForPolyline.notNull() ) + { + m_highlightPointsForPolyline->setTransform( scaleTransform ); + model->addPart( m_highlightPointsForPolyline.p() ); + } } } diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h index ae30e02ce3..8cf97e267d 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h @@ -75,7 +75,7 @@ public: void appendIntersectionFacesToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); void appendMeshLinePartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); - void appendPolylinePartsToModel( Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); + void appendPolylinePartsToModel( Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform, bool annotationOnly = false ); cvf::Mat4d unflattenTransformMatrix( const cvf::Vec3d& intersectionPointFlat ) const; diff --git a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp index b89a90414b..156d756fc1 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -20,13 +20,16 @@ #include "Rim3dOverlayInfoConfig.h" #include "RimCase.h" +#include "RimCellFilterCollection.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" +#include "RimEclipsePropertyFilterCollection.h" #include "RimEclipseView.h" #include "RimExtrudedCurveIntersection.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechView.h" #include "RimGridView.h" +#include "RimIntersectionCollection.h" #include "RimIntersectionResultDefinition.h" #include "RimRegularLegendConfig.h" #include "RimSimWellInView.h" @@ -516,16 +519,19 @@ void Rim2dIntersectionView::onCreateDisplayModel() nativeOrOverrideViewer()->addFrame( new cvf::Scene(), isUsingOverrideViewer() ); } - m_flatIntersectionPartMgr = new RivExtrudedCurveIntersectionPartMgr( m_intersection(), true ); + bool propertiesFiltersActive = false; + bool cellFiltersActive = false; - m_intersectionVizModel->removeAllParts(); + RimGridView* grView = m_intersection->firstAncestorOrThisOfType(); + if ( grView && grView->intersectionCollection()->shouldApplyCellFiltersToIntersections() ) + { + propertiesFiltersActive = grView->propertyFilterCollection()->hasActiveFilters(); + cellFiltersActive = grView->cellFilterCollection()->hasActiveFilters(); + } - m_flatIntersectionPartMgr->generatePartGeometry( nullptr, scaleTransform() ); - m_flatIntersectionPartMgr->appendIntersectionFacesToModel( m_intersectionVizModel.p(), scaleTransform() ); - m_flatIntersectionPartMgr->appendMeshLinePartsToModel( m_intersectionVizModel.p(), scaleTransform() ); - m_flatIntersectionPartMgr->appendPolylinePartsToModel( *this, m_intersectionVizModel.p(), scaleTransform() ); + m_flatIntersectionPartMgr = new RivExtrudedCurveIntersectionPartMgr( m_intersection, true ); - m_flatIntersectionPartMgr->applySingleColorEffect(); + appendIntersectionToModel( cellFiltersActive, propertiesFiltersActive ); m_flatSimWellPipePartMgr = nullptr; m_flatWellHeadPartMgr = nullptr; @@ -574,6 +580,17 @@ void Rim2dIntersectionView::onUpdateDisplayModelForCurrentTimeStep() update3dInfo(); onUpdateLegends(); + RimGridView* grView = m_intersection->firstAncestorOrThisOfType(); + if ( grView ) + { + if ( grView->intersectionCollection()->shouldApplyCellFiltersToIntersections() && + grView->propertyFilterCollection()->hasActiveFilters() ) + { + m_flatIntersectionPartMgr = new RivExtrudedCurveIntersectionPartMgr( m_intersection, true ); + appendIntersectionForCurrentTimeStep(); + } + } + if ( m_flatSimWellPipePartMgr.notNull() ) { cvf::Scene* frameScene = nativeOrOverrideViewer()->frame( m_currentTimeStep, isUsingOverrideViewer() ); @@ -831,3 +848,118 @@ void Rim2dIntersectionView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTree { uiTreeOrdering.skipRemainingChildren( true ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::appendIntersectionToModel( bool cellFiltersActive, bool propertyFiltersActive ) +{ + m_intersectionVizModel->removeAllParts(); + + RimEclipseView* eclView = m_intersection->firstAncestorOrThisOfType(); + RimGeoMechView* geoView = m_intersection->firstAncestorOrThisOfType(); + + if ( cellFiltersActive || propertyFiltersActive ) + { + if ( eclView ) + { + if ( !propertyFiltersActive ) + { + cvf::UByteArray visibleCells; + eclView->calculateCellVisibility( &visibleCells, { RANGE_FILTERED_WELL_CELLS, RANGE_FILTERED }, m_currentTimeStep ); + appendDynamicPartsToModel( m_intersectionVizModel.p(), scaleTransform(), &visibleCells ); + } + } + else if ( geoView ) + { + if ( !propertyFiltersActive ) + { + cvf::UByteArray visibleCells; + geoView->calculateCurrentTotalCellVisibility( &visibleCells, m_currentTimeStep ); + appendDynamicPartsToModel( m_intersectionVizModel.p(), scaleTransform(), &visibleCells ); + } + } + + // NB! Geometry objects are recreated in appendDynamicPartsToModel(), always call + // appendPartsToModel() after appendDynamicPartsToModel() + appendPartsToModel( m_intersectionVizModel.p(), scaleTransform() ); + } + else + { + appendDynamicPartsToModel( m_intersectionVizModel.p(), scaleTransform(), nullptr ); + + // NB! Geometry objects are recreated in appendDynamicPartsToModel(), always call + // appendPartsToModel() after appendDynamicPartsToModel() + appendPartsToModel( m_intersectionVizModel.p(), scaleTransform() ); + } + m_intersectionVizModel->updateBoundingBoxesRecursive(); + nativeOrOverrideViewer()->addStaticModelOnce( m_intersectionVizModel.p(), isUsingOverrideViewer() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::appendIntersectionForCurrentTimeStep() +{ + 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 ); + + RimEclipseView* eclView = m_intersection->firstAncestorOrThisOfType(); + RimGeoMechView* geoView = m_intersection->firstAncestorOrThisOfType(); + if ( eclView ) + { + cvf::UByteArray visibility; + eclView->calculateCellVisibility( &visibility, { PROPERTY_FILTERED, PROPERTY_FILTERED_WELL_CELLS }, m_currentTimeStep ); + appendDynamicPartsToModel( frameParts.p(), scaleTransform(), &visibility ); + } + else if ( geoView ) + { + cvf::UByteArray visibility; + geoView->calculateCurrentTotalCellVisibility( &visibility, m_currentTimeStep ); + appendDynamicPartsToModel( frameParts.p(), scaleTransform(), &visibility ); + } + else + { + appendDynamicPartsToModel( frameParts.p(), scaleTransform(), nullptr ); + } + frameParts->updateBoundingBoxesRecursive(); + + frameScene->addModel( frameParts.p() ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::appendPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ) +{ + m_flatIntersectionPartMgr->appendPolylinePartsToModel( *this, model, scaleTransform, true /*annotationOnly*/ ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::appendDynamicPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform, cvf::UByteArray* visibleCells ) +{ + m_flatIntersectionPartMgr->generatePartGeometry( visibleCells, scaleTransform ); + m_flatIntersectionPartMgr->appendIntersectionFacesToModel( model, scaleTransform ); + m_flatIntersectionPartMgr->appendMeshLinePartsToModel( model, scaleTransform ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::onCellVisibilityChanged( const SignalEmitter* emitter ) +{ + onCreateDisplayModel(); + scheduleCreateDisplayModelAndRedraw(); +} diff --git a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.h index a9a83af986..1482dac5fc 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.h @@ -21,6 +21,7 @@ #include "Rim3dView.h" #include "cafPdmProxyValueField.h" #include "cafPdmPtrField.h" +#include "cvfArray.h" class RimExtrudedCurveIntersection; class RimRegularLegendConfig; @@ -73,6 +74,8 @@ public: std::vector legendConfigs() const override; + void onCellVisibilityChanged( const SignalEmitter* emitter ); + protected: void onUpdateLegends() override; @@ -96,11 +99,17 @@ protected: size_t onTimeStepCountRequested() override; + void appendIntersectionForCurrentTimeStep(); + void appendIntersectionToModel( bool cellFiltersActive, bool propertyFiltersActive ); + private: QString createAutoName() const override; QString getName() const; void setName( const QString& name ); + void appendPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); + void appendDynamicPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform, cvf::UByteArray* visibleCells ); + caf::PdmChildField m_legendConfig; caf::PdmChildField m_ternaryLegendConfig; diff --git a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp index 7502d72fb7..972d2ea4d5 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp @@ -21,6 +21,7 @@ #include "Rim2dIntersectionView.h" #include "RimCase.h" #include "RimExtrudedCurveIntersection.h" +#include "RimGridView.h" CAF_PDM_SOURCE_INIT( Rim2dIntersectionViewCollection, "Intersection2dViewCollection" ); @@ -88,23 +89,28 @@ void Rim2dIntersectionViewCollection::syncFromExistingIntersections( bool doUpda for ( RimExtrudedCurveIntersection* intersection : allOrderedIntersectionsInCase ) { + auto view = intersection->firstAncestorOrThisOfType(); + auto it = intersectionToViewMap.find( intersection ); if ( it == intersectionToViewMap.end() ) { Rim2dIntersectionView* newView = new Rim2dIntersectionView(); - auto view = intersection->firstAncestorOrThisOfType(); if ( view ) { newView->setCurrentTimeStep( view->currentTimeStep() ); + view->cellVisibilityChanged.connect( newView, &Rim2dIntersectionView::onCellVisibilityChanged ); } newView->setIntersection( intersection ); + m_intersectionViews.push_back( newView ); } else { + view->cellVisibilityChanged.disconnect( it->second ); m_intersectionViews.push_back( it->second ); + view->cellVisibilityChanged.connect( it->second, &Rim2dIntersectionView::onCellVisibilityChanged ); } }