Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_scale_engine.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_scale_engine.cpp (modified) (49 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_scale_engine.cpp
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 10 10 #include "qwt_scale_engine.h" 11 11 #include "qwt_math.h" 12 #include "qwt_scale_map.h" 13 #include <qalgorithms.h> 14 #include <qmath.h> 15 #include <float.h> 12 #include "qwt_interval.h" 13 #include "qwt_transform.h" 14 15 #include <qdebug.h> 16 16 17 #include <limits> 17 18 18 #if QT_VERSION < 0x04060119 #define qFabs(x) ::fabs(x)20 #define qExp(x) ::exp(x)21 #endif22 23 19 static inline double qwtLog( double base, double value ) 24 20 { 25 return log( value ) / log( base ); 26 } 27 28 static inline QwtInterval qwtLogInterval( double base, const QwtInterval &interval )21 return std::log( value ) / std::log( base ); 22 } 23 24 static inline QwtInterval qwtLogInterval( double base, const QwtInterval& interval ) 29 25 { 30 26 return QwtInterval( qwtLog( base, interval.minValue() ), 31 qwtLog( base, interval.maxValue() ) ); 32 } 33 34 static inline QwtInterval qwtPowInterval( double base, const QwtInterval &interval ) 35 { 36 return QwtInterval( qPow( base, interval.minValue() ), 37 qPow( base, interval.maxValue() ) ); 38 } 39 40 static inline long double qwtIntervalWidthL( const QwtInterval &interval ) 41 { 42 if ( !interval.isValid() ) 43 return 0.0; 44 45 return static_cast<long double>( interval.maxValue() ) 46 - static_cast<long double>( interval.minValue() ); 27 qwtLog( base, interval.maxValue() ) ); 28 } 29 30 static inline QwtInterval qwtPowInterval( double base, const QwtInterval& interval ) 31 { 32 return QwtInterval( std::pow( base, interval.minValue() ), 33 std::pow( base, interval.maxValue() ) ); 47 34 } 48 35 … … 58 45 { 59 46 // # ticks per interval 60 const int numTicks = qCeil( qAbs( intervalSize / minStep ) ) - 1; 47 const int numTicks = qwtCeil( qAbs( intervalSize / minStep ) ) - 1; 61 48 62 49 // Do the minor steps fit into the interval? 63 if ( qwtFuzzyCompare( ( numTicks + 1 ) * qAbs( minStep ),50 if ( qwtFuzzyCompare( ( numTicks + 1 ) * qAbs( minStep ), 64 51 qAbs( intervalSize ), intervalSize ) > 0 ) 65 52 { … … 85 72 const double stepSize = intervalSize / numSteps; 86 73 87 const double p = ::floor( ::log( stepSize ) / ::log( base ) ); 88 const double fraction = qPow( base, p );74 const double p = std::floor( std::log( stepSize ) / std::log( base ) ); 75 const double fraction = std::pow( base, p ); 89 76 90 77 for ( uint n = base; n > 1; n /= 2 ) … … 110 97 111 98 /*! 112 Ceil a value, relative to an interval 113 114 \param value Value to be ceiled 115 \param intervalSize Interval size 116 117 \return Rounded value 118 119 \sa floorEps() 120 */ 99 Ceil a value, relative to an interval 100 101 \param value Value to be ceiled 102 \param intervalSize Interval size 103 104 \return Rounded value 105 106 \sa floorEps() 107 */ 121 108 double QwtScaleArithmetic::ceilEps( double value, 122 109 double intervalSize ) … … 125 112 126 113 value = ( value - eps ) / intervalSize; 127 return ::ceil( value ) * intervalSize; 128 } 129 130 /*! 131 Floor a value, relative to an interval 132 133 \param value Value to be floored 134 \param intervalSize Interval size 135 136 \return Rounded value 137 \sa floorEps() 138 */ 114 return std::ceil( value ) * intervalSize; 115 } 116 117 /*! 118 Floor a value, relative to an interval 119 120 \param value Value to be floored 121 \param intervalSize Interval size 122 123 \return Rounded value 124 \sa floorEps() 125 */ 139 126 double QwtScaleArithmetic::floorEps( double value, double intervalSize ) 140 127 { … … 142 129 143 130 value = ( value + eps ) / intervalSize; 144 return ::floor( value ) * intervalSize; 145 } 146 147 /*! 148 \brief Divide an interval into steps 149 150 \f$stepSize = (intervalSize - intervalSize * 10e^{-6}) / numSteps\f$ 151 152 \param intervalSize Interval size 153 \param numSteps Number of steps 154 \return Step size 155 */ 131 return std::floor( value ) * intervalSize; 132 } 133 134 /*! 135 \brief Divide an interval into steps 136 137 \f$stepSize = (intervalSize - intervalSize * 10e^{-6}) / numSteps\f$ 138 139 \param intervalSize Interval size 140 \param numSteps Number of steps 141 \return Step size 142 */ 156 143 double QwtScaleArithmetic::divideEps( double intervalSize, double numSteps ) 157 144 { … … 163 150 164 151 /*! 165 Calculate a step size for a given interval 166 167 \param intervalSize Interval size 168 \param numSteps Number of steps 169 \param base Base for the division ( usually 10 ) 170 171 \return Calculated step size 152 Calculate a step size for a given interval 153 154 \param intervalSize Interval size 155 \param numSteps Number of steps 156 \param base Base for the division ( usually 10 ) 157 158 \return Calculated step size 172 159 */ 173 160 double QwtScaleArithmetic::divideInterval( … … 181 168 return 0.0; 182 169 183 const double lx = qwtLog( base, qFabs( v ) );184 const double p = ::floor( lx ); 185 186 const double fraction = qPow( base, lx - p );170 const double lx = qwtLog( base, std::fabs( v ) ); 171 const double p = std::floor( lx ); 172 173 const double fraction = std::pow( base, lx - p ); 187 174 188 175 uint n = base; … … 190 177 n /= 2; 191 178 192 double stepSize = n * qPow( base, p );179 double stepSize = n * std::pow( base, p ); 193 180 if ( v < 0 ) 194 181 stepSize = -stepSize; … … 199 186 class QwtScaleEngine::PrivateData 200 187 { 201 public: 188 public: 202 189 PrivateData(): 203 190 attributes( QwtScaleEngine::NoAttribute ), … … 228 215 229 216 /*! 230 Constructor 231 232 \param base Base of the scale engine 233 \sa setBase() 217 Constructor 218 219 \param base Base of the scale engine 220 \sa setBase() 234 221 */ 235 222 QwtScaleEngine::QwtScaleEngine( uint base ) 236 223 { 237 d_data = new PrivateData;224 m_data = new PrivateData; 238 225 setBase( base ); 239 226 } … … 243 230 QwtScaleEngine::~QwtScaleEngine () 244 231 { 245 delete d_data;232 delete m_data; 246 233 } 247 234 … … 259 246 260 247 */ 261 void QwtScaleEngine::setTransformation( QwtTransform *transform )262 { 263 if ( transform != d_data->transform )264 { 265 delete d_data->transform;266 d_data->transform = transform;248 void QwtScaleEngine::setTransformation( QwtTransform* transform ) 249 { 250 if ( transform != m_data->transform ) 251 { 252 delete m_data->transform; 253 m_data->transform = transform; 267 254 } 268 255 } … … 273 260 NULL is returned, indicating no transformation. 274 261 275 \return A clone of the transfomation 262 \return A clone of the transformation 276 263 \sa setTransformation() 277 264 */ 278 QwtTransform *QwtScaleEngine::transformation() const279 { 280 QwtTransform *transform = NULL;281 if ( d_data->transform )282 transform = d_data->transform->copy();265 QwtTransform* QwtScaleEngine::transformation() const 266 { 267 QwtTransform* transform = NULL; 268 if ( m_data->transform ) 269 transform = m_data->transform->copy(); 283 270 284 271 return transform; … … 290 277 291 278 \sa setMargins() 292 */ 279 */ 293 280 double QwtScaleEngine::lowerMargin() const 294 281 { 295 return d_data->lowerMargin;282 return m_data->lowerMargin; 296 283 } 297 284 … … 301 288 302 289 \sa setMargins() 303 */ 290 */ 304 291 double QwtScaleEngine::upperMargin() const 305 292 { 306 return d_data->upperMargin;307 } 308 309 /*! 310 \brief Specify margins at the scale's endpoints 311 \param lower minimum distance between the scale's lower boundary and the 293 return m_data->upperMargin; 294 } 295 296 /*! 297 \brief Specify margins at the scale's endpoints 298 \param lower minimum distance between the scale's lower boundary and the 312 299 smallest enclosed value 313 \param upper minimum distance between the scale's upper boundary and the 300 \param upper minimum distance between the scale's upper boundary and the 314 301 greatest enclosed value 315 302 316 Margins can be used to leave a minimum amount of space between 317 the enclosed intervals and the boundaries of the scale. 318 319 \warning 320 \li QwtLogScaleEngine measures the margins in decades. 321 322 \sa upperMargin(), lowerMargin() 323 */ 303 Margins can be used to leave a minimum amount of space between 304 the enclosed intervals and the boundaries of the scale. 305 306 \warning 307 \li QwtLogScaleEngine measures the margins in decades. 308 309 \sa upperMargin(), lowerMargin() 310 */ 324 311 325 312 void QwtScaleEngine::setMargins( double lower, double upper ) 326 313 { 327 d_data->lowerMargin = qMax( lower, 0.0 );328 d_data->upperMargin = qMax( upper, 0.0 );329 } 330 331 /*! 332 Calculate a step size for an interval size 333 334 \param intervalSize Interval size 335 \param numSteps Number of steps 336 337 \return Step size 338 */ 314 m_data->lowerMargin = qwtMaxF( lower, 0.0 ); 315 m_data->upperMargin = qwtMaxF( upper, 0.0 ); 316 } 317 318 /*! 319 Calculate a step size for an interval size 320 321 \param intervalSize Interval size 322 \param numSteps Number of steps 323 324 \return Step size 325 */ 339 326 double QwtScaleEngine::divideInterval( 340 327 double intervalSize, int numSteps ) const 341 328 { 342 329 return QwtScaleArithmetic::divideInterval( 343 intervalSize, numSteps, d_data->base );344 } 345 346 /*! 347 Check if an interval "contains" a value 348 349 \param interval Interval 350 \param value Value 351 352 \return True, when the value is inside the interval 353 */ 330 intervalSize, numSteps, m_data->base ); 331 } 332 333 /*! 334 Check if an interval "contains" a value 335 336 \param interval Interval 337 \param value Value 338 339 \return True, when the value is inside the interval 340 */ 354 341 bool QwtScaleEngine::contains( 355 const QwtInterval &interval, double value ) const342 const QwtInterval& interval, double value ) const 356 343 { 357 344 if ( !interval.isValid() ) … … 368 355 369 356 /*! 370 Remove ticks from a list, that are not inside an interval 371 372 \param ticks Tick list 373 \param interval Interval 374 375 \return Stripped tick list 376 */ 377 QList< double> QwtScaleEngine::strip( const QList<double>& ticks,378 const QwtInterval &interval ) const357 Remove ticks from a list, that are not inside an interval 358 359 \param ticks Tick list 360 \param interval Interval 361 362 \return Stripped tick list 363 */ 364 QList< double > QwtScaleEngine::strip( const QList< double >& ticks, 365 const QwtInterval& interval ) const 379 366 { 380 367 if ( !interval.isValid() || ticks.count() == 0 ) 381 return QList< double>();368 return QList< double >(); 382 369 383 370 if ( contains( interval, ticks.first() ) … … 387 374 } 388 375 389 QList< double> strippedTicks;376 QList< double > strippedTicks; 390 377 for ( int i = 0; i < ticks.count(); i++ ) 391 378 { … … 397 384 398 385 /*! 399 \brief Build an interval around a value 400 401 In case of v == 0.0 the interval is [-0.5, 0.5], 402 otherwide it is [0.5 * v, 1.5 * v]403 404 \param value Initial value 405 \return Calculated interval 406 */ 386 \brief Build an interval around a value 387 388 In case of v == 0.0 the interval is [-0.5, 0.5], 389 otherwise it is [0.5 * v, 1.5 * v] 390 391 \param value Initial value 392 \return Calculated interval 393 */ 407 394 408 395 QwtInterval QwtScaleEngine::buildInterval( double value ) const 409 396 { 410 397 const double delta = ( value == 0.0 ) ? 0.5 : qAbs( 0.5 * value ); 411 412 if ( DBL_MAX - delta < value ) 413 return QwtInterval( DBL_MAX - delta, DBL_MAX ); 414 415 if ( -DBL_MAX + delta > value ) 416 return QwtInterval( -DBL_MAX, -DBL_MAX + delta ); 398 const double max = std::numeric_limits< double >::max(); 399 400 if ( max - delta < value ) 401 return QwtInterval( max - delta, max ); 402 403 if ( -max + delta > value ) 404 return QwtInterval( -max, -max + delta ); 417 405 418 406 return QwtInterval( value - delta, value + delta ); … … 420 408 421 409 /*! 422 Change a scale attribute 423 424 \param attribute Attribute to change 425 \param on On/Off 426 427 \sa Attribute, testAttribute() 428 */ 410 Change a scale attribute 411 412 \param attribute Attribute to change 413 \param on On/Off 414 415 \sa Attribute, testAttribute() 416 */ 429 417 void QwtScaleEngine::setAttribute( Attribute attribute, bool on ) 430 418 { 431 419 if ( on ) 432 d_data->attributes |= attribute;420 m_data->attributes |= attribute; 433 421 else 434 d_data->attributes &= ~attribute;435 } 436 437 /*! 438 \return True, if attribute is enabled. 439 440 \param attribute Attribute to be tested 441 \sa Attribute, setAttribute() 442 */ 422 m_data->attributes &= ~attribute; 423 } 424 425 /*! 426 \return True, if attribute is enabled. 427 428 \param attribute Attribute to be tested 429 \sa Attribute, setAttribute() 430 */ 443 431 bool QwtScaleEngine::testAttribute( Attribute attribute ) const 444 432 { 445 return ( d_data->attributes & attribute );446 } 447 448 /*! 449 Change the scale attribute 450 451 \param attributes Set scale attributes 452 \sa Attribute, attributes() 453 */ 433 return ( m_data->attributes & attribute ); 434 } 435 436 /*! 437 Change the scale attribute 438 439 \param attributes Set scale attributes 440 \sa Attribute, attributes() 441 */ 454 442 void QwtScaleEngine::setAttributes( Attributes attributes ) 455 443 { 456 d_data->attributes = attributes;457 } 458 459 /*! 460 \return Scale attributes 461 \sa Attribute, setAttributes(), testAttribute() 462 */ 444 m_data->attributes = attributes; 445 } 446 447 /*! 448 \return Scale attributes 449 \sa Attribute, setAttributes(), testAttribute() 450 */ 463 451 QwtScaleEngine::Attributes QwtScaleEngine::attributes() const 464 452 { 465 return d_data->attributes;466 } 467 468 /*! 469 \brief Specify a reference point 470 \param reference New reference value 471 472 The reference point is needed if options IncludeReference or 473 Symmetric are active. Its default value is 0.0. 474 475 \sa Attribute 476 */ 453 return m_data->attributes; 454 } 455 456 /*! 457 \brief Specify a reference point 458 \param reference New reference value 459 460 The reference point is needed if options IncludeReference or 461 Symmetric are active. Its default value is 0.0. 462 463 \sa Attribute 464 */ 477 465 void QwtScaleEngine::setReference( double reference ) 478 466 { 479 d_data->referenceValue = reference;480 } 481 482 /*! 483 \return the reference value 484 \sa setReference(), setAttribute() 485 */ 467 m_data->referenceValue = reference; 468 } 469 470 /*! 471 \return the reference value 472 \sa setReference(), setAttribute() 473 */ 486 474 double QwtScaleEngine::reference() const 487 475 { 488 return d_data->referenceValue;489 } 490 491 /*! 492 Set the base of the scale engine 493 494 While a base of 10 is what 99.9% of all applications need 495 certain scales might need a different base: f.e 2 496 497 The default setting is 10 498 499 \param base Base of the engine 500 501 \sa base() 476 return m_data->referenceValue; 477 } 478 479 /*! 480 Set the base of the scale engine 481 482 While a base of 10 is what 99.9% of all applications need 483 certain scales might need a different base: f.e 2 484 485 The default setting is 10 486 487 \param base Base of the engine 488 489 \sa base() 502 490 */ 503 491 void QwtScaleEngine::setBase( uint base ) 504 492 { 505 d_data->base = qMax( base, 2U );506 } 507 508 /*! 509 \return base Base of the scale engine 510 \sa setBase() 493 m_data->base = qMax( base, 2U ); 494 } 495 496 /*! 497 \return base Base of the scale engine 498 \sa setBase() 511 499 */ 512 500 uint QwtScaleEngine::base() const 513 501 { 514 return d_data->base;515 } 516 517 /*! 518 Constructor 519 520 \param base Base of the scale engine 521 \sa setBase() 502 return m_data->base; 503 } 504 505 /*! 506 Constructor 507 508 \param base Base of the scale engine 509 \sa setBase() 522 510 */ 523 511 QwtLinearScaleEngine::QwtLinearScaleEngine( uint base ): … … 532 520 533 521 /*! 534 Align and divide an interval 535 536 \param maxNumSteps Max. number of steps 537 \param x1 First limit of the interval (In/Out) 538 \param x2 Second limit of the interval (In/Out) 539 \param stepSize Step size (Out) 540 541 \sa setAttribute() 542 */ 522 Align and divide an interval 523 524 \param maxNumSteps Max. number of steps 525 \param x1 First limit of the interval (In/Out) 526 \param x2 Second limit of the interval (In/Out) 527 \param stepSize Step size (Out) 528 529 \sa setAttribute() 530 */ 543 531 void QwtLinearScaleEngine::autoScale( int maxNumSteps, 544 double &x1, double&x2, double&stepSize ) const532 double& x1, double& x2, double& stepSize ) const 545 533 { 546 534 QwtInterval interval( x1, x2 ); … … 586 574 587 575 \return Calculated scale division 588 */ 576 */ 589 577 QwtScaleDiv QwtLinearScaleEngine::divideScale( double x1, double x2, 590 578 int maxMajorSteps, int maxMinorSteps, double stepSize ) const … … 592 580 QwtInterval interval = QwtInterval( x1, x2 ).normalized(); 593 581 594 if ( qwtIntervalWidthL(interval) > std::numeric_limits<double>::max() )582 if ( interval.widthL() > std::numeric_limits< double >::max() ) 595 583 { 596 584 qWarning() << "QwtLinearScaleEngine::divideScale: overflow"; … … 615 603 if ( stepSize != 0.0 ) 616 604 { 617 QList< double> ticks[QwtScaleDiv::NTickTypes];605 QList< double > ticks[QwtScaleDiv::NTickTypes]; 618 606 buildTicks( interval, stepSize, maxMinorSteps, ticks ); 619 607 … … 636 624 637 625 \sa buildMajorTicks(), buildMinorTicks 638 */ 626 */ 639 627 void QwtLinearScaleEngine::buildTicks( 640 628 const QwtInterval& interval, double stepSize, int maxMinorSteps, 641 QList< double> ticks[QwtScaleDiv::NTickTypes] ) const629 QList< double > ticks[QwtScaleDiv::NTickTypes] ) const 642 630 { 643 631 const QwtInterval boundingInterval = align( interval, stepSize ); … … 656 644 ticks[i] = strip( ticks[i], interval ); 657 645 658 // ticks very close to 0.0 are 659 // explicitely set to 0.0 646 // ticks very close to 0.0 are explicitly set to 0.0 660 647 661 648 for ( int j = 0; j < ticks[i].count(); j++ ) … … 674 661 675 662 \return Calculated ticks 676 */ 677 QList< double> QwtLinearScaleEngine::buildMajorTicks(678 const QwtInterval &interval, double stepSize ) const663 */ 664 QList< double > QwtLinearScaleEngine::buildMajorTicks( 665 const QwtInterval& interval, double stepSize ) const 679 666 { 680 667 int numTicks = qRound( interval.width() / stepSize ) + 1; … … 682 669 numTicks = 10000; 683 670 684 QList<double> ticks; 671 QList< double > ticks; 672 ticks.reserve( numTicks ); 685 673 686 674 ticks += interval.minValue(); … … 701 689 \param mediumTicks Array to be filled with the calculated medium ticks 702 690 703 */ 691 */ 704 692 void QwtLinearScaleEngine::buildMinorTicks( 705 const QList< double>& majorTicks,693 const QList< double >& majorTicks, 706 694 int maxMinorSteps, double stepSize, 707 QList< double> &minorTicks,708 QList< double> &mediumTicks ) const695 QList< double >& minorTicks, 696 QList< double >& mediumTicks ) const 709 697 { 710 698 double minStep = qwtStepSize( stepSize, maxMinorSteps, base() ); … … 713 701 714 702 // # ticks per interval 715 const int numTicks = qCeil( qAbs( stepSize / minStep ) ) - 1; 703 const int numTicks = qwtCeil( qAbs( stepSize / minStep ) ) - 1; 716 704 717 705 int medIndex = -1; … … 741 729 742 730 /*! 743 \brief Align an interval to a step size 744 745 The limits of an interval are aligned that both are integer 746 multiples of the step size. 747 748 \param interval Interval 749 \param stepSize Step size 750 751 \return Aligned interval 752 */ 731 \brief Align an interval to a step size 732 733 The limits of an interval are aligned that both are integer 734 multiples of the step size. 735 736 \param interval Interval 737 \param stepSize Step size 738 739 \return Aligned interval 740 */ 753 741 QwtInterval QwtLinearScaleEngine::align( 754 const QwtInterval &interval, double stepSize ) const742 const QwtInterval& interval, double stepSize ) const 755 743 { 756 744 double x1 = interval.minValue(); … … 761 749 762 750 const double eps = 0.000000000001; // since Qt 4.8: qFuzzyIsNull 763 if ( -DBL_MAX + stepSize <= x1 ) 751 const double max = std::numeric_limits< double >::max(); 752 753 if ( -max + stepSize <= x1 ) 764 754 { 765 755 const double x = QwtScaleArithmetic::floorEps( x1, stepSize ); … … 768 758 } 769 759 770 if ( DBL_MAX- stepSize >= x2 )760 if ( max - stepSize >= x2 ) 771 761 { 772 762 const double x = QwtScaleArithmetic::ceilEps( x2, stepSize ); … … 779 769 780 770 /*! 781 Constructor 782 783 \param base Base of the scale engine 784 \sa setBase() 771 Constructor 772 773 \param base Base of the scale engine 774 \sa setBase() 785 775 */ 786 776 QwtLogScaleEngine::QwtLogScaleEngine( uint base ): … … 804 794 805 795 \sa QwtScaleEngine::setAttribute() 806 */ 796 */ 807 797 void QwtLogScaleEngine::autoScale( int maxNumSteps, 808 double &x1, double&x2, double&stepSize ) const798 double& x1, double& x2, double& stepSize ) const 809 799 { 810 800 if ( x1 > x2 ) … … 813 803 const double logBase = base(); 814 804 815 QwtInterval interval( x1 / qPow( logBase, lowerMargin() ),816 x2 * qPow( logBase, upperMargin() ) );805 QwtInterval interval( x1 / std::pow( logBase, lowerMargin() ), 806 x2 * std::pow( logBase, upperMargin() ) ); 817 807 818 808 if ( interval.maxValue() / interval.minValue() < logBase ) … … 828 818 829 819 QwtInterval linearInterval = QwtInterval( x1, x2 ).normalized(); 830 linearInterval = linearInterval.limited( LOG_MIN, LOG_MAX ); 820 linearInterval = linearInterval.limited( 821 QwtLogTransform::LogMin, QwtLogTransform::LogMax ); 831 822 832 823 if ( linearInterval.maxValue() / linearInterval.minValue() < logBase ) 833 824 { 834 // the aligned scale is still less than one step 835 836 #if 1 837 // this code doesn't make any sense, but for compatibility 838 // reasons we keep it until 6.2. But it will be ignored 839 // in divideScale 840 841 if ( stepSize < 0.0 ) 842 stepSize = -qwtLog( logBase, qAbs( stepSize ) ); 843 else 844 stepSize = qwtLog( logBase, stepSize ); 845 #endif 846 825 stepSize = 0.0; 847 826 return; 848 827 } … … 850 829 851 830 double logRef = 1.0; 852 if ( reference() > LOG_MIN/ 2 )853 logRef = q Min( reference(),LOG_MAX/ 2 );831 if ( reference() > QwtLogTransform::LogMin / 2 ) 832 logRef = qwtMinF( reference(), QwtLogTransform::LogMax / 2 ); 854 833 855 834 if ( testAttribute( QwtScaleEngine::Symmetric ) ) 856 835 { 857 const double delta = q Max( interval.maxValue() / logRef,836 const double delta = qwtMaxF( interval.maxValue() / logRef, 858 837 logRef / interval.minValue() ); 859 838 interval.setInterval( logRef / delta, logRef * delta ); … … 863 842 interval = interval.extend( logRef ); 864 843 865 interval = interval.limited( LOG_MIN, LOG_MAX);844 interval = interval.limited( QwtLogTransform::LogMin, QwtLogTransform::LogMax ); 866 845 867 846 if ( interval.width() == 0.0 ) … … 897 876 898 877 \return Calculated scale division 899 */ 878 */ 900 879 QwtScaleDiv QwtLogScaleEngine::divideScale( double x1, double x2, 901 880 int maxMajorSteps, int maxMinorSteps, double stepSize ) const 902 881 { 903 882 QwtInterval interval = QwtInterval( x1, x2 ).normalized(); 904 interval = interval.limited( LOG_MIN, LOG_MAX);883 interval = interval.limited( QwtLogTransform::LogMin, QwtLogTransform::LogMax ); 905 884 906 885 if ( interval.width() <= 0 ) … … 937 916 if ( stepSize != 0.0 ) 938 917 { 939 QList< double> ticks[QwtScaleDiv::NTickTypes];918 QList< double > ticks[QwtScaleDiv::NTickTypes]; 940 919 buildTicks( interval, stepSize, maxMinorSteps, ticks ); 941 920 … … 958 937 959 938 \sa buildMajorTicks(), buildMinorTicks 960 */ 939 */ 961 940 void QwtLogScaleEngine::buildTicks( 962 941 const QwtInterval& interval, double stepSize, int maxMinorSteps, 963 QList< double> ticks[QwtScaleDiv::NTickTypes] ) const942 QList< double > ticks[QwtScaleDiv::NTickTypes] ) const 964 943 { 965 944 const QwtInterval boundingInterval = align( interval, stepSize ); … … 985 964 986 965 \return Calculated ticks 987 */ 988 QList< double> QwtLogScaleEngine::buildMajorTicks(989 const QwtInterval &interval, double stepSize ) const966 */ 967 QList< double > QwtLogScaleEngine::buildMajorTicks( 968 const QwtInterval& interval, double stepSize ) const 990 969 { 991 970 double width = qwtLogInterval( base(), interval ).width(); … … 995 974 numTicks = 10000; 996 975 997 const double lxmin = ::log( interval.minValue() ); 998 const double lxmax = ::log( interval.maxValue() ); 976 const double lxmin = std::log( interval.minValue() ); 977 const double lxmax = std::log( interval.maxValue() ); 999 978 const double lstep = ( lxmax - lxmin ) / double( numTicks - 1 ); 1000 979 1001 QList<double> ticks; 980 QList< double > ticks; 981 ticks.reserve( numTicks ); 1002 982 1003 983 ticks += interval.minValue(); 1004 984 1005 985 for ( int i = 1; i < numTicks - 1; i++ ) 1006 ticks += qExp( lxmin + double( i ) * lstep );986 ticks += std::exp( lxmin + double( i ) * lstep ); 1007 987 1008 988 ticks += interval.maxValue(); … … 1019 999 \param minorTicks Array to be filled with the calculated minor ticks 1020 1000 \param mediumTicks Array to be filled with the calculated medium ticks 1021 */ 1001 */ 1022 1002 void QwtLogScaleEngine::buildMinorTicks( 1023 const QList< double> &majorTicks,1003 const QList< double >& majorTicks, 1024 1004 int maxMinorSteps, double stepSize, 1025 QList< double> &minorTicks,1026 QList< double> &mediumTicks ) const1005 QList< double >& minorTicks, 1006 QList< double >& mediumTicks ) const 1027 1007 { 1028 1008 const double logBase = base(); … … 1081 1061 1082 1062 // Do the minor steps fit into the interval? 1083 if ( qwtFuzzyCompare( ( numTicks + 1 ) * minStep,1063 if ( qwtFuzzyCompare( ( numTicks + 1 ) * minStep, 1084 1064 stepSize, stepSize ) > 0 ) 1085 1065 { … … 1095 1075 1096 1076 // substep factor = base^substeps 1097 const qreal minFactor = q Max( qPow( logBase, minStep ),qreal( logBase ));1077 const qreal minFactor = qwtMaxF( std::pow( logBase, minStep ), logBase ); 1098 1078 1099 1079 for ( int i = 0; i < majorTicks.count(); i++ ) … … 1114 1094 1115 1095 /*! 1116 \brief Align an interval to a step size 1117 1118 The limits of an interval are aligned that both are integer 1119 multiples of the step size. 1120 1121 \param interval Interval 1122 \param stepSize Step size 1123 1124 \return Aligned interval 1125 */ 1096 \brief Align an interval to a step size 1097 1098 The limits of an interval are aligned that both are integer 1099 multiples of the step size. 1100 1101 \param interval Interval 1102 \param stepSize Step size 1103 1104 \return Aligned interval 1105 */ 1126 1106 QwtInterval QwtLogScaleEngine::align( 1127 const QwtInterval &interval, double stepSize ) const1107 const QwtInterval& interval, double stepSize ) const 1128 1108 { 1129 1109 const QwtInterval intv = qwtLogInterval( base(), interval );
Note:
See TracChangeset
for help on using the changeset viewer.
