KiCad PCB EDA Suite
Loading...
Searching...
No Matches
gbr_metadata.h File Reference

Handle special data (items attributes) during plot. More...

Go to the source code of this file.

Classes

class  GBR_APERTURE_METADATA
 
class  GBR_METADATA
 Metadata which can be added in a gerber file as attribute in X2 format. More...
 

Enumerations

enum  GBR_NC_STRING_FORMAT { GBR_NC_STRING_FORMAT_X1 , GBR_NC_STRING_FORMAT_X2 , GBR_NC_STRING_FORMAT_GBRJOB , GBR_NC_STRING_FORMAT_NCDRILL }
 Create a gerber TF.CreationDate attribute. More...
 

Functions

wxString GbrMakeCreationDateAttributeString (GBR_NC_STRING_FORMAT aFormat)
 
wxString GbrMakeProjectGUIDfromString (const wxString &aText)
 Build a project GUID using format RFC4122 Version 1 or 4 from the project name, because a KiCad project has no specific GUID.
 
std::string FormatStringToGerber (const wxString &aString)
 Normalize aString and convert it to a Gerber std::string.
 
wxString ConvertNotAllowedCharsInGerber (const wxString &aString, bool aAllowUtf8Chars, bool aQuoteString)
 Normalize aString and convert it to a Gerber compatible wxString.
 
wxString FormatStringFromGerber (const wxString &aString)
 Convert a gerber string into a 16 bit Unicode string.
 
bool FormatNetAttribute (std::string &aPrintedText, std::string &aLastNetAttributes, const GBR_NETLIST_METADATA *aData, bool &aClearPreviousAttributes, bool aUseX1StructuredComment)
 Generate the string to set a net attribute for a graphic object to print to a gerber file.
 

Detailed Description

Handle special data (items attributes) during plot.

Used in Gerber plotter to generate auxiliary data during plot (for instance info associated to apertures and flashed pads)

Definition in file gbr_metadata.h.

Enumeration Type Documentation

◆ GBR_NC_STRING_FORMAT

Create a gerber TF.CreationDate attribute.

The attribute value must conform to the full version of the ISO 8601 date and time format, including time and time zone.

Example of structured comment (compatible X1 gerber) G04 #@! TF.CreationDate,2018-11-21T08:49:16+01:00* (example of X1 attribute)

Example NC drill files ; #@! TF.CreationDate,2018-11-21T08:49:16+01:00* (example of NC drill comment)

Example of X2 attribute: TF.CreationDate,2018-11-06T08:25:24+01:00*%

Note
This is the date the Gerber file is effectively created, not the time the project PCB was started.
Parameters
aFormatstring compatibility: X1, X2, GBRJOB or NC drill syntax.
Enumerator
GBR_NC_STRING_FORMAT_X1 
GBR_NC_STRING_FORMAT_X2 
GBR_NC_STRING_FORMAT_GBRJOB 
GBR_NC_STRING_FORMAT_NCDRILL 

Definition at line 59 of file gbr_metadata.h.

Function Documentation

◆ ConvertNotAllowedCharsInGerber()

wxString ConvertNotAllowedCharsInGerber ( const wxString &  aString,
bool  aAllowUtf8Chars,
bool  aQuoteString 
)

Normalize aString and convert it to a Gerber compatible wxString.

Normalization means convert to a hexadecimal 16 bit sequence Unicode and on request convert any code > 0x7F. Illegal characters are ',' '*' '' '\'.

Parameters
aStringthe string to convert.
aAllowUtf8Charsfalse to convert non ASCII7 values to Unicode sequence.
aQuoteStringtrue to double quote the returned string.
Returns
a without illegal chars (and converted non ASCII7 chars on request)

Definition at line 435 of file gbr_metadata.cpp.

References convert.

Referenced by PLACEFILE_GERBER_WRITER::CreatePlaceFile(), FormatStringToGerber(), and GBR_DATA_FIELD::GetGerberString().

◆ FormatNetAttribute()

bool FormatNetAttribute ( std::string &  aPrintedText,
std::string &  aLastNetAttributes,
const GBR_NETLIST_METADATA aData,
bool &  aClearPreviousAttributes,
bool  aUseX1StructuredComment 
)

Generate the string to set a net attribute for a graphic object to print to a gerber file.

Parameters
aPrintedTextis the string to print.
aLastNetAttributesis the current full set of attributes.
aDatais the GBR_NETLIST_METADATA associated to the graphic object (can be NULL if no associated metadata, and aClearPreviousAttributes will be set to false)
aClearPreviousAttributesreturns true if the full set of attributes must be deleted from file before adding new attribute (happens when a previous attribute no longer exists).
aUseX1StructuredCommentfalse in X2 mode and true in X1 mode to add the net attribute in compatible X1 structured comment (i.e. prefixed by "G04 #@! ")
Returns
false if nothing can be done (GBR_NETLIST_METADATA has GBR_APERTURE_ATTRIB_NONE, and true if OK. If the new attribute(s) is the same as current attribute(s), aPrintedText will be empty.

Definition at line 542 of file gbr_metadata.cpp.

References FormatStringToGerber(), GBR_NETLIST_METADATA::GBR_NETINFO_CMP, GBR_NETLIST_METADATA::GBR_NETINFO_NET, GBR_NETLIST_METADATA::GBR_NETINFO_PAD, GBR_NETLIST_METADATA::GBR_NETINFO_UNSPECIFIED, GBR_DATA_FIELD::GetGerberString(), GBR_DATA_FIELD::IsEmpty(), GBR_NETLIST_METADATA::m_Cmpref, GBR_NETLIST_METADATA::m_NetAttribType, GBR_NETLIST_METADATA::m_Netname, GBR_NETLIST_METADATA::m_NotInNet, GBR_NETLIST_METADATA::m_Padname, GBR_NETLIST_METADATA::m_PadPinFunction, GBR_NETLIST_METADATA::m_TryKeepPreviousAttributes, NO_NET_NAME, and NO_PAD_NAME.

Referenced by GERBER_PLOTTER::formatNetAttribute().

◆ FormatStringFromGerber()

wxString FormatStringFromGerber ( const wxString &  aString)

Convert a gerber string into a 16 bit Unicode string.

Parameters
aStringthe gerber string to format.
Returns
a 16 bit Unicode string.

Definition at line 369 of file gbr_metadata.cpp.

References char2Hex().

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand().

◆ FormatStringToGerber()

std::string FormatStringToGerber ( const wxString &  aString)

Normalize aString and convert it to a Gerber std::string.

Normalization means convert any code > 0x7F and unauthorized code to a hexadecimal 16 bit sequence Unicode. Illegal characters are ',' '*' '' '\'.

Parameters
aStringthe string to convert.
Returns
an ASCII7 coded compliant gerber string.

Definition at line 512 of file gbr_metadata.cpp.

References ConvertNotAllowedCharsInGerber().

Referenced by FormatNetAttribute().

◆ GbrMakeCreationDateAttributeString()

◆ GbrMakeProjectGUIDfromString()

wxString GbrMakeProjectGUIDfromString ( const wxString &  aText)

Build a project GUID using format RFC4122 Version 1 or 4 from the project name, because a KiCad project has no specific GUID.

RFC4122 is used mainly for its syntax, because fields have no meaning for Gerber files and therefore the GUID generated has no meaning because it do not use any time and time stamp specific to the project, just a random pattern (random is here a pattern specific to a project).

See en.wikipedia.org/wiki/Universally_unique_identifier

Definition at line 81 of file gbr_metadata.cpp.

Referenced by AddGerberX2Header(), and GERBER_JOBFILE_WRITER::addJSONGeneralSpecs().