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-2015 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 
72 {
73 public:
74  BOARD_NETLIST_UPDATER( PCB_EDIT_FRAME* aFrame, BOARD* aBoard );
76 
85  bool UpdateNetlist( NETLIST& aNetlist );
86 
87  // @todo: implement and move NETLIST::ReadPcbNetlist here
88  bool UpdateNetlist( const wxString& aNetlistFileName, const wxString& aCmpFileName );
89 
91  void SetReporter( REPORTER* aReporter )
92  {
93  m_reporter = aReporter;
94  }
95 
97  void SetDeleteSinglePadNets( bool aEnabled )
98  {
99  m_deleteSinglePadNets = aEnabled;
100  }
101 
103  void SetIsDryRun( bool aEnabled )
104  {
105  m_isDryRun = aEnabled;
106  }
107 
109  void SetReplaceFootprints( bool aEnabled )
110  {
111  m_replaceFootprints = aEnabled;
112  }
113 
115  void SetDeleteUnusedComponents( bool aEnabled )
116  {
117  m_deleteUnusedComponents = aEnabled;
118  }
119 
121  void SetLookupByTimestamp( bool aEnabled )
122  {
123  m_lookupByTimestamp = aEnabled;
124  }
125 
126  std::vector<MODULE*> GetAddedComponents() const
127  {
128  return m_addedComponents;
129  }
130 
131 private:
132  void cacheNetname( D_PAD* aPad, const wxString& aNetname );
133  wxString getNetname( D_PAD* aPad );
134 
136  MODULE* addNewComponent( COMPONENT* aComponent );
137  MODULE* replaceComponent( NETLIST& aNetlist, MODULE* aPcbComponent, COMPONENT* aNewComponent );
138  bool updateComponentParameters( MODULE* aPcbComponent, COMPONENT* aNewComponent );
139  bool updateComponentPadConnections( MODULE* aPcbComponent, COMPONENT* aNewComponent );
141  bool updateCopperZoneNets( NETLIST& aNetlist );
142  bool deleteUnusedComponents( NETLIST& aNetlist );
143  bool deleteSinglePadNets();
144  bool testConnectivity( NETLIST& aNetlist );
145 
150 
151  std::map< ZONE_CONTAINER*, std::vector<D_PAD*> > m_zoneConnectionsCache;
152  std::map< D_PAD*, wxString > m_padNets;
153  std::vector<MODULE*> m_addedComponents;
154  std::map<wxString, NETINFO_ITEM*> m_addedNets;
155 
161 
164 };
165 
166 #endif
MODULE * replaceComponent(NETLIST &aNetlist, MODULE *aPcbComponent, COMPONENT *aNewComponent)
void cacheNetname(D_PAD *aPad, const wxString &aNetname)
Class 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
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
Class REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:61
bool UpdateNetlist(NETLIST &aNetlist)
Function UpdateNetlist()
std::map< wxString, NETINFO_ITEM * > m_addedNets
Class NETLIST stores all of information read from a netlist along with the flags used to update the N...
Definition: pcb_netlist.h:214
wxString getNetname(D_PAD *aPad)
void SetReplaceFootprints(bool aEnabled)
Enables replacing footprints with new ones
void SetIsDryRun(bool aEnabled)
Enables dry run mode (just report, no changes to PCB)
std::map< D_PAD *, wxString > m_padNets
Class COMPONENT is used to store components and all of their related information found in a netlist...
Definition: pcb_netlist.h:83
bool updateComponentParameters(MODULE *aPcbComponent, COMPONENT *aNewComponent)
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:170
void SetDeleteUnusedComponents(bool aEnabled)
Enables removing unused components
Class 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)