KiCad PCB EDA Suite
netclass.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) 2009 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
5  * Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras@inpg.fr
6  * Copyright (C) 2009-2020 KiCad Developers, see change_log.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #ifndef CLASS_NETCLASS_H
27 #define CLASS_NETCLASS_H
28 
29 
30 #include <macros.h>
31 #include <gal/color4d.h>
32 
33 
34 class LINE_READER;
35 class BOARD;
37 using KIGFX::COLOR4D;
38 
39 
40 DECL_SET_FOR_SWIG( STRINGSET, wxString )
41 
42 
43 
49 class NETCLASS
50 {
51 protected:
52  wxString m_Name;
53  wxString m_Description;
54 
56 
58 
60 
62  int m_ViaDia;
63  int m_ViaDrill;
64 
65  int m_uViaDia;
67 
71 
76 
78 
79 public:
80  static const char Default[];
81 
87  NETCLASS( const wxString& aName );
88 
89  ~NETCLASS();
90 
91  wxString GetClass() const
92  {
93  return wxT( "NETCLASS" );
94  }
95 
96  const wxString& GetName() const { return m_Name; }
97  void SetName( const wxString& aName ) { m_Name = aName; }
98 
103  unsigned GetCount() const
104  {
105  return m_Members.size();
106  }
107 
112  void Clear()
113  {
114  m_Members.clear();
115  }
116 
122  void Add( const wxString& aNetname )
123  {
124  m_Members.insert( aNetname );
125  }
126 
127  typedef STRINGSET::iterator iterator;
128  iterator begin() { return m_Members.begin(); }
129  iterator end() { return m_Members.end(); }
130 
131  typedef STRINGSET::const_iterator const_iterator;
132  const_iterator begin() const { return m_Members.begin(); }
133  const_iterator end() const { return m_Members.end(); }
134 
139  void Remove( iterator aName )
140  {
141  m_Members.erase( aName );
142  }
143 
148  void Remove( const wxString& aName )
149  {
150  m_Members.erase( aName );
151  }
152 
153  STRINGSET& NetNames() { return m_Members; }
154 
155  const wxString& GetDescription() const { return m_Description; }
156  void SetDescription( const wxString& aDesc ) { m_Description = aDesc; }
157 
158  int GetClearance( wxString* aSource = nullptr ) const
159  {
160  if( aSource )
161  *aSource = wxString::Format( _( "'%s' netclass" ), m_Name );
162 
163  return m_Clearance;
164  }
165 
166  void SetClearance( int aClearance ) { m_Clearance = aClearance; }
167 
168  int GetTrackWidth() const { return m_TrackWidth; }
169  void SetTrackWidth( int aWidth ) { m_TrackWidth = aWidth; }
170 
171  int GetViaDiameter() const { return m_ViaDia; }
172  void SetViaDiameter( int aDia ) { m_ViaDia = aDia; }
173 
174  int GetViaDrill() const { return m_ViaDrill; }
175  void SetViaDrill( int aSize ) { m_ViaDrill = aSize; }
176 
177  int GetuViaDiameter() const { return m_uViaDia; }
178  void SetuViaDiameter( int aSize ) { m_uViaDia = aSize; }
179 
180  int GetuViaDrill() const { return m_uViaDrill; }
181  void SetuViaDrill( int aSize ) { m_uViaDrill = aSize; }
182 
183  int GetDiffPairWidth() const { return m_diffPairWidth; }
184  void SetDiffPairWidth( int aSize ) { m_diffPairWidth = aSize; }
185 
186  int GetDiffPairGap() const { return m_diffPairGap; }
187  void SetDiffPairGap( int aSize ) { m_diffPairGap = aSize; }
188 
189  int GetDiffPairViaGap() const { return m_diffPairViaGap; }
190  void SetDiffPairViaGap( int aSize ) { m_diffPairViaGap = aSize; }
191 
192  COLOR4D GetPcbColor() const { return m_PcbColor; }
193  void SetPcbColor( const COLOR4D& aColor ) { m_PcbColor = aColor; }
194 
195  int GetWireWidth() const { return m_wireWidth; }
196  void SetWireWidth( int aWidth ) { m_wireWidth = aWidth; }
197 
198  int GetBusWidth() const { return m_busWidth; }
199  void SetBusWidth( int aWidth ) { m_busWidth = aWidth; }
200 
201  COLOR4D GetSchematicColor() const { return m_schematicColor; }
202  void SetSchematicColor( COLOR4D aColor ) { m_schematicColor = aColor; }
203 
204  int GetLineStyle() const { return m_lineStyle; }
205  void SetLineStyle( int aStyle ) { m_lineStyle = aStyle; }
206 
207 #if defined(DEBUG)
208  void Show( int nestLevel, std::ostream& os ) const;
209 #endif
210 };
211 
212 
213 DECL_SPTR_FOR_SWIG( NETCLASSPTR, NETCLASS )
214 DECL_MAP_FOR_SWIG( NETCLASS_MAP, wxString, NETCLASSPTR )
215 
216 
217 
223 {
224 private:
225  NETCLASS_MAP m_NetClasses; // All the netclasses EXCEPT the default one
226  NETCLASSPTR m_default;
227 
228 public:
229  NETCLASSES();
230  ~NETCLASSES();
231 
236  void Clear()
237  {
238  m_NetClasses.clear();
239  }
240 
241  typedef NETCLASS_MAP::iterator iterator;
242  iterator begin() { return m_NetClasses.begin(); }
243  iterator end() { return m_NetClasses.end(); }
244 
245  typedef NETCLASS_MAP::const_iterator const_iterator;
246  const_iterator begin() const { return m_NetClasses.begin(); }
247  const_iterator end() const { return m_NetClasses.end(); }
248 
253  unsigned GetCount() const
254  {
255  return m_NetClasses.size();
256  }
257 
262  NETCLASSPTR GetDefault() const
263  {
264  return m_default;
265  }
266 
268  {
269  return m_default.get();
270  }
271 
279  bool Add( const NETCLASSPTR& aNetclass );
280 
287  NETCLASSPTR Remove( const wxString& aNetName );
288 
295  NETCLASSPTR Find( const wxString& aName ) const;
296 
298  NETCLASS_MAP& NetClasses() { return m_NetClasses; }
299 };
300 
301 #endif // CLASS_NETCLASS_H
int m_ViaDrill
via drill hole diameter
Definition: netclass.h:63
LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived to re...
Definition: richio.h:81
void SetDiffPairWidth(int aSize)
Definition: netclass.h:184
int GetDiffPairGap() const
Definition: netclass.h:186
NETCLASSPTR m_default
Definition: netclass.h:226
wxString GetClass() const
Definition: netclass.h:91
int m_busWidth
Definition: netclass.h:73
const wxString & GetName() const
Definition: netclass.h:96
NETCLASS_MAP & NetClasses()
Provide public access to m_NetClasses so it gets swigged.
Definition: netclass.h:298
int m_uViaDrill
microvia drill hole diameter
Definition: netclass.h:66
STRINGSET & NetNames()
for SWIG
Definition: netclass.h:153
const_iterator end() const
Definition: netclass.h:247
int m_ViaDia
via diameter
Definition: netclass.h:62
unsigned GetCount() const
Function GetCount returns the number of nets in this NETCLASS, i.e.
Definition: netclass.h:103
void SetDescription(const wxString &aDesc)
Definition: netclass.h:156
iterator end()
Definition: netclass.h:243
void SetLineStyle(int aStyle)
Definition: netclass.h:205
int m_diffPairWidth
Definition: netclass.h:68
int GetClearance(wxString *aSource=nullptr) const
Definition: netclass.h:158
COLOR4D m_PcbColor
Optional color override for this netclass (PCB context)
Definition: netclass.h:77
void SetTrackWidth(int aWidth)
Definition: netclass.h:169
void SetWireWidth(int aWidth)
Definition: netclass.h:196
NETCLASS_MAP::const_iterator const_iterator
Definition: netclass.h:245
void SetViaDrill(int aSize)
Definition: netclass.h:175
iterator begin()
Definition: netclass.h:128
STRINGSET m_Members
names of NET members of this class
Definition: netclass.h:55
std::set< std::string > STRINGSET
void SetPcbColor(const COLOR4D &aColor)
Definition: netclass.h:193
This file contains miscellaneous commonly used macros and functions.
void SetName(const wxString &aName)
Definition: netclass.h:97
void SetDiffPairGap(int aSize)
Definition: netclass.h:187
COLOR4D GetSchematicColor() const
Definition: netclass.h:201
NETCLASS_MAP::iterator iterator
Definition: netclass.h:241
STRINGSET::iterator iterator
Definition: netclass.h:127
int GetTrackWidth() const
Definition: netclass.h:168
iterator begin()
Definition: netclass.h:242
NETCLASSES is a container for NETCLASS instances.
Definition: netclass.h:222
int GetDiffPairViaGap() const
Definition: netclass.h:189
iterator end()
Definition: netclass.h:129
void SetClearance(int aClearance)
Definition: netclass.h:166
#define DECL_SET_FOR_SWIG(TypeName, MemberType)
NETCLASS handles a collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:49
int GetLineStyle() const
Definition: netclass.h:204
int GetViaDrill() const
Definition: netclass.h:174
void SetSchematicColor(COLOR4D aColor)
Definition: netclass.h:202
COLOR4D GetPcbColor() const
Definition: netclass.h:192
int m_uViaDia
microvia diameter
Definition: netclass.h:65
int m_diffPairViaGap
Definition: netclass.h:70
int GetuViaDiameter() const
Definition: netclass.h:177
void SetuViaDiameter(int aSize)
Definition: netclass.h:178
int GetDiffPairWidth() const
Definition: netclass.h:183
NETCLASS * GetDefaultPtr() const
Definition: netclass.h:267
void SetBusWidth(int aWidth)
Definition: netclass.h:199
void SetDiffPairViaGap(int aSize)
Definition: netclass.h:190
const_iterator end() const
Definition: netclass.h:133
void Clear()
Function Clear empties the collection of members.
Definition: netclass.h:112
void Remove(iterator aName)
Function Remove will remove NET name aName from the collection of members.
Definition: netclass.h:139
int m_lineStyle
Definition: netclass.h:75
#define DECL_MAP_FOR_SWIG(TypeName, KeyType, ValueType)
void Clear()
Function Clear destroys any contained NETCLASS instances except the Default one.
Definition: netclass.h:236
void SetuViaDrill(int aSize)
Definition: netclass.h:181
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
int GetWireWidth() const
Definition: netclass.h:195
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
#define _(s)
Definition: 3d_actions.cpp:33
wxString m_Description
what this NETCLASS is for.
Definition: netclass.h:53
wxString m_Name
Name of the net class.
Definition: netclass.h:52
void Remove(const wxString &aName)
Function Remove will remove NET name aName from the collection of members.
Definition: netclass.h:148
int GetViaDiameter() const
Definition: netclass.h:171
const_iterator begin() const
Definition: netclass.h:132
COLOR4D m_schematicColor
Definition: netclass.h:74
unsigned GetCount() const
Function GetCount.
Definition: netclass.h:253
int GetBusWidth() const
Definition: netclass.h:198
const wxString & GetDescription() const
Definition: netclass.h:155
STRINGSET::const_iterator const_iterator
Definition: netclass.h:131
void SetViaDiameter(int aDia)
Definition: netclass.h:172
NETCLASSPTR GetDefault() const
Function GetDefault.
Definition: netclass.h:262
int GetuViaDrill() const
Definition: netclass.h:180
#define DECL_SPTR_FOR_SWIG(TypeName, MemberType)
const_iterator begin() const
Definition: netclass.h:246
int m_diffPairGap
Definition: netclass.h:69
NETCLASS_MAP m_NetClasses
Definition: netclass.h:225
int m_TrackWidth
track width used to route NETs in this NETCLASS
Definition: netclass.h:61
int m_wireWidth
Definition: netclass.h:72
int m_Clearance
The units on these parameters is Internal Units (1 nm)
Definition: netclass.h:59
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
void Add(const wxString &aNetname)
Function Add adds aNetname to this NETCLASS if it is not already in this NETCLASS.
Definition: netclass.h:122
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99