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 (C) 2018-2020 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
34
#ifndef GBR_METADATA_H
35
#define GBR_METADATA_H
36
37
#include <
gbr_netlist_metadata.h
>
38
59
enum
GBR_NC_STRING_FORMAT
// Options for string format in some attribute strings
60
{
61
GBR_NC_STRING_FORMAT_X1
,
62
GBR_NC_STRING_FORMAT_X2
,
63
GBR_NC_STRING_FORMAT_GBRJOB
,
64
GBR_NC_STRING_FORMAT_NCDRILL
65
};
66
wxString
GbrMakeCreationDateAttributeString
(
GBR_NC_STRING_FORMAT
aFormat );
67
68
80
wxString
GbrMakeProjectGUIDfromString
(
const
wxString& aText );
81
82
83
// this class handle info which can be added in a gerber file as attribute
84
// of an aperture, by the %TA.AperFunction command
85
// This attribute is added when creating a new aperture (command %ADDxx)
86
// Only one aperture attribute can be added to a given aperture
87
//
88
class
GBR_APERTURE_METADATA
89
{
90
public
:
91
enum
GBR_APERTURE_ATTRIB
92
{
93
GBR_APERTURE_ATTRIB_NONE
,
94
GBR_APERTURE_ATTRIB_ETCHEDCMP
,
95
97
GBR_APERTURE_ATTRIB_CONDUCTOR
,
98
GBR_APERTURE_ATTRIB_EDGECUT
,
99
101
GBR_APERTURE_ATTRIB_NONCONDUCTOR
,
102
GBR_APERTURE_ATTRIB_VIAPAD
,
103
105
GBR_APERTURE_ATTRIB_COMPONENTPAD
,
106
108
GBR_APERTURE_ATTRIB_SMDPAD_SMDEF
,
109
111
GBR_APERTURE_ATTRIB_SMDPAD_CUDEF
,
112
114
GBR_APERTURE_ATTRIB_BGAPAD_SMDEF
,
115
117
GBR_APERTURE_ATTRIB_BGAPAD_CUDEF
,
118
120
GBR_APERTURE_ATTRIB_CONNECTORPAD
,
121
GBR_APERTURE_ATTRIB_WASHERPAD
,
122
GBR_APERTURE_ATTRIB_TESTPOINT
,
123
125
GBR_APERTURE_ATTRIB_FIDUCIAL_GLBL
,
126
128
GBR_APERTURE_ATTRIB_FIDUCIAL_LOCAL
,
129
131
GBR_APERTURE_ATTRIB_HEATSINKPAD
,
132
134
GBR_APERTURE_ATTRIB_CASTELLATEDPAD
,
135
137
GBR_APERTURE_ATTRIB_CASTELLATEDDRILL
,
138
139
GBR_APERTURE_ATTRIB_VIADRILL
,
140
GBR_APERTURE_ATTRIB_CMP_DRILL
,
141
143
GBR_APERTURE_ATTRIB_CMP_OBLONG_DRILL
,
144
146
GBR_APERTURE_ATTRIB_CMP_POSITION
,
147
149
GBR_APERTURE_ATTRIB_PAD1_POS
,
150
152
GBR_APERTURE_ATTRIB_PADOTHER_POS
,
153
155
GBR_APERTURE_ATTRIB_CMP_BODY
,
156
158
GBR_APERTURE_ATTRIB_CMP_LEAD2LEAD
,
159
161
GBR_APERTURE_ATTRIB_CMP_FOOTPRINT
,
162
164
GBR_APERTURE_ATTRIB_CMP_COURTYARD
,
165
GBR_APERTURE_ATTRIB_END
166
};
167
168
GBR_APERTURE_METADATA
()
169
:
m_ApertAttribute
(
GBR_APERTURE_ATTRIB_NONE
)
170
{}
171
175
static
std::string
GetAttributeName
(
GBR_APERTURE_ATTRIB
aAttribute );
176
std::string
GetAttributeName
()
177
{
178
return
GetAttributeName
(
m_ApertAttribute
);
179
}
180
188
static
std::string
FormatAttribute
(
GBR_APERTURE_ATTRIB
aAttribute,
189
bool
aUseX1StructuredComment );
190
191
std::string
FormatAttribute
(
bool
aUseX1StructuredComment )
192
{
193
return
FormatAttribute
(
m_ApertAttribute
, aUseX1StructuredComment );
194
}
195
196
// The id of the aperture attribute
197
GBR_APERTURE_ATTRIB
m_ApertAttribute
;
198
};
199
200
204
class
GBR_METADATA
205
{
206
public
:
207
GBR_METADATA
():
m_isCopper
( false) {}
208
209
void
SetApertureAttrib
(
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB
aApertAttribute )
210
{
211
m_ApertureMetadata
.
m_ApertAttribute
= aApertAttribute;
212
}
213
214
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB
GetApertureAttrib
()
215
{
216
return
m_ApertureMetadata
.
m_ApertAttribute
;
217
}
218
219
void
SetNetAttribType
(
int
aNetAttribType )
220
{
221
m_NetlistMetadata
.
m_NetAttribType
= aNetAttribType;
222
}
223
224
int
GetNetAttribType
()
const
225
{
226
return
m_NetlistMetadata
.
m_NetAttribType
;
227
}
228
229
void
SetNetName
(
const
wxString& aNetname ) {
m_NetlistMetadata
.
m_Netname
= aNetname; }
230
231
void
SetPadName
(
const
wxString& aPadname,
bool
aUseUTF8 =
false
,
bool
aEscapeString =
false
)
232
{
233
m_NetlistMetadata
.
m_Padname
.
SetField
( aPadname, aUseUTF8, aEscapeString );
234
}
235
236
void
SetPadPinFunction
(
const
wxString& aPadPinFunction,
bool
aUseUTF8,
bool
aEscapeString )
237
{
238
m_NetlistMetadata
.
m_PadPinFunction
.
SetField
( aPadPinFunction, aUseUTF8, aEscapeString );
239
}
240
241
void
SetCmpReference
(
const
wxString& aComponentRef )
242
{
243
m_NetlistMetadata
.
m_Cmpref
= aComponentRef;
244
}
245
251
bool
IsCopper
() {
return
m_isCopper
; }
252
void
SetCopper
(
bool
aValue ) {
m_isCopper
= aValue; }
253
257
GBR_APERTURE_METADATA
m_ApertureMetadata
;
258
262
GBR_NETLIST_METADATA
m_NetlistMetadata
;
263
264
private
:
270
bool
m_isCopper
;
271
};
272
273
283
std::string
FormatStringToGerber
(
const
wxString& aString );
284
285
297
wxString
ConvertNotAllowedCharsInGerber
(
const
wxString& aString,
bool
aAllowUtf8Chars,
298
bool
aQuoteString );
299
306
wxString
FormatStringFromGerber
(
const
wxString& aString );
307
324
bool
FormatNetAttribute
( std::string& aPrintedText, std::string& aLastNetAttributes,
325
const
GBR_NETLIST_METADATA
* aData,
bool
& aClearPreviousAttributes,
326
bool
aUseX1StructuredComment );
327
328
#endif
// GBR_METADATA_H
GBR_APERTURE_METADATA
Definition:
gbr_metadata.h:89
GBR_APERTURE_METADATA::m_ApertAttribute
GBR_APERTURE_ATTRIB m_ApertAttribute
Definition:
gbr_metadata.h:197
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB
GBR_APERTURE_ATTRIB
Definition:
gbr_metadata.h:92
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_DRILL
@ GBR_APERTURE_ATTRIB_CMP_DRILL
aperture used for pad holes in drill files.
Definition:
gbr_metadata.h:140
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR
@ GBR_APERTURE_ATTRIB_CONDUCTOR
Definition:
gbr_metadata.h:97
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_VIAPAD
@ GBR_APERTURE_ATTRIB_VIAPAD
aperture used for vias.
Definition:
gbr_metadata.h:102
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_ETCHEDCMP
@ GBR_APERTURE_ATTRIB_ETCHEDCMP
aperture used for etched components.
Definition:
gbr_metadata.h:94
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_BGAPAD_CUDEF
@ GBR_APERTURE_ATTRIB_BGAPAD_CUDEF
aperture used for edge connector pad (outer layers).
Definition:
gbr_metadata.h:117
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_PAD1_POS
@ GBR_APERTURE_ATTRIB_PAD1_POS
aperture used for flashed pads position in placement files.
Definition:
gbr_metadata.h:149
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_HEATSINKPAD
@ GBR_APERTURE_ATTRIB_HEATSINKPAD
aperture used for castellated pads in copper layer files.
Definition:
gbr_metadata.h:131
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_OBLONG_DRILL
@ GBR_APERTURE_ATTRIB_CMP_OBLONG_DRILL
aperture used for flashed cmp position in placement files.
Definition:
gbr_metadata.h:143
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_COURTYARD
@ GBR_APERTURE_ATTRIB_CMP_COURTYARD
Definition:
gbr_metadata.h:164
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_TESTPOINT
@ GBR_APERTURE_ATTRIB_TESTPOINT
aperture used for test point pad (outer layers).
Definition:
gbr_metadata.h:122
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_SMDPAD_SMDEF
@ GBR_APERTURE_ATTRIB_SMDPAD_SMDEF
aperture used for SMD pad with a solder mask defined by the solder mask.
Definition:
gbr_metadata.h:108
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_SMDPAD_CUDEF
@ GBR_APERTURE_ATTRIB_SMDPAD_CUDEF
aperture used for BGA pads with a solder mask defined by the copper shape.
Definition:
gbr_metadata.h:111
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONE
@ GBR_APERTURE_ATTRIB_NONE
uninitialized attribute.
Definition:
gbr_metadata.h:93
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONNECTORPAD
@ GBR_APERTURE_ATTRIB_CONNECTORPAD
Definition:
gbr_metadata.h:120
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CASTELLATEDDRILL
@ GBR_APERTURE_ATTRIB_CASTELLATEDDRILL
Definition:
gbr_metadata.h:137
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR
@ GBR_APERTURE_ATTRIB_NONCONDUCTOR
Definition:
gbr_metadata.h:101
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_END
@ GBR_APERTURE_ATTRIB_END
sentinel: max value
Definition:
gbr_metadata.h:165
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_POSITION
@ GBR_APERTURE_ATTRIB_CMP_POSITION
aperture used for flashed pin 1 (or A1 or AA1) position in placement files.
Definition:
gbr_metadata.h:146
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_BODY
@ GBR_APERTURE_ATTRIB_CMP_BODY
aperture used to draw component physical body outline with pins in placement files.
Definition:
gbr_metadata.h:155
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_BGAPAD_SMDEF
@ GBR_APERTURE_ATTRIB_BGAPAD_SMDEF
aperture used for BGA pad with a solder mask defined by the solder mask.
Definition:
gbr_metadata.h:114
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_WASHERPAD
@ GBR_APERTURE_ATTRIB_WASHERPAD
aperture used for mechanical pads (NPTH).
Definition:
gbr_metadata.h:121
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_PADOTHER_POS
@ GBR_APERTURE_ATTRIB_PADOTHER_POS
aperture used to draw component physical body outline without pins in placement files.
Definition:
gbr_metadata.h:152
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_COMPONENTPAD
@ GBR_APERTURE_ATTRIB_COMPONENTPAD
aperture used for SMD pad. Excluded BGA pads which have their own type.
Definition:
gbr_metadata.h:105
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_VIADRILL
@ GBR_APERTURE_ATTRIB_VIADRILL
aperture used for via holes in drill files.
Definition:
gbr_metadata.h:139
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_FOOTPRINT
@ GBR_APERTURE_ATTRIB_CMP_FOOTPRINT
aperture used to draw component outline courtyard in placement files.
Definition:
gbr_metadata.h:161
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_LEAD2LEAD
@ GBR_APERTURE_ATTRIB_CMP_LEAD2LEAD
aperture used to draw component footprint bounding box in placement files.
Definition:
gbr_metadata.h:158
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_FIDUCIAL_GLBL
@ GBR_APERTURE_ATTRIB_FIDUCIAL_GLBL
aperture used for fiducial pad (outer layers), at footprint level.
Definition:
gbr_metadata.h:125
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CASTELLATEDPAD
@ GBR_APERTURE_ATTRIB_CASTELLATEDPAD
aperture used for castellated pads in drill files.
Definition:
gbr_metadata.h:134
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_FIDUCIAL_LOCAL
@ GBR_APERTURE_ATTRIB_FIDUCIAL_LOCAL
aperture used for heat sink pad (typically for SMDs).
Definition:
gbr_metadata.h:128
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_EDGECUT
@ GBR_APERTURE_ATTRIB_EDGECUT
aperture used for board cutout,
Definition:
gbr_metadata.h:98
GBR_APERTURE_METADATA::FormatAttribute
static std::string FormatAttribute(GBR_APERTURE_ATTRIB aAttribute, bool aUseX1StructuredComment)
Definition:
gbr_metadata.cpp:156
GBR_APERTURE_METADATA::GBR_APERTURE_METADATA
GBR_APERTURE_METADATA()
Definition:
gbr_metadata.h:168
GBR_APERTURE_METADATA::GetAttributeName
static std::string GetAttributeName(GBR_APERTURE_ATTRIB aAttribute)
GBR_APERTURE_METADATA::GetAttributeName
std::string GetAttributeName()
Definition:
gbr_metadata.h:176
GBR_APERTURE_METADATA::FormatAttribute
std::string FormatAttribute(bool aUseX1StructuredComment)
Definition:
gbr_metadata.h:191
GBR_DATA_FIELD::SetField
void SetField(const wxString &aField, bool aUseUTF8, bool aEscapeString)
Definition:
gbr_netlist_metadata.h:116
GBR_METADATA
Metadata which can be added in a gerber file as attribute in X2 format.
Definition:
gbr_metadata.h:205
GBR_METADATA::SetCopper
void SetCopper(bool aValue)
Definition:
gbr_metadata.h:252
GBR_METADATA::SetCmpReference
void SetCmpReference(const wxString &aComponentRef)
Definition:
gbr_metadata.h:241
GBR_METADATA::SetNetName
void SetNetName(const wxString &aNetname)
Definition:
gbr_metadata.h:229
GBR_METADATA::SetPadPinFunction
void SetPadPinFunction(const wxString &aPadPinFunction, bool aUseUTF8, bool aEscapeString)
Definition:
gbr_metadata.h:236
GBR_METADATA::GetApertureAttrib
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB GetApertureAttrib()
Definition:
gbr_metadata.h:214
GBR_METADATA::IsCopper
bool IsCopper()
Allowed attributes are not the same on board copper layers and on other layers.
Definition:
gbr_metadata.h:251
GBR_METADATA::SetApertureAttrib
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
Definition:
gbr_metadata.h:209
GBR_METADATA::GBR_METADATA
GBR_METADATA()
Definition:
gbr_metadata.h:207
GBR_METADATA::m_NetlistMetadata
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
Definition:
gbr_metadata.h:262
GBR_METADATA::GetNetAttribType
int GetNetAttribType() const
Definition:
gbr_metadata.h:224
GBR_METADATA::SetNetAttribType
void SetNetAttribType(int aNetAttribType)
Definition:
gbr_metadata.h:219
GBR_METADATA::m_ApertureMetadata
GBR_APERTURE_METADATA m_ApertureMetadata
An item to handle aperture attribute.
Definition:
gbr_metadata.h:257
GBR_METADATA::m_isCopper
bool m_isCopper
If the metadata is relative to a copper layer or not, this flag which can be set/reset when an attrib...
Definition:
gbr_metadata.h:270
GBR_METADATA::SetPadName
void SetPadName(const wxString &aPadname, bool aUseUTF8=false, bool aEscapeString=false)
Definition:
gbr_metadata.h:231
GBR_NETLIST_METADATA
Information which can be added in a gerber file as attribute of an object.
Definition:
gbr_netlist_metadata.h:149
GBR_NETLIST_METADATA::m_NetAttribType
int m_NetAttribType
the type of net info (used to define the gerber string to create)
Definition:
gbr_netlist_metadata.h:235
GBR_NETLIST_METADATA::m_Cmpref
wxString m_Cmpref
the component reference parent of the data
Definition:
gbr_netlist_metadata.h:242
GBR_NETLIST_METADATA::m_PadPinFunction
GBR_DATA_FIELD m_PadPinFunction
for a pad: the pin function (defined in schematic)
Definition:
gbr_netlist_metadata.h:241
GBR_NETLIST_METADATA::m_Padname
GBR_DATA_FIELD m_Padname
for a flashed pad: the pad name ((TO.P attribute)
Definition:
gbr_netlist_metadata.h:240
GBR_NETLIST_METADATA::m_Netname
wxString m_Netname
for items associated to a net: the netname
Definition:
gbr_netlist_metadata.h:243
GbrMakeProjectGUIDfromString
wxString GbrMakeProjectGUIDfromString(const wxString &aText)
Build a project GUID using format RFC4122 Version 1 or 4 from the project name, because a KiCad proje...
Definition:
gbr_metadata.cpp:81
GbrMakeCreationDateAttributeString
wxString GbrMakeCreationDateAttributeString(GBR_NC_STRING_FORMAT aFormat)
Definition:
gbr_metadata.cpp:37
FormatStringToGerber
std::string FormatStringToGerber(const wxString &aString)
Normalize aString and convert it to a Gerber std::string.
Definition:
gbr_metadata.cpp:512
GBR_NC_STRING_FORMAT
GBR_NC_STRING_FORMAT
Create a gerber TF.CreationDate attribute.
Definition:
gbr_metadata.h:60
GBR_NC_STRING_FORMAT_X1
@ GBR_NC_STRING_FORMAT_X1
Definition:
gbr_metadata.h:61
GBR_NC_STRING_FORMAT_NCDRILL
@ GBR_NC_STRING_FORMAT_NCDRILL
Definition:
gbr_metadata.h:64
GBR_NC_STRING_FORMAT_X2
@ GBR_NC_STRING_FORMAT_X2
Definition:
gbr_metadata.h:62
GBR_NC_STRING_FORMAT_GBRJOB
@ GBR_NC_STRING_FORMAT_GBRJOB
Definition:
gbr_metadata.h:63
ConvertNotAllowedCharsInGerber
wxString ConvertNotAllowedCharsInGerber(const wxString &aString, bool aAllowUtf8Chars, bool aQuoteString)
Normalize aString and convert it to a Gerber compatible wxString.
Definition:
gbr_metadata.cpp:435
FormatStringFromGerber
wxString FormatStringFromGerber(const wxString &aString)
Convert a gerber string into a 16 bit Unicode string.
Definition:
gbr_metadata.cpp:369
FormatNetAttribute
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.
Definition:
gbr_metadata.cpp:542
gbr_netlist_metadata.h
src
include
gbr_metadata.h
Generated on Sun Dec 22 2024 00:05:24 for KiCad PCB EDA Suite by
1.9.6