From 9cda16220e2f155e79268f7eccc8accde18fb030 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 18 Nov 2019 09:06:43 +0100 Subject: [PATCH] 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 --- gerbview/rs274x.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gerbview/rs274x.cpp b/gerbview/rs274x.cpp index 8cbc5791ce..d6ea9c8f1b 100644 --- a/gerbview/rs274x.cpp +++ b/gerbview/rs274x.cpp @@ -1049,7 +1049,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: @@ -1095,10 +1096,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 ) { @@ -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 ); }