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 <gal/color4d.h>
31 #include <core/optional.h>
32 #include <macros_swig.h>
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 
64 
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  bool HasClearance() const { return (bool) m_Clearance; }
159  int GetClearance() const { return m_Clearance.value_or(-1); }
160  void SetClearance( int aClearance ) { m_Clearance = aClearance; }
161 
162  bool HasTrackWidth() const { return (bool) m_TrackWidth; }
163  int GetTrackWidth() const { return m_TrackWidth.value_or( -1 ); }
164  void SetTrackWidth( int aWidth ) { m_TrackWidth = aWidth; }
165 
166  bool HasViaDiameter() const { return (bool) m_ViaDia; }
167  int GetViaDiameter() const { return m_ViaDia.value_or( -1 ); }
168  void SetViaDiameter( int aDia ) { m_ViaDia = aDia; }
169 
170  int HasViaDrill() const { return (bool) m_ViaDrill; }
171  int GetViaDrill() const { return m_ViaDrill.value_or( -1 ); }
172  void SetViaDrill( int aSize ) { m_ViaDrill = aSize; }
173 
174  bool HasuViaDiameter() const { return (bool) m_uViaDia; }
175  int GetuViaDiameter() const { return m_uViaDia.value_or( -1 ); }
176  void SetuViaDiameter( int aSize ) { m_uViaDia = aSize; }
177 
178  bool HasuViaDrill() const { return (bool) m_uViaDrill; }
179  int GetuViaDrill() const { return m_uViaDrill.value_or( -1 ); }
180  void SetuViaDrill( int aSize ) { m_uViaDrill = aSize; }
181 
182  bool HasDiffPairWidth() const { return (bool) m_diffPairWidth; }
183  int GetDiffPairWidth() const { return m_diffPairWidth.value_or( -1 ); }
184  void SetDiffPairWidth( int aSize ) { m_diffPairWidth = aSize; }
185 
186  bool HasDiffPairGap() const { return (bool) m_diffPairGap; }
187  int GetDiffPairGap() const { return m_diffPairGap.value_or( -1 ); }
188  void SetDiffPairGap( int aSize ) { m_diffPairGap = aSize; }
189 
190  bool HasDiffPairViaGap() const { return (bool) m_diffPairViaGap; }
191  int GetDiffPairViaGap() const { return m_diffPairViaGap.value_or( -1 ); }
192  void SetDiffPairViaGap( int aSize ) { m_diffPairViaGap = aSize; }
193 
194  COLOR4D GetPcbColor() const { return m_PcbColor; }
195  void SetPcbColor( const COLOR4D& aColor ) { m_PcbColor = aColor; }
196 
197  int GetWireWidth() const { return m_wireWidth; }
198  void SetWireWidth( int aWidth ) { m_wireWidth = aWidth; }
199 
200  int GetBusWidth() const { return m_busWidth; }
201  void SetBusWidth( int aWidth ) { m_busWidth = aWidth; }
202 
203  COLOR4D GetSchematicColor() const { return m_schematicColor; }
204  void SetSchematicColor( COLOR4D aColor ) { m_schematicColor = aColor; }
205 
206  int GetLineStyle() const { return m_lineStyle; }
207  void SetLineStyle( int aStyle ) { m_lineStyle = aStyle; }
208 
209 #if defined(DEBUG)
210  void Show( int nestLevel, std::ostream& os ) const;
211 #endif
212 };
213 
214 
215 DECL_SPTR_FOR_SWIG( NETCLASSPTR, NETCLASS )
216 DECL_MAP_FOR_SWIG( NETCLASS_MAP, wxString, NETCLASSPTR )
217 
218 
219 
225 {
226 private:
227  NETCLASS_MAP m_NetClasses; // All the netclasses EXCEPT the default one
228  NETCLASSPTR m_default;
229 
230 public:
231  NETCLASSES();
232  ~NETCLASSES();
233 
239  void Clear()
240  {
241  m_NetClasses.clear();
242  m_default->Clear();
243  }
244 
245  typedef NETCLASS_MAP::iterator iterator;
246  iterator begin() { return m_NetClasses.begin(); }
247  iterator end() { return m_NetClasses.end(); }
248 
249  typedef NETCLASS_MAP::const_iterator const_iterator;
250  const_iterator begin() const { return m_NetClasses.begin(); }
251  const_iterator end() const { return m_NetClasses.end(); }
252 
257  unsigned GetCount() const
258  {
259  return m_NetClasses.size();
260  }
261 
266  NETCLASSPTR GetDefault() const
267  {
268  return m_default;
269  }
270 
272  {
273  return m_default.get();
274  }
275 
283  bool Add( const NETCLASSPTR& aNetclass );
284 
291  NETCLASSPTR Remove( const wxString& aNetName );
292 
299  NETCLASSPTR Find( const wxString& aName ) const;
300 
302  NETCLASS_MAP& NetClasses() { return m_NetClasses; }
303 };
304 
305 #endif // CLASS_NETCLASS_H
LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived to re...
Definition: richio.h:82
void SetDiffPairWidth(int aSize)
Definition: netclass.h:184
int GetDiffPairGap() const
Definition: netclass.h:187
NETCLASSPTR m_default
Definition: netclass.h:228
wxString GetClass() const
Definition: netclass.h:91
int m_busWidth
Definition: netclass.h:73
bool HasDiffPairViaGap() const
Definition: netclass.h:190
const wxString & GetName() const
Definition: netclass.h:96
OPT< int > m_diffPairViaGap
Definition: netclass.h:70
NETCLASS_MAP & NetClasses()
Provide public access to m_NetClasses so it gets swigged.
Definition: netclass.h:302
STRINGSET & NetNames()
for SWIG
Definition: netclass.h:153
const_iterator end() const
Definition: netclass.h:251
int HasViaDrill() const
Definition: netclass.h:170
OPT< int > m_TrackWidth
track width used to route NETs in this NETCLASS
Definition: netclass.h:61
unsigned GetCount() const
Function GetCount returns the number of nets in this NETCLASS, i.e.
Definition: netclass.h:103
OPT< int > m_uViaDia
microvia diameter
Definition: netclass.h:65
void SetDescription(const wxString &aDesc)
Definition: netclass.h:156
OPT< int > m_diffPairGap
Definition: netclass.h:69
iterator end()
Definition: netclass.h:247
void SetLineStyle(int aStyle)
Definition: netclass.h:207
COLOR4D m_PcbColor
Optional color override for this netclass (PCB context)
Definition: netclass.h:77
OPT< int > m_diffPairWidth
Definition: netclass.h:68
void SetTrackWidth(int aWidth)
Definition: netclass.h:164
void SetWireWidth(int aWidth)
Definition: netclass.h:198
OPT< int > m_uViaDrill
microvia drill hole diameter
Definition: netclass.h:66
bool HasClearance() const
Definition: netclass.h:158
bool HasuViaDrill() const
Definition: netclass.h:178
NETCLASS_MAP::const_iterator const_iterator
Definition: netclass.h:249
void SetViaDrill(int aSize)
Definition: netclass.h:172
iterator begin()
Definition: netclass.h:128
bool HasDiffPairGap() const
Definition: netclass.h:186
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:195
void SetName(const wxString &aName)
Definition: netclass.h:97
OPT< int > m_ViaDia
via diameter
Definition: netclass.h:62
void SetDiffPairGap(int aSize)
Definition: netclass.h:188
COLOR4D GetSchematicColor() const
Definition: netclass.h:203
NETCLASS_MAP::iterator iterator
Definition: netclass.h:245
OPT< int > m_Clearance
The units on these parameters is Internal Units (1 nm)
Definition: netclass.h:59
STRINGSET::iterator iterator
Definition: netclass.h:127
int GetTrackWidth() const
Definition: netclass.h:163
iterator begin()
Definition: netclass.h:246
NETCLASSES is a container for NETCLASS instances.
Definition: netclass.h:224
bool HasDiffPairWidth() const
Definition: netclass.h:182
int GetDiffPairViaGap() const
Definition: netclass.h:191
OPT< int > m_ViaDrill
via drill hole diameter
Definition: netclass.h:63
iterator end()
Definition: netclass.h:129
void SetClearance(int aClearance)
Definition: netclass.h:160
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:206
int GetViaDrill() const
Definition: netclass.h:171
#define DECL_MAP_FOR_SWIG(TypeName, KeyType, ValueType)
Definition: macros_swig.h:52
void SetSchematicColor(COLOR4D aColor)
Definition: netclass.h:204
COLOR4D GetPcbColor() const
Definition: netclass.h:194
#define DECL_SET_FOR_SWIG(TypeName, MemberType)
Definition: macros_swig.h:54
int GetuViaDiameter() const
Definition: netclass.h:175
void SetuViaDiameter(int aSize)
Definition: netclass.h:176
int GetDiffPairWidth() const
Definition: netclass.h:183
NETCLASS * GetDefaultPtr() const
Definition: netclass.h:271
void SetBusWidth(int aWidth)
Definition: netclass.h:201
void SetDiffPairViaGap(int aSize)
Definition: netclass.h:192
bool HasuViaDiameter() const
Definition: netclass.h:174
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
void Clear()
Function Clear destroys any contained NETCLASS instances except the Default one, and clears any membe...
Definition: netclass.h:239
void SetuViaDrill(int aSize)
Definition: netclass.h:180
int GetWireWidth() const
Definition: netclass.h:197
Information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:186
int GetClearance() const
Definition: netclass.h:159
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:167
const_iterator begin() const
Definition: netclass.h:132
COLOR4D m_schematicColor
Definition: netclass.h:74
unsigned GetCount() const
Function GetCount.
Definition: netclass.h:257
int GetBusWidth() const
Definition: netclass.h:200
boost::optional< T > OPT
Definition: optional.h:7
const wxString & GetDescription() const
Definition: netclass.h:155
This file contains macros just for swig binding.
STRINGSET::const_iterator const_iterator
Definition: netclass.h:131
void SetViaDiameter(int aDia)
Definition: netclass.h:168
NETCLASSPTR GetDefault() const
Function GetDefault.
Definition: netclass.h:266
int GetuViaDrill() const
Definition: netclass.h:179
#define DECL_SPTR_FOR_SWIG(TypeName, MemberType)
Definition: macros_swig.h:53
const_iterator begin() const
Definition: netclass.h:250
NETCLASS_MAP m_NetClasses
Definition: netclass.h:227
int m_wireWidth
Definition: netclass.h:72
bool HasTrackWidth() const
Definition: netclass.h:162
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:100
bool HasViaDiameter() const
Definition: netclass.h:166