From c53c5b47ea67d3b2d45237e82401c2bad6d4c99d Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Thu, 19 Apr 2012 01:55:45 -0500 Subject: [PATCH] // Dick Hollenbeck's KiROUND R&D // This provides better project control over rounding to int from double // than wxRound() did. This scheme provides better logging in Debug builds // and it provides for compile time calculation of constants. #include #include #include //----------------------------------------------------------------- /** * KiROUND * rounds a floating point number to an int using * "round halfway cases away from zero". * In Debug build an assert fires if will not fit into an int. */ #if defined( DEBUG ) // DEBUG: a macro to capture line and file, then calls this inline static inline int KiRound( double v, int line, const char* filename ) { v = v < 0 ? v - 0.5 : v + 0.5; if( v > INT_MAX + 0.5 ) { printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v ); } else if( v < INT_MIN - 0.5 ) { printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v ); } return int( v ); } #define KiROUND( v ) KiRound( v, __LINE__, __FILE__ ) #else // RELEASE: a macro so compile can pre-compute constants. #define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 ) #endif //---------------------------------------------------------------- // Only a macro is compile time calculated, an inline function causes a static constructor // in a situation like this. // Therefore the Release build is best done with a MACRO not an inline function. int Computed = KiROUND( 14.3 * 8 ); int main( int argc, char** argv ) { for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 ) { int i = KiROUND( d ); printf( "t: %d %.16g\n", i, d ); } return 0; } --- 3d-viewer/3d_frame.cpp | 6 +-- common/base_screen.cpp | 12 ++--- common/class_bitmap_base.cpp | 8 ++-- common/class_plotter.cpp | 2 +- common/common.cpp | 2 +- common/common_plotDXF_functions.cpp | 6 +-- common/common_plotGERBER_functions.cpp | 6 +-- common/common_plotHPGL_functions.cpp | 16 +++---- common/common_plotPS_functions.cpp | 14 +++--- common/dcsvg.cpp | 6 +-- common/dialogs/dialog_page_settings.cpp | 6 +-- common/drawframe.cpp | 32 ++++++------- common/drawpanel.cpp | 32 ++++++------- common/drawtxt.cpp | 18 ++++---- common/gr_basic.cpp | 2 +- common/trigo.cpp | 10 ++--- cvpcb/class_DisplayFootprintsFrame.cpp | 8 ++-- eeschema/controle.cpp | 24 +++++----- eeschema/lib_arc.cpp | 4 +- eeschema/lib_circle.cpp | 4 +- eeschema/lib_pin.cpp | 4 +- eeschema/sch_bus_entry.cpp | 2 +- eeschema/sch_line.cpp | 2 +- eeschema/sch_sheet.cpp | 4 +- eeschema/sch_text.cpp | 2 +- eeschema/sheet.cpp | 4 +- gerbview/class_aperture_macro.cpp | 26 +++++------ gerbview/class_gerber_draw_item.cpp | 14 +++--- gerbview/controle.cpp | 8 ++-- gerbview/dcode.cpp | 14 +++--- gerbview/excellon_read_drill_file.cpp | 2 +- gerbview/export_to_pcbnew.cpp | 2 +- gerbview/rs274_read_XY_and_IJ_coordinates.cpp | 16 +++---- gerbview/rs274d.cpp | 4 +- gerbview/rs274x.cpp | 28 ++++++------ include/common.h | 45 ++++++++++++++++++- include/plot_common.h | 2 +- pcbnew/class_board.cpp | 6 +-- pcbnew/class_dimension.cpp | 2 +- pcbnew/class_drawsegment.h | 2 +- pcbnew/class_pad.cpp | 6 +-- pcbnew/class_pad_draw_functions.cpp | 16 +++---- pcbnew/class_track.cpp | 2 +- pcbnew/class_zone.cpp | 4 +- pcbnew/controle.cpp | 8 ++-- pcbnew/dialogs/dialog_orient_footprints.cpp | 2 +- pcbnew/editrack.cpp | 10 ++--- pcbnew/export_vrml.cpp | 16 +++---- pcbnew/gendrill.cpp | 10 ++--- pcbnew/gpcb_exchange.cpp | 22 ++++----- pcbnew/legacy_plugin.cpp | 2 +- pcbnew/magnetic_tracks_functions.cpp | 8 ++-- pcbnew/moduleframe.cpp | 8 ++-- pcbnew/modview_frame.cpp | 8 ++-- pcbnew/move_or_drag_track.cpp | 8 ++-- pcbnew/muonde.cpp | 30 ++++++------- pcbnew/plothpgl.cpp | 8 ++-- pcbnew/plotps.cpp | 4 +- pcbnew/specctra_import.cpp | 4 +- polygon/PolyLine.cpp | 3 +- 60 files changed, 314 insertions(+), 272 deletions(-) diff --git a/3d-viewer/3d_frame.cpp b/3d-viewer/3d_frame.cpp index 205ddb0d9b..f6e835f7c1 100644 --- a/3d-viewer/3d_frame.cpp +++ b/3d-viewer/3d_frame.cpp @@ -362,9 +362,9 @@ void EDA_3D_FRAME::Set3DBgColor() S3D_Color color; wxColour newcolor, oldcolor; - oldcolor.Set( wxRound( g_Parm_3D_Visu.m_BgColor.m_Red * 255 ), - wxRound( g_Parm_3D_Visu.m_BgColor.m_Green * 255 ), - wxRound( g_Parm_3D_Visu.m_BgColor.m_Blue * 255 ) ); + oldcolor.Set( KiROUND( g_Parm_3D_Visu.m_BgColor.m_Red * 255 ), + KiROUND( g_Parm_3D_Visu.m_BgColor.m_Green * 255 ), + KiROUND( g_Parm_3D_Visu.m_BgColor.m_Blue * 255 ) ); newcolor = wxGetColourFromUser( this, oldcolor ); diff --git a/common/base_screen.cpp b/common/base_screen.cpp index 4a6e13cd7c..7c92d64dbe 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -362,12 +362,12 @@ wxPoint BASE_SCREEN::GetNearestGridPosition( const wxPoint& aPosition, wxRealPoi wxPoint gridOrigin = m_GridOrigin; double offset = fmod( gridOrigin.x, gridSize.x ); - int x = wxRound( (aPosition.x - offset) / gridSize.x ); - pt.x = wxRound( x * gridSize.x + offset ); + int x = KiROUND( (aPosition.x - offset) / gridSize.x ); + pt.x = KiROUND( x * gridSize.x + offset ); offset = fmod( gridOrigin.y, gridSize.y ); - int y = wxRound( (aPosition.y - offset) / gridSize.y ); - pt.y = wxRound ( y * gridSize.y + offset ); + int y = KiROUND( (aPosition.y - offset) / gridSize.y ); + pt.y = KiROUND ( y * gridSize.y + offset ); return pt; } @@ -387,8 +387,8 @@ wxPoint BASE_SCREEN::GetCrossHairScreenPosition() const wxPoint pos = m_crossHairPosition - m_DrawOrg; double scalar = GetScalingFactor(); - pos.x = wxRound( (double) pos.x * scalar ); - pos.y = wxRound( (double) pos.y * scalar ); + pos.x = KiROUND( (double) pos.x * scalar ); + pos.y = KiROUND( (double) pos.y * scalar ); return pos; } diff --git a/common/class_bitmap_base.cpp b/common/class_bitmap_base.cpp index ebca19d945..bab646a730 100644 --- a/common/class_bitmap_base.cpp +++ b/common/class_bitmap_base.cpp @@ -197,8 +197,8 @@ void BITMAP_BASE::DrawBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aDC->SetLogicalOrigin( logicalOriginX / GetScalingFactor(), logicalOriginY / GetScalingFactor() ); aDC->DrawBitmap( *m_bitmap, - wxRound( pos.x / GetScalingFactor() ), - wxRound( pos.y / GetScalingFactor() ), + KiROUND( pos.x / GetScalingFactor() ), + KiROUND( pos.y / GetScalingFactor() ), true ); aDC->SetUserScale( scale, scale ); aDC->SetLogicalOrigin( logicalOriginX, logicalOriginY ); @@ -217,8 +217,8 @@ wxSize BITMAP_BASE::GetSize() const size.x = m_bitmap->GetWidth(); size.y = m_bitmap->GetHeight(); - size.x = wxRound( size.x * GetScalingFactor() ); - size.y = wxRound( size.y * GetScalingFactor() ); + size.x = KiROUND( size.x * GetScalingFactor() ); + size.y = KiROUND( size.y * GetScalingFactor() ); } return size; diff --git a/common/class_plotter.cpp b/common/class_plotter.cpp index 9285340a9e..4fd290249e 100644 --- a/common/class_plotter.cpp +++ b/common/class_plotter.cpp @@ -98,7 +98,7 @@ double PLOTTER::user_to_device_size( double size ) void PLOTTER::center_square( const wxPoint& position, int diametre, FILL_T fill ) { - int radius = wxRound( diametre / 2.8284 ); + int radius = KiROUND( diametre / 2.8284 ); static std::vector< wxPoint > corner_list; corner_list.clear(); wxPoint corner; diff --git a/common/common.cpp b/common/common.cpp index f23d111b09..2697a6dae8 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -371,7 +371,7 @@ double RoundTo0( double x, double precision ) { assert( precision != 0 ); - long long ix = wxRound( x * precision ); + long long ix = KiROUND( x * precision ); if ( x < 0.0 ) NEGATE( ix ); diff --git a/common/common_plotDXF_functions.cpp b/common/common_plotDXF_functions.cpp index 1d7bdf1dbf..e455db7cdf 100644 --- a/common/common_plotDXF_functions.cpp +++ b/common/common_plotDXF_functions.cpp @@ -155,8 +155,8 @@ void DXF_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor size.x = aImage.GetWidth(); size.y = aImage.GetHeight(); - size.x = wxRound( size.x * aScaleFactor ); - size.y = wxRound( size.y * aScaleFactor ); + size.x = KiROUND( size.x * aScaleFactor ); + size.y = KiROUND( size.y * aScaleFactor ); wxPoint start = aPos; start.x -= size.x / 2; @@ -241,7 +241,7 @@ void DXF_PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int radius, return; user_to_device_coordinates( centre ); - radius = wxRound( user_to_device_size( radius ) ); + radius = KiROUND( user_to_device_size( radius ) ); /* DXF ARC */ wxString cname = ColorRefs[current_color].m_Name; diff --git a/common/common_plotGERBER_functions.cpp b/common/common_plotGERBER_functions.cpp index cacf4476f1..051e359e57 100644 --- a/common/common_plotGERBER_functions.cpp +++ b/common/common_plotGERBER_functions.cpp @@ -284,7 +284,7 @@ void GERBER_PLOTTER::circle( wxPoint aCentre, int aDiameter, FILL_T aFill, int a double radius = aDiameter / 2; const int delta = 3600 / 32; /* increment (in 0.1 degrees) to draw circles */ - start.x = aCentre.x + wxRound( radius ); + start.x = aCentre.x + KiROUND( radius ); start.y = aCentre.y; set_current_line_width( aWidth ); move_to( start ); @@ -351,8 +351,8 @@ void GERBER_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFac size.x = aImage.GetWidth(); size.y = aImage.GetHeight(); - size.x = wxRound( size.x * aScaleFactor ); - size.y = wxRound( size.y * aScaleFactor ); + size.x = KiROUND( size.x * aScaleFactor ); + size.y = KiROUND( size.y * aScaleFactor ); wxPoint start = aPos; start.x -= size.x / 2; diff --git a/common/common_plotHPGL_functions.cpp b/common/common_plotHPGL_functions.cpp index a88c08c68e..e9c28cd988 100644 --- a/common/common_plotHPGL_functions.cpp +++ b/common/common_plotHPGL_functions.cpp @@ -112,8 +112,8 @@ void HPGL_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFacto size.x = aImage.GetWidth(); size.y = aImage.GetHeight(); - size.x = wxRound( size.x * aScaleFactor ); - size.y = wxRound( size.y * aScaleFactor ); + size.x = KiROUND( size.x * aScaleFactor ); + size.y = KiROUND( size.y * aScaleFactor ); wxPoint start = aPos; start.x -= size.x / 2; @@ -285,7 +285,7 @@ void HPGL_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient, if( trace_mode == FILLED ) { - flash_pad_rect( pos, wxSize( size.x, deltaxy + wxRound( pen_diameter ) ), + flash_pad_rect( pos, wxSize( size.x, deltaxy + KiROUND( pen_diameter ) ), orient, trace_mode ); cx = 0; cy = deltaxy / 2; RotatePoint( &cx, &cy, orient ); @@ -298,7 +298,7 @@ void HPGL_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient, } else // Plot in SKETCH mode. { - sketch_oval( pos, size, orient, wxRound( pen_diameter ) ); + sketch_oval( pos, size, orient, KiROUND( pen_diameter ) ); } } @@ -313,12 +313,12 @@ void HPGL_PLOTTER::flash_pad_circle( wxPoint pos, int diametre, user_to_device_coordinates( pos ); - delta = wxRound( pen_diameter - pen_overlap ); + delta = KiROUND( pen_diameter - pen_overlap ); rayon = diametre / 2; if( trace_mode != LINE ) { - rayon = ( diametre - wxRound( pen_diameter ) ) / 2; + rayon = ( diametre - KiROUND( pen_diameter ) ) / 2; } if( rayon < 0 ) @@ -483,7 +483,7 @@ void HPGL_PLOTTER::flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4], wxPoint coord[4]; // absolute coordinates of corners (coordinates in plotter space) int move; - move = wxRound( pen_diameter ); + move = KiROUND( pen_diameter ); for( int ii = 0; ii < 4; ii++ ) polygone[ii] = aCorners[ii]; @@ -512,7 +512,7 @@ void HPGL_PLOTTER::flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4], // TODO: replace this par the HPGL plot polygon. int jj; // Fill the shape - move = wxRound( pen_diameter - pen_overlap ); + move = KiROUND( pen_diameter - pen_overlap ); // Calculate fill height. if( polygone[0].y == polygone[3].y ) // Horizontal diff --git a/common/common_plotPS_functions.cpp b/common/common_plotPS_functions.cpp index 702199d260..d0251881f8 100644 --- a/common/common_plotPS_functions.cpp +++ b/common/common_plotPS_functions.cpp @@ -160,7 +160,7 @@ void PS_PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int radius, // Calculate start point. user_to_device_coordinates( centre ); - radius = wxRound( user_to_device_size( radius ) ); + radius = KiROUND( user_to_device_size( radius ) ); if( plotMirror ) fprintf( output_file, "%d %d %d %g %g arc%d\n", centre.x, centre.y, radius, (double) -EndAngle / 10, (double) -StAngle / 10, @@ -216,8 +216,8 @@ void PS_PLOTTER::PlotImage( wxImage & aImage, wxPoint aPos, double aScaleFactor pix_size.x = aImage.GetWidth(); pix_size.y = aImage.GetHeight(); wxSize drawsize; // requested size of image - drawsize.x = wxRound( aScaleFactor * pix_size.x ); - drawsize.y = wxRound( aScaleFactor * pix_size.y ); + drawsize.x = KiROUND( aScaleFactor * pix_size.x ); + drawsize.y = KiROUND( aScaleFactor * pix_size.y ); // calculate the bottom left corner position of bitmap wxPoint start = aPos; @@ -405,14 +405,14 @@ bool PS_PLOTTER::start_plot( FILE* fout ) if( pageInfo.IsCustom() ) fprintf( output_file, "%%%%DocumentMedia: Custom %d %d 0 () ()\n", - wxRound( psPageSize.x * 10 * CONV_SCALE ), - wxRound( psPageSize.y * 10 * CONV_SCALE ) ); + KiROUND( psPageSize.x * 10 * CONV_SCALE ), + KiROUND( psPageSize.y * 10 * CONV_SCALE ) ); else // a standard paper size fprintf( output_file, "%%%%DocumentMedia: %s %d %d 0 () ()\n", TO_UTF8( pageInfo.GetType() ), - wxRound( psPageSize.x * 10 * CONV_SCALE ), - wxRound( psPageSize.y * 10 * CONV_SCALE ) ); + KiROUND( psPageSize.x * 10 * CONV_SCALE ), + KiROUND( psPageSize.y * 10 * CONV_SCALE ) ); if( pageInfo.IsPortrait() ) fprintf( output_file, "%%%%Orientation: Portrait\n" ); diff --git a/common/dcsvg.cpp b/common/dcsvg.cpp index e6066c334d..fe7c148a19 100644 --- a/common/dcsvg.cpp +++ b/common/dcsvg.cpp @@ -186,15 +186,15 @@ KicadSVGFileDCImpl::~KicadSVGFileDCImpl() void KicadSVGFileDCImpl::DoGetSizeMM( int *width, int *height ) const { if (width) - *width = wxRound( (double)m_width / m_mm_to_pix_x ); + *width = KiROUND( (double)m_width / m_mm_to_pix_x ); if (height) - *height = wxRound( (double)m_height / m_mm_to_pix_y ); + *height = KiROUND( (double)m_height / m_mm_to_pix_y ); } wxSize KicadSVGFileDCImpl::GetPPI() const { - return wxSize( wxRound(m_dpi), wxRound(m_dpi) ); + return wxSize( KiROUND(m_dpi), KiROUND(m_dpi) ); } void KicadSVGFileDCImpl::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp index 7adb5c73b0..a5cee66249 100644 --- a/common/dialogs/dialog_page_settings.cpp +++ b/common/dialogs/dialog_page_settings.cpp @@ -594,12 +594,12 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample() if( clamped_layout_size.x < clamped_layout_size.y ) { lyHeight = MAX_PAGE_EXAMPLE_SIZE; - lyWidth = wxRound( (double) lyHeight / lyRatio ); + lyWidth = KiROUND( (double) lyHeight / lyRatio ); } else { lyWidth = MAX_PAGE_EXAMPLE_SIZE; - lyHeight = wxRound( (double) lyWidth / lyRatio ); + lyHeight = KiROUND( (double) lyWidth / lyRatio ); } if( m_page_bitmap ) @@ -760,5 +760,5 @@ void DIALOG_PAGES_SETTINGS::GetCustomSizeMilsFromDialog() // Prepare to painless double -> int conversion. customSizeX = Clamp( double( INT_MIN ), customSizeX, double( INT_MAX ) ); customSizeY = Clamp( double( INT_MIN ), customSizeY, double( INT_MAX ) ); - m_layout_size = wxSize( wxRound( customSizeX ), wxRound( customSizeY ) ); + m_layout_size = wxSize( KiROUND( customSizeX ), KiROUND( customSizeY ) ); } diff --git a/common/drawframe.cpp b/common/drawframe.cpp index a2f3979f8e..7bd1f1441b 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -515,8 +515,8 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition ) clientSize = m_canvas->GetClientSize(); // The logical size of the client window. - logicalClientSize.x = wxRound( (double) clientSize.x / scalar ); - logicalClientSize.y = wxRound( (double) clientSize.y / scalar ); + logicalClientSize.x = KiROUND( (double) clientSize.x / scalar ); + logicalClientSize.y = KiROUND( (double) clientSize.y / scalar ); // A corner of the drawing in internal units. wxSize corner = GetPageSizeIU(); @@ -531,14 +531,14 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition ) drawingRect.GetTop(), drawingRect.GetBottom() ); // The size of the client rectangle in logical units. - int x = wxRound( (double) aCenterPosition.x - ( (double) logicalClientSize.x / 2.0 ) ); - int y = wxRound( (double) aCenterPosition.y - ( (double) logicalClientSize.y / 2.0 ) ); + int x = KiROUND( (double) aCenterPosition.x - ( (double) logicalClientSize.x / 2.0 ) ); + int y = KiROUND( (double) aCenterPosition.y - ( (double) logicalClientSize.y / 2.0 ) ); // If drawn around the center, adjust the client rectangle accordingly. if( screen->m_Center ) { - x += wxRound( (double) drawingRect.width / 2.0 ); - y += wxRound( (double) drawingRect.height / 2.0 ); + x += KiROUND( (double) drawingRect.width / 2.0 ); + y += KiROUND( (double) drawingRect.height / 2.0 ); } wxRect logicalClientRect( wxPoint( x, y ), logicalClientSize ); @@ -622,13 +622,13 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition ) if( screen->m_Center ) { - screen->m_DrawOrg.x = -( wxRound( (double) virtualSize.x / 2.0 ) ); - screen->m_DrawOrg.y = -( wxRound( (double) virtualSize.y / 2.0 ) ); + screen->m_DrawOrg.x = -( KiROUND( (double) virtualSize.x / 2.0 ) ); + screen->m_DrawOrg.y = -( KiROUND( (double) virtualSize.y / 2.0 ) ); } else { - screen->m_DrawOrg.x = -( wxRound( (double) (virtualSize.x - drawingRect.width) / 2.0 ) ); - screen->m_DrawOrg.y = -( wxRound( (double) (virtualSize.y - drawingRect.height) / 2.0 ) ); + screen->m_DrawOrg.x = -( KiROUND( (double) (virtualSize.x - drawingRect.width) / 2.0 ) ); + screen->m_DrawOrg.y = -( KiROUND( (double) (virtualSize.y - drawingRect.height) / 2.0 ) ); } /* Always set scrollbar pixels per unit to 1 unless you want the zoom @@ -640,20 +640,20 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition ) screen->m_ScrollPixelsPerUnitX = screen->m_ScrollPixelsPerUnitY = 1; // Calculate the number of scroll bar units for the given zoom level in device units. - unitsX = wxRound( (double) virtualSize.x * scalar ); - unitsY = wxRound( (double) virtualSize.y * scalar ); + unitsX = KiROUND( (double) virtualSize.x * scalar ); + unitsY = KiROUND( (double) virtualSize.y * scalar ); // Calculate the scroll bar position in logical units to place the center position at // the center of client rectangle. screen->SetScrollCenterPosition( aCenterPosition ); - posX = aCenterPosition.x - wxRound( (double) logicalClientRect.width / 2.0 ) - + posX = aCenterPosition.x - KiROUND( (double) logicalClientRect.width / 2.0 ) - screen->m_DrawOrg.x; - posY = aCenterPosition.y - wxRound( (double) logicalClientRect.height / 2.0 ) - + posY = aCenterPosition.y - KiROUND( (double) logicalClientRect.height / 2.0 ) - screen->m_DrawOrg.y; // Convert scroll bar position to device units. - posX = wxRound( (double) posX * scalar ); - posY = wxRound( (double) posY * scalar ); + posX = KiROUND( (double) posX * scalar ); + posY = KiROUND( (double) posY * scalar ); if( posX < 0 ) { diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp index c6b23f51ee..fe95da1366 100644 --- a/common/drawpanel.cpp +++ b/common/drawpanel.cpp @@ -405,8 +405,8 @@ void EDA_DRAW_PANEL::OnScroll( wxScrollWinEvent& event ) double scale = GetParent()->GetScreen()->GetScalingFactor(); wxPoint center = GetParent()->GetScreen()->GetScrollCenterPosition(); - center.x += wxRound( (double) ( x - tmpX ) / scale ); - center.y += wxRound( (double) ( y - tmpY ) / scale ); + center.x += KiROUND( (double) ( x - tmpX ) / scale ); + center.y += KiROUND( (double) ( y - tmpY ) / scale ); GetParent()->GetScreen()->SetScrollCenterPosition( center ); Scroll( x, y ); @@ -432,8 +432,8 @@ void EDA_DRAW_PANEL::SetClipBox( wxDC& aDC, const wxRect* aRect ) int scrollX, scrollY; double scalar = Screen->GetScalingFactor(); - scrollX = wxRound( Screen->GetGridSize().x * scalar ); - scrollY = wxRound( Screen->GetGridSize().y * scalar ); + scrollX = KiROUND( Screen->GetGridSize().x * scalar ); + scrollY = KiROUND( Screen->GetGridSize().y * scalar ); m_scrollIncrementX = MAX( GetClientSize().x / 8, scrollX ); m_scrollIncrementY = MAX( GetClientSize().y / 8, scrollY ); @@ -599,8 +599,8 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC ) screen->m_StartVisu = CalcUnscrolledPosition( wxPoint( 0, 0 ) ); screenSize = GetClientSize(); - screenGridSize.x = aDC->LogicalToDeviceXRel( wxRound( gridSize.x ) ); - screenGridSize.y = aDC->LogicalToDeviceYRel( wxRound( gridSize.y ) ); + screenGridSize.x = aDC->LogicalToDeviceXRel( KiROUND( gridSize.x ) ); + screenGridSize.y = aDC->LogicalToDeviceYRel( KiROUND( gridSize.y ) ); org = m_ClipBox.GetPosition(); @@ -621,10 +621,10 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC ) // Incrementing the start point by one grid step should prevent drawing grid points // outside the clip box. if( org.x < m_ClipBox.GetX() ) - org.x += wxRound( gridSize.x ); + org.x += KiROUND( gridSize.x ); if( org.y < m_ClipBox.GetY() ) - org.y += wxRound( gridSize.y ); + org.y += KiROUND( gridSize.y ); #if ( defined( __WXMAC__ ) || 1 ) // Use a pixel based draw to display grid. There are a lot of calls, so the cost is @@ -643,11 +643,11 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC ) for( double x = (double) org.x; x <= right; x += gridSize.x ) { - xpos = wxRound( x ); + xpos = KiROUND( x ); for( double y = (double) org.y; y <= bottom; y += gridSize.y ) { - aDC->DrawPoint( xpos, wxRound( y ) ); + aDC->DrawPoint( xpos, KiROUND( y ) ); } } #else @@ -684,7 +684,7 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC ) // Draw a column of grid points. for( double y = (double) org.y; y <= bottom; y += gridSize.y ) { - tmpDC.DrawPoint( 0, scaleDC.LogicalToDeviceY( wxRound( y ) ) ); + tmpDC.DrawPoint( 0, scaleDC.LogicalToDeviceY( KiROUND( y ) ) ); } // Reset the device context scale and origin and restore on exit. @@ -700,7 +700,7 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC ) // Blit the column for each row of the damaged region. for( double x = (double) org.x; x <= right; x += gridSize.x ) { - aDC->Blit( scaleDC.LogicalToDeviceX( wxRound( x ) ), + aDC->Blit( scaleDC.LogicalToDeviceX( KiROUND( x ) ), scaleDC.LogicalToDeviceY( m_ClipBox.GetY() ), 1, tmpBM.GetHeight(), &tmpDC, 0, 0, wxCOPY, true ); } @@ -1072,8 +1072,8 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) double scale = GetParent()->GetScreen()->GetScalingFactor(); wxPoint center = GetParent()->GetScreen()->GetScrollCenterPosition(); - center.x += wxRound( (double) ( x - tmpX ) / scale ) / ppux; - center.y += wxRound( (double) ( y - tmpY ) / scale ) / ppuy; + center.x += KiROUND( (double) ( x - tmpX ) / scale ) / ppux; + center.y += KiROUND( (double) ( y - tmpY ) / scale ) / ppuy; GetParent()->GetScreen()->SetScrollCenterPosition( center ); Refresh(); @@ -1083,9 +1083,9 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) { double scale = GetParent()->GetScreen()->GetScalingFactor(); int x = m_PanStartCenter.x + - wxRound( (double) ( m_PanStartEventPosition.x - currentPosition.x ) / scale ); + KiROUND( (double) ( m_PanStartEventPosition.x - currentPosition.x ) / scale ); int y = m_PanStartCenter.y + - wxRound( (double) ( m_PanStartEventPosition.y - currentPosition.y ) / scale ); + KiROUND( (double) ( m_PanStartEventPosition.y - currentPosition.y ) / scale ); GetParent()->RedrawScreen( wxPoint( x, y ), false ); } diff --git a/common/drawtxt.cpp b/common/drawtxt.cpp index fed7ff29d0..590c0d69ec 100644 --- a/common/drawtxt.cpp +++ b/common/drawtxt.cpp @@ -35,7 +35,7 @@ double s_HerscheyScaleFactor = HERSHEY_SCALE_FACTOR; */ int GetPenSizeForBold( int aTextSize ) { - return wxRound( aTextSize / 5.0 ); + return KiROUND( aTextSize / 5.0 ); } @@ -55,7 +55,7 @@ int Clamp_Text_PenSize( int aPenSize, int aSize, bool aBold ) { int penSize = aPenSize; double scale = aBold ? 4.0 : 6.0; - int maxWidth = wxRound( ABS( aSize ) / scale ); + int maxWidth = KiROUND( ABS( aSize ) / scale ); if( penSize > maxWidth ) penSize = maxWidth; @@ -138,13 +138,13 @@ int ReturnGraphicTextWidth( const wxString& aText, int aXSize, bool aItalic, boo /* Get metrics */ int xsta = *ptcar++ - 'R'; int xsto = *ptcar++ - 'R'; - tally += wxRound( aXSize * (xsto - xsta) * s_HerscheyScaleFactor ); + tally += KiROUND( aXSize * (xsto - xsta) * s_HerscheyScaleFactor ); } /* Italic correction, 1/8em */ if( aItalic ) { - tally += wxRound( aXSize * 0.125 ); + tally += KiROUND( aXSize * 0.125 ); } return tally; } @@ -196,7 +196,7 @@ static void DrawGraphicTextPline( */ static int overbar_position( int size_v, int thickness ) { - return wxRound( ( (double) size_v * 26 * s_HerscheyScaleFactor ) + ( (double) thickness * 1.5 ) ); + return KiROUND( ( (double) size_v * 26 * s_HerscheyScaleFactor ) + ( (double) thickness * 1.5 ) ); } @@ -460,12 +460,12 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, { wxPoint currpoint; hc1 -= xsta; hc2 -= 11; /* Align the midpoint */ - hc1 = wxRound( hc1 * size_h * s_HerscheyScaleFactor ); - hc2 = wxRound( hc2 * size_v * s_HerscheyScaleFactor ); + hc1 = KiROUND( hc1 * size_h * s_HerscheyScaleFactor ); + hc2 = KiROUND( hc2 * size_v * s_HerscheyScaleFactor ); // To simulate an italic font, add a x offset depending on the y offset if( aItalic ) - hc1 -= wxRound( italic_reverse ? -hc2 / 8.0 : hc2 / 8.0 ); + hc1 -= KiROUND( italic_reverse ? -hc2 / 8.0 : hc2 / 8.0 ); currpoint.x = hc1 + current_char_pos.x; currpoint.y = hc2 + current_char_pos.y; @@ -481,7 +481,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, ptr++; // Apply the advance width - current_char_pos.x += wxRound( size_h * (xsto - xsta) * s_HerscheyScaleFactor ); + current_char_pos.x += KiROUND( size_h * (xsto - xsta) * s_HerscheyScaleFactor ); } if( overbars % 2 ) diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp index 98126bf5cd..d5886ae113 100644 --- a/common/gr_basic.cpp +++ b/common/gr_basic.cpp @@ -1410,7 +1410,7 @@ void ClipAndDrawFilledPoly( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPoints[], in for( cpointIterator cit = outputPolygon.begin(); cit != outputPolygon.end(); ++cit ) { - clippedPolygon.push_back( wxPoint( wxRound( cit->X ), wxRound( cit->Y ) ) ); + clippedPolygon.push_back( wxPoint( KiROUND( cit->X ), KiROUND( cit->Y ) ) ); } if( clippedPolygon.size() ) diff --git a/common/trigo.cpp b/common/trigo.cpp index c09a83ac99..12fb0014f2 100644 --- a/common/trigo.cpp +++ b/common/trigo.cpp @@ -6,7 +6,7 @@ #include #include #include - +#include bool TestSegmentHit( wxPoint aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist ) { @@ -140,7 +140,7 @@ bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY ) */ int angle; - angle = wxRound( ( atan2( (double) segY, (double) segX ) * 1800.0 / M_PI ) ); + angle = KiROUND( ( atan2( (double) segY, (double) segX ) * 1800.0 / M_PI ) ); cXrot = pointX; cYrot = pointY; @@ -211,7 +211,7 @@ int ArcTangente( int dy, int dx ) } fangle = atan2( (double) dy, (double) dx ) / M_PI * 1800; - return wxRound( fangle ); + return KiROUND( fangle ); } @@ -253,8 +253,8 @@ void RotatePoint( int* pX, int* pY, double angle ) double cosinus = cos( fangle ); double fpx = (*pY * sinus ) + (*pX * cosinus ); double fpy = (*pY * cosinus ) - (*pX * sinus ); - *pX = wxRound( fpx ); - *pY = wxRound( fpy ); + *pX = KiROUND( fpx ); + *pY = KiROUND( fpy ); } } diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index fd64a701f7..69d55be7db 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -380,25 +380,25 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPositi case WXK_NUMPAD8: /* cursor moved up */ case WXK_UP: - pos.y -= wxRound( gridSize.y ); + pos.y -= KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD2: /* cursor moved down */ case WXK_DOWN: - pos.y += wxRound( gridSize.y ); + pos.y += KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD4: /* cursor moved left */ case WXK_LEFT: - pos.x -= wxRound( gridSize.x ); + pos.x -= KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD6: /* cursor moved right */ case WXK_RIGHT: - pos.x += wxRound( gridSize.x ); + pos.x += KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; } diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index fb077f70a4..5552f0495e 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -208,25 +208,25 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH case WXK_NUMPAD8: case WXK_UP: - pos.y -= wxRound( gridSize.y ); + pos.y -= KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD2: case WXK_DOWN: - pos.y += wxRound( gridSize.y ); + pos.y += KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD4: case WXK_LEFT: - pos.x -= wxRound( gridSize.x ); + pos.x -= KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD6: case WXK_RIGHT: - pos.x += wxRound( gridSize.x ); + pos.x += KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; @@ -293,25 +293,25 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH case WXK_NUMPAD8: case WXK_UP: - pos.y -= wxRound( gridSize.y ); + pos.y -= KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD2: case WXK_DOWN: - pos.y += wxRound( gridSize.y ); + pos.y += KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD4: case WXK_LEFT: - pos.x -= wxRound( gridSize.x ); + pos.x -= KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD6: case WXK_RIGHT: - pos.x += wxRound( gridSize.x ); + pos.x += KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; @@ -375,25 +375,25 @@ void LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH case WXK_NUMPAD8: case WXK_UP: - pos.y -= wxRound( gridSize.y ); + pos.y -= KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD2: case WXK_DOWN: - pos.y += wxRound( gridSize.y ); + pos.y += KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD4: case WXK_LEFT: - pos.x -= wxRound( gridSize.x ); + pos.x -= KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD6: case WXK_RIGHT: - pos.x += wxRound( gridSize.x ); + pos.x += KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index e9567fb0cb..a13bd9a66e 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -188,7 +188,7 @@ bool LIB_ARC::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTran NEGATE( relativePosition.y ); // reverse Y axis - int distance = wxRound( EuclideanNorm( TwoPointVector( m_Pos, relativePosition ) ) ); + int distance = KiROUND( EuclideanNorm( TwoPointVector( m_Pos, relativePosition ) ) ); if( abs( distance - m_Radius ) > aThreshold ) return false; @@ -738,7 +738,7 @@ void LIB_ARC::calcRadiusAngles() wxPoint centerStartVector = TwoPointVector( m_Pos, m_ArcStart ); wxPoint centerEndVector = TwoPointVector( m_Pos, m_ArcEnd ); - m_Radius = wxRound( EuclideanNorm( centerStartVector ) ); + m_Radius = KiROUND( EuclideanNorm( centerStartVector ) ); m_t1 = (int) ( atan2( (double) centerStartVector.y, (double) centerStartVector.x ) * 1800 / M_PI ); diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index 4c5032c17e..327420a2d8 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -106,7 +106,7 @@ bool LIB_CIRCLE::HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTra wxPoint relpos = aPosRef - aTransform.TransformCoordinate( m_Pos ); - int dist = wxRound( sqrt( ( (double) relpos.x * relpos.x ) + + int dist = KiROUND( sqrt( ( (double) relpos.x * relpos.x ) + ( (double) relpos.y * relpos.y ) ) ); if( abs( dist - m_Radius ) <= aThreshold ) @@ -346,7 +346,7 @@ void LIB_CIRCLE::calcEdit( const wxPoint& aPosition ) int dx = m_Pos.x - aPosition.x; int dy = m_Pos.y - aPosition.y; - m_Radius = wxRound( sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) ) ); + m_Radius = KiROUND( sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) ) ); } else { diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index fa7c106b70..4e64347c16 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -1889,7 +1889,7 @@ EDA_RECT LIB_PIN::GetBoundingBox() const int numberTextLength = showNum ? m_numTextSize * GetNumberString().Len() : 0; // Actual text height is bigger than text size - int numberTextHeight = showNum ? wxRound( m_numTextSize * 1.1 ) : 0; + int numberTextHeight = showNum ? KiROUND( m_numTextSize * 1.1 ) : 0; if( m_shape & INVERT ) minsizeV = MAX( TARGET_PIN_RADIUS, INVERT_PIN_RADIUS ); @@ -1914,7 +1914,7 @@ EDA_RECT LIB_PIN::GetBoundingBox() const nameTextLength = ( m_nameTextSize * length ) + nameTextOffset; // Actual text height are bigger than text size - nameTextHeight = wxRound( m_nameTextSize * 1.1 ) + TXTMARGE; + nameTextHeight = KiROUND( m_nameTextSize * 1.1 ) + TXTMARGE; } if( nameTextOffset ) // for values > 0, pin name is inside the body diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index ac9d8bd46a..a3b7b136db 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -169,7 +169,7 @@ int SCH_BUS_ENTRY::GetPenSize() const if( m_Layer == LAYER_BUS && m_width == 0 ) { - pensize = wxRound( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND ); + pensize = KiROUND( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND ); pensize = MAX( pensize, 3 ); } diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 6e20f18fbe..ec43fb5872 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -214,7 +214,7 @@ int SCH_LINE::GetPenSize() const if( m_Layer == LAYER_BUS && m_width == 0 ) { - pensize = wxRound( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND ); + pensize = KiROUND( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND ); pensize = MAX( pensize, 3 ); } diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index ab31d80788..066924b628 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -651,8 +651,8 @@ EDA_RECT SCH_SHEET::GetBoundingBox() const end += m_pos; // Move upper and lower limits to include texts: - box.SetY( box.GetY() - ( wxRound( m_sheetNameSize * 1.3 ) + 8 ) ); - end.y += wxRound( m_fileNameSize * 1.3 ) + 8; + box.SetY( box.GetY() - ( KiROUND( m_sheetNameSize * 1.3 ) + 8 ) ); + end.y += KiROUND( m_fileNameSize * 1.3 ) + 8; box.SetEnd( end ); box.Inflate( lineWidth / 2 ); diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index c6e6df09c1..08e54bb310 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -1242,7 +1242,7 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector & aPoints, const int x = symb_len + linewidth + 3; // 50% more for negation bar - int y = wxRound( (double) HalfSize * 1.5 + (double) linewidth + 3.0 ); + int y = KiROUND( (double) HalfSize * 1.5 + (double) linewidth + 3.0 ); // Starting point(anchor) aPoints.push_back( wxPoint( 0, 0 ) ); diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index c72a7c2898..ce8e6a0601 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -231,8 +231,8 @@ static void MoveOrResizeSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& if( sheet->HasPins() ) { - int gridSizeX = wxRound( screen->GetGridSize().x ); - int gridSizeY = wxRound( screen->GetGridSize().y ); + int gridSizeX = KiROUND( screen->GetGridSize().x ); + int gridSizeY = KiROUND( screen->GetGridSize().y ); // If the sheet has pins, use the pin positions to clamp the minimum height. height = ( height < sheet->GetMinHeight() + gridSizeY ) ? diff --git a/gerbview/class_aperture_macro.cpp b/gerbview/class_aperture_macro.cpp index 12661308d9..2e7d9ee4a3 100644 --- a/gerbview/class_aperture_macro.cpp +++ b/gerbview/class_aperture_macro.cpp @@ -176,7 +176,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, ConvertShapeToPolygon( aParent, polybuffer ); // shape rotation: - rotation = wxRound( params[6].GetValue( tool ) * 10.0 ); + rotation = KiROUND( params[6].GetValue( tool ) * 10.0 ); if( rotation ) { for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) @@ -205,7 +205,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, ConvertShapeToPolygon( aParent, polybuffer ); // shape rotation: - rotation = wxRound( params[5].GetValue( tool ) * 10.0 ); + rotation = KiROUND( params[5].GetValue( tool ) * 10.0 ); if( rotation ) { for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) @@ -234,7 +234,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, ConvertShapeToPolygon( aParent, polybuffer ); // shape rotation: - rotation = wxRound( params[5].GetValue( tool ) * 10.0 ); + rotation = KiROUND( params[5].GetValue( tool ) * 10.0 ); if( rotation ) { for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) @@ -264,7 +264,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, ConvertShapeToPolygon( aParent, polybuffer ); // shape rotation: - rotation = wxRound( params[5].GetValue( tool ) * 10.0 ); + rotation = KiROUND( params[5].GetValue( tool ) * 10.0 ); // Because a thermal shape has 4 identical sub-shapes, only one is created in polybuffer. // We must draw 4 sub-shapes rotated by 90 deg @@ -303,7 +303,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, int outerDiam = scaletoIU( params[2].GetValue( tool ), m_GerbMetric ); int penThickness = scaletoIU( params[3].GetValue( tool ), m_GerbMetric ); int gap = scaletoIU( params[4].GetValue( tool ), m_GerbMetric ); - int numCircles = wxRound( params[5].GetValue( tool ) ); + int numCircles = KiROUND( params[5].GetValue( tool ) ); // Draw circles: wxPoint center = aParent->GetABPosition( curPos ); @@ -329,7 +329,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, // Draw the cross: ConvertShapeToPolygon( aParent, polybuffer ); - rotation = wxRound( params[8].GetValue( tool ) * 10.0 ); + rotation = KiROUND( params[8].GetValue( tool ) * 10.0 ); for( unsigned ii = 0; ii < polybuffer.size(); ii++ ) { // shape rotation: @@ -352,7 +352,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, * type is not stored in parameters list, so the first parameter is exposure */ int numPoints = (int) params[1].GetValue( tool ); - rotation = wxRound( params[numPoints * 2 + 4].GetValue( tool ) * 10.0 ); + rotation = KiROUND( params[numPoints * 2 + 4].GetValue( tool ) * 10.0 ); wxPoint pos; // Read points. numPoints does not include the starting point, so add 1. for( int i = 0; i 0) @@ -537,7 +537,7 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent, // outer arc startpos.x = outerRadius; startpos.y = 0; - angle_start = wxRound( asin( (double) halfthickness / outerRadius ) * 1800 / M_PI ); + angle_start = KiROUND( asin( (double) halfthickness / outerRadius ) * 1800 / M_PI ); angle_end = 900 - angle_start; // First point, near Y axis, outer arc @@ -593,7 +593,7 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent, case AMP_POLYGON: // Creates a regular polygon { - int vertexcount = wxRound( params[1].GetValue( tool ) ); + int vertexcount = KiROUND( params[1].GetValue( tool ) ); int radius = scaletoIU( params[4].GetValue( tool ), m_GerbMetric ) / 2; // rs274x said: vertex count = 3 ... 10, and the first corner is on the X axis if( vertexcount < 3 ) diff --git a/gerbview/class_gerber_draw_item.cpp b/gerbview/class_gerber_draw_item.cpp index c98ef7e78f..eb12582741 100644 --- a/gerbview/class_gerber_draw_item.cpp +++ b/gerbview/class_gerber_draw_item.cpp @@ -115,9 +115,9 @@ wxPoint GERBER_DRAW_ITEM::GetABPosition( const wxPoint& aXYPosition ) const EXCHG( abPos.x, abPos.y ); abPos += m_layerOffset + m_imageParams->m_ImageOffset; - abPos.x = wxRound( abPos.x * m_drawScale.x ); - abPos.y = wxRound( abPos.y * m_drawScale.y ); - int rotation = wxRound(m_lyrRotation*10) + (m_imageParams->m_ImageRotation*10); + abPos.x = KiROUND( abPos.x * m_drawScale.x ); + abPos.y = KiROUND( abPos.y * m_drawScale.y ); + int rotation = KiROUND(m_lyrRotation*10) + (m_imageParams->m_ImageRotation*10); if( rotation ) RotatePoint( &abPos, -rotation ); @@ -144,13 +144,13 @@ wxPoint GERBER_DRAW_ITEM::GetXYPosition( const wxPoint& aABPosition ) if( !m_mirrorB ) NEGATE( xyPos.y ); - int rotation = wxRound(m_lyrRotation*10) + (m_imageParams->m_ImageRotation*10); + int rotation = KiROUND(m_lyrRotation*10) + (m_imageParams->m_ImageRotation*10); if( rotation ) RotatePoint( &xyPos, rotation ); - xyPos.x = wxRound( xyPos.x / m_drawScale.x ); - xyPos.y = wxRound( xyPos.y / m_drawScale.y ); + xyPos.x = KiROUND( xyPos.x / m_drawScale.x ); + xyPos.y = KiROUND( xyPos.y / m_drawScale.y ); xyPos -= m_layerOffset + m_imageParams->m_ImageOffset; if( m_swapAxis ) @@ -368,7 +368,7 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, break; case GBR_CIRCLE: - radius = wxRound(hypot( (double) ( m_End.x - m_Start.x ), + radius = KiROUND(hypot( (double) ( m_End.x - m_Start.x ), (double) ( m_End.y - m_Start.y ) )); halfPenWidth = m_Size.x >> 1; diff --git a/gerbview/controle.cpp b/gerbview/controle.cpp index 5ec581b7c6..f42c0e1f67 100644 --- a/gerbview/controle.cpp +++ b/gerbview/controle.cpp @@ -47,25 +47,25 @@ void GERBVIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH { case WXK_NUMPAD8: case WXK_UP: - pos.y -= wxRound( gridSize.y ); + pos.y -= KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD2: case WXK_DOWN: - pos.y += wxRound( gridSize.y ); + pos.y += KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD4: case WXK_LEFT: - pos.x -= wxRound( gridSize.x ); + pos.x -= KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD6: case WXK_RIGHT: - pos.x += wxRound( gridSize.x ); + pos.x += KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; diff --git a/gerbview/dcode.cpp b/gerbview/dcode.cpp index 73d4b973eb..beb64ef5e5 100644 --- a/gerbview/dcode.cpp +++ b/gerbview/dcode.cpp @@ -215,9 +215,9 @@ int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName sscanf( line, "%d,%d,%d,%d,%d,%d,%d", &ii, &dimH, &dimV, &drill, &dummy, &dummy, &type_outil ); - dimH = wxRound( dimH * dcode_scale ); - dimV = wxRound( dimV * dcode_scale ); - drill = wxRound( drill * dcode_scale ); + dimH = KiROUND( dimH * dcode_scale ); + dimV = KiROUND( dimV * dcode_scale ); + drill = KiROUND( drill * dcode_scale ); if( ii < 1 ) ii = 1; @@ -245,9 +245,9 @@ int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName } } - dimH = wxRound( fdimH * dcode_scale * 1000 ); - dimV = wxRound( fdimV * dcode_scale * 1000 ); - drill = wxRound( fdrill * dcode_scale * 1000 ); + dimH = KiROUND( fdimH * dcode_scale * 1000 ); + dimV = KiROUND( fdimV * dcode_scale * 1000 ); + drill = KiROUND( fdrill * dcode_scale * 1000 ); if( strchr( "CLROP", c_type_outil[0] ) ) { @@ -600,7 +600,7 @@ void D_CODE::ConvertShapeToPolygon() if( m_Rotation ) // vertical oval, rotate polygon. { - int angle = wxRound( m_Rotation * 10 ); + int angle = KiROUND( m_Rotation * 10 ); for( unsigned jj = 0; jj < m_PolyCorners.size(); jj++ ) { diff --git a/gerbview/excellon_read_drill_file.cpp b/gerbview/excellon_read_drill_file.cpp index 4d3f01ce29..64e40a4305 100644 --- a/gerbview/excellon_read_drill_file.cpp +++ b/gerbview/excellon_read_drill_file.cpp @@ -436,7 +436,7 @@ bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text ) if( m_GerbMetric ) conv_scale /= 25.4; - dcode->m_Size.x = dcode->m_Size.y = wxRound( dprm * conv_scale ); + dcode->m_Size.x = dcode->m_Size.y = KiROUND( dprm * conv_scale ); dcode->m_Shape = APT_CIRCLE; break; } diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp index 23cefae601..2e835f909c 100644 --- a/gerbview/export_to_pcbnew.cpp +++ b/gerbview/export_to_pcbnew.cpp @@ -220,7 +220,7 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, in (double)( aGbrItem->m_End.x - aGbrItem->m_ArcCentre.x ) ); drawitem->SetShape( S_ARC ); - drawitem->SetAngle( wxRound( (a - b) / M_PI * 1800.0 ) ); + drawitem->SetAngle( KiROUND( (a - b) / M_PI * 1800.0 ) ); drawitem->SetStart( aGbrItem->m_ArcCentre ); if( drawitem->GetAngle() < 0 ) diff --git a/gerbview/rs274_read_XY_and_IJ_coordinates.cpp b/gerbview/rs274_read_XY_and_IJ_coordinates.cpp index 001cd4947e..eea3b618ca 100644 --- a/gerbview/rs274_read_XY_and_IJ_coordinates.cpp +++ b/gerbview/rs274_read_XY_and_IJ_coordinates.cpp @@ -44,9 +44,9 @@ int scaletoIU( double aCoord, bool isMetric ) int ret; if( isMetric ) - ret = wxRound( aCoord * MILS_TO_IU_SCALAR / 0.00254 ); + ret = KiROUND( aCoord * MILS_TO_IU_SCALAR / 0.00254 ); else - ret = wxRound( aCoord * MILS_TO_IU_SCALAR ); + ret = KiROUND( aCoord * MILS_TO_IU_SCALAR ); return ret; } @@ -94,9 +94,9 @@ wxPoint GERBER_IMAGE::ReadXYCoord( char*& Text ) { // When X or Y values are float numbers, they are given in mm or inches if( m_GerbMetric ) // units are mm - current_coord = wxRound( atof( line ) * MILS_TO_IU_SCALAR / 0.0254 ); + current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALAR / 0.0254 ); else // units are inches - current_coord = wxRound( atof( line ) * MILS_TO_IU_SCALAR * 1000 ); + current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALAR * 1000 ); } else { @@ -119,7 +119,7 @@ wxPoint GERBER_IMAGE::ReadXYCoord( char*& Text ) if( m_GerbMetric ) real_scale = real_scale / 25.4; - current_coord = wxRound( current_coord * real_scale ); + current_coord = KiROUND( current_coord * real_scale ); } if( type_coord == 'X' ) @@ -185,9 +185,9 @@ wxPoint GERBER_IMAGE::ReadIJCoord( char*& Text ) { // When X or Y values are float numbers, they are given in mm or inches if( m_GerbMetric ) // units are mm - current_coord = wxRound( atof( line ) * MILS_TO_IU_SCALAR / 0.0254 ); + current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALAR / 0.0254 ); else // units are inches - current_coord = wxRound( atof( line ) * MILS_TO_IU_SCALAR * 1000 ); + current_coord = KiROUND( atof( line ) * MILS_TO_IU_SCALAR * 1000 ); } else { @@ -213,7 +213,7 @@ wxPoint GERBER_IMAGE::ReadIJCoord( char*& Text ) double real_scale = scale_list[fmt_scale]; if( m_GerbMetric ) real_scale = real_scale / 25.4; - current_coord = wxRound( current_coord * real_scale ); + current_coord = KiROUND( current_coord * real_scale ); } if( type_coord == 'I' ) pos.x = current_coord; diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp index db58560e01..e6500c0864 100644 --- a/gerbview/rs274d.cpp +++ b/gerbview/rs274d.cpp @@ -345,8 +345,8 @@ static void fillArcPOLY( BOARD* aPcb, GERBER_DRAW_ITEM* aGbrItem, * angle is trigonometrical (counter-clockwise), * and axis is the X,Y gerber coordinates */ - int start_angle = wxRound(atan2( (double) start.y, (double) start.x ) * 1800 / M_PI); - int end_angle = wxRound(atan2( (double) end.y, (double) end.x ) * 1800 / M_PI); + int start_angle = KiROUND(atan2( (double) start.y, (double) start.x ) * 1800 / M_PI); + int end_angle = KiROUND(atan2( (double) end.y, (double) end.x ) * 1800 / M_PI); // dummyTrack has right geometric parameters, but // fillArcGBRITEM calculates arc parameters for a draw function that expects diff --git a/gerbview/rs274x.cpp b/gerbview/rs274x.cpp index ab539e6ec6..311566f0dc 100644 --- a/gerbview/rs274x.cpp +++ b/gerbview/rs274x.cpp @@ -306,13 +306,13 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, case 'A': // A axis offset in current unit (inch or mm) text++; fcoord = ReadDouble( text ); - m_Offset.x = wxRound( fcoord * conv_scale ); + m_Offset.x = KiROUND( fcoord * conv_scale ); break; case 'B': // B axis offset in current unit (inch or mm) text++; fcoord = ReadDouble( text ); - m_Offset.y = wxRound( fcoord * conv_scale ); + m_Offset.y = KiROUND( fcoord * conv_scale ); break; } } @@ -346,13 +346,13 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, case 'A': // A axis offset in current unit (inch or mm) text++; fcoord = ReadDouble( text ); - m_ImageOffset.x = wxRound( fcoord * conv_scale ); + m_ImageOffset.x = KiROUND( fcoord * conv_scale ); break; case 'B': // B axis offset in current unit (inch or mm) text++; fcoord = ReadDouble( text ); - m_ImageOffset.y = wxRound( fcoord * conv_scale ); + m_ImageOffset.y = KiROUND( fcoord * conv_scale ); break; } } @@ -429,7 +429,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, m_ImageJustifyXCenter = true; text++; } - else m_ImageJustifyOffset.x = wxRound( ReadDouble( text ) * conv_scale); + else m_ImageJustifyOffset.x = KiROUND( ReadDouble( text ) * conv_scale); break; case 'B': // B axis justify @@ -444,7 +444,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, m_ImageJustifyYCenter = true; text++; } - else m_ImageJustifyOffset.y = wxRound( ReadDouble( text ) * conv_scale); + else m_ImageJustifyOffset.y = KiROUND( ReadDouble( text ) * conv_scale); break; default: text++; @@ -580,7 +580,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, text += 2; // skip "C," for example dcode->m_Size.x = dcode->m_Size.y = - wxRound( ReadDouble( text ) * conv_scale ); + KiROUND( ReadDouble( text ) * conv_scale ); switch( stdAperture ) // Aperture desceiption has optional parameters. Read them { @@ -593,7 +593,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, { text++; dcode->m_Drill.x = dcode->m_Drill.y = - wxRound( ReadDouble( text ) * conv_scale ); + KiROUND( ReadDouble( text ) * conv_scale ); dcode->m_DrillShape = APT_DEF_ROUND_HOLE; } @@ -604,7 +604,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, { text++; dcode->m_Drill.y = - wxRound( ReadDouble( text ) * conv_scale ); + KiROUND( ReadDouble( text ) * conv_scale ); dcode->m_DrillShape = APT_DEF_RECT_HOLE; } @@ -622,7 +622,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, { text++; dcode->m_Size.y = - wxRound( ReadDouble( text ) * conv_scale ); + KiROUND( ReadDouble( text ) * conv_scale ); } while( *text == ' ' ) @@ -632,7 +632,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, { text++; dcode->m_Drill.x = dcode->m_Drill.y = - wxRound( ReadDouble( text ) * conv_scale ); + KiROUND( ReadDouble( text ) * conv_scale ); dcode->m_DrillShape = APT_DEF_ROUND_HOLE; } @@ -643,7 +643,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, { text++; dcode->m_Drill.y = - wxRound( ReadDouble( text ) * conv_scale ); + KiROUND( ReadDouble( text ) * conv_scale ); dcode->m_DrillShape = APT_DEF_RECT_HOLE; } dcode->m_Defined = true; @@ -680,7 +680,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, { text++; dcode->m_Drill.x = dcode->m_Drill.y = - wxRound( ReadDouble( text ) * conv_scale ); + KiROUND( ReadDouble( text ) * conv_scale ); dcode->m_DrillShape = APT_DEF_ROUND_HOLE; } @@ -691,7 +691,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, { text++; dcode->m_Drill.y = - wxRound( ReadDouble( text ) * conv_scale ); + KiROUND( ReadDouble( text ) * conv_scale ); dcode->m_DrillShape = APT_DEF_RECT_HOLE; } dcode->m_Defined = true; diff --git a/include/common.h b/include/common.h index 12d8efe3f7..e9d7274255 100644 --- a/include/common.h +++ b/include/common.h @@ -118,11 +118,52 @@ enum pseudokeys { #define OFF 0 +//----------------------------------------------------------------- + +/** + * KiROUND + * rounds a floating point number to an int using + * "round halfway cases away from zero". + * In Debug build an assert fires if will not fit into an int. + */ + +#if defined( DEBUG ) + +// DEBUG: a macro to capture line and file, then calls this inline + +static inline int KiRound( double v, int line, const char* filename ) +{ + v = v < 0 ? v - 0.5 : v + 0.5; + if( v > INT_MAX + 0.5 ) + { + printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v ); + } + else if( v < INT_MIN - 0.5 ) + { + printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v ); + } + return int( v ); +} + +#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ ) + +#else + +// RELEASE: a macro so compile can pre-compute constants. + +#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 ) + +#endif + +//---------------------------------------------------------------- + + + /// Convert mm to mils. -inline int Mm2mils( double x ) { return wxRound( x * 1000./25.4 ); } +inline int Mm2mils( double x ) { return KiROUND( x * 1000./25.4 ); } /// Convert mils to mm. -inline int Mils2mm( double x ) { return wxRound( x * 25.4 / 1000. ); } +inline int Mils2mm( double x ) { return KiROUND( x * 25.4 / 1000. ); } /// Return whether GOST is in play diff --git a/include/plot_common.h b/include/plot_common.h index f9c4c62dcc..0a5beecafb 100644 --- a/include/plot_common.h +++ b/include/plot_common.h @@ -257,7 +257,7 @@ public: virtual void set_current_line_width( int width ) { // Handy override - current_pen_width = wxRound( pen_diameter ); + current_pen_width = KiROUND( pen_diameter ); } virtual void set_default_line_width( int width ) {}; diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 1eec4719a9..209afd0e5b 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -1954,10 +1954,10 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, } if( aTraceLength ) - *aTraceLength = wxRound( full_len ); + *aTraceLength = KiROUND( full_len ); if( aDieLength ) - *aDieLength = wxRound( lenDie ); + *aDieLength = KiROUND( lenDie ); if( aCount ) *aCount = NbSegmBusy; @@ -2092,7 +2092,7 @@ TRACK* BOARD::CreateLockPoint( wxPoint& aPosition, TRACK* aSegment, PICKED_ITEMS if( delta.x == 0 ) lockPoint.x = 0; /* horizontal segment*/ else - lockPoint.y = wxRound( ( (double)lockPoint.x * delta.y ) / delta.x ); + lockPoint.y = KiROUND( ( (double)lockPoint.x * delta.y ) / delta.x ); /* Create the intermediate point (that is to say creation of a new * segment, beginning at the intermediate point. diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index c954b630e3..f72805bad3 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -258,7 +258,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) deltay = m_featureLineDOy - m_featureLineGOy; // Calculate dimension value - mesure = wxRound( hypot( (double) deltax, (double) deltay ) ); + mesure = KiROUND( hypot( (double) deltax, (double) deltay ) ); if( deltax || deltay ) angle = atan2( (double) deltay, (double) deltax ); diff --git a/pcbnew/class_drawsegment.h b/pcbnew/class_drawsegment.h index fb32619e9c..7d9e5e5609 100644 --- a/pcbnew/class_drawsegment.h +++ b/pcbnew/class_drawsegment.h @@ -128,7 +128,7 @@ public: int GetRadius() const { double radius = hypot( (double) (m_End.x - m_Start.x), (double) (m_End.y - m_Start.y) ); - return wxRound( radius ); + return KiROUND( radius ); } /** diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index cd9ae27c5f..1c91dd4054 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -433,8 +433,8 @@ wxSize D_PAD::GetSolderPasteMargin() } wxSize pad_margin; - pad_margin.x = margin + wxRound( m_Size.x * mratio ); - pad_margin.y = margin + wxRound( m_Size.y * mratio ); + pad_margin.x = margin + KiROUND( m_Size.x * mratio ); + pad_margin.y = margin + KiROUND( m_Size.y * mratio ); // ensure mask have a size always >= 0 if( pad_margin.x < -m_Size.x / 2 ) @@ -688,7 +688,7 @@ bool D_PAD::HitTest( const wxPoint& aPosition ) case PAD_CIRCLE: dist = hypot( delta.x, delta.y ); - if( wxRound( dist ) <= dx ) + if( KiROUND( dist ) <= dx ) return true; break; diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index d314148b43..8587d71808 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -234,8 +234,8 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDraw_mode, const wxPoi } // if PAD_SMD pad and high contrast mode - if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && - ( GetAttribute() == PAD_SMD || GetAttribute() == PAD_CONN ) && + if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && + ( GetAttribute() == PAD_SMD || GetAttribute() == PAD_CONN ) && DisplayOpt.ContrastModeDisplay ) { // when routing tracks @@ -303,7 +303,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDraw_mode, const wxPoi // if Contrast mode is ON and a technical layer active, show pads on this // layer so we can see pads on paste or solder layer and the size of the // mask - if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && + if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && DisplayOpt.ContrastModeDisplay && screen->m_Active_Layer > LAST_COPPER_LAYER ) { if( IsOnLayer( screen->m_Active_Layer ) ) @@ -376,7 +376,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDraw_mode, const wxPoi // Display net names is restricted to pads that are on the active layer // in hight contrast mode display - if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && + if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && !IsOnLayer( screen->m_Active_Layer ) && DisplayOpt.ContrastModeDisplay ) drawInfo.m_Display_netname = false; @@ -771,8 +771,8 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat // left and right sides are moved by aInflateValue.x in their perpendicular direction // We must calculate the corresponding displacement on the horizontal axis // that is delta.x +- corr.x depending on the corner - corr.x = wxRound( tan( angle ) * aInflateValue.x ); - delta.x = wxRound( aInflateValue.x / cos( angle ) ); + corr.x = KiROUND( tan( angle ) * aInflateValue.x ); + delta.x = KiROUND( aInflateValue.x / cos( angle ) ); // Horizontal sides are moved up and down by aInflateValue.y delta.y = aInflateValue.y; @@ -787,8 +787,8 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat // lower and upper sides are moved by aInflateValue.x in their perpendicular direction // We must calculate the corresponding displacement on the vertical axis // that is delta.y +- corr.y depending on the corner - corr.y = wxRound( tan( angle ) * aInflateValue.y ); - delta.y = wxRound( aInflateValue.y / cos( angle ) ); + corr.y = KiROUND( tan( angle ) * aInflateValue.y ); + delta.y = KiROUND( aInflateValue.y / cos( angle ) ); // Vertical sides are moved left and right by aInflateValue.x delta.x = aInflateValue.x; diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 1fc4ff3a5f..dc79f6181a 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -1173,7 +1173,7 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame ) // Display segment length if( Type() != PCB_VIA_T ) // Display Diam and Drill values { - msg = frame->CoordinateToString( wxRound( GetLength() ) ); + msg = frame->CoordinateToString( KiROUND( GetLength() ) ); frame->AppendMsgPanel( _( "Segment Length" ), msg, DARKCYAN ); } } diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 8ee9e83b98..1732eef0e2 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -497,7 +497,7 @@ bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos ) { // Use grid size because it is known wxRealPoint grid = GetBoard()->m_PcbFrame->GetCanvas()->GetGrid(); - min_dist = wxRound( MIN( grid.x, grid.y ) ); + min_dist = KiROUND( MIN( grid.x, grid.y ) ); } #endif @@ -543,7 +543,7 @@ bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos ) { // Use grid size because it is known wxRealPoint grid = GetBoard()->m_PcbFrame->GetCanvas()->GetGrid(); - min_dist = wxRound( MIN( grid.x, grid.y ) ); + min_dist = KiROUND( MIN( grid.x, grid.y ) ); } #endif diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index a59abef318..5e685aba76 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -270,25 +270,25 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH { case WXK_NUMPAD8: case WXK_UP: - pos.y -= wxRound( gridSize.y ); + pos.y -= KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD2: case WXK_DOWN: - pos.y += wxRound( gridSize.y ); + pos.y += KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD4: case WXK_LEFT: - pos.x -= wxRound( gridSize.x ); + pos.x -= KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD6: case WXK_RIGHT: - pos.x += wxRound( gridSize.x ); + pos.x += KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; diff --git a/pcbnew/dialogs/dialog_orient_footprints.cpp b/pcbnew/dialogs/dialog_orient_footprints.cpp index 2df11a67c4..98a6294fb9 100644 --- a/pcbnew/dialogs/dialog_orient_footprints.cpp +++ b/pcbnew/dialogs/dialog_orient_footprints.cpp @@ -161,7 +161,7 @@ void DIALOG_ORIENT_FOOTPRINTS::OnOkClick( wxCommandEvent& event ) return; } - newOrientation = wxRound(d_orient * 10); + newOrientation = KiROUND(d_orient * 10); NORMALIZE_ANGLE_180( newOrientation ); EndModal( wxID_OK ); } diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index c731d26c42..269fe02e9b 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -309,7 +309,7 @@ bool PCB_EDIT_FRAME::Add45DegreeSegment( wxDC* aDC ) return false; } - int segm_step_45 = wxRound( GetScreen()->GetGridSize().x / 2 ); + int segm_step_45 = KiROUND( GetScreen()->GetGridSize().x / 2 ); if( segm_step_45 < ( curTrack->m_Width * 2 ) ) segm_step_45 = curTrack->m_Width * 2; @@ -643,8 +643,8 @@ static void PushTrack( EDA_DRAW_PANEL* panel ) } f = dist / hypot( double(n.x), double(n.y) ); - n.x = wxRound( f * n.x ); - n.y = wxRound( f * n.y ); + n.x = KiROUND( f * n.x ); + n.y = KiROUND( f * n.y ); Project( &track->m_End, cursor, other ); track->m_End += n; @@ -789,13 +789,13 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo for( TRACK* track = g_FirstTrackSegment; track; track = track->Next() ) trackLen += track->GetLength(); - valeur_param( wxRound( trackLen ), msg ); + valeur_param( KiROUND( trackLen ), msg ); frame->AppendMsgPanel( _( "Track Len" ), msg, DARKCYAN ); if( lenDie != 0 ) // display the track len on board and the actual track len { frame->AppendMsgPanel( _( "Full Len" ), msg, DARKCYAN ); - valeur_param( wxRound( trackLen+lenDie ), msg ); + valeur_param( KiROUND( trackLen+lenDie ), msg ); frame->AppendMsgPanel( _( "On Die" ), msg, DARKCYAN ); } diff --git a/pcbnew/export_vrml.cpp b/pcbnew/export_vrml.cpp index 27abfa0a4c..690bb13303 100644 --- a/pcbnew/export_vrml.cpp +++ b/pcbnew/export_vrml.cpp @@ -953,17 +953,17 @@ static void export_vrml_pad( BOARD* pcb, D_PAD* aPad ) //{{{ { int coord[8] = { - wxRound(-pad_w - pad_dy), wxRound(+pad_h + pad_dx), - wxRound(-pad_w + pad_dy), wxRound(-pad_h - pad_dx), - wxRound(+pad_w - pad_dy), wxRound(+pad_h - pad_dx), - wxRound(+pad_w + pad_dy), wxRound(-pad_h + pad_dx), + KiROUND(-pad_w - pad_dy), KiROUND(+pad_h + pad_dx), + KiROUND(-pad_w + pad_dy), KiROUND(-pad_h - pad_dx), + KiROUND(+pad_w - pad_dy), KiROUND(+pad_h - pad_dx), + KiROUND(+pad_w + pad_dy), KiROUND(-pad_h + pad_dx), }; for( int i = 0; i < 4; i++ ) { RotatePoint( &coord[i * 2], &coord[i * 2 + 1], aPad->GetOrientation() ); - coord[i * 2] += wxRound( pad_x ); - coord[i * 2 + 1] += wxRound( pad_y ); + coord[i * 2] += KiROUND( pad_x ); + coord[i * 2 + 1] += KiROUND( pad_y ); } bag_flat_quad( layer, coord[0], coord[1], @@ -1123,8 +1123,8 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule, // adjust 3D shape offset position (offset is given inch) #define UNITS_3D_TO_PCB_UNITS PCB_INTERNAL_UNIT - int offsetx = wxRound( vrmlm->m_MatPosition.x * UNITS_3D_TO_PCB_UNITS ); - int offsety = wxRound( vrmlm->m_MatPosition.y * UNITS_3D_TO_PCB_UNITS ); + int offsetx = KiROUND( vrmlm->m_MatPosition.x * UNITS_3D_TO_PCB_UNITS ); + int offsety = KiROUND( vrmlm->m_MatPosition.y * UNITS_3D_TO_PCB_UNITS ); double offsetz = vrmlm->m_MatPosition.z * UNITS_3D_TO_PCB_UNITS; if ( isFlipped ) diff --git a/pcbnew/gendrill.cpp b/pcbnew/gendrill.cpp index 0ea551856b..0aed12bb46 100644 --- a/pcbnew/gendrill.cpp +++ b/pcbnew/gendrill.cpp @@ -440,7 +440,7 @@ void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoo aCoordX *= 10; aCoordY *= 10; } - sprintf( aLine, "X%dY%d\n", wxRound( aCoordX ), wxRound( aCoordY ) ); + sprintf( aLine, "X%dY%d\n", KiROUND( aCoordX ), KiROUND( aCoordY ) ); break; case SUPPRESS_TRAILING: @@ -456,8 +456,8 @@ void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoo if( aCoordY < 0 ) ypad++; - xs.Printf( wxT( "%0*d" ), xpad, wxRound( aCoordX ) ); - ys.Printf( wxT( "%0*d" ), ypad, wxRound( aCoordY ) ); + xs.Printf( wxT( "%0*d" ), xpad, KiROUND( aCoordX ) ); + ys.Printf( wxT( "%0*d" ), ypad, KiROUND( aCoordY ) ); size_t j = xs.Len() - 1; while( xs[j] == '0' && j ) @@ -481,8 +481,8 @@ void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoo xpad++; if( aCoordY < 0 ) ypad++; - xs.Printf( wxT( "%0*d" ), xpad, wxRound( aCoordX ) ); - ys.Printf( wxT( "%0*d" ), ypad, wxRound( aCoordY ) ); + xs.Printf( wxT( "%0*d" ), xpad, KiROUND( aCoordX ) ); + ys.Printf( wxT( "%0*d" ), ypad, KiROUND( aCoordY ) ); sprintf( aLine, "X%sY%s\n", TO_UTF8( xs ), TO_UTF8( ys ) ); break; } diff --git a/pcbnew/gpcb_exchange.cpp b/pcbnew/gpcb_exchange.cpp index 32e2b7790d..4649825972 100644 --- a/pcbnew/gpcb_exchange.cpp +++ b/pcbnew/gpcb_exchange.cpp @@ -247,8 +247,8 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) } } wxPoint pos; - pos.x = wxRound( ibuf[idx] * conv_unit ); - pos.y = wxRound( ibuf[idx+1] * conv_unit ); + pos.x = KiROUND( ibuf[idx] * conv_unit ); + pos.y = KiROUND( ibuf[idx+1] * conv_unit ); m_Reference->SetPos( pos ); m_Reference->SetPos0( pos ); m_Reference->SetOrientation( ibuf[idx+2] ? 900 : 0 ); @@ -301,7 +301,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) if( ii < (params.GetCount() - 2) ) { if( params[ii + 2].ToLong( &dim ) ) - *list[ii] = wxRound( dim * conv_unit ); + *list[ii] = KiROUND( dim * conv_unit ); } } @@ -347,8 +347,8 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) int radius = (ibuf[2] + ibuf[3]) / 4; wxPoint centre; - centre.x = wxRound( ibuf[0] * conv_unit ); - centre.y = wxRound( ibuf[1] * conv_unit ); + centre.x = KiROUND( ibuf[0] * conv_unit ); + centre.y = KiROUND( ibuf[1] * conv_unit ); drawSeg->SetStart0( centre ); @@ -357,14 +357,14 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) drawSeg->SetAngle( ibuf[5] * 10 ); // Angle value is clockwise in gpcb and Pcbnew - drawSeg->SetEnd0( wxPoint( wxRound( radius * conv_unit ), 0 ) ); + drawSeg->SetEnd0( wxPoint( KiROUND( radius * conv_unit ), 0 ) ); // Calculate start point coordinate of arc wxPoint arcStart( drawSeg->GetEnd0() ); RotatePoint( &arcStart, -start_angle ); drawSeg->SetEnd0( centre + arcStart ); - drawSeg->SetWidth( wxRound( ibuf[6] * conv_unit ) ); + drawSeg->SetWidth( KiROUND( ibuf[6] * conv_unit ) ); drawSeg->SetDrawCoord(); continue; } @@ -389,7 +389,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) long dim; if( params[ii + 2].ToLong( &dim ) ) - ibuf[ii] = wxRound( dim * conv_unit ); + ibuf[ii] = KiROUND( dim * conv_unit ); } else { @@ -425,12 +425,12 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) // Negate angle (due to Y reversed axis) and convert it to internal units angle = - angle * 1800.0 / M_PI; - pad->SetOrientation( wxRound( angle ) ); + pad->SetOrientation( KiROUND( angle ) ); wxPoint padPos( (ibuf[0] + ibuf[2]) / 2, (ibuf[1] + ibuf[3]) / 2 ); pad->SetSize( wxSize( - wxRound( hypot( (double)delta.x, (double)delta.y ) ) + ibuf[4], + KiROUND( hypot( (double)delta.x, (double)delta.y ) ) + ibuf[4], ibuf[4] ) ); padPos += m_Pos; @@ -471,7 +471,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) { long dim; if( params[ii + 2].ToLong( &dim ) ) - ibuf[ii] = wxRound( dim * conv_unit ); + ibuf[ii] = KiROUND( dim * conv_unit ); } else { diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index 9e944698d6..263a9b4127 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -2633,7 +2633,7 @@ BIU LEGACY_PLUGIN::biuParse( const char* aValue, const char** nptrptr ) { // this is the special reverse trip mm -> deci-mils testing run, // only available in DEBUG mode. - return BIU( wxRound( fval * diskToBiu ) ); + return BIU( KiROUND( fval * diskToBiu ) ); } #endif diff --git a/pcbnew/magnetic_tracks_functions.cpp b/pcbnew/magnetic_tracks_functions.cpp index 03b2be5c98..de78eac847 100644 --- a/pcbnew/magnetic_tracks_functions.cpp +++ b/pcbnew/magnetic_tracks_functions.cpp @@ -61,8 +61,8 @@ static bool Join( wxPoint* res, wxPoint a0, wxPoint a1, wxPoint b0, wxPoint b1 ) t = min( max( t, 0.0 ), 1.0 ); - res->x = wxRound( a0.x + t * a1.x ); - res->y = wxRound( a0.y + t * a1.y ); + res->x = KiROUND( a0.x + t * a1.x ); + res->y = KiROUND( a0.y + t * a1.y ); return true; } @@ -85,8 +85,8 @@ bool Project( wxPoint* res, wxPoint on_grid, const TRACK* track ) t /= (double) vec.x * vec.x + (double) vec.y * vec.y; t = min( max( t, 0.0 ), 1.0 ); - res->x = wxRound( track->m_Start.x + t * vec.x ); - res->y = wxRound( track->m_Start.y + t * vec.y ); + res->x = KiROUND( track->m_Start.x + t * vec.x ); + res->y = KiROUND( track->m_Start.y + t * vec.y ); return true; } diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index aa23bb98eb..3c6261dede 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -435,25 +435,25 @@ void FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, { case WXK_NUMPAD8: case WXK_UP: - pos.y -= wxRound( gridSize.y ); + pos.y -= KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD2: case WXK_DOWN: - pos.y += wxRound( gridSize.y ); + pos.y += KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD4: case WXK_LEFT: - pos.x -= wxRound( gridSize.x ); + pos.x -= KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD6: case WXK_RIGHT: - pos.x += wxRound( gridSize.x ); + pos.x += KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index 0e6f2780d6..8c47ea7487 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -580,25 +580,25 @@ void FOOTPRINT_VIEWER_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition case WXK_NUMPAD8: /* cursor moved up */ case WXK_UP: - pos.y -= wxRound( gridSize.y ); + pos.y -= KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD2: /* cursor moved down */ case WXK_DOWN: - pos.y += wxRound( gridSize.y ); + pos.y += KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD4: /* cursor moved left */ case WXK_LEFT: - pos.x -= wxRound( gridSize.x ); + pos.x -= KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; case WXK_NUMPAD6: /* cursor moved right */ case WXK_RIGHT: - pos.x += wxRound( gridSize.x ); + pos.x += KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; } diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 0cdbf1f5ed..f99f26c12b 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -473,10 +473,10 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( EDA_DRAW_PANEL* aPanel, wxDC if( update ) { s_LastPos = Pos; - Track->m_Start.x = wxRound( xi1 ); - Track->m_Start.y = wxRound( yi1 ); - Track->m_End.x = wxRound( xi2 ); - Track->m_End.y = wxRound( yi2 ); + Track->m_Start.x = KiROUND( xi1 ); + Track->m_Start.y = KiROUND( yi1 ); + Track->m_End.x = KiROUND( xi2 ); + Track->m_End.y = KiROUND( yi2 ); if( tSegmentToEnd ) { diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index 8ae24e52fc..6f85dbe20b 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -103,8 +103,8 @@ static void ShowBoundingBoxMicroWaveInductor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint poly[5]; wxPoint pt = Mself.m_End - Mself.m_Start; - int angle = -wxRound( atan2( (double) pt.y, (double) pt.x ) * 1800.0 / M_PI ); - int len = wxRound( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) ); + int angle = -KiROUND( atan2( (double) pt.y, (double) pt.x ) * 1800.0 / M_PI ); + int len = KiROUND( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) ); // calculate corners pt.x = 0; pt.y = len / 4; @@ -124,8 +124,8 @@ static void ShowBoundingBoxMicroWaveInductor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, Mself.m_End = aPanel->GetScreen()->GetCrossHairPosition(); pt = Mself.m_End - Mself.m_Start; - angle = -wxRound( atan2( (double) pt.y, (double) pt.x ) * 1800.0 / M_PI ); - len = wxRound( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) ); + angle = -KiROUND( atan2( (double) pt.y, (double) pt.x ) * 1800.0 / M_PI ); + len = KiROUND( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) ); // calculate new corners pt.x = 0; pt.y = len / 4; @@ -194,7 +194,7 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC ) Mself.m_End = GetScreen()->GetCrossHairPosition(); wxPoint pt = Mself.m_End - Mself.m_Start; - int min_len = wxRound( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) ); + int min_len = KiROUND( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) ); Mself.lng = min_len; // Enter the desired length. @@ -330,8 +330,8 @@ static void gen_arc( std::vector & aBuffer, wxPoint currpt; // Rotate current point: - currpt.x = wxRound( ( first_point.x * fcos + first_point.y * fsin ) ); - currpt.y = wxRound( ( first_point.y * fcos - first_point.x * fsin ) ); + currpt.x = KiROUND( ( first_point.x * fcos + first_point.y * fsin ) ); + currpt.y = KiROUND( ( first_point.y * fcos - first_point.x * fsin ) ); wxPoint corner = aCenter + currpt; aBuffer.push_back( corner ); @@ -394,8 +394,8 @@ int BuildCornersList_S_Shape( std::vector & aBuffer, #define ADJUST_SIZE 0.988 wxPoint pt = aEndPoint - aStartPoint; - int angle = -wxRound( atan2( (double) pt.y, (double) pt.x ) * 1800.0 / M_PI ); - int min_len = wxRound( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) ); + int angle = -KiROUND( atan2( (double) pt.y, (double) pt.x ) * 1800.0 / M_PI ); + int min_len = KiROUND( sqrt( (double) pt.x * pt.x + (double) pt.y * pt.y ) ); int segm_len = 0; // length of segments int full_len; // full len of shape (sum of lenght of all segments + arcs) @@ -437,7 +437,7 @@ int BuildCornersList_S_Shape( std::vector & aBuffer, segm_len = size.x - ( radius * 2 ); full_len = 2 * stubs_len; // Length of coil connections. full_len += segm_len * segm_count; // Length of full length segments. - full_len += wxRound( ( segm_count + 2 ) * M_PI * ADJUST_SIZE * radius ); // Ard arcs len + full_len += KiROUND( ( segm_count + 2 ) * M_PI * ADJUST_SIZE * radius ); // Ard arcs len full_len += segm_len - (2 * radius); // Length of first and last segments // (half size segments len = segm_len/2 - radius). @@ -646,7 +646,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) abort = true; } - angle = ABS( wxRound( fval * fcoeff ) ); + angle = ABS( KiROUND( fval * fcoeff ) ); if( angle > 1800 ) angle = 1800; @@ -955,8 +955,8 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape() if( PolyShapeType == 2 ) // mirrored ShapeScaleY = -ShapeScaleY; - ShapeSize.x = wxRound( ShapeScaleX ); - ShapeSize.y = wxRound( ShapeScaleY ); + ShapeSize.x = KiROUND( ShapeScaleX ); + ShapeSize.y = KiROUND( ShapeScaleY ); if( ( ShapeSize.x ) == 0 || ( ShapeSize.y == 0 ) ) { @@ -999,8 +999,8 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape() for( unsigned ii = 0; ii < PolyEdges.size(); ii++ ) // Copy points { - last_coordinate.x = wxRound( PolyEdges[ii] * ShapeScaleX ) + pad1->GetPos0().x; - last_coordinate.y = -wxRound( PolyEdges[ii] * ShapeScaleY ); + last_coordinate.x = KiROUND( PolyEdges[ii] * ShapeScaleX ) + pad1->GetPos0().x; + last_coordinate.y = -KiROUND( PolyEdges[ii] * ShapeScaleY ); polyPoints.push_back( last_coordinate ); } diff --git a/pcbnew/plothpgl.cpp b/pcbnew/plothpgl.cpp index da1815d98b..f5177aec7e 100644 --- a/pcbnew/plothpgl.cpp +++ b/pcbnew/plothpgl.cpp @@ -38,7 +38,7 @@ bool PCB_BASE_FRAME::ExportToHpglFile( const wxString& aFullFileName, int aLayer // Compute pen_dim (from g_m_HPGLPenDiam in mils) in pcb units, // with plot scale (if Scale is 2, pen diameter is always g_m_HPGLPenDiam // so apparent pen diam is real pen diam / Scale - int pen_diam = wxRound( (plot_opts.m_HPGLPenDiam * U_PCB) / + int pen_diam = KiROUND( (plot_opts.m_HPGLPenDiam * U_PCB) / plot_opts.m_PlotScale ); // compute pen_overlay (from g_m_HPGLPenOvr in mils) with plot scale @@ -48,7 +48,7 @@ bool PCB_BASE_FRAME::ExportToHpglFile( const wxString& aFullFileName, int aLayer if( plot_opts.m_HPGLPenOvr >= plot_opts.m_HPGLPenDiam ) plot_opts.m_HPGLPenOvr = plot_opts.m_HPGLPenDiam - 1; - int pen_overlay = wxRound( plot_opts.m_HPGLPenOvr * 10.0 / + int pen_overlay = KiROUND( plot_opts.m_HPGLPenOvr * 10.0 / plot_opts.m_PlotScale ); @@ -82,9 +82,9 @@ bool PCB_BASE_FRAME::ExportToHpglFile( const wxString& aFullFileName, int aLayer // Calculate the page size offset. if( center ) { - offset.x = wxRound( (double) boardCenter.x - + offset.x = KiROUND( (double) boardCenter.x - ( (double) pageSizeIU.x / 2.0 ) / scale ); - offset.y = wxRound( (double) boardCenter.y - + offset.y = KiROUND( (double) boardCenter.y - ( (double) pageSizeIU.y / 2.0 ) / scale ); } else diff --git a/pcbnew/plotps.cpp b/pcbnew/plotps.cpp index a253c0bad7..eb518d4782 100644 --- a/pcbnew/plotps.cpp +++ b/pcbnew/plotps.cpp @@ -92,8 +92,8 @@ bool PCB_BASE_FRAME::ExportToPostScriptFile( const wxString& aFullFileName, int if( center ) { - offset.x = wxRound( (double) boardCenter.x - ( (double) paperSizeIU.x / 2.0 ) / scale ); - offset.y = wxRound( (double) boardCenter.y - ( (double) paperSizeIU.y / 2.0 ) / scale ); + offset.x = KiROUND( (double) boardCenter.x - ( (double) paperSizeIU.x / 2.0 ) / scale ); + offset.y = KiROUND( (double) boardCenter.y - ( (double) paperSizeIU.y / 2.0 ) / scale ); } else { diff --git a/pcbnew/specctra_import.cpp b/pcbnew/specctra_import.cpp index dcb02f2b21..92f4555bc9 100644 --- a/pcbnew/specctra_import.cpp +++ b/pcbnew/specctra_import.cpp @@ -169,7 +169,7 @@ static int scale( double distance, UNIT_RES* aResolution ) break; } - int ret = wxRound( factor * distance / resValue ); + int ret = KiROUND( factor * distance / resValue ); #else @@ -197,7 +197,7 @@ static int scale( double distance, UNIT_RES* aResolution ) // used within KiCad. factor *= 10.0; - int ret = wxRound( factor * distance / resValue ); + int ret = KiROUND( factor * distance / resValue ); #endif diff --git a/polygon/PolyLine.cpp b/polygon/PolyLine.cpp index 7efda63ff0..ff4753c749 100644 --- a/polygon/PolyLine.cpp +++ b/polygon/PolyLine.cpp @@ -8,13 +8,14 @@ #include #include +#include // KiROUND #include #include #include -#define to_int( x ) wxRound( (x) ) +#define to_int( x ) KiROUND( (x) ) #ifndef MIN #define MIN( x1, x2 ) ( (x1) > (x2) ? (x2) : (x1) )