A scale engine for logarithmic (base 10) scales. More...
#include <qwt_scale_engine.h>


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 QwtScaleTransformation * | transformation () const |
Protected Member Functions | |
| QwtDoubleInterval | log10 (const QwtDoubleInterval &) const |
| QwtDoubleInterval | pow10 (const QwtDoubleInterval &) const |
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
, where n is a natural number including zero.
Definition at line 182 of file qwt_scale_engine.h.
| void QwtLog10ScaleEngine::autoScale | ( | int | maxNumSteps, |
| double & | x1, | ||
| double & | x2, | ||
| double & | stepSize | ||
| ) | const [virtual] |
Align and divide an interval
| maxNumSteps | Max. number of steps |
| x1 | First limit of the interval (In/Out) |
| x2 | Second limit of the interval (In/Out) |
| stepSize | Step size (Out) |
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.
| x1 | First interval limit |
| x2 | Second interval limit |
| maxMajSteps | Maximum for the number of major steps |
| maxMinSteps | Maximum number of minor steps |
| stepSize | Step size. If stepSize == 0, the scaleEngine calculates one. |
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.
{
return new QwtScaleTransformation(QwtScaleTransformation::Log10);
}
1.7.2