Public Member Functions | Protected Member Functions

QwtLog10ScaleEngine Class Reference

A scale engine for logarithmic (base 10) scales. More...

#include <qwt_scale_engine.h>

Inheritance diagram for QwtLog10ScaleEngine:
Inheritance graph
[legend]
Collaboration diagram for QwtLog10ScaleEngine:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual void autoScale (int maxSteps, double &x1, double &x2, double &stepSize) const
virtual QwtScaleDiv divideScale (double x1, double x2, int numMajorSteps, int numMinorSteps, double stepSize=0.0) const
 Calculate a scale division.
virtual QwtScaleTransformationtransformation () const

Protected Member Functions

QwtDoubleInterval log10 (const QwtDoubleInterval &) const
QwtDoubleInterval pow10 (const QwtDoubleInterval &) const

Detailed Description

A scale engine for logarithmic (base 10) scales.

The step size is measured in *decades* and the major step size will be adjusted to fit the pattern $\left\{ 1,2,3,5\right\} \cdot 10^{n}$, where n is a natural number including zero.

Warning:
the step size as well as the margins are measured in *decades*.

Definition at line 182 of file qwt_scale_engine.h.


Member Function Documentation

void QwtLog10ScaleEngine::autoScale ( int  maxNumSteps,
double &  x1,
double &  x2,
double &  stepSize 
) const [virtual]

Align and divide an interval

Parameters:
maxNumStepsMax. number of steps
x1First limit of the interval (In/Out)
x2Second limit of the interval (In/Out)
stepSizeStep size (Out)
See also:
QwtScaleEngine::setAttribute()

Implements QwtScaleEngine.

Definition at line 614 of file qwt_scale_engine.cpp.

References QwtScaleEngine::buildInterval(), QwtScaleEngine::divideInterval(), QwtDoubleInterval::extend(), QwtScaleEngine::Floating, QwtScaleEngine::IncludeReference, QwtScaleEngine::Inverted, QwtDoubleInterval::limited(), log10(), LOG_MAX, LOG_MIN, QwtScaleEngine::lowerMargin(), QwtDoubleInterval::maxValue(), QwtDoubleInterval::minValue(), QuadProgPP::pow(), qwtMax, qwtMin, QwtScaleEngine::reference(), QwtDoubleInterval::setInterval(), QwtScaleEngine::Symmetric, QwtScaleEngine::testAttribute(), QwtScaleEngine::upperMargin(), and QwtDoubleInterval::width().

{
    if ( x1 > x2 )
        qSwap(x1, x2);

    QwtDoubleInterval interval(x1 / pow(10.0, lowerMargin()), 
        x2 * pow(10.0, upperMargin()) );

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

    if (testAttribute(QwtScaleEngine::Symmetric))
    {
        const double delta = qwtMax(interval.maxValue() / logRef,  
            logRef / interval.minValue());
        interval.setInterval(logRef / delta, logRef * delta);
    }

    if (testAttribute(QwtScaleEngine::IncludeReference))
        interval = interval.extend(logRef);

    interval = interval.limited(LOG_MIN, LOG_MAX);

    if (interval.width() == 0.0)
        interval = buildInterval(interval.minValue());

    stepSize = divideInterval(log10(interval).width(), qwtMax(maxNumSteps, 1));
    if ( stepSize < 1.0 )
        stepSize = 1.0;

    if (!testAttribute(QwtScaleEngine::Floating))
        interval = align(interval, stepSize);

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

    if (testAttribute(QwtScaleEngine::Inverted))
    {
        qSwap(x1, x2);
        stepSize = -stepSize;
    }
}
QwtScaleDiv QwtLog10ScaleEngine::divideScale ( double  x1,
double  x2,
int  maxMajSteps,
int  maxMinSteps,
double  stepSize = 0.0 
) const [virtual]

Calculate a scale division.

Parameters:
x1First interval limit
x2Second interval limit
maxMajStepsMaximum for the number of major steps
maxMinStepsMaximum number of minor steps
stepSizeStep size. If stepSize == 0, the scaleEngine calculates one.
See also:
QwtScaleEngine::stepSize(), QwtLog10ScaleEngine::subDivide()

Implements QwtScaleEngine.

Definition at line 671 of file qwt_scale_engine.cpp.

References QwtScaleEngine::attributes(), QwtScaleEngine::divideInterval(), QwtLinearScaleEngine::divideScale(), QwtScaleDiv::invert(), QwtDoubleInterval::limited(), log10(), LOG_MAX, LOG_MIN, QwtScaleEngine::lowerMargin(), QwtDoubleInterval::maxValue(), QwtDoubleInterval::minValue(), QwtDoubleInterval::normalized(), qwtAbs, QwtScaleEngine::reference(), QwtScaleEngine::setAttributes(), QwtScaleEngine::setMargins(), QwtScaleEngine::setReference(), QwtScaleEngine::upperMargin(), and QwtDoubleInterval::width().

{
    QwtDoubleInterval interval = QwtDoubleInterval(x1, x2).normalized();
    interval = interval.limited(LOG_MIN, LOG_MAX);

    if (interval.width() <= 0 )
        return QwtScaleDiv();

    if (interval.maxValue() / interval.minValue() < 10.0)
    {
        // scale width is less than one decade -> build linear scale
    
        QwtLinearScaleEngine linearScaler;
        linearScaler.setAttributes(attributes());
        linearScaler.setReference(reference());
        linearScaler.setMargins(lowerMargin(), upperMargin());

        return linearScaler.divideScale(x1, x2, 
            maxMajSteps, maxMinSteps, stepSize);
    }

    stepSize = qwtAbs(stepSize);
    if ( stepSize == 0.0 )
    {
        if ( maxMajSteps < 1 )
            maxMajSteps = 1;

        stepSize = divideInterval(log10(interval).width(), maxMajSteps);
        if ( stepSize < 1.0 )
            stepSize = 1.0; // major step must be >= 1 decade
    }

    QwtScaleDiv scaleDiv;
    if ( stepSize != 0.0 )
    {
        QwtValueList ticks[QwtScaleDiv::NTickTypes];
        buildTicks(interval, stepSize, maxMinSteps, ticks);

        scaleDiv = QwtScaleDiv(interval, ticks);
    }

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

    return scaleDiv;
}
QwtDoubleInterval QwtLog10ScaleEngine::log10 ( const QwtDoubleInterval interval ) const [protected]

Return the interval [log10(interval.minValue(), log10(interval.maxValue]

Definition at line 877 of file qwt_scale_engine.cpp.

References QwtDoubleInterval::maxValue(), and QwtDoubleInterval::minValue().

Referenced by autoScale(), and divideScale().

{
    return QwtDoubleInterval(::log10(interval.minValue()),
            ::log10(interval.maxValue()));
}
QwtDoubleInterval QwtLog10ScaleEngine::pow10 ( const QwtDoubleInterval interval ) const [protected]

Return the interval [pow10(interval.minValue(), pow10(interval.maxValue]

Definition at line 887 of file qwt_scale_engine.cpp.

References QwtDoubleInterval::maxValue(), QwtDoubleInterval::minValue(), and QuadProgPP::pow().

{
    return QwtDoubleInterval(pow(10.0, interval.minValue()),
            pow(10.0, interval.maxValue()));
}
QwtScaleTransformation * QwtLog10ScaleEngine::transformation (  ) const [virtual]

Return a transformation, for logarithmic (base 10) scales

Implements QwtScaleEngine.

Definition at line 599 of file qwt_scale_engine.cpp.

References QwtScaleTransformation::Log10.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines