Gerbview, read Excellon files: fix a few issues.
The main issue is the fact Excellon files have no coordinate fine format definition. Only the units are defined. Units are floating point numbers or integer numbers. Integer numbers can be defined as 3.3 or 2.4 numbers (mm/inches) However some files (altium drill files for instance) use an other notation. This fix is a workaround to accept 2.x (inch) or 3.x (mm) notations. Fixes: lp:1754121 https://bugs.launchpad.net/kicad/+bug/1754121 Fixes: lp:1782053 https://bugs.launchpad.net/kicad/+bug/1782053
This commit is contained in:
parent
2af5fb51f2
commit
c291505830
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1992-2016 Jean-Pierre Charras <jp.charras at wanadoo.fr>
|
* Copyright (C) 1992-2016 Jean-Pierre Charras <jp.charras at wanadoo.fr>
|
||||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -526,6 +526,7 @@ bool EXCELLON_IMAGE::readToolInformation( char*& aText )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool EXCELLON_IMAGE::Execute_Drill_Command( char*& text )
|
bool EXCELLON_IMAGE::Execute_Drill_Command( char*& text )
|
||||||
{
|
{
|
||||||
D_CODE* tool;
|
D_CODE* tool;
|
||||||
|
@ -536,15 +537,18 @@ bool EXCELLON_IMAGE::Execute_Drill_Command( char*& text )
|
||||||
switch( *text )
|
switch( *text )
|
||||||
{
|
{
|
||||||
case 'X':
|
case 'X':
|
||||||
ReadXYCoord( text );
|
ReadXYCoord( text, true );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Y':
|
case 'Y':
|
||||||
ReadXYCoord( text );
|
ReadXYCoord( text, true );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'G': // G85 is found here for oval holes
|
case 'G': // G85 is found here for oval holes
|
||||||
m_PreviousPos = m_CurrentPos;
|
m_PreviousPos = m_CurrentPos;
|
||||||
Execute_EXCELLON_G_Command( text );
|
Execute_EXCELLON_G_Command( text );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0: // E.O.L: execute command
|
case 0: // E.O.L: execute command
|
||||||
tool = GetDCODE( m_Current_Tool );
|
tool = GetDCODE( m_Current_Tool );
|
||||||
|
|
||||||
|
@ -656,7 +660,7 @@ bool EXCELLON_IMAGE::Execute_EXCELLON_G_Command( char*& text )
|
||||||
switch( id )
|
switch( id )
|
||||||
{
|
{
|
||||||
case DRILL_G_ZERO_SET:
|
case DRILL_G_ZERO_SET:
|
||||||
ReadXYCoord( text );
|
ReadXYCoord( text, true );
|
||||||
m_Offset = m_CurrentPos;
|
m_Offset = m_CurrentPos;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -308,8 +308,12 @@ public:
|
||||||
/**
|
/**
|
||||||
* Function ReadXYCoord
|
* Function ReadXYCoord
|
||||||
* Returns the current coordinate type pointed to by XnnYnn Text (XnnnnYmmmm)
|
* Returns the current coordinate type pointed to by XnnYnn Text (XnnnnYmmmm)
|
||||||
|
* @param aText is a pointer to the text to parse.
|
||||||
|
* @param aExcellonMode = true to parse a Excellon drill file.
|
||||||
|
* it force truncation of a digit string to a max len because the exact coordinate
|
||||||
|
* format is not always known
|
||||||
*/
|
*/
|
||||||
wxPoint ReadXYCoord( char*& Text );
|
wxPoint ReadXYCoord( char*& aText, bool aExcellonMode = false );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current coordinate type pointed to by InnJnn Text (InnnnJmmmm)
|
* Returns the current coordinate type pointed to by InnJnn Text (InnnnJmmmm)
|
||||||
|
|
|
@ -69,7 +69,7 @@ int scaletoIU( double aCoord, bool isMetric )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxPoint GERBER_FILE_IMAGE::ReadXYCoord( char*& Text )
|
wxPoint GERBER_FILE_IMAGE::ReadXYCoord( char*& Text, bool aExcellonMode )
|
||||||
{
|
{
|
||||||
wxPoint pos;
|
wxPoint pos;
|
||||||
int type_coord = 0, current_coord, nbdigits;
|
int type_coord = 0, current_coord, nbdigits;
|
||||||
|
@ -123,14 +123,27 @@ wxPoint GERBER_FILE_IMAGE::ReadXYCoord( char*& Text )
|
||||||
|
|
||||||
if( m_NoTrailingZeros )
|
if( m_NoTrailingZeros )
|
||||||
{
|
{
|
||||||
int min_digit =
|
// no trailing zero format, we need to add missing zeros.
|
||||||
(type_coord == 'X') ? m_FmtLen.x : m_FmtLen.y;
|
int digit_count = (type_coord == 'X') ? m_FmtLen.x : m_FmtLen.y;
|
||||||
while( nbdigits < min_digit )
|
|
||||||
|
while( nbdigits < digit_count )
|
||||||
{
|
{
|
||||||
*(text++) = '0';
|
*(text++) = '0';
|
||||||
nbdigits++;
|
nbdigits++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( aExcellonMode )
|
||||||
|
{
|
||||||
|
// Truncate the extra digits if the len is more than expected
|
||||||
|
// because the conversion to internal units expect exactly
|
||||||
|
// digit_count digits
|
||||||
|
while( nbdigits > digit_count )
|
||||||
|
{
|
||||||
|
*(text--) = 0;
|
||||||
|
nbdigits--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*text = 0;
|
*text = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue