A scale engine for linear 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 | align (const QwtDoubleInterval &, double stepSize) const |
| Align an interval to a step size. | |
A scale engine for linear scales.
The step size will fit into the pattern
, where n is an integer.
Definition at line 141 of file qwt_scale_engine.h.
| 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.
| interval | Interval |
| stepSize | Step size |
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
| 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 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.
| 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 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().
{
return new QwtScaleTransformation(QwtScaleTransformation::Linear);
}
1.7.2