KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 <[email protected]>
5 * Copyright The 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 <set>
32#include <memory>
33#include <sch_reference_list.h>
34#include <template_fieldnames.h>
35#include <wx/string.h>
36
37// Forward declarations
38class REPORTER;
39class SCH_SHEET_LIST;
40class SCH_EDIT_FRAME;
41class SCH_COMMIT;
42
57{
58public:
63 {
64 PCB_FP_DATA( const wxString& aRef, const wxString& aFootprint, const wxString& aValue,
65 bool aDNP, bool aExcludeFromBOM,
66 const std::map<wxString, wxString>& aPinMap,
67 const std::map<wxString, wxString>& aFieldsMap ) :
68 m_ref( aRef ),
69 m_footprint( aFootprint ),
70 m_value( aValue ),
71 m_DNP( aDNP ),
72 m_excludeFromBOM( aExcludeFromBOM ),
73 m_pinMap( aPinMap ),
74 m_fieldsMap( aFieldsMap )
75 {}
76
77 wxString m_ref;
78 wxString m_footprint;
79 wxString m_value;
80 bool m_DNP;
82 std::map<wxString, wxString> m_pinMap;
83 std::map<wxString, wxString> m_fieldsMap;
84 };
85
87 using PCB_FOOTPRINTS_MAP = std::map<wxString, std::shared_ptr<PCB_FP_DATA>>;
88
89 using CHANGELIST_ITEM = std::pair<SCH_REFERENCE, std::shared_ptr<PCB_FP_DATA>>;
90
91 BACK_ANNOTATE( SCH_EDIT_FRAME* aFrame, REPORTER& aReporter, bool aRelinkFootprints,
92 bool aProcessFootprints, bool aProcessValues, bool aProcessReferences,
93 bool aProcessNetNames, bool aProcessAttributes, bool aProcessOtherFields,
94 bool aPreferUnitSwaps, bool aPreferPinSwaps, bool aDryRun );
96
103 bool FetchNetlistFromPCB( std::string& aNetlist );
104
105 void PushNewLinksToPCB();
106
113 bool BackAnnotateSymbols( const std::string& aNetlist );
114
115private:
122 void getPcbModulesFromString( const std::string& aPayload );
123
125 void getChangeList();
126
133
137 void applyChangelist();
138
142 std::set<wxString> applyPinSwaps( SCH_SYMBOL* aSymbol, const SCH_REFERENCE& aReference, const PCB_FP_DATA& aFpData,
143 SCH_COMMIT* aCommit );
144
145 void processNetNameChange( SCH_COMMIT* aCommit, const wxString& aRef, SCH_PIN* aPin,
146 const SCH_CONNECTION* aConnection, const wxString& aOldName,
147 const wxString& aNewName );
148
149
151
162
166 std::deque<CHANGELIST_ITEM> m_changelist;
168
169 int m_changesCount; // Number of user-level changes
170};
171
172#endif
bool BackAnnotateSymbols(const std::string &aNetlist)
Run back annotation algorithm.
SCH_MULTI_UNIT_REFERENCE_MAP m_multiUnitsRefs
std::deque< CHANGELIST_ITEM > m_changelist
std::pair< SCH_REFERENCE, std::shared_ptr< PCB_FP_DATA > > CHANGELIST_ITEM
bool m_processReferences
bool m_processFootprints
bool m_processOtherFields
void getPcbModulesFromString(const std::string &aPayload)
Parse netlist sent over KiWay express mail interface and fill m_pcbModules.
SCH_EDIT_FRAME * m_frame
void checkForUnusedSymbols()
Check if some symbols are not represented in PCB footprints and vice versa.
SCH_REFERENCE_LIST m_refs
bool FetchNetlistFromPCB(std::string &aNetlist)
Get netlist from the Pcbnew.
PCB_FOOTPRINTS_MAP m_pcbFootprints
std::map< wxString, std::shared_ptr< PCB_FP_DATA > > PCB_FOOTPRINTS_MAP
void processNetNameChange(SCH_COMMIT *aCommit, const wxString &aRef, SCH_PIN *aPin, const SCH_CONNECTION *aConnection, const wxString &aOldName, const wxString &aNewName)
REPORTER & m_reporter
bool m_processAttributes
BACK_ANNOTATE(SCH_EDIT_FRAME *aFrame, REPORTER &aReporter, bool aRelinkFootprints, bool aProcessFootprints, bool aProcessValues, bool aProcessReferences, bool aProcessNetNames, bool aProcessAttributes, bool aProcessOtherFields, bool aPreferUnitSwaps, bool aPreferPinSwaps, bool aDryRun)
std::set< wxString > applyPinSwaps(SCH_SYMBOL *aSymbol, const SCH_REFERENCE &aReference, const PCB_FP_DATA &aFpData, SCH_COMMIT *aCommit)
Handle footprint pad net swaps with symbol pin swaps where possible.
bool m_matchByReference
void PushNewLinksToPCB()
void applyChangelist()
Apply changelist to the schematic.
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
Schematic editor (Eeschema) main window.
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
A helper to define a symbol's reference designator in a schematic.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Schematic symbol object.
Definition sch_symbol.h:75
std::map< wxString, SCH_REFERENCE_LIST > SCH_MULTI_UNIT_REFERENCE_MAP
Container to map reference designators for multi-unit parts.
Container for Pcbnew footprint data.Map to hold NETLIST footprints data.
std::map< wxString, wxString > m_pinMap
std::map< wxString, wxString > m_fieldsMap
PCB_FP_DATA(const wxString &aRef, const wxString &aFootprint, const wxString &aValue, bool aDNP, bool aExcludeFromBOM, const std::map< wxString, wxString > &aPinMap, const std::map< wxString, wxString > &aFieldsMap)