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 36acadbd52
commit 9cda16220e
1 changed files with 12 additions and 2 deletions

View File

@ -1049,7 +1049,8 @@ bool GERBER_FILE_IMAGE::ReadApertureMacro( char *aBuff, unsigned int aBuffSize,
break; break;
case AMP_OUTLINE: case AMP_OUTLINE:
paramCount = 4; paramCount = 4; // partial count. other parameters are vertices and rotation
// Second parameter is vertice (coordinate pairs) count.
break; break;
case AMP_POLYGON: case AMP_POLYGON:
@ -1095,10 +1096,11 @@ bool GERBER_FILE_IMAGE::ReadApertureMacro( char *aBuff, unsigned int aBuffSize,
if( ii < paramCount ) if( ii < paramCount )
{ {
// maybe some day we can throw an exception and track a line number // 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 ); prim.primitive_id, ii );
AddMessageToList( msg ); AddMessageToList( msg );
} }
// there are more parameters to read if this is an AMP_OUTLINE // there are more parameters to read if this is an AMP_OUTLINE
if( prim.primitive_id == AMP_OUTLINE ) if( prim.primitive_id == AMP_OUTLINE )
{ {
@ -1126,6 +1128,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 ); am.primitives.push_back( prim );
} }