KiCad PCB EDA Suite
board_netlist_updater.h
Go to the documentation of this file.
1 
6 /*
7  * This program source code file is part of KiCad, a free EDA CAD application.
8  *
9  * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
10  * Copyright (C) 2015 CERN
11  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
12  * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
13  *
14  * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
15  *
16  * This program is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU General Public License
18  * as published by the Free Software Foundation; either version 2
19  * of the License, or (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, you may find one here:
28  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
29  * or you may search the http://www.gnu.org website for the version 2 license,
30  * or you may write to the Free Software Foundation, Inc.,
31  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
32  */
33 
34 #ifndef __BOARD_NETLIST_UPDATER_H
35 #define __BOARD_NETLIST_UPDATER_H
36 
37 class BOARD;
38 class REPORTER;
39 class NETLIST;
40 class COMPONENT;
41 class FOOTPRINT;
42 class PCB_EDIT_FRAME;
43 
44 #include <board_commit.h>
45 
72 {
73 public:
74  BOARD_NETLIST_UPDATER( PCB_EDIT_FRAME* aFrame, BOARD* aBoard );
76 
85  bool UpdateNetlist( NETLIST& aNetlist );
86 
88  void SetReporter( REPORTER* aReporter )
89  {
90  m_reporter = aReporter;
91  }
92 
94  void SetDeleteSinglePadNets( bool aEnabled )
95  {
96  m_deleteSinglePadNets = aEnabled;
97  }
98 
101  void SetWarnPadNoNetInNetlist( bool aEnabled )
102  {
103  m_warnForNoNetPads = aEnabled;
104  }
105 
107  void SetIsDryRun( bool aEnabled )
108  {
109  m_isDryRun = aEnabled;
110  }
111 
113  void SetReplaceFootprints( bool aEnabled )
114  {
115  m_replaceFootprints = aEnabled;
116  }
117 
119  void SetDeleteUnusedComponents( bool aEnabled )
120  {
121  m_deleteUnusedComponents = aEnabled;
122  }
123 
125  void SetLookupByTimestamp( bool aEnabled )
126  {
127  m_lookupByTimestamp = aEnabled;
128  }
129 
130  std::vector<FOOTPRINT*> GetAddedComponents() const
131  {
132  return m_addedComponents;
133  }
134 
135 private:
136  void cacheNetname( PAD* aPad, const wxString& aNetname );
137  wxString getNetname( PAD* aPad );
138 
139  void cachePinFunction( PAD* aPad, const wxString& aPinFunction );
140  wxString getPinFunction( PAD* aPad );
141 
143 
144  FOOTPRINT* addNewComponent( COMPONENT* aComponent );
145 
146  FOOTPRINT* replaceComponent( NETLIST& aNetlist, FOOTPRINT* aPcbComponent,
147  COMPONENT* aNewComponent );
148 
149  bool updateFootprintParameters( FOOTPRINT* aPcbFootprint, COMPONENT* aNetlistComponent );
150 
151  bool updateComponentPadConnections( FOOTPRINT* aFootprint, COMPONENT* aNewComponent );
152 
154 
155  bool updateCopperZoneNets( NETLIST& aNetlist );
156 
157  bool deleteUnusedComponents( NETLIST& aNetlist );
158 
159  bool deleteSinglePadNets();
160 
161  bool testConnectivity( NETLIST& aNetlist, std::map<COMPONENT*, FOOTPRINT*>& aFootprintMap );
162 
167 
168  std::map<ZONE*, std::vector<PAD*>> m_zoneConnectionsCache;
169  std::map<wxString, wxString> m_oldToNewNets;
170  std::map<PAD*, wxString> m_padNets;
171  std::map<PAD*, wxString> m_padPinFunctions;
172  std::vector<FOOTPRINT*> m_addedComponents;
173  std::map<wxString, NETINFO_ITEM*> m_addedNets;
174 
180  bool m_warnForNoNetPads; // Warn if a connectable pad has no net in netlist (not found).
181 
184  int m_newFootprintsCount; // the count of new footprints
185  // either really new or replaced by new fp.
186 };
187 
188 #endif
wxString getNetname(PAD *aPad)
Update the BOARD with a new netlist.
void SetDeleteSinglePadNets(bool aEnabled)
Enable warning option if a connectable pad is not found in netlist connectable = pad with a name and ...
void SetWarnPadNoNetInNetlist(bool aEnabled)
Enable dry run mode (just report, no changes to PCB).
void SetReporter(REPORTER *aReporter)
Enable "delete single pad nets" option.
std::map< wxString, wxString > m_oldToNewNets
bool updateCopperZoneNets(NETLIST &aNetlist)
void cachePinFunction(PAD *aPad, const wxString &aPinFunction)
void SetLookupByTimestamp(bool aEnabled)
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:64
bool UpdateNetlist(NETLIST &aNetlist)
Update the board's components according to the new netlist.
std::map< wxString, NETINFO_ITEM * > m_addedNets
bool updateComponentPadConnections(FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
wxString getPinFunction(PAD *aPad)
FOOTPRINT * addNewComponent(COMPONENT *aComponent)
NETLIST stores all of information read from a netlist along with the flags used to update the NETLIST...
Definition: pcb_netlist.h:207
std::vector< FOOTPRINT * > m_addedComponents
std::map< ZONE *, std::vector< PAD * > > m_zoneConnectionsCache
void SetReplaceFootprints(bool aEnabled)
Enable removing unused components.
FOOTPRINT * replaceComponent(NETLIST &aNetlist, FOOTPRINT *aPcbComponent, COMPONENT *aNewComponent)
void SetIsDryRun(bool aEnabled)
Enable replacing footprints with new ones.
COMPONENT is used to store components and all of their related information found in a netlist.
Definition: pcb_netlist.h:85
bool updateFootprintParameters(FOOTPRINT *aPcbFootprint, COMPONENT *aNetlistComponent)
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
void SetDeleteUnusedComponents(bool aEnabled)
Enable component lookup by timestamp instead of reference.
The main frame for Pcbnew.
std::map< PAD *, wxString > m_padNets
std::vector< FOOTPRINT * > GetAddedComponents() const
Definition: pad.h:60
bool testConnectivity(NETLIST &aNetlist, std::map< COMPONENT *, FOOTPRINT * > &aFootprintMap)
BOARD_NETLIST_UPDATER(PCB_EDIT_FRAME *aFrame, BOARD *aBoard)
void cacheNetname(PAD *aPad, const wxString &aNetname)
std::map< PAD *, wxString > m_padPinFunctions
bool deleteUnusedComponents(NETLIST &aNetlist)