KiCad PCB EDA Suite
backannotate.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) 2019 Alexander Shuklin <Jasuramme@gmail.com>
5  * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 
26 #ifndef BACKANNOTATE_H
27 #define BACKANNOTATE_H
28 
29 #include <deque>
30 #include <map>
31 #include <memory>
32 #include <sch_reference_list.h>
33 #include <template_fieldnames.h>
34 #include <wx/string.h>
35 
36 // Forward declarations
37 class REPORTER;
38 class SCH_SHEET_LIST;
39 class SCH_EDIT_FRAME;
40 
41 
56 {
57 public:
61  struct PCB_FP_DATA
62  {
63  PCB_FP_DATA( const wxString& aRef, const wxString& aFootprint, const wxString& aValue,
64  const std::map<wxString, wxString> aPinMap ) :
65  m_ref( aRef ),
66  m_footprint( aFootprint ),
67  m_value( aValue ),
68  m_pinMap( aPinMap )
69  {};
70 
71  wxString m_ref;
72  wxString m_footprint;
73  wxString m_value;
74  std::map<wxString, wxString> m_pinMap;
75  };
76 
78  using PCB_FOOTPRINTS_MAP = std::map<wxString, std::shared_ptr<PCB_FP_DATA>>;
79 
80  using CHANGELIST_ITEM = std::pair<SCH_REFERENCE, std::shared_ptr<PCB_FP_DATA>>;
81 
82  BACK_ANNOTATE( SCH_EDIT_FRAME* aFrame, REPORTER& aReporter, bool aRelinkFootprints,
83  bool aProcessFootprints, bool aProcessValues, bool aProcessReferences,
84  bool aProcessNetNames, bool aDryRun );
86 
93  bool FetchNetlistFromPCB( std::string& aNetlist );
94 
95  void PushNewLinksToPCB();
96 
103  bool BackAnnotateSymbols( const std::string& aNetlist );
104 
105 private:
112  void getPcbModulesFromString( const std::string& aPayload );
113 
115  void getChangeList();
116 
122  void checkForUnusedSymbols();
123 
127  void applyChangelist();
128 
129  void processNetNameChange( const wxString& aRef, SCH_PIN* aPin,
130  const SCH_CONNECTION* aConnection, const wxString& aOldName,
131  const wxString& aNewName );
132 
134 
140  bool m_dryRun;
141 
145  std::deque<CHANGELIST_ITEM> m_changelist;
147 
148  int m_changesCount; // Number of user-level changes
150 };
151 
152 #endif
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
BACK_ANNOTATE(SCH_EDIT_FRAME *aFrame, REPORTER &aReporter, bool aRelinkFootprints, bool aProcessFootprints, bool aProcessValues, bool aProcessReferences, bool aProcessNetNames, bool aDryRun)
SCH_EDIT_FRAME * m_frame
Definition: backannotate.h:146
PCB_FP_DATA(const wxString &aRef, const wxString &aFootprint, const wxString &aValue, const std::map< wxString, wxString > aPinMap)
Definition: backannotate.h:63
void PushNewLinksToPCB()
bool m_processNetNames
Definition: backannotate.h:139
bool m_processFootprints
Definition: backannotate.h:136
std::map< wxString, std::shared_ptr< PCB_FP_DATA > > PCB_FOOTPRINTS_MAP
Definition: backannotate.h:78
Schematic editor (Eeschema) main window.
bool m_processReferences
Definition: backannotate.h:138
void getPcbModulesFromString(const std::string &aPayload)
Parse netlist sent over KiWay express mail interface and fill m_pcbModules.
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:64
bool m_matchByReference
Definition: backannotate.h:135
std::map< wxString, wxString > m_pinMap
Definition: backannotate.h:74
bool BackAnnotateSymbols(const std::string &aNetlist)
Run back annotation algorithm.
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
void checkForUnusedSymbols()
Check if some symbols are not represented in PCB footprints and vice versa.
REPORTER & m_reporter
Definition: backannotate.h:133
bool m_processValues
Definition: backannotate.h:137
void processNetNameChange(const wxString &aRef, SCH_PIN *aPin, const SCH_CONNECTION *aConnection, const wxString &aOldName, const wxString &aNewName)
bool FetchNetlistFromPCB(std::string &aNetlist)
Get netlist from the Pcbnew.
std::map< wxString, SCH_REFERENCE_LIST > SCH_MULTI_UNIT_REFERENCE_MAP
Container to map reference designators for multi-unit parts.
std::pair< SCH_REFERENCE, std::shared_ptr< PCB_FP_DATA > > CHANGELIST_ITEM
Definition: backannotate.h:80
void getChangeList()
void applyChangelist()
Apply changelist to the schematic.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
Back annotation algorithm class used to receive, check, and apply a NETLIST from Pcbnew.
Definition: backannotate.h:55
SCH_REFERENCE_LIST m_refs
Definition: backannotate.h:143
std::deque< CHANGELIST_ITEM > m_changelist
Definition: backannotate.h:145
Container for Pcbnew footprint data.Map to hold NETLIST footprints data.
Definition: backannotate.h:61
PCB_FOOTPRINTS_MAP m_pcbFootprints
Definition: backannotate.h:142
SCH_MULTI_UNIT_REFERENCE_MAP m_multiUnitsRefs
Definition: backannotate.h:144