qwt_scale_engine.cpp 27.5 KB
Newer Older
pixhawk's avatar
pixhawk committed
1 2 3 4
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
 * Qwt Widget Library
 * Copyright (C) 1997   Josef Wilgen
 * Copyright (C) 2002   Uwe Rathmann
5
 *
pixhawk's avatar
pixhawk committed
6 7 8 9
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the Qwt License, Version 1.0
 *****************************************************************************/

Bryant's avatar
Bryant committed
10
#include "qwt_scale_engine.h"
pixhawk's avatar
pixhawk committed
11 12
#include "qwt_math.h"
#include "qwt_scale_map.h"
Bryant's avatar
Bryant committed
13 14 15
#include <qalgorithms.h>
#include <qmath.h>
#include <float.h>
pixhawk's avatar
pixhawk committed
16

Bryant's avatar
Bryant committed
17 18 19 20
#if QT_VERSION < 0x040601
#define qFabs(x) ::fabs(x)
#define qExp(x) ::exp(x)
#endif
pixhawk's avatar
pixhawk committed
21

Bryant's avatar
Bryant committed
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
static inline double qwtLog( double base, double value )
{
    return log( value ) / log( base );
}

static inline QwtInterval qwtLogInterval( double base, const QwtInterval &interval )
{
    return QwtInterval( qwtLog( base, interval.minValue() ),
            qwtLog( base, interval.maxValue() ) );
}

static inline QwtInterval qwtPowInterval( double base, const QwtInterval &interval ) 
{
    return QwtInterval( qPow( base, interval.minValue() ),
            qPow( base, interval.maxValue() ) );
}
pixhawk's avatar
pixhawk committed
38 39


Bryant's avatar
Bryant committed
40
#if 1
pixhawk's avatar
pixhawk committed
41

Bryant's avatar
Bryant committed
42 43
// this version often doesn't find the best ticks: f.e for 15: 5, 10
static double qwtStepSize( double intervalSize, int maxSteps, uint base )
pixhawk's avatar
pixhawk committed
44
{
Bryant's avatar
Bryant committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
    const double minStep = 
        QwtScaleArithmetic::divideInterval( intervalSize, maxSteps, base );

    if ( minStep != 0.0 )
    {
        // # ticks per interval
        const int numTicks = qCeil( qAbs( intervalSize / minStep ) ) - 1;

        // Do the minor steps fit into the interval?
        if ( qwtFuzzyCompare( ( numTicks +  1 ) * qAbs( minStep ),
            qAbs( intervalSize ), intervalSize ) > 0 )
        {
            // The minor steps doesn't fit into the interval
            return 0.5 * intervalSize;
        }
    }

    return minStep;
}
pixhawk's avatar
pixhawk committed
64

Bryant's avatar
Bryant committed
65
#else
pixhawk's avatar
pixhawk committed
66

Bryant's avatar
Bryant committed
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
static double qwtStepSize( double intervalSize, int maxSteps, uint base )
{
    if ( maxSteps <= 0 )
        return 0.0;

    if ( maxSteps > 2 )
    {
        for ( int numSteps = maxSteps; numSteps > 1; numSteps-- )
        {
            const double stepSize = intervalSize / numSteps;

            const double p = ::floor( ::log( stepSize ) / ::log( base ) );
            const double fraction = qPow( base, p );

            for ( uint n = base; n > 1; n /= 2 )
            {
                if ( qFuzzyCompare( stepSize, n * fraction ) )
                    return stepSize;

                if ( n == 3 && ( base % 2 ) == 0 )
                {
                    if ( qFuzzyCompare( stepSize, 2 * fraction ) )
                        return stepSize;
                }
            }
        }
    }
pixhawk's avatar
pixhawk committed
94

Bryant's avatar
Bryant committed
95
    return intervalSize * 0.5;
pixhawk's avatar
pixhawk committed
96 97
}

Bryant's avatar
Bryant committed
98 99 100 101
#endif

static const double _eps = 1.0e-6;

pixhawk's avatar
pixhawk committed
102 103 104
/*!
  Ceil a value, relative to an interval

Bryant's avatar
Bryant committed
105
  \param value Value to be ceiled
pixhawk's avatar
pixhawk committed
106
  \param intervalSize Interval size
107

Bryant's avatar
Bryant committed
108 109 110
  \return Rounded value

  \sa floorEps()
pixhawk's avatar
pixhawk committed
111
*/
Bryant's avatar
Bryant committed
112 113
double QwtScaleArithmetic::ceilEps( double value,
    double intervalSize )
pixhawk's avatar
pixhawk committed
114 115 116
{
    const double eps = _eps * intervalSize;

Bryant's avatar
Bryant committed
117 118
    value = ( value - eps ) / intervalSize;
    return ::ceil( value ) * intervalSize;
pixhawk's avatar
pixhawk committed
119 120 121 122 123
}

/*!
  Floor a value, relative to an interval

Bryant's avatar
Bryant committed
124
  \param value Value to be floored
pixhawk's avatar
pixhawk committed
125
  \param intervalSize Interval size
126

Bryant's avatar
Bryant committed
127 128
  \return Rounded value
  \sa floorEps()
pixhawk's avatar
pixhawk committed
129
*/
Bryant's avatar
Bryant committed
130
double QwtScaleArithmetic::floorEps( double value, double intervalSize )
pixhawk's avatar
pixhawk committed
131 132 133
{
    const double eps = _eps * intervalSize;

Bryant's avatar
Bryant committed
134 135
    value = ( value + eps ) / intervalSize;
    return ::floor( value ) * intervalSize;
pixhawk's avatar
pixhawk committed
136 137
}

Bryant's avatar
Bryant committed
138
/*!
pixhawk's avatar
pixhawk committed
139 140 141 142 143 144 145 146
  \brief Divide an interval into steps

  \f$stepSize = (intervalSize - intervalSize * 10e^{-6}) / numSteps\f$

  \param intervalSize Interval size
  \param numSteps Number of steps
  \return Step size
*/
Bryant's avatar
Bryant committed
147
double QwtScaleArithmetic::divideEps( double intervalSize, double numSteps )
pixhawk's avatar
pixhawk committed
148 149 150 151
{
    if ( numSteps == 0.0 || intervalSize == 0.0 )
        return 0.0;

Bryant's avatar
Bryant committed
152
    return ( intervalSize - ( _eps * intervalSize ) ) / numSteps;
153
}
pixhawk's avatar
pixhawk committed
154 155

/*!
Bryant's avatar
Bryant committed
156
  Calculate a step size for a given interval
157

Bryant's avatar
Bryant committed
158 159 160 161 162 163 164 165
  \param intervalSize Interval size
  \param numSteps Number of steps
  \param base Base for the division ( usually 10 )

  \return Calculated step size
 */
double QwtScaleArithmetic::divideInterval( 
    double intervalSize, int numSteps, uint base ) 
pixhawk's avatar
pixhawk committed
166
{
Bryant's avatar
Bryant committed
167
    if ( numSteps <= 0 )
pixhawk's avatar
pixhawk committed
168 169
        return 0.0;

Bryant's avatar
Bryant committed
170 171 172
    const double v = QwtScaleArithmetic::divideEps( intervalSize, numSteps );
    if ( v == 0.0 )
        return 0.0;
pixhawk's avatar
pixhawk committed
173

Bryant's avatar
Bryant committed
174 175
    const double lx = qwtLog( base, qFabs( v ) );
    const double p = ::floor( lx );
pixhawk's avatar
pixhawk committed
176

Bryant's avatar
Bryant committed
177
    const double fraction = qPow( base, lx - p );
pixhawk's avatar
pixhawk committed
178

Bryant's avatar
Bryant committed
179 180 181
    uint n = base;
    while ( ( n > 1 ) && ( fraction <= n / 2 ) )
        n /= 2;
pixhawk's avatar
pixhawk committed
182

Bryant's avatar
Bryant committed
183 184 185
    double stepSize = n * qPow( base, p );
    if ( v < 0 )
        stepSize = -stepSize;
pixhawk's avatar
pixhawk committed
186

Bryant's avatar
Bryant committed
187
    return stepSize;
pixhawk's avatar
pixhawk committed
188 189 190 191 192 193
}

class QwtScaleEngine::PrivateData
{
public:
    PrivateData():
Bryant's avatar
Bryant committed
194 195 196 197 198 199 200 201 202 203 204 205
        attributes( QwtScaleEngine::NoAttribute ),
        lowerMargin( 0.0 ),
        upperMargin( 0.0 ),
        referenceValue( 0.0 ),
        base( 10 ),
        transform( NULL )
    {
    }

    ~PrivateData()
    {
        delete transform;
pixhawk's avatar
pixhawk committed
206 207
    }

Bryant's avatar
Bryant committed
208
    QwtScaleEngine::Attributes attributes;
pixhawk's avatar
pixhawk committed
209

Bryant's avatar
Bryant committed
210 211
    double lowerMargin;
    double upperMargin;
pixhawk's avatar
pixhawk committed
212

Bryant's avatar
Bryant committed
213
    double referenceValue;
pixhawk's avatar
pixhawk committed
214

Bryant's avatar
Bryant committed
215 216 217
    uint base;

    QwtTransform* transform;
pixhawk's avatar
pixhawk committed
218 219
};

Bryant's avatar
Bryant committed
220 221 222 223 224 225 226
/*!
  Constructor

  \param base Base of the scale engine
  \sa setBase()
 */
QwtScaleEngine::QwtScaleEngine( uint base )
pixhawk's avatar
pixhawk committed
227 228
{
    d_data = new PrivateData;
Bryant's avatar
Bryant committed
229
    setBase( base );
pixhawk's avatar
pixhawk committed
230 231 232
}


Bryant's avatar
Bryant committed
233
//! Destructor
pixhawk's avatar
pixhawk committed
234 235 236 237 238
QwtScaleEngine::~QwtScaleEngine ()
{
    delete d_data;
}

Bryant's avatar
Bryant committed
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
/*!
   Assign a transformation

   \param transform Transformation

   The transformation object is used as factory for clones
   that are returned by transformation()

   The scale engine takes ownership of the transformation.

   \sa QwtTransform::copy(), transformation()

 */
void QwtScaleEngine::setTransformation( QwtTransform *transform )
{
    if ( transform != d_data->transform )
    {
        delete d_data->transform;
        d_data->transform = transform;
    }
}

/*!
   Create and return a clone of the transformation 
   of the engine. When the engine has no special transformation
   NULL is returned, indicating no transformation.

   \return A clone of the transfomation
   \sa setTransformation()
 */
QwtTransform *QwtScaleEngine::transformation() const
{
    QwtTransform *transform = NULL;
    if ( d_data->transform )
        transform = d_data->transform->copy();

    return transform;
}

pixhawk's avatar
pixhawk committed
278 279 280 281
/*!
    \return the margin at the lower end of the scale
    The default margin is 0.

Bryant's avatar
Bryant committed
282
    \sa setMargins()
pixhawk's avatar
pixhawk committed
283
*/
Bryant's avatar
Bryant committed
284
double QwtScaleEngine::lowerMargin() const
285
{
Bryant's avatar
Bryant committed
286
    return d_data->lowerMargin;
pixhawk's avatar
pixhawk committed
287 288 289 290 291 292
}

/*!
    \return the margin at the upper end of the scale
    The default margin is 0.

Bryant's avatar
Bryant committed
293
    \sa setMargins()
pixhawk's avatar
pixhawk committed
294
*/
Bryant's avatar
Bryant committed
295
double QwtScaleEngine::upperMargin() const
296
{
Bryant's avatar
Bryant committed
297
    return d_data->upperMargin;
pixhawk's avatar
pixhawk committed
298 299 300 301
}

/*!
  \brief Specify margins at the scale's endpoints
Bryant's avatar
Bryant committed
302
  \param lower minimum distance between the scale's lower boundary and the
pixhawk's avatar
pixhawk committed
303
             smallest enclosed value
Bryant's avatar
Bryant committed
304
  \param upper minimum distance between the scale's upper boundary and the
pixhawk's avatar
pixhawk committed
305 306 307 308 309 310
             greatest enclosed value

  Margins can be used to leave a minimum amount of space between
  the enclosed intervals and the boundaries of the scale.

  \warning
Bryant's avatar
Bryant committed
311
  \li QwtLogScaleEngine measures the margins in decades.
pixhawk's avatar
pixhawk committed
312

Bryant's avatar
Bryant committed
313
  \sa upperMargin(), lowerMargin()
pixhawk's avatar
pixhawk committed
314 315
*/

Bryant's avatar
Bryant committed
316
void QwtScaleEngine::setMargins( double lower, double upper )
pixhawk's avatar
pixhawk committed
317
{
Bryant's avatar
Bryant committed
318 319
    d_data->lowerMargin = qMax( lower, 0.0 );
    d_data->upperMargin = qMax( upper, 0.0 );
pixhawk's avatar
pixhawk committed
320 321 322 323 324 325 326
}

/*!
  Calculate a step size for an interval size

  \param intervalSize Interval size
  \param numSteps Number of steps
327

pixhawk's avatar
pixhawk committed
328 329 330
  \return Step size
*/
double QwtScaleEngine::divideInterval(
Bryant's avatar
Bryant committed
331
    double intervalSize, int numSteps ) const
pixhawk's avatar
pixhawk committed
332
{
Bryant's avatar
Bryant committed
333 334
    return QwtScaleArithmetic::divideInterval( 
        intervalSize, numSteps, d_data->base );
pixhawk's avatar
pixhawk committed
335 336 337 338 339 340 341 342
}

/*!
  Check if an interval "contains" a value

  \param interval Interval
  \param value Value

Bryant's avatar
Bryant committed
343
  \return True, when the value is inside the interval
pixhawk's avatar
pixhawk committed
344 345
*/
bool QwtScaleEngine::contains(
Bryant's avatar
Bryant committed
346
    const QwtInterval &interval, double value ) const
pixhawk's avatar
pixhawk committed
347
{
Bryant's avatar
Bryant committed
348
    if ( !interval.isValid() )
pixhawk's avatar
pixhawk committed
349
        return false;
350

Bryant's avatar
Bryant committed
351
    if ( qwtFuzzyCompare( value, interval.minValue(), interval.width() ) < 0 )
pixhawk's avatar
pixhawk committed
352 353
        return false;

Bryant's avatar
Bryant committed
354
    if ( qwtFuzzyCompare( value, interval.maxValue(), interval.width() ) > 0 )
pixhawk's avatar
pixhawk committed
355 356 357 358 359 360 361 362 363 364 365 366 367
        return false;

    return true;
}

/*!
  Remove ticks from a list, that are not inside an interval

  \param ticks Tick list
  \param interval Interval

  \return Stripped tick list
*/
Bryant's avatar
Bryant committed
368 369
QList<double> QwtScaleEngine::strip( const QList<double>& ticks,
    const QwtInterval &interval ) const
pixhawk's avatar
pixhawk committed
370 371
{
    if ( !interval.isValid() || ticks.count() == 0 )
Bryant's avatar
Bryant committed
372
        return QList<double>();
pixhawk's avatar
pixhawk committed
373

Bryant's avatar
Bryant committed
374 375 376
    if ( contains( interval, ticks.first() )
        && contains( interval, ticks.last() ) )
    {
pixhawk's avatar
pixhawk committed
377 378 379
        return ticks;
    }

Bryant's avatar
Bryant committed
380 381 382 383
    QList<double> strippedTicks;
    for ( int i = 0; i < ticks.count(); i++ )
    {
        if ( contains( interval, ticks[i] ) )
pixhawk's avatar
pixhawk committed
384 385 386 387 388 389
            strippedTicks += ticks[i];
    }
    return strippedTicks;
}

/*!
Bryant's avatar
Bryant committed
390
  \brief Build an interval around a value
pixhawk's avatar
pixhawk committed
391 392 393

  In case of v == 0.0 the interval is [-0.5, 0.5],
  otherwide it is [0.5 * v, 1.5 * v]
Bryant's avatar
Bryant committed
394 395 396

  \param value Initial value
  \return Calculated interval
pixhawk's avatar
pixhawk committed
397 398
*/

Bryant's avatar
Bryant committed
399
QwtInterval QwtScaleEngine::buildInterval( double value ) const
pixhawk's avatar
pixhawk committed
400
{
Bryant's avatar
Bryant committed
401 402 403 404 405 406 407 408 409
    const double delta = ( value == 0.0 ) ? 0.5 : qAbs( 0.5 * value );

    if ( DBL_MAX - delta < value )
        return QwtInterval( DBL_MAX - delta, DBL_MAX );

    if ( -DBL_MAX + delta > value )
        return QwtInterval( -DBL_MAX, -DBL_MAX + delta );

    return QwtInterval( value - delta, value + delta );
pixhawk's avatar
pixhawk committed
410 411 412 413 414 415 416 417
}

/*!
  Change a scale attribute

  \param attribute Attribute to change
  \param on On/Off

Bryant's avatar
Bryant committed
418
  \sa Attribute, testAttribute()
pixhawk's avatar
pixhawk committed
419
*/
Bryant's avatar
Bryant committed
420
void QwtScaleEngine::setAttribute( Attribute attribute, bool on )
pixhawk's avatar
pixhawk committed
421
{
Bryant's avatar
Bryant committed
422
    if ( on )
423
        d_data->attributes |= attribute;
pixhawk's avatar
pixhawk committed
424
    else
Bryant's avatar
Bryant committed
425
        d_data->attributes &= ~attribute;
pixhawk's avatar
pixhawk committed
426 427 428
}

/*!
Bryant's avatar
Bryant committed
429
  \return True, if attribute is enabled.
pixhawk's avatar
pixhawk committed
430 431

  \param attribute Attribute to be tested
Bryant's avatar
Bryant committed
432
  \sa Attribute, setAttribute()
pixhawk's avatar
pixhawk committed
433
*/
Bryant's avatar
Bryant committed
434
bool QwtScaleEngine::testAttribute( Attribute attribute ) const
pixhawk's avatar
pixhawk committed
435
{
Bryant's avatar
Bryant committed
436
    return ( d_data->attributes & attribute );
pixhawk's avatar
pixhawk committed
437 438 439 440 441 442
}

/*!
  Change the scale attribute

  \param attributes Set scale attributes
Bryant's avatar
Bryant committed
443
  \sa Attribute, attributes()
pixhawk's avatar
pixhawk committed
444
*/
Bryant's avatar
Bryant committed
445
void QwtScaleEngine::setAttributes( Attributes attributes )
pixhawk's avatar
pixhawk committed
446 447 448 449 450
{
    d_data->attributes = attributes;
}

/*!
Bryant's avatar
Bryant committed
451 452
  \return Scale attributes
  \sa Attribute, setAttributes(), testAttribute()
pixhawk's avatar
pixhawk committed
453
*/
Bryant's avatar
Bryant committed
454
QwtScaleEngine::Attributes QwtScaleEngine::attributes() const
pixhawk's avatar
pixhawk committed
455 456 457 458 459 460 461 462
{
    return d_data->attributes;
}

/*!
  \brief Specify a reference point
  \param r new reference value

Bryant's avatar
Bryant committed
463
  The reference point is needed if options IncludeReference or
pixhawk's avatar
pixhawk committed
464
  Symmetric are active. Its default value is 0.0.
Bryant's avatar
Bryant committed
465 466

  \sa Attribute
pixhawk's avatar
pixhawk committed
467
*/
Bryant's avatar
Bryant committed
468
void QwtScaleEngine::setReference( double r )
pixhawk's avatar
pixhawk committed
469 470 471 472 473
{
    d_data->referenceValue = r;
}

/*!
Bryant's avatar
Bryant committed
474 475
  \return the reference value
  \sa setReference(), setAttribute()
pixhawk's avatar
pixhawk committed
476
*/
477 478 479
double QwtScaleEngine::reference() const
{
    return d_data->referenceValue;
pixhawk's avatar
pixhawk committed
480 481 482
}

/*!
Bryant's avatar
Bryant committed
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503
  Set the base of the scale engine

  While a base of 10 is what 99.9% of all applications need
  certain scales might need a different base: f.e 2

  The default setting is 10

  \param base Base of the engine

  \sa base()
 */
void QwtScaleEngine::setBase( uint base )
{ 
    d_data->base = qMax( base, 2U );
}

/*!
  \return base Base of the scale engine
  \sa setBase()
 */
uint QwtScaleEngine::base() const
pixhawk's avatar
pixhawk committed
504
{
Bryant's avatar
Bryant committed
505
    return d_data->base;
pixhawk's avatar
pixhawk committed
506 507 508
}

/*!
Bryant's avatar
Bryant committed
509
  Constructor
pixhawk's avatar
pixhawk committed
510

Bryant's avatar
Bryant committed
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525
  \param base Base of the scale engine
  \sa setBase()
 */
QwtLinearScaleEngine::QwtLinearScaleEngine( uint base ):
    QwtScaleEngine( base )
{
}

//! Destructor
QwtLinearScaleEngine::~QwtLinearScaleEngine()
{
}

/*!
  Align and divide an interval
pixhawk's avatar
pixhawk committed
526

Bryant's avatar
Bryant committed
527 528 529 530 531 532
  \param maxNumSteps Max. number of steps
  \param x1 First limit of the interval (In/Out)
  \param x2 Second limit of the interval (In/Out)
  \param stepSize Step size (Out)

  \sa setAttribute()
pixhawk's avatar
pixhawk committed
533
*/
Bryant's avatar
Bryant committed
534 535
void QwtLinearScaleEngine::autoScale( int maxNumSteps,
    double &x1, double &x2, double &stepSize ) const
pixhawk's avatar
pixhawk committed
536
{
Bryant's avatar
Bryant committed
537
    QwtInterval interval( x1, x2 );
pixhawk's avatar
pixhawk committed
538 539
    interval = interval.normalized();

Bryant's avatar
Bryant committed
540 541
    interval.setMinValue( interval.minValue() - lowerMargin() );
    interval.setMaxValue( interval.maxValue() + upperMargin() );
pixhawk's avatar
pixhawk committed
542

Bryant's avatar
Bryant committed
543 544
    if ( testAttribute( QwtScaleEngine::Symmetric ) )
        interval = interval.symmetrize( reference() );
545

Bryant's avatar
Bryant committed
546 547
    if ( testAttribute( QwtScaleEngine::IncludeReference ) )
        interval = interval.extend( reference() );
pixhawk's avatar
pixhawk committed
548

Bryant's avatar
Bryant committed
549 550
    if ( interval.width() == 0.0 )
        interval = buildInterval( interval.minValue() );
pixhawk's avatar
pixhawk committed
551

Bryant's avatar
Bryant committed
552 553
    stepSize = QwtScaleArithmetic::divideInterval( 
        interval.width(), qMax( maxNumSteps, 1 ), base() );
pixhawk's avatar
pixhawk committed
554

Bryant's avatar
Bryant committed
555 556
    if ( !testAttribute( QwtScaleEngine::Floating ) )
        interval = align( interval, stepSize );
pixhawk's avatar
pixhawk committed
557 558 559 560

    x1 = interval.minValue();
    x2 = interval.maxValue();

Bryant's avatar
Bryant committed
561 562 563
    if ( testAttribute( QwtScaleEngine::Inverted ) )
    {
        qSwap( x1, x2 );
pixhawk's avatar
pixhawk committed
564 565 566 567 568
        stepSize = -stepSize;
    }
}

/*!
Bryant's avatar
Bryant committed
569
   \brief Calculate a scale division for an interval
pixhawk's avatar
pixhawk committed
570

571 572
   \param x1 First interval limit
   \param x2 Second interval limit
Bryant's avatar
Bryant committed
573 574 575
   \param maxMajorSteps Maximum for the number of major steps
   \param maxMinorSteps Maximum number of minor steps
   \param stepSize Step size. If stepSize == 0, the engine
pixhawk's avatar
pixhawk committed
576 577
                   calculates one.

Bryant's avatar
Bryant committed
578
   \return Calculated scale division
pixhawk's avatar
pixhawk committed
579
*/
Bryant's avatar
Bryant committed
580 581
QwtScaleDiv QwtLinearScaleEngine::divideScale( double x1, double x2,
    int maxMajorSteps, int maxMinorSteps, double stepSize ) const
pixhawk's avatar
pixhawk committed
582
{
Bryant's avatar
Bryant committed
583 584
    QwtInterval interval = QwtInterval( x1, x2 ).normalized();
    if ( interval.width() <= 0 )
pixhawk's avatar
pixhawk committed
585 586
        return QwtScaleDiv();

Bryant's avatar
Bryant committed
587 588 589 590 591
    stepSize = qAbs( stepSize );
    if ( stepSize == 0.0 )
    {
        if ( maxMajorSteps < 1 )
            maxMajorSteps = 1;
pixhawk's avatar
pixhawk committed
592

Bryant's avatar
Bryant committed
593 594
        stepSize = QwtScaleArithmetic::divideInterval( 
            interval.width(), maxMajorSteps, base() );
pixhawk's avatar
pixhawk committed
595 596 597 598
    }

    QwtScaleDiv scaleDiv;

Bryant's avatar
Bryant committed
599 600 601 602
    if ( stepSize != 0.0 )
    {
        QList<double> ticks[QwtScaleDiv::NTickTypes];
        buildTicks( interval, stepSize, maxMinorSteps, ticks );
pixhawk's avatar
pixhawk committed
603

Bryant's avatar
Bryant committed
604
        scaleDiv = QwtScaleDiv( interval, ticks );
pixhawk's avatar
pixhawk committed
605 606 607 608 609 610 611 612
    }

    if ( x1 > x2 )
        scaleDiv.invert();

    return scaleDiv;
}

Bryant's avatar
Bryant committed
613 614 615 616 617 618 619 620 621 622
/*!
   \brief Calculate ticks for an interval

   \param interval Interval
   \param stepSize Step size
   \param maxMinorSteps Maximum number of minor steps
   \param ticks Arrays to be filled with the calculated ticks

   \sa buildMajorTicks(), buildMinorTicks
*/
pixhawk's avatar
pixhawk committed
623
void QwtLinearScaleEngine::buildTicks(
Bryant's avatar
Bryant committed
624 625
    const QwtInterval& interval, double stepSize, int maxMinorSteps,
    QList<double> ticks[QwtScaleDiv::NTickTypes] ) const
pixhawk's avatar
pixhawk committed
626
{
Bryant's avatar
Bryant committed
627
    const QwtInterval boundingInterval = align( interval, stepSize );
628 629

    ticks[QwtScaleDiv::MajorTick] =
Bryant's avatar
Bryant committed
630
        buildMajorTicks( boundingInterval, stepSize );
pixhawk's avatar
pixhawk committed
631

Bryant's avatar
Bryant committed
632 633 634 635
    if ( maxMinorSteps > 0 )
    {
        buildMinorTicks( ticks[QwtScaleDiv::MajorTick], maxMinorSteps, stepSize,
            ticks[QwtScaleDiv::MinorTick], ticks[QwtScaleDiv::MediumTick] );
pixhawk's avatar
pixhawk committed
636
    }
637

Bryant's avatar
Bryant committed
638 639 640
    for ( int i = 0; i < QwtScaleDiv::NTickTypes; i++ )
    {
        ticks[i] = strip( ticks[i], interval );
pixhawk's avatar
pixhawk committed
641

642
        // ticks very close to 0.0 are
pixhawk's avatar
pixhawk committed
643 644
        // explicitely set to 0.0

Bryant's avatar
Bryant committed
645 646 647
        for ( int j = 0; j < ticks[i].count(); j++ )
        {
            if ( qwtFuzzyCompare( ticks[i][j], 0.0, stepSize ) == 0 )
pixhawk's avatar
pixhawk committed
648 649 650 651 652
                ticks[i][j] = 0.0;
        }
    }
}

Bryant's avatar
Bryant committed
653 654 655 656 657 658 659 660 661 662
/*!
   \brief Calculate major ticks for an interval

   \param interval Interval
   \param stepSize Step size

   \return Calculated ticks
*/
QList<double> QwtLinearScaleEngine::buildMajorTicks(
    const QwtInterval &interval, double stepSize ) const
pixhawk's avatar
pixhawk committed
663
{
Bryant's avatar
Bryant committed
664
    int numTicks = qRound( interval.width() / stepSize ) + 1;
pixhawk's avatar
pixhawk committed
665 666 667
    if ( numTicks > 10000 )
        numTicks = 10000;

Bryant's avatar
Bryant committed
668
    QList<double> ticks;
pixhawk's avatar
pixhawk committed
669 670

    ticks += interval.minValue();
Bryant's avatar
Bryant committed
671
    for ( int i = 1; i < numTicks - 1; i++ )
pixhawk's avatar
pixhawk committed
672 673 674 675 676 677
        ticks += interval.minValue() + i * stepSize;
    ticks += interval.maxValue();

    return ticks;
}

Bryant's avatar
Bryant committed
678 679 680 681 682 683 684 685 686 687
/*!
   \brief Calculate minor/medium ticks for major ticks

   \param majorTicks Major ticks
   \param maxMinorSteps Maximum number of minor steps
   \param stepSize Step size
   \param minorTicks Array to be filled with the calculated minor ticks
   \param mediumTicks Array to be filled with the calculated medium ticks

*/
pixhawk's avatar
pixhawk committed
688
void QwtLinearScaleEngine::buildMinorTicks(
Bryant's avatar
Bryant committed
689 690 691 692
    const QList<double>& majorTicks,
    int maxMinorSteps, double stepSize,
    QList<double> &minorTicks,
    QList<double> &mediumTicks ) const
693
{
Bryant's avatar
Bryant committed
694 695
    double minStep = qwtStepSize( stepSize, maxMinorSteps, base() );
    if ( minStep == 0.0 )
696 697
        return;

pixhawk's avatar
pixhawk committed
698
    // # ticks per interval
Bryant's avatar
Bryant committed
699
    const int numTicks = qCeil( qAbs( stepSize / minStep ) ) - 1;
pixhawk's avatar
pixhawk committed
700 701 702 703 704 705 706

    int medIndex = -1;
    if ( numTicks % 2 )
        medIndex = numTicks / 2;

    // calculate minor ticks

Bryant's avatar
Bryant committed
707 708
    for ( int i = 0; i < majorTicks.count(); i++ )
    {
pixhawk's avatar
pixhawk committed
709
        double val = majorTicks[i];
Bryant's avatar
Bryant committed
710 711
        for ( int k = 0; k < numTicks; k++ )
        {
pixhawk's avatar
pixhawk committed
712 713 714
            val += minStep;

            double alignedValue = val;
Bryant's avatar
Bryant committed
715
            if ( qwtFuzzyCompare( val, 0.0, stepSize ) == 0 )
pixhawk's avatar
pixhawk committed
716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736
                alignedValue = 0.0;

            if ( k == medIndex )
                mediumTicks += alignedValue;
            else
                minorTicks += alignedValue;
        }
    }
}

/*!
  \brief Align an interval to a step size

  The limits of an interval are aligned that both are integer
  multiples of the step size.

  \param interval Interval
  \param stepSize Step size

  \return Aligned interval
*/
Bryant's avatar
Bryant committed
737 738
QwtInterval QwtLinearScaleEngine::align(
    const QwtInterval &interval, double stepSize ) const
pixhawk's avatar
pixhawk committed
739
{
Bryant's avatar
Bryant committed
740 741 742 743 744 745 746 747 748
    double x1 = interval.minValue();
    double x2 = interval.maxValue();

    if ( -DBL_MAX + stepSize <= x1 )
    {
        const double x = QwtScaleArithmetic::floorEps( x1, stepSize );
        if ( qwtFuzzyCompare( x1, x, stepSize ) != 0 )
            x1 = x;
    }
pixhawk's avatar
pixhawk committed
749

Bryant's avatar
Bryant committed
750 751 752 753 754 755 756 757
    if ( DBL_MAX - stepSize >= x2 )
    {
        const double x = QwtScaleArithmetic::ceilEps( x2, stepSize );
        if ( qwtFuzzyCompare( x2, x, stepSize ) != 0 )
            x2 = x;
    }

    return QwtInterval( x1, x2 );
pixhawk's avatar
pixhawk committed
758 759 760
}

/*!
Bryant's avatar
Bryant committed
761 762 763 764 765 766 767 768 769 770 771 772 773
  Constructor

  \param base Base of the scale engine
  \sa setBase()
 */
QwtLogScaleEngine::QwtLogScaleEngine( uint base ):
    QwtScaleEngine( base )
{
    setTransformation( new QwtLogTransform() );
}

//! Destructor
QwtLogScaleEngine::~QwtLogScaleEngine()
pixhawk's avatar
pixhawk committed
774 775 776 777 778 779 780 781 782 783 784
{
}

/*!
    Align and divide an interval

   \param maxNumSteps Max. number of steps
   \param x1 First limit of the interval (In/Out)
   \param x2 Second limit of the interval (In/Out)
   \param stepSize Step size (Out)

Bryant's avatar
Bryant committed
785
   \sa QwtScaleEngine::setAttribute()
pixhawk's avatar
pixhawk committed
786
*/
Bryant's avatar
Bryant committed
787 788
void QwtLogScaleEngine::autoScale( int maxNumSteps,
    double &x1, double &x2, double &stepSize ) const
pixhawk's avatar
pixhawk committed
789 790
{
    if ( x1 > x2 )
Bryant's avatar
Bryant committed
791
        qSwap( x1, x2 );
pixhawk's avatar
pixhawk committed
792

Bryant's avatar
Bryant committed
793
    const double logBase = base();
pixhawk's avatar
pixhawk committed
794

Bryant's avatar
Bryant committed
795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810
    QwtInterval interval( x1 / qPow( logBase, lowerMargin() ),
        x2 * qPow( logBase, upperMargin() ) );

    if ( interval.maxValue() / interval.minValue() < logBase )
    {
        // scale width is less than one step -> try to build a linear scale

        QwtLinearScaleEngine linearScaler;
        linearScaler.setAttributes( attributes() );
        linearScaler.setReference( reference() );
        linearScaler.setMargins( lowerMargin(), upperMargin() );

        linearScaler.autoScale( maxNumSteps, x1, x2, stepSize );

        QwtInterval linearInterval = QwtInterval( x1, x2 ).normalized();
        linearInterval = linearInterval.limited( LOG_MIN, LOG_MAX );
pixhawk's avatar
pixhawk committed
811

Bryant's avatar
Bryant committed
812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832
        if ( linearInterval.maxValue() / linearInterval.minValue() < logBase )
        {
            // the aligned scale is still less than one step
            if ( stepSize < 0.0 )
                stepSize = -qwtLog( logBase, qAbs( stepSize ) );
            else
                stepSize = qwtLog( logBase, stepSize );

            return;
        }
    }

    double logRef = 1.0;
    if ( reference() > LOG_MIN / 2 )
        logRef = qMin( reference(), LOG_MAX / 2 );

    if ( testAttribute( QwtScaleEngine::Symmetric ) )
    {
        const double delta = qMax( interval.maxValue() / logRef,
            logRef / interval.minValue() );
        interval.setInterval( logRef / delta, logRef * delta );
pixhawk's avatar
pixhawk committed
833 834
    }

Bryant's avatar
Bryant committed
835 836
    if ( testAttribute( QwtScaleEngine::IncludeReference ) )
        interval = interval.extend( logRef );
pixhawk's avatar
pixhawk committed
837

Bryant's avatar
Bryant committed
838
    interval = interval.limited( LOG_MIN, LOG_MAX );
pixhawk's avatar
pixhawk committed
839

Bryant's avatar
Bryant committed
840 841
    if ( interval.width() == 0.0 )
        interval = buildInterval( interval.minValue() );
pixhawk's avatar
pixhawk committed
842

Bryant's avatar
Bryant committed
843 844
    stepSize = divideInterval( qwtLogInterval( logBase, interval ).width(), 
        qMax( maxNumSteps, 1 ) );
pixhawk's avatar
pixhawk committed
845 846 847
    if ( stepSize < 1.0 )
        stepSize = 1.0;

Bryant's avatar
Bryant committed
848 849
    if ( !testAttribute( QwtScaleEngine::Floating ) )
        interval = align( interval, stepSize );
pixhawk's avatar
pixhawk committed
850 851 852 853

    x1 = interval.minValue();
    x2 = interval.maxValue();

Bryant's avatar
Bryant committed
854 855 856
    if ( testAttribute( QwtScaleEngine::Inverted ) )
    {
        qSwap( x1, x2 );
pixhawk's avatar
pixhawk committed
857 858 859 860 861
        stepSize = -stepSize;
    }
}

/*!
Bryant's avatar
Bryant committed
862
   \brief Calculate a scale division for an interval
pixhawk's avatar
pixhawk committed
863

864 865
   \param x1 First interval limit
   \param x2 Second interval limit
Bryant's avatar
Bryant committed
866 867 868
   \param maxMajorSteps Maximum for the number of major steps
   \param maxMinorSteps Maximum number of minor steps
   \param stepSize Step size. If stepSize == 0, the engine
pixhawk's avatar
pixhawk committed
869 870
                   calculates one.

Bryant's avatar
Bryant committed
871
   \return Calculated scale division
pixhawk's avatar
pixhawk committed
872
*/
Bryant's avatar
Bryant committed
873 874
QwtScaleDiv QwtLogScaleEngine::divideScale( double x1, double x2,
    int maxMajorSteps, int maxMinorSteps, double stepSize ) const
pixhawk's avatar
pixhawk committed
875
{
Bryant's avatar
Bryant committed
876 877
    QwtInterval interval = QwtInterval( x1, x2 ).normalized();
    interval = interval.limited( LOG_MIN, LOG_MAX );
pixhawk's avatar
pixhawk committed
878

Bryant's avatar
Bryant committed
879
    if ( interval.width() <= 0 )
pixhawk's avatar
pixhawk committed
880 881
        return QwtScaleDiv();

Bryant's avatar
Bryant committed
882 883 884 885
    const double logBase = base();

    if ( interval.maxValue() / interval.minValue() < logBase )
    {
pixhawk's avatar
pixhawk committed
886
        // scale width is less than one decade -> build linear scale
887

pixhawk's avatar
pixhawk committed
888
        QwtLinearScaleEngine linearScaler;
Bryant's avatar
Bryant committed
889 890 891 892 893 894 895 896 897 898 899
        linearScaler.setAttributes( attributes() );
        linearScaler.setReference( reference() );
        linearScaler.setMargins( lowerMargin(), upperMargin() );

        if ( stepSize != 0.0 )
        {
            if ( stepSize < 0.0 )
                stepSize = -qPow( logBase, -stepSize );
            else
                stepSize = qPow( logBase, stepSize );
        }
pixhawk's avatar
pixhawk committed
900

Bryant's avatar
Bryant committed
901 902
        return linearScaler.divideScale( x1, x2,
            maxMajorSteps, maxMinorSteps, stepSize );
pixhawk's avatar
pixhawk committed
903 904
    }

Bryant's avatar
Bryant committed
905 906 907 908 909
    stepSize = qAbs( stepSize );
    if ( stepSize == 0.0 )
    {
        if ( maxMajorSteps < 1 )
            maxMajorSteps = 1;
pixhawk's avatar
pixhawk committed
910

Bryant's avatar
Bryant committed
911 912
        stepSize = divideInterval( 
            qwtLogInterval( logBase, interval ).width(), maxMajorSteps );
pixhawk's avatar
pixhawk committed
913 914 915 916 917
        if ( stepSize < 1.0 )
            stepSize = 1.0; // major step must be >= 1 decade
    }

    QwtScaleDiv scaleDiv;
Bryant's avatar
Bryant committed
918 919 920 921
    if ( stepSize != 0.0 )
    {
        QList<double> ticks[QwtScaleDiv::NTickTypes];
        buildTicks( interval, stepSize, maxMinorSteps, ticks );
pixhawk's avatar
pixhawk committed
922

Bryant's avatar
Bryant committed
923
        scaleDiv = QwtScaleDiv( interval, ticks );
pixhawk's avatar
pixhawk committed
924 925 926 927 928 929 930 931
    }

    if ( x1 > x2 )
        scaleDiv.invert();

    return scaleDiv;
}

Bryant's avatar
Bryant committed
932 933 934 935 936 937 938 939 940 941 942 943 944
/*!
   \brief Calculate ticks for an interval

   \param interval Interval
   \param maxMinorSteps Maximum number of minor steps
   \param stepSize Step size
   \param ticks Arrays to be filled with the calculated ticks

   \sa buildMajorTicks(), buildMinorTicks
*/
void QwtLogScaleEngine::buildTicks(
    const QwtInterval& interval, double stepSize, int maxMinorSteps,
    QList<double> ticks[QwtScaleDiv::NTickTypes] ) const
pixhawk's avatar
pixhawk committed
945
{
Bryant's avatar
Bryant committed
946
    const QwtInterval boundingInterval = align( interval, stepSize );
947 948

    ticks[QwtScaleDiv::MajorTick] =
Bryant's avatar
Bryant committed
949
        buildMajorTicks( boundingInterval, stepSize );
pixhawk's avatar
pixhawk committed
950

Bryant's avatar
Bryant committed
951 952 953 954
    if ( maxMinorSteps > 0 )
    {
        buildMinorTicks( ticks[QwtScaleDiv::MajorTick], maxMinorSteps, stepSize,
            ticks[QwtScaleDiv::MinorTick], ticks[QwtScaleDiv::MediumTick] );
pixhawk's avatar
pixhawk committed
955
    }
956

pixhawk's avatar
pixhawk committed
957
    for ( int i = 0; i < QwtScaleDiv::NTickTypes; i++ )
Bryant's avatar
Bryant committed
958
        ticks[i] = strip( ticks[i], interval );
pixhawk's avatar
pixhawk committed
959 960
}

Bryant's avatar
Bryant committed
961 962 963 964 965 966 967 968 969 970
/*!
   \brief Calculate major ticks for an interval

   \param interval Interval
   \param stepSize Step size

   \return Calculated ticks
*/
QList<double> QwtLogScaleEngine::buildMajorTicks(
    const QwtInterval &interval, double stepSize ) const
pixhawk's avatar
pixhawk committed
971
{
Bryant's avatar
Bryant committed
972
    double width = qwtLogInterval( base(), interval ).width();
pixhawk's avatar
pixhawk committed
973

Bryant's avatar
Bryant committed
974
    int numTicks = qRound( width / stepSize ) + 1;
pixhawk's avatar
pixhawk committed
975 976 977
    if ( numTicks > 10000 )
        numTicks = 10000;

Bryant's avatar
Bryant committed
978 979 980
    const double lxmin = ::log( interval.minValue() );
    const double lxmax = ::log( interval.maxValue() );
    const double lstep = ( lxmax - lxmin ) / double( numTicks - 1 );
pixhawk's avatar
pixhawk committed
981

Bryant's avatar
Bryant committed
982
    QList<double> ticks;
pixhawk's avatar
pixhawk committed
983 984 985

    ticks += interval.minValue();

Bryant's avatar
Bryant committed
986 987
    for ( int i = 1; i < numTicks - 1; i++ )
        ticks += qExp( lxmin + double( i ) * lstep );
pixhawk's avatar
pixhawk committed
988 989 990 991 992 993

    ticks += interval.maxValue();

    return ticks;
}

Bryant's avatar
Bryant committed
994 995
/*!
   \brief Calculate minor/medium ticks for major ticks
pixhawk's avatar
pixhawk committed
996

Bryant's avatar
Bryant committed
997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009
   \param majorTicks Major ticks
   \param maxMinorSteps Maximum number of minor steps
   \param stepSize Step size
   \param minorTicks Array to be filled with the calculated minor ticks
   \param mediumTicks Array to be filled with the calculated medium ticks
*/
void QwtLogScaleEngine::buildMinorTicks(
    const QList<double> &majorTicks,
    int maxMinorSteps, double stepSize,
    QList<double> &minorTicks,
    QList<double> &mediumTicks ) const
{
    const double logBase = base();
pixhawk's avatar
pixhawk committed
1010

Bryant's avatar
Bryant committed
1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024
    if ( stepSize < 1.1 )          // major step width is one base
    {
        double minStep = divideInterval( stepSize, maxMinorSteps + 1 );
        if ( minStep == 0.0 )
            return;
        
        const int numSteps = qRound( stepSize / minStep ); 

        int mediumTickIndex = -1;
        if ( ( numSteps > 2 ) && ( numSteps % 2 == 0 ) )
            mediumTickIndex = numSteps / 2;

        for ( int i = 0; i < majorTicks.count() - 1; i++ )
        {
pixhawk's avatar
pixhawk committed
1025
            const double v = majorTicks[i];
Bryant's avatar
Bryant committed
1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045
            const double s = logBase / numSteps;

            if ( s >= 1.0 )
            {
                for ( int j = 2; j < numSteps; j++ )
                {
                    minorTicks += v * j * s;
                }
            }
            else
            {
                for ( int j = 1; j < numSteps; j++ )
                {
                    const double tick = v + j * v * ( logBase - 1 ) / numSteps;
                    if ( j == mediumTickIndex )
                        mediumTicks += tick;
                    else
                        minorTicks += tick;
                }
            }
pixhawk's avatar
pixhawk committed
1046
        }
Bryant's avatar
Bryant committed
1047 1048 1049 1050
    }
    else
    {
        double minStep = divideInterval( stepSize, maxMinorSteps );
pixhawk's avatar
pixhawk committed
1051
        if ( minStep == 0.0 )
Bryant's avatar
Bryant committed
1052
            return;
pixhawk's avatar
pixhawk committed
1053 1054 1055 1056 1057

        if ( minStep < 1.0 )
            minStep = 1.0;

        // # subticks per interval
Bryant's avatar
Bryant committed
1058
        int numTicks = qRound( stepSize / minStep ) - 1;
pixhawk's avatar
pixhawk committed
1059 1060

        // Do the minor steps fit into the interval?
Bryant's avatar
Bryant committed
1061 1062 1063 1064
        if ( qwtFuzzyCompare( ( numTicks +  1 ) * minStep,
            stepSize, stepSize ) > 0 )
        {
            numTicks = 0;
pixhawk's avatar
pixhawk committed
1065 1066
        }

Bryant's avatar
Bryant committed
1067 1068 1069 1070 1071 1072 1073 1074 1075
        if ( numTicks < 1 )
            return; 

        int mediumTickIndex = -1;
        if ( ( numTicks > 2 ) && ( numTicks % 2 ) )
            mediumTickIndex = numTicks / 2;

        // substep factor = base^substeps
        const qreal minFactor = qMax( qPow( logBase, minStep ), qreal( logBase ) );
pixhawk's avatar
pixhawk committed
1076

Bryant's avatar
Bryant committed
1077 1078 1079 1080 1081 1082
        for ( int i = 0; i < majorTicks.count(); i++ )
        {
            double tick = majorTicks[i];
            for ( int j = 0; j < numTicks; j++ )
            {
                tick *= minFactor;
pixhawk's avatar
pixhawk committed
1083

Bryant's avatar
Bryant committed
1084 1085 1086 1087
                if ( j == mediumTickIndex )
                    mediumTicks += tick;
                else
                    minorTicks += tick;
pixhawk's avatar
pixhawk committed
1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103
            }
        }
    }
}

/*!
  \brief Align an interval to a step size

  The limits of an interval are aligned that both are integer
  multiples of the step size.

  \param interval Interval
  \param stepSize Step size

  \return Aligned interval
*/
Bryant's avatar
Bryant committed
1104 1105
QwtInterval QwtLogScaleEngine::align(
    const QwtInterval &interval, double stepSize ) const
pixhawk's avatar
pixhawk committed
1106
{
Bryant's avatar
Bryant committed
1107
    const QwtInterval intv = qwtLogInterval( base(), interval );
pixhawk's avatar
pixhawk committed
1108

Bryant's avatar
Bryant committed
1109 1110 1111
    double x1 = QwtScaleArithmetic::floorEps( intv.minValue(), stepSize );
    if ( qwtFuzzyCompare( interval.minValue(), x1, stepSize ) == 0 )
        x1 = interval.minValue();
pixhawk's avatar
pixhawk committed
1112

Bryant's avatar
Bryant committed
1113 1114 1115
    double x2 = QwtScaleArithmetic::ceilEps( intv.maxValue(), stepSize );
    if ( qwtFuzzyCompare( interval.maxValue(), x2, stepSize ) == 0 )
        x2 = interval.maxValue();
pixhawk's avatar
pixhawk committed
1116

Bryant's avatar
Bryant committed
1117
    return qwtPowInterval( base(), QwtInterval( x1, x2 ) );
pixhawk's avatar
pixhawk committed
1118
}