⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qwt_autoscl.cpp

📁 软件无线电的平台
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        d_scaleMin = pow (10.0, step *             floor ((log10(d_scaleMin) + MinEps * step) / step));        d_scaleMax = pow (10.0, step *             ceil ((log10(d_scaleMax) - MinEps * step) / step));    }    if (d_scaleOpt & Inverted)    {        step = -step;        d_scldiv.rebuild(d_scaleMax, d_scaleMin, d_maxMajor, d_maxMinor, TRUE,             step, FALSE);    }    else    {        d_scldiv.rebuild(d_scaleMin, d_scaleMax, d_maxMajor, d_maxMinor,             TRUE, step, TRUE);    }}/*!  \brief Set or reset specified scale options  \param opt or-combined  scale options  \param tf If \c TRUE, set the specified options.  If \c FALSE, reset these options.  \sa QwtAutoScale::setOptions()*/void QwtAutoScale::changeOptions(int opt, bool tf){    if (tf)       d_scaleOpt |= opt;    else       d_scaleOpt &= (~opt);    build();}/*!  \brief Set the interval boundaries to zero and clear the scale division  This member function resets an AutoScale object   to its initial state. It is needed to clean up  the scale before or  after subsequent adjust() calls.  The boundaries of the scale are set to zero  and the scale division is cleared.  \warning A reset doesn't affect the margins.*/void QwtAutoScale::reset(){    d_reset = TRUE;    d_scldiv.reset();    d_minValue = 0;    d_maxValue = 0;    d_step = 0;}/*!  \brief Enable auto-scaling  This function is used to switch back to auto-scaling mode  if the scale has been frozen temporarily (see setScale()).  When auto-scaling is reactivated, the scale will be rebuild, which  means that  \li if adjust or setMaxIntv have been called in between, the scale      will be adjusted to the new conditions.  \li if none of these functions and no reset has been called, the old state      will be restored.  \li if only reset has been called in between, nothing will happen.  \sa QwtAutoScale::setScale()*/void QwtAutoScale::setAutoScale(){    d_autoScale = TRUE;    build();}/*!  \brief Specify margins at the scale's endpoints  \param mlo minimum distance between the scale's lower boundary and the             smallest enclosed value  \param mhi minimum distance between the scale's upper boundary and the             greatest enclosed value  Margins can be used to leave a minimum amount of space between  the enclosed intervals and the boundaries of the scale.  \warning  \li With logarithmic scales, the margins are measured in decades.  \li The margins will not be changed by any other member function.      You should remember this when you call reset()      or change from a linear to a logarithmic scale.*/void QwtAutoScale::setMargins(double mlo, double mhi){    d_loMargin = qwtMax(mlo,0.0);    d_hiMargin = qwtMax(mhi,0.0);    build();}/*!  \brief Specify the maximum number of major intervals  \param mx maximum number of subintervals  The auto-scaler places the major ticks at reasonable  points, such that the number of major tick intervals does not exceed  the specified maximum number.*/void QwtAutoScale::setMaxMajor(int mx){    d_maxMajor = qwtMax(mx,1);    d_maxMajor = qwtMin(mx, 10000);    build();}/*!  \brief Specify the maximum number of minor subdivisions within major scale         intervals  \param mx maximum number of minor ticks*/void QwtAutoScale::setMaxMinor(int mx){    d_maxMinor = qwtMin(qwtMax(mx,0), 100);    build();}/*!  \todo Documentation*/void QwtAutoScale::setRange(double x1, double x2){    double minval = qwtMin(x1, x2);    double maxval = qwtMax(x1, x2);    if (d_scaleOpt & Logarithmic)    {        minval = qwtMin(qwtMax(minval, LOG_MIN), LOG_MAX);        maxval = qwtMin(qwtMax(maxval,LOG_MIN), LOG_MAX);    }        double delta = maxval - minval;        if (delta <= 0.0)       // all values are equal    {                       if (minval > 0)        {            d_scaleMin = minval * 0.5;            d_scaleMax = maxval * 1.5;        }        else if (minval < 0)        {            d_scaleMin = minval * 1.5;            d_scaleMax = maxval * 0.5;        }        else              // all values are zero        {                       d_scaleMin = -0.5;            d_scaleMax = 0.5;        }        delta = d_scaleMax - d_scaleMin;    }    else            // the normal case    {                       d_scaleMin = minval;        d_scaleMax = maxval;    }}/*!  \brief Specify a user-defined scale and switch off auto-scaling  \param xmin user-defined lower boundary  \param xmax user-defined upper boundary  \param step user-defined fixed major step size  A fixed scale may be used for different purposes, e.g.  zooming. If the step argument is left out or less or equal  to zero, the auto-scaler will calculate the major step size  size according to the maxMajor setting.  The fixed-scale mode can switched off using  setAutoScale(), which restores the  previous values.  \warning  \li if xmin > xmax, xmax will be the lower boundary.  \li if xmin == xmax, the auto-scaler sets the boundaries to (-0.5, 0.5).  \li Options and margins have no effect while auto-scaling is switched off.  \sa QwtAutoScale::setMaxMajor(), QwtAutoScale::setAutoScale()*/void QwtAutoScale::setScale(double xmin, double xmax, double step){    // turn auto-scaling off and set the    // scale limits to the desired values    setRange(xmin,xmax);    d_autoScale = FALSE;    d_step = step;    build(); // rebuild the scale}/*!  \brief Reset scale options and set specified options  \param opt Combined set of options  The behaviour of the auto-scaling algorithm can be changed  with the following options:  <dl>  <dt>QwtAutoScale::None  <dd>Switch all options off.  <dt>QwtAutoscale::IncludeRef  <dd>Build a scale which includes the reference value.  <dt>QwtAutoScale::Symmetric  <dd>Build a scale which is symmetric to the reference value.  <dt>QwtAutoScale::Logarithmic  <dd>Build a logarithmic scale.  <dt>QwtAutoScale::Floating  <dd>The endpoints of the scale are supposed to be equal the outmost included  values plus the specified margins (see setMargins()). If this option is  *not* set, the endpoints of the scale will be integer multiples of the step  size.  <dt>QwtAutoScale::Inverted  <dd>Turn the scale upside down.  </dl>  \warning  \li If the type of scale division is changed from logarithmic to linear      or vice versa, the margins will not be transformed. Note that      the margins count in decades if the scale is logarithmic.  \li If a linear scale contains negative values, switching to a      logarithmic scale will cut them off and set the lower scale      boundary to its lowest possible value of 1.0E-100. This effect      is reversible if you      switch back to a linear scale.  \li The options have no effect while auto-scaling is turned off      (see setScale())        Example:\code#include "../include/qwt_autoscl.h>void main() {    QwtAutoScale as;    // build linear scale with default settings    as.adjust(17.45, 87344.0);    //...    // change to logarithmic scale with floating ends    as.setOptions(QwtAutoScale::Floating | QwtAutoscale::Logarithmic);    //...    // change to linear, zero-symmetric scale    as.setOptions(QwtAutoScale::ZeroSymmetric);    //...}\endcode  \sa QwtAutoScale::changeOptions() for a description of the possible options.*/void QwtAutoScale::setOptions(int opt){    d_scaleOpt = opt;    build();}/*!  \brief Specify a reference point  \param r new reference value  The reference point is needed if the auto-scaler options IncludeRef or  Symmetric are active. Its default value is 0 for linear scales and 1 for  logarithmic scales.  \warning The reference value for logarithmic scales is limited to  ( LOG_MIN / 2 <= reference <= LOG_MAX /2 ). If the specified  value is less than LOG_MIN (defined in qwt_math.h), it will  be set to 1.0 for logarithmic scales.*/void QwtAutoScale::setReference(double r){    d_ref = r;        if (r > LOG_MIN / 2)         d_lref = qwtMin(r, LOG_MAX / 2);    else       d_lref = 1.0;    build();}/*!    \return the reference value    \sa QwtAutoScale::setOptions(), QwtAutoScale::option()*/double QwtAutoScale::reference() const {     return d_ref; }/*!  \brief Returns TRUE if the specified option is set.  \param opt Option  \sa QwtAutoScale::setOptions()*/bool QwtAutoScale::option(int opt) const{    return bool(d_scaleOpt & opt);}/*!    \return options    \sa QwtAutoScale::setOptions(), QwtAutoScale::option()*/int QwtAutoScale::options() const {     return d_scaleOpt; }/*!    The scale division consists of two boundary values,    an array of major tickmarks and an array of minor    tickmarks.    \return a const reference to the scale division    \sa QwtScaleDiv*/const QwtScaleDiv &QwtAutoScale::scaleDiv() const {     return d_scldiv; }/*!    If true, rebuild scale automatically with call to 'adjust'    \sa QwtAutoScale::autoRebuild*/void QwtAutoScale::setAutoRebuild(bool tf) {     d_autoRebuild = tf; }/*!    \return If true, rebuild scale automatically with call to 'adjust'    \sa QwtAutoScale::setAutoRebuild*/bool QwtAutoScale::autoRebuild() const{    return d_autoRebuild;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -