contains/fuzzyContains for intervals added
This commit is contained in:
parent
18dd693892
commit
664b141ee4
@ -159,6 +159,26 @@ bool QskIntervalF::fuzzyContains( qreal value ) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QskIntervalF::fuzzyContains( const QskIntervalF& interval ) const
|
||||
{
|
||||
if ( !isValid() || !interval.isValid() )
|
||||
return false;
|
||||
|
||||
if ( ( interval.m_lowerBound < m_lowerBound )
|
||||
&& !qskFuzzyCompare( interval.m_lowerBound, m_lowerBound ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ( interval.m_upperBound > m_upperBound )
|
||||
&& !qskFuzzyCompare( interval.m_upperBound, m_upperBound ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
|
||||
#include <qdebug.h>
|
||||
|
@ -39,7 +39,10 @@ class QSK_EXPORT QskIntervalF
|
||||
void setWidth( qreal ) noexcept;
|
||||
|
||||
constexpr bool contains( qreal value ) const noexcept;
|
||||
constexpr bool contains( const QskIntervalF& ) const noexcept;
|
||||
|
||||
bool fuzzyContains( qreal value ) const;
|
||||
bool fuzzyContains( const QskIntervalF& ) const;
|
||||
|
||||
static constexpr QskIntervalF normalized( qreal value1, qreal value2 ) noexcept;
|
||||
|
||||
@ -150,6 +153,12 @@ inline constexpr bool QskIntervalF::contains( qreal value ) const noexcept
|
||||
return ( value >= m_lowerBound ) && ( value <= m_upperBound );
|
||||
}
|
||||
|
||||
inline constexpr bool QskIntervalF::contains( const QskIntervalF& interval ) const noexcept
|
||||
{
|
||||
return interval.isValid() && contains( interval.m_lowerBound )
|
||||
&& contains( interval.m_upperBound );
|
||||
}
|
||||
|
||||
inline void QskIntervalF::translate( qreal offset ) noexcept
|
||||
{
|
||||
m_lowerBound += offset;
|
||||
|
Loading…
x
Reference in New Issue
Block a user