KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KICAD_DIFF::PCB_DIFFER Class Reference

Diff two already-parsed BOARDs and produce a DOCUMENT_DIFF. More...

#include <pcb_differ.h>

Inheritance diagram for KICAD_DIFF::PCB_DIFFER:
KICAD_DIFF::KICAD_DIFFER

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 BOARDBefore () 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 BOARDAfter () const
 
void SetOptions (const OPTIONS &aOptions)
 
const OPTIONSGetOptions () const
 

Protected Attributes

OPTIONS m_options
 

Private Member Functions

std::vector< PROPERTY_DELTAdiffProperties (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_CHANGEdiffFootprintChildren (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 BOARDm_before
 
const BOARDm_after
 
wxString m_path
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ PCB_DIFFER()

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.

References m_after, m_before, and m_path.

◆ ~PCB_DIFFER()

KICAD_DIFF::PCB_DIFFER::~PCB_DIFFER ( )
overridedefault

Member Function Documentation

◆ After()

const BOARD * KICAD_DIFF::PCB_DIFFER::After ( ) const
inline

Definition at line 62 of file pcb_differ.h.

References m_after.

◆ Before()

const BOARD * KICAD_DIFF::PCB_DIFFER::Before ( ) const
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.

◆ Diff()

DOCUMENT_DIFF KICAD_DIFF::PCB_DIFFER::Diff ( )
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().

◆ diffFootprintChildren()

◆ diffProperties()

std::vector< PROPERTY_DELTA > KICAD_DIFF::PCB_DIFFER::diffProperties ( const BOARD_ITEM * aBefore,
const BOARD_ITEM * aAfter ) const
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().

◆ GetOptions()

const OPTIONS & KICAD_DIFF::KICAD_DIFFER::GetOptions ( ) const
inlineinherited

Definition at line 67 of file kicad_differ.h.

References m_options.

◆ itemRefdes()

std::optional< wxString > KICAD_DIFF::PCB_DIFFER::itemRefdes ( const BOARD_ITEM * aItem)
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().

◆ itemTypeName()

wxString KICAD_DIFF::PCB_DIFFER::itemTypeName ( const BOARD_ITEM * aItem)
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().

◆ makeDescriptor()

◆ SetOptions()

void KICAD_DIFF::KICAD_DIFFER::SetOptions ( const OPTIONS & aOptions)
inlineinherited

Definition at line 66 of file kicad_differ.h.

References m_options.

◆ sortChanges()

void KICAD_DIFF::PCB_DIFFER::sortChanges ( std::vector< ITEM_CHANGE > & aChanges)
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().

Member Data Documentation

◆ m_after

const BOARD* KICAD_DIFF::PCB_DIFFER::m_after
private

Definition at line 87 of file pcb_differ.h.

Referenced by After(), Diff(), and PCB_DIFFER().

◆ m_before

const BOARD* KICAD_DIFF::PCB_DIFFER::m_before
private

Definition at line 86 of file pcb_differ.h.

Referenced by Before(), Diff(), and PCB_DIFFER().

◆ m_options

◆ m_path

wxString KICAD_DIFF::PCB_DIFFER::m_path
private

Definition at line 88 of file pcb_differ.h.

Referenced by Diff(), and PCB_DIFFER().


The documentation for this class was generated from the following files: