31#include <wx/datetime.h> 
   44    wxDateTime date( wxDateTime::GetTimeNow() );
 
   47    wxString timezone_offset;   
 
   48    timezone_offset = date.Format( 
"%z" );  
 
   53    if( timezone_offset.Len() > 3 )     
 
   55        timezone_offset.insert( 3, 
":", 1 );
 
   62        msg.Printf( wxS( 
"%%TF.CreationDate,%s%s*%%" ), date.FormatISOCombined(), timezone_offset );
 
   66        msg.Printf( wxS( 
"G04 #@! TF.CreationDate,%s%s*" ), date.FormatISOCombined(),
 
   71        msg.Printf( wxS( 
"%s%s" ), date.FormatISOCombined(), timezone_offset );
 
   75        msg.Printf( wxS( 
"; #@! TF.CreationDate,%s%s" ), date.FormatISOCombined(),
 
 
  106    wxString bname = aText;
 
  107    int cnt = 16 - bname.Len();
 
  110        bname.Append( 
'X', cnt );
 
  115    for( 
unsigned ii = 0; ii < 4; ii++ )
 
  117        int cc = int( bname[chr_idx++] ) & 0xFF;
 
  118        guid << wxString::Format( 
"%2.2x", cc );
 
  124    for( 
unsigned ii = 0; ii < 2; ii++ )
 
  126        int cc = int( bname[chr_idx++] ) & 0xFF;
 
  127        guid << wxString::Format( 
"%2.2x", cc );
 
  133        int cc = int( bname[chr_idx++] ) << 4 & 0xFF0;
 
  134        cc += int( bname[chr_idx] ) >> 4 & 0x0F;
 
  135        guid << wxString::Format( 
"%3.3x", cc );
 
  141        int cc = (int( bname[chr_idx++] ) & 0x0F) << 8;
 
  142        cc += int( bname[chr_idx++] ) & 0xFF;
 
  143        guid << wxString::Format( 
"%3.3x", cc );
 
  149    for( 
unsigned ii = 0; ii < 6; ii++ )
 
  151        int cc = int( bname[chr_idx++] ) & 0xFF;
 
  152        guid << wxString::Format( 
"%2.2x", cc );
 
 
  160                                                    bool                aUseX1StructuredComment,
 
  161                                                    const std::string&  aCustomAttribute )
 
  163    std::string attribute_string;   
 
  164    std::string comment_string;     
 
  177        attribute_string = 
"TA.AperFunction,EtchedComponent";
 
  181        attribute_string = 
"TA.AperFunction,Conductor";
 
  185        attribute_string = 
"TA.AperFunction,Profile";
 
  189        attribute_string = 
"TA.AperFunction,ViaPad";
 
  194        attribute_string = 
"TA.AperFunction,NonConductor";
 
  199        attribute_string = 
"TA.AperFunction,ComponentPad";
 
  205        attribute_string = 
"TA.AperFunction,SMDPad,SMDef";
 
  210        attribute_string = 
"TA.AperFunction,SMDPad,CuDef";
 
  215        attribute_string = 
"TA.AperFunction,BGAPad,SMDef";
 
  220        attribute_string = 
"TA.AperFunction,BGAPad,CuDef";
 
  225        attribute_string = 
"TA.AperFunction,ConnectorPad";
 
  230        attribute_string = 
"TA.AperFunction,WasherPad";
 
  235        attribute_string = 
"TA.AperFunction,HeatsinkPad";
 
  240        attribute_string = 
"TA.AperFunction,TestPad";
 
  245        attribute_string = 
"TA.AperFunction,FiducialPad,Global";
 
  250        attribute_string = 
"TA.AperFunction,FiducialPad,Local";
 
  255        attribute_string = 
"TA.AperFunction,CastellatedPad";
 
  260        attribute_string = 
"TA.AperFunction,CastellatedDrill";
 
  264        attribute_string = 
"TA.AperFunction,ViaDrill";
 
  269        attribute_string = 
"TA.AperFunction,ComponentDrill";
 
  274        attribute_string = 
"TA.AperFunction,ComponentDrill,PressFit";
 
  281        comment_string = 
"aperture for slot hole";
 
  282        attribute_string = 
"TA.AperFunction,ComponentDrill";
 
  288        attribute_string = 
"TA.AperFunction,ComponentMain";
 
  295        attribute_string = 
"TA.AperFunction,ComponentPin";
 
  303        attribute_string = 
"TA.AperFunction,ComponentPin";
 
  309        attribute_string = 
"TA.AperFunction,ComponentOutline,Body";
 
  315        attribute_string = 
"TA.AperFunction,ComponentOutline,Lead2Lead";
 
  321        attribute_string = 
"TA.AperFunction,ComponentOutline,Footprint";
 
  327        attribute_string = 
"TA.AperFunction,ComponentOutline,Courtyard";
 
  331        attribute_string = 
"TA.AperFunction,Other," + aCustomAttribute;
 
  335    std::string full_attribute_string;
 
  338    if( !attribute_string.empty() )
 
  340        if( !comment_string.empty() )
 
  342            full_attribute_string = 
"G04 " + comment_string + 
"*\n";
 
  345        if( aUseX1StructuredComment )
 
  347            full_attribute_string += 
"G04 #@! ";
 
  352            full_attribute_string += 
"%";
 
  357    full_attribute_string += attribute_string + eol_string;
 
  359    return full_attribute_string;
 
 
  367    if( aCode >= 
'0' && aCode <= 
'9' )
 
  370    if( aCode >= 
'A' && aCode <= 
'F' )
 
  371        return aCode - 
'A' + 10;
 
  373    if( aCode >= 
'a' && aCode <= 
'f' )
 
  374        return aCode - 
'a' + 10;
 
 
  389    unsigned count = aString.Length();
 
  391    for( 
unsigned ii = 0; ii < count; ++ii )
 
  393        unsigned code = aString[ii];
 
  395        if( code == 
'\\' && ii < count-5 && aString[ii+1] == 
'u' )
 
  407            for( 
int jj = 0; jj < 4; jj++ )
 
  410                code = aString[ii+jj+2];
 
  426                    txt.Append( wxChar( value ) );
 
  432                txt.Append( aString[ii] );
 
  438            txt.Append( aString[ii] );
 
 
  460    for( 
unsigned ii = 0; ii < aString.Length(); ++ii )
 
  462        wxChar code = aString[ii];
 
  483        if( !aAllowUtf8Chars && code > 0x7F )
 
  492            std::snprintf( hexa, 
sizeof( hexa ), 
"\\u%4.4X", code & 0xFFFF );
 
 
  517    std::string txt = 
static_cast<const char*
>( converted.utf8_str() );
 
 
  534    if( !aString.IsEmpty() && ( aString[0] != 
'\"' || aString[aString.Len()-1] != 
'\"' ) )
 
  541    std::string txt = 
static_cast<const char*
>( converted.utf8_str() );
 
 
  549#define NO_NET_NAME wxT( "N/C" )     
  550#define NO_PAD_NAME wxT( "" )        
  555                         bool aUseX1StructuredComment )
 
  557    aClearPreviousAttributes = 
false;
 
  558    wxString prepend_string;
 
  561    if( aUseX1StructuredComment )
 
  563        prepend_string = 
"G04 #@! ";
 
  568        prepend_string = 
"%";
 
  575    if( aData == 
nullptr )
 
  578    std::string pad_attribute_string;
 
  579    std::string net_attribute_string;
 
  580    std::string cmp_attribute_string;
 
  590        pad_attribute_string = prepend_string + 
"TO.P,";
 
  606                pad_attribute_string += 
',';
 
  611        pad_attribute_string += eol_string;
 
  618        net_attribute_string = prepend_string + 
"TO.N,";
 
  640        net_attribute_string += eol_string;
 
  650        cmp_attribute_string = prepend_string + 
"TO.C,";
 
  655    std::string full_attribute_string = pad_attribute_string + net_attribute_string
 
  656                                   + cmp_attribute_string;
 
  659    std::string short_attribute_string;
 
  663    if( aLastNetAttributes != full_attribute_string )
 
  672        bool clearDict = 
false;
 
  674        if( aLastNetAttributes.find( 
"TO.P," ) != std::string::npos )
 
  676            if( pad_attribute_string.empty() )  
 
  679                    short_attribute_string.insert( 0, prepend_string + 
"TO.P" + eol_string );
 
  683            else if( aLastNetAttributes.find( pad_attribute_string ) == std::string::npos )
 
  686                short_attribute_string += pad_attribute_string;
 
  691            short_attribute_string += pad_attribute_string;
 
  694        if( aLastNetAttributes.find( 
"TO.N," ) != std::string::npos )
 
  696            if( net_attribute_string.empty() )  
 
  699                    short_attribute_string.insert( 0, prepend_string + 
"TO.N" + eol_string );
 
  703            else if( aLastNetAttributes.find( net_attribute_string ) == std::string::npos )
 
  706                short_attribute_string += net_attribute_string;
 
  711            short_attribute_string += net_attribute_string;
 
  714        if( aLastNetAttributes.find( 
"TO.C," ) != std::string::npos )
 
  716            if( cmp_attribute_string.empty() )  
 
  724                    if( pad_attribute_string.empty() )
 
  725                        short_attribute_string.insert( 0, prepend_string + 
"TO.C" + eol_string );
 
  732            else if( aLastNetAttributes.find( cmp_attribute_string ) == std::string::npos )
 
  735                short_attribute_string += cmp_attribute_string;
 
  740            short_attribute_string += cmp_attribute_string;
 
  743        aClearPreviousAttributes = clearDict;
 
  745        aLastNetAttributes = full_attribute_string;
 
  748            aPrintedText = full_attribute_string;
 
  750            aPrintedText = short_attribute_string;
 
 
  772    wxString start_of_line( 
"%TO." );
 
  773    wxString end_of_line( 
"*%\n" );
 
  775    wxString mountTypeStrings[] =
 
  783    if( !
m_MPN.IsEmpty() )
 
  784        text << start_of_line << 
"CMPN," << 
m_MPN << end_of_line;
 
  787        text << start_of_line << 
"Cpkg," << 
m_Package << end_of_line;
 
  793        text << start_of_line << 
"CVal," << 
m_Value << end_of_line;
 
  801    text << start_of_line << 
"CMnt," << mountTypeStrings[
m_MountType] << end_of_line;
 
 
std::string GetGerberString() const
 
wxString m_field
the Unicode text to print in Gbr file (after escape and quoting)
 
bool m_useUTF8
true to use UTF8, false to escape non ASCII7 chars
 
bool m_escapeString
true to quote the field in gbr file