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 (C) 2021-2022 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
50 void SetDefaultNetclass( std::shared_ptr<NETCLASS> netclass );
51
53 std::shared_ptr<NETCLASS> GetDefaultNetclass();
54
56 bool HasNetclass( const wxString& netclassName ) const;
57
59 void SetNetclass( const wxString& netclassName, std::shared_ptr<NETCLASS>& netclass );
60
62 void SetNetclasses( const std::map<wxString, std::shared_ptr<NETCLASS>>& netclasses );
63
65 const std::map<wxString, std::shared_ptr<NETCLASS>>& GetNetclasses() const;
66
68 // Note the full connectivity or board net synchronisation must be run before calling
69 // this, otherwise resolved netclasses may be missing
70 const std::map<wxString, std::shared_ptr<NETCLASS>>& GetCompositeNetclasses() const;
71
73 void ClearNetclasses();
74
76 const std::map<wxString, std::set<wxString>>& GetNetclassLabelAssignments() const;
77
79 void ClearNetclassLabelAssignments();
80
82 void ClearNetclassLabelAssignment( const wxString& netName );
83
85 void SetNetclassLabelAssignment( const wxString& netName,
86 const std::set<wxString>& netclasses );
87
89 void AppendNetclassLabelAssignment( const wxString& netName,
90 const std::set<wxString>& netclasses );
91
93 bool HasNetclassLabelAssignment( const wxString& netName ) const;
94
96 void SetNetclassPatternAssignment( const wxString& pattern, const wxString& netclass );
97
99 void SetNetclassPatternAssignments(
100 std::vector<std::pair<std::unique_ptr<EDA_COMBINED_MATCHER>, wxString>>&&
101 netclassPatterns );
102
104 std::vector<std::pair<std::unique_ptr<EDA_COMBINED_MATCHER>, wxString>>&
105 GetNetclassPatternAssignments();
106
108 void ClearNetclassPatternAssignments();
109
111 void ClearCacheForNet( const wxString& netName );
112
113 // @brief Clears the effective netclass cache for all nets
114 void ClearAllCaches();
115
117 void SetNetColorAssignment( const wxString& netName, const KIGFX::COLOR4D& color );
118
120 const std::map<wxString, KIGFX::COLOR4D>& GetNetColorAssignments() const;
121
123 void ClearNetColorAssignments();
124
126 bool HasEffectiveNetClass( const wxString& aNetName ) const;
127
130 std::shared_ptr<NETCLASS> GetCachedEffectiveNetClass( const wxString& aNetName ) const;
131
133 // If the effective netclass has not been computed, it will be created and cached.
134 std::shared_ptr<NETCLASS> GetEffectiveNetClass( const wxString& aNetName );
135
137 // Called when a value of a user-defined netclass changes, but the whole netclass list is not
138 // being recomputed.
139 void RecomputeEffectiveNetclasses();
140
147 std::shared_ptr<NETCLASS> GetNetClassByName( const wxString& aNetName ) const;
148
159 static bool ParseBusVector( const wxString& aBus, wxString* aName,
160 std::vector<wxString>* aMemberList );
161
170 static bool ParseBusGroup( const wxString& aGroup, wxString* name,
171 std::vector<wxString>* aMemberList );
172
173private:
174 bool migrateSchema0to1();
175 bool migrateSchema1to2();
176 bool migrateSchema2to3();
177 bool migrateSchema3to4();
178
188 void makeEffectiveNetclass( std::shared_ptr<NETCLASS>& effectiveNetclass,
189 std::vector<NETCLASS*>& netclasses ) const;
190
193 bool addMissingDefaults( NETCLASS* nc ) const;
194
196 std::shared_ptr<NETCLASS> m_defaultNetClass;
197
199 std::map<wxString, std::shared_ptr<NETCLASS>> m_netClasses;
200
202 std::map<wxString, std::set<wxString>> m_netClassLabelAssignments;
203
205 std::vector<std::pair<std::unique_ptr<EDA_COMBINED_MATCHER>, wxString>>
207
209 // composite (multiple netclass assignment / missing defaults) netclasses
210 std::map<wxString, std::shared_ptr<NETCLASS>> m_compositeNetClasses;
211
217 // to the effective netclasses which contain them.
218 std::map<wxString, std::shared_ptr<NETCLASS>> m_impicitNetClasses;
219
221 std::map<wxString, std::shared_ptr<NETCLASS>> m_effectiveNetclassCache;
222
229 std::map<wxString, KIGFX::COLOR4D> m_netColorAssignments;
230
231 // TODO: Add diff pairs, bus information, etc.
232};
233
234#endif // KICAD_NET_SETTINGS_H
int color
Definition: DXF_plotter.cpp:58
const char * name
Definition: DXF_plotter.cpp:57
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:44
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:210
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:229
std::shared_ptr< NETCLASS > m_defaultNetClass
The default netclass.
Definition: net_settings.h:196
std::map< wxString, std::shared_ptr< NETCLASS > > m_impicitNetClasses
Map of netclass names to netclass definitions for implicit netclasses.
Definition: net_settings.h:218
std::vector< std::pair< std::unique_ptr< EDA_COMBINED_MATCHER >, wxString > > m_netClassPatternAssignments
List of net class pattern assignments.
Definition: net_settings.h:206
std::map< wxString, std::shared_ptr< NETCLASS > > m_effectiveNetclassCache
Cache of nets to pattern-matched netclasses.
Definition: net_settings.h:221
std::map< wxString, std::shared_ptr< NETCLASS > > m_netClasses
Map of netclass names to netclass definitions.
Definition: net_settings.h:199
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:202
Abstract pattern-matching tool and implementations.
#define KICOMMON_API
Definition: kicommon.h:28