Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_interval.h
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_interval.h (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_interval.h
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 14 14 #include <qmetatype.h> 15 15 16 #ifndef QT_NO_DEBUG_STREAM 17 #include <qdebug.h> 18 #endif 19 20 /*! 21 \brief A class representing an interval 22 23 The interval is represented by 2 doubles, the lower and the upper limit. 24 */ 16 /*! 17 \brief A class representing an interval 18 19 The interval is represented by 2 doubles, the lower and the upper limit. 20 */ 25 21 26 22 class QWT_EXPORT QwtInterval 27 23 { 28 public: 24 public: 29 25 /*! 30 Flag indicating if a border is included or excluded 31 \sa setBorderFlags(), borderFlags() 32 */ 26 Flag indicating if a border is included or excluded 27 \sa setBorderFlags(), borderFlags() 28 */ 33 29 enum BorderFlag 34 30 { … … 47 43 48 44 //! Border flags 49 typedef QFlags<BorderFlag>BorderFlags;45 Q_DECLARE_FLAGS( BorderFlags, BorderFlag ) 50 46 51 47 QwtInterval(); … … 60 56 QwtInterval limited( double lowerBound, double upperBound ) const; 61 57 62 bool operator==( const QwtInterval & ) const;63 bool operator!=( const QwtInterval & ) const;58 bool operator==( const QwtInterval& ) const; 59 bool operator!=( const QwtInterval& ) const; 64 60 65 61 void setBorderFlags( BorderFlags ); … … 70 66 71 67 double width() const; 68 long double widthL() const; 72 69 73 70 void setMinValue( double ); … … 75 72 76 73 bool contains( double value ) const; 77 78 bool intersects( const QwtInterval & ) const; 79 QwtInterval intersect( const QwtInterval & ) const; 80 QwtInterval unite( const QwtInterval & ) const; 81 82 QwtInterval operator|( const QwtInterval & ) const; 83 QwtInterval operator&( const QwtInterval & ) const; 84 85 QwtInterval &operator|=( const QwtInterval & ); 86 QwtInterval &operator&=( const QwtInterval & ); 74 bool contains( const QwtInterval& ) const; 75 76 bool intersects( const QwtInterval& ) const; 77 QwtInterval intersect( const QwtInterval& ) const; 78 QwtInterval unite( const QwtInterval& ) const; 79 80 QwtInterval operator|( const QwtInterval& ) const; 81 QwtInterval operator&( const QwtInterval& ) const; 82 83 QwtInterval& operator|=( const QwtInterval& ); 84 QwtInterval& operator&=( const QwtInterval& ); 87 85 88 86 QwtInterval extend( double value ) const; 89 87 QwtInterval operator|( double ) const; 90 QwtInterval &operator|=( double );88 QwtInterval& operator|=( double ); 91 89 92 90 bool isValid() const; … … 96 94 QwtInterval symmetrize( double value ) const; 97 95 98 private: 99 double d_minValue;100 double d_maxValue;101 BorderFlags d_borderFlags;96 private: 97 double m_minValue; 98 double m_maxValue; 99 BorderFlags m_borderFlags; 102 100 }; 103 101 104 Q_DECLARE_TYPEINFO(QwtInterval, Q_MOVABLE_TYPE); 105 106 /*! 107 \brief Default Constructor 108 109 Creates an invalid interval [0.0, -1.0] 110 \sa setInterval(), isValid() 111 */ 112 inline QwtInterval::QwtInterval(): 113 d_minValue( 0.0 ), 114 d_maxValue( -1.0 ), 115 d_borderFlags( IncludeBorders ) 102 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtInterval::BorderFlags ) 103 Q_DECLARE_METATYPE( QwtInterval ) 104 Q_DECLARE_TYPEINFO( QwtInterval, Q_MOVABLE_TYPE ); 105 106 /*! 107 \brief Default Constructor 108 109 Creates an invalid interval [0.0, -1.0] 110 \sa setInterval(), isValid() 111 */ 112 inline QwtInterval::QwtInterval() 113 : m_minValue( 0.0 ) 114 , m_maxValue( -1.0 ) 115 , m_borderFlags( IncludeBorders ) 116 116 { 117 117 } … … 125 125 \param maxValue Maximum value 126 126 \param borderFlags Include/Exclude borders 127 */ 127 */ 128 128 inline QwtInterval::QwtInterval( 129 double minValue, double maxValue, BorderFlags borderFlags ) :130 d_minValue( minValue ),131 d_maxValue( maxValue ),132 d_borderFlags( borderFlags )129 double minValue, double maxValue, BorderFlags borderFlags ) 130 : m_minValue( minValue ) 131 , m_maxValue( maxValue ) 132 , m_borderFlags( borderFlags ) 133 133 { 134 134 } … … 140 140 \param maxValue Maximum value 141 141 \param borderFlags Include/Exclude borders 142 */ 142 */ 143 143 inline void QwtInterval::setInterval( 144 144 double minValue, double maxValue, BorderFlags borderFlags ) 145 145 { 146 d_minValue = minValue;147 d_maxValue = maxValue;148 d_borderFlags = borderFlags;146 m_minValue = minValue; 147 m_maxValue = maxValue; 148 m_borderFlags = borderFlags; 149 149 } 150 150 … … 154 154 \param borderFlags Or'd BorderMode flags 155 155 \sa borderFlags() 156 */ 156 */ 157 157 inline void QwtInterval::setBorderFlags( BorderFlags borderFlags ) 158 158 { 159 d_borderFlags = borderFlags;159 m_borderFlags = borderFlags; 160 160 } 161 161 … … 163 163 \return Border flags 164 164 \sa setBorderFlags() 165 */ 165 */ 166 166 inline QwtInterval::BorderFlags QwtInterval::borderFlags() const 167 167 { 168 return d_borderFlags;168 return m_borderFlags; 169 169 } 170 170 … … 173 173 174 174 \param minValue Minimum value 175 */ 175 */ 176 176 inline void QwtInterval::setMinValue( double minValue ) 177 177 { 178 d_minValue = minValue;178 m_minValue = minValue; 179 179 } 180 180 … … 183 183 184 184 \param maxValue Maximum value 185 */ 185 */ 186 186 inline void QwtInterval::setMaxValue( double maxValue ) 187 187 { 188 d_maxValue = maxValue;188 m_maxValue = maxValue; 189 189 } 190 190 … … 192 192 inline double QwtInterval::minValue() const 193 193 { 194 return d_minValue;194 return m_minValue; 195 195 } 196 196 … … 198 198 inline double QwtInterval::maxValue() const 199 199 { 200 return d_maxValue;200 return m_maxValue; 201 201 } 202 202 … … 207 207 208 208 \return True, when the interval is valid 209 */ 209 */ 210 210 inline bool QwtInterval::isValid() const 211 211 { 212 if ( ( d_borderFlags & ExcludeBorders ) == 0 )213 return d_minValue <=d_maxValue;212 if ( ( m_borderFlags & ExcludeBorders ) == 0 ) 213 return m_minValue <= m_maxValue; 214 214 else 215 return d_minValue <d_maxValue;215 return m_minValue < m_maxValue; 216 216 } 217 217 … … 224 224 \return Interval width 225 225 \sa isValid() 226 */ 226 */ 227 227 inline double QwtInterval::width() const 228 228 { 229 return isValid() ? ( d_maxValue - d_minValue ) : 0.0; 229 return isValid() ? ( m_maxValue - m_minValue ) : 0.0; 230 } 231 232 /*! 233 \brief Return the width of an interval as long double 234 235 The width of invalid intervals is 0.0, otherwise the result is 236 maxValue() - minValue(). 237 238 \return Interval width 239 \sa isValid() 240 */ 241 inline long double QwtInterval::widthL() const 242 { 243 if ( !isValid() ) 244 return 0.0; 245 246 return static_cast< long double >( m_maxValue ) 247 - static_cast< long double >( m_minValue ); 230 248 } 231 249 … … 237 255 238 256 \sa intersect() 239 */ 257 */ 240 258 inline QwtInterval QwtInterval::operator&( 241 const QwtInterval &other ) const259 const QwtInterval& other ) const 242 260 { 243 261 return intersect( other ); … … 251 269 252 270 \sa unite() 253 */ 271 */ 254 272 inline QwtInterval QwtInterval::operator|( 255 const QwtInterval &other ) const273 const QwtInterval& other ) const 256 274 { 257 275 return unite( other ); … … 263 281 \param other Interval to compare with 264 282 \return True, when this and other are equal 265 */ 266 inline bool QwtInterval::operator==( const QwtInterval &other ) const267 { 268 return ( d_minValue == other.d_minValue ) &&269 ( d_maxValue == other.d_maxValue ) &&270 ( d_borderFlags == other.d_borderFlags );283 */ 284 inline bool QwtInterval::operator==( const QwtInterval& other ) const 285 { 286 return ( m_minValue == other.m_minValue ) && 287 ( m_maxValue == other.m_maxValue ) && 288 ( m_borderFlags == other.m_borderFlags ); 271 289 } 272 290 /*! … … 275 293 \param other Interval to compare with 276 294 \return True, when this and other are not equal 277 */ 278 inline bool QwtInterval::operator!=( const QwtInterval &other ) const295 */ 296 inline bool QwtInterval::operator!=( const QwtInterval& other ) const 279 297 { 280 298 return ( !( *this == other ) ); … … 287 305 \return Extended interval 288 306 \sa extend() 289 */ 307 */ 290 308 inline QwtInterval QwtInterval::operator|( double value ) const 291 309 { … … 296 314 inline bool QwtInterval::isNull() const 297 315 { 298 return isValid() && d_minValue >=d_maxValue;299 } 300 301 /*! 302 Invalidate the interval 303 304 The limits are set to interval [0.0, -1.0] 305 \sa isValid() 306 */ 316 return isValid() && m_minValue >= m_maxValue; 317 } 318 319 /*! 320 Invalidate the interval 321 322 The limits are set to interval [0.0, -1.0] 323 \sa isValid() 324 */ 307 325 inline void QwtInterval::invalidate() 308 326 { 309 d_minValue = 0.0; 310 d_maxValue = -1.0; 311 } 312 313 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtInterval::BorderFlags ) 314 Q_DECLARE_METATYPE( QwtInterval ) 327 m_minValue = 0.0; 328 m_maxValue = -1.0; 329 } 315 330 316 331 #ifndef QT_NO_DEBUG_STREAM 317 QWT_EXPORT QDebug operator<<( QDebug, const QwtInterval & );332 QWT_EXPORT QDebug operator<<( QDebug, const QwtInterval& ); 318 333 #endif 319 334
Note:
See TracChangeset
for help on using the changeset viewer.
