mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add step support to range text format (#10311)
* Add step support to range text format * Add step support to integer selection filter
This commit is contained in:
@@ -25,17 +25,20 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCellFilterInterval::RimCellFilterInterval( size_t minIncludeVal, size_t maxIncludeVal )
|
||||
RimCellFilterInterval::RimCellFilterInterval( size_t minIncludeVal, size_t maxIncludeVal, size_t step )
|
||||
: m_minIncludeVal( minIncludeVal )
|
||||
, m_maxIncludeVal( maxIncludeVal )
|
||||
, m_step( step )
|
||||
{
|
||||
m_valid = maxIncludeVal >= minIncludeVal;
|
||||
m_valid = m_valid && minIncludeVal > 0;
|
||||
m_valid = m_valid && step > 0;
|
||||
}
|
||||
|
||||
RimCellFilterInterval::RimCellFilterInterval( size_t includeVal )
|
||||
: m_minIncludeVal( includeVal )
|
||||
, m_maxIncludeVal( includeVal )
|
||||
, m_step( 1 )
|
||||
{
|
||||
m_valid = includeVal > 0;
|
||||
}
|
||||
@@ -52,7 +55,12 @@ RimCellFilterInterval::~RimCellFilterInterval()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimCellFilterInterval::isIncluded( size_t val ) const
|
||||
{
|
||||
if ( ( val >= m_minIncludeVal ) && ( val <= m_maxIncludeVal ) ) return m_valid;
|
||||
if ( ( val < m_minIncludeVal ) || ( val > m_maxIncludeVal ) ) return false;
|
||||
|
||||
size_t tmp = val - m_minIncludeVal;
|
||||
|
||||
if ( m_valid && ( tmp % m_step == 0 ) ) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -99,7 +107,8 @@ size_t RimCellFilterIntervalTool::numberFromPart( std::string strVal ) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
// Define a range with the comma separated format A,B,C-D, etc., i.e. 1,4,5-8
|
||||
// Only positive numbers are supported.
|
||||
// Only numbers > 0 are supported.
|
||||
// For a range with increment > 1, use i.e. 4-8:2
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCellFilterIntervalTool::setInterval( bool enabled, std::string intervalText )
|
||||
{
|
||||
@@ -113,7 +122,14 @@ void RimCellFilterIntervalTool::setInterval( bool enabled, std::string intervalT
|
||||
|
||||
for ( auto& part : parts )
|
||||
{
|
||||
QStringList minmax = RiaTextStringTools::splitSkipEmptyParts( part, "-" );
|
||||
QStringList rangeStep = RiaTextStringTools::splitSkipEmptyParts( part, ":" );
|
||||
QStringList minmax = RiaTextStringTools::splitSkipEmptyParts( rangeStep[0], "-" );
|
||||
size_t step = 1;
|
||||
if ( rangeStep.size() == 2 )
|
||||
{
|
||||
step = numberFromPart( rangeStep[1].toStdString() );
|
||||
}
|
||||
|
||||
switch ( minmax.size() )
|
||||
{
|
||||
case 1:
|
||||
@@ -121,7 +137,7 @@ void RimCellFilterIntervalTool::setInterval( bool enabled, std::string intervalT
|
||||
break;
|
||||
case 2:
|
||||
m_intervals.push_back(
|
||||
RimCellFilterInterval( numberFromPart( minmax[0].toStdString() ), numberFromPart( minmax[1].toStdString() ) ) );
|
||||
RimCellFilterInterval( numberFromPart( minmax[0].toStdString() ), numberFromPart( minmax[1].toStdString() ), step ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -24,7 +24,7 @@
|
||||
class RimCellFilterInterval
|
||||
{
|
||||
public:
|
||||
RimCellFilterInterval( size_t minIncludeVal, size_t maxIncludeVal );
|
||||
RimCellFilterInterval( size_t minIncludeVal, size_t maxIncludeVal, size_t step = 1 );
|
||||
RimCellFilterInterval( size_t includeVal );
|
||||
~RimCellFilterInterval();
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
private:
|
||||
size_t m_minIncludeVal;
|
||||
size_t m_maxIncludeVal;
|
||||
size_t m_step;
|
||||
bool m_valid;
|
||||
};
|
||||
|
||||
|
@@ -153,7 +153,7 @@ RimPolygonFilter::RimPolygonFilter()
|
||||
CAF_PDM_InitField( &m_enableFiltering, "EnableFiltering", false, "Enable Filter" );
|
||||
|
||||
CAF_PDM_InitField( &m_enableKFilter, "EnableKFilter", false, "Enable K Range Filter" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_kFilterStr, "KRangeFilter", "K Range Filter", "", "Example: 2,4,10-20,31", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_kFilterStr, "KRangeFilter", "K Range Filter", "", "Example: 2,4-6,10-20:2", "" );
|
||||
|
||||
CAF_PDM_InitField( &m_polygonPlaneDepth, "PolygonPlaneDepth", 0.0, "Polygon Plane Depth" );
|
||||
CAF_PDM_InitField( &m_lockPolygonToPlane, "LockPolygon", false, "Lock Polygon to Plane" );
|
||||
|
@@ -268,12 +268,12 @@ RimExtrudedCurveIntersection::RimExtrudedCurveIntersection()
|
||||
m_collectionDepthFilterType.uiCapability()->setUiHidden( true );
|
||||
|
||||
CAF_PDM_InitField( &m_enableKFilter, "EnableKFilter", false, "Enable K Range Filter" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_kFilterText, "KRangeFilter", "K Range Filter", "", "Example: 2,4,10-20,31", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_kFilterText, "KRangeFilter", "K Range Filter", "", "Example: 2,4-6,10-30:2", "" );
|
||||
|
||||
CAF_PDM_InitField( &m_kFilterCollectionOverride, "KFilterCollectionOverride", false, "K Range Filter is Controlled by Intersection Collection" );
|
||||
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_kFilterCollectionOverride );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_kFilterCollectionText, "KRangeCollectionFilter", "Collection K Range Filter", "", "Example: 2,4,10-20,31", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_kFilterCollectionText, "KRangeCollectionFilter", "Collection K Range Filter", "", "Example: 2,4-6,10-30:2", "" );
|
||||
m_kFilterCollectionText.uiCapability()->setUiHidden( true );
|
||||
|
||||
setDeletable( true );
|
||||
|
@@ -74,7 +74,7 @@ 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,10-20,31", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_kFilterStr, "KRangeFilter", "K Range Filter", "", "Example: 2,4-6,10-30:2", "" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user