KiCad PCB EDA Suite
gbr_metadata.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
33 #ifndef GBR_METADATA_H
34 #define GBR_METADATA_H
35 
36 #include <gbr_netlist_metadata.h>
37 
51 enum GBR_NC_STRING_FORMAT // Options for string format in some attribute strings
52 {
57 };
59 
60 
69 wxString GbrMakeProjectGUIDfromString( wxString& aText );
70 
71 
72 // this class handle info which can be added in a gerber file as attribute
73 // of an aperture, by the %TA.AperFunction command
74 // This attribute is added when creating a new aperture (command %ADDxx)
75 // Only one aperture attribute can be added to a given aperture
76 //
78 {
79 public:
81  {
88 
102 
118  };
119 
122  {}
123 
127  static std::string GetAttributeName( GBR_APERTURE_ATTRIB aAttribute );
128  std::string GetAttributeName()
129  {
131  }
132 
141  static std::string FormatAttribute( GBR_APERTURE_ATTRIB aAttribute,
142  bool aUseX1StructuredComment );
143 
144  std::string FormatAttribute( bool aUseX1StructuredComment )
145  {
146  return FormatAttribute( m_ApertAttribute, aUseX1StructuredComment );
147  }
148 
149  // The id of the aperture attribute
151 };
152 
153 // this class handle metadata which can be added in a gerber file as attribute
154 // in X2 format
156 {
157 public:
158  GBR_METADATA(): m_isCopper( false) {}
159 
161  {
162  m_ApertureMetadata.m_ApertAttribute = aApertAttribute;
163  }
164 
166  {
168  }
169 
170  void SetNetAttribType( int aNetAttribType )
171  {
172  m_NetlistMetadata.m_NetAttribType = aNetAttribType;
173  }
174 
175  int GetNetAttribType() const
176  {
178  }
179 
180  void SetNetName( const wxString& aNetname ) { m_NetlistMetadata.m_Netname = aNetname; }
181 
182  void SetPadName( const wxString& aPadname, bool aUseUTF8 = false, bool aEscapeString = false )
183  {
184  m_NetlistMetadata.m_Padname.SetField( aPadname, aUseUTF8, aEscapeString );
185  }
186 
187  void SetPadPinFunction( const wxString& aPadPinFunction, bool aUseUTF8, bool aEscapeString )
188  {
189  m_NetlistMetadata.m_PadPinFunction.SetField( aPadPinFunction, aUseUTF8, aEscapeString );
190  }
191 
192  void SetCmpReference( const wxString& aComponentRef )
193  {
194  m_NetlistMetadata.m_Cmpref = aComponentRef;
195  }
196 
201  bool IsCopper() { return m_isCopper; }
202  void SetCopper( bool aValue ) { m_isCopper = aValue; }
203 
208 
213 
214 private:
222 };
223 
224 
233 std::string FormatStringToGerber( const wxString& aString );
234 
235 
247 wxString ConvertNotAllowedCharsInGerber( const wxString& aString, bool aAllowUtf8Chars, bool aQuoteString );
248 
255 wxString FormatStringFromGerber( const wxString& aString );
256 
274 bool FormatNetAttribute( std::string& aPrintedText, std::string& aLastNetAttributes,
275  GBR_NETLIST_METADATA* aData, bool& aClearPreviousAttributes,
276  bool aUseX1StructuredComment );
277 
278 #endif // GBR_METADATA_H
aperture used for etched components
Definition: gbr_metadata.h:83
aperture used to draw component footprint bounding box in placement files
Definition: gbr_metadata.h:113
aperture used for edge connector pad (outer layers)
Definition: gbr_metadata.h:94
aperture used for flashed pin 1 (or A1 or AA1) position in placement files
Definition: gbr_metadata.h:107
aperture used for pads oblong holes in drill files
Definition: gbr_metadata.h:105
aperture used for heat sink pad (typically for SMDs)
Definition: gbr_metadata.h:99
aperture used for flashed pads position in placement files
Definition: gbr_metadata.h:108
void SetNetAttribType(int aNetAttribType)
Definition: gbr_metadata.h:170
wxString m_Cmpref
the component reference parent of the data
aperture used for through hole component on outer layer
Definition: gbr_metadata.h:89
bool IsCopper()
Allowed attributes are not the same on board copper layers and on other layers Therefore a flag can b...
Definition: gbr_metadata.h:201
aperture used for via holes in drill files
Definition: gbr_metadata.h:103
aperture used for castellated pads in drill files
Definition: gbr_metadata.h:101
aperture used for castellated pads in copper layer files
Definition: gbr_metadata.h:100
this class handle info which can be added in a gerber file as attribute of an object the GBR_INFO_TYP...
aperture used for SMD pad. Excluded BGA pads which have their own type
Definition: gbr_metadata.h:90
GBR_DATA_FIELD m_PadPinFunction
for a pad: the pin function (defined in schematic)
void SetPadPinFunction(const wxString &aPadPinFunction, bool aUseUTF8, bool aEscapeString)
Definition: gbr_metadata.h:187
void SetField(const wxString &aField, bool aUseUTF8, bool aEscapeString)
aperture used for BGA pad with a solder mask defined by the solder mask
Definition: gbr_metadata.h:93
aperture used for fiducial pad (outer layers), at board level
Definition: gbr_metadata.h:97
std::string FormatStringToGerber(const wxString &aString)
This helper function "normalize" aString and convert it to a Gerber std::string Normalisation means c...
void SetPadName(const wxString &aPadname, bool aUseUTF8=false, bool aEscapeString=false)
Definition: gbr_metadata.h:182
aperture used for pad holes in drill files
Definition: gbr_metadata.h:104
GBR_DATA_FIELD m_Padname
for a flashed pad: the pad name ((TO.P attribute)
wxString FormatStringFromGerber(const wxString &aString)
This helper function make the inverse conversion of FormatStringToGerber() It converts a "normalized"...
wxString m_Netname
for items associated to a net: the netname
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB GetApertureAttrib()
Definition: gbr_metadata.h:165
std::string GetAttributeName()
Definition: gbr_metadata.h:128
aperture used for mechanical pads (NPTH)
Definition: gbr_metadata.h:95
wxString GbrMakeProjectGUIDfromString(wxString &aText)
A helper function to build a project GUID using format RFC4122 Version 1 or 4 from the project name,...
aperture used to draw component outline courtyard in placement files
Definition: gbr_metadata.h:115
aperture used for BGA pads with a solder mask defined by the copper shape
Definition: gbr_metadata.h:92
bool FormatNetAttribute(std::string &aPrintedText, std::string &aLastNetAttributes, GBR_NETLIST_METADATA *aData, bool &aClearPreviousAttributes, bool aUseX1StructuredComment)
Generates the string to print to a gerber file, to set a net attribute for a graphic object.
aperture used for connected items like tracks (not vias)
Definition: gbr_metadata.h:84
aperture used to draw component physical body outline (without pins) in placement files
Definition: gbr_metadata.h:109
aperture used for test point pad (outer layers)
Definition: gbr_metadata.h:96
static std::string FormatAttribute(GBR_APERTURE_ATTRIB aAttribute, bool aUseX1StructuredComment)
void SetNetName(const wxString &aNetname)
Definition: gbr_metadata.h:180
aperture used for flashed cmp position in placement files
Definition: gbr_metadata.h:106
wxString ConvertNotAllowedCharsInGerber(const wxString &aString, bool aAllowUtf8Chars, bool aQuoteString)
Similar to FormatStringToGerber.
aperture used for fiducial pad (outer layers), at footprint level
Definition: gbr_metadata.h:98
aperture used for SMD pad with a solder mask defined by the solder mask
Definition: gbr_metadata.h:91
int GetNetAttribType() const
Definition: gbr_metadata.h:175
bool m_isCopper
if the metadata is relative to a copper layer or not.
Definition: gbr_metadata.h:221
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
Definition: gbr_metadata.h:160
GBR_NETLIST_METADATA m_NetlistMetadata
a item to handle object attribute:
Definition: gbr_metadata.h:212
wxString GbrMakeCreationDateAttributeString(GBR_NC_STRING_FORMAT aFormat)
aperture used for not connected items (texts, outlines on copper)
Definition: gbr_metadata.h:86
std::string FormatAttribute(bool aUseX1StructuredComment)
Definition: gbr_metadata.h:144
void SetCopper(bool aValue)
Definition: gbr_metadata.h:202
GBR_NC_STRING_FORMAT
creates the TF.CreationDate attribute: The attribute value must conform to the full version of the IS...
Definition: gbr_metadata.h:51
void SetCmpReference(const wxString &aComponentRef)
Definition: gbr_metadata.h:192
GBR_APERTURE_METADATA m_ApertureMetadata
a item to handle aperture attribute:
Definition: gbr_metadata.h:207
aperture used to draw component physical body outline (with pins) in placement files
Definition: gbr_metadata.h:111
GBR_APERTURE_ATTRIB m_ApertAttribute
Definition: gbr_metadata.h:150
int m_NetAttribType
the type of net info (used to define the gerber string to create)