#178 QwtScaleDraw: lost fractional part of "off" variable

closed
nobody
None
5
2012-11-20
2012-11-05
Maks
No

qwt_scale_draw.cpp: 501 line
if ( alignment() == LeftScale || alignment() == TopScale )
off = ( pw - 1 ) / 2;
else
off = pw / 2;

"pw" is a int varyable (const int pw 491 line).
Must be:
off = static_cast<double> (pw - 1) / 2;
off = static_cast<double> (pw) / 2

Discussion

  • Maks

    Maks - 2012-11-05
    • summary: QwtScaleDraw: lost fractional of "off" --> QwtScaleDraw: lost fractional part of "off" variable
     
  • Maks

    Maks - 2012-11-05

    Same in other files:

    ------ qwt_interval_symbol.cpp -------
    (262 line):
    const double y = p1.y() - d_data->width / 2;
    ->width() return int.
    const double y = p1.y() - static_cast<double>(d_data->width) / 2;

    271 line:
    const double y = p1.x() - static_cast<double>(d_data->width) / 2;

     
  • Uwe Rathmann

    Uwe Rathmann - 2012-11-20

    The code aligns explicitly to integers when drawing to an paint device with an integer based coordinate system. The reason is to avoid random rounding inside of Qt code.

     
  • Uwe Rathmann

    Uwe Rathmann - 2012-11-20
    • status: open --> closed-rejected
     


Anonymous

Cancel  Add attachments





Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks