Use resolution enum in contourmaps (#12113)

* Use resolution enum in contourmaps
This commit is contained in:
jonjenssen 2025-01-31 14:43:34 +01:00 committed by GitHub
parent 19a2c8b63d
commit 08c207e556
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 17 additions and 59 deletions

View File

@ -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;

View File

@ -27,10 +27,10 @@ void caf::AppEnum<RimContourMapResolutionTools::SamplingResolution>::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;
}

View File

@ -15,6 +15,7 @@
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
class RimContourMapResolutionTools
{
@ -23,7 +24,7 @@ public:
{
EXTRA_FINE,
FINE,
BASE,
NORMAL,
COARSE,
EXTRA_COARSE
};

View File

@ -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;
}

View File

@ -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<cvf::Vec4d>& 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<caf::PdmUiDoubleSliderEditorAttribute*>( 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<caf::PdmUiDoubleSliderEditorAttribute*>( 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() );

View File

@ -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<int> kLayers );
@ -141,7 +142,7 @@ private:
std::optional<std::pair<double, double>> valueFilterMinMax() const;
protected:
caf::PdmField<double> m_relativeSampleSpacing;
caf::PdmField<caf::AppEnum<RimContourMapResolutionTools::SamplingResolution>> m_resolution;
caf::PdmField<ResultAggregation> m_resultAggregation;
caf::PdmField<bool> m_showContourLines;

View File

@ -147,7 +147,7 @@ double RimEclipseContourMapProjection::sampleSpacing() const
{
if ( auto mainGrid = ec->mainGrid() )
{
return m_relativeSampleSpacing * mainGrid->characteristicIJCellSize();
return sampleSpacingFactor() * mainGrid->characteristicIJCellSize();
}
}