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 
46 class NETCLASS
47 {
48 public:
49  static const char Default[];
50 
56  NETCLASS( const wxString& aName );
57 
58  ~NETCLASS();
59 
60  wxString GetClass() const
61  {
62  return wxT( "NETCLASS" );
63  }
64 
65  const wxString& GetName() const { return m_Name; }
66  void SetName( const wxString& aName ) { m_Name = aName; }
67 
71  unsigned GetCount() const
72  {
73  return m_Members.size();
74  }
75 
79  void Clear()
80  {
81  m_Members.clear();
82  }
83 
89  void Add( const wxString& aNetname )
90  {
91  m_Members.insert( aNetname );
92  }
93 
94  typedef STRINGSET::iterator iterator;
95  iterator begin() { return m_Members.begin(); }
96  iterator end() { return m_Members.end(); }
97 
98  typedef STRINGSET::const_iterator const_iterator;
99  const_iterator begin() const { return m_Members.begin(); }
100  const_iterator end() const { return m_Members.end(); }
101 
105  void Remove( iterator aName )
106  {
107  m_Members.erase( aName );
108  }
109 
113  void Remove( const wxString& aName )
114  {
115  m_Members.erase( aName );
116  }
117 
118  STRINGSET& NetNames() { return m_Members; }
119 
120  const wxString& GetDescription() const { return m_Description; }
121  void SetDescription( const wxString& aDesc ) { m_Description = aDesc; }
122 
123  bool HasClearance() const { return (bool) m_Clearance; }
124  int GetClearance() const { return m_Clearance.value_or(-1); }
125  void SetClearance( int aClearance ) { m_Clearance = aClearance; }
126 
127  bool HasTrackWidth() const { return (bool) m_TrackWidth; }
128  int GetTrackWidth() const { return m_TrackWidth.value_or( -1 ); }
129  void SetTrackWidth( int aWidth ) { m_TrackWidth = aWidth; }
130 
131  bool HasViaDiameter() const { return (bool) m_ViaDia; }
132  int GetViaDiameter() const { return m_ViaDia.value_or( -1 ); }
133  void SetViaDiameter( int aDia ) { m_ViaDia = aDia; }
134 
135  int HasViaDrill() const { return (bool) m_ViaDrill; }
136  int GetViaDrill() const { return m_ViaDrill.value_or( -1 ); }
137  void SetViaDrill( int aSize ) { m_ViaDrill = aSize; }
138 
139  bool HasuViaDiameter() const { return (bool) m_uViaDia; }
140  int GetuViaDiameter() const { return m_uViaDia.value_or( -1 ); }
141  void SetuViaDiameter( int aSize ) { m_uViaDia = aSize; }
142 
143  bool HasuViaDrill() const { return (bool) m_uViaDrill; }
144  int GetuViaDrill() const { return m_uViaDrill.value_or( -1 ); }
145  void SetuViaDrill( int aSize ) { m_uViaDrill = aSize; }
146 
147  bool HasDiffPairWidth() const { return (bool) m_diffPairWidth; }
148  int GetDiffPairWidth() const { return m_diffPairWidth.value_or( -1 ); }
149  void SetDiffPairWidth( int aSize ) { m_diffPairWidth = aSize; }
150 
151  bool HasDiffPairGap() const { return (bool) m_diffPairGap; }
152  int GetDiffPairGap() const { return m_diffPairGap.value_or( -1 ); }
153  void SetDiffPairGap( int aSize ) { m_diffPairGap = aSize; }
154 
155  bool HasDiffPairViaGap() const { return (bool) m_diffPairViaGap; }
156  int GetDiffPairViaGap() const { return m_diffPairViaGap.value_or( -1 ); }
157  void SetDiffPairViaGap( int aSize ) { m_diffPairViaGap = aSize; }
158 
159  COLOR4D GetPcbColor() const { return m_PcbColor; }
160  void SetPcbColor( const COLOR4D& aColor ) { m_PcbColor = aColor; }
161 
162  int GetWireWidth() const { return m_wireWidth; }
163  void SetWireWidth( int aWidth ) { m_wireWidth = aWidth; }
164 
165  int GetBusWidth() const { return m_busWidth; }
166  void SetBusWidth( int aWidth ) { m_busWidth = aWidth; }
167 
168  COLOR4D GetSchematicColor() const { return m_schematicColor; }
169  void SetSchematicColor( COLOR4D aColor ) { m_schematicColor = aColor; }
170 
171  int GetLineStyle() const { return m_lineStyle; }
172  void SetLineStyle( int aStyle ) { m_lineStyle = aStyle; }
173 
174 #if defined(DEBUG)
175  void Show( int nestLevel, std::ostream& os ) const;
176 #endif
177 
178 protected:
179  wxString m_Name;
180  wxString m_Description;
181 
183 
185 
187 
191 
194 
198 
203 
205 };
206 
207 
208 DECL_SPTR_FOR_SWIG( NETCLASSPTR, NETCLASS )
209 DECL_MAP_FOR_SWIG( NETCLASS_MAP, wxString, NETCLASSPTR )
210 
211 
212 
219 {
220 public:
221  NETCLASSES();
222  ~NETCLASSES();
223 
228  void Clear()
229  {
230  m_NetClasses.clear();
231  m_default->Clear();
232  }
233 
234  typedef NETCLASS_MAP::iterator iterator;
235  iterator begin() { return m_NetClasses.begin(); }
236  iterator end() { return m_NetClasses.end(); }
237 
238  typedef NETCLASS_MAP::const_iterator const_iterator;
239  const_iterator begin() const { return m_NetClasses.begin(); }
240  const_iterator end() const { return m_NetClasses.end(); }
241 
245  unsigned GetCount() const
246  {
247  return m_NetClasses.size();
248  }
249 
253  NETCLASSPTR GetDefault() const
254  {
255  return m_default;
256  }
257 
259  {
260  return m_default.get();
261  }
262 
270  bool Add( const NETCLASSPTR& aNetclass );
271 
279  NETCLASSPTR Remove( const wxString& aNetName );
280 
287  NETCLASSPTR Find( const wxString& aName ) const;
288 
290  NETCLASS_MAP& NetClasses() { return m_NetClasses; }
291 
292 private:
293  NETCLASS_MAP m_NetClasses; // All the netclasses EXCEPT the default one
294  NETCLASSPTR m_default;
295 };
296 
297 #endif // CLASS_NETCLASS_H
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:80
void SetDiffPairWidth(int aSize)
Definition: netclass.h:149
int GetDiffPairGap() const
Definition: netclass.h:152
NETCLASSPTR m_default
Definition: netclass.h:294
wxString GetClass() const
Definition: netclass.h:60
int m_busWidth
Definition: netclass.h:200
bool HasDiffPairViaGap() const
Definition: netclass.h:155
const wxString & GetName() const
Definition: netclass.h:65
OPT< int > m_diffPairViaGap
Definition: netclass.h:197
NETCLASS_MAP & NetClasses()
Provide public access to m_NetClasses so it gets swigged.
Definition: netclass.h:290
STRINGSET & NetNames()
for SWIG
Definition: netclass.h:118
const_iterator end() const
Definition: netclass.h:240
int HasViaDrill() const
Definition: netclass.h:135
OPT< int > m_TrackWidth
track width used to route NETs in this NETCLASS
Definition: netclass.h:188
unsigned GetCount() const
Return the number of nets in this NETCLASS, i.e.
Definition: netclass.h:71
OPT< int > m_uViaDia
microvia diameter
Definition: netclass.h:192
void SetDescription(const wxString &aDesc)
Definition: netclass.h:121
OPT< int > m_diffPairGap
Definition: netclass.h:196
iterator end()
Definition: netclass.h:236
void SetLineStyle(int aStyle)
Definition: netclass.h:172
COLOR4D m_PcbColor
Optional color override for this netclass (PCB context)
Definition: netclass.h:204
OPT< int > m_diffPairWidth
Definition: netclass.h:195
void SetTrackWidth(int aWidth)
Definition: netclass.h:129
void SetWireWidth(int aWidth)
Definition: netclass.h:163
OPT< int > m_uViaDrill
microvia drill hole diameter
Definition: netclass.h:193
bool HasClearance() const
Definition: netclass.h:123
bool HasuViaDrill() const
Definition: netclass.h:143
NETCLASS_MAP::const_iterator const_iterator
Definition: netclass.h:238
void SetViaDrill(int aSize)
Definition: netclass.h:137
iterator begin()
Definition: netclass.h:95
bool HasDiffPairGap() const
Definition: netclass.h:151
STRINGSET m_Members
names of NET members of this class
Definition: netclass.h:182
std::set< std::string > STRINGSET
void SetPcbColor(const COLOR4D &aColor)
Definition: netclass.h:160
void SetName(const wxString &aName)
Definition: netclass.h:66
OPT< int > m_ViaDia
via diameter
Definition: netclass.h:189
void SetDiffPairGap(int aSize)
Definition: netclass.h:153
COLOR4D GetSchematicColor() const
Definition: netclass.h:168
NETCLASS_MAP::iterator iterator
Definition: netclass.h:234
OPT< int > m_Clearance
The units on these parameters is Internal Units (1 nm)
Definition: netclass.h:186
STRINGSET::iterator iterator
Definition: netclass.h:94
int GetTrackWidth() const
Definition: netclass.h:128
iterator begin()
Definition: netclass.h:235
A container for NETCLASS instances.
Definition: netclass.h:218
bool HasDiffPairWidth() const
Definition: netclass.h:147
int GetDiffPairViaGap() const
Definition: netclass.h:156
OPT< int > m_ViaDrill
via drill hole diameter
Definition: netclass.h:190
iterator end()
Definition: netclass.h:96
void SetClearance(int aClearance)
Definition: netclass.h:125
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:46
int GetLineStyle() const
Definition: netclass.h:171
int GetViaDrill() const
Definition: netclass.h:136
#define DECL_MAP_FOR_SWIG(TypeName, KeyType, ValueType)
Definition: macros_swig.h:52
void SetSchematicColor(COLOR4D aColor)
Definition: netclass.h:169
COLOR4D GetPcbColor() const
Definition: netclass.h:159
#define DECL_SET_FOR_SWIG(TypeName, MemberType)
Definition: macros_swig.h:54
int GetuViaDiameter() const
Definition: netclass.h:140
void SetuViaDiameter(int aSize)
Definition: netclass.h:141
int GetDiffPairWidth() const
Definition: netclass.h:148
NETCLASS * GetDefaultPtr() const
Definition: netclass.h:258
void SetBusWidth(int aWidth)
Definition: netclass.h:166
void SetDiffPairViaGap(int aSize)
Definition: netclass.h:157
bool HasuViaDiameter() const
Definition: netclass.h:139
const_iterator end() const
Definition: netclass.h:100
void Clear()
Empties the collection of members.
Definition: netclass.h:79
void Remove(iterator aName)
Remove NET aName from the collection of members.
Definition: netclass.h:105
int m_lineStyle
Definition: netclass.h:202
void Clear()
Destroy any contained NETCLASS instances except the default one, and clears any members from the defa...
Definition: netclass.h:228
void SetuViaDrill(int aSize)
Definition: netclass.h:145
int GetWireWidth() const
Definition: netclass.h:162
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
int GetClearance() const
Definition: netclass.h:124
wxString m_Description
what this NETCLASS is for.
Definition: netclass.h:180
wxString m_Name
Name of the net class.
Definition: netclass.h:179
void Remove(const wxString &aName)
Remove NET aName from the collection of members.
Definition: netclass.h:113
int GetViaDiameter() const
Definition: netclass.h:132
const_iterator begin() const
Definition: netclass.h:99
COLOR4D m_schematicColor
Definition: netclass.h:201
unsigned GetCount() const
Definition: netclass.h:245
int GetBusWidth() const
Definition: netclass.h:165
boost::optional< T > OPT
Definition: optional.h:7
const wxString & GetDescription() const
Definition: netclass.h:120
This file contains macros just for swig binding.
STRINGSET::const_iterator const_iterator
Definition: netclass.h:98
void SetViaDiameter(int aDia)
Definition: netclass.h:133
NETCLASSPTR GetDefault() const
Definition: netclass.h:253
int GetuViaDrill() const
Definition: netclass.h:144
#define DECL_SPTR_FOR_SWIG(TypeName, MemberType)
Definition: macros_swig.h:53
const_iterator begin() const
Definition: netclass.h:239
NETCLASS_MAP m_NetClasses
Definition: netclass.h:293
int m_wireWidth
Definition: netclass.h:199
bool HasTrackWidth() const
Definition: netclass.h:127
Container for design settings for a BOARD object.
void Add(const wxString &aNetname)
Adds aNetname to this NETCLASS if it is not already in this NETCLASS.
Definition: netclass.h:89
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98
bool HasViaDiameter() const
Definition: netclass.h:131