Public Member Functions | Protected Member Functions

QwtLinearScaleEngine Class Reference

A scale engine for linear scales. More...

#include <qwt_scale_engine.h>

Inheritance diagram for QwtLinearScaleEngine:
Inheritance graph
[legend]
Collaboration diagram for QwtLinearScaleEngine:
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 align (const QwtDoubleInterval &, double stepSize) const
 Align an interval to a step size.

Detailed Description

A scale engine for linear scales.

The step size will fit into the pattern $\left\{ 1,2,5\right\} \cdot 10^{n}$, where n is an integer.

Definition at line 141 of file qwt_scale_engine.h.


Member Function Documentation

QwtDoubleInterval QwtLinearScaleEngine::align ( const QwtDoubleInterval interval,
double  stepSize 
) const [protected]

Align an interval to a step size.

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

Parameters:
intervalInterval
stepSizeStep size
Returns:
Aligned interval

Definition at line 585 of file qwt_scale_engine.cpp.

References QwtScaleArithmetic::ceilEps(), QwtScaleArithmetic::floorEps(), QwtDoubleInterval::maxValue(), and QwtDoubleInterval::minValue().

Referenced by autoScale().

{
    const double x1 = 
        QwtScaleArithmetic::floorEps(interval.minValue(), stepSize);
    const double x2 = 
        QwtScaleArithmetic::ceilEps(interval.maxValue(), stepSize);

    return QwtDoubleInterval(x1, x2);
}
void QwtLinearScaleEngine::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:
setAttribute()

Implements QwtScaleEngine.

Definition at line 403 of file qwt_scale_engine.cpp.

References align(), QwtScaleEngine::buildInterval(), QwtScaleEngine::divideInterval(), QwtDoubleInterval::extend(), QwtScaleEngine::Floating, QwtScaleEngine::IncludeReference, QwtScaleEngine::Inverted, QwtScaleEngine::lowerMargin(), QwtDoubleInterval::maxValue(), QwtDoubleInterval::minValue(), QwtDoubleInterval::normalized(), qwtMax, QwtScaleEngine::reference(), QwtDoubleInterval::setMaxValue(), QwtDoubleInterval::setMinValue(), QwtScaleEngine::Symmetric, QwtDoubleInterval::symmetrize(), QwtScaleEngine::testAttribute(), QwtScaleEngine::upperMargin(), and QwtDoubleInterval::width().

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

    interval.setMinValue(interval.minValue() - lowerMargin());
    interval.setMaxValue(interval.maxValue() + upperMargin());

    if (testAttribute(QwtScaleEngine::Symmetric))
        interval = interval.symmetrize(reference());
 
    if (testAttribute(QwtScaleEngine::IncludeReference))
        interval = interval.extend(reference());

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

    stepSize = divideInterval(interval.width(), qwtMax(maxNumSteps, 1));

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

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

    if (testAttribute(QwtScaleEngine::Inverted))
    {
        qSwap(x1, x2);
        stepSize = -stepSize;
    }
}
QwtScaleDiv QwtLinearScaleEngine::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(), QwtScaleEngine::subDivide()

Implements QwtScaleEngine.

Definition at line 448 of file qwt_scale_engine.cpp.

References QwtScaleEngine::divideInterval(), QwtScaleDiv::invert(), QwtDoubleInterval::normalized(), QwtScaleDiv::NTickTypes, qwtAbs, and QwtDoubleInterval::width().

Referenced by QwtLog10ScaleEngine::divideScale(), and QwtDial::updateScale().

{
    QwtDoubleInterval interval = QwtDoubleInterval(x1, x2).normalized();
    if (interval.width() <= 0 )
        return QwtScaleDiv();

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

        stepSize = divideInterval(interval.width(), maxMajSteps);
    }

    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;
}
QwtScaleTransformation * QwtLinearScaleEngine::transformation (  ) const [virtual]

Return a transformation, for linear scales

Implements QwtScaleEngine.

Definition at line 388 of file qwt_scale_engine.cpp.

References QwtScaleTransformation::Linear.

Referenced by QwtDial::updateScale().


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