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;
 
 
  199                                              unsigned int aBuffSize, 
char*& aText )
 
  207    bool     x_fmt_known = 
false;
 
  208    bool     y_fmt_known = 
false;
 
  211    double   conv_scale = 
gerbIUScale.IU_PER_MILS * 1000;
 
  223        while( *aText != 
'*' )
 
  232                msg.Printf( 
_( 
"RS274X: Invalid GERBER format command '%c' at line %d: '%s'" ),
 
  235                msg.Printf( 
_(
"GERBER file '%s' may not display as intended." ),
 
  267                if( (seq_char >= 
'0') && (seq_char <= 
'9') )
 
  268                    seq_len = seq_char - 
'0';
 
  278                if( ( code >= 
'0' ) && ( code <= 
'9' ) )
 
  287                char ctmp = *(aText++) - 
'0';
 
  325                msg.Printf( wxT( 
"Unknown id (%c) in FS command" ), *aText );
 
  333        if( !x_fmt_known || !y_fmt_known )
 
  334            AddMessageToList( wxT( 
"RS274X: Format Statement (FS) without X or Y format" ) );
 
  341        if( strncasecmp( aText, 
"AYBX", 4 ) == 0 )
 
  349        while( *aText && *aText != 
'*' )
 
  390        if( 
dummy.IsFileFunction() )
 
  399        else if( 
dummy.IsFileMD5() )
 
  403        else if( 
dummy.IsFilePart() )
 
  413        if( 
dummy.GetAttribute() == wxT( 
".AperFunction" ) )
 
  418            for( 
int ii = 2; ii < 
dummy.GetPrmCount(); ii++ )
 
  427        if( 
dummy.GetAttribute() == wxT( 
".N" ) )
 
  432        else if( 
dummy.GetAttribute() == wxT( 
".C" ) )
 
  437        else if( 
dummy.GetAttribute() == wxT( 
".P" ) )
 
  443            if( 
dummy.GetPrmCount() > 3 )
 
  465        while( *aText != 
'*' )
 
  488        while( *aText != 
'*' )
 
  509        while( *aText != 
'*' )
 
  530        if( strncasecmp( aText, 
"0*", 2 ) == 0 )
 
  532        else if( strncasecmp( aText, 
"90*", 3 ) == 0 )
 
  534        else if( strncasecmp( aText, 
"180*", 4 ) == 0 )
 
  536        else if( strncasecmp( aText, 
"270*", 4 ) == 0 )
 
  551        while( *aText && *aText != 
'*' )
 
  588        while( *aText && *aText != 
'*' )
 
  601                else if( *aText == 
'L' )
 
  621                else if( *aText == 
'L' )
 
  649        msg = 
_( 
"RS274X: Command KNOCKOUT ignored by GerbView" ) ;
 
  661        while( *aText != 
'*' )
 
  668        while( *aText && *aText != 
'*' )
 
  675        if( strncasecmp( aText, 
"NEG", 3 ) == 0 )
 
  680            AddMessageToList( 
_( 
"IPNEG Gerber command is deprecated since 2012. Skip it" ) );
 
  714        if( *aText++ != 
'D' )
 
  727        if( dcode == 
nullptr )
 
  735        if( aText[1] == 
',' )
 
  737            char stdAperture = *aText;
 
  745            switch( stdAperture )   
 
  749                while( *aText == 
' ' )
 
  760                while( *aText == 
' ' )
 
  779                while( *aText == 
' ' )
 
  788                while( *aText == 
' ' )
 
  799                while( *aText == 
' ' )
 
  819                while( *aText == 
' ' )
 
  828                while( *aText == 
' ' )
 
  837                while( *aText == 
' ' )
 
  848                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" ),
 
 
  936        while( (aText < aBuff + aBuffSize) && *aText )
 
  947        if( fgets( aBuff, aBuffSize, 
gerber_file ) == 
nullptr )
 
 
  971            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\"" ),
 
 1052            primitive_type = 
ReadInt( aText );
 
 1055        bool is_comment = 
false;
 
 1057        switch( primitive_type )
 
 1100            msg.Printf( wxT( 
"RS274X: Aperture Macro \"%s\": Invalid primitive id code %d, line %d: \"%s\"" ),
 
 1113        for( ii = 0; ii < paramCount && *aText && *aText != 
'*'; ++ii )
 
 1121            if( aText == 
nullptr)   
 
 1127        if( ii < paramCount )
 
 1130            msg.Printf( wxT( 
"RS274X: read macro descr type %d: read %d parameters, insufficient " 
 1144            wxASSERT( prim.
m_Params[1].IsImmediate() );
 
 1146            paramCount = (int) prim.
m_Params[1].GetValueFromMacro( 
nullptr ) * 2 + 1;
 
 1148            for( 
int jj = 0; jj < paramCount && *aText != 
'*'; ++jj )
 
 1156                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.
 
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.
 
wxString result
Test unit parsing edge cases and error handling.
 
VECTOR2< int32_t > VECTOR2I