Commit Graph

1527 Commits

Author SHA1 Message Date
Ian McInerney 533d7531a1 Via routing actions need to use int flags
The actions the router uses for via placement can be a combination of
enum values, so the actions must use an int parameter instead of the
enum type.

Fixes KICAD-2DS
2023-06-29 23:21:15 +01:00
Ian McInerney 2fb6f19a84 Separate immediate and delayed action dispatch
Using a boolean argument just leads to a lot of trailing booleans in the
function calls and is not user friendly. Instead, introduce PostAction()
to send an action that runs after the coroutine (equivalent to passing
false or the default argument), and leave RunAction as the immediate
execution function.
2023-06-27 00:57:59 +01:00
Jeff Young 493828cc6b Eradicate a bunch of calls to dyn_cast.
Also deletes PAD::GetParent() which fails to look for parent footprint
through groups.
2023-06-25 11:10:07 +01:00
Tomasz Wlostowski 61391e3984 router: take holes into account when building the restricted items set for collision search 2023-06-23 14:52:45 +02:00
Tomasz Wlostowski a0a68d198c router: when no collision search context is provided, assume differentNetsOnly is true 2023-06-22 23:52:21 +02:00
Tomasz Wlostowski bd5954242e router: provisional fix for 14926 2023-06-22 16:52:34 +02:00
Jeff Young 0fde88eefc Protect custom rule function caches from transient items. 2023-06-21 18:14:41 +01:00
Ian McInerney 3c24ddd8cc Fix passing CLIENT_SELECTION_FILTER through the tool framework 2023-06-20 21:52:50 +01:00
Ian McInerney 07cc85e76c Fix more places where casts into RunAction were happening 2023-06-20 21:52:50 +01:00
Ian McInerney b04e54dbea Switch TOOL_EVENT and TOOL_ACTION to have a std::any parameter
Using std::any from C++17 allows for proper type handling in the
parameter field, removing the need for casting to void* and then casting
the void* to the desired type.
2023-06-20 21:52:50 +01:00
Mike Williams 37837dc392 PCB: introduce PCB_FIELD_T 2023-06-20 18:34:52 +00:00
Jeff Young 30336b2fe3 Unify go-back-one-step processing for drawing tools (and router).
Also warps mouse on all go-back-one-step operations for better feedback.

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

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9985
2023-06-19 17:14:32 +01:00
Jeff Young 1c7971c4dc Cleanup. 2023-06-17 18:12:13 +01:00
Jeff Young 9fbaa238a2 Don't create 22.5-degree gateways if we're not cardinal or diagonal.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14984
2023-06-17 16:05:35 +01:00
Ian McInerney 63e91366e2 Add variable initializations 2023-06-15 23:49:24 +01:00
Ian McInerney b73cc7db4a Fix a few accidental copies in loop iterators 2023-06-15 22:57:05 +01:00
Yang Hongbo fe1b1becef Check visibility when switching layer in router tool
When routing and using layerNext (hotkey '+') to switch to next layer,
it will skip invisible layer, when click BUT_LEFT, the new line should
be in the same layer (visible layer)

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14480
2023-06-13 09:46:12 -07:00
Tomasz Wlostowski 3667e4f6b2 router: correctly assign owner via/pad to its hole when committing the world state
fixes #14852
2023-06-08 11:57:23 +02:00
Jeff Young 3c8d2bfca5 Assertion checking for hole/parent ownership mismatch.
(This mismatch is the root of the problem in issue #14852.)
2023-06-02 18:30:16 +01:00
Tomasz Włostowski 3c3517cc36 router: can't add a clone of a VIA's hole when adding the via to INDEX - this will result in bogus colliding objects
This commit partially reverts deb3cbf8. VIA and SOLID operator='s introduced in it do a good job but the cloning of holes in addHole() causes bogus collisions.
2023-06-01 22:47:02 +02:00
Jeff Young deb3cbf89b Prevent use-after-free crashes by not fighting over who owns a HOLE.
The diff-pair placer creates DIFF_PAIRs on the stack, which have
VIAs in them, which have HOLEs in them.  The HOLEs get put in the
NODE's index, and we then crash later when doing a collision after
the stack variable has gone out of scope.

The stack variable is also copied while doing a search for "best",
and without the operator= definitions the "best" and the "original"
both think they own the HOLE.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14852
2023-06-01 15:07:29 +01:00
Tomasz Wlostowski 7966126040 router: invalidate items freed by PNS::NODE in the clearance cache
This was causing intermittent shove hiccups/freezes as RULE_RESOLVER::GetClearance() could return a bogus clearance value, taking
a cached value for an item that does not exist anymore. If the allocator/stack accidentally reclaimed such item's address - we were getting
very nasty and difficult to reproduce misbehaviours of the shove algorithm. Hopefully this patch fixes this. More info in the comments.

Note to self - I'm still not fully convinced I want PNS::ITEM pointers as the cache key, probably a unique counter would be better here.
2023-06-01 00:01:15 +02:00
Tomasz Wlostowski 15db42d9c8 router: fix use-after-free crash in drag walkaround mode 2023-05-31 22:20:28 +02:00
Tomasz Wlostowski 5100345c6e router: prevent pushout/bogus collision of via with is own hole (or copper) when dragging
The root cause was not removing the original (pre-dragging) via from the world, comparing the ITEM::Parent() pointers of the items was only hiding the main issue.
This also fixes the PNSViaCollisions test in the qa/ suite.
2023-05-31 17:06:24 +02:00
Jeff Young 4874537c40 Push/pop router tool for inline drag.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14832
2023-05-30 18:02:12 +01:00
Jon Evans 141cc85ff3 PNS: Work around collision checking issues in shove mode
Need to special-case shove mode since 942ee13c introduced
collision checking in all modes.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14836
2023-05-29 18:19:47 -04:00
Jeff Young c71cf21e2f Use rendered text to generate bounding box for knockout text.
Don't open-code knockout text shape generation in several different
places.

Make sure triangulated knockout text gets clearance added when
specified.

Collapse duplicated footprint text item plot routine (they're no
longer any different from plotting pcb text items).
2023-05-28 17:20:11 +01:00
Jeff Young 768fbf5af2 Give up on trying to calculate text bounding boxes.
It results in too many hacks strewn through the code.  Just draw the
text and measure it.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14803
2023-05-26 18:44:33 +01:00
Jon Evans 942ee13cd1 PNS: Allow width-caused DRC violations at start of route
Also fix an issue where DRC violations introduced by the
width change action could be committed in walk/shove mode.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14805
2023-05-25 23:10:00 -04:00
Jeff Young b442d769fd Don't allow collisions with self.
The previous test didn't handle is-self-tests between a hole and
its override in a different NODE.  When calculating the pushout
force we don't remove the via (and its hole) from the current
node until after the calculation, so we end up checking for
collisions between the new (cloned) via's hole and the original
hole in the root node.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14795
2023-05-23 14:10:22 +01:00
Jeff Young df763eaf88 Reconcile PNS router with DRC.
Hole-to-hole is only for drilled holes.
NPTH slots also get EDGE_CLEARANCE applied.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14771
2023-05-21 19:58:00 +01:00
Marek Roszko 8a7044c3fb Fix some more warnings 2023-05-20 08:00:16 -04:00
Jeff Young 8b1fd62d35 Make pad & via teardrops 1st-class citizens (props of the pad/via)
Change teardrop generation to rely more heavily on BOARD_CONNECTIVITY
for improved performance.

Add updating of teardrops on BOARD_COMMIT::Push().

Also converts m_CopperItemRTreeCache to std::shared_ptr.
We don't copy it around anyway, and having to create a new set
of std::unique_ptr's for each operation is likely to be more
expensive than std::shared_ptr's overhead.
2023-05-19 18:02:03 +01:00
Jon Evans 94130716a5 PNS: Collision search context may be null
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14741
2023-05-14 17:20:59 -04:00
Alex d790865549 Make sure text bounding box exists when syncing PNS world.
Fixes https://gitlab.com/kicad/code/kicad/issues/14733
2023-05-14 13:40:14 +03:00
Steve Bollinger 85f4f0d6c8 pcbnew: switching track posture may not work on first attempt
If you drag a track out and connect to a pad then press the hotkey
to switch the track posture it may not switch because the track
posture selected when the pad was reached is different than the one
that the mouse trail placer drew. As the aspect switching is done
in the mouse trail placer it does not know that the line placer
already override the track.

To correct this, in LINE_PLACER::FlipPosture() if the aspect is not
currently manually forced then copy the current aspect from the
line placer to m_mouseTrailPlacer before calling the FlipPosture()
method of m_mouseTrailPlacer. This will only be done once per
dragging session as once the aspect is manually forced it remains
manually forced. This seems to fix the issue with no undesirable
side effects.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/12369
2023-05-11 23:35:21 +00:00
Jon Evans 89aae88e96 PNS: make sure context options are used in collideSimple
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14659
2023-05-11 16:48:15 -04:00
Jon Evans 2e60315959 PNS: Don't use clearance epsilon for calculating shove distances
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14707
2023-05-11 13:09:03 -04:00
Jeff Young 2dcbc10a09 Performance optimization. 2023-05-08 11:46:04 +01:00
Jeff Young 5b3798a370 Holes need a parent.
SetHole() handles all this for us.  Make sure it's called.

Fixes https://gitlab.com/kicad/code/kicad/issues/14702
2023-05-08 11:41:12 +01:00
Jon Evans b06f90335b PNS: Remove holes when removing items with holes
Related to https://gitlab.com/kicad/code/kicad/-/issues/14702
2023-05-07 22:12:11 -04:00
Lucas Dumont a22e6db982 Add Zone when dragging component
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14629
2023-05-06 09:32:38 +00:00
Jeff Young f27bc16d62 Cleanup API and use text bounding box for routing.
If someone wants to route around the text more tightly
they can now convert the text to polygons.

Fixes https://gitlab.com/kicad/code/kicad/issues/14252
2023-05-02 16:03:43 +01:00
Jeff Young 80f8cd2254 Commenting and formatting. 2023-05-02 14:16:02 +01:00
Jeff Young 16e000f2b0 Use Net() accessor uniformly; init hole parent in VIA::Clone()
Fixes https://gitlab.com/kicad/code/kicad/issues/14603
2023-04-28 18:32:58 +01:00
Lucas Dumont b1a4353c34 Update collide for hole
As hole don't keep track of the net, update the collide function to keep it working
2023-04-28 10:20:55 +00:00
Jeff Young b2a45023bc Tighten ownership model of PNS::ITEM.
In particular, ownership must be explicitly set.  It is
no longer inherited through copy/clone/etc.
2023-04-28 11:05:39 +01:00
Jeff Young 9646e3c1c0 Simplify PNS::VIA construction. 2023-04-28 00:32:49 +01:00
Lucas Dumont 2992d7c68b Fix typo in QueryConstraint switch 2023-04-26 13:20:32 +00:00
jean-pierre charras b9ed84b7db Fix minor compil warnings 2023-04-25 12:43:15 +02:00
Lucas Dumont e2e901de1d Don't override clearance when routing
The default `m_overrideClearance = -1` used here was changed to 1.
Reseting it to -1 to solve linked issue

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14595
2023-04-25 09:18:53 +00:00
Jeff Young 676a15df65 Don't try to keep track of a HOLE's net.
Keep track of it's parentPadVia instead.

Fixes https://gitlab.com/kicad/code/kicad/issues/14603
2023-04-24 18:32:17 +01:00
Seth Hillbrand 990641d2eb Cleanup printf bits 2023-04-20 15:19:04 -07:00
Lucas Dumont 469fe76994 pcbnew: Fix crash with differential routing
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14537
2023-04-17 14:17:14 +12:00
Jeff Young 26609bbf05 Fix PNS_KICAD_IFACE_BASE::IsFlashedOnLayer() to be able to handle multi-layer queries. 2023-04-14 12:02:36 +01:00
Jeff Young 6059e895d7 Fix a typo.
Fixes https://gitlab.com/kicad/code/kicad/issues/14515
2023-04-12 10:45:24 +01:00
Jeff Young 6fb30398ca Don't steal an existing via's hole. 2023-04-11 17:48:27 +01:00
Jeff Young ab0dbeb523 Post-holes-work cleanup. 2023-04-11 15:51:00 +01:00
Jeff Young 2f198bdcb2 Further simplify PNS::ITEM::collideSimple().
Also brings text_pns_basic's mocks into line with their "real"
counterparts.
2023-04-11 15:51:00 +01:00
Jeff Young 6f0d963683 Add PNS::ITEM::BoardItem() call.
About 1/3 of callers to Parent() don't care if they get the immediate
parent or not, about 1/3 want only the immediate parent, and about 1/3
want the hole parent's Parent().

I had earlier changed PNS::ITEM::HOLE to override Parent() and return
the hole parent's Parent(), but since the callers are pretty evenly
split I've reverted that and added BoardItem() for callers who want the
eventual BOARD_ITEM (whether a direct parent or a grandparent).

(Also removes a dead routine so I didn't have to figure out which of
the two it wanted....)
2023-04-11 15:51:00 +01:00
Jeff Young 8a0c225efa Unify most special-case processing to the clearance if-then-else.
This also allows us to support hole-to-hole clearance when dragging
a via near another via on the same net.

Fixes https://gitlab.com/kicad/code/kicad/issues/12781
2023-04-11 15:51:00 +01:00
Jeff Young b18bf09208 Don't return holes that have a parent pad or via.
(While we don't currently have holes without a parent pad or via, you
could imagine using HOLEs in the future to represent a hole in a first-class
board outline, so better not to build this assumption in.)
2023-04-11 15:51:00 +01:00
Jeff Young 4cc289c6fb Post-merge cleanup of holes-as-first-class-citizens. 2023-04-11 15:51:00 +01:00
Tomasz Wlostowski 1532a83330 router: hole as first-class-object, initial version of rewritten collision check routine
Rebased and modified by Jeff Young <jeff@rokeby.ie> 6 April 2023
2023-04-11 15:51:00 +01:00
Tomasz Wlostowski d961cdce3f router: further changes to the ownership model
- LINEs now own their vias optionally (depending whether a LINE with its VIA belongs to a node)
- get rid of unique_ptr on the internal NODE::Add API (and also made it private)
- make sure stack pointers are not added to the node
- use rvalue reference for NODE::Add/NODE::Replace

Manually rebased by Jeff Young <jeff@rokeby.ie> 5 April 2023
2023-04-11 15:51:00 +01:00
Tomasz Wlostowski bfbda978b8 router: hole as first class objects, wip
Rebased by Jeff Young <jeff@rokeby.ie> 5 April 2023

(Also includes a bug-fix for highlighting collisions with edge-cut
items.)
2023-04-11 15:51:00 +01:00
Jeff Young 507a25f150 Don't call BuildInitialTrace() for entry gateways.
We're going to call it to connect the entry and target gateways
anyway, so all we need are gateways at 22.5 degrees to setup entry
at +/- 45 degrees from the current direction.

Fixes https://gitlab.com/kicad/code/kicad/issues/14324

Fixes https://gitlab.com/kicad/code/kicad/issues/12459
2023-04-11 15:34:55 +01:00
Jeff Young 11995c1350 Improve readability. 2023-04-11 15:26:39 +01:00
Jeff Young d040690f60 Ease acquisition of a target item.
pickSingleItem() had a two-attempt algorithm, but the second attempt
was never made because we'd check for no hits before throwing out the
aAvoidItems.

The second attempt would fail anyway because QueryHoverItems() ignored
the aUseClearance flag when not idle, and didn't factor in the actual
clearance.
2023-04-09 22:05:17 +00:00
Jeff Young 1d19672054 Handle more pad shapes when building diffpair gateways.
Fixes https://gitlab.com/kicad/code/kicad/issues/1883
2023-04-09 22:05:17 +00:00
Jeff Young e522e73e0e Improve readability. 2023-04-08 15:06:49 +01:00
Jeff Young 3b63d70d01 Centralize NPTH has-annulus processing.
Fixes https://gitlab.com/kicad/code/kicad/issues/13437
2023-04-08 15:06:49 +01:00
Tomasz Wlostowski 1283c4713f router: rework ITEM ownership model.
- prerequisite for holes as first class objects code
- introduced the OWNABLE_ITEM interface that defines the owning container (NODE/other ITEM/ITEM_SET)
- simplified the ITEM_SET interface
- constified a lot of APIs (ownership/JOINT management) as a side effect

Rebased and cleaned up by Jeff Young <jeff@rokeby.ie> 5 April 2023
- some STL cover types removed
2023-04-05 11:21:31 +01:00
Tomasz Wlostowski eed05191a9 router: pass collision query options in a structure
Selectively cherry-picked by Jeff Young <jeff@rokeby.ie> 4 April 2023
- Jon's user-clearance-epsilon algo kept intact
- Jeff's castellated-pad code kept intact
2023-04-05 11:21:31 +01:00
Jeff Young bbd6c80507 Collapse FP_* down into their PCB_* equivalents. 2023-03-31 22:57:46 +01:00
Wayne Stambaugh 28776f5745 Text attributes object improvements.
* Add compare method to COLOR4D object.
* Add unit test to validate COLOR4D comparison method.
* Add missing color test in text attribute comparison method.
* Add unit test for text attribute object.
* Remove unnecessary headers from text attribute header.
* Move text attribute code into separate source file.
2023-03-29 12:53:45 -04:00
jean-pierre charras 893a362d9e Minor Coverity and compil warnings fix. 2023-03-15 20:09:04 +01:00
Mike Williams 74a9d79a8d Router: fix Continue From End/ Attempt Finish work for diff pairs
Fixes: https://gitlab.com/kicad/code/kicad/-/issues/13772
2023-03-08 12:23:04 -05:00
Mike Williams 8d3e1eb52a Continue From End: support other placement algos 2023-03-08 12:01:29 -05:00
Mike Williams e7555aa45f PNS Router: arcs are directional, too
Fixes: https://gitlab.com/kicad/code/kicad/-/issues/10391
2023-03-08 12:01:29 -05:00
Mike Williams 5bc018f7dc PNS Diff Placer: fix invalid cast of Arc to Segment and derefence 2023-03-08 12:01:29 -05:00
Wayne Stambaugh a1fb8e1b1d Coverity fixes and code cleaning. 2023-03-06 07:12:18 -05:00
Wayne Stambaugh 4e99812145 Coverity fixes and code cleaning. 2023-03-04 13:02:05 -05:00
Wayne Stambaugh 789bf6455a Coverity fixes and code cleaning. 2023-03-02 09:04:47 -05:00
Ian McInerney c6e417c19c Fix missing override statements 2023-02-22 01:44:06 +00:00
Marek Roszko aacc9746e3 Yeet the last of wxSize/wxPoint to stop leaking gdicmn everywhere 2023-02-18 22:57:18 -05:00
Jon Evans f12f2b8420 PNS: Diff pairs can have different hole-to-hole size
Fixes https://gitlab.com/kicad/code/kicad/-/issues/13993
2023-02-17 19:56:02 -05:00
Jon Evans 459473ccc3 PNS: Safety for evaluating item nets for rules
Fixes https://gitlab.com/kicad/code/kicad/-/issues/13993
2023-02-17 19:56:02 -05:00
Jon Evans 2d7c5c5c0f Router: Do not collide items within a net tie footprint
Fixes https://gitlab.com/kicad/code/kicad/-/issues/13909
2023-02-14 21:08:36 -05:00
Alex bf1a8f2582 router: Fix clamp in meander corner radius calculation.
Fixes https://gitlab.com/kicad/code/kicad/issues/13781
2023-02-05 07:22:38 +03:00
Alex 6543d23d9f router: Re-add electrical path lines drawing for length tuning. 2023-02-01 20:36:52 +03:00
Jon Evans 48e4005111 Fix diff pair router checking of min clearance
Fixes https://gitlab.com/kicad/code/kicad/-/issues/13720
2023-01-31 19:53:35 -05:00
Jon Evans 971abcfc1a Fix DP meander placer when tuning from an uncoupled section
Fixes https://gitlab.com/kicad/code/kicad/-/issues/12212
2023-01-28 22:25:46 -05:00
Jeff Young 8268234aa1 Reverse shown-source logic so we report if it's the netclass width.
(whether or not it's *also* the previous track width).
2023-01-27 15:31:02 +00:00
Alex e3fa447f0c router: Remove extra qualification. 2023-01-27 11:56:23 +03:00
Alex 0ff6cb49d6 router: When dragging tracks, don't snap to parts of the original line.
Fixes https://gitlab.com/kicad/code/kicad/issues/10113
2023-01-27 11:06:36 +03:00
Mike Williams a76a4f9788 Router: don't unnecessarily change track widths on layer change
Fixes: https://gitlab.com/kicad/code/kicad/-/issues/13546
2023-01-25 09:34:17 -05:00
Jeff Young 89d434255c Run clearance rules for router status bar.
Fixes https://gitlab.com/kicad/code/kicad/issues/13605
2023-01-20 14:19:58 +00:00
Tomasz Wlostowski 761e754294 router: trying to improve the 'guess posture' algorithm to work well with both fix-all and fix-last-segment on click 2023-01-12 23:37:07 +01:00
Tomasz Wlostowski 65def26b4d router: follow up ROUTER::GetUpdatedItems() API changes in the ROUTER_TOOL 2023-01-12 23:37:07 +01:00