KiCad PCB EDA Suite
Loading...
Searching...
No Matches
net_settings.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) 2020 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Jon Evans <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef KICAD_NET_SETTINGS_H
23#define KICAD_NET_SETTINGS_H
24
25#include <vector>
26#include <set>
27#include <memory>
28#include <map>
29
30#include <netclass.h>
32#include <eda_pattern_match.h>
33
39{
40public:
41 NET_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath );
42
43 virtual ~NET_SETTINGS();
44
45 bool operator==( const NET_SETTINGS& aOther ) const;
46
47 bool operator!=( const NET_SETTINGS& aOther ) const { return !operator==( aOther ); }
48
51 void SetDefaultNetclass( std::shared_ptr<NETCLASS> netclass );
52
54 std::shared_ptr<NETCLASS> GetDefaultNetclass();
55
57 bool HasNetclass( const wxString& netclassName ) const;
58
61 void SetNetclass( const wxString& netclassName, std::shared_ptr<NETCLASS>& netclass );
62
65 void SetNetclasses( const std::map<wxString, std::shared_ptr<NETCLASS>>& netclasses );
66
68 const std::map<wxString, std::shared_ptr<NETCLASS>>& GetNetclasses() const;
69
71 // Note the full connectivity or board net synchronisation must be run before calling
72 // this, otherwise resolved netclasses may be missing
73 const std::map<wxString, std::shared_ptr<NETCLASS>>& GetCompositeNetclasses() const;
74
77 void ClearNetclasses();
78
80 const std::map<wxString, std::set<wxString>>& GetNetclassLabelAssignments() const;
81
84 void ClearNetclassLabelAssignments();
85
88 void ClearNetclassLabelAssignment( const wxString& netName );
89
92 void SetNetclassLabelAssignment( const wxString& netName,
93 const std::set<wxString>& netclasses );
94
97 void AppendNetclassLabelAssignment( const wxString& netName,
98 const std::set<wxString>& netclasses );
99
101 bool HasNetclassLabelAssignment( const wxString& netName ) const;
102
105 void SetNetclassPatternAssignment( const wxString& pattern, const wxString& netclass );
106
109 void SetNetclassPatternAssignments(
110 std::vector<std::pair<std::unique_ptr<EDA_COMBINED_MATCHER>, wxString>>&&
111 netclassPatterns );
112
114 std::vector<std::pair<std::unique_ptr<EDA_COMBINED_MATCHER>, wxString>>&
115 GetNetclassPatternAssignments();
116
118 void ClearNetclassPatternAssignments();
119
121 void ClearCacheForNet( const wxString& netName );
122
124 void ClearAllCaches();
125
128 void SetNetColorAssignment( const wxString& netName, const KIGFX::COLOR4D& color );
129
131 const std::map<wxString, KIGFX::COLOR4D>& GetNetColorAssignments() const;
132
135 void ClearNetColorAssignments();
136
138 bool HasEffectiveNetClass( const wxString& aNetName ) const;
139
142 std::shared_ptr<NETCLASS> GetCachedEffectiveNetClass( const wxString& aNetName ) const;
143
145 // If the effective netclass has not been computed, it will be created and cached.
146 std::shared_ptr<NETCLASS> GetEffectiveNetClass( const wxString& aNetName );
147
151 void RecomputeEffectiveNetclasses();
152
159 std::shared_ptr<NETCLASS> GetNetClassByName( const wxString& aNetName ) const;
160
171 static bool ParseBusVector( const wxString& aBus, wxString* aName,
172 std::vector<wxString>* aMemberList );
173
182 static bool ParseBusGroup( const wxString& aGroup, wxString* name,
183 std::vector<wxString>* aMemberList );
184
185private:
186 bool migrateSchema0to1();
187 bool migrateSchema1to2();
188 bool migrateSchema2to3();
189 bool migrateSchema3to4();
190
200 void makeEffectiveNetclass( std::shared_ptr<NETCLASS>& effectiveNetclass,
201 std::vector<NETCLASS*>& netclasses ) const;
202
205 bool addMissingDefaults( NETCLASS* nc ) const;
206
208 std::shared_ptr<NETCLASS> m_defaultNetClass;
209
211 std::map<wxString, std::shared_ptr<NETCLASS>> m_netClasses;
212
214 std::map<wxString, std::set<wxString>> m_netClassLabelAssignments;
215
217 std::vector<std::pair<std::unique_ptr<EDA_COMBINED_MATCHER>, wxString>>
219
221 // composite (multiple netclass assignment / missing defaults) netclasses
222 std::map<wxString, std::shared_ptr<NETCLASS>> m_compositeNetClasses;
223
229 // to the effective netclasses which contain them.
230 std::map<wxString, std::shared_ptr<NETCLASS>> m_impicitNetClasses;
231
233 std::map<wxString, std::shared_ptr<NETCLASS>> m_effectiveNetclassCache;
234
241 std::map<wxString, KIGFX::COLOR4D> m_netColorAssignments;
242
243 // TODO: Add diff pairs, bus information, etc.
244};
245
246#endif // KICAD_NET_SETTINGS_H
int color
Definition: DXF_plotter.cpp:60
const char * name
Definition: DXF_plotter.cpp:59
bool operator==(const wxAuiPaneInfo &aLhs, const wxAuiPaneInfo &aRhs)
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
NESTED_SETTINGS is a JSON_SETTINGS that lives inside a JSON_SETTINGS.
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:45
NET_SETTINGS stores various net-related settings in a project context.
Definition: net_settings.h:39
std::map< wxString, std::shared_ptr< NETCLASS > > m_compositeNetClasses
Map of netclass names to netclass definitions for.
Definition: net_settings.h:222
std::map< wxString, KIGFX::COLOR4D > m_netColorAssignments
A map of fully-qualified net names to colors used in the board context.
Definition: net_settings.h:241
std::shared_ptr< NETCLASS > m_defaultNetClass
The default netclass.
Definition: net_settings.h:208
std::map< wxString, std::shared_ptr< NETCLASS > > m_impicitNetClasses
Map of netclass names to netclass definitions for implicit netclasses.
Definition: net_settings.h:230
std::vector< std::pair< std::unique_ptr< EDA_COMBINED_MATCHER >, wxString > > m_netClassPatternAssignments
List of net class pattern assignments.
Definition: net_settings.h:218
std::map< wxString, std::shared_ptr< NETCLASS > > m_effectiveNetclassCache
Cache of nets to pattern-matched netclasses.
Definition: net_settings.h:233
std::map< wxString, std::shared_ptr< NETCLASS > > m_netClasses
Map of netclass names to netclass definitions.
Definition: net_settings.h:211
bool operator!=(const NET_SETTINGS &aOther) const
Definition: net_settings.h:47
std::map< wxString, std::set< wxString > > m_netClassLabelAssignments
Map of net names to resolved netclasses.
Definition: net_settings.h:214
Abstract pattern-matching tool and implementations.
#define KICOMMON_API
Definition: kicommon.h:28