21#ifndef KICAD_DIFF_TYPES_H
22#define KICAD_DIFF_TYPES_H
111 static const KIID sentinel{ std::string(
"5c50ee00-0000-4000-8000-000000000000" ) };
138template<
typename SeverityMap>
143 for(
const auto& [code, sev] : aMap )
144 h ^= std::hash<int>{}( code ) + std::hash<int>{}(
static_cast<int>( sev ) );
146 return wxString::Format( wxS(
"%zu override(s) (hash %zx)" ),
147 aMap.size(), h ).ToStdString();
182 using PolygonSet = std::vector<std::vector<std::vector<VECTOR2I>>>;
191 static DIFF_VALUE FromInt64( int64_t aValue );
192 static DIFF_VALUE FromDouble(
double aValue );
193 static DIFF_VALUE FromString(
const wxString& aValue );
194 static DIFF_VALUE FromString(
const std::string& aValue );
200 static DIFF_VALUE FromEnum(
int aValue,
const std::string& aLabel );
201 static DIFF_VALUE FromPolygonSet( PolygonSet aValue );
208 int64_t AsInt64()
const;
209 double AsDouble()
const;
210 wxString AsString()
const;
213 BOX2I AsBox2I()
const;
216 EnumValue AsEnum()
const;
217 const PolygonSet& AsPolygonSet()
const;
233 wxString ToDisplayString()
const;
244 nlohmann::json ToJson()
const;
245 static DIFF_VALUE FromJson(
const nlohmann::json& aJson );
271 nlohmann::json
ToJson()
const;
294 nlohmann::json
ToJson()
const;
311 nlohmann::json ToJson()
const;
312 static DOCUMENT_DIFF FromJson(
const nlohmann::json& aJson );
325 nlohmann::json
ToJson()
const;
346 const wxString& aLabelB,
EDA_UNITS aUnits,
400 return aChange.
typeName == wxS(
"ZONE" )
401 || aChange.
typeName == wxS(
"PCB_TRACK" )
402 || aChange.
typeName == wxS(
"PCB_ARC" )
403 || aChange.
typeName == wxS(
"PCB_VIA" )
404 || aChange.
typeName == wxS(
"FOOTPRINT" )
405 || aChange.
typeName == wxS(
"PAD" );
431 return aChange.
typeName == wxS(
"PCB_TRACK" )
432 || aChange.
typeName == wxS(
"PCB_ARC" )
433 || aChange.
typeName == wxS(
"PCB_VIA" )
434 || aChange.
typeName == wxS(
"PCB_SHAPE" )
436 || aChange.
typeName == wxS(
"SCH_LINE" )
437 || aChange.
typeName == wxS(
"SCH_PIN" )
438 || aChange.
typeName == wxS(
"SCH_SYMBOL" )
439 || aChange.
typeName == wxS(
"SCH_LABEL" )
440 || aChange.
typeName == wxS(
"SCH_GLOBALLABEL" )
441 || aChange.
typeName == wxS(
"SCH_HIERLABEL" )
442 || aChange.
typeName == wxS(
"SCH_DIRECTIVE_LABEL" )
443 || aChange.
typeName == wxS(
"SCH_JUNCTION" )
444 || aChange.
typeName == wxS(
"SCH_NO_CONNECT" )
445 || aChange.
typeName == wxS(
"SCH_SHEET_PIN" )
446 || aChange.
typeName == wxS(
"SCH_BUS_WIRE_ENTRY" )
447 || aChange.
typeName == wxS(
"SCH_BUS_BUS_ENTRY" )
448 || aChange.
typeName == wxS(
"SCH_SHEET" )
449 || aChange.
typeName == wxS(
"SCH_RULE_AREA" );
bool operator==(const wxAuiPaneInfo &aLhs, const wxAuiPaneInfo &aRhs)
A typed sum value used to carry the before/after of any single property.
DISPLAY_HINT GetDisplayHint() const
std::variant< std::monostate, bool, int, int64_t, double, std::string, KIID, VECTOR2I, BOX2I, KIGFX::COLOR4D, PCB_LAYER_ID, EnumValue, PolygonSet > Storage
DIFF_VALUE WithDisplayHint(DISPLAY_HINT aHint) const
Tag this value with a display hint and return a copy, so call sites can chain DIFF_VALUE::FromInt( w ...
std::pair< int, std::string > EnumValue
Enum payload: (numeric_value, label) so JSON output is human-readable while the integer is the canoni...
bool operator!=(const DIFF_VALUE &aOther) const
const Storage & GetStorage() const
std::vector< std::vector< std::vector< VECTOR2I > > > PolygonSet
DISPLAY_HINT m_displayHint
Presentation aid only; excluded from operator== and JSON (see DISPLAY_HINT).
A color representation with 4 components: red, green, blue, alpha.
static KIID FromDeterministicString(const wxString &aName)
Build a deterministic UUID from an arbitrary name string.
PCB_LAYER_ID
A quick note on layer IDs:
CHANGE_KIND
Coarse classification of a single item-level change between two documents.
const wxString DOC_PROP_ERC_SEVERITIES
const KIID & SchScreenSentinelKiid()
Sentinel KIID appended to a sheet's KIID_PATH to mark a per-sheet SCH_SCREEN resolution (page format ...
const wxString DOC_PROP_SYM_LIB_TABLE
bool ChangeInvalidatesZone(const ITEM_CHANGE &aChange)
Whether a change to an item of the given type invalidates any overlapping filled zones.
const wxString DOC_PROP_BOARD_THICKNESS
CHANGE_KIND ChangeKindFromString(const std::string &aKind)
const wxString DOC_PROP_PAGE_FORMAT
Property-name keys for the synthetic document-level ITEM_CHANGE (empty KIID_PATH).
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 wxString DOC_PROP_NET_CLASSES
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...
const wxString DOC_PROP_CUSTOM_RULES
const wxString DOC_PROP_PAGE_ORIENTATION
const wxString DOC_PROP_FP_LIB_TABLE
KIID_PATH LibraryItemKiidPath(const wxString &aName)
Build a deterministic synthetic KIID_PATH from a library item name (symbol name or footprint name).
const wxString DOC_PROP_LAYER_STACKUP
const wxString DOC_PROP_DRAWING_SHEET
DISPLAY_HINT
How a numeric DIFF_VALUE should be interpreted when rendered for humans.
@ COORD
Coordinate in internal units (PT_COORD)
@ DISTANCE
Length in internal units (PT_SIZE)
@ ANGLE
Angle in degrees (PT_DEGREE)
bool ChangeRequiresConnectivityRebuild(const ITEM_CHANGE &aChange)
Whether a change to an item of the given type requires the connectivity graph to be rebuilt.
const wxString DOC_PROP_DRC_SEVERITIES
const char * ChangeKindToString(CHANGE_KIND aKind)
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...
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 <lab...
std::map< wxString, const PROPERTY_DELTA * > IndexPropertiesByName(const ITEM_CHANGE &aChange)
Index property deltas inside one ITEM_CHANGE by property name.
The full set of changes between two parsed documents of one type.
std::vector< ITEM_CHANGE > changes
One change record on a single item.
static ITEM_CHANGE FromJson(const nlohmann::json &aJson)
std::vector< PROPERTY_DELTA > properties
std::optional< wxString > refdes
std::vector< ITEM_CHANGE > children
nlohmann::json ToJson() const
Aggregated project-level diff covering many documents.
nlohmann::json ToJson() const
std::vector< DOCUMENT_DIFF > documents
static PROJECT_DIFF FromJson(const nlohmann::json &aJson)
Single (name, before, after) triple for one mutated property on an item.
static PROPERTY_DELTA FromJson(const nlohmann::json &aJson)
nlohmann::json ToJson() const
VECTOR2< int32_t > VECTOR2I