Gerbview: add parsing of optional Aperture Macro parameter.

AMP_CIRCLE primitive has 4 or 5 parameters (last is optional)
Reading the optional parameter was missing.

Fixes: lp:1852924
https://bugs.launchpad.net/kicad/+bug/1852924
This commit is contained in:
jean-pierre charras 2019-11-18 09:06:43 +01:00
parent c1f88b2d9c
commit 32043cfa26
1 changed files with 12 additions and 2 deletions
gerbview

View File

@ -1006,7 +1006,8 @@ bool GERBER_FILE_IMAGE::ReadApertureMacro( char *aBuff, unsigned int aBuffSize,
break;
case AMP_OUTLINE:
paramCount = 4;
paramCount = 4; // partial count. other parameters are vertices and rotation
// Second parameter is vertice (coordinate pairs) count.
break;
case AMP_POLYGON:
@ -1052,10 +1053,11 @@ bool GERBER_FILE_IMAGE::ReadApertureMacro( char *aBuff, unsigned int aBuffSize,
if( ii < paramCount )
{
// maybe some day we can throw an exception and track a line number
msg.Printf( wxT( "RS274X: read macro descr type %d: read %d parameters, insufficient parameters\n" ),
msg.Printf( "RS274X: read macro descr type %d: read %d parameters, insufficient parameters\n",
prim.primitive_id, ii );
AddMessageToList( msg );
}
// there are more parameters to read if this is an AMP_OUTLINE
if( prim.primitive_id == AMP_OUTLINE )
{
@ -1083,6 +1085,14 @@ bool GERBER_FILE_IMAGE::ReadApertureMacro( char *aBuff, unsigned int aBuffSize,
}
}
// AMP_CIRCLE can have a optional parameter (rotation)
if( prim.primitive_id == AMP_CIRCLE && aText && *aText != '*' )
{
prim.params.push_back( AM_PARAM() );
AM_PARAM& param = prim.params.back();
param.ReadParam( aText );
}
am.primitives.push_back( prim );
}