KiCad PCB EDA Suite
gbr_netlist_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) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2016 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 
25 #ifndef GBR_NETLIST_METADATA_H
26 #define GBR_NETLIST_METADATA_H
27 
56 {
57 public:
59  {
63  };
64 
65  double m_Orientation; // orientation in degree
66  wxString m_Manufacturer; // Manufacturer name
67  wxString m_MPN; // Manufacturer part number
68  wxString m_Package; // Package, as per IPC-7351
69  wxString m_Footprint; // Footprint name, from library
70  wxString m_LibraryName; // Library name, containing the footprint
71  wxString m_LibraryDescr; // Library description
72  wxString m_Value; // Component value
73  MOUNT_TYPE m_MountType; // SMD|TH|Other
74 
77  {}
78 
79  void ClearData(); // Clear all strings
85  wxString FormatCmpPnPMetadata();
86 };
87 
96 {
97 public:
98  GBR_DATA_FIELD() : m_useUTF8( false ), m_escapeString( false )
99  {}
100 
101  void clear()
102  {
103  m_field.clear();
104  m_useUTF8 = false;
105  m_escapeString = false;
106  }
107 
108  void Clear() { clear(); }
109 
110  const wxString& GetValue() { return m_field; }
111 
112  void SetField( const wxString& aField, bool aUseUTF8, bool aEscapeString )
113  {
114  m_field = aField;
115  m_useUTF8 = aUseUTF8;
116  m_escapeString = aEscapeString;
117  }
118 
119  bool IsEmpty() { return m_field.IsEmpty(); }
120 
121  std::string GetGerberString();
122 
123 
124 private:
125  wxString m_field;
126  bool m_useUTF8;
129 };
130 
131 
146 {
147 public:
148  // This enum enables the different net attributes attache to the object
149  // the values can be ORed for items which can have more than one attribute
150  // (A flashed pad has all allowed attributes)
152  {
157  };
158 
159  // these members are used in the %TO object attributes command.
161  bool m_NotInNet;
167  wxString m_Cmpref;
168  wxString m_Netname;
169 
170  wxString m_ExtraData;
171 
178 
179 
181  m_NotInNet( false ), m_TryKeepPreviousAttributes( false )
182  {
183  }
184 
188  {
189  m_ExtraData.Clear();
190  }
191 
194  void SetExtraData( const wxString& aExtraData)
195  {
196  m_ExtraData = aExtraData;
197  }
198 
204  void ClearAttribute( const wxString* aName )
205  {
207  {
208  m_Padname.clear();
210  m_Cmpref.clear();
211  m_Netname.clear();
212  return;
213  }
214 
215  if( !aName || aName->IsEmpty() || *aName == ".CN" )
216  {
218  m_Padname.clear();
220  m_Cmpref.clear();
221  m_Netname.clear();
222  return;
223  }
224 
225  if( *aName == ".C" )
226  {
228  m_Cmpref.clear();
229  return;
230  }
231 
232  if( *aName == ".N" )
233  {
235  m_Netname.clear();
236  return;
237  }
238 
239  if( *aName == ".P" )
240  {
242  m_Padname.clear();
244  return;
245  }
246  }
247 };
248 
249 // Flashed pads use the full attribute set: this is a helper for flashed pads
250 #define GBR_NETINFO_ALL (GBR_NETLIST_METADATA::GBR_NETINFO_PAD\
251  | GBR_NETLIST_METADATA::GBR_NETINFO_NET\
252  | GBR_NETLIST_METADATA::GBR_NETINFO_CMP )
253 
254 #endif // GBR_NETLIST_METADATA_H
bool m_useUTF8
true to use UTF8, false to escape non ascii7 chars
print info associated to a component (TO.C attribute)
const wxString & GetValue()
wxString m_Cmpref
the component reference parent of the data
wxString m_field
the unicade text to print in Gbr file (after escape and quoting)
this class handle info which can be added in a gerber file as attribute of an object the GBR_INFO_TYP...
this class handle info which can be added in a gerber P&P file as attribute of a component Only appli...
GBR_DATA_FIELD m_PadPinFunction
for a pad: the pin function (defined in schematic)
This class handle a Gerber data field.
void SetField(const wxString &aField, bool aUseUTF8, bool aEscapeString)
wxString m_ExtraData
a string to print after TO object attributes, if not empty it is printed "as this"
void SetExtraData(const wxString &aExtraData)
Set the extra data string printed at end of net attributes.
GBR_DATA_FIELD m_Padname
for a flashed pad: the pad name ((TO.P attribute)
bool m_escapeString
true to quote the field in gbr file
wxString m_Netname
for items associated to a net: the netname
wxString FormatCmpPnPMetadata()
std::string GetGerberString()
bool m_TryKeepPreviousAttributes
If true, do not clear all attributes when a atribute has changed Usefull when some attributes need to...
print info associated to a flashed pad (TO.P attribute)
void ClearAttribute(const wxString *aName)
remove the net attribute specified by aName If aName == NULL or empty, remove all attributes
bool m_NotInNet
true if a pad of a footprint cannot be connected (for instance a mechanical NPTH, ot a not named pad)...
print info associated to a net (TO.N attribute)
void ClearExtraData()
Clear the extra data string printed at end of net attributes.
int m_NetAttribType
the type of net info (used to define the gerber string to create)