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-2019 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 MODULE;
42 class PCB_EDIT_FRAME;
43 
44 #include <board_commit.h>
45 
73 {
74 public:
75  BOARD_NETLIST_UPDATER( PCB_EDIT_FRAME* aFrame, BOARD* aBoard );
77 
86  bool UpdateNetlist( NETLIST& aNetlist );
87 
89  void SetReporter( REPORTER* aReporter )
90  {
91  m_reporter = aReporter;
92  }
93 
95  void SetDeleteSinglePadNets( bool aEnabled )
96  {
97  m_deleteSinglePadNets = aEnabled;
98  }
99 
102  void SetWarnPadNoNetInNetlist( bool aEnabled )
103  {
104  m_warnForNoNetPads = aEnabled;
105  }
106 
108  void SetIsDryRun( bool aEnabled )
109  {
110  m_isDryRun = aEnabled;
111  }
112 
114  void SetReplaceFootprints( bool aEnabled )
115  {
116  m_replaceFootprints = aEnabled;
117  }
118 
120  void SetDeleteUnusedComponents( bool aEnabled )
121  {
122  m_deleteUnusedComponents = aEnabled;
123  }
124 
126  void SetLookupByTimestamp( bool aEnabled )
127  {
128  m_lookupByTimestamp = aEnabled;
129  }
130 
131  std::vector<MODULE*> GetAddedComponents() const
132  {
133  return m_addedComponents;
134  }
135 
136 private:
137  void cacheNetname( D_PAD* aPad, const wxString& aNetname );
138  wxString getNetname( D_PAD* aPad );
139 
140  void cachePinFunction( D_PAD* aPad, const wxString& aPinFunction );
141  wxString getPinFunction( D_PAD* aPad );
142 
144  MODULE* addNewComponent( COMPONENT* aComponent );
145  MODULE* replaceComponent( NETLIST& aNetlist, MODULE* aPcbComponent, COMPONENT* aNewComponent );
146  bool updateComponentParameters( MODULE* aPcbComponent, COMPONENT* aNewComponent );
147  bool updateComponentPadConnections( MODULE* aPcbComponent, COMPONENT* aNewComponent );
149  bool updateCopperZoneNets( NETLIST& aNetlist );
150  bool deleteUnusedComponents( NETLIST& aNetlist );
151  bool deleteSinglePadNets();
152  bool testConnectivity( NETLIST& aNetlist );
153 
158 
159  std::map< ZONE_CONTAINER*, std::vector<D_PAD*> > m_zoneConnectionsCache;
160  std::map< wxString, wxString> m_oldToNewNets;
161  std::map< D_PAD*, wxString > m_padNets;
162  std::map< D_PAD*, wxString > m_padPinFunctions;
163  std::vector<MODULE*> m_addedComponents;
164  std::map<wxString, NETINFO_ITEM*> m_addedNets;
165 
171  bool m_warnForNoNetPads; //Warn if a connectable pad has no net in netlist (not found).
172 
175  int m_newFootprintsCount; // the count of new footprints
176  // either really new or replaced by new fp.
177 };
178 
179 #endif
MODULE * replaceComponent(NETLIST &aNetlist, MODULE *aPcbComponent, COMPONENT *aNewComponent)
void cacheNetname(D_PAD *aPad, const wxString &aNetname)
BOARD_NETLIST_UPDATER updates the BOARD with a new netlist.
void SetDeleteSinglePadNets(bool aEnabled)
Enables "delete single pad nets" option
std::map< ZONE_CONTAINER *, std::vector< D_PAD * > > m_zoneConnectionsCache
void SetWarnPadNoNetInNetlist(bool aEnabled)
Enables warning option if a connectable pad is not found in netlist connectable = pad with a name and...
std::vector< MODULE * > GetAddedComponents() const
bool updateComponentPadConnections(MODULE *aPcbComponent, COMPONENT *aNewComponent)
void SetReporter(REPORTER *aReporter)
Sets the reporter object
bool updateCopperZoneNets(NETLIST &aNetlist)
bool testConnectivity(NETLIST &aNetlist)
void SetLookupByTimestamp(bool aEnabled)
Enables component lookup by timestamp instead of reference
REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:64
bool UpdateNetlist(NETLIST &aNetlist)
Function UpdateNetlist()
std::map< wxString, NETINFO_ITEM * > m_addedNets
NETLIST stores all of information read from a netlist along with the flags used to update the NETLIST...
Definition: pcb_netlist.h:212
wxString getNetname(D_PAD *aPad)
wxString getPinFunction(D_PAD *aPad)
void SetReplaceFootprints(bool aEnabled)
Enables replacing footprints with new ones
std::map< wxString, wxString > m_oldToNewNets
void SetIsDryRun(bool aEnabled)
Enables dry run mode (just report, no changes to PCB)
std::map< D_PAD *, wxString > m_padNets
COMPONENT is used to store components and all of their related information found in a netlist.
Definition: pcb_netlist.h:80
void cachePinFunction(D_PAD *aPad, const wxString &aPinFunction)
bool updateComponentParameters(MODULE *aPcbComponent, COMPONENT *aNewComponent)
std::map< D_PAD *, wxString > m_padPinFunctions
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
void SetDeleteUnusedComponents(bool aEnabled)
Enables removing unused components
PCB_EDIT_FRAME is the main frame for Pcbnew.
std::vector< MODULE * > m_addedComponents
BOARD_NETLIST_UPDATER(PCB_EDIT_FRAME *aFrame, BOARD *aBoard)
bool deleteUnusedComponents(NETLIST &aNetlist)
MODULE * addNewComponent(COMPONENT *aComponent)