From 850ca98e7b35a9cd4243d7e2206739876cd32558 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 6 Jan 2020 05:15:14 -0800 Subject: [PATCH] Remove outdated RoundTo0 With internal units in 100nm, there are no rounding errors when representing mm coordinates in eeschema. --- common/common.cpp | 23 ----------------------- eeschema/sch_base_frame.cpp | 12 ------------ include/common.h | 10 ---------- 3 files changed, 45 deletions(-) diff --git a/common/common.cpp b/common/common.cpp index 175134ffaa..94fe167ba2 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -230,29 +230,6 @@ timestamp_t GetNewTimeStamp() } -double RoundTo0( double x, double precision ) -{ - assert( precision != 0 ); - - long long ix = KiROUND( x * precision ); - - if ( x < 0.0 ) - ix = -ix; - - int remainder = ix % 10; // remainder is in precision mm - - if( remainder <= 2 ) - ix -= remainder; // truncate to the near number - else if( remainder >= 8 ) - ix += 10 - remainder; // round to near number - - if ( x < 0 ) - ix = -ix; - - return (double) ix / precision; -} - - std::unique_ptr GetNewConfig( const wxString& aProgName ) { wxFileName configname; diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index da71a7b358..8f2d474855 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -185,12 +185,6 @@ void SCH_BASE_FRAME::UpdateStatusBar() double dXpos = To_User_Unit( GetUserUnits(), cursorPos.x ); double dYpos = To_User_Unit( GetUserUnits(), cursorPos.y ); - if( GetUserUnits() == EDA_UNITS::MILLIMETRES ) - { - dXpos = RoundTo0( dXpos, 100.0 ); - dYpos = RoundTo0( dYpos, 100.0 ); - } - wxString absformatter; wxString locformatter; @@ -226,12 +220,6 @@ void SCH_BASE_FRAME::UpdateStatusBar() dXpos = To_User_Unit( GetUserUnits(), dx ); dYpos = To_User_Unit( GetUserUnits(), dy ); - if( GetUserUnits() == EDA_UNITS::MILLIMETRES ) - { - dXpos = RoundTo0( dXpos, 100.0 ); - dYpos = RoundTo0( dYpos, 100.0 ); - } - // We already decided the formatter above line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) ); SetStatusText( line, 3 ); diff --git a/include/common.h b/include/common.h index 1703000835..fd8049c6c5 100644 --- a/include/common.h +++ b/include/common.h @@ -217,16 +217,6 @@ int GetCommandOptions( const int argc, const char** argv, const char* stringtst, const char** optarg, int* optind ); -/** - * Round to the nearest precision. - * - * Try to approximate a coordinate using a given precision to prevent - * rounding errors when converting from inches to mm. - * - * ie round the unit value to 0 if unit is 1 or 2, or 8 or 9 - */ -double RoundTo0( double x, double precision ); - /** * Split \a aString to a string list separated at \a aSplitter. *