From 08c207e556800da21f1c05f8e3f35f7de924b830 Mon Sep 17 00:00:00 2001 From: jonjenssen <69144954+jonjenssen@users.noreply.github.com> Date: Fri, 31 Jan 2025 14:43:34 +0100 Subject: [PATCH] Use resolution enum in contourmaps (#12113) * Use resolution enum in contourmaps --- .../Commands/RicNewContourMapViewFeature.cpp | 25 ---------------- .../RimContourMapResolutionTools.cpp | 6 ++-- .../ContourMap/RimContourMapResolutionTools.h | 3 +- .../RimGeoMechContourMapProjection.cpp | 2 +- .../RimContourMapProjection.cpp | 29 ++++--------------- .../RimContourMapProjection.h | 9 +++--- .../RimEclipseContourMapProjection.cpp | 2 +- 7 files changed, 17 insertions(+), 59 deletions(-) diff --git a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp index 458bb19874..8789136d6e 100644 --- a/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp @@ -60,9 +60,6 @@ CAF_CMD_SOURCE_INIT( RicNewContourMapViewFeature, "RicNewContourMapViewFeature" ); -const size_t mediumSamplingThresholdCellCount = 500000u; -const size_t largeSamplingThresholdCellCount = 5000000u; - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -245,17 +242,6 @@ RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMapFr caf::PdmDefaultObjectFactory::instance() ) ); CVF_ASSERT( contourMap ); - const RigActiveCellInfo* activeCellInfo = eclipseCase->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); - size_t activeCellCount = activeCellInfo->reservoirActiveCellCount(); - if ( activeCellCount >= largeSamplingThresholdCellCount ) - { - contourMap->contourMapProjection()->setSampleSpacingFactor( 1.5 ); - } - else if ( activeCellCount >= mediumSamplingThresholdCellCount ) - { - contourMap->contourMapProjection()->setSampleSpacingFactor( 1.2 ); - } - contourMap->setEclipseCase( eclipseCase ); auto col = RiuGuiTheme::getColorByVariableName( "backgroundColor2" ); @@ -330,17 +316,6 @@ RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMap( size_t i = eclipseCase->contourMapCollection()->views().size(); contourMap->setName( QString( "Contour Map %1" ).arg( i + 1 ) ); - const RigActiveCellInfo* activeCellInfo = eclipseCase->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); - size_t activeCellCount = activeCellInfo->reservoirActiveCellCount(); - if ( activeCellCount >= largeSamplingThresholdCellCount ) - { - contourMap->contourMapProjection()->setSampleSpacingFactor( 1.5 ); - } - else if ( activeCellCount >= mediumSamplingThresholdCellCount ) - { - contourMap->contourMapProjection()->setSampleSpacingFactor( 1.2 ); - } - contourMap->faultCollection()->setActive( false ); contourMap->wellCollection()->isActive = false; diff --git a/ApplicationLibCode/ProjectDataModel/ContourMap/RimContourMapResolutionTools.cpp b/ApplicationLibCode/ProjectDataModel/ContourMap/RimContourMapResolutionTools.cpp index 6eebc41c2c..4b03082f8b 100644 --- a/ApplicationLibCode/ProjectDataModel/ContourMap/RimContourMapResolutionTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/ContourMap/RimContourMapResolutionTools.cpp @@ -27,10 +27,10 @@ void caf::AppEnum::setUp() { addItem( RimContourMapResolutionTools::SamplingResolution::EXTRA_FINE, "Extra Fine", "Extra Fine" ); addItem( RimContourMapResolutionTools::SamplingResolution::FINE, "Fine", "Fine" ); - addItem( RimContourMapResolutionTools::SamplingResolution::BASE, "Base", "Normal" ); + addItem( RimContourMapResolutionTools::SamplingResolution::NORMAL, "Normal", "Normal" ); addItem( RimContourMapResolutionTools::SamplingResolution::COARSE, "Coarse", "Coarse" ); addItem( RimContourMapResolutionTools::SamplingResolution::EXTRA_COARSE, "Extra Coarse", "Extra Coarse" ); - setDefault( RimContourMapResolutionTools::SamplingResolution::BASE ); + setDefault( RimContourMapResolutionTools::SamplingResolution::NORMAL ); } }; // namespace caf @@ -49,7 +49,7 @@ double RimContourMapResolutionTools::resolutionFromEnumValue( SamplingResolution return 5.0; case RimContourMapResolutionTools::SamplingResolution::EXTRA_COARSE: return 8.0; - case RimContourMapResolutionTools::SamplingResolution::BASE: + case RimContourMapResolutionTools::SamplingResolution::NORMAL: default: return 2.0; } diff --git a/ApplicationLibCode/ProjectDataModel/ContourMap/RimContourMapResolutionTools.h b/ApplicationLibCode/ProjectDataModel/ContourMap/RimContourMapResolutionTools.h index 089c5cf90a..214260331b 100644 --- a/ApplicationLibCode/ProjectDataModel/ContourMap/RimContourMapResolutionTools.h +++ b/ApplicationLibCode/ProjectDataModel/ContourMap/RimContourMapResolutionTools.h @@ -15,6 +15,7 @@ // for more details. // ///////////////////////////////////////////////////////////////////////////////// +#pragma once class RimContourMapResolutionTools { @@ -23,7 +24,7 @@ public: { EXTRA_FINE, FINE, - BASE, + NORMAL, COARSE, EXTRA_COARSE }; diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp index 4333f217d0..2d8ec29710 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp @@ -146,7 +146,7 @@ double RimGeoMechContourMapProjection::sampleSpacing() const RimGeoMechCase* geoMechCase = this->geoMechCase(); if ( geoMechCase ) { - return m_relativeSampleSpacing * geoMechCase->characteristicCellSize(); + return sampleSpacingFactor() * geoMechCase->characteristicCellSize(); } return 0.0; } diff --git a/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.cpp b/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.cpp index fd986f30d6..624423dbf4 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.cpp @@ -75,8 +75,8 @@ RimContourMapProjection::RimContourMapProjection() { CAF_PDM_InitObject( "RimContourMapProjection", ":/2DMapProjection16x16.png" ); - CAF_PDM_InitField( &m_relativeSampleSpacing, "SampleSpacing", 0.9, "Sample Spacing Factor" ); - m_relativeSampleSpacing.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); + CAF_PDM_InitFieldNoDefault( &m_resolution, "Resolution", "Sampling Resolution" ); + m_resolution.setValue( RimContourMapResolutionTools::SamplingResolution::FINE ); CAF_PDM_InitFieldNoDefault( &m_resultAggregation, "ResultAggregation", "Result Aggregation" ); @@ -222,15 +222,7 @@ const std::vector& RimContourMapProjection::trianglesWithVertexValue //-------------------------------------------------------------------------------------------------- double RimContourMapProjection::sampleSpacingFactor() const { - return m_relativeSampleSpacing(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimContourMapProjection::setSampleSpacingFactor( double spacingFactor ) -{ - m_relativeSampleSpacing = spacingFactor; + return RimContourMapResolutionTools::resolutionFromEnumValue( m_resolution() ); } //-------------------------------------------------------------------------------------------------- @@ -532,7 +524,7 @@ void RimContourMapProjection::fieldChangedByUi( const caf::PdmFieldHandle* chang { clearGeometry(); } - else if ( changedField == &m_relativeSampleSpacing ) + else if ( changedField == &m_resolution ) { clearGridMapping(); clearResults(); @@ -548,17 +540,6 @@ void RimContourMapProjection::fieldChangedByUi( const caf::PdmFieldHandle* chang //-------------------------------------------------------------------------------------------------- void RimContourMapProjection::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) { - if ( &m_relativeSampleSpacing == field ) - { - if ( auto myAttr = dynamic_cast( attribute ) ) - { - myAttr->m_minimum = 0.2; - myAttr->m_maximum = 20.0; - myAttr->m_sliderTickCount = 20; - myAttr->m_delaySliderUpdateUntilRelease = true; - } - } - if ( &m_lowerThreshold == field || &m_upperThreshold == field ) { if ( auto myAttr = dynamic_cast( attribute ) ) @@ -578,7 +559,7 @@ void RimContourMapProjection::defineUiOrdering( QString uiConfigName, caf::PdmUi caf::PdmUiGroup* mainGroup = uiOrdering.addNewGroup( "Projection Settings" ); mainGroup->add( &m_resultAggregation ); legendConfig()->uiOrdering( "NumLevelsOnly", *mainGroup ); - mainGroup->add( &m_relativeSampleSpacing ); + mainGroup->add( &m_resolution ); mainGroup->add( &m_showContourLines ); mainGroup->add( &m_showContourLabels ); m_showContourLabels.uiCapability()->setUiReadOnly( !m_showContourLines() ); diff --git a/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.h b/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.h index 25c61802f8..d678f49c47 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.h +++ b/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.h @@ -18,6 +18,7 @@ #pragma once +#include "ContourMap/RimContourMapResolutionTools.h" #include "RimCheckableNamedObject.h" #include "RimIntersectionEnums.h" @@ -62,9 +63,9 @@ public: virtual double sampleSpacing() const = 0; double sampleSpacingFactor() const; - void setSampleSpacingFactor( double spacingFactor ); - bool showContourLines() const; - bool showContourLabels() const; + + bool showContourLines() const; + bool showContourLabels() const; // k layer filter, only consider kLayers in the given set (0-based index) void useKLayers( std::set kLayers ); @@ -141,7 +142,7 @@ private: std::optional> valueFilterMinMax() const; protected: - caf::PdmField m_relativeSampleSpacing; + caf::PdmField> m_resolution; caf::PdmField m_resultAggregation; caf::PdmField m_showContourLines; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp index c1d45020e1..1b723fb578 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp @@ -147,7 +147,7 @@ double RimEclipseContourMapProjection::sampleSpacing() const { if ( auto mainGrid = ec->mainGrid() ) { - return m_relativeSampleSpacing * mainGrid->characteristicIJCellSize(); + return sampleSpacingFactor() * mainGrid->characteristicIJCellSize(); } }