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  {
103  };
104 
107  {}
108 
112  static std::string GetAttributeName( GBR_APERTURE_ATTRIB aAttribute );
113  std::string GetAttributeName()
114  {
116  }
117 
126  static std::string FormatAttribute( GBR_APERTURE_ATTRIB aAttribute,
127  bool aUseX1StructuredComment );
128 
129  std::string FormatAttribute( bool aUseX1StructuredComment )
130  {
131  return FormatAttribute( m_ApertAttribute, aUseX1StructuredComment );
132  }
133 
134  // The id of the aperture attribute
136 };
137 
138 // this class handle metadata which can be added in a gerber file as attribute
139 // in X2 format
141 {
142 public:
143  GBR_METADATA(): m_isCopper( false) {}
144 
146  {
147  m_ApertureMetadata.m_ApertAttribute = aApertAttribute;
148  }
149 
151  {
153  }
154 
155  void SetNetAttribType( int aNetAttribType )
156  {
157  m_NetlistMetadata.m_NetAttribType = aNetAttribType;
158  }
159 
160  int GetNetAttribType() const
161  {
163  }
164 
165  void SetNetName( const wxString& aNetname ) { m_NetlistMetadata.m_Netname = aNetname; }
166  void SetPadName( const wxString& aPadname ) { m_NetlistMetadata.m_Padname = aPadname; }
167  void SetCmpReference( const wxString& aComponentRef ) { m_NetlistMetadata.m_Cmpref = aComponentRef; }
168 
173  bool IsCopper() { return m_isCopper; }
174  void SetCopper( bool aValue ) { m_isCopper = aValue; }
175 
180 
185 
186 private:
194 };
195 
196 
205 std::string formatStringToGerber( const wxString& aString );
206 
213 wxString FormatStringFromGerber( const wxString& aString );
214 
232 bool FormatNetAttribute( std::string& aPrintedText, std::string& aLastNetAttributes,
233  GBR_NETLIST_METADATA* aData, bool& aClearPreviousAttributes,
234  bool aUseX1StructuredComment );
235 
236 #endif // GBR_METADATA_H
void SetPadName(const wxString &aPadname)
Definition: gbr_metadata.h:166
aperture used for etched components
Definition: gbr_metadata.h:83
aperture used for edge connecto pad (outer layers)
Definition: gbr_metadata.h:93
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
void SetNetAttribType(int aNetAttribType)
Definition: gbr_metadata.h:155
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:173
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 obtect 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)
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:150
std::string GetAttributeName()
Definition: gbr_metadata.h:113
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:100
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.
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 connected items like tracks (not vias)
Definition: gbr_metadata.h:84
static std::string FormatAttribute(GBR_APERTURE_ATTRIB aAttribute, bool aUseX1StructuredComment)
void SetNetName(const wxString &aNetname)
Definition: gbr_metadata.h:165
aperture used for flashed shape in placement files
Definition: gbr_metadata.h:99
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:160
bool m_isCopper
if the metadata is relative to a copper layer or not.
Definition: gbr_metadata.h:193
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
Definition: gbr_metadata.h:145
GBR_NETLIST_METADATA m_NetlistMetadata
a item to handle object attribute:
Definition: gbr_metadata.h:184
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:129
void SetCopper(bool aValue)
Definition: gbr_metadata.h:174
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:167
GBR_APERTURE_METADATA m_ApertureMetadata
a item to handle aperture attribute:
Definition: gbr_metadata.h:179
GBR_APERTURE_ATTRIB m_ApertAttribute
Definition: gbr_metadata.h:135
int m_NetAttribType
the type of net info (used to define the gerber string to create)