~cern-kicad/kicad/kicad-pns-tom

« back to all changes in this revision

Viewing changes to pcbnew/gen_drill_report_files.cpp

More int casts to rounding conversions

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
            wxSize      pageSizeIU = pageA4.GetSizeIU();
110
110
 
111
111
            // Reserve a margin around the page.
112
 
            int         margin = (int) (20 * IU_PER_MM );
 
112
            int         margin = KiROUND( 20 * IU_PER_MM );
113
113
 
114
114
            // Calculate a scaling factor to print the board on the sheet
115
 
            double      Xscale = (double) ( pageSizeIU.x - ( 2 * margin ) ) / bbbox.GetWidth();
 
115
            double      Xscale = double( pageSizeIU.x - ( 2 * margin ) ) / bbbox.GetWidth();
116
116
 
117
117
            // We should print the list of drill sizes, so reserve room for it
118
118
            // 60% height for board 40% height for list
119
 
            int     ypagesize_for_board = (int) (pageSizeIU.y * 0.6);
120
 
            double  Yscale = (double) ( ypagesize_for_board - margin ) / bbbox.GetHeight();
 
119
            int     ypagesize_for_board = KiROUND( pageSizeIU.y * 0.6 );
 
120
            double  Yscale = double( ypagesize_for_board - margin ) / bbbox.GetHeight();
121
121
 
122
122
            scale = std::min( Xscale, Yscale );
123
123
 
126
126
            // So the scale is clipped at 3.0;
127
127
            scale = std::min( scale, 3.0 );
128
128
 
129
 
            offset.x    = (int) ( (double) bbbox.Centre().x - ( pageSizeIU.x / 2.0 ) / scale );
130
 
            offset.y    = (int) ( (double) bbbox.Centre().y -
 
129
            offset.x    = KiROUND( double( bbbox.Centre().x ) - 
 
130
                                  ( pageSizeIU.x / 2.0 ) / scale );
 
131
            offset.y    = KiROUND( double( bbbox.Centre().y ) -
131
132
                                  ( ypagesize_for_board / 2.0 ) / scale );
132
133
 
133
134
            if( aFormat == PLOT_FORMAT_PDF )
200
201
    int         intervalle = 0;
201
202
    char        line[1024];
202
203
    wxString    msg;
203
 
    int         textmarginaftersymbol = (int) (2 * IU_PER_MM);
 
204
    int         textmarginaftersymbol = KiROUND( 2 * IU_PER_MM );
204
205
 
205
206
    // Set Drill Symbols width
206
207
    plotter->SetDefaultLineWidth( 0.2 * IU_PER_MM / scale );
213
214
    int     charSize    = 3 * IU_PER_MM;                    // text size in IUs
214
215
    double  charScale   = 1.0 / scale;                      // real scale will be 1/scale,
215
216
                                                            // because the global plot scale is scale
216
 
    TextWidth   = (int) ( (charSize * charScale) / 10 );    // Set text width (thickness)
217
 
    intervalle  = (int) ( charSize * charScale ) + TextWidth;
 
217
    TextWidth   = KiROUND( (charSize * charScale) / 10.0 );    // Set text width (thickness)
 
218
    intervalle  = KiROUND( charSize * charScale ) + TextWidth;
218
219
 
219
220
    // Trace information.
220
 
    plotX   = (int) ( (double) bbbox.GetX() + textmarginaftersymbol * charScale );
 
221
    plotX   = KiROUND( bbbox.GetX() + textmarginaftersymbol * charScale );
221
222
    plotY   = bbbox.GetBottom() + intervalle;
222
223
 
223
224
    // Plot title  "Info"
224
225
    wxString Text = wxT( "Drill Map:" );
225
226
    plotter->Text( wxPoint( plotX, plotY ), UNSPECIFIED_COLOR, Text, 0,
226
 
                   wxSize( (int) ( charSize * charScale ),
227
 
                           (int) ( charSize * charScale ) ),
 
227
                   wxSize( KiROUND( charSize * charScale ),
 
228
                           KiROUND( charSize * charScale ) ),
228
229
                   GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
229
230
                   TextWidth, false, false );
230
231
 
237
238
 
238
239
        plotY += intervalle;
239
240
 
240
 
        plot_diam = (int) m_toolListBuffer[ii].m_Diameter;
241
 
        x = (int) ( (double) plotX - textmarginaftersymbol * charScale
242
 
                    - (double) plot_diam / 2.0 );
243
 
        y = (int) ( (double) plotY + (double) charSize * charScale );
 
241
        plot_diam = KiROUND( m_toolListBuffer[ii].m_Diameter );
 
242
        x = KiROUND( plotX - textmarginaftersymbol * charScale
 
243
                    - plot_diam / 2.0 );
 
244
        y = KiROUND( plotY + charSize * charScale );
244
245
        plotter->Marker( wxPoint( x, y ), plot_diam, ii );
245
246
 
246
247
        // List the diameter of each drill in mm and inches.
268
269
        msg += FROM_UTF8( line );
269
270
        plotter->Text( wxPoint( plotX, y ), UNSPECIFIED_COLOR,
270
271
                       msg,
271
 
                       0, wxSize( (int) ( charSize * charScale ),
272
 
                                  (int) ( charSize * charScale ) ),
 
272
                       0, wxSize( KiROUND( charSize * charScale ),
 
273
                                  KiROUND( charSize * charScale ) ),
273
274
                       GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
274
275
                       TextWidth, false, false );
275
276
 
276
 
        intervalle  = (int) ( charSize * charScale ) + TextWidth;
277
 
        intervalle  = (int) ( intervalle * 1.2 );
 
277
        intervalle  = KiROUND( (( charSize * charScale ) + TextWidth) * 1.2);
278
278
 
279
279
        if( intervalle < (plot_diam + (1 * IU_PER_MM / scale) + TextWidth) )
280
280
            intervalle = plot_diam + (1 * IU_PER_MM / scale) + TextWidth;