KiCad PCB EDA Suite
Loading...
Searching...
No Matches
board_netlist_updater.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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2015 CERN
6 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
7 * Copyright (C) 2011 Wayne Stambaugh <[email protected]>
8 *
9 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
25#ifndef BOARD_NETLIST_UPDATER_H
26#define BOARD_NETLIST_UPDATER_H
27
28class BOARD;
29class REPORTER;
30class NETLIST;
31class COMPONENT;
32class FOOTPRINT;
33class LIB_ID;
34class NETINFO_ITEM;
35class PAD;
36class PCB_EDIT_FRAME;
37class PCB_GROUP;
38class PCBNEW_SETTINGS;
39class TOOL_MANAGER;
40
41#include <board_commit.h>
42
68{
69public:
73 BOARD_NETLIST_UPDATER( PCB_EDIT_FRAME* aFrame, BOARD* aBoard );
74
78 BOARD_NETLIST_UPDATER( TOOL_MANAGER* aToolManager, BOARD* aBoard );
80
89 bool UpdateNetlist( NETLIST& aNetlist );
90
98 static bool fpidsEquivalent( const LIB_ID& aBoardFpid, const LIB_ID& aSchematicFpid );
99
100 void SetReporter( REPORTER* aReporter ) { m_reporter = aReporter; }
101
103 void SetIsDryRun( bool aEnabled ) { m_isDryRun = aEnabled; }
104
105 void SetReplaceFootprints( bool aEnabled ) { m_replaceFootprints = aEnabled; }
106
107 void SetTransferGroups( bool aEnabled ) { m_transferGroups = aEnabled; }
108
109 void SetApplyDesignBlockLayouts( bool aEnabled ) { m_applyDesignBlockLayouts = aEnabled; }
110
111 void SetOverrideLocks( bool aOverride ) { m_overrideLocks = aOverride; }
112
113 void SetDeleteUnusedFootprints( bool aEnabled ) { m_deleteUnusedFootprints = aEnabled; }
114
115 void SetLookupByTimestamp( bool aEnabled ) { m_lookupByTimestamp = aEnabled; }
116
117 void SetUpdateFields( bool aEnabled ) { m_updateFields = aEnabled; }
118
119 void SetRemoveExtraFields( bool aEnabled ) { m_removeExtraFields = aEnabled; }
120
121 std::vector<FOOTPRINT*> GetAddedFootprints() const { return m_addedFootprints; }
122
123 std::vector<PCB_GROUP*> GetAddedGroups() const { return m_addedGroups; }
124
125 int GetErrorCount() const { return m_errorCount; }
126
127 int GetWarningCount() const { return m_warningCount; }
128
130
138 static void ApplyChainAssignments( BOARD* aBoard, const NETLIST& aNetlist, REPORTER* aReporter,
139 bool aDryRun );
140
141private:
142 void cacheNetname( PAD* aPad, const wxString& aNetname );
143 wxString getNetname( PAD* aPad );
144
145 void cachePinFunction( PAD* aPad, const wxString& aPinFunction );
146 wxString getPinFunction( PAD* aPad );
147
149
150 FOOTPRINT* addNewFootprint( COMPONENT* aComponent );
151 FOOTPRINT* addNewFootprint( COMPONENT* aComponent, const LIB_ID& aFootprintId );
152
153 FOOTPRINT* replaceFootprint( NETLIST& aNetlist, FOOTPRINT* aFootprint,
154 COMPONENT* aNewComponent );
155
156 bool updateFootprintParameters( FOOTPRINT* aFootprint, COMPONENT* aNetlistComponent );
157
158 bool updateFootprintGroup( FOOTPRINT* aPcbFootprint, COMPONENT* aNetlistComponent );
159
160 bool updateComponentPadConnections( FOOTPRINT* aFootprint, COMPONENT* aNewComponent );
161
162 bool updateComponentClass( FOOTPRINT* aFootprint, COMPONENT* aNewComponent );
163
164 bool updateComponentUnits( FOOTPRINT* aFootprint, COMPONENT* aNewComponent );
165
166 void applyComponentVariants( COMPONENT* aComponent,
167 const std::vector<FOOTPRINT*>& aFootprints,
168 const LIB_ID& aBaseFpid );
169
171
172 bool updateCopperZoneNets( NETLIST& aNetlist );
173
174 bool updateGroups( NETLIST& aNetlist );
175
176 bool testConnectivity( NETLIST& aNetlist, std::map<COMPONENT*, FOOTPRINT*>& aFootprintMap );
177
183
184 std::map<ZONE*, std::vector<PAD*>> m_zoneConnectionsCache;
185 std::map<wxString, wxString> m_oldToNewNets;
186 std::map<PAD*, wxString> m_padNets;
187 std::map<PAD*, wxString> m_padPinFunctions;
188 std::vector<FOOTPRINT*> m_addedFootprints;
189 std::vector<PCB_GROUP*> m_addedGroups;
190 std::map<wxString, NETINFO_ITEM*> m_addedNets;
191 std::set<wxString> m_schematicNetNames;
192
194 bool m_isDryRun = false;
196 bool m_transferGroups = false; // copy component group associations from schematic to PCB
199 bool m_overrideLocks = false;
200 bool m_updateFields = false;
202
205 int m_newFootprintsCount = 0; // the count of new footprints
206 // either really new or replaced by new fp.
207};
208
209#endif
std::map< PAD *, wxString > m_padNets
void SetRemoveExtraFields(bool aEnabled)
void cacheNetname(PAD *aPad, const wxString &aNetname)
void SetReporter(REPORTER *aReporter)
Enable dry run mode (just report, no changes to PCB).
bool UpdateNetlist(NETLIST &aNetlist)
Update the board's components according to the new netlist.
wxString getPinFunction(PAD *aPad)
std::vector< FOOTPRINT * > m_addedFootprints
bool updateFootprintParameters(FOOTPRINT *aFootprint, COMPONENT *aNetlistComponent)
void SetIsDryRun(bool aEnabled)
void SetDeleteUnusedFootprints(bool aEnabled)
std::map< wxString, wxString > m_oldToNewNets
static void ApplyChainAssignments(BOARD *aBoard, const NETLIST &aNetlist, REPORTER *aReporter, bool aDryRun)
Apply the netlist's chain assignments to every NETINFO_ITEM on the board.
bool updateFootprintGroup(FOOTPRINT *aPcbFootprint, COMPONENT *aNetlistComponent)
static bool fpidsEquivalent(const LIB_ID &aBoardFpid, const LIB_ID &aSchematicFpid)
Compare a board footprint ID against a schematic-derived footprint ID, ignoring the library nickname ...
void SetOverrideLocks(bool aOverride)
std::map< wxString, NETINFO_ITEM * > m_addedNets
std::vector< PCB_GROUP * > GetAddedGroups() const
void SetApplyDesignBlockLayouts(bool aEnabled)
std::vector< PCB_GROUP * > m_addedGroups
bool testConnectivity(NETLIST &aNetlist, std::map< COMPONENT *, FOOTPRINT * > &aFootprintMap)
void SetReplaceFootprints(bool aEnabled)
bool updateCopperZoneNets(NETLIST &aNetlist)
void cachePinFunction(PAD *aPad, const wxString &aPinFunction)
bool updateGroups(NETLIST &aNetlist)
BOARD_NETLIST_UPDATER(PCB_EDIT_FRAME *aFrame, BOARD *aBoard)
Construct an updater for interactive use from the board editor.
bool updateComponentClass(FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
bool updateComponentPadConnections(FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
std::map< PAD *, wxString > m_padPinFunctions
void applyComponentVariants(COMPONENT *aComponent, const std::vector< FOOTPRINT * > &aFootprints, const LIB_ID &aBaseFpid)
std::map< ZONE *, std::vector< PAD * > > m_zoneConnectionsCache
FOOTPRINT * replaceFootprint(NETLIST &aNetlist, FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
void SetLookupByTimestamp(bool aEnabled)
void SetUpdateFields(bool aEnabled)
void SetTransferGroups(bool aEnabled)
bool updateComponentUnits(FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
FOOTPRINT * addNewFootprint(COMPONENT *aComponent)
std::set< wxString > m_schematicNetNames
std::vector< FOOTPRINT * > GetAddedFootprints() const
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
Store all of the related component information found in a netlist.
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
Handle the data for a net.
Definition netinfo.h:46
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition pad.h:61
The main frame for Pcbnew.
A set of BOARD_ITEMs (i.e., without duplicates).
Definition pcb_group.h:49
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:71
Master controller class:
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683