简体   繁体   中英

magic numbers in qwt

Qwt seems to be using a lot of magic numbers. Could anyone please explain what 90 and 16 from the following code

void QwtRoundScaleDraw::drawBackbone( QPainter *painter ) const
{
    const double a1 = qMin( scaleMap().p1(), scaleMap().p2() ) - 90 * 16;
    const double a2 = qMax( scaleMap().p1(), scaleMap().p2() ) - 90 * 16;

    const double radius = d_data->radius;
    const double x = d_data->center.x() - radius;
    const double y = d_data->center.y() - radius;

    painter->drawArc( x, y, 2 * radius, 2 * radius,
        -a2, a2 - a1 + 1 );          // counterclockwise
}

Steps to figure it out:

  1. Doc of drawArc
  2. a1 and a2 is used to calculate the startAngle and spanAngle parameter of that function
  3. the measure of these parameters is the 1/16th of a degree (see #1)
  4. you can guess that those numbers will rotate the original arc with a quadrant (90 degree)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM