|
KiCad PCB EDA Suite
|
Diff two already-parsed BOARDs and produce a DOCUMENT_DIFF. More...
#include <pcb_differ.h>
Public Member Functions | |
| PCB_DIFFER (const BOARD *aBefore, const BOARD *aAfter, const wxString &aPath=wxEmptyString) | |
| ~PCB_DIFFER () override | |
| DOCUMENT_DIFF | Diff () override |
| Produce a DOCUMENT_DIFF of the inputs the concrete differ was constructed with. | |
| const BOARD * | Before () const |
| Expose the underlying boards for callers that want to drive their own walk (e.g., the merge applier reaches in to materialize ITEM_CHANGE records). | |
| const BOARD * | After () const |
| void | SetOptions (const OPTIONS &aOptions) |
| const OPTIONS & | GetOptions () const |
Protected Attributes | |
| OPTIONS | m_options |
Private Member Functions | |
| 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. | |
| ITEM_DESCRIPTOR | makeDescriptor (const BOARD_ITEM *aItem) const |
| Build the ITEM_DESCRIPTOR for the reconciler from a BOARD_ITEM. | |
| std::vector< ITEM_CHANGE > | diffFootprintChildren (const FOOTPRINT *aBefore, const FOOTPRINT *aAfter) const |
| Construct a child-level diff for nested items inside a footprint pair. | |
Static Private Member Functions | |
| static void | sortChanges (std::vector< ITEM_CHANGE > &aChanges) |
| Stable, deterministic sort of ITEM_CHANGEs (by id, then typeName, then kind). | |
| static wxString | itemTypeName (const BOARD_ITEM *aItem) |
| Convert the dynamic class string for an item into the type name used in diffs. | |
| static std::optional< wxString > | itemRefdes (const BOARD_ITEM *aItem) |
| Extract a presentation label: footprint refdes, or routing net name for tracks/vias. | |
Private Attributes | |
| const BOARD * | m_before |
| const BOARD * | m_after |
| wxString | m_path |
Diff two already-parsed BOARDs and produce a DOCUMENT_DIFF.
Identity is UUID-keyed primarily, with similarity fallback via IDENTITY_RECONCILER for cases where copy-paste or third-party imports have rewritten KIIDs.
The differ walks the union of BOARD::GetItemSet() on both boards plus each footprint's children (pads, text, graphics) so that "inside the
footprint" diffs surface as nested ITEM_CHANGE::children entries on the footprint's record. This mirrors how KiCad organizes the data model and lets UI consumers fold and unfold per-footprint detail.
Definition at line 51 of file pcb_differ.h.
| KICAD_DIFF::PCB_DIFFER::PCB_DIFFER | ( | const BOARD * | aBefore, |
| const BOARD * | aAfter, | ||
| const wxString & | aPath = wxEmptyString ) |
Definition at line 55 of file pcb_differ.cpp.
|
overridedefault |
|
inline |
Definition at line 62 of file pcb_differ.h.
References m_after.
|
inline |
Expose the underlying boards for callers that want to drive their own walk (e.g., the merge applier reaches in to materialize ITEM_CHANGE records).
Definition at line 61 of file pcb_differ.h.
References m_before.
|
overridevirtual |
Produce a DOCUMENT_DIFF of the inputs the concrete differ was constructed with.
Must be deterministic for fixed inputs. Concrete differs sort their output by KIID_PATH so the JSON serialization is bit-stable across runs.
Implements KICAD_DIFF::KICAD_DIFFER.
Definition at line 437 of file pcb_differ.cpp.
References KICAD_DIFF::ADDED, KICAD_DIFF::PROPERTY_DELTA::after, KICAD_DIFF::RECONCILIATION::aOnly, KICAD_DIFF::AppendPaperDeltas(), KICAD_DIFF::RECONCILIATION::aToB, KICAD_DIFF::ITEM_CHANGE::bbox, KICAD_DIFF::PROPERTY_DELTA::before, KICAD_DIFF::RECONCILIATION::bOnly, BS_ITEM_TYPE_COPPER, BS_ITEM_TYPE_DIELECTRIC, chain, KICAD_DIFF::ITEM_CHANGE::children, FILEEXT::DesignRulesFileExtension, diffFootprintChildren(), diffProperties(), KICAD_DIFF::DOC_PROP_BOARD_THICKNESS, KICAD_DIFF::DOC_PROP_CUSTOM_RULES, KICAD_DIFF::DOC_PROP_DRAWING_SHEET, KICAD_DIFF::DOC_PROP_DRC_SEVERITIES, KICAD_DIFF::DOC_PROP_FP_LIB_TABLE, KICAD_DIFF::DOC_PROP_LAYER_STACKUP, KICAD_DIFF::DOC_PROP_NET_CLASSES, KICAD_DIFF::DOC_PROP_SYM_LIB_TABLE, KICAD_DIFF::DUPLICATE_UUID, KICAD_DIFF::RECONCILIATION::duplicatesA, KICAD_DIFF::RECONCILIATION::duplicatesB, empty(), KICAD_DIFF::FOOTPRINT, FILEEXT::FootprintLibraryTableFileName, KICAD_DIFF::DIFF_VALUE::FromInt(), KICAD_DIFF::DIFF_VALUE::FromString(), BOARD_DESIGN_SETTINGS::GetBoardThickness(), EDA_ITEM::GetBoundingBox(), BOARD::GetFileName(), BOARD::GetProject(), PROJECT::GetProjectFile(), BOARD_DESIGN_SETTINGS::GetStackupDescriptor(), KICAD_DIFF::ITEM_CHANGE::id, itemRefdes(), itemTypeName(), KiHashCombine(), KICAD_DIFF::ITEM_CHANGE::kind, m_after, m_before, PROJECT_FILE::m_BoardDrawingSheetFile, BOARD_DESIGN_SETTINGS::m_DRCSeverities, BOARD_DESIGN_SETTINGS::m_NetSettings, KICAD_DIFF::KICAD_DIFFER::m_options, m_path, makeDescriptor(), KICAD_DIFF::MODIFIED, KICAD_DIFF::PROPERTY_DELTA::name, name, PCB_GENERATOR_T, KICAD_DIFF::pcbAddedRemovedProperties(), KICAD_DIFF::ITEM_CHANGE::properties, KICAD_DIFF::IDENTITY_RECONCILER::Reconcile(), KICAD_DIFF::ITEM_CHANGE::refdes, KICAD_DIFF::REMOVED, result, sortChanges(), KICAD_DIFF::SummarizeSeverities(), FILEEXT::SymbolLibraryTableFileName, and KICAD_DIFF::ITEM_CHANGE::typeName.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), PCBNEW_JOBS_HANDLER::JobDiff(), KIGIT_PCB_MERGE::Merge(), PCBNEW_JOBS_HANDLER::OpenDiffDialog(), and PCBNEW_JOBS_HANDLER::runPcbMerge().
|
private |
Construct a child-level diff for nested items inside a footprint pair.
Definition at line 267 of file pcb_differ.cpp.
References KICAD_DIFF::ADDED, KICAD_DIFF::RECONCILIATION::aOnly, KICAD_DIFF::RECONCILIATION::aToB, KICAD_DIFF::ITEM_CHANGE::bbox, KICAD_DIFF::RECONCILIATION::bOnly, diffProperties(), KICAD_DIFF::FOOTPRINT, KIID::FromDeterministicString(), EDA_ITEM::GetBoundingBox(), FOOTPRINT::GetFields(), FOOTPRINT::GraphicalItems(), KICAD_DIFF::ITEM_CHANGE::id, KICAD_DIFF::ITEM_DESCRIPTOR::id, itemRefdes(), itemTypeName(), KICAD_DIFF::ITEM_CHANGE::kind, KICAD_DIFF::KICAD_DIFFER::m_options, EDA_ITEM::m_Uuid, makeDescriptor(), KICAD_DIFF::MODIFIED, pad, FOOTPRINT::Pads(), PCB_SHAPE_T, PCB_TEXT_T, KICAD_DIFF::pcbAddedRemovedProperties(), KICAD_DIFF::ITEM_CHANGE::properties, KICAD_DIFF::IDENTITY_RECONCILER::Reconcile(), KICAD_DIFF::ITEM_CHANGE::refdes, KICAD_DIFF::REMOVED, sortChanges(), KICAD_DIFF::ITEM_CHANGE::typeName, and FOOTPRINT::Zones().
Referenced by Diff().
|
private |
Compute property deltas between two items of the same dynamic type.
Returns the populated PROPERTY_DELTA list; empty if items compare equal via PROPERTY_MANAGER (i.e., no surfaced property changed).
Definition at line 185 of file pcb_differ.cpp.
References KICAD_DIFF::PROPERTY_DELTA::after, KICAD_DIFF::PROPERTY_DELTA::before, KICAD_DIFF::DiffItemProperties(), KICAD_DIFF::DIFF_VALUE::FromPolygonSet(), BOARD_ITEM::GetParent(), LayerName(), KICAD_DIFF::PROPERTY_DELTA::name, PCB_FOOTPRINT_T, and EDA_ITEM::Type().
Referenced by Diff(), and diffFootprintChildren().
|
inlineinherited |
Definition at line 67 of file kicad_differ.h.
References m_options.
|
staticprivate |
Extract a presentation label: footprint refdes, or routing net name for tracks/vias.
Definition at line 78 of file pcb_differ.cpp.
References KICAD_DIFF::FOOTPRINT, and BOARD_ITEM::GetParent().
Referenced by Diff(), and diffFootprintChildren().
|
staticprivate |
Convert the dynamic class string for an item into the type name used in diffs.
Definition at line 66 of file pcb_differ.cpp.
References KIGFX::VIEW_ITEM::GetClass().
Referenced by Diff(), diffFootprintChildren(), and makeDescriptor().
|
private |
Build the ITEM_DESCRIPTOR for the reconciler from a BOARD_ITEM.
Definition at line 99 of file pcb_differ.cpp.
References KICAD_DIFF::ITEM_DESCRIPTOR::bbox, KICAD_DIFF::FOOTPRINT, EDA_ITEM::GetBoundingBox(), EDA_ITEM::GetPosition(), KICAD_DIFF::ITEM_DESCRIPTOR::id, itemTypeName(), KICAD_DIFF::ITEM_DESCRIPTOR::keyProps, EDA_ITEM::m_Uuid, pad, KICAD_DIFF::ITEM_DESCRIPTOR::position, and KICAD_DIFF::ITEM_DESCRIPTOR::type.
Referenced by Diff(), and diffFootprintChildren().
|
inlineinherited |
Definition at line 66 of file kicad_differ.h.
References m_options.
|
staticprivate |
Stable, deterministic sort of ITEM_CHANGEs (by id, then typeName, then kind).
Definition at line 419 of file pcb_differ.cpp.
Referenced by Diff(), and diffFootprintChildren().
|
private |
Definition at line 87 of file pcb_differ.h.
Referenced by After(), Diff(), and PCB_DIFFER().
|
private |
Definition at line 86 of file pcb_differ.h.
Referenced by Before(), Diff(), and PCB_DIFFER().
|
protectedinherited |
Definition at line 80 of file kicad_differ.h.
Referenced by KICAD_DIFF::FP_LIB_DIFFER::Diff(), KICAD_DIFF::PCB_DIFFER::Diff(), KICAD_DIFF::SCH_DIFFER::Diff(), KICAD_DIFF::SYM_LIB_DIFFER::Diff(), KICAD_DIFF::PCB_DIFFER::diffFootprintChildren(), GetOptions(), and SetOptions().
|
private |
Definition at line 88 of file pcb_differ.h.
Referenced by Diff(), and PCB_DIFFER().