38extern int ReadInt(
char*&
text,
bool aSkipSeparator =
true );
39extern double ReadDouble(
char*&
text,
bool aSkipSeparator =
true );
42#define CODE( x, y ) ( ( (x) << 8 ) + (y) )
125 result = ( currbyte & 0xFF ) << 8;
133 result += currbyte & 0xFF;
198 unsigned int aBuffSize,
char*& aText )
206 bool x_fmt_known =
false;
207 bool y_fmt_known =
false;
220 while( *aText !=
'*' )
229 msg.Printf(
_(
"RS274X: Invalid GERBER format command '%c' at line %d: \"%s\"" ),
232 msg.Printf(
_(
"GERBER file \"%s\" may not display as intended." ),
264 if( (seq_char >=
'0') && (seq_char <=
'9') )
265 seq_len = seq_char -
'0';
275 if( ( code >=
'0' ) && ( code <=
'9' ) )
284 char ctmp = *(aText++) -
'0';
322 msg.Printf( wxT(
"Unknown id (%c) in FS command" ),
331 if( !x_fmt_known || !y_fmt_known )
332 AddMessageToList( wxT(
"RS274X: Format Statement (FS) without X or Y format" ) );
339 if( strncasecmp( aText,
"AYBX", 4 ) == 0 )
347 while( *aText && *aText !=
'*' )
390 if(
dummy.IsFileFunction() )
399 else if(
dummy.IsFileMD5() )
403 else if(
dummy.IsFilePart() )
415 if(
dummy.GetAttribute() == wxT(
".AperFunction" ) )
420 for(
int ii = 2; ii <
dummy.GetPrmCount(); ii++ )
432 if(
dummy.GetAttribute() == wxT(
".N" ) )
437 else if(
dummy.GetAttribute() == wxT(
".C" ) )
442 else if(
dummy.GetAttribute() == wxT(
".P" ) )
448 if(
dummy.GetPrmCount() > 3 )
471 while( *aText !=
'*' )
492 while( *aText !=
'*' )
511 while( *aText !=
'*' )
531 if( strncasecmp( aText,
"0*", 2 ) == 0 )
533 else if( strncasecmp( aText,
"90*", 3 ) == 0 )
535 else if( strncasecmp( aText,
"180*", 4 ) == 0 )
537 else if( strncasecmp( aText,
"270*", 4 ) == 0 )
552 while( *aText && *aText !=
'*' )
587 while( *aText && *aText !=
'*' )
600 else if( *aText ==
'L' )
620 else if( *aText ==
'L' )
648 msg =
_(
"RS274X: Command KNOCKOUT ignored by GerbView" ) ;
660 while( *aText !=
'*' )
667 while( *aText && *aText !=
'*' )
675 if( strncasecmp( aText,
"NEG", 3 ) == 0 )
680 AddMessageToList(
_(
"IPNEG Gerber command is deprecated since 2012. Skip it" ) );
715 if( *aText++ !=
'D' )
728 if( dcode ==
nullptr )
736 if( aText[1] ==
',' )
738 char stdAperture = *aText;
746 switch( stdAperture )
750 while( *aText ==
' ' )
761 while( *aText ==
' ' )
779 while( *aText ==
' ' )
789 while( *aText ==
' ' )
800 while( *aText ==
' ' )
820 while( *aText ==
' ' )
829 while( *aText ==
' ' )
838 while( *aText ==
' ' )
849 while( *aText ==
' ' )
866 while( *aText && *aText !=
'*' && *aText !=
',' )
867 am_lookup.
m_AmName.Append( *aText++ );
875 while( *aText && *aText !=
'*' )
880 if( !( isspace( *aText ) || *aText ==
'X' || *aText ==
'x' || *aText ==
'*' ) )
882 msg.Printf( wxT(
"RS274X: aperture macro %s has invalid template "
890 while( isspace( *aText ) )
894 if( *aText ==
'X' || *aText ==
'x' )
904 msg.Printf( wxT(
"RS274X: aperture macro %s not found\n" ),
935 while( (aText < aBuff + aBuffSize) && *aText )
946 if( fgets( aBuff, aBuffSize,
gerber_file ) ==
nullptr )
970 if( fgets( aBuff, aBuffSize, aFile ) ==
nullptr )
1011 if( aText ==
nullptr )
1037 if( aText ==
nullptr)
1043 else if( !isdigit(*aText) )
1045 msg.Printf( wxT(
"RS274X: Aperture Macro \"%s\": ill. symbol, line: \"%s\"" ),
1051 primitive_type =
ReadInt( aText );
1053 bool is_comment =
false;
1055 switch( primitive_type )
1098 msg.Printf( wxT(
"RS274X: Aperture Macro \"%s\": Invalid primitive id code %d, line %d: \"%s\"" ),
1111 for( ii = 0; ii < paramCount && *aText && *aText !=
'*'; ++ii )
1119 if( aText ==
nullptr)
1125 if( ii < paramCount )
1128 msg.Printf( wxT(
"RS274X: read macro descr type %d: read %d parameters, insufficient "
1142 wxASSERT( prim.
m_Params[1].IsImmediate() );
1144 paramCount = (int) prim.
m_Params[1].GetValueFromMacro(
nullptr ) * 2 + 1;
1146 for(
int jj = 0; jj < paramCount && *aText !=
'*'; ++jj )
1154 if( aText ==
nullptr )
int ReadInt(char *&text, bool aSkipSeparator=true)
Read an integer from an ASCII character buffer.
double ReadDouble(char *&text, bool aSkipSeparator=true)
Read a double precision floating point number from an ASCII character buffer.
AM_PRIMITIVE_ID
The set of all "aperture macro primitives" (primitive numbers).
constexpr EDA_IU_SCALE gerbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Hold a parameter value for an "aperture macro" as defined within standard RS274X.
bool ReadParamFromAmDef(char *&aText)
Read one aperture macro parameter.
An aperture macro primitive as given in gerber layer format doc.
AM_PARAMS m_Params
A sequence of parameters used by the primitive.
AM_PRIMITIVE_ID m_Primitive_id
The primitive type.
Support the "aperture macro" defined within standard RS274X.
wxString m_AmName
The name of the aperture macro as defined like AMVB_RECTANGLE* (name is VB_RECTANGLE)
void AddLocalParamDefToStack()
A deferred parameter can be defined in aperture macro, but outside aperture primitives.
AM_PARAM & GetLastLocalParamDefFromStack()
void AddPrimitiveToList(AM_PRIMITIVE &aPrimitive)
Add a new ptimitive ( AMP_CIRCLE, AMP_LINE2 ...) to the list of primitives to define the full shape o...
A gerber DCODE (also called Aperture) definition.
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command).
EDA_ANGLE m_Rotation
shape rotation
VECTOR2I m_Drill
dimension of the hole (if any) (drill file)
void SetMacro(APERTURE_MACRO *aMacro)
int m_EdgesCount
in aperture definition Polygon only: number of edges for the polygon
VECTOR2I m_Size
Horizontal and vertical dimensions.
APERTURE_T m_ApertType
Aperture type ( Line, rectangle, circle, oval poly, macro )
bool m_Defined
false if the aperture is not defined in the header
APERTURE_DEF_HOLETYPE m_DrillShape
shape of the hole (0 = no hole, round = 1, rect = 2).
void AppendParam(double aValue)
Add a parameter to the D_CODE parameter list.
void SetField(const wxString &aField, bool aUseUTF8, bool aEscapeString)
APERTURE_MACRO * FindApertureMacro(const APERTURE_MACRO &aLookup)
Look up a previously read in aperture macro.
X2_ATTRIBUTE_FILEFUNCTION * m_FileFunction
file function parameters, found in a TF command or a G04
void RemoveAttribute(X2_ATTRIBUTE &aAttribute)
Called when a TD command is found the Gerber file.
static char m_LineBuffer[GERBER_BUFZ+1]
bool m_SwapAxis
false if A = X and B = Y (default); true if A = Y, B = X
double m_LocalRotation
Local rotation added to m_ImageRotation.
VECTOR2I m_Offset
Coord Offset, from OF command.
wxSize m_FmtScale
Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4.
wxString m_FileName
Full File Name for this layer.
bool m_ImageJustifyXCenter
Image Justify Center on X axis (default = false)
bool m_ImageJustifyYCenter
Image Justify Center on Y axis (default = false)
bool m_ImageNegative
true = Negative image
void AddMessageToList(const wxString &aMessage)
Add a message to the message list.
int m_LineNum
Line number of the gerber file while reading.
wxString m_ImageName
Image name, from IN <name>* command.
bool m_Relative
false = absolute Coord, true = relative Coord.
wxString m_MD5_value
MD5 value found in a TF.MD5 command.
char * GetNextLine(char *aBuff, unsigned int aBuffSize, char *aText, FILE *aFile)
Test for an end of line.
bool m_MirrorB
true: mirror / axis B (Y)
wxString m_PartString
string found in a TF.Part command
bool ReadRS274XCommand(char *aBuff, unsigned int aBuffSize, char *&aText)
Read a single RS274X command terminated with a %.
bool m_IsX2_file
True if a X2 gerber attribute was found in file.
int m_ImageRotation
Image rotation (0, 90, 180, 270 only) in degrees.
VECTOR2I m_ImageOffset
Coord Offset, from IO command.
bool m_Has_DCode
< True if has DCodes in file or false if no DCodes found. Perhaps deprecated RS274D file.
bool GetEndOfBlock(char *aBuff, unsigned int aBuffSize, char *&aText, FILE *aGerberFile)
bool ReadApertureMacro(char *aBuff, unsigned int aBuffSize, char *&text, FILE *gerber_file)
Read in an aperture macro and saves it in m_aperture_macros.
D_CODE * GetDCODEOrCreate(int aDCODE, bool aCreateIfNoExist=true)
Return a pointer to the D_CODE within this GERBER for the given aDCODE.
bool ExecuteRS274XCommand(int aCommand, char *aBuff, unsigned int aBuffSize, char *&aText)
Execute a RS274X command.
wxSize m_FmtLen
Nb chars per coord. ex fmt 2.3, m_FmtLen = 5.
APERTURE_MACRO_SET m_aperture_macros
int ReadXCommandID(char *&text)
Read two bytes of data and assembles them into an int with the first byte in the sequence put into th...
bool m_GerbMetric
false = Inches, true = metric
GBR_NETLIST_METADATA m_NetAttributeDict
int m_CommandState
state of gerber analysis command
bool m_NoTrailingZeros
true: remove tailing zeros.
int m_Iterpolation
Linear, 90 arc, Circ.
bool m_MirrorA
true: mirror / axis A (X)
VECTOR2I m_Scale
scale (X and Y) of layer.
VECTOR2I m_ImageJustifyOffset
Image Justify Offset on XY axis (default = 0,0)
GERBER_LAYER & GetLayerParams()
wxRealPoint m_StepForRepeat
bool m_StepForRepeatMetric
X2_ATTRIBUTE_FILEFUNCTION ( from TF.FileFunction in Gerber file) Example file function: TF....
The attribute value consists of a number of substrings separated by a comma.
@ GERB_INTERPOL_LINEAR_1X
void ignore_unused(const T &)
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
@ REMOVE_APERTURE_ATTRIBUTE
int ReadInt(char *&text, bool aSkipSeparator=true)
Read an integer from an ASCII character buffer.
double ReadDouble(char *&text, bool aSkipSeparator=true)
Read a double precision floating point number from an ASCII character buffer.
std::vector< FAB_LAYER_COLOR > dummy
wxString From_UTF8(const char *cstring)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
VECTOR2< int32_t > VECTOR2I