41extern int ReadInt(
char*&
text,
bool aSkipSeparator =
true );
42extern double ReadDouble(
char*&
text,
bool aSkipSeparator =
true );
45#define CODE( x, y ) ( ( (x) << 8 ) + (y) )
128 result = ( currbyte & 0xFF ) << 8;
136 result += currbyte & 0xFF;
201 unsigned int aBuffSize,
char*& aText )
209 bool x_fmt_known =
false;
210 bool y_fmt_known =
false;
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" ),
334 if( !x_fmt_known || !y_fmt_known )
335 AddMessageToList( wxT(
"RS274X: Format Statement (FS) without X or Y format" ) );
342 if( strncasecmp( aText,
"AYBX", 4 ) == 0 )
350 while( *aText && *aText !=
'*' )
393 if(
dummy.IsFileFunction() )
402 else if(
dummy.IsFileMD5() )
406 else if(
dummy.IsFilePart() )
418 if(
dummy.GetAttribute() == wxT(
".AperFunction" ) )
423 for(
int ii = 2; ii <
dummy.GetPrmCount(); ii++ )
435 if(
dummy.GetAttribute() == wxT(
".N" ) )
440 else if(
dummy.GetAttribute() == wxT(
".C" ) )
445 else if(
dummy.GetAttribute() == wxT(
".P" ) )
451 if(
dummy.GetPrmCount() > 3 )
474 while( *aText !=
'*' )
495 while( *aText !=
'*' )
514 while( *aText !=
'*' )
534 if( strncasecmp( aText,
"0*", 2 ) == 0 )
536 else if( strncasecmp( aText,
"90*", 3 ) == 0 )
538 else if( strncasecmp( aText,
"180*", 4 ) == 0 )
540 else if( strncasecmp( aText,
"270*", 4 ) == 0 )
555 while( *aText && *aText !=
'*' )
590 while( *aText && *aText !=
'*' )
603 else if( *aText ==
'L' )
623 else if( *aText ==
'L' )
651 msg =
_(
"RS274X: Command KNOCKOUT ignored by GerbView" ) ;
663 while( *aText !=
'*' )
670 while( *aText && *aText !=
'*' )
676 if( strncasecmp( aText,
"NEG", 3 ) == 0 )
705 if( *aText++ !=
'D' )
718 if( dcode ==
nullptr )
726 if( aText[1] ==
',' )
728 char stdAperture = *aText;
736 switch( stdAperture )
740 while( *aText ==
' ' )
751 while( *aText ==
' ' )
769 while( *aText ==
' ' )
779 while( *aText ==
' ' )
790 while( *aText ==
' ' )
810 while( *aText ==
' ' )
819 while( *aText ==
' ' )
828 while( *aText ==
' ' )
839 while( *aText ==
' ' )
856 while( *aText && *aText !=
'*' && *aText !=
',' )
857 am_lookup.
m_AmName.Append( *aText++ );
865 while( *aText && *aText !=
'*' )
870 if( !( isspace( *aText ) || *aText ==
'X' || *aText ==
'x' || *aText ==
'*' ) )
872 msg.Printf( wxT(
"RS274X: aperture macro %s has invalid template "
880 while( isspace( *aText ) )
884 if( *aText ==
'X' || *aText ==
'x' )
894 msg.Printf( wxT(
"RS274X: aperture macro %s not found\n" ),
925 while( (aText < aBuff + aBuffSize) && *aText )
936 if( fgets( aBuff, aBuffSize,
gerber_file ) ==
nullptr )
960 if( fgets( aBuff, aBuffSize, aFile ) ==
nullptr )
1001 if( aText ==
nullptr )
1027 if( aText ==
nullptr)
1033 else if( !isdigit(*aText) )
1035 msg.Printf( wxT(
"RS274X: Aperture Macro \"%s\": ill. symbol, line: \"%s\"" ),
1041 primitive_type =
ReadInt( aText );
1043 bool is_comment =
false;
1045 switch( primitive_type )
1052 while( *aText && ( *aText !=
'*' ) )
1089 msg.Printf( wxT(
"RS274X: Aperture Macro \"%s\": Invalid primitive id code %d, line %d: \"%s\"" ),
1102 for( ii = 0; ii < paramCount && *aText && *aText !=
'*'; ++ii )
1110 if( aText ==
nullptr)
1116 if( ii < paramCount )
1119 msg.Printf( wxT(
"RS274X: read macro descr type %d: read %d parameters, insufficient "
1133 wxASSERT( prim.
m_Params[1].IsImmediate() );
1135 paramCount = (int) prim.
m_Params[1].GetValueFromMacro(
nullptr ) * 2 + 1;
1137 for(
int jj = 0; jj < paramCount && *aText !=
'*'; ++jj )
1145 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
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.
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.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".