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  {
111  };
112 
115  {}
116 
120  static std::string GetAttributeName( GBR_APERTURE_ATTRIB aAttribute );
121  std::string GetAttributeName()
122  {
124  }
125 
134  static std::string FormatAttribute( GBR_APERTURE_ATTRIB aAttribute,
135  bool aUseX1StructuredComment );
136 
137  std::string FormatAttribute( bool aUseX1StructuredComment )
138  {
139  return FormatAttribute( m_ApertAttribute, aUseX1StructuredComment );
140  }
141 
142  // The id of the aperture attribute
144 };
145 
146 // this class handle metadata which can be added in a gerber file as attribute
147 // in X2 format
149 {
150 public:
151  GBR_METADATA(): m_isCopper( false) {}
152 
154  {
155  m_ApertureMetadata.m_ApertAttribute = aApertAttribute;
156  }
157 
159  {
161  }
162 
163  void SetNetAttribType( int aNetAttribType )
164  {
165  m_NetlistMetadata.m_NetAttribType = aNetAttribType;
166  }
167 
168  int GetNetAttribType() const
169  {
171  }
172 
173  void SetNetName( const wxString& aNetname ) { m_NetlistMetadata.m_Netname = aNetname; }
174  void SetPadName( const wxString& aPadname ) { m_NetlistMetadata.m_Padname = aPadname; }
175  void SetCmpReference( const wxString& aComponentRef ) { m_NetlistMetadata.m_Cmpref = aComponentRef; }
176 
181  bool IsCopper() { return m_isCopper; }
182  void SetCopper( bool aValue ) { m_isCopper = aValue; }
183 
188 
193 
194 private:
202 };
203 
204 
213 std::string FormatStringToGerber( const wxString& aString );
214 
215 
227 wxString ConvertNotAllowedCharsInGerber( const wxString& aString, bool aAllowUtf8Chars, bool aQuoteString );
228 
235 wxString FormatStringFromGerber( const wxString& aString );
236 
254 bool FormatNetAttribute( std::string& aPrintedText, std::string& aLastNetAttributes,
255  GBR_NETLIST_METADATA* aData, bool& aClearPreviousAttributes,
256  bool aUseX1StructuredComment );
257 
258 #endif // GBR_METADATA_H
void SetPadName(const wxString &aPadname)
Definition: gbr_metadata.h:174
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:106
aperture used for edge connecto pad (outer layers)
Definition: gbr_metadata.h:93
aperture used for flashed pin 1 (or A1 or AA1) position in placement files
Definition: gbr_metadata.h:100
aperture used for pads oblong holes in drill files
Definition: gbr_metadata.h:98
aperture used for heat sink pad (typically for SMDs)
Definition: gbr_metadata.h:95
aperture used for flashed pads position in placement files
Definition: gbr_metadata.h:101
void SetNetAttribType(int aNetAttribType)
Definition: gbr_metadata.h:163
wxString m_Cmpref
the component reference parent of the data
aperture used for through hole component on outer layer
Definition: gbr_metadata.h:88
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:181
aperture used for via holes in drill files
Definition: gbr_metadata.h:96
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:89
aperture used for BGA pad with a solder mask defined by the solder mask
Definition: gbr_metadata.h:92
wxString m_Padname
for a flashed pad: the pad name ((TO.P attribute)
std::string FormatStringToGerber(const wxString &aString)
This helper function "normalize" aString and convert it to a Gerber std::string Normalisation means c...
aperture used for pad holes in drill files
Definition: gbr_metadata.h:97
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:158
std::string GetAttributeName()
Definition: gbr_metadata.h:121
aperture used for mechanical pads (NPTH)
Definition: gbr_metadata.h:94
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:108
aperture used for BGA pads with a solder mask defined by the copper shape
Definition: gbr_metadata.h:91
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:102
static std::string FormatAttribute(GBR_APERTURE_ATTRIB aAttribute, bool aUseX1StructuredComment)
void SetNetName(const wxString &aNetname)
Definition: gbr_metadata.h:173
aperture used for flashed cmp position in placement files
Definition: gbr_metadata.h:99
wxString ConvertNotAllowedCharsInGerber(const wxString &aString, bool aAllowUtf8Chars, bool aQuoteString)
Similar to FormatStringToGerber.
aperture used for SMD pad with a solder mask defined by the solder mask
Definition: gbr_metadata.h:90
int GetNetAttribType() const
Definition: gbr_metadata.h:168
bool m_isCopper
if the metadata is relative to a copper layer or not.
Definition: gbr_metadata.h:201
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
Definition: gbr_metadata.h:153
GBR_NETLIST_METADATA m_NetlistMetadata
a item to handle object attribute:
Definition: gbr_metadata.h:192
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:137
void SetCopper(bool aValue)
Definition: gbr_metadata.h:182
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:175
GBR_APERTURE_METADATA m_ApertureMetadata
a item to handle aperture attribute:
Definition: gbr_metadata.h:187
aperture used to draw component physical body outline (with pins) in placement files
Definition: gbr_metadata.h:104
GBR_APERTURE_ATTRIB m_ApertAttribute
Definition: gbr_metadata.h:143
int m_NetAttribType
the type of net info (used to define the gerber string to create)