Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_scale_div.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_scale_div.cpp (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_scale_div.cpp
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 9 9 10 10 #include "qwt_scale_div.h" 11 #include "qwt_math.h" 12 #include <qalgorithms.h> 13 14 /*! 15 Construct a division without ticks 16 17 \param lowerBound First boundary 18 \param upperBound Second boundary 19 20 \note lowerBound might be greater than upperBound for inverted scales 21 */ 22 QwtScaleDiv::QwtScaleDiv( double lowerBound, double upperBound ): 23 d_lowerBound( lowerBound ), 24 d_upperBound( upperBound ) 25 { 26 } 27 28 /*! 29 Construct a scale division 30 31 \param interval Interval 32 \param ticks List of major, medium and minor ticks 33 */ 34 QwtScaleDiv::QwtScaleDiv( const QwtInterval &interval, 35 QList<double> ticks[NTickTypes] ): 36 d_lowerBound( interval.minValue() ), 37 d_upperBound( interval.maxValue() ) 11 #include "qwt_interval.h" 12 13 /*! 14 Construct a division without ticks 15 16 \param lowerBound First boundary 17 \param upperBound Second boundary 18 19 \note lowerBound might be greater than upperBound for inverted scales 20 */ 21 QwtScaleDiv::QwtScaleDiv( double lowerBound, double upperBound ) 22 : m_lowerBound( lowerBound ) 23 , m_upperBound( upperBound ) 24 { 25 } 26 27 /*! 28 Construct a scale division 29 30 \param interval Interval 31 \param ticks List of major, medium and minor ticks 32 */ 33 QwtScaleDiv::QwtScaleDiv( const QwtInterval& interval, 34 QList< double > ticks[NTickTypes] ) 35 : m_lowerBound( interval.minValue() ) 36 , m_upperBound( interval.maxValue() ) 38 37 { 39 38 for ( int i = 0; i < NTickTypes; i++ ) 40 d_ticks[i] = ticks[i];41 } 42 43 /*! 44 Construct a scale division 45 46 \param lowerBound First boundary 47 \param upperBound Second boundary 48 \param ticks List of major, medium and minor ticks 49 50 \note lowerBound might be greater than upperBound for inverted scales 51 */ 39 m_ticks[i] = ticks[i]; 40 } 41 42 /*! 43 Construct a scale division 44 45 \param lowerBound First boundary 46 \param upperBound Second boundary 47 \param ticks List of major, medium and minor ticks 48 49 \note lowerBound might be greater than upperBound for inverted scales 50 */ 52 51 QwtScaleDiv::QwtScaleDiv( double lowerBound, double upperBound, 53 QList< double> ticks[NTickTypes] ):54 d_lowerBound( lowerBound ),55 d_upperBound( upperBound )52 QList< double > ticks[NTickTypes] ) 53 : m_lowerBound( lowerBound ) 54 , m_upperBound( upperBound ) 56 55 { 57 56 for ( int i = 0; i < NTickTypes; i++ ) 58 d_ticks[i] = ticks[i];59 } 60 61 /*! 62 Construct a scale division 63 64 \param lowerBound First boundary 65 \param upperBound Second boundary 66 \param minorTicks List of minor ticks 67 \param mediumTicks List medium ticks 68 \param majorTicks List of major ticks 69 70 \note lowerBound might be greater than upperBound for inverted scales 71 */ 57 m_ticks[i] = ticks[i]; 58 } 59 60 /*! 61 Construct a scale division 62 63 \param lowerBound First boundary 64 \param upperBound Second boundary 65 \param minorTicks List of minor ticks 66 \param mediumTicks List medium ticks 67 \param majorTicks List of major ticks 68 69 \note lowerBound might be greater than upperBound for inverted scales 70 */ 72 71 QwtScaleDiv::QwtScaleDiv( double lowerBound, double upperBound, 73 const QList< double> &minorTicks,74 const QList< double> &mediumTicks,75 const QList< double> &majorTicks ):76 d_lowerBound( lowerBound ),77 d_upperBound( upperBound )78 { 79 d_ticks[ MinorTick ] = minorTicks;80 d_ticks[ MediumTick ] = mediumTicks;81 d_ticks[ MajorTick ] = majorTicks;82 } 83 84 /*! 85 Change the interval 86 87 \param lowerBound First boundary 88 \param upperBound Second boundary 89 90 \note lowerBound might be greater than upperBound for inverted scales 91 */ 72 const QList< double >& minorTicks, 73 const QList< double >& mediumTicks, 74 const QList< double >& majorTicks ) 75 : m_lowerBound( lowerBound ) 76 , m_upperBound( upperBound ) 77 { 78 m_ticks[ MinorTick ] = minorTicks; 79 m_ticks[ MediumTick ] = mediumTicks; 80 m_ticks[ MajorTick ] = majorTicks; 81 } 82 83 /*! 84 Change the interval 85 86 \param lowerBound First boundary 87 \param upperBound Second boundary 88 89 \note lowerBound might be greater than upperBound for inverted scales 90 */ 92 91 void QwtScaleDiv::setInterval( double lowerBound, double upperBound ) 93 92 { 94 d_lowerBound = lowerBound;95 d_upperBound = upperBound;93 m_lowerBound = lowerBound; 94 m_upperBound = upperBound; 96 95 } 97 96 … … 100 99 101 100 \param interval Interval 102 */ 103 void QwtScaleDiv::setInterval( const QwtInterval &interval )104 { 105 d_lowerBound = interval.minValue();106 d_upperBound = interval.maxValue();107 } 108 109 /*! 110 \return lowerBound -> upperBound 111 */ 101 */ 102 void QwtScaleDiv::setInterval( const QwtInterval& interval ) 103 { 104 m_lowerBound = interval.minValue(); 105 m_upperBound = interval.maxValue(); 106 } 107 108 /*! 109 \return lowerBound -> upperBound 110 */ 112 111 QwtInterval QwtScaleDiv::interval() const 113 112 { 114 return QwtInterval( d_lowerBound,d_upperBound );115 } 116 117 /*! 118 Set the first boundary 119 120 \param lowerBound First boundary 121 \sa lowerB iound(), setUpperBound()113 return QwtInterval( m_lowerBound, m_upperBound ); 114 } 115 116 /*! 117 Set the first boundary 118 119 \param lowerBound First boundary 120 \sa lowerBound(), setUpperBound() 122 121 */ 123 122 void QwtScaleDiv::setLowerBound( double lowerBound ) 124 123 { 125 d_lowerBound = lowerBound;126 } 127 128 /*! 129 \return First boundary 130 \sa upperBound() 131 */ 124 m_lowerBound = lowerBound; 125 } 126 127 /*! 128 \return First boundary 129 \sa upperBound() 130 */ 132 131 double QwtScaleDiv::lowerBound() const 133 132 { 134 return d_lowerBound;135 } 136 137 /*! 138 Set the second boundary 139 140 \param upperBound Second boundary 141 \sa upperBound(), setLowerBound() 133 return m_lowerBound; 134 } 135 136 /*! 137 Set the second boundary 138 139 \param upperBound Second boundary 140 \sa upperBound(), setLowerBound() 142 141 */ 143 142 void QwtScaleDiv::setUpperBound( double upperBound ) 144 143 { 145 d_upperBound = upperBound;146 } 147 148 /*! 149 \return upper bound 150 \sa lowerBound() 151 */ 144 m_upperBound = upperBound; 145 } 146 147 /*! 148 \return upper bound 149 \sa lowerBound() 150 */ 152 151 double QwtScaleDiv::upperBound() const 153 152 { 154 return d_upperBound;155 } 156 157 /*! 158 \return upperBound() - lowerBound() 159 */ 153 return m_upperBound; 154 } 155 156 /*! 157 \return upperBound() - lowerBound() 158 */ 160 159 double QwtScaleDiv::range() const 161 160 { 162 return d_upperBound -d_lowerBound;163 } 164 165 /*! 166 \brief Equality operator 167 \return true if this instance is equal to other 168 */ 169 bool QwtScaleDiv::operator==( const QwtScaleDiv &other ) const170 { 171 if ( d_lowerBound != other.d_lowerBound ||172 d_upperBound != other.d_upperBound )161 return m_upperBound - m_lowerBound; 162 } 163 164 /*! 165 \brief Equality operator 166 \return true if this instance is equal to other 167 */ 168 bool QwtScaleDiv::operator==( const QwtScaleDiv& other ) const 169 { 170 if ( m_lowerBound != other.m_lowerBound || 171 m_upperBound != other.m_upperBound ) 173 172 { 174 173 return false; … … 177 176 for ( int i = 0; i < NTickTypes; i++ ) 178 177 { 179 if ( d_ticks[i] != other.d_ticks[i] )178 if ( m_ticks[i] != other.m_ticks[i] ) 180 179 return false; 181 180 } … … 185 184 186 185 /*! 187 \brief Inequality 188 \return true if this instance is not equal to other 189 */ 190 bool QwtScaleDiv::operator!=( const QwtScaleDiv &other ) const186 \brief Inequality 187 \return true if this instance is not equal to other 188 */ 189 bool QwtScaleDiv::operator!=( const QwtScaleDiv& other ) const 191 190 { 192 191 return ( !( *this == other ) ); … … 196 195 bool QwtScaleDiv::isEmpty() const 197 196 { 198 return ( d_lowerBound ==d_upperBound );197 return ( m_lowerBound == m_upperBound ); 199 198 } 200 199 … … 202 201 bool QwtScaleDiv::isIncreasing() const 203 202 { 204 return d_lowerBound <=d_upperBound;205 } 206 207 /*! 208 Return if a value is between lowerBound() and upperBound() 209 210 \param value Value 211 \return true/false 212 */ 203 return m_lowerBound <= m_upperBound; 204 } 205 206 /*! 207 Return if a value is between lowerBound() and upperBound() 208 209 \param value Value 210 \return true/false 211 */ 213 212 bool QwtScaleDiv::contains( double value ) const 214 213 { 215 const double min = qMin( d_lowerBound,d_upperBound );216 const double max = qMax( d_lowerBound,d_upperBound );214 const double min = qMin( m_lowerBound, m_upperBound ); 215 const double max = qMax( m_lowerBound, m_upperBound ); 217 216 218 217 return value >= min && value <= max; … … 225 224 void QwtScaleDiv::invert() 226 225 { 227 qSwap( d_lowerBound,d_upperBound );226 qSwap( m_lowerBound, m_upperBound ); 228 227 229 228 for ( int i = 0; i < NTickTypes; i++ ) 230 229 { 231 QList< double>& ticks =d_ticks[i];230 QList< double >& ticks = m_ticks[i]; 232 231 233 232 const int size = ticks.count(); … … 240 239 241 240 /*! 242 \return A scale division with inverted boundaries and ticks 243 \sa invert() 241 \return A scale division with inverted boundaries and ticks 242 \sa invert() 244 243 */ 245 244 QwtScaleDiv QwtScaleDiv::inverted() const … … 261 260 262 261 \note lowerBound might be greater than upperBound for inverted scales 263 */ 262 */ 264 263 QwtScaleDiv QwtScaleDiv::bounded( 265 264 double lowerBound, double upperBound ) const … … 273 272 for ( int tickType = 0; tickType < QwtScaleDiv::NTickTypes; tickType++ ) 274 273 { 275 const QList< double> &ticks =d_ticks[ tickType ];276 277 QList< double> boundedTicks;274 const QList< double >& ticks = m_ticks[ tickType ]; 275 276 QList< double > boundedTicks; 278 277 for ( int i = 0; i < ticks.size(); i++ ) 279 278 { … … 293 292 Assign ticks 294 293 295 \param type MinorTick, MediumTick or MajorTick 294 \param tickType MinorTick, MediumTick or MajorTick 296 295 \param ticks Values of the tick positions 297 */ 298 void QwtScaleDiv::setTicks( int type, const QList< double> &ticks )299 { 300 if ( type >= 0 && type < NTickTypes ) 301 d_ticks[type] = ticks;296 */ 297 void QwtScaleDiv::setTicks( int tickType, const QList< double >& ticks ) 298 { 299 if ( tickType >= 0 && tickType < NTickTypes ) 300 m_ticks[tickType] = ticks; 302 301 } 303 302 … … 305 304 Return a list of ticks 306 305 307 \param type MinorTick, MediumTick or MajorTick 306 \param tickType MinorTick, MediumTick or MajorTick 308 307 \return Tick list 309 */ 310 QList< double> QwtScaleDiv::ticks( int type ) const311 { 312 if ( type >= 0 && type < NTickTypes ) 313 return d_ticks[type];314 315 return QList< double>();308 */ 309 QList< double > QwtScaleDiv::ticks( int tickType ) const 310 { 311 if ( tickType >= 0 && tickType < NTickTypes ) 312 return m_ticks[tickType]; 313 314 return QList< double >(); 316 315 } 317 316 318 317 #ifndef QT_NO_DEBUG_STREAM 319 318 320 QDebug operator<<( QDebug debug, const QwtScaleDiv &scaleDiv ) 319 #include <qdebug.h> 320 321 QDebug operator<<( QDebug debug, const QwtScaleDiv& scaleDiv ) 321 322 { 322 323 debug << scaleDiv.lowerBound() << "<->" << scaleDiv.upperBound();
Note:
See TracChangeset
for help on using the changeset viewer.
