Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_interval.cpp


Ignore:
Timestamp:
Nov 3, 2026, 10:53:35 AM (3 weeks ago)
Author:
stuerze
Message:

deprecated functions exchanged libs updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_interval.cpp

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    99
    1010#include "qwt_interval.h"
    11 #include "qwt_math.h"
    12 #include <qalgorithms.h>
    13 
    14 /*!
    15   \brief Normalize the limits of the interval
    16 
    17   If maxValue() < minValue() the limits will be inverted.
    18   \return Normalized interval
    19 
    20   \sa isValid(), inverted()
    21 */
     11
     12namespace
     13{
     14    static const struct RegisterQwtInterval
     15    {
     16        inline RegisterQwtInterval() { qRegisterMetaType< QwtInterval >(); }
     17
     18    } qwtRegisterQwtInterval;
     19}
     20
     21/*!
     22   \brief Normalize the limits of the interval
     23
     24   If maxValue() < minValue() the limits will be inverted.
     25   \return Normalized interval
     26
     27   \sa isValid(), inverted()
     28 */
    2229QwtInterval QwtInterval::normalized() const
    2330{
    24     if ( d_minValue > d_maxValue )
     31    if ( m_minValue > m_maxValue )
    2532    {
    2633        return inverted();
    2734    }
    28     if ( d_minValue == d_maxValue && d_borderFlags == ExcludeMinimum )
     35    if ( m_minValue == m_maxValue && m_borderFlags == ExcludeMinimum )
    2936    {
    3037        return inverted();
    … …  
    3542
    3643/*!
    37   Invert the limits of the interval
    38   \return Inverted interval
    39   \sa normalized()
    40 */
     44   Invert the limits of the interval
     45   \return Inverted interval
     46   \sa normalized()
     47 */
    4148QwtInterval QwtInterval::inverted() const
    4249{
    4350    BorderFlags borderFlags = IncludeBorders;
    44     if ( d_borderFlags & ExcludeMinimum )
     51
     52    if ( m_borderFlags & ExcludeMinimum )
    4553        borderFlags |= ExcludeMaximum;
    46     if ( d_borderFlags & ExcludeMaximum )
     54
     55    if ( m_borderFlags & ExcludeMaximum )
    4756        borderFlags |= ExcludeMinimum;
    4857
    49     return QwtInterval( d_maxValue, d_minValue, borderFlags );
    50 }
    51 
    52 /*!
    53   Test if a value is inside an interval
    54 
    55   \param value Value
    56   \return true, if value >= minValue() && value <= maxValue()
    57 */
     58    return QwtInterval( m_maxValue, m_minValue, borderFlags );
     59}
     60
     61/*!
     62   Test if a value is inside an interval
     63
     64   \param value Value
     65   \return true, if value lies inside the boundaries
     66 */
    5867bool QwtInterval::contains( double value ) const
    5968{
    … …  
    6170        return false;
    6271
    63     if ( value < d_minValue || value > d_maxValue )
    64         return false;
    65 
    66     if ( value == d_minValue && d_borderFlags & ExcludeMinimum )
    67         return false;
    68 
    69     if ( value == d_maxValue && d_borderFlags & ExcludeMaximum )
     72    if ( ( value < m_minValue ) || ( value > m_maxValue ) )
     73        return false;
     74
     75    if ( ( value == m_minValue ) && ( m_borderFlags & ExcludeMinimum ) )
     76        return false;
     77
     78    if ( ( value == m_maxValue ) && ( m_borderFlags & ExcludeMaximum ) )
    7079        return false;
    7180
    … …  
    7382}
    7483
     84/*!
     85   Test if an interval is inside an interval
     86
     87   \param interval Interval
     88   \return true, if interval lies inside the boundaries
     89 */
     90bool QwtInterval::contains( const QwtInterval& interval ) const
     91{
     92    if ( !isValid() || !interval.isValid() )
     93        return false;
     94
     95    if ( ( interval.m_minValue < m_minValue ) || ( interval.m_maxValue > m_maxValue ) )
     96        return false;
     97
     98    if ( m_borderFlags )
     99    {
     100        if ( interval.m_minValue == m_minValue )
     101        {
     102            if ( ( m_borderFlags & ExcludeMinimum )
     103                && !( interval.m_borderFlags & ExcludeMinimum ) )
     104            {
     105                return false;
     106            }
     107        }
     108
     109        if ( interval.m_maxValue == m_maxValue )
     110        {
     111            if ( ( m_borderFlags & ExcludeMaximum )
     112                && !( interval.m_borderFlags & ExcludeMaximum ) )
     113            {
     114                return false;
     115            }
     116        }
     117    }
     118
     119    return true;
     120}
     121
    75122//! Unite 2 intervals
    76 QwtInterval QwtInterval::unite( const QwtInterval &other ) const
     123QwtInterval QwtInterval::unite( const QwtInterval& other ) const
    77124{
    78125    /*
    79      If one of the intervals is invalid return the other one.
    80      If both are invalid return an invalid default interval
     126       If one of the intervals is invalid return the other one.
     127       If both are invalid return an invalid default interval
    81128     */
    82129    if ( !isValid() )
    … …  
    94141
    95142    // minimum
    96     if ( d_minValue < other.minValue() )
    97     {
    98         united.setMinValue( d_minValue );
    99         flags &= d_borderFlags & ExcludeMinimum;
    100     }
    101     else if ( other.minValue() < d_minValue )
     143    if ( m_minValue < other.minValue() )
     144    {
     145        united.setMinValue( m_minValue );
     146        flags &= m_borderFlags & ExcludeMinimum;
     147    }
     148    else if ( other.minValue() < m_minValue )
    102149    {
    103150        united.setMinValue( other.minValue() );
    104151        flags &= other.borderFlags() & ExcludeMinimum;
    105152    }
    106     else // d_minValue == other.minValue()
    107     {
    108         united.setMinValue( d_minValue );
    109         flags &= ( d_borderFlags & other.borderFlags() ) & ExcludeMinimum;
     153    else // m_minValue == other.minValue()
     154    {
     155        united.setMinValue( m_minValue );
     156        flags &= ( m_borderFlags & other.borderFlags() ) & ExcludeMinimum;
    110157    }
    111158
    112159    // maximum
    113     if ( d_maxValue > other.maxValue() )
    114     {
    115         united.setMaxValue( d_maxValue );
    116         flags &= d_borderFlags & ExcludeMaximum;
    117     }
    118     else if ( other.maxValue() > d_maxValue )
     160    if ( m_maxValue > other.maxValue() )
     161    {
     162        united.setMaxValue( m_maxValue );
     163        flags &= m_borderFlags & ExcludeMaximum;
     164    }
     165    else if ( other.maxValue() > m_maxValue )
    119166    {
    120167        united.setMaxValue( other.maxValue() );
    121168        flags &= other.borderFlags() & ExcludeMaximum;
    122169    }
    123     else // d_maxValue == other.maxValue() )
    124     {
    125         united.setMaxValue( d_maxValue );
    126         flags &= d_borderFlags & other.borderFlags() & ExcludeMaximum;
     170    else // m_maxValue == other.maxValue() )
     171    {
     172        united.setMaxValue( m_maxValue );
     173        flags &= m_borderFlags & other.borderFlags() & ExcludeMaximum;
    127174    }
    128175
    … …  
    132179
    133180/*!
    134   \brief Intersect 2 intervals
    135 
    136   \param other Interval to be intersect with
    137   \return Intersection
    138  */
    139 QwtInterval QwtInterval::intersect( const QwtInterval &other ) const
     181   \brief Intersect 2 intervals
     182
     183   \param other Interval to be intersect with
     184   \return Intersection
     185 */
     186QwtInterval QwtInterval::intersect( const QwtInterval& other ) const
    140187{
    141188    if ( !other.isValid() || !isValid() )
    … …  
    199246
    200247/*!
    201   \brief Unite this interval with the given interval.
    202 
    203   \param other Interval to be united with
    204   \return This interval
    205  */
    206 QwtInterval& QwtInterval::operator|=( const QwtInterval &other )
     248   \brief Unite this interval with the given interval.
     249
     250   \param other Interval to be united with
     251   \return This interval
     252 */
     253QwtInterval& QwtInterval::operator|=( const QwtInterval& other )
    207254{
    208255    *this = *this | other;
    … …  
    211258
    212259/*!
    213   \brief Intersect this interval with the given interval.
    214 
    215   \param other Interval to be intersected with
    216   \return This interval
    217  */
    218 QwtInterval& QwtInterval::operator&=( const QwtInterval &other )
     260   \brief Intersect this interval with the given interval.
     261
     262   \param other Interval to be intersected with
     263   \return This interval
     264 */
     265QwtInterval& QwtInterval::operator&=( const QwtInterval& other )
    219266{
    220267    *this = *this & other;
    … …  
    223270
    224271/*!
    225   \brief Test if two intervals overlap
    226 
    227   \param other Interval
    228   \return True, when the intervals are intersecting
    229 */
    230 bool QwtInterval::intersects( const QwtInterval &other ) const
     272   \brief Test if two intervals overlap
     273
     274   \param other Interval
     275   \return True, when the intervals are intersecting
     276 */
     277bool QwtInterval::intersects( const QwtInterval& other ) const
    231278{
    232279    if ( !isValid() || !other.isValid() )
    … …  
    244291    }
    245292    else if ( i1.minValue() == i2.minValue() &&
    246               i1.borderFlags() & ExcludeMinimum )
     293        i1.borderFlags() & ExcludeMinimum )
    247294    {
    248295        qSwap( i1, i2 );
    … …  
    256303    {
    257304        return !( ( i1.borderFlags() & ExcludeMaximum ) ||
    258             ( i2.borderFlags() & ExcludeMinimum ) );
     305               ( i2.borderFlags() & ExcludeMinimum ) );
    259306    }
    260307    return false;
    … …  
    262309
    263310/*!
    264   Adjust the limit that is closer to value, so that value becomes
    265   the center of the interval.
    266 
    267   \param value Center
    268   \return Interval with value as center
    269 */
     311   Adjust the limit that is closer to value, so that value becomes
     312   the center of the interval.
     313
     314   \param value Center
     315   \return Interval with value as center
     316 */
    270317QwtInterval QwtInterval::symmetrize( double value ) const
    271318{
    … …  
    274321
    275322    const double delta =
    276         qMax( qAbs( value - d_maxValue ), qAbs( value - d_minValue ) );
     323        qMax( qAbs( value - m_maxValue ), qAbs( value - m_minValue ) );
    277324
    278325    return QwtInterval( value - delta, value + delta );
    … …  
    280327
    281328/*!
    282   Limit the interval, keeping the border modes
    283 
    284   \param lowerBound Lower limit
    285   \param upperBound Upper limit
    286 
    287   \return Limited interval
    288 */
     329   Limit the interval, keeping the border modes
     330
     331   \param lowerBound Lower limit
     332   \param upperBound Upper limit
     333
     334   \return Limited interval
     335 */
    289336QwtInterval QwtInterval::limited( double lowerBound, double upperBound ) const
    290337{
    … …  
    292339        return QwtInterval();
    293340
    294     double minValue = qMax( d_minValue, lowerBound );
     341    double minValue = qMax( m_minValue, lowerBound );
    295342    minValue = qMin( minValue, upperBound );
    296343
    297     double maxValue = qMax( d_maxValue, lowerBound );
     344    double maxValue = qMax( m_maxValue, lowerBound );
    298345    maxValue = qMin( maxValue, upperBound );
    299346
    300     return QwtInterval( minValue, maxValue, d_borderFlags );
    301 }
    302 
    303 /*!
    304   \brief Extend the interval
    305 
    306   If value is below minValue(), value becomes the lower limit.
    307   If value is above maxValue(), value becomes the upper limit.
    308 
    309   extend() has no effect for invalid intervals
    310 
    311   \param value Value
    312   \return extended interval
    313 
    314   \sa isValid()
    315 */
     347    return QwtInterval( minValue, maxValue, m_borderFlags );
     348}
     349
     350/*!
     351   \brief Extend the interval
     352
     353   If value is below minValue(), value becomes the lower limit.
     354   If value is above maxValue(), value becomes the upper limit.
     355
     356   extend() has no effect for invalid intervals
     357
     358   \param value Value
     359   \return extended interval
     360
     361   \sa isValid()
     362 */
    316363QwtInterval QwtInterval::extend( double value ) const
    317364{
    … …  
    319366        return *this;
    320367
    321     return QwtInterval( qMin( value, d_minValue ),
    322         qMax( value, d_maxValue ), d_borderFlags );
    323 }
    324 
    325 /*!
    326   Extend an interval
    327 
    328   \param value Value
    329   \return Reference of the extended interval
    330 
    331   \sa extend()
    332 */
     368    return QwtInterval( qMin( value, m_minValue ),
     369        qMax( value, m_maxValue ), m_borderFlags );
     370}
     371
     372/*!
     373   Extend an interval
     374
     375   \param value Value
     376   \return Reference of the extended interval
     377
     378   \sa extend()
     379 */
    333380QwtInterval& QwtInterval::operator|=( double value )
    334381{
    … …  
    339386#ifndef QT_NO_DEBUG_STREAM
    340387
    341 QDebug operator<<( QDebug debug, const QwtInterval &interval )
     388#include <qdebug.h>
     389
     390QDebug operator<<( QDebug debug, const QwtInterval& interval )
    342391{
    343392    const int flags = interval.borderFlags();
    344393
    345394    debug.nospace() << "QwtInterval("
    346         << ( ( flags & QwtInterval::ExcludeMinimum ) ? "]" : "[" )
    347         << interval.minValue() << "," << interval.maxValue()
    348         << ( ( flags & QwtInterval::ExcludeMaximum ) ? "[" : "]" )
    349         << ")";
     395                    << ( ( flags& QwtInterval::ExcludeMinimum ) ? "]" : "[" )
     396                    << interval.minValue() << "," << interval.maxValue()
     397                    << ( ( flags& QwtInterval::ExcludeMaximum ) ? "[" : "]" )
     398                    << ")";
    350399
    351400    return debug.space();
Note: See TracChangeset for help on using the changeset viewer.