KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
29
30#ifndef GBR_METADATA_H
31#define GBR_METADATA_H
32
34
62
64
65
77wxString GbrMakeProjectGUIDfromString( const wxString& aText );
78
79
80// this class handle info which can be added in a gerber file as attribute
81// of an aperture, by the %TA.AperFunction command
82// This attribute is added when creating a new aperture (command %ADDxx)
83// Only one aperture attribute can be added to a given aperture
84//
86{
87public:
177
180
184 static std::string GetAttributeName( GBR_APERTURE_ATTRIB aAttribute );
185 std::string GetAttributeName()
186 {
188 }
189
197 static std::string FormatAttribute( GBR_APERTURE_ATTRIB aAttribute,
198 bool aUseX1StructuredComment,
199 const std::string& aCustomAttribute );
200
201 std::string FormatAttribute( bool aUseX1StructuredComment )
202 {
203 return FormatAttribute( m_ApertAttribute, aUseX1StructuredComment, m_CustomAttribute );
204 }
205
206 // The id of the aperture attribute
208
209 std::string m_CustomAttribute;
210};
211
212
217{
218public:
220
222 {
223 m_ApertureMetadata.m_ApertAttribute = aApertAttribute;
224 }
225
226 void SetApertureAttrib( std::string aCustomAttribute )
227 {
229 m_ApertureMetadata.m_CustomAttribute = aCustomAttribute;
230 }
231
236
237 std::string GetCustomAttribute() { return m_ApertureMetadata.m_CustomAttribute; }
238
239 void SetNetAttribType( int aNetAttribType )
240 {
241 m_NetlistMetadata.m_NetAttribType = aNetAttribType;
242 }
243
245 {
246 return m_NetlistMetadata.m_NetAttribType;
247 }
248
249 void SetNetName( const wxString& aNetname ) { m_NetlistMetadata.m_Netname = aNetname; }
250
251 void SetPadName( const wxString& aPadname, bool aUseUTF8 = false, bool aEscapeString = false )
252 {
253 m_NetlistMetadata.m_Padname.SetField( aPadname, aUseUTF8, aEscapeString );
254 }
255
256 void SetPadPinFunction( const wxString& aPadPinFunction, bool aUseUTF8, bool aEscapeString )
257 {
258 m_NetlistMetadata.m_PadPinFunction.SetField( aPadPinFunction, aUseUTF8, aEscapeString );
259 }
260
261 void SetCmpReference( const wxString& aComponentRef )
262 {
263 m_NetlistMetadata.m_Cmpref = aComponentRef;
264 }
265
271 bool IsCopper() { return m_isCopper; }
272 void SetCopper( bool aValue ) { m_isCopper = aValue; }
273
278
283
284private:
291};
292
293
303std::string FormatStringToGerber( const wxString& aString );
304
305
317wxString ConvertNotAllowedCharsInGerber( const wxString& aString, bool aAllowUtf8Chars,
318 bool aQuoteString );
319
326wxString FormatStringFromGerber( const wxString& aString );
327
344bool FormatNetAttribute( std::string& aPrintedText, std::string& aLastNetAttributes,
345 const GBR_NETLIST_METADATA* aData, bool& aClearPreviousAttributes,
346 bool aUseX1StructuredComment );
347
348#endif // GBR_METADATA_H
GBR_APERTURE_ATTRIB m_ApertAttribute
@ GBR_APERTURE_ATTRIB_CONDUCTOR
Aperture used for connected items like tracks (not vias).
@ GBR_APERTURE_ATTRIB_VIAPAD
Aperture used for vias.
@ GBR_APERTURE_ATTRIB_ETCHEDCMP
Aperture used for etched components.
@ GBR_APERTURE_ATTRIB_BGAPAD_CUDEF
Aperture used for BGA pad with a solder mask defined by the solder mask.
@ GBR_APERTURE_ATTRIB_PRESSFITDRILL
Aperture used for pressfit pads in drill files.
@ GBR_APERTURE_ATTRIB_PAD1_POS
Aperture used for flashed pin 1 (or A1 or AA1) position in placement files.
@ GBR_APERTURE_ATTRIB_BACKDRILL
Aperture used for pad holes in drill files.
@ GBR_APERTURE_ATTRIB_HEATSINKPAD
Aperture used for heat sink pad (typically for SMDs).
@ GBR_APERTURE_ATTRIB_CMP_OBLONG_DRILL
Aperture used for pads oblong holes in drill files.
@ GBR_APERTURE_ATTRIB_CMP_COURTYARD
Aperture used to draw component outline courtyard in placement files.
@ GBR_APERTURE_ATTRIB_TESTPOINT
Aperture used for test point pad (outer layers).
@ GBR_APERTURE_ATTRIB_SMDPAD_SMDEF
Aperture used for SMD pad. Excluded BGA pads which have their own type.
@ GBR_APERTURE_ATTRIB_SMDPAD_CUDEF
Aperture used for SMD pad with a solder mask defined by the solder mask.
@ GBR_APERTURE_ATTRIB_NONE
uninitialized attribute.
@ GBR_APERTURE_ATTRIB_CONNECTORPAD
Aperture used for edge connector pad (outer layers).
@ GBR_APERTURE_ATTRIB_CASTELLATEDDRILL
Aperture used for castellated pads in drill files.
@ GBR_APERTURE_ATTRIB_NONCONDUCTOR
Aperture used for not connected items (texts, outlines on copper).
@ GBR_APERTURE_ATTRIB_END
sentinel: max value
@ GBR_APERTURE_ATTRIB_CMP_POSITION
Aperture used for flashed cmp position in placement files.
@ GBR_APERTURE_ATTRIB_CMP_BODY
Aperture used to draw component physical body outline without pins in placement files.
@ GBR_APERTURE_ATTRIB_BGAPAD_SMDEF
Aperture used for BGA pads with a solder mask defined by the copper shape.
@ GBR_APERTURE_ATTRIB_WASHERPAD
Aperture used for mechanical pads (NPTH).
@ GBR_APERTURE_ATTRIB_PADOTHER_POS
Aperture used for flashed pads position in placement files.
@ GBR_APERTURE_ATTRIB_COMPONENTPAD
Aperture used for through hole component on outer layer.
@ GBR_APERTURE_ATTRIB_VIADRILL
Aperture used for backdrill holes in drill files.
@ GBR_APERTURE_ATTRIB_CMP_FOOTPRINT
Aperture used to draw component footprint bounding box in placement files.
@ GBR_APERTURE_ATTRIB_CMP_LEAD2LEAD
Aperture used to draw component physical body outline with pins in placement files.
@ GBR_APERTURE_ATTRIB_FIDUCIAL_GLBL
Aperture used for fiducial pad (outer layers), at board level.
@ GBR_APERTURE_ATTRIB_CASTELLATEDPAD
Aperture used for castellated pads in copper layer files.
@ GBR_APERTURE_ATTRIB_FIDUCIAL_LOCAL
Aperture used for fiducial pad (outer layers), at footprint level.
@ GBR_APERTURE_ATTRIB_EDGECUT
Aperture used for board cutout,.
static std::string FormatAttribute(GBR_APERTURE_ATTRIB aAttribute, bool aUseX1StructuredComment, const std::string &aCustomAttribute)
std::string m_CustomAttribute
static std::string GetAttributeName(GBR_APERTURE_ATTRIB aAttribute)
std::string GetAttributeName()
std::string FormatAttribute(bool aUseX1StructuredComment)
void SetCopper(bool aValue)
void SetCmpReference(const wxString &aComponentRef)
void SetNetName(const wxString &aNetname)
std::string GetCustomAttribute()
void SetPadPinFunction(const wxString &aPadPinFunction, bool aUseUTF8, bool aEscapeString)
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB GetApertureAttrib()
bool IsCopper()
Allowed attributes are not the same on board copper layers and on other layers.
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
int GetNetAttribType() const
void SetNetAttribType(int aNetAttribType)
GBR_APERTURE_METADATA m_ApertureMetadata
An item to handle aperture attribute.
void SetApertureAttrib(std::string aCustomAttribute)
bool m_isCopper
If the metadata is relative to a copper layer or not, this flag which can be set/reset when an attrib...
void SetPadName(const wxString &aPadname, bool aUseUTF8=false, bool aEscapeString=false)
Information which can be added in a gerber file as attribute of an object.
wxString GbrMakeProjectGUIDfromString(const wxString &aText)
Build a project GUID using format RFC4122 Version 1 or 4 from the project name, because a KiCad proje...
wxString GbrMakeCreationDateAttributeString(GBR_NC_STRING_FORMAT aFormat)
std::string FormatStringToGerber(const wxString &aString)
Normalize aString and convert it to a Gerber std::string.
GBR_NC_STRING_FORMAT
Create a gerber TF.CreationDate attribute.
@ GBR_NC_STRING_FORMAT_X1
@ GBR_NC_STRING_FORMAT_NCDRILL
@ GBR_NC_STRING_FORMAT_X2
@ GBR_NC_STRING_FORMAT_GBRJOB
wxString ConvertNotAllowedCharsInGerber(const wxString &aString, bool aAllowUtf8Chars, bool aQuoteString)
Normalize aString and convert it to a Gerber compatible wxString.
wxString FormatStringFromGerber(const wxString &aString)
Convert a gerber string into a 16 bit Unicode string.
bool FormatNetAttribute(std::string &aPrintedText, std::string &aLastNetAttributes, const GBR_NETLIST_METADATA *aData, bool &aClearPreviousAttributes, bool aUseX1StructuredComment)
Generate the string to set a net attribute for a graphic object to print to a gerber file.