KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KICAD_DIFF Namespace Reference

Classes

struct  APPLY_AUTO_RESOLUTIONS_RESULT
 
struct  AUTO_RESOLUTION_PARSE_RESULT
 Result of ParseAutoResolutionJson. More...
 
struct  CHANGE_TREE_ENTRY
 One row in a grouped change tree — an ITEM_CHANGE plus its display label (typeName + optional refdes in [brackets]). More...
 
struct  CHANGE_TREE_GROUP
 One bucket in a grouped change tree — a CHANGE_KIND, a human- readable group label, and the entries belonging to that bucket. More...
 
struct  CONFLICT_LIST_ENTRY
 Build the list of conflict-action indices the dialog walks (i.e. More...
 
struct  DIFF_COLOR_THEME
 Color theme. More...
 
struct  DIFF_EMIT_OPTIONS
 Describes how a computed DOCUMENT_DIFF should be emitted by a diff job. More...
 
struct  DIFF_SCENE
 
class  DIFF_VALUE
 A typed sum value used to carry the before/after of any single property. More...
 
struct  DOCUMENT_CIRCLE
 Filled or stroked circle. More...
 
struct  DOCUMENT_DIFF
 The full set of changes between two parsed documents of one type. More...
 
struct  DOCUMENT_GEOMETRY
 Aggregate of background geometry extracted from one source document. More...
 
struct  DOCUMENT_POLYGON
 Closed polygon outline from a source document. More...
 
struct  DOCUMENT_SEGMENT
 Stroked line segment from one of the source documents. More...
 
class  FP_LIB_DIFFER
 Diff two .pretty footprint library directories. More...
 
struct  GEOMETRY_SINK
 Sink for the shared DOCUMENT_GEOMETRY walk. More...
 
class  IDENTITY_RECONCILER
 Reconciles item identity across two snapshots of the same document. More...
 
struct  ITEM_CHANGE
 One change record on a single item. More...
 
struct  ITEM_DESCRIPTOR
 Descriptor used by the identity reconciler to compare items across two documents. More...
 
struct  ITEM_RESOLUTION
 
class  KICAD_DIFFER
 Abstract base for every per-document-type differ. More...
 
class  KICAD_MERGE_ENGINE
 Three-way merge plan generator. More...
 
class  LIB_MERGE_APPLIER
 Materialize a MERGE_PLAN into a merged name-keyed library. More...
 
struct  MERGE_PLAN
 Result of planning a 3-way merge. More...
 
class  PCB_DIFFER
 Diff two already-parsed BOARDs and produce a DOCUMENT_DIFF. More...
 
class  PCB_MERGE_APPLIER
 Materialize a MERGE_PLAN into a real merged BOARD. More...
 
struct  PLOTTER_RENDER_OPTIONS
 Options controlling the headless PNG/SVG renderer. More...
 
struct  PROJECT_DIFF
 Aggregated project-level diff covering many documents. More...
 
struct  PROPERTY_APPLY_COUNTS
 Applied/failed tallies from ApplyPropertyResolutions, folded into a caller's report. More...
 
struct  PROPERTY_DELTA
 Single (name, before, after) triple for one mutated property on an item. More...
 
struct  PROPERTY_RESOLUTION
 
struct  PROPERTY_RESOLUTION_OUTCOME
 Per-property merge decision result. More...
 
struct  RECONCILIATION
 Maps every item in document A to either a peer in document B or to "only-in-A", and vice versa. More...
 
struct  REFDES_ENTRY
 Reference-designator uniqueness over a flat list of (refdes, id) pairs. More...
 
struct  SCENE_SHAPE
 Shared rendering model consumed by both the GAL renderer (interactive widget) and the plotter renderer (headless PNG/SVG output). More...
 
class  SCH_DIFFER
 Diff two already-parsed SCHEMATICs and produce a DOCUMENT_DIFF. More...
 
class  SCH_MERGE_APPLIER
 Materialize a MERGE_PLAN into a merged SCHEMATIC by mutating the ancestor in place. More...
 
class  SHEET_SCOPE
 RAII guard that temporarily swaps SCHEMATIC::CurrentSheet to a given path for the duration of a scope, restoring it on exit. More...
 
struct  SYM_ELEMENT
 
class  SYM_LIB_DIFFER
 Diff two .kicad_sym symbol libraries. More...
 
struct  VALIDATION_FAILURE
 Outcome of a single validator run. More...
 
struct  VALIDATION_INPUT
 Inputs needed to run the post-apply validator pipeline. More...
 
struct  VALIDATION_REPORT
 

Typedefs

using SYM_LIB_MERGE_APPLIER = LIB_MERGE_APPLIER<LIB_SYMBOL>
 Symbol-library 3-way merge applier. See LIB_MERGE_APPLIER for behavior.
 
using FP_LIB_MERGE_APPLIER = LIB_MERGE_APPLIER<FOOTPRINT>
 Footprint-library 3-way merge applier. See LIB_MERGE_APPLIER for behavior.
 

Enumerations

enum class  AUTO_RESOLUTION_STATUS {
  OK , INVALID_JSON , NOT_OBJECT , BAD_VALUE ,
  UNKNOWN_KIND , ENGINE_INTERNAL_KIND
}
 Outcome of parsing a KICAD_MERGETOOL_AUTO JSON document. More...
 
enum class  APPLY_AUTO_RESOLUTIONS_STATUS { COMPLETE , PARTIAL , NO_CONFLICTS }
 Outcome of applying an auto-resolution map to a MERGE_PLAN. More...
 
enum class  DOC_KIND {
  UNKNOWN , PCB , SCH , SYM_LIB ,
  FP_LIB , FOOTPRINT
}
 Document type a diff/merge entry point should route to, derived from a file path's extension. More...
 
enum class  CATEGORY { ADDED , REMOVED , MODIFIED , CONFLICT }
 Visual category each ITEM_CHANGE belongs to in the scene. More...
 
enum class  DISPLAY_HINT { NONE , DISTANCE , COORD , ANGLE }
 How a numeric DIFF_VALUE should be interpreted when rendered for humans. More...
 
enum class  CHANGE_KIND {
  ADDED , REMOVED , MODIFIED , COLLISION ,
  DUPLICATE_UUID
}
 Coarse classification of a single item-level change between two documents. More...
 
enum class  PROP_RES { OURS , THEIRS , ANCESTOR , CUSTOM }
 Resolution kind for a single property of a single item. More...
 
enum class  ITEM_RES {
  TAKE_OURS , TAKE_THEIRS , TAKE_ANCESTOR , MERGE_PROPS ,
  DELETE_ITEM , KEEP
}
 Resolution kind for a whole item. More...
 

Functions

AUTO_RESOLUTION_PARSE_RESULT ParseAutoResolutionJson (const std::string &aJsonContent)
 Parse a KICAD_MERGETOOL_AUTO-format JSON object mapping item IDs (KIID_PATH strings) to ITEM_RES spellings (the canonical snake_case names emitted by ItemResToString).
 
APPLY_AUTO_RESOLUTIONS_RESULT ApplyAutoResolutions (MERGE_PLAN &aPlan, const std::vector< std::size_t > &aConflictActionIndices, const std::map< wxString, ITEM_RES > &aResolutions)
 Apply a parsed auto-resolution map to a MERGE_PLAN's conflicts.
 
std::vector< CONFLICT_LIST_ENTRYBuildConflictList (const MERGE_PLAN &aPlan)
 
std::vector< KIID_PATHCollectUnresolvedConflicts (const MERGE_PLAN &aPlan, const std::vector< std::size_t > &aConflictActionIndices)
 Return the subset of conflict actions whose kind is NOT one of the concrete TAKE_OURS / TAKE_THEIRS / TAKE_ANCESTOR — the dialog uses this to refuse Apply when the user hasn't picked a side on every conflict.
 
std::optional< BOX2IResolveConflictBBox (const KIID_PATH &aId, const std::map< KIID_PATH, BOX2I > &aPrimary, const std::map< KIID_PATH, BOX2I > &aOurs, const std::map< KIID_PATH, BOX2I > &aTheirs, const std::map< KIID_PATH, BOX2I > &aAncestor)
 Resolve the best bounding box for a conflicted item across the three sides of a 3-way merge.
 
wxString BuildConflictDetailText (const ITEM_RESOLUTION &aResolution)
 Build the human-readable detail text shown in the merge dialog's resolution panel for a given ITEM_RESOLUTION.
 
DOC_KIND DocKindFromExtension (const wxString &aPath)
 Map a path's extension to a DOC_KIND (.kicad_pcb -> PCB, .kicad_sch -> SCH, .kicad_sym -> SYM_LIB, .kicad_mod -> FOOTPRINT; anything else -> UNKNOWN).
 
DIFF_EMIT_OPTIONS MakeEmitOptions (const JOB_DIFF_BASE &aJob, const wxString &aLabelA, const wxString &aLabelB)
 Build a DIFF_EMIT_OPTIONS pre-filled from the job's format, resolved output path and the supplied per-side labels.
 
int DiffExitCode (const DOCUMENT_DIFF &aResult)
 Map a computed diff onto its CLI exit code – SUCCESS when empty, otherwise ERR_RC_VIOLATIONS.
 
int EmitDiffResult (const DOCUMENT_DIFF &aResult, const DIFF_EMIT_OPTIONS &aOptions, int aDiffExitCode, REPORTER &aReporter)
 Emit a computed DOCUMENT_DIFF in the requested format.
 
void RenderSceneToOverlay (KIGFX::VIEW_OVERLAY &aOverlay, const DIFF_SCENE &aScene, const std::array< bool, CATEGORY_COUNT > &aVisible=ALL_CATEGORIES_VISIBLE, const std::optional< KIID_PATH > &aHighlight=std::nullopt, const std::set< KIID_PATH > &aHidden={})
 Push a DIFF_SCENE's shapes onto a VIEW_OVERLAY as filled, semi-transparent rectangles, drawn in the canonical PAINT_ORDER so conflicts visually win over earlier categories.
 
static bool writeEmptyPng (const wxString &aOutputPath)
 Write a tiny placeholder PNG (single empty pixel) so a "no differences" diff still produces a valid output file.
 
static bool writeEmptySvg (const wxString &aOutputPath)
 
bool RenderSceneToPng (const DIFF_SCENE &aScene, const wxString &aOutputPath, const PLOTTER_RENDER_OPTIONS &aOptions)
 Render a DIFF_SCENE to a PNG file.
 
bool RenderSceneToSvg (const DIFF_SCENE &aScene, const wxString &aOutputPath, const PLOTTER_RENDER_OPTIONS &aOptions)
 Render a DIFF_SCENE to an SVG file.
 
KIGFX::COLOR4D ThemeColorFor (const DIFF_COLOR_THEME &aTheme, CATEGORY aCategory)
 Map a CATEGORY to its color in a DIFF_COLOR_THEME.
 
std::optional< BOX2IBBoxFromGeometry (const DOCUMENT_GEOMETRY &aGeometry)
 Compute the tight bounding box of a DOCUMENT_GEOMETRY, inflating each primitive by half its stroke so the bbox actually contains the rendered pixels.
 
LSET GeometryLayerSet (const DOCUMENT_GEOMETRY &aGeometry)
 Return the union of every non-empty layer set carried by the geometry.
 
DOCUMENT_GEOMETRY FilterGeometryByVisibleLayers (const DOCUMENT_GEOMETRY &aGeometry, const LSET &aVisibleLayers)
 Copy geometry primitives whose layer set intersects aVisibleLayers.
 
void AppendGeometry (DOCUMENT_GEOMETRY &aDst, DOCUMENT_GEOMETRY &&aSrc)
 Move all primitives from aSrc into aDst.
 
bool IsRoutingNetChange (const ITEM_CHANGE &aChange)
 Presentation predicate for PCB routing changes that should be displayed as one net-level entry/shape.
 
wxString ChangeDisplayLabel (const ITEM_CHANGE &aChange)
 User-facing item label used consistently by scene tooltips and change tree entries.
 
DIFF_SCENE BuildScene (const DOCUMENT_DIFF &aDiff, const DIFF_COLOR_THEME &aTheme)
 Build a DIFF_SCENE from a DOCUMENT_DIFF, populating the shape lists and computing the union bbox.
 
void ExpandBBoxToGeometry (DIFF_SCENE &aScene)
 Grow the scene's documentBBox to also include the extent of any background geometry.
 
void CollectChangeBBoxes (const DOCUMENT_DIFF &aDiff, std::map< KIID_PATH, BOX2I > &aOut)
 Walk a DOCUMENT_DIFF and populate a (KIID_PATHBOX2I) map with each changed item's bbox, recursing into nested children.
 
DOCUMENT_POLYGON MakeBBoxOutline (const BOX2I &aBBox, const KIGFX::COLOR4D &aColor, int aLineWidth=0)
 Build a DOCUMENT_POLYGON outlining a bounding box.
 
SHAPE_POLY_SET PolySetFromPolygonList (const SCENE_SHAPE::PolygonList &aPolygons)
 Build a SHAPE_POLY_SET from a SCENE_SHAPE::PolygonList.
 
CATEGORY CategoryFor (CHANGE_KIND aKind)
 Map a CHANGE_KIND to the visual category it belongs to.
 
const std::vector< SCENE_SHAPE > & ShapesFor (const DIFF_SCENE &aScene, CATEGORY aCategory)
 Read-only access to a DIFF_SCENE's shape list for a given category.
 
std::optional< BOX2IHighlightedBBox (const DIFF_SCENE &aScene, const KIID_PATH &aChangeId, const std::array< bool, CATEGORY_COUNT > &aCategoryVisible)
 Union bbox of every visible SCENE_SHAPE whose changeId matches aChangeId.
 
wxString ChangeKindLabel (CHANGE_KIND aKind)
 Human-readable label for a CHANGE_KIND (e.g.
 
bool ChangeMatchesSearchFilter (const ITEM_CHANGE &aChange, const wxString &aLowercaseFilter)
 Predicate: does this item change match the active search filter?
 
std::vector< CHANGE_TREE_GROUPBuildChangeTreeGroups (const DOCUMENT_DIFF &aDiff, const wxString &aSearchFilter, const std::array< bool, CATEGORY_COUNT > &aVisibleCategories)
 Group the changes in a DOCUMENT_DIFF by kind, apply category and search filters, and return the resulting tree structure for a UI to render.
 
const char * ChangeKindToString (CHANGE_KIND aKind)
 
CHANGE_KIND ChangeKindFromString (const std::string &aKind)
 
std::string FormatDiffAsText (const DOCUMENT_DIFF &aDiff, const wxString &aLabelA, const wxString &aLabelB, EDA_UNITS aUnits, const EDA_IU_SCALE &aScale)
 Render a DOCUMENT_DIFF as the human-readable text report shared by the diff jobs and CLI: a diff <labelA> <labelB> header, the change count, then one indented line per change (recursing into footprint/sheet children) with property deltas printed as name: before -> after.
 
bool WriteDiffOutput (const std::string &aContent, const wxString &aOutputPath)
 Write diff/merge text output to aOutputPath, or to stdout when the path is empty.
 
const char * PropResToString (PROP_RES aRes)
 Canonical lower-case spellings for PROP_RES used inside the JSON serialization of PROPERTY_RESOLUTION (ours / theirs / ancestor / custom).
 
PROP_RES PropResFromString (const std::string &aStr)
 
const char * ItemResToString (ITEM_RES aRes)
 Canonical snake_case spellings used in MERGE_PLAN JSON serialization (take_ours / take_theirs / take_ancestor / merge_props / delete / keep).
 
ITEM_RES ItemResFromString (const std::string &aStr)
 
std::map< KIID_PATH, const ITEM_CHANGE * > IndexChangesByKiid (const DOCUMENT_DIFF &aDiff)
 Flatten a DOCUMENT_DIFF's ITEM_CHANGE tree into a KIID_PATH -> ITEM_CHANGE* map, recursing into child changes.
 
std::map< wxString, const PROPERTY_DELTA * > IndexPropertiesByName (const ITEM_CHANGE &aChange)
 Index property deltas inside one ITEM_CHANGE by property name.
 
PROPERTY_RESOLUTION_OUTCOME ResolvePropertyConflict (const PROPERTY_DELTA *aOurs, const PROPERTY_DELTA *aTheirs, const KICAD_MERGE_ENGINE::OPTIONS &aOptions)
 Decide how to resolve a single property edit between two sides.
 
int DispatchMerge (KIWAY &aKiway, DOC_KIND aKind, const wxString &aAncestor, const wxString &aOurs, const wxString &aTheirs, const wxString &aOutput, bool aInteractive, bool aSingleFile, REPORTER *aReporter)
 Run a 3-way document/library merge by calling the owning kiface's KIFACE_MERGE_DOCUMENT function export (chosen from aKind).
 
int DispatchOpenDiffDialog (KIWAY &aKiway, DOC_KIND aKind, const wxString &aFileA, const wxString &aFileB, const wxString &aLabelA, const wxString &aLabelB, wxWindow *aParent, REPORTER *aReporter=nullptr)
 Open DIALOG_KICAD_DIFF on two files by calling the owning kiface's KIFACE_OPEN_DIFF_DIALOG function export (chosen from aKind).
 
VALIDATION_REPORT RunPostApplyValidators (const VALIDATION_INPUT &aInput)
 Run every standard post-apply validator and merge their reports.
 
VALIDATION_REPORT CheckRefdesUniqueness (const std::vector< REFDES_ENTRY > &aEntries)
 Run refdes-uniqueness checks.
 
VALIDATION_REPORT CheckConnectivityRebuildFlag (bool aPlanRequiredRebuild, bool aApplierReportedRebuild)
 Information needed for the connectivity-rebuild side-effect check.
 
VALIDATION_REPORT CheckSchemaVersions (int aAncestorVersion, int aOursVersion, int aTheirsVersion)
 Schema-version compatibility check: every input to the merge must use a compatible serialization version.
 
std::optional< std::string > DocPropJsonPointer (const wxString &aDocProp, DOC_KIND aKind)
 Return the JSON pointer (RFC 6901, slash-separated) under which aDocProp is persisted in a .kicad_pro project file.
 
std::optional< std::string > DocPropJsonPointer (const wxString &aDocProp)
 
bool ApplyProjectFilePatch (nlohmann::json &aTarget, const nlohmann::json &aSource, const wxString &aDocProp, DOC_KIND aKind)
 Copy the JSON sub-tree located at the pointer for aDocProp from aSource into aTarget.
 
bool ApplyProjectFilePatch (nlohmann::json &aTarget, const nlohmann::json &aSource, const wxString &aDocProp)
 
bool ApplyProjectFilePatches (const wxString &aOutputProPath, const nlohmann::json &aSource, const std::set< wxString > &aDocProps, DOC_KIND aKind)
 Higher-level orchestrator: load the existing aOutputProPath as JSON (or start from aSource if the file doesn't exist), apply each DOC_PROP patch from aSource via ApplyProjectFilePatch, and write the result back to aOutputProPath.
 
bool ApplyProjectFilePatches (const wxString &aOutputProPath, const nlohmann::json &aSource, const std::set< wxString > &aDocProps)
 
DIFF_VALUE WxAnyToDiffValue (const wxAny &aValue, PROPERTY_BASE *aProperty=nullptr)
 Convert a wxAny value read from a PROPERTY_BASE getter into a DIFF_VALUE that the engine can store, serialize, and compare.
 
bool DiffValueToWxAny (const DIFF_VALUE &aValue, wxAny &aOut)
 Convert a DIFF_VALUE back into a wxAny a PROPERTY_BASE setter can consume.
 
std::vector< KIGFX::VIEW_ITEM * > CollectSchematicDiffContextItems (SCHEMATIC &aSchematic, SCH_SCREEN *aScreen)
 
void ConfigureSchDiffContextRenderSettings (SCH_RENDER_SETTINGS &aSettings, const KIGFX::COLOR4D &aColor)
 
std::unique_ptr< KIGFX::PAINTERMakeSchDiffContextPainter (KIGFX::GAL *aGal, SCHEMATIC *aSchematic, const KIGFX::COLOR4D &aColor, std::map< KIID, KIGFX::COLOR4D > aOverrides)
 
void ConfigureSchDiffCanvasContext (WIDGET_DIFF_CANVAS &aCanvas, SCHEMATIC *aReference, SCHEMATIC *aComparison, const KIGFX::COLOR4D &aColor, const std::map< KIID, KIGFX::COLOR4D > &aOverrides, const std::vector< KIGFX::VIEW_ITEM * > &aExtraItems, const std::map< KIID, KICAD_DIFF::CATEGORY > &aCategories, SCH_SCREEN *aReferenceScreen, SCH_SCREEN *aComparisonScreen)
 
template<typename SHEET_VISITOR, typename ITEM_VISITOR>
void WalkSchematic (const SCHEMATIC *aSchematic, SHEET_VISITOR &&aSheetVisitor, ITEM_VISITOR &&aItemVisitor, const KIID_PATH &aScope={})
 Visit every SCH_ITEM in every sheet of aSchematic in page-number order.
 
DOCUMENT_GEOMETRY ExtractSchematicGeometry (const SCHEMATIC &aSchematic, const KIGFX::COLOR4D &aColor, const std::map< KIID, KIGFX::COLOR4D > &aOverrides={}, bool aOnlyOverrides=false)
 Extract a coarse outline of a SCHEMATIC into a DOCUMENT_GEOMETRY for use as background context in DIFF_SCENE rendering.
 
DOCUMENT_GEOMETRY ExtractSymbolGeometry (const LIB_SYMBOL &aSymbol, const KIGFX::COLOR4D &aColor, int aUnit=0, int aBodyStyle=0)
 Extract coarse drawable context from a library symbol for visual symbol diffs.
 
static bool isSheetItem (const SCH_ITEM *aItem)
 True iff aItem is a SCH_SHEET.
 
static int rootFileFormatVersion (const SCHEMATIC *aSchematic)
 Return aSchematic's root-screen file-format version, or 0 when no root screen is reachable.
 
void ConfigureSymDiffCanvasContext (WIDGET_DIFF_CANVAS &aCanvas, LIB_SYMBOL *aBefore, LIB_SYMBOL *aAfter)
 
std::vector< SYM_ELEMENTDiffSymbolElements (const LIB_SYMBOL *aBefore, const LIB_SYMBOL *aAfter)
 Compares the elements of two library symbols.
 
constexpr int EffectivePlotWidth (int aWidth)
 Return aWidth if positive, otherwise PLOT_HAIRLINE_IU.
 
void IterateDocumentGeometry (const DOCUMENT_GEOMETRY &aGeometry, GEOMETRY_SINK &aSink)
 Walk a DOCUMENT_GEOMETRY in the canonical render order shared by the GAL and plotter renderers: every polygon fill pass, every polygon stroke pass, then segments, then circles.
 
const EDA_IU_SCALEIuScaleForDocKind (DOC_KIND aKind)
 Internal-unit scale a document kind's coordinates are expressed in.
 
void AppendPaperDeltas (std::vector< PROPERTY_DELTA > &aDeltas, const PAGE_INFO &aBefore, const PAGE_INFO &aAfter)
 Append DOC_PROP_PAGE_FORMAT and/or DOC_PROP_PAGE_ORIENTATION deltas to aDeltas when the two PAGE_INFO structs differ on either field.
 
const KIIDSchScreenSentinelKiid ()
 Sentinel KIID appended to a sheet's KIID_PATH to mark a per-sheet SCH_SCREEN resolution (page format / orientation override on that sheet's screen).
 
KIID_PATH LibraryItemKiidPath (const wxString &aName)
 Build a deterministic synthetic KIID_PATH from a library item name (symbol name or footprint name).
 
template<typename SeverityMap>
std::string SummarizeSeverities (const SeverityMap &aMap)
 Format a severity-override map (DRC or ERC, keyed by error code, value is a SEVERITY enum) as a short summary with a content hash, so two maps with the same size but different contents render as distinct before/after strings.
 
bool ChangeInvalidatesZone (const ITEM_CHANGE &aChange)
 Whether a change to an item of the given type invalidates any overlapping filled zones.
 
bool ChangeRequiresConnectivityRebuild (const ITEM_CHANGE &aChange)
 Whether a change to an item of the given type requires the connectivity graph to be rebuilt.
 
template<typename MAP, typename BBoxFn, typename ChangedFn>
DOCUMENT_DIFF DiffLibraryByName (const MAP &aBefore, const MAP &aAfter, const wxString &aPath, const wxString &aDocType, const wxString &aTypeName, const KICAD_DIFFER::OPTIONS &aOptions, BBoxFn aBBox, ChangedFn aChanged)
 Shared name-keyed library diff used by FP_LIB_DIFFER and SYM_LIB_DIFFER.
 
std::vector< PROPERTY_DELTADiffItemProperties (const INSPECTABLE *aBefore, const INSPECTABLE *aAfter)
 Enumerate the property deltas between two items of the same dynamic type.
 
std::vector< PROPERTY_DELTAItemProperties (const INSPECTABLE *aItem, bool aAsAfter)
 List one item's properties as one-sided deltas for an added or removed item.
 
PROPERTY_APPLY_COUNTS ApplyPropertyResolutions (INSPECTABLE *aTarget, const std::vector< PROPERTY_RESOLUTION > &aProps, const INSPECTABLE *aOurs, const INSPECTABLE *aTheirs, const INSPECTABLE *aAncestor)
 Apply per-property merge resolutions to aTarget, sourcing OURS/THEIRS/ANCESTOR values from the matching source item and CUSTOM values from the resolution payload.
 
void CollectTopLevelIds (const BOARD *aBoard, std::set< KIID > &aOut)
 Insert every top-level item UUID from aBoard into aOut.
 
std::vector< KIGFX::VIEW_ITEM * > CollectFootprintDiffContextItems (FOOTPRINT &aFootprint)
 
std::vector< KIGFX::VIEW_ITEM * > CollectBoardDiffContextItems (BOARD &aBoard)
 
void ConfigurePcbDiffContextRenderSettings (KIGFX::PCB_RENDER_SETTINGS &aSettings, const KIGFX::COLOR4D &aColor)
 
std::unique_ptr< KIGFX::PAINTERMakePcbDiffContextPainter (KIGFX::GAL *aGal, const KIGFX::COLOR4D &aColor, std::map< KIID, KIGFX::COLOR4D > aOverrides)
 
void ConfigurePcbDiffCanvasContext (WIDGET_DIFF_CANVAS &aCanvas, BOARD *aReference, BOARD *aComparison, const KIGFX::COLOR4D &aColor, const std::map< KIID, KIGFX::COLOR4D > &aOverrides, const std::vector< KIGFX::VIEW_ITEM * > &aExtraItems, const std::map< KIID, KICAD_DIFF::CATEGORY > &aCategories)
 
static bool pcbLibraryMetadataNoise (const wxString &aName)
 
static bool pcbDiffPropertyIsNoise (const wxString &aName, bool aInsideFootprint)
 
static std::vector< PROPERTY_DELTApcbAddedRemovedProperties (const BOARD_ITEM *aItem, bool aAsAfter)
 
DOCUMENT_GEOMETRY ExtractBoardGeometry (const BOARD &aBoard, const KIGFX::COLOR4D &aColor)
 Extract a coarse outline of a BOARD into a DOCUMENT_GEOMETRY for use as background context in DIFF_SCENE rendering.
 
DOCUMENT_GEOMETRY ExtractFootprintGeometry (const FOOTPRINT &aFootprint, const KIGFX::COLOR4D &aColor)
 Extract drawable context geometry from a single FOOTPRINT.
 

Variables

constexpr std::array< bool, CATEGORY_COUNTALL_CATEGORIES_VISIBLE
 Default-visible category filter — every CATEGORY shows.
 
constexpr int PLOT_HAIRLINE_IU = 10
 Minimum stroke width the headless plotter will use when a primitive declares a non-positive line width.
 
constexpr std::array< CATEGORY, 4 > PAINT_ORDER
 Paint order.
 
constexpr std::size_t CATEGORY_COUNT = PAINT_ORDER.size()
 
const wxString DOC_PROP_PAGE_FORMAT = wxS( "Page Format" )
 Property-name keys for the synthetic document-level ITEM_CHANGE (empty KIID_PATH).
 
const wxString DOC_PROP_PAGE_ORIENTATION = wxS( "Page Orientation" )
 
const wxString DOC_PROP_BOARD_THICKNESS = wxS( "Board Thickness" )
 
const wxString DOC_PROP_LAYER_STACKUP = wxS( "Layer Stackup" )
 
const wxString DOC_PROP_DRC_SEVERITIES = wxS( "DRC Severity Overrides" )
 
const wxString DOC_PROP_ERC_SEVERITIES = wxS( "ERC Severity Overrides" )
 
const wxString DOC_PROP_DRAWING_SHEET = wxS( "Drawing Sheet File" )
 
const wxString DOC_PROP_NET_CLASSES = wxS( "Net Classes" )
 
const wxString DOC_PROP_CUSTOM_RULES = wxS( "Custom DRC Rules" )
 
const wxString DOC_PROP_FP_LIB_TABLE = wxS( "Footprint Library Table" )
 
const wxString DOC_PROP_SYM_LIB_TABLE = wxS( "Symbol Library Table" )
 

Typedef Documentation

◆ FP_LIB_MERGE_APPLIER

Footprint-library 3-way merge applier. See LIB_MERGE_APPLIER for behavior.

Definition at line 37 of file fp_lib_merge_applier.h.

◆ SYM_LIB_MERGE_APPLIER

Symbol-library 3-way merge applier. See LIB_MERGE_APPLIER for behavior.

Definition at line 37 of file sym_lib_merge_applier.h.

Enumeration Type Documentation

◆ APPLY_AUTO_RESOLUTIONS_STATUS

Outcome of applying an auto-resolution map to a MERGE_PLAN.

COMPLETE — every conflict in the plan was covered by the auto map, the plan's unresolved list was cleared, and the caller should apply the plan (EndModal wxID_APPLY in the dialog case).

PARTIAL — at least one conflict had no auto-resolution; the plan has been left untouched and the caller should treat this as a failure (EndModal wxID_CANCEL).

NO_CONFLICTS — the plan had no conflicts to resolve in the first place; trivially complete.

Enumerator
COMPLETE 
PARTIAL 
NO_CONFLICTS 

Definition at line 105 of file auto_resolution.h.

◆ AUTO_RESOLUTION_STATUS

Outcome of parsing a KICAD_MERGETOOL_AUTO JSON document.

The dialog's headless path needs to distinguish three states: the env variable is unset (interactive use, no auto-mode), the file was successfully parsed (apply the resolutions), or the file existed but something about it was wrong (CI must fail loudly rather than silently fall back to an interactive UI with no human present).

Enumerator
OK 

parsed cleanly; resolutions is populated

INVALID_JSON 

input could not be parsed as JSON

NOT_OBJECT 

JSON parsed but the root was not an object.

BAD_VALUE 

at least one entry's value wasn't a string

UNKNOWN_KIND 

at least one entry's string wasn't a known ITEM_RES

ENGINE_INTERNAL_KIND 

at least one entry asked for an engine-internal kind (KEEP / DELETE / MERGE_PROPS); only the TAKE_* family makes sense as a scripted choice

Definition at line 50 of file auto_resolution.h.

◆ CATEGORY

enum class KICAD_DIFF::CATEGORY
strong

Visual category each ITEM_CHANGE belongs to in the scene.

There are four categories because the renderer buckets shapes into four lists; both COLLISION and DUPLICATE_UUID map to CONFLICT.

Enumerator
ADDED 
REMOVED 
MODIFIED 
CONFLICT 

Definition at line 51 of file diff_scene.h.

◆ CHANGE_KIND

enum class KICAD_DIFF::CHANGE_KIND
strong

Coarse classification of a single item-level change between two documents.

The engine never carries display severity on the change record; consumers compute their own ranking from (typeName, kind, properties).

Enumerator
ADDED 
REMOVED 
MODIFIED 
COLLISION 
DUPLICATE_UUID 

Definition at line 74 of file kicad_diff_types.h.

◆ DISPLAY_HINT

enum class KICAD_DIFF::DISPLAY_HINT
strong

How a numeric DIFF_VALUE should be interpreted when rendered for humans.

Derived from the source property's PROPERTY_DISPLAY (PT_SIZE / PT_COORD / PT_DEGREE) so distance, coordinate and angle deltas render in mm / degrees instead of raw internal units. Plain numbers carry NONE and are printed verbatim. The hint is display-only and deliberately not serialized: it is a presentation aid recoverable from the property metadata, not part of the canonical value.

Enumerator
NONE 
DISTANCE 

Length in internal units (PT_SIZE)

COORD 

Coordinate in internal units (PT_COORD)

ANGLE 

Angle in degrees (PT_DEGREE)

Definition at line 60 of file kicad_diff_types.h.

◆ DOC_KIND

enum class KICAD_DIFF::DOC_KIND
strong

Document type a diff/merge entry point should route to, derived from a file path's extension.

Used by the mergetool, the MR-review dialog, and the kiface diff/merge function exports to pick the right kiface + differ.

Enumerator
UNKNOWN 
PCB 
SCH 
SYM_LIB 
FP_LIB 
FOOTPRINT 

Definition at line 38 of file diff_doc_kind.h.

◆ ITEM_RES

enum class KICAD_DIFF::ITEM_RES
strong

Resolution kind for a whole item.

MERGE_PROPS is the common case: produce a new item by taking each property from whichever side the per-property resolution says. The other kinds let the user take one side wholesale (after a property conflict that's impractical to resolve property-by-property — e.g., zone outline edits on both sides).

Enumerator
TAKE_OURS 
TAKE_THEIRS 
TAKE_ANCESTOR 
MERGE_PROPS 
DELETE_ITEM 
KEEP 

Definition at line 63 of file kicad_merge_engine.h.

◆ PROP_RES

enum class KICAD_DIFF::PROP_RES
strong

Resolution kind for a single property of a single item.

Conflicts are resolved at the property level, not the item level — the engine takes "we moved it" + "they renamed it" as auto-merge candidates, not as a single conflict on the item. CUSTOM lets the user supply a value that came from neither side (used by the 3-way merge dialog).

Enumerator
OURS 
THEIRS 
ANCESTOR 
CUSTOM 

Definition at line 45 of file kicad_merge_engine.h.

Function Documentation

◆ AppendGeometry()

KICOMMON_API void KICAD_DIFF::AppendGeometry ( DOCUMENT_GEOMETRY & aDst,
DOCUMENT_GEOMETRY && aSrc )

Move all primitives from aSrc into aDst.

Presentation code often builds document geometry one library item at a time; keep the move/append details in one helper so job handlers and dialogs do not duplicate three vector insertions.

Definition at line 392 of file diff_scene.cpp.

References KICAD_DIFF::DOCUMENT_GEOMETRY::circles, KICAD_DIFF::DOCUMENT_GEOMETRY::polygons, and KICAD_DIFF::DOCUMENT_GEOMETRY::segments.

Referenced by BOOST_AUTO_TEST_CASE(), footprintLibraryGeometry(), and symbolLibraryGeometry().

◆ AppendPaperDeltas()

void KICAD_DIFF::AppendPaperDeltas ( std::vector< PROPERTY_DELTA > & aDeltas,
const PAGE_INFO & aBefore,
const PAGE_INFO & aAfter )
inline

Append DOC_PROP_PAGE_FORMAT and/or DOC_PROP_PAGE_ORIENTATION deltas to aDeltas when the two PAGE_INFO structs differ on either field.

Shared between SCH_DIFFER (root + per-sheet paper diff) and PCB_DIFFER so the property-name + DIFF_VALUE encoding can't drift between document types as the paper-info struct evolves.

Emit order is fixed: page-format delta appended first, page-orientation delta second. Downstream marker rendering and diff JSON serialization rely on this stable ordering to produce deterministic output across runs.

Definition at line 51 of file doc_property_helpers.h.

References KICAD_DIFF::PROPERTY_DELTA::after, KICAD_DIFF::PROPERTY_DELTA::before, DOC_PROP_PAGE_FORMAT, DOC_PROP_PAGE_ORIENTATION, KICAD_DIFF::DIFF_VALUE::FromBool(), KICAD_DIFF::DIFF_VALUE::FromEnum(), PAGE_INFO::GetType(), PAGE_INFO::GetTypeAsString(), PAGE_INFO::IsPortrait(), and KICAD_DIFF::PROPERTY_DELTA::name.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), KICAD_DIFF::PCB_DIFFER::Diff(), and KICAD_DIFF::SCH_DIFFER::Diff().

◆ ApplyAutoResolutions()

KICOMMON_API APPLY_AUTO_RESOLUTIONS_RESULT KICAD_DIFF::ApplyAutoResolutions ( MERGE_PLAN & aPlan,
const std::vector< std::size_t > & aConflictActionIndices,
const std::map< wxString, ITEM_RES > & aResolutions )

Apply a parsed auto-resolution map to a MERGE_PLAN's conflicts.

aConflictActionIndices is the list of plan.actions indices that the dialog identified as conflicts (i.e. ids appearing in plan.unresolved). Building it is the caller's job; this function just iterates that list and applies the map.

On COMPLETE the plan's unresolved vector is cleared. On PARTIAL the plan is left untouched.

Definition at line 106 of file auto_resolution.cpp.

References KICAD_DIFF::MERGE_PLAN::actions, KICAD_DIFF::APPLY_AUTO_RESOLUTIONS_RESULT::appliedCount, KIID_PATH::AsString(), COMPLETE, KICAD_DIFF::APPLY_AUTO_RESOLUTIONS_RESULT::firstMissingId, KICAD_DIFF::ITEM_RESOLUTION::id, NO_CONFLICTS, PARTIAL, KICAD_DIFF::APPLY_AUTO_RESOLUTIONS_RESULT::status, and KICAD_DIFF::MERGE_PLAN::unresolved.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and DIALOG_KICAD_MERGE_3WAY::DIALOG_KICAD_MERGE_3WAY().

◆ ApplyProjectFilePatch() [1/2]

KICOMMON_API bool KICAD_DIFF::ApplyProjectFilePatch ( nlohmann::json & aTarget,
const nlohmann::json & aSource,
const wxString & aDocProp )

Definition at line 126 of file project_file_patch.cpp.

References ApplyProjectFilePatch(), and PCB.

◆ ApplyProjectFilePatch() [2/2]

KICOMMON_API bool KICAD_DIFF::ApplyProjectFilePatch ( nlohmann::json & aTarget,
const nlohmann::json & aSource,
const wxString & aDocProp,
DOC_KIND aKind )

Copy the JSON sub-tree located at the pointer for aDocProp from aSource into aTarget.

Returns
true iff aDocProp has a json-pointer mapping AND aSource contains the sub-tree. aTarget is left untouched on false.

This is the elemental decision-table entry that the handler iterates over. Pure function (no I/O), so each DOC_PROP mapping is unit-testable in isolation.

Definition at line 94 of file project_file_patch.cpp.

References DocPropJsonPointer().

Referenced by ApplyProjectFilePatch(), ApplyProjectFilePatches(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ ApplyProjectFilePatches() [1/2]

KICOMMON_API bool KICAD_DIFF::ApplyProjectFilePatches ( const wxString & aOutputProPath,
const nlohmann::json & aSource,
const std::set< wxString > & aDocProps )

Definition at line 199 of file project_file_patch.cpp.

References ApplyProjectFilePatches(), and PCB.

◆ ApplyProjectFilePatches() [2/2]

KICOMMON_API bool KICAD_DIFF::ApplyProjectFilePatches ( const wxString & aOutputProPath,
const nlohmann::json & aSource,
const std::set< wxString > & aDocProps,
DOC_KIND aKind )

Higher-level orchestrator: load the existing aOutputProPath as JSON (or start from aSource if the file doesn't exist), apply each DOC_PROP patch from aSource via ApplyProjectFilePatch, and write the result back to aOutputProPath.

Empty aDocProps is a no-op and does not create aOutputProPath.

Returns
true on success; false if the output file existed but couldn't be parsed, if any requested field is missing from aSource, or if the final write failed.

This is the path the merge handler should use in place of a full SaveProjectCopy when the goal is to surgically patch the diffed fields.

Definition at line 134 of file project_file_patch.cpp.

References ApplyProjectFilePatch(), and KIPLATFORM::IO::AtomicWriteFile().

Referenced by ApplyProjectFilePatches(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), PCBNEW_JOBS_HANDLER::runPcbMerge(), and EESCHEMA_JOBS_HANDLER::runSchMerge().

◆ ApplyPropertyResolutions()

PROPERTY_APPLY_COUNTS KICAD_DIFF::ApplyPropertyResolutions ( INSPECTABLE * aTarget,
const std::vector< PROPERTY_RESOLUTION > & aProps,
const INSPECTABLE * aOurs,
const INSPECTABLE * aTheirs,
const INSPECTABLE * aAncestor )
inline

Apply per-property merge resolutions to aTarget, sourcing OURS/THEIRS/ANCESTOR values from the matching source item and CUSTOM values from the resolution payload.

Works on any INSPECTABLE so PCB and schematic appliers share it.

Header-only for the same reason as DiffItemProperties: it reaches PROPERTY_MANAGER / INSPECTABLE, which live in the common static library.

A property is counted as failed when it is missing on the target type, is read-only, names a source side that wasn't supplied, carries a CUSTOM value of DIFF_VALUE::T::NONE, or its Set() call is rejected by the target.

Definition at line 202 of file property_diff.h.

References ANCESTOR, KICAD_DIFF::PROPERTY_APPLY_COUNTS::applied, CUSTOM, DiffValueToWxAny(), KICAD_DIFF::PROPERTY_APPLY_COUNTS::failed, PROPERTY_MANAGER::GetProperty(), PROPERTY_MANAGER::Instance(), OURS, res, INSPECTABLE::Set(), THEIRS, traceDiffMerge, TYPE_HASH, and PROPERTY_BASE::Writeable().

Referenced by KICAD_DIFF::PCB_MERGE_APPLIER::applyPropertyResolutions(), and KICAD_DIFF::SCH_MERGE_APPLIER::applyPropertyResolutions().

◆ BBoxFromGeometry()

KICOMMON_API std::optional< BOX2I > KICAD_DIFF::BBoxFromGeometry ( const DOCUMENT_GEOMETRY & aGeometry)

Compute the tight bounding box of a DOCUMENT_GEOMETRY, inflating each primitive by half its stroke so the bbox actually contains the rendered pixels.

Returns std::nullopt for an empty geometry so callers can distinguish "no shapes" from "shapes that collapsed to a degenerate box at origin".

Pure function — exposed so headless renderers and tests can reason about the bbox without instantiating a full DIFF_SCENE.

Definition at line 284 of file diff_scene.cpp.

References KICAD_DIFF::DOCUMENT_CIRCLE::center, KICAD_DIFF::DOCUMENT_GEOMETRY::circles, EffectivePlotWidth(), KICAD_DIFF::DOCUMENT_SEGMENT::end, KICAD_DIFF::DOCUMENT_CIRCLE::lineWidth, KICAD_DIFF::DOCUMENT_POLYGON::lineWidth, KICAD_DIFF::DOCUMENT_POLYGON::outline, pad, KICAD_DIFF::DOCUMENT_GEOMETRY::polygons, KICAD_DIFF::DOCUMENT_CIRCLE::radius, KICAD_DIFF::DOCUMENT_GEOMETRY::segments, KICAD_DIFF::DOCUMENT_SEGMENT::start, and KICAD_DIFF::DOCUMENT_SEGMENT::width.

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(), and ExpandBBoxToGeometry().

◆ BuildChangeTreeGroups()

KICOMMON_API std::vector< CHANGE_TREE_GROUP > KICAD_DIFF::BuildChangeTreeGroups ( const DOCUMENT_DIFF & aDiff,
const wxString & aSearchFilter,
const std::array< bool, CATEGORY_COUNT > & aVisibleCategories )

Group the changes in a DOCUMENT_DIFF by kind, apply category and search filters, and return the resulting tree structure for a UI to render.

Recursion into ITEM_CHANGE::children is automatic — nested footprint pads, sub-sheet symbols, etc. each appear as their own entry under the appropriate kind bucket. PCB routing changes (tracks/arcs/vias) with the same net-name refdes are collapsed into a single NET [name] entry per kind for display only.

aVisibleCategories is indexed by static_cast<size_t>( CATEGORY ); a kind whose CategoryFor() maps to a hidden category is dropped entirely. aSearchFilter is the raw user input — this function lowercases it once internally and passes the result to ChangeMatchesSearchFilter.

Buckets with zero visible entries after filtering are omitted from the result (the UI doesn't show empty groups).

Pure function — no I/O, no wx widget interaction, no globals.

Definition at line 65 of file diff_tree_grouping.cpp.

References CategoryFor(), ChangeDisplayLabel(), ChangeKindLabel(), ChangeMatchesSearchFilter(), KICAD_DIFF::DOCUMENT_DIFF::changes, KICAD_DIFF::ITEM_CHANGE::children, KICAD_DIFF::DOCUMENT_DIFF::docType, and IsRoutingNetChange().

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(), and DIALOG_KICAD_DIFF::buildTree().

◆ BuildConflictDetailText()

KICOMMON_API wxString KICAD_DIFF::BuildConflictDetailText ( const ITEM_RESOLUTION & aResolution)

Build the human-readable detail text shown in the merge dialog's resolution panel for a given ITEM_RESOLUTION.

Output format: "Item id: <KIID_PATH>\nCurrent resolution: <kind label>\n\n <N> property edit(s) in this resolution.\n"

The kind labels are locale-aware (_(...)). Pure dispatch + text formatting; useful for any UI surface displaying a resolution's summary.

Definition at line 248 of file auto_resolution.cpp.

References _, KIID_PATH::AsString(), DELETE_ITEM, KICAD_DIFF::ITEM_RESOLUTION::id, KEEP, KICAD_DIFF::ITEM_RESOLUTION::kind, MERGE_PROPS, KICAD_DIFF::ITEM_RESOLUTION::props, TAKE_ANCESTOR, TAKE_OURS, TAKE_THEIRS, and text.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and DIALOG_KICAD_MERGE_3WAY::showConflict().

◆ BuildConflictList()

◆ BuildScene()

KICOMMON_API DIFF_SCENE KICAD_DIFF::BuildScene ( const DOCUMENT_DIFF & aDiff,
const DIFF_COLOR_THEME & aTheme )

Build a DIFF_SCENE from a DOCUMENT_DIFF, populating the shape lists and computing the union bbox.

Items whose bbox is empty are skipped (no meaningful rectangle to draw).

For nested ITEM_CHANGEs (footprint children), each child contributes its own bbox; the parent's bbox is also added so the overall enclosing area still shows up. PCB routing changes (tracks/arcs/vias) that carry the same net-name refdes are collapsed into one net-level shape per kind for display only; the underlying DOCUMENT_DIFF remains item-keyed for merge.

Definition at line 422 of file diff_scene.cpp.

References KICAD_DIFF::DIFF_SCENE::addedShapes, KICAD_DIFF::DOCUMENT_DIFF::changes, KICAD_DIFF::DIFF_SCENE::conflictShapes, KICAD_DIFF::DIFF_SCENE::documentBBox, KICAD_DIFF::DIFF_SCENE::modifiedShapes, KICAD_DIFF::DIFF_SCENE::removedShapes, and traceDiffMerge.

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(), DIALOG_KICAD_DIFF::DIALOG_KICAD_DIFF(), EmitDiffResult(), and DIALOG_KICAD_DIFF::Reload().

◆ CategoryFor()

KICOMMON_API CATEGORY KICAD_DIFF::CategoryFor ( CHANGE_KIND aKind)

Map a CHANGE_KIND to the visual category it belongs to.

Both COLLISION and DUPLICATE_UUID land on CONFLICT.

Definition at line 529 of file diff_scene.cpp.

References ADDED, COLLISION, DUPLICATE_UUID, MODIFIED, and REMOVED.

Referenced by BOOST_AUTO_TEST_CASE(), and BuildChangeTreeGroups().

◆ ChangeDisplayLabel()

KICOMMON_API wxString KICAD_DIFF::ChangeDisplayLabel ( const ITEM_CHANGE & aChange)

User-facing item label used consistently by scene tooltips and change tree entries.

Format: typeName or typeName [refdes].

Definition at line 411 of file diff_scene.cpp.

References KICAD_DIFF::ITEM_CHANGE::refdes, and KICAD_DIFF::ITEM_CHANGE::typeName.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BuildChangeTreeGroups().

◆ ChangeInvalidatesZone()

bool KICAD_DIFF::ChangeInvalidatesZone ( const ITEM_CHANGE & aChange)
inline

Whether a change to an item of the given type invalidates any overlapping filled zones.

Drives MERGE_PLAN::requiresZoneRefill so the merge driver knows to re-run the filler before saving.

Pure function of the type name — does not look at the change contents, because even a property edit on (say) a track changes its keepout influence on the zone fill. Returns false for classes whose zone-affecting status depends on layer (PCB_TEXT, PCB_SHAPE on copper are knockouts but on silkscreen are not); the type-name-only signature can't distinguish, and silkscreen edits are common enough that the conservative choice is to skip the (slow) refill and let the user trigger one manually if they edited copper graphics.

Definition at line 398 of file kicad_diff_types.h.

References KICAD_DIFF::ITEM_CHANGE::typeName.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and KICAD_DIFF::KICAD_MERGE_ENGINE::Plan().

◆ ChangeKindFromString()

KICOMMON_API CHANGE_KIND KICAD_DIFF::ChangeKindFromString ( const std::string & aKind)

◆ ChangeKindLabel()

KICOMMON_API wxString KICAD_DIFF::ChangeKindLabel ( CHANGE_KIND aKind)

Human-readable label for a CHANGE_KIND (e.g.

"Added", "Removed", "Modified", "Collision", "Duplicate ID"). Goes through the wx translation machinery via _() so the result is locale-aware.

Pure dispatch over the enum; useful as a standalone helper for any UI surface that displays change kinds.

Definition at line 33 of file diff_tree_grouping.cpp.

References _, ADDED, COLLISION, DUPLICATE_UUID, MODIFIED, and REMOVED.

Referenced by BOOST_AUTO_TEST_CASE(), BuildChangeTreeGroups(), and DIALOG_KICAD_DIFF::showChange().

◆ ChangeKindToString()

KICOMMON_API const char * KICAD_DIFF::ChangeKindToString ( CHANGE_KIND aKind)

◆ ChangeMatchesSearchFilter()

KICOMMON_API bool KICAD_DIFF::ChangeMatchesSearchFilter ( const ITEM_CHANGE & aChange,
const wxString & aLowercaseFilter )

Predicate: does this item change match the active search filter?

Match rule: filter empty -> true; otherwise the lowercased filter must appear as a substring of the item's typeName.Lower() or, if the item has a refdes, the refdes lowercased. aFilter is expected to already be lowercased by the caller — this lets repeated calls over a list avoid re-lowercasing the same string.

Definition at line 48 of file diff_tree_grouping.cpp.

References KICAD_DIFF::ITEM_CHANGE::refdes, 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(), and BuildChangeTreeGroups().

◆ ChangeRequiresConnectivityRebuild()

bool KICAD_DIFF::ChangeRequiresConnectivityRebuild ( const ITEM_CHANGE & aChange)
inline

Whether a change to an item of the given type requires the connectivity graph to be rebuilt.

Drives MERGE_PLAN::requiresConnectivityRebuild so the merge driver knows to re-derive netlists / from-tos before saving.

Like ChangeInvalidatesZone, this is a pure function of the type name — any change to a connectable object can shift connectivity.

Note
The set below is the canonical list of net-carrying / connection- marker class names. Keep common/diff_merge/README.md in sync (the "Pure index + predicate helpers" section claims this is the complete list); the QA test ChangeRequiresConnectivityRebuild_NetCarriers enumerates every entry and trips if one is dropped.

Definition at line 423 of file kicad_diff_types.h.

References KICAD_DIFF::ITEM_CHANGE::typeName.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and KICAD_DIFF::KICAD_MERGE_ENGINE::Plan().

◆ CheckConnectivityRebuildFlag()

KICOMMON_API VALIDATION_REPORT KICAD_DIFF::CheckConnectivityRebuildFlag ( bool aPlanRequiredRebuild,
bool aApplierReportedRebuild )

Information needed for the connectivity-rebuild side-effect check.

The merge engine sets MERGE_PLAN::requiresConnectivityRebuild when a connectivity-affecting item changes. The applier must have called the appropriate rebuild before the merged document is written; this validator is a guard against missed rebuilds.

Definition at line 93 of file merge_validators.cpp.

References KICAD_DIFF::VALIDATION_REPORT::failures, KICAD_DIFF::VALIDATION_FAILURE::message, RPT_SEVERITY_ERROR, KICAD_DIFF::VALIDATION_FAILURE::severity, and KICAD_DIFF::VALIDATION_FAILURE::validator.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and RunPostApplyValidators().

◆ CheckRefdesUniqueness()

◆ CheckSchemaVersions()

KICOMMON_API VALIDATION_REPORT KICAD_DIFF::CheckSchemaVersions ( int aAncestorVersion,
int aOursVersion,
int aTheirsVersion )

Schema-version compatibility check: every input to the merge must use a compatible serialization version.

Mismatches are surfaced as ERROR so the caller can refuse the merge before producing a file the loaders won't read.

Definition at line 112 of file merge_validators.cpp.

References KICAD_DIFF::VALIDATION_REPORT::failures, KICAD_DIFF::VALIDATION_FAILURE::message, RPT_SEVERITY_ERROR, RPT_SEVERITY_WARNING, KICAD_DIFF::VALIDATION_FAILURE::severity, and KICAD_DIFF::VALIDATION_FAILURE::validator.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and RunPostApplyValidators().

◆ CollectBoardDiffContextItems()

std::vector< KIGFX::VIEW_ITEM * > KICAD_DIFF::CollectBoardDiffContextItems ( BOARD & aBoard)

◆ CollectChangeBBoxes()

KICOMMON_API void KICAD_DIFF::CollectChangeBBoxes ( const DOCUMENT_DIFF & aDiff,
std::map< KIID_PATH, BOX2I > & aOut )

Walk a DOCUMENT_DIFF and populate a (KIID_PATHBOX2I) map with each changed item's bbox, recursing into nested children.

Empty bboxes are skipped. emplace is used so existing entries in aOut are preserved when the same key appears more than once across siblings. Used by the 3-way merge dialog to look up where conflicts live for per-side highlight.

Definition at line 471 of file diff_scene.cpp.

References IndexChangesByKiid().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), PCBNEW_JOBS_HANDLER::runPcbMerge(), and EESCHEMA_JOBS_HANDLER::runSchMerge().

◆ CollectFootprintDiffContextItems()

std::vector< KIGFX::VIEW_ITEM * > KICAD_DIFF::CollectFootprintDiffContextItems ( FOOTPRINT & aFootprint)

◆ CollectSchematicDiffContextItems()

std::vector< KIGFX::VIEW_ITEM * > KICAD_DIFF::CollectSchematicDiffContextItems ( SCHEMATIC & aSchematic,
SCH_SCREEN * aScreen )

◆ CollectTopLevelIds()

void KICAD_DIFF::CollectTopLevelIds ( const BOARD * aBoard,
std::set< KIID > & aOut )
inline

Insert every top-level item UUID from aBoard into aOut.

"Top-level" excludes footprint children (pads, fields, graphical items, zones) – those are handled implicitly when the parent footprint is cloned by the applier. Promoted from the per-applier lambda so other PCB-side merge tooling (auto-resolution, planner) can share the same walk without re-implementing the const-cast dance over BOARD::GetItemSet.

Definition at line 47 of file applier_helpers.h.

References BOARD::GetItemSet().

Referenced by KICAD_DIFF::PCB_MERGE_APPLIER::Apply(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ CollectUnresolvedConflicts()

KICOMMON_API std::vector< KIID_PATH > KICAD_DIFF::CollectUnresolvedConflicts ( const MERGE_PLAN & aPlan,
const std::vector< std::size_t > & aConflictActionIndices )

Return the subset of conflict actions whose kind is NOT one of the concrete TAKE_OURS / TAKE_THEIRS / TAKE_ANCESTOR — the dialog uses this to refuse Apply when the user hasn't picked a side on every conflict.

KEEP / MERGE_PROPS at that point mean the engine's default is still in effect, which silently loses user intent.

Definition at line 187 of file auto_resolution.cpp.

References KICAD_DIFF::MERGE_PLAN::actions, KICAD_DIFF::ITEM_RESOLUTION::id, KICAD_DIFF::ITEM_RESOLUTION::kind, TAKE_ANCESTOR, TAKE_OURS, and TAKE_THEIRS.

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(), and DIALOG_KICAD_MERGE_3WAY::OnApply().

◆ ConfigurePcbDiffCanvasContext()

◆ ConfigurePcbDiffContextRenderSettings()

◆ ConfigureSchDiffCanvasContext()

void KICAD_DIFF::ConfigureSchDiffCanvasContext ( WIDGET_DIFF_CANVAS & aCanvas,
SCHEMATIC * aReference,
SCHEMATIC * aComparison,
const KIGFX::COLOR4D & aColor,
const std::map< KIID, KIGFX::COLOR4D > & aOverrides,
const std::vector< KIGFX::VIEW_ITEM * > & aExtraItems,
const std::map< KIID, KICAD_DIFF::CATEGORY > & aCategories,
SCH_SCREEN * aReferenceScreen,
SCH_SCREEN * aComparisonScreen )

◆ ConfigureSchDiffContextRenderSettings()

◆ ConfigureSymDiffCanvasContext()

◆ DiffExitCode()

int KICAD_DIFF::DiffExitCode ( const DOCUMENT_DIFF & aResult)

Map a computed diff onto its CLI exit code – SUCCESS when empty, otherwise ERR_RC_VIOLATIONS.

Definition at line 54 of file diff_job_output.cpp.

References KICAD_DIFF::DOCUMENT_DIFF::Empty(), CLI::EXIT_CODES::ERR_RC_VIOLATIONS, and CLI::EXIT_CODES::SUCCESS.

Referenced by PCBNEW_JOBS_HANDLER::JobDiff(), PCBNEW_JOBS_HANDLER::JobFpDiff(), EESCHEMA_JOBS_HANDLER::JobSchDiff(), and EESCHEMA_JOBS_HANDLER::JobSymDiff().

◆ DiffItemProperties()

std::vector< PROPERTY_DELTA > KICAD_DIFF::DiffItemProperties ( const INSPECTABLE * aBefore,
const INSPECTABLE * aAfter )
inline

Enumerate the property deltas between two items of the same dynamic type.

Walks the PROPERTY_MANAGER properties for the items' shared type, skipping hidden and context-unavailable properties, and emits one PROPERTY_DELTA per value that differs (compared via KiWxAnyEquals, converted via WxAnyToDiffValue). Returns an empty vector when the items are null or of differing types. The result is sorted alphabetically by property name for deterministic output.

Header-only because it reaches PROPERTY_MANAGER / INSPECTABLE, which live in the common static library rather than kicommon; instantiating it in the caller's translation unit keeps the dependency where it belongs.

Callers that need a property-resolution scope (e.g. a schematic sheet path) must establish it around the call; this helper only reads the live items.

Definition at line 64 of file property_diff.h.

References KICAD_DIFF::PROPERTY_DELTA::after, KICAD_DIFF::PROPERTY_DELTA::before, INSPECTABLE::Get(), PROPERTY_MANAGER::GetProperties(), KICAD_DIFF::DIFF_VALUE::GetType(), PROPERTY_MANAGER::Instance(), PROPERTY_MANAGER::IsAvailableFor(), KiWxAnyEquals(), KICAD_DIFF::PROPERTY_DELTA::name, KICAD_DIFF::DIFF_VALUE::NONE, TYPE_HASH, and WxAnyToDiffValue().

Referenced by KICAD_DIFF::SYM_LIB_DIFFER::Diff(), KICAD_DIFF::PCB_DIFFER::diffProperties(), KICAD_DIFF::SCH_DIFFER::diffProperties(), and DiffSymbolElements().

◆ DiffLibraryByName()

template<typename MAP, typename BBoxFn, typename ChangedFn>
DOCUMENT_DIFF KICAD_DIFF::DiffLibraryByName ( const MAP & aBefore,
const MAP & aAfter,
const wxString & aPath,
const wxString & aDocType,
const wxString & aTypeName,
const KICAD_DIFFER::OPTIONS & aOptions,
BBoxFn aBBox,
ChangedFn aChanged )

Shared name-keyed library diff used by FP_LIB_DIFFER and SYM_LIB_DIFFER.

Walks the union of names in aBefore and aAfter, classifying each entry as ADDED, REMOVED, or MODIFIED. aBBox yields the bounding box stored on each change; aChanged decides whether two present items differ. Library files aren't UUID-keyed, so each change's id is the deterministic synthetic LibraryItemKiidPath( name ) the appliers look up by.

Definition at line 94 of file kicad_differ.h.

References ADDED, KICAD_DIFF::ITEM_CHANGE::bbox, KICAD_DIFF::ITEM_CHANGE::id, KICAD_DIFF::ITEM_CHANGE::kind, LibraryItemKiidPath(), MODIFIED, name, KICAD_DIFF::KICAD_DIFFER::OPTIONS::progress, KICAD_DIFF::ITEM_CHANGE::refdes, REMOVED, result, and KICAD_DIFF::ITEM_CHANGE::typeName.

Referenced by KICAD_DIFF::FP_LIB_DIFFER::Diff(), and KICAD_DIFF::SYM_LIB_DIFFER::Diff().

◆ DiffSymbolElements()

std::vector< SYM_ELEMENT > KICAD_DIFF::DiffSymbolElements ( const LIB_SYMBOL * aBefore,
const LIB_SYMBOL * aAfter )

Compares the elements of two library symbols.

Pins match by number and fields by name. Graphics and text first match identical shapes, then pair up the leftovers so an edited shape reads as modified. Only changed elements are returned. Either symbol may be null for a whole symbol add or remove.

Definition at line 143 of file sym_item_diff.cpp.

References _, ADDED, delta, DiffItemProperties(), empty(), EDA_ITEM::GetPosition(), ItemProperties(), MODIFIED, REMOVED, and EDA_ITEM::Type().

Referenced by ConfigureSymDiffCanvasContext(), and KICAD_DIFF::SYM_LIB_DIFFER::Diff().

◆ DiffValueToWxAny()

KICOMMON_API bool KICAD_DIFF::DiffValueToWxAny ( const DIFF_VALUE & aValue,
wxAny & aOut )

Convert a DIFF_VALUE back into a wxAny a PROPERTY_BASE setter can consume.

This is the inverse direction of WxAnyToDiffValue, used by the merge appliers when a CUSTOM resolution carries a user-edited value that must be written onto the merged item.

Returns false (leaving aOut untouched) for DIFF_VALUE::T::NONE, which carries no value; returns true for every other variant after populating aOut with the matching wxAny payload.

Definition at line 223 of file property_value_converter.cpp.

References KICAD_DIFF::DIFF_VALUE::AsBool(), KICAD_DIFF::DIFF_VALUE::AsBox2I(), KICAD_DIFF::DIFF_VALUE::AsColor(), KICAD_DIFF::DIFF_VALUE::AsDouble(), KICAD_DIFF::DIFF_VALUE::AsEnum(), KICAD_DIFF::DIFF_VALUE::AsInt(), KICAD_DIFF::DIFF_VALUE::AsInt64(), KICAD_DIFF::DIFF_VALUE::AsKiid(), KICAD_DIFF::DIFF_VALUE::AsLayer(), KICAD_DIFF::DIFF_VALUE::AsString(), KICAD_DIFF::DIFF_VALUE::AsVector2I(), KICAD_DIFF::DIFF_VALUE::BOOL, KICAD_DIFF::DIFF_VALUE::BOX2I, KICAD_DIFF::DIFF_VALUE::COLOR, KICAD_DIFF::DIFF_VALUE::DOUBLE, KICAD_DIFF::DIFF_VALUE::ENUM, KICAD_DIFF::DIFF_VALUE::GetType(), KICAD_DIFF::DIFF_VALUE::INT, KICAD_DIFF::DIFF_VALUE::INT64, KICAD_DIFF::DIFF_VALUE::KIID, KICAD_DIFF::DIFF_VALUE::LAYER, KICAD_DIFF::DIFF_VALUE::NONE, KICAD_DIFF::DIFF_VALUE::POLYGON_SET, KICAD_DIFF::DIFF_VALUE::STRING, and KICAD_DIFF::DIFF_VALUE::VECTOR2I.

Referenced by ApplyPropertyResolutions(), 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(), and BOOST_AUTO_TEST_CASE().

◆ DispatchMerge()

KICOMMON_API int KICAD_DIFF::DispatchMerge ( KIWAY & aKiway,
DOC_KIND aKind,
const wxString & aAncestor,
const wxString & aOurs,
const wxString & aTheirs,
const wxString & aOutput,
bool aInteractive,
bool aSingleFile,
REPORTER * aReporter )

Run a 3-way document/library merge by calling the owning kiface's KIFACE_MERGE_DOCUMENT function export (chosen from aKind).

This is the non-job bridge used by the CLI merge subcommands and the mergetool frame.

Returns
the kiface's CLI exit code, or ERR_UNKNOWN if the kiface or its export is unavailable.

Definition at line 53 of file merge_dispatch.cpp.

References CLI::EXIT_CODES::ERR_UNKNOWN, KIWAY::KiFACE(), kiface(), and KIFACE_MERGE_DOCUMENT.

Referenced by CLI::GIT_MERGEDRIVER_COMMAND::doPerform(), and MERGETOOL_FRAME::RunMerge().

◆ DispatchOpenDiffDialog()

KICOMMON_API int KICAD_DIFF::DispatchOpenDiffDialog ( KIWAY & aKiway,
DOC_KIND aKind,
const wxString & aFileA,
const wxString & aFileB,
const wxString & aLabelA,
const wxString & aLabelB,
wxWindow * aParent,
REPORTER * aReporter = nullptr )

Open DIALOG_KICAD_DIFF on two files by calling the owning kiface's KIFACE_OPEN_DIFF_DIALOG function export (chosen from aKind).

Non-job bridge used by the MR-review dialog.

Returns
the kiface's exit code, or ERR_UNKNOWN if unavailable.

Definition at line 75 of file merge_dispatch.cpp.

References CLI::EXIT_CODES::ERR_UNKNOWN, KIWAY::KiFACE(), kiface(), and KIFACE_OPEN_DIFF_DIALOG.

Referenced by DIALOG_GIT_MR_REVIEW::openFileDiff().

◆ DocKindFromExtension()

KICOMMON_API DOC_KIND KICAD_DIFF::DocKindFromExtension ( const wxString & aPath)

Map a path's extension to a DOC_KIND (.kicad_pcb -> PCB, .kicad_sch -> SCH, .kicad_sym -> SYM_LIB, .kicad_mod -> FOOTPRINT; anything else -> UNKNOWN).

Definition at line 34 of file diff_doc_kind.cpp.

References FOOTPRINT, FILEEXT::KiCadFootprintFileExtension, FILEEXT::KiCadPcbFileExtension, FILEEXT::KiCadSchematicFileExtension, FILEEXT::KiCadSymbolLibFileExtension, PCB, SCH, SYM_LIB, and UNKNOWN.

Referenced by CLI::MERGETOOL_COMMAND::doPerform(), DIALOG_GIT_MR_REVIEW::openFileDiff(), and MERGETOOL_FRAME::RunMerge().

◆ DocPropJsonPointer() [1/2]

KICOMMON_API std::optional< std::string > KICAD_DIFF::DocPropJsonPointer ( const wxString & aDocProp)

Definition at line 88 of file project_file_patch.cpp.

References DocPropJsonPointer(), and PCB.

◆ DocPropJsonPointer() [2/2]

KICOMMON_API std::optional< std::string > KICAD_DIFF::DocPropJsonPointer ( const wxString & aDocProp,
DOC_KIND aKind )

Return the JSON pointer (RFC 6901, slash-separated) under which aDocProp is persisted in a .kicad_pro project file.

Returns an empty optional for DOC_PROP values that do NOT live in .kicad_pro – those go to sibling files (.kicad_dru, fp-lib-table, sym-lib-table) or to the document file (.kicad_pcb / .kicad_sch). The caller is responsible for routing those separately.

Used by the 3-way merge handler to surgically patch only the diffed fields of the output .kicad_pro, preserving any non-diffed user customisations the existing output file may carry (text variables, private layouts, last-paths, etc.). The previous full-copy approach silently overwrote those fields with ancestor's values.

Definition at line 82 of file project_file_patch.cpp.

Referenced by ApplyProjectFilePatch(), 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(), and DocPropJsonPointer().

◆ EffectivePlotWidth()

int KICAD_DIFF::EffectivePlotWidth ( int aWidth)
constexpr

Return aWidth if positive, otherwise PLOT_HAIRLINE_IU.

Pure helper used by the plotter's polygon/segment/circle paths to keep them in lock-step on the "what does width<=0 mean" rule.

Definition at line 91 of file diff_renderer_plotter.h.

References PLOT_HAIRLINE_IU.

Referenced by BBoxFromGeometry(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ EmitDiffResult()

int KICAD_DIFF::EmitDiffResult ( const DOCUMENT_DIFF & aResult,
const DIFF_EMIT_OPTIONS & aOptions,
int aDiffExitCode,
REPORTER & aReporter )

◆ ExpandBBoxToGeometry()

KICOMMON_API void KICAD_DIFF::ExpandBBoxToGeometry ( DIFF_SCENE & aScene)

Grow the scene's documentBBox to also include the extent of any background geometry.

Called by callers that populated referenceGeometry / comparison- Geometry after BuildScene — without this the initial fit-to-view would clip the geometry to the change cluster's bbox.

Definition at line 445 of file diff_scene.cpp.

References BBoxFromGeometry(), KICAD_DIFF::DIFF_SCENE::comparisonGeometry, KICAD_DIFF::DIFF_SCENE::documentBBox, BOX2< Vec >::GetHeight(), BOX2< Vec >::GetWidth(), and KICAD_DIFF::DIFF_SCENE::referenceGeometry.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), DIALOG_KICAD_DIFF::DIALOG_KICAD_DIFF(), DIALOG_KICAD_MERGE_3WAY::rebuildCanvas(), DIALOG_KICAD_DIFF::Reload(), RenderSceneToPng(), and RenderSceneToSvg().

◆ ExtractBoardGeometry()

DOCUMENT_GEOMETRY KICAD_DIFF::ExtractBoardGeometry ( const BOARD & aBoard,
const KIGFX::COLOR4D & aColor )

Extract a coarse outline of a BOARD into a DOCUMENT_GEOMETRY for use as background context in DIFF_SCENE rendering.

The extractor pulls the most informative shapes without redrawing the whole board:

  • Edge.Cuts segments / arcs / circles / polys → segments + circles
  • Tracks / vias → segments + circles
  • Pads / zones → bounding-box outlines
  • Footprint bounding boxes → outline polygons
  • User drawings on doc layers → segments

Color is taken from the supplied palette (typically theme.reference or theme.comparison depending on which side the board represents). Each emitted primitive carries its PCB layer set so the diff canvas can filter board context by selected layer.

Definition at line 237 of file pcb_geometry_extractor.cpp.

References B_SilkS, Cmts_User, BOARD::Drawings(), Dwgs_User, Eco1_User, Eco2_User, Edge_Cuts, F_SilkS, FOOTPRINT, BOARD::Footprints(), PCB_SHAPE::GetLayer(), BOARD::GetPads(), KICAD_DIFF::DOCUMENT_POLYGON::layers, MakeBBoxOutline(), KICAD_DIFF::DOCUMENT_POLYGON::outline, pad, KICAD_DIFF::DOCUMENT_GEOMETRY::polygons, BOARD::Tracks(), and BOARD::Zones().

Referenced by BOOST_AUTO_TEST_CASE(), PCBNEW_JOBS_HANDLER::JobDiff(), PCBNEW_JOBS_HANDLER::OpenDiffDialog(), and PCBNEW_JOBS_HANDLER::runPcbMerge().

◆ ExtractFootprintGeometry()

DOCUMENT_GEOMETRY KICAD_DIFF::ExtractFootprintGeometry ( const FOOTPRINT & aFootprint,
const KIGFX::COLOR4D & aColor )

◆ ExtractSchematicGeometry()

DOCUMENT_GEOMETRY KICAD_DIFF::ExtractSchematicGeometry ( const SCHEMATIC & aSchematic,
const KIGFX::COLOR4D & aColor,
const std::map< KIID, KIGFX::COLOR4D > & aOverrides = {},
bool aOnlyOverrides = false )

Extract a coarse outline of a SCHEMATIC into a DOCUMENT_GEOMETRY for use as background context in DIFF_SCENE rendering.

The extractor walks every sheet's screen and pulls the most informative shapes:

Color is taken from the supplied palette (typically theme.reference or theme.comparison depending on which side the schematic represents).

Definition at line 137 of file sch_geometry_extractor.cpp.

References SCHEMATIC::Hierarchy().

Referenced by BOOST_AUTO_TEST_CASE(), SCH_INSPECTION_TOOL::CompareSchematicWithHistory(), EESCHEMA_JOBS_HANDLER::JobSchDiff(), EESCHEMA_JOBS_HANDLER::OpenDiffDialog(), EESCHEMA_JOBS_HANDLER::runSchMerge(), and SCH_INSPECTION_TOOL::showSchematicComparison().

◆ ExtractSymbolGeometry()

DOCUMENT_GEOMETRY KICAD_DIFF::ExtractSymbolGeometry ( const LIB_SYMBOL & aSymbol,
const KIGFX::COLOR4D & aColor,
int aUnit = 0,
int aBodyStyle = 0 )

Extract coarse drawable context from a library symbol for visual symbol diffs.

The optional unit/body style filters mirror LIB_SYMBOL display selection; zero means include all.

Definition at line 158 of file sch_geometry_extractor.cpp.

References KICAD_DIFF::DOCUMENT_GEOMETRY::Empty(), LIB_SYMBOL::GetDrawItems(), and LIB_SYMBOL::GetUnitBoundingBox().

Referenced by BOOST_AUTO_TEST_CASE(), and symbolLibraryGeometry().

◆ FilterGeometryByVisibleLayers()

KICOMMON_API DOCUMENT_GEOMETRY KICAD_DIFF::FilterGeometryByVisibleLayers ( const DOCUMENT_GEOMETRY & aGeometry,
const LSET & aVisibleLayers )

Copy geometry primitives whose layer set intersects aVisibleLayers.

Layerless primitives are preserved so schematic/context geometry without PCB layer metadata does not disappear when board-layer filtering is active.

Definition at line 361 of file diff_scene.cpp.

References KICAD_DIFF::DOCUMENT_GEOMETRY::circles, KICAD_DIFF::DOCUMENT_CIRCLE::layers, KICAD_DIFF::DOCUMENT_POLYGON::layers, KICAD_DIFF::DOCUMENT_SEGMENT::layers, KICAD_DIFF::DOCUMENT_GEOMETRY::polygons, and KICAD_DIFF::DOCUMENT_GEOMETRY::segments.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and WIDGET_DIFF_CANVAS::buildRenderScene().

◆ FormatDiffAsText()

KICOMMON_API std::string KICAD_DIFF::FormatDiffAsText ( const DOCUMENT_DIFF & aDiff,
const wxString & aLabelA,
const wxString & aLabelB,
EDA_UNITS aUnits,
const EDA_IU_SCALE & aScale )

Render a DOCUMENT_DIFF as the human-readable text report shared by the diff jobs and CLI: a diff <labelA> <labelB> header, the change count, then one indented line per change (recursing into footprint/sheet children) with property deltas printed as name: before -> after.

Property values are formatted in aUnits using aScale, so distance, coordinate and angle deltas render in user units (e.g. "0.25 mm") rather than raw internal units. Use IuScaleForDocKind() to pick the scale matching the source document.

Definition at line 807 of file kicad_diff_types.cpp.

References KICAD_DIFF::PROPERTY_DELTA::after, KIID_PATH::AsString(), KICAD_DIFF::PROPERTY_DELTA::before, ChangeKindToString(), KICAD_DIFF::DOCUMENT_DIFF::changes, KICAD_DIFF::ITEM_CHANGE::children, FormatDiffAsText(), KICAD_DIFF::ITEM_CHANGE::id, KICAD_DIFF::ITEM_CHANGE::kind, KICAD_DIFF::PROPERTY_DELTA::name, KICAD_DIFF::ITEM_CHANGE::properties, KICAD_DIFF::ITEM_CHANGE::refdes, KICAD_DIFF::DIFF_VALUE::ToDisplayString(), and KICAD_DIFF::ITEM_CHANGE::typeName.

Referenced by EmitDiffResult(), and FormatDiffAsText().

◆ GeometryLayerSet()

KICOMMON_API LSET KICAD_DIFF::GeometryLayerSet ( const DOCUMENT_GEOMETRY & aGeometry)

Return the union of every non-empty layer set carried by the geometry.

Layerless primitives are omitted; they are treated as always-visible context by FilterGeometryByVisibleLayers.

Definition at line 344 of file diff_scene.cpp.

References KICAD_DIFF::DOCUMENT_GEOMETRY::circles, KICAD_DIFF::DOCUMENT_CIRCLE::layers, KICAD_DIFF::DOCUMENT_POLYGON::layers, KICAD_DIFF::DOCUMENT_SEGMENT::layers, KICAD_DIFF::DOCUMENT_GEOMETRY::polygons, and KICAD_DIFF::DOCUMENT_GEOMETRY::segments.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and DIALOG_KICAD_DIFF::DIALOG_KICAD_DIFF().

◆ HighlightedBBox()

KICOMMON_API std::optional< BOX2I > KICAD_DIFF::HighlightedBBox ( const DIFF_SCENE & aScene,
const KIID_PATH & aChangeId,
const std::array< bool, CATEGORY_COUNT > & aCategoryVisible )

Union bbox of every visible SCENE_SHAPE whose changeId matches aChangeId.

Returns std::nullopt when no visible shape matches. Used by interactive viewers to zoom to the currently-highlighted change.

Definition at line 560 of file diff_scene.cpp.

References PAINT_ORDER, result, and ShapesFor().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and WIDGET_DIFF_CANVAS::highlightedBBox().

◆ IndexChangesByKiid()

KICOMMON_API std::map< KIID_PATH, const ITEM_CHANGE * > KICAD_DIFF::IndexChangesByKiid ( const DOCUMENT_DIFF & aDiff)

Flatten a DOCUMENT_DIFF's ITEM_CHANGE tree into a KIID_PATH -> ITEM_CHANGE* map, recursing into child changes.

Without the recursive walk, child conflicts (e.g. a pad edit inside a footprint with no top-level conflict) are invisible to downstream conflict detection.

Dedup: last-write-wins on duplicate keys (uses operator[] assignment). KIID_PATHs are unique by construction so duplicates shouldn't occur in practice, but a corrupt or hand-crafted diff with collisions surfaces the deeper / later entry.

Pointers reference items owned by aDiff — the map must not outlive the diff.

Definition at line 105 of file kicad_merge_engine.cpp.

References KICAD_DIFF::DOCUMENT_DIFF::changes, and index.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), CollectChangeBBoxes(), and KICAD_DIFF::KICAD_MERGE_ENGINE::Plan().

◆ IndexPropertiesByName()

KICOMMON_API std::map< wxString, const PROPERTY_DELTA * > KICAD_DIFF::IndexPropertiesByName ( const ITEM_CHANGE & aChange)

Index property deltas inside one ITEM_CHANGE by property name.

Last entry wins on duplicate names — callers must not rely on stability of which entry "wins" because the differ never emits duplicates.

Definition at line 116 of file kicad_merge_engine.cpp.

References index, KICAD_DIFF::PROPERTY_DELTA::name, and KICAD_DIFF::ITEM_CHANGE::properties.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and KICAD_DIFF::KICAD_MERGE_ENGINE::Plan().

◆ IsRoutingNetChange()

KICOMMON_API bool KICAD_DIFF::IsRoutingNetChange ( const ITEM_CHANGE & aChange)

Presentation predicate for PCB routing changes that should be displayed as one net-level entry/shape.

The underlying DOCUMENT_DIFF remains item-keyed; this only affects UI/rendering grouping.

Definition at line 403 of file diff_scene.cpp.

References KICAD_DIFF::ITEM_CHANGE::refdes, and KICAD_DIFF::ITEM_CHANGE::typeName.

Referenced by BOOST_AUTO_TEST_CASE(), BuildChangeTreeGroups(), and DIALOG_KICAD_DIFF::changeRowIds().

◆ isSheetItem()

static bool KICAD_DIFF::isSheetItem ( const SCH_ITEM * aItem)
static

True iff aItem is a SCH_SHEET.

Sheet-level operations require deep cloning the SCH_SHEET + SCH_SCREEN pair and rebuilding the path graph; the current applier skips them. Hoisted to file scope so the predicate is reusable across the multiple lambdas in Apply() that need it.

Definition at line 56 of file sch_merge_applier.cpp.

References SCH_SHEET_T, and EDA_ITEM::Type().

Referenced by KICAD_DIFF::SCH_MERGE_APPLIER::Apply().

◆ ItemProperties()

std::vector< PROPERTY_DELTA > KICAD_DIFF::ItemProperties ( const INSPECTABLE * aItem,
bool aAsAfter )
inline

List one item's properties as one-sided deltas for an added or removed item.

aAsAfter puts each value on the after side (added), else the before side (removed). The empty side stays NONE and renders as "<none>".

Definition at line 131 of file property_diff.h.

References KICAD_DIFF::PROPERTY_DELTA::after, KICAD_DIFF::DIFF_VALUE::AsString(), KICAD_DIFF::PROPERTY_DELTA::before, INSPECTABLE::Get(), PROPERTY_MANAGER::GetProperties(), KICAD_DIFF::DIFF_VALUE::GetType(), PROPERTY_MANAGER::Instance(), PROPERTY_MANAGER::IsAvailableFor(), KICAD_DIFF::PROPERTY_DELTA::name, KICAD_DIFF::DIFF_VALUE::NONE, KICAD_DIFF::DIFF_VALUE::STRING, TYPE_HASH, and WxAnyToDiffValue().

Referenced by KICAD_DIFF::SCH_DIFFER::Diff(), DiffSymbolElements(), and pcbAddedRemovedProperties().

◆ ItemResFromString()

KICOMMON_API ITEM_RES KICAD_DIFF::ItemResFromString ( const std::string & aStr)

◆ ItemResToString()

KICOMMON_API const char * KICAD_DIFF::ItemResToString ( ITEM_RES aRes)

Canonical snake_case spellings used in MERGE_PLAN JSON serialization (take_ours / take_theirs / take_ancestor / merge_props / delete / keep).

Reused by KICAD_MERGETOOL_AUTO so scripted resolutions can copy enum strings directly out of a plan JSON file.

Definition at line 60 of file kicad_merge_engine.cpp.

References DELETE_ITEM, KEEP, MERGE_PROPS, TAKE_ANCESTOR, TAKE_OURS, and TAKE_THEIRS.

Referenced by BOOST_AUTO_TEST_CASE(), and KICAD_DIFF::ITEM_RESOLUTION::ToJson().

◆ IterateDocumentGeometry()

void KICAD_DIFF::IterateDocumentGeometry ( const DOCUMENT_GEOMETRY & aGeometry,
GEOMETRY_SINK & aSink )
inline

Walk a DOCUMENT_GEOMETRY in the canonical render order shared by the GAL and plotter renderers: every polygon fill pass, every polygon stroke pass, then segments, then circles.

Empty geometry draws nothing. The sink decides how each primitive is drawn and which ones to skip.

Definition at line 200 of file diff_scene.h.

References circle(), KICAD_DIFF::DOCUMENT_GEOMETRY::circles, KICAD_DIFF::GEOMETRY_SINK::DrawCircle(), KICAD_DIFF::GEOMETRY_SINK::DrawSegment(), KICAD_DIFF::DOCUMENT_GEOMETRY::Empty(), KICAD_DIFF::GEOMETRY_SINK::FillPolygon(), KICAD_DIFF::DOCUMENT_GEOMETRY::polygons, KICAD_DIFF::DOCUMENT_GEOMETRY::segments, and KICAD_DIFF::GEOMETRY_SINK::StrokePolygon().

◆ IuScaleForDocKind()

const EDA_IU_SCALE & KICAD_DIFF::IuScaleForDocKind ( DOC_KIND aKind)
inline

Internal-unit scale a document kind's coordinates are expressed in.

PCB and footprint geometry are 1 nm/IU (pcbIUScale); schematic and symbol geometry are 100 nm/IU (schIUScale). The headless plotter renderer uses this to size its viewport so a schematic diff is not silently scaled by the PCB ratio.

Inline so both the renderer (in common) and kicommon callers share one mapping without a cross-library link dependency on base_units.

Definition at line 253 of file diff_scene.h.

References FOOTPRINT, FP_LIB, PCB, pcbIUScale, SCH, schIUScale, SYM_LIB, and UNKNOWN.

Referenced by EmitDiffResult(), RenderSceneToPng(), and RenderSceneToSvg().

◆ LibraryItemKiidPath()

KIID_PATH KICAD_DIFF::LibraryItemKiidPath ( const wxString & aName)
inline

Build a deterministic synthetic KIID_PATH from a library item name (symbol name or footprint name).

Library files aren't UUID-keyed; the engine API is. The naive KIID_PATH(name) falls into KIID(string)'s random-UUID fallback for any non-hex name, so two callsites produce different IDs for the same name. KIID::FromDeterministicString hashes the name into a UUID-shaped string so both callsites produce identical bytes.

Used by SYM_LIB_DIFFER / FP_LIB_DIFFER (differ side) and SYM_LIB_MERGE_APPLIER / FP_LIB_MERGE_APPLIER (applier side); they MUST share this mapping or item-resolution lookups silently miss.

Definition at line 126 of file kicad_diff_types.h.

References KIID::FromDeterministicString(), and path.

Referenced by KICAD_DIFF::LIB_MERGE_APPLIER< LIB_SYMBOL >::Apply(), 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(), and DiffLibraryByName().

◆ MakeBBoxOutline()

KICOMMON_API DOCUMENT_POLYGON KICAD_DIFF::MakeBBoxOutline ( const BOX2I & aBBox,
const KIGFX::COLOR4D & aColor,
int aLineWidth = 0 )

Build a DOCUMENT_POLYGON outlining a bounding box.

Convenience for extractors that want to emit an item's bbox as background context. Returns an empty polygon (no points) when the box is degenerate so callers can guard with !poly.outline.empty().

Definition at line 484 of file diff_scene.cpp.

References KICAD_DIFF::DOCUMENT_POLYGON::color, KICAD_DIFF::DOCUMENT_POLYGON::filled, BOX2< Vec >::GetEnd(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetOrigin(), BOX2< Vec >::GetWidth(), KICAD_DIFF::DOCUMENT_POLYGON::lineWidth, KICAD_DIFF::DOCUMENT_POLYGON::outline, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), ExtractBoardGeometry(), and ExtractFootprintGeometry().

◆ MakeEmitOptions()

DIFF_EMIT_OPTIONS KICAD_DIFF::MakeEmitOptions ( const JOB_DIFF_BASE & aJob,
const wxString & aLabelA,
const wxString & aLabelB )

Build a DIFF_EMIT_OPTIONS pre-filled from the job's format, resolved output path and the supplied per-side labels.

The geometry callbacks are left unset for the caller to assign, since they capture local scene data.

Definition at line 41 of file diff_job_output.cpp.

References KICAD_DIFF::DIFF_EMIT_OPTIONS::format, JOB::GetFullOutputPath(), KICAD_DIFF::DIFF_EMIT_OPTIONS::labelA, KICAD_DIFF::DIFF_EMIT_OPTIONS::labelB, JOB_DIFF_BASE::m_format, and KICAD_DIFF::DIFF_EMIT_OPTIONS::outputPath.

Referenced by PCBNEW_JOBS_HANDLER::JobDiff(), PCBNEW_JOBS_HANDLER::JobFpDiff(), EESCHEMA_JOBS_HANDLER::JobSchDiff(), and EESCHEMA_JOBS_HANDLER::JobSymDiff().

◆ MakePcbDiffContextPainter()

std::unique_ptr< KIGFX::PAINTER > KICAD_DIFF::MakePcbDiffContextPainter ( KIGFX::GAL * aGal,
const KIGFX::COLOR4D & aColor,
std::map< KIID, KIGFX::COLOR4D > aOverrides )

◆ MakeSchDiffContextPainter()

std::unique_ptr< KIGFX::PAINTER > KICAD_DIFF::MakeSchDiffContextPainter ( KIGFX::GAL * aGal,
SCHEMATIC * aSchematic,
const KIGFX::COLOR4D & aColor,
std::map< KIID, KIGFX::COLOR4D > aOverrides )

◆ ParseAutoResolutionJson()

KICOMMON_API AUTO_RESOLUTION_PARSE_RESULT KICAD_DIFF::ParseAutoResolutionJson ( const std::string & aJsonContent)

Parse a KICAD_MERGETOOL_AUTO-format JSON object mapping item IDs (KIID_PATH strings) to ITEM_RES spellings (the canonical snake_case names emitted by ItemResToString).

Only the TAKE_* family is accepted; KEEP / DELETE / MERGE_PROPS are engine-internal and would corrupt a scripted resolution.

Pure function — no I/O, no globals, no logging. Callers that want trace output should log against the errorContext field.

Definition at line 36 of file auto_resolution.cpp.

References BAD_VALUE, ENGINE_INTERNAL_KIND, KICAD_DIFF::AUTO_RESOLUTION_PARSE_RESULT::errorContext, INVALID_JSON, ItemResFromString(), KEEP, NOT_OBJECT, OK, KICAD_DIFF::AUTO_RESOLUTION_PARSE_RESULT::resolutions, KICAD_DIFF::AUTO_RESOLUTION_PARSE_RESULT::status, TAKE_ANCESTOR, TAKE_OURS, TAKE_THEIRS, and UNKNOWN_KIND.

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(), and BOOST_AUTO_TEST_CASE().

◆ pcbAddedRemovedProperties()

static std::vector< PROPERTY_DELTA > KICAD_DIFF::pcbAddedRemovedProperties ( const BOARD_ITEM * aItem,
bool aAsAfter )
static

◆ pcbDiffPropertyIsNoise()

static bool KICAD_DIFF::pcbDiffPropertyIsNoise ( const wxString & aName,
bool aInsideFootprint )
static

Definition at line 146 of file pcb_differ.cpp.

References pcbLibraryMetadataNoise().

◆ pcbLibraryMetadataNoise()

static bool KICAD_DIFF::pcbLibraryMetadataNoise ( const wxString & aName)
static

Definition at line 137 of file pcb_differ.cpp.

Referenced by pcbDiffPropertyIsNoise().

◆ PolySetFromPolygonList()

KICOMMON_API SHAPE_POLY_SET KICAD_DIFF::PolySetFromPolygonList ( const SCENE_SHAPE::PolygonList & aPolygons)

Build a SHAPE_POLY_SET from a SCENE_SHAPE::PolygonList.

Outer vector is polygons, middle is contours (index 0 outline, 1+ holes), inner is points. Polygons whose outline has fewer than three points are dropped. Shared by the GAL and plotter renderers so the delta-region fill builds the same way in interactive and headless output.

Definition at line 502 of file diff_scene.cpp.

References SHAPE_POLY_SET::Append(), SHAPE_POLY_SET::NewHole(), and SHAPE_POLY_SET::NewOutline().

Referenced by RenderSceneToOverlay().

◆ PropResFromString()

KICOMMON_API PROP_RES KICAD_DIFF::PropResFromString ( const std::string & aStr)

◆ PropResToString()

KICOMMON_API const char * KICAD_DIFF::PropResToString ( PROP_RES aRes)

Canonical lower-case spellings for PROP_RES used inside the JSON serialization of PROPERTY_RESOLUTION (ours / theirs / ancestor / custom).

Public so external mergetool scripts can produce/consume the strings directly without depending on the internal serializer.

Definition at line 35 of file kicad_merge_engine.cpp.

References ANCESTOR, CUSTOM, OURS, and THEIRS.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and KICAD_DIFF::PROPERTY_RESOLUTION::ToJson().

◆ RenderSceneToOverlay()

void KICAD_DIFF::RenderSceneToOverlay ( KIGFX::VIEW_OVERLAY & aOverlay,
const DIFF_SCENE & aScene,
const std::array< bool, CATEGORY_COUNT > & aVisible = ALL_CATEGORIES_VISIBLE,
const std::optional< KIID_PATH > & aHighlight = std::nullopt,
const std::set< KIID_PATH > & aHidden = {} )

Push a DIFF_SCENE's shapes onto a VIEW_OVERLAY as filled, semi-transparent rectangles, drawn in the canonical PAINT_ORDER so conflicts visually win over earlier categories.

The overlay is cleared first; existing commands are discarded.

Caller is responsible for adding the overlay to its KIGFX::VIEW and for invalidating the view after rendering. The function does not interact with the VIEW; it only mutates the overlay.

When aHighlight is set, a second pass strokes the matching shapes' bbox with a one-pixel outline on top of the fills so the selection stays visible even when its category is painted under another.

Shapes whose changeId is in aHidden render muted grey instead of their category color.

Definition at line 151 of file diff_renderer_gal.cpp.

References KIGFX::COLOR4D::a, SHAPE_POLY_SET::Append(), SHAPE_POLY_SET::BooleanSubtract(), KIGFX::VIEW_OVERLAY::Clear(), KICAD_DIFF::DIFF_SCENE::comparisonGeometry, KICAD_DIFF::DOCUMENT_GEOMETRY::Empty(), SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::OutlineCount(), PAINT_ORDER, KIGFX::VIEW_OVERLAY::Polygon(), PolySetFromPolygonList(), KIGFX::VIEW_OVERLAY::Rectangle(), KICAD_DIFF::DIFF_SCENE::referenceGeometry, KIGFX::VIEW_OVERLAY::SetFillColor(), KIGFX::VIEW_OVERLAY::SetIsFill(), KIGFX::VIEW_OVERLAY::SetIsStroke(), KIGFX::VIEW_OVERLAY::SetLineWidth(), KIGFX::VIEW_OVERLAY::SetStrokeColor(), and ShapesFor().

Referenced by WIDGET_DIFF_CANVAS::rebuildOverlay().

◆ RenderSceneToPng()

bool KICAD_DIFF::RenderSceneToPng ( const DIFF_SCENE & aScene,
const wxString & aOutputPath,
const PLOTTER_RENDER_OPTIONS & aOptions )

◆ RenderSceneToSvg()

◆ ResolveConflictBBox()

KICOMMON_API std::optional< BOX2I > KICAD_DIFF::ResolveConflictBBox ( const KIID_PATH & aId,
const std::map< KIID_PATH, BOX2I > & aPrimary,
const std::map< KIID_PATH, BOX2I > & aOurs,
const std::map< KIID_PATH, BOX2I > & aTheirs,
const std::map< KIID_PATH, BOX2I > & aAncestor )

Resolve the best bounding box for a conflicted item across the three sides of a 3-way merge.

The merge dialog hosts a canvas that previews each conflict on the user's currently-selected side. Some items only exist on one or two sides — a "Take ancestor" preview of an ours-only addition should still highlight the item's bbox somewhere reasonable, not collapse to a degenerate point.

Lookup order: aPrimary (the user's currently-selected side, pass an empty map for "no preferred side"), then ours, then theirs, then ancestor. The first map that has a usable bbox for aId wins. A bbox is considered usable if at least one of its dimensions is positive — a 1-unit-wide segment is fine, but a zero-size bbox at any origin is treated as absence and falls through to the next side.

Returns std::nullopt if none of the four maps contain a usable bbox.

Pure function — no widget interaction. Used by the dialog's rebuildCanvas and by any headless surface (e.g. a future kicad-cli mergetool --preview flag) that wants to identify a conflict's spatial location.

Definition at line 215 of file auto_resolution.cpp.

References find.

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(), and DIALOG_KICAD_MERGE_3WAY::rebuildCanvas().

◆ ResolvePropertyConflict()

KICOMMON_API PROPERTY_RESOLUTION_OUTCOME KICAD_DIFF::ResolvePropertyConflict ( const PROPERTY_DELTA * aOurs,
const PROPERTY_DELTA * aTheirs,
const KICAD_MERGE_ENGINE::OPTIONS & aOptions )

Decide how to resolve a single property edit between two sides.

Pass nullptr for whichever side didn't touch the property. The function encodes the engine's documented auto-merge contract:

  1. only-ours-touched -> OURS (clean)
  2. only-theirs-touched -> THEIRS (clean)
  3. both touched, after values equal AND options.autoResolveEqualValues -> OURS (equal-value auto-merge)
  4. both touched, ours is a no-op (before == after) AND both deltas share the same before value (no stale baseline) AND options.preferAutoMerge -> THEIRS
  5. both touched, theirs is a no-op AND both deltas share the same before value AND options.preferAutoMerge -> OURS
  6. otherwise -> OURS + unresolved flag

Branch order is load-bearing — the equal-end-value auto-resolve precedes the no-op detectors so converging edits land cleanly. The no-op detectors require matching before values on both sides; without that check a stale baseline (e.g., theirs computed against a different ancestor) would silently override a real edit on the other side.

Pure function — extracted so the decision table can be regression-tested directly without driving PlanMerge through full DOCUMENT_DIFF fixtures.

Definition at line 127 of file kicad_merge_engine.cpp.

References KICAD_DIFF::PROPERTY_DELTA::after, KICAD_DIFF::KICAD_MERGE_ENGINE::OPTIONS::autoResolveEqualValues, KICAD_DIFF::PROPERTY_DELTA::before, KICAD_DIFF::PROPERTY_RESOLUTION_OUTCOME::isUnresolved, KICAD_DIFF::PROPERTY_RESOLUTION_OUTCOME::kind, OURS, KICAD_DIFF::KICAD_MERGE_ENGINE::OPTIONS::preferAutoMerge, and THEIRS.

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(), and KICAD_DIFF::KICAD_MERGE_ENGINE::Plan().

◆ rootFileFormatVersion()

static int KICAD_DIFF::rootFileFormatVersion ( const SCHEMATIC * aSchematic)
static

Return aSchematic's root-screen file-format version, or 0 when no root screen is reachable.

Used by the post-apply validator pipeline to feed CheckSchemaVersions; hoisted from Apply() so a follow-up validator fixture can call it without re-implementing the null-guard chain.

Definition at line 66 of file sch_merge_applier.cpp.

References SCH_SCREEN::GetFileFormatVersionAtLoad(), and SCHEMATIC::RootScreen().

Referenced by KICAD_DIFF::SCH_MERGE_APPLIER::Apply().

◆ RunPostApplyValidators()

KICOMMON_API VALIDATION_REPORT KICAD_DIFF::RunPostApplyValidators ( const VALIDATION_INPUT & aInput)

Run every standard post-apply validator and merge their reports.

Pure function: no I/O, no global state. Composes

  • CheckRefdesUniqueness(refdesEntries)
  • CheckConnectivityRebuildFlag(planRequiredRebuild, applierReportedRebuild)
  • CheckSchemaVersions(ancestor, ours, theirs) and aggregates their failures via VALIDATION_REPORT::Merge.

The applier stores the result on its REPORT::validation; the CLI merge handlers surface the failures through the job reporter.

Definition at line 30 of file merge_validation_pipeline.cpp.

References KICAD_DIFF::VALIDATION_INPUT::ancestorSchemaVersion, KICAD_DIFF::VALIDATION_INPUT::applierReportedRebuild, CheckConnectivityRebuildFlag(), CheckRefdesUniqueness(), CheckSchemaVersions(), KICAD_DIFF::VALIDATION_REPORT::Merge(), KICAD_DIFF::VALIDATION_INPUT::oursSchemaVersion, KICAD_DIFF::VALIDATION_INPUT::planRequiredRebuild, KICAD_DIFF::VALIDATION_INPUT::refdesEntries, and KICAD_DIFF::VALIDATION_INPUT::theirsSchemaVersion.

Referenced by KICAD_DIFF::PCB_MERGE_APPLIER::Apply(), KICAD_DIFF::SCH_MERGE_APPLIER::Apply(), 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(), and BOOST_AUTO_TEST_CASE().

◆ SchScreenSentinelKiid()

const KIID & KICAD_DIFF::SchScreenSentinelKiid ( )
inline

Sentinel KIID appended to a sheet's KIID_PATH to mark a per-sheet SCH_SCREEN resolution (page format / orientation override on that sheet's screen).

Distinguishes a "this is a SCH_SCREEN doc-property delta on the sheet at this path" resolution from "this is the SCH_SHEET symbol item at this path" — those two would otherwise share the same KIID_PATH and the applier would route the SCH_SCREEN resolution into the (intentionally skipped) sheet-symbol applier branch. UUID is hard-coded as a valid v4 shape (so KIID's string_generator parses it deterministically), distinct from KIID::niluuid, and unlikely to collide with any real item KIID.

Definition at line 109 of file kicad_diff_types.h.

Referenced by KICAD_DIFF::SCH_MERGE_APPLIER::Apply(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and KICAD_DIFF::SCH_DIFFER::Diff().

◆ ShapesFor()

◆ SummarizeSeverities()

template<typename SeverityMap>
std::string KICAD_DIFF::SummarizeSeverities ( const SeverityMap & aMap)
inline

Format a severity-override map (DRC or ERC, keyed by error code, value is a SEVERITY enum) as a short summary with a content hash, so two maps with the same size but different contents render as distinct before/after strings.

Definition at line 139 of file kicad_diff_types.h.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), KICAD_DIFF::PCB_DIFFER::Diff(), and KICAD_DIFF::SCH_DIFFER::Diff().

◆ ThemeColorFor()

KICOMMON_API KIGFX::COLOR4D KICAD_DIFF::ThemeColorFor ( const DIFF_COLOR_THEME & aTheme,
CATEGORY aCategory )

Map a CATEGORY to its color in a DIFF_COLOR_THEME.

Pure dispatch — exposed so renderers and tests can pin the theme-to-shape-color mapping without driving BuildScene. A future theme that adds (or accidentally drops) a category color must trip an explicit test rather than silently render grey on screen.

Out-of-range CATEGORY values trip a wxFAIL_MSG and return a default- constructed COLOR4D (transparent black). Under QA's wxAssertThrower install the failure throws KI_TEST::WX_ASSERT_ERROR instead of silently returning grey.

Definition at line 40 of file diff_scene.cpp.

References KICAD_DIFF::DIFF_COLOR_THEME::added, KICAD_DIFF::DIFF_COLOR_THEME::conflict, KICAD_DIFF::DIFF_COLOR_THEME::modified, and KICAD_DIFF::DIFF_COLOR_THEME::removed.

Referenced by BOOST_AUTO_TEST_CASE(), and WIDGET_DIFF_CANVAS::HighlightChange().

◆ WalkSchematic()

template<typename SHEET_VISITOR, typename ITEM_VISITOR>
void KICAD_DIFF::WalkSchematic ( const SCHEMATIC * aSchematic,
SHEET_VISITOR && aSheetVisitor,
ITEM_VISITOR && aItemVisitor,
const KIID_PATH & aScope = {} )

Visit every SCH_ITEM in every sheet of aSchematic in page-number order.

Sheets are enumerated via BuildSheetListSortedByPageNumbers(); for each sheet the item visitor is invoked once per item on that sheet's screen as aItemVisitor( item, sheetPath, kiidPath ) where:

  • item is the SCH_ITEM* (never null),
  • sheetPath is the SCH_SHEET_PATH for the current sheet,
  • kiidPath is sheetPath.Path() with the item's m_Uuid pushed on.

aSheetVisitor is invoked once for every sheet in the list, before its items, as aSheetVisitor( sheetPath ) regardless of whether the sheet has a screen or any items. Callers that need to own a SCH_SHEET_PATH per sheet (the differ and the applier keep raw pointers into a storage vector) use it to materialize the copy exactly once per sheet.

The sheet path passed to either visitor is a reference to a local that is only valid for the duration of the call; callers that retain it must copy.

This intentionally visits every sheet INSTANCE with no screen-level dedup, so a screen shared by several instances is walked once per instance and yields a distinct per-instance KIID_PATH (the differ and applier key on that path). Contrast sch_geometry_extractor's ExtractSchematicGeometry, which dedups by screen so a shared screen renders once. Don't unify the two enumerations.

Definition at line 98 of file sch_diff_utils.h.

Referenced by KICAD_DIFF::SCH_MERGE_APPLIER::indexSchematic(), and KICAD_DIFF::SCH_DIFFER::walk().

◆ WriteDiffOutput()

KICOMMON_API bool KICAD_DIFF::WriteDiffOutput ( const std::string & aContent,
const wxString & aOutputPath )

Write diff/merge text output to aOutputPath, or to stdout when the path is empty.

Returns false only when a non-empty path cannot be opened for writing.

Definition at line 849 of file kicad_diff_types.cpp.

References WriteDiffOutput().

Referenced by BOOST_AUTO_TEST_CASE(), EmitDiffResult(), and WriteDiffOutput().

◆ writeEmptyPng()

static bool KICAD_DIFF::writeEmptyPng ( const wxString & aOutputPath)
static

Write a tiny placeholder PNG (single empty pixel) so a "no differences" diff still produces a valid output file.

Used when the scene has no shapes to render. The file is the smallest valid PNG that displays as transparent (or theme background in viewers that fill).

Definition at line 222 of file diff_renderer_plotter.cpp.

Referenced by RenderSceneToPng().

◆ writeEmptySvg()

static bool KICAD_DIFF::writeEmptySvg ( const wxString & aOutputPath)
static

Definition at line 245 of file diff_renderer_plotter.cpp.

Referenced by RenderSceneToSvg().

◆ WxAnyToDiffValue()

KICOMMON_API DIFF_VALUE KICAD_DIFF::WxAnyToDiffValue ( const wxAny & aValue,
PROPERTY_BASE * aProperty = nullptr )

Convert a wxAny value read from a PROPERTY_BASE getter into a DIFF_VALUE that the engine can store, serialize, and compare.

The aProperty argument is consulted when needed to interpret enum-backed values (so the integer payload can be paired with the choice label) and for coordinate-typed properties.

Returns a DIFF_VALUE::T::NONE if the wxAny is empty or carries an unsupported type; the differ can use that as a signal to omit the property from its delta rather than producing a bogus comparison.

Definition at line 93 of file property_value_converter.cpp.

References ANGLE, PROPERTY_BASE::Choices(), KICAD_DIFF::DIFF_VALUE::FromBool(), KICAD_DIFF::DIFF_VALUE::FromBox2I(), KICAD_DIFF::DIFF_VALUE::FromColor(), KICAD_DIFF::DIFF_VALUE::FromDouble(), KICAD_DIFF::DIFF_VALUE::FromEnum(), KICAD_DIFF::DIFF_VALUE::FromInt(), KICAD_DIFF::DIFF_VALUE::FromInt64(), KICAD_DIFF::DIFF_VALUE::FromKiid(), KICAD_DIFF::DIFF_VALUE::FromLayer(), KICAD_DIFF::DIFF_VALUE::FromString(), KICAD_DIFF::DIFF_VALUE::FromVector2I(), PROPERTY_BASE::HasChoices(), and KICAD_DIFF::DIFF_VALUE::WithDisplayHint().

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(), DiffItemProperties(), and ItemProperties().

Variable Documentation

◆ ALL_CATEGORIES_VISIBLE

std::array<bool, CATEGORY_COUNT> KICAD_DIFF::ALL_CATEGORIES_VISIBLE
inlineconstexpr
Initial value:
{ {
true, true, true, true } }

Default-visible category filter — every CATEGORY shows.

Use as the default argument to RenderSceneToOverlay.

Definition at line 47 of file diff_renderer_gal.h.

◆ CATEGORY_COUNT

std::size_t KICAD_DIFF::CATEGORY_COUNT = PAINT_ORDER.size()
inlineconstexpr

Definition at line 75 of file diff_scene.h.

Referenced by BOOST_AUTO_TEST_CASE(), and DIALOG_KICAD_DIFF::buildTree().

◆ DOC_PROP_BOARD_THICKNESS

const wxString KICAD_DIFF::DOC_PROP_BOARD_THICKNESS = wxS( "Board Thickness" )
inline

◆ DOC_PROP_CUSTOM_RULES

const wxString KICAD_DIFF::DOC_PROP_CUSTOM_RULES = wxS( "Custom DRC Rules" )
inline

◆ DOC_PROP_DRAWING_SHEET

◆ DOC_PROP_DRC_SEVERITIES

◆ DOC_PROP_ERC_SEVERITIES

const wxString KICAD_DIFF::DOC_PROP_ERC_SEVERITIES = wxS( "ERC Severity Overrides" )
inline

◆ DOC_PROP_FP_LIB_TABLE

const wxString KICAD_DIFF::DOC_PROP_FP_LIB_TABLE = wxS( "Footprint Library Table" )
inline

◆ DOC_PROP_LAYER_STACKUP

const wxString KICAD_DIFF::DOC_PROP_LAYER_STACKUP = wxS( "Layer Stackup" )
inline

◆ DOC_PROP_NET_CLASSES

◆ DOC_PROP_PAGE_FORMAT

const wxString KICAD_DIFF::DOC_PROP_PAGE_FORMAT = wxS( "Page Format" )
inline

Property-name keys for the synthetic document-level ITEM_CHANGE (empty KIID_PATH).

Shared between PCB and SCH differs / appliers so a typo on one side doesn't silently desync from the other.

Definition at line 87 of file kicad_diff_types.h.

Referenced by AppendPaperDeltas(), KICAD_DIFF::PCB_MERGE_APPLIER::Apply(), KICAD_DIFF::SCH_MERGE_APPLIER::Apply(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ DOC_PROP_PAGE_ORIENTATION

const wxString KICAD_DIFF::DOC_PROP_PAGE_ORIENTATION = wxS( "Page Orientation" )
inline

◆ DOC_PROP_SYM_LIB_TABLE

const wxString KICAD_DIFF::DOC_PROP_SYM_LIB_TABLE = wxS( "Symbol Library Table" )
inline

◆ PAINT_ORDER

std::array<CATEGORY, 4> KICAD_DIFF::PAINT_ORDER
inlineconstexpr
Initial value:
{
CATEGORY::MODIFIED,
CATEGORY::ADDED,
CATEGORY::REMOVED,
CATEGORY::CONFLICT,
}

Paint order.

Modified shapes are drawn first (background), conflicts last (foreground) so the most important changes win when bboxes overlap. Renderers (plotter, GAL, thumbnail) must walk this array forward when painting and backward when hit-testing. Also the canonical "iterate all categories" sequence — its size is the number of categories.

Definition at line 67 of file diff_scene.h.

Referenced by BOOST_AUTO_TEST_CASE(), HighlightedBBox(), RenderSceneToOverlay(), RenderSceneToPng(), RenderSceneToSvg(), and WIDGET_DIFF_CANVAS::shapeAt().

◆ PLOT_HAIRLINE_IU

int KICAD_DIFF::PLOT_HAIRLINE_IU = 10
constexpr

Minimum stroke width the headless plotter will use when a primitive declares a non-positive line width.

SVG treats stroke-width=0 as "no stroke" and the PNG path silently drops sub-pixel widths, so for diff-overlay shapes we substitute a small absolute internal-unit width. Pinned here so tests and any new plotter surfaces share the same hairline definition.

Definition at line 83 of file diff_renderer_plotter.h.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and EffectivePlotWidth().