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  {
100  };
101 
104  {}
105 
109  static std::string GetAttributeName( GBR_APERTURE_ATTRIB aAttribute );
110  std::string GetAttributeName()
111  {
113  }
114 
123  static std::string FormatAttribute( GBR_APERTURE_ATTRIB aAttribute,
124  bool aUseX1StructuredComment );
125 
126  std::string FormatAttribute( bool aUseX1StructuredComment )
127  {
128  return FormatAttribute( m_ApertAttribute, aUseX1StructuredComment );
129  }
130 
131  // The id of the aperture attribute
133 };
134 
135 // this class handle metadata which can be added in a gerber file as attribute
136 // in X2 format
138 {
139 public:
140  GBR_METADATA(): m_isCopper( false) {}
141 
143  {
144  m_ApertureMetadata.m_ApertAttribute = aApertAttribute;
145  }
146 
148  {
150  }
151 
152  void SetNetAttribType( int aNetAttribType )
153  {
154  m_NetlistMetadata.m_NetAttribType = aNetAttribType;
155  }
156 
157  int GetNetAttribType() const
158  {
160  }
161 
162  void SetNetName( const wxString& aNetname ) { m_NetlistMetadata.m_Netname = aNetname; }
163  void SetPadName( const wxString& aPadname ) { m_NetlistMetadata.m_Padname = aPadname; }
164  void SetCmpReference( const wxString& aComponentRef ) { m_NetlistMetadata.m_Cmpref = aComponentRef; }
165 
170  bool IsCopper() { return m_isCopper; }
171  void SetCopper( bool aValue ) { m_isCopper = aValue; }
172 
177 
182 
183 private:
191 };
192 
193 
202 std::string formatStringToGerber( const wxString& aString );
203 
210 wxString FormatStringFromGerber( const wxString& aString );
211 
229 bool FormatNetAttribute( std::string& aPrintedText, std::string& aLastNetAttributes,
230  GBR_NETLIST_METADATA* aData, bool& aClearPreviousAttributes,
231  bool aUseX1StructuredComment );
232 
233 #endif // GBR_METADATA_H
void SetPadName(const wxString &aPadname)
Definition: gbr_metadata.h:163
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 heat sink pad (typically for SMDs)
Definition: gbr_metadata.h:95
void SetNetAttribType(int aNetAttribType)
Definition: gbr_metadata.h:152
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:170
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:147
std::string GetAttributeName()
Definition: gbr_metadata.h:110
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 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:162
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:157
bool m_isCopper
if the metadata is relative to a copper layer or not.
Definition: gbr_metadata.h:190
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
Definition: gbr_metadata.h:142
GBR_NETLIST_METADATA m_NetlistMetadata
a item to handle object attribute:
Definition: gbr_metadata.h:181
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:126
void SetCopper(bool aValue)
Definition: gbr_metadata.h:171
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
aperture used for oblong holes in drill files
Definition: gbr_metadata.h:98
void SetCmpReference(const wxString &aComponentRef)
Definition: gbr_metadata.h:164
GBR_APERTURE_METADATA m_ApertureMetadata
a item to handle aperture attribute:
Definition: gbr_metadata.h:176
GBR_APERTURE_ATTRIB m_ApertAttribute
Definition: gbr_metadata.h:132
int m_NetAttribType
the type of net info (used to define the gerber string to create)