48 Commits

Author SHA1 Message Date
John Beard c4c19018c3 Pcbnew: Restrict includes of pad.h/footprint.h
There are some headers which don't need to include pad.h (which brings
padstack.h) - they just need forward defines.

While pad.h is not an especially heavy include on the scale of things,
footprint is quite heavy. And both reduce inclusion load and
reduce the number of files needlessly sensitive to changes in headers.
2026-03-05 02:18:34 +08:00
Seth Hillbrand 8dce8aa786 Tag geometry-dependent DRC functions at registration
The geometry-dependent function set in CreateFuncCall was a
hardcoded copy of names that had to be manually synchronized
with RegisterAllFunctions. Adding a new geometry-dependent
function without updating both lists would silently skip
per-segment DRC evaluation for rules using that function.

Add an isGeometryDependent flag to RegisterFunc and query it
from CreateFuncCall so there is a single source of truth.
2026-02-27 19:14:03 -08:00
Seth Hillbrand f49ed45952 Skip per-segment DRC eval during drag
Commit 77499b92c6 added segment-by-segment DRC evaluation
for multi-segment PNS LINEs in QueryConstraint(). This runs
the full LIBEVAL VM per segment per collision pair, which is
catastrophically slow on boards with custom clearance rules.

The per-segment path only produces different results from
anchor-based evaluation when a rule condition calls a
geometry-dependent function (intersectsArea, etc.). For
property-based conditions like NetClass or Type, all segments
of a LINE share the same values, so a single evaluation at
the anchor is correct.

Tag geometry-dependent functions at compile time in
PCBEXPR_UCODE::CreateFuncCall(). Propagate the flag through
DRC_RULE_CONDITION to DRC_ENGINE::m_hasGeometryDependentRules
during compileRules(). Gate the segment-by-segment path in
QueryConstraint() on this flag so the fast anchor-based path
runs when no rules use geometry functions.
2026-02-27 15:21:23 -08:00
Seth Hillbrand 6c9c75eb07 Remove property.h and property_mgr.h from inspectable.h
This breaks the view_item.h -> inspectable.h -> property.h chain that
pulled wx/propgrid/property.h into 150-200 TUs. The lean inspectable.h
now includes only wx/any.h, wx/string.h, wx/variant.h.

Headers using DECLARE_ENUM_TO_WXANY (board_item.h, sch_item.h) retain
their property.h include since the macro requires it.
2026-02-13 19:54:46 -08:00
Seth Hillbrand fadab1d36a Use item cache for faster zone lookup
Replace searchAreas zone iteration with a direct cache lookup.
The board's item-by-ID cache already contains all zones, both
board-level and footprint-level, so we can retrieve the target
zone by UUID in constant time instead of scanning all zones.
2026-01-29 10:37:23 -08:00
Seth Hillbrand 986580905f Cache zone lookups and deflated outlines for DRC
Optimize performance of area-based DRC clearance rules by caching
zone name lookups and deflated outlines. This avoids repeated
expensive operations during trace moves. Caches are cleared when
the board is modified and use thread-safe locking for concurrent
access.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/21444
2026-01-29 10:17:05 -08:00
Seth Hillbrand ab8ff442d3 Some performance optimizations for PNS/DRC
Removed the double map lookup (count() + op[])
Normalized the commutative caching so A,B = B,A
Batched the locks for the layers
2026-01-09 16:50:08 -08:00
Seth Hillbrand e741ee2e6c Cache netclass clearances
Importing Altium boards can generate hundreds of netclasses.  Our O(N)
search was choking on the overload
2026-01-09 16:15:20 -08:00
Seth Hillbrand e966185b43 Add some defensive code to prevent crashes
Need to avoid the cases where we might have a missing board or an
undefined netclass before dereferencing

Fixes https://gitlab.com/kicad/code/kicad/-/issues/22126
2025-12-31 15:06:44 -08:00
Jeff Young f48a5ee0d1 Formatting. 2025-11-20 18:05:01 +00:00
Seth Hillbrand 43e327b688 Resolve discrepancy between constraint and disallow
Vias are referred to by their type without combining (e.g. blind/buried)

Fixes https://gitlab.com/kicad/code/kicad/-/issues/13783
2025-09-26 11:41:17 -07:00
Jeff Young ca7059b487 Honour flip when checking front/back courtyards.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/21670
2025-09-13 18:12:07 +01:00
Jeff Young 7fc9fc5f58 Remove double-layer-processing.
(The caller already handles cycling through the
layers.)
2025-07-04 19:34:20 -06:00
Jeff Young 1184bc3c36 Iterate pad layers when doing collisions (KICAD-R3Q). 2025-07-04 15:10:22 -06:00
Jeff Young 2564e5511f Tighten isCoupledDiffPair test when we only have one item.
Improves https://gitlab.com/kicad/code/kicad/-/issues/19838
2025-06-26 19:42:14 -06:00
Jeff Young ea8b0c0e8a Don't expect a B item when evaling DIFF_PAIR_GAP_CONSTRAINT.
The checker first builds a map with only the
A items.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19825
2025-05-06 14:15:03 +01:00
JamesJCode 1400eb7902 Add hasExactNetclass function to DRC condition language
Following changes to the `A.NetClass == '<netclass>'` semantics to
match on exact netclass name OR any constituent netclass names, we
can have conditions where constituent netclass constraints match
before the composite netclass constraints in the DRC engine. This
adds the functionality to match on the exact full netclass name, and
modifies the implicit netclass DRC rules to use this function in
their rule condition.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20797

(cherry picked from commit c25264528c)
2025-04-27 22:40:46 +01:00
Mike Williams 05e9772d54 groups: extract common class methods into EDA_GROUP base class 2025-04-01 14:34:20 -04:00
JamesJCode 4a99a3060d Add new DRC expression function isMemberOfSheetOrChildren
This allows the multichannel tool to search for footprints that are in nested
hierarchical sheets.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20339
2025-03-17 15:55:59 +00:00
JamesJCode ede5faee72 Implement dynamic assignment of component classes 2025-03-15 14:33:47 +00:00
Jeff Young 6ac64d290b Check parent footprint as well for component class.
Also output more descriptive text when checking inherited
rules on parent footprint.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20281
2025-03-10 13:34:01 +00:00
JamesJCode 54540f9e82 Don't dereference null COMPONENT_CLASS in testFootprintSelector
This can happen when running standalone, where component classes
have not been resolved.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20235
2025-03-06 21:43:52 +00:00
Jeff Young c5bb59468d Get rid of assumptions about field order. 2025-02-24 11:08:29 +00:00
Jon Evans d74744596e Fix application of component class to memberOfFootprint
Fixes https://gitlab.com/kicad/code/kicad/-/issues/19663
2025-01-18 09:14:28 -05:00
Seth Hillbrand 0b2d4d4879 Revise Copyright statement to align with TLF
Recommendation is to avoid using the year nomenclature as this
information is already encoded in the git repo.  Avoids needing to
repeatly update.

Also updates AUTHORS.txt from current repo with contributor names
2025-01-01 14:12:04 -08:00
Seth Hillbrand e9bc8cfe9d Give Clipper1 a Viking funeral
Clears out the last spot where we were only using Clipper1 (how'd I
miss that?) and remove all calls to the Clipper1 structures
2024-12-23 17:12:09 -08:00
Jeff Young 610d497600 Fix enclosedByArea for footprints.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/19137
2024-12-03 12:43:59 +00:00
Jon Evans 683ce4c904 Support component class in footprint custom rules 2024-11-11 18:34:27 -05:00
JamesJCode db072a524c Consolidation of Component Class implementation
- Moves functionality to FOOTPRINT class from BOARD_ITEM
- Renames DRC property from ComponentClass to Component_Class
- Adds DRC checks QA for A.Component_Class and a.hasComponentClass('x')
2024-10-24 20:11:35 +01:00
JamesJCode d64a112971 Implement Component Classes
- Adds Component Class field to SCH_DIRECTIVE_LABEL
- Adds SCH_SYMBOLs to SCH_RULE_AREA item lists
- SCH_SYMBOLs resolve Component Class directives
- Netlist exporter / importer handles Component Class names
- Adds DRC expressions and functions
- Adds QA check for component class netlist export
2024-10-01 22:36:18 +01:00
Tomasz Wlostowski 64afa302c9 pcbnew: improve handling of trailing '/' in hierarchical sheet paths in DRC memberOfSheet() function 2024-08-13 22:50:25 +02:00
James J 7ce00e511b Multi-netclass support 2024-07-26 20:49:29 +00:00
Seth Hillbrand cc850d0da0 Split out LSEQ/LSET from LAYER_ID
Separate the layer grouping classes for easier modification
2024-07-08 20:59:46 -07:00
Jeff Young 5ba2896968 enclosedByArea test for zone needs to be outline-based.
(Otherwise it's order-specific when filling, which
is pretty unpredictable.)

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18202
2024-06-15 17:52:15 +01:00
Jeff Young 694a7db457 Performance improvements.
Don't construct a wxString or a LSEQ when you don't
have to.  They're both more expensive than you might
think.
2024-06-12 11:06:10 +01:00
Jeff Young 560f6f87e5 Silkscreen clearance tests are run across layer pairs.
(So any rule areas must pretend they're on all the
given side's layers to get expected results.)
2024-05-22 01:16:06 +01:00
Jeff Young ab2fdfb9cc Formatting. 2024-05-22 01:16:06 +01:00
Jon Evans 7f03666f96 Support LIB_ID queries in searchFootprints too
Fixes https://gitlab.com/kicad/code/kicad/-/issues/18039


(cherry picked from commit fee0028ee9)

Co-authored-by: Jon Evans <jon@craftyjon.com>
2024-05-17 17:57:42 +00:00
Seth Hillbrand 9648fafe11 Handle memberOfSheet for full footprints
Previously, we handled clearance for just components in the eval
function.  We also checked the incorrect root sheetname.
2024-03-11 16:32:24 -07:00
Jeff Young 06a8517818 Further improvements to cache locking.
In particular, don't hold cache lock while doing computations.
2024-03-07 13:20:20 +00:00
Armin Schoisswohl 4dcec60bf4 add include <mutex> to fix compilation under linux 2024-03-07 13:20:16 +00:00
Armin Schoisswohl bb9448edcb change m_CachesMutex to shared_mutex and do shared locking for read access in zone BBox calculations 2024-03-07 13:20:13 +00:00
Armin Schoisswohl 991ff71f33 fix deadlock in DRC "Checking keeopouts & disallow constraints" 2024-03-07 13:20:10 +00:00
Jeff Young 43c45f3ee8 Fix copy pasta. 2024-02-26 12:39:01 +00:00
Jeff Young 236123c487 Allow FPID to be matched against in memberOfFootprint().
Fixes https://gitlab.com/kicad/code/kicad/-/issues/16662
2024-01-22 14:03:45 +00:00
Alex Shvartzkop d7863b09c5 Move CORNER_STRATEGY out of SHAPE_POLY_SET. 2023-10-06 15:42:50 +03:00
Seth Hillbrand cb3c712a9c ADDED: memberOfSheet() design rule function
Footprints that are a member of a specific sheet may be assigned
distinct rules, allowing users to group their rules based on sheet
layout
2023-09-06 19:14:00 +00:00
Jeff Young 55a7b9e6bf More consistent naming.
(Also better differentiates the PCBEXPR_ classes from PCB_
objects.)
2023-08-21 15:26:33 +01:00