KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_differ.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/gpl-3.0.html
19 */
20
21#ifndef PCB_DIFFER_H
22#define PCB_DIFFER_H
23
26
27#include <wx/string.h>
28
29
30class BOARD;
31class BOARD_ITEM;
32class EDA_ITEM;
33class FOOTPRINT;
34
35
36namespace KICAD_DIFF
37{
38
42KIID PcbDiffItemId( const EDA_ITEM& aItem );
43
46BOARD_ITEM* FindPcbDiffItem( const BOARD* aBoard, const KIID& aId );
47
62{
63public:
64 PCB_DIFFER( const BOARD* aBefore, const BOARD* aAfter, const wxString& aPath = wxEmptyString );
65 ~PCB_DIFFER() override;
66
67 DOCUMENT_DIFF Diff() override;
68
71 const BOARD* Before() const { return m_before; }
72 const BOARD* After() const { return m_after; }
73
74private:
78 std::vector<PROPERTY_DELTA> diffProperties( const BOARD_ITEM* aBefore, const BOARD_ITEM* aAfter ) const;
79
81 ITEM_DESCRIPTOR makeDescriptor( const BOARD_ITEM* aItem ) const;
82
84 std::vector<ITEM_CHANGE> diffFootprintChildren( const FOOTPRINT* aBefore, const FOOTPRINT* aAfter ) const;
85
87 static void sortChanges( std::vector<ITEM_CHANGE>& aChanges );
88
90 static wxString itemTypeName( const BOARD_ITEM* aItem );
91
93 static std::optional<wxString> itemRefdes( const BOARD_ITEM* aItem );
94
95private:
97 const BOARD* m_after;
98 wxString m_path;
99};
100
101} // namespace KICAD_DIFF
102
103#endif // PCB_DIFFER_H
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:410
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
const BOARD * m_after
Definition pcb_differ.h:97
static void sortChanges(std::vector< ITEM_CHANGE > &aChanges)
Stable, deterministic sort of ITEM_CHANGEs (by id, then typeName, then kind).
const BOARD * m_before
Definition pcb_differ.h:96
PCB_DIFFER(const BOARD *aBefore, const BOARD *aAfter, const wxString &aPath=wxEmptyString)
const BOARD * Before() const
Expose the underlying boards for callers that want to drive their own walk (e.g., the merge applier r...
Definition pcb_differ.h:71
std::vector< ITEM_CHANGE > diffFootprintChildren(const FOOTPRINT *aBefore, const FOOTPRINT *aAfter) const
Construct a child-level diff for nested items inside a footprint pair.
DOCUMENT_DIFF Diff() override
Produce a DOCUMENT_DIFF of the inputs the concrete differ was constructed with.
static std::optional< wxString > itemRefdes(const BOARD_ITEM *aItem)
Extract a presentation label: footprint refdes, or routing net name for tracks/vias.
std::vector< PROPERTY_DELTA > diffProperties(const BOARD_ITEM *aBefore, const BOARD_ITEM *aAfter) const
Compute property deltas between two items of the same dynamic type.
static wxString itemTypeName(const BOARD_ITEM *aItem)
Convert the dynamic class string for an item into the type name used in diffs.
const BOARD * After() const
Definition pcb_differ.h:72
ITEM_DESCRIPTOR makeDescriptor(const BOARD_ITEM *aItem) const
Build the ITEM_DESCRIPTOR for the reconciler from a BOARD_ITEM.
BOARD_ITEM * FindPcbDiffItem(const BOARD *aBoard, const KIID &aId)
Resolve an actual UUID or a footprint field's diff ID on a board.
KIID PcbDiffItemId(const EDA_ITEM &aItem)
Fields match by parent footprint and untranslated name, including after a library refresh.
The full set of changes between two parsed documents of one type.
Descriptor used by the identity reconciler to compare items across two documents.