本文整理汇总了C++中QwtInterval::limited方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtInterval::limited方法的具体用法?C++ QwtInterval::limited怎么用?C++ QwtInterval::limited使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtInterval
的用法示例。
在下文中一共展示了QwtInterval::limited方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: divideScale
/*!
\brief Calculate a scale division for an interval
\param x1 First interval limit
\param x2 Second interval limit
\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
calculates one.
\return Calculated scale division
*/
QwtScaleDiv QwtLogScaleEngine::divideScale( double x1, double x2,
int maxMajorSteps, int maxMinorSteps, double stepSize ) const
{
QwtInterval interval = QwtInterval( x1, x2 ).normalized();
interval = interval.limited( LOG_MIN, LOG_MAX );
if ( interval.width() <= 0 )
return QwtScaleDiv();
const double logBase = base();
if ( interval.maxValue() / interval.minValue() < logBase )
{
// scale width is less than one decade -> build linear scale
QwtLinearScaleEngine linearScaler;
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 );
}
return linearScaler.divideScale( x1, x2,
maxMajorSteps, maxMinorSteps, stepSize );
}
stepSize = qAbs( stepSize );
if ( stepSize == 0.0 )
{
if ( maxMajorSteps < 1 )
maxMajorSteps = 1;
stepSize = divideInterval(
qwtLogInterval( logBase, interval ).width(), maxMajorSteps );
if ( stepSize < 1.0 )
stepSize = 1.0; // major step must be >= 1 decade
}
QwtScaleDiv scaleDiv;
if ( stepSize != 0.0 )
{
QList<double> ticks[QwtScaleDiv::NTickTypes];
buildTicks( interval, stepSize, maxMinorSteps, ticks );
scaleDiv = QwtScaleDiv( interval, ticks );
}
if ( x1 > x2 )
scaleDiv.invert();
return scaleDiv;
}
示例2: autoScale
/*!
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)
\sa QwtScaleEngine::setAttribute()
*/
void QwtLogScaleEngine::autoScale( int maxNumSteps,
double &x1, double &x2, double &stepSize ) const
{
if ( x1 > x2 )
qSwap( x1, x2 );
const double logBase = base();
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 );
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 );
}
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( qwtLogInterval( logBase, interval ).width(),
qMax( 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;
}
}