diff --git a/gerbview/rs274_read_XY_and_IJ_coordinates.cpp b/gerbview/rs274_read_XY_and_IJ_coordinates.cpp index a0dca5335f..a439941c65 100644 --- a/gerbview/rs274_read_XY_and_IJ_coordinates.cpp +++ b/gerbview/rs274_read_XY_and_IJ_coordinates.cpp @@ -62,7 +62,7 @@ int scaletoIU( double aCoord, bool isMetric ) if( isMetric ) // gerber are units in mm ret = KiROUND( aCoord * GERB_IU_PER_MM ); else // gerber are units in inches - ret = KiROUND( aCoord * GERB_IU_PER_MM * 0.0254 ); + ret = KiROUND( aCoord * GERB_IU_PER_MM * 25.4 ); return ret; } @@ -78,7 +78,8 @@ wxPoint GERBER_FILE_IMAGE::ReadXYCoord( char*& aText, bool aExcellonMode ) // Reserve the anticipated length plus an optional sign and decimal line.reserve( std::max( m_FmtLen.x, m_FmtLen.y ) + 3 ); - if( m_Relative ) + // Set up return value for case where aText == nullptr + if( !m_Relative ) pos = m_CurrentPos; if( aText == nullptr ) @@ -142,11 +143,11 @@ wxPoint GERBER_FILE_IMAGE::ReadXYCoord( char*& aText, bool aExcellonMode ) if( type_coord == 'X' ) { - pos.x += current_coord; + pos.x = current_coord; } else if( type_coord == 'Y' ) { - pos.y += current_coord; + pos.y = current_coord; } else if( type_coord == 'A' ) { @@ -155,6 +156,9 @@ wxPoint GERBER_FILE_IMAGE::ReadXYCoord( char*& aText, bool aExcellonMode ) } } + if( m_Relative ) + pos += m_CurrentPos; + m_CurrentPos = pos; return pos; }