Perform coordinate format detection on Excellon drill files

Fixes: lp:1754121
* https://bugs.launchpad.net/kicad/+bug/1754121
This commit is contained in:
Jon Evans 2018-03-07 22:05:06 -05:00
parent 8f0c798dc8
commit 3e033aee0c
2 changed files with 26 additions and 2 deletions

View File

@ -96,12 +96,14 @@ private:
excellon_state m_State; // state of excellon file analysis
bool m_SlotOn; // true during an oblong drill definition
bool m_format_known; // true if number format (2:4, etc) is known
public: EXCELLON_IMAGE( int layer ) :
GERBER_FILE_IMAGE( layer )
{
m_State = READ_HEADER_STATE;
m_SlotOn = false;
m_format_known = false;
}

View File

@ -547,9 +547,31 @@ bool EXCELLON_IMAGE::Execute_Drill_Command( char*& text )
switch( *text )
{
case 'X':
ReadXYCoord( text );
break;
case 'Y':
if( !m_format_known )
{
// Scan the first entry to decode format
int nbdigits = 0;
int integer = m_GerbMetric ? fmtIntegerMM : fmtIntegerInch;
int mantissa;
char* read = text + 1;
while( IsNumber( *read ) )
{
if( (*read >= '0') && (*read <='9') )
nbdigits++;
read++;
}
mantissa = nbdigits - integer;
m_FmtScale.x = m_FmtScale.y = mantissa;
m_FmtLen.x = m_FmtLen.y = integer + mantissa;
m_format_known = true;
}
ReadXYCoord( text );
break;
case 'G': // G85 is found here for oval holes