40extern int ReadInt(
char*& text,
bool aSkipSeparator =
true );
41extern double ReadDouble(
char*& text,
bool aSkipSeparator =
true );
44#define CODE( x, y ) ( ( (x) << 8 ) + (y) )
127 result = ( currbyte & 0xFF ) << 8;
135 result += currbyte & 0xFF;
200 unsigned int aBuffSize,
char*& aText )
208 bool x_fmt_known =
false;
209 bool y_fmt_known =
false;
222 while( *aText !=
'*' )
231 msg.Printf(
_(
"RS274X: Invalid GERBER format command '%c' at line %d: \"%s\"" ),
234 msg.Printf(
_(
"GERBER file \"%s\" may not display as intended." ),
266 if( (seq_char >=
'0') && (seq_char <=
'9') )
267 seq_len = seq_char -
'0';
277 if( ( code >=
'0' ) && ( code <=
'9' ) )
286 char ctmp = *(aText++) -
'0';
324 msg.Printf( wxT(
"Unknown id (%c) in FS command" ),
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 !=
'*' )
392 if(
dummy.IsFileFunction() )
401 else if(
dummy.IsFileMD5() )
405 else if(
dummy.IsFilePart() )
417 if(
dummy.GetAttribute() == wxT(
".AperFunction" ) )
422 for(
int ii = 2; ii <
dummy.GetPrmCount(); ii++ )
434 if(
dummy.GetAttribute() == wxT(
".N" ) )
439 else if(
dummy.GetAttribute() == wxT(
".C" ) )
444 else if(
dummy.GetAttribute() == wxT(
".P" ) )
450 if(
dummy.GetPrmCount() > 3 )
473 while( *aText !=
'*' )
494 while( *aText !=
'*' )
513 while( *aText !=
'*' )
533 if( strncasecmp( aText,
"0*", 2 ) == 0 )
535 else if( strncasecmp( aText,
"90*", 3 ) == 0 )
537 else if( strncasecmp( aText,
"180*", 4 ) == 0 )
539 else if( strncasecmp( aText,
"270*", 4 ) == 0 )
554 while( *aText && *aText !=
'*' )
589 while( *aText && *aText !=
'*' )
602 else if( *aText ==
'L' )
622 else if( *aText ==
'L' )
650 msg =
_(
"RS274X: Command KNOCKOUT ignored by GerbView" ) ;
662 while( *aText !=
'*' )
669 while( *aText && *aText !=
'*' )
675 if( strncasecmp( aText,
"NEG", 3 ) == 0 )
704 if( *aText++ !=
'D' )
717 if( dcode ==
nullptr )
725 if( aText[1] ==
',' )
727 char stdAperture = *aText;
735 switch( stdAperture )
739 while( *aText ==
' ' )
750 while( *aText ==
' ' )
768 while( *aText ==
' ' )
778 while( *aText ==
' ' )
789 while( *aText ==
' ' )
809 while( *aText ==
' ' )
818 while( *aText ==
' ' )
827 while( *aText ==
' ' )
838 while( *aText ==
' ' )
855 while( *aText && *aText !=
'*' && *aText !=
',' )
856 am_lookup.
m_AmName.Append( *aText++ );
864 while( *aText && *aText !=
'*' )
869 if( !( isspace( *aText ) || *aText ==
'X' || *aText ==
'x' || *aText ==
'*' ) )
871 msg.Printf( wxT(
"RS274X: aperture macro %s has invalid template "
879 while( isspace( *aText ) )
883 if( *aText ==
'X' || *aText ==
'x' )
893 msg.Printf( wxT(
"RS274X: aperture macro %s not found\n" ),
924 while( (aText < aBuff + aBuffSize) && *aText )
935 if( fgets( aBuff, aBuffSize,
gerber_file ) ==
nullptr )
959 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 )
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 ...
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
@ 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
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".