Commit Graph

216 Commits

Author SHA1 Message Date
Jeff Young f3db64af05 Multi-threading safety.
(Possible fix for KICAD-74.)

(cherry picked from commit b76ef8c7e2)
2023-04-16 15:38:22 +01:00
Jeff Young fbef9ea600 Keep track of single-pad-islands so we can discount spokes to them.
(cherry picked from commit d6dd58fff9)
2023-03-25 15:37:57 +00:00
Seth Hillbrand 9995b8714b Check for dirtied items in the cluster
When drawing the ratsnest, we need to be careful to avoid accessing
CONN_ITEMs that have been changed by the underlying model.  Checking for
dirty items instead of valid items will prevent us looking at data that
are out of date

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

(cherry picked from commit 283770fc45)
2023-03-13 16:11:27 -07:00
Salvador E. Tropea d311915f9d Fix the CONNECTIVITY_DATA::GetNetItems Python API
- The C++ member now uses std::vector<KICAD_T>
- The Python side can use a single value or a list,
  like in v6.

The std::vector translation is based on the v6 KICAD_T[]
translation.
2023-03-01 18:49:12 +00:00
Seth Hillbrand 6fb9d190ac Use the common subset of nets for local update
When adding new data, we may have differing sizes of the dynamic
ratsnest and our local copy, so ensure that we are only referencing
elements that exist in both
2023-02-10 12:50:29 -08:00
Jeff Young f2f54fe926 Improve zone-layer-connections terminology and comments.
This makes it clearer that the overrides are not inverses of each
other -- one overrides the flashing state and the other overrides
the connection state (to other zones, not to everything).

Also fixes a bug where we were failing to check the force-no-connect
for pads.
2023-02-05 17:39:42 +00:00
Seth Hillbrand dde336ee40 Split connectivity mutex locking
Internal routines have no need for locking the mutex they already own.
While external routines that want to recalculate the Ratsnest do need an
exclusive lock before being allowed access

Fixes https://gitlab.com/kicad/code/kicad/issues/13011
2023-02-03 15:26:19 +01:00
Seth Hillbrand a0236113da Attempt fix to RATSNEST crash
We call 'RecalculateRatsnest' in multiple locations, this will
invalidate various pointers needed by VIEW::Redraw().  When this is
called through the normal connectivity routines, we have the mutex
locked to prevent conflict but we've added more locations that update
just the Ratsnest.  The std::adopt_lock should take over the existing
lock when needed

Fixes https://gitlab.com/kicad/code/kicad/issues/13011
2023-01-26 17:32:38 -08:00
Seth Hillbrand e713a3eac2 Handle cleanup safely
Make sure that the connectivity has successfully completed before
attempting to merge segments.  Also avoids reaching into the shared_ptr
if we don't need to

Fixes https://gitlab.com/kicad/code/kicad/issues/13639
2023-01-23 15:56:46 -08:00
Jeff Young 509b39e9e4 Propagate nets within non-conflicting clusters immediately.
Fixes https://gitlab.com/kicad/code/kicad/issues/13601
2023-01-23 16:25:29 +00:00
Jeff Young c430c88f9d Immediate update of no-net objects when they're connected to something else.
Fixes https://gitlab.com/kicad/code/kicad/issues/13601
2023-01-23 16:25:29 +00:00
Jeff Young 3cc960a872 Push nets to free pads when they're used.
Fixes https://gitlab.com/kicad/code/kicad/issues/13516

Fixes https://gitlab.com/kicad/code/kicad/issues/13517
2023-01-17 23:29:47 +00:00
Jeff Young e916b715d5 Special case for very-short tracks was killing both-ends-in-a-zone.
(And doing so randomly as if the closer endpoint to the zone center
was the one without a pad then it would get marked as good, while if
it was the other way around we'd notch 2 connections for the pad end
and none for the other end.)

Fixes https://gitlab.com/kicad/code/kicad/issues/13420
2023-01-09 13:35:54 +00:00
Seth Hillbrand 66e9d5c61c Return reference rather than copy
No need to return a const copy by default in GetItems().  The const
reference will be faster.  Thanks to @GyrosGeier for the suggestion
2022-12-16 10:52:57 -08:00
Seth Hillbrand f9a36b9c91 Update thread_pool to 3.3
Fixes an issue with `wait_for_tasks()` and adds a lower-overhead
`push_loop` helper.  We replace our usage of `parallelize_loop` with
`push_loop` as we didn't use the multi-future vector return and don't
need the extra overhead.
2022-12-02 12:01:34 -08:00
Jeff Young 19eab62516 More safety around ratsnest state.
Fixes https://gitlab.com/kicad/code/kicad/issues/13011
2022-11-30 13:00:21 +00:00
Jeff Young b42d5da07d Check keepTopBottom when determining whether or not to flash a pad/via.
Fixes https://gitlab.com/kicad/code/kicad/issues/12961
2022-11-22 18:18:43 +00:00
Jeff Young 50089ce558 Fix errors in handling of std::shared_ptrs.
We can't reset to a pointer owned by another std::shared_ptr.
2022-11-22 13:14:00 +00:00
Jeff Young 226529235c Mostly const safety, but also performance opt. by avoiding shared_ptr overhead. 2022-11-22 12:21:30 +00:00
Jeff Young 11130bfd88 Backing out earlier fix in favour of fixing std::shared_ptr usage.
Assigning to a reference to a std::shared_ptr does not update the
reference to a different std::shared_ptr; it changes what the
std::shared_ptr points to.

Fixes https://gitlab.com/kicad/code/kicad/issues/12968
2022-11-21 21:56:17 +00:00
Jeff Young 106508f266 Split ratsnest optimization into separate parallel threads.
Fixes https://gitlab.com/kicad/code/kicad/issues/12968
2022-11-21 18:50:44 +00:00
Jeff Young 3451506d25 Slight performance improvement. 2022-10-20 18:37:48 +01:00
Jeff Young 437d2c4589 Overhaul of remove-unconnected's zone filling and drawing strategies.
1) The highest priority zone that a via/pad collides with "owns" its
connectivity state.  Once set, lower priority zones cannot change it --
and in fact, if they would have connected to it are forced not to.

2) The connectivity state goes with the zone fill state, and therefore
must be saved in the file.

3) Display of remove-unconnected's pads is no longer done in GetViewLOD()
(which isn't called for selected items), and is instead done in PCB_PAINTER.
This allows us to draw the full pad in outline mode when a via/pad is
selected which would otherwise only show the hole.

4) Note that in some cases this will still generate DRC errors -- in
particular when a via nearly collides with a higher priority zone it
won't get "owned" by that zone and may therefore have insufficient
clearance if said zone concludes it's unconnected and a subsequent
(lower priority) zone connects to it (causing it to now become flashed).

Fixes https://gitlab.com/kicad/code/kicad/issues/11299
2022-10-18 13:05:42 +01:00
Seth Hillbrand c9f11827a7 Don't connect disparate nets
Only some elements get their nets assigned based on connectivity.  Other
elements should be keps in different clusters for connection

Fixes https://gitlab.com/kicad/code/kicad/issues/12622
2022-10-11 15:03:51 -07:00
Seth Hillbrand 87171f53c7 Speedup dynamic ratsnest
Removes some unneeded calculations and threads the remaining.

Threading was previously removed to avoid overhead issues with small
boards.  This is no longer needed with the thread pool implementation

Fixes https://gitlab.com/kicad/code/kicad/issues/12131
2022-10-04 17:06:45 -07:00
Seth Hillbrand 15d52c91e4 Clear ratsnest when removing nets
While we can keep the vector for nets, we need to ensure that the data
are cleared to prevent stale pointer access

Fixes https://gitlab.com/kicad/code/kicad/issues/12564
2022-10-03 09:33:31 -07:00
Seth Hillbrand 6d298b661a Minor speedup for some dynamic ratsnest cases 2022-10-01 13:43:57 -07:00
Jeff Young f095453d3e Optimize ratsnest line endings for zones. 2022-09-30 19:04:54 +00:00
Jeff Young d67437a2aa Move ratsnest exclusion processing to a post-pass.
Also fixes a few cases where we were unnecessarily rebuilding
connectivity more than once for an operation.
2022-09-29 17:08:49 +01:00
Alex dc07ab9df1 Replace PROF_COUNTER with PROF_TIMER in some conditional places. 2022-09-27 14:07:47 +00:00
Mike Williams 700edb95e3 PCB Actions: Grab Unconnected
Grabs the nearest unconnected item for each selected footprint/pad.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/1986
2022-09-26 16:17:41 -04:00
Seth Hillbrand 26a1114e3c Avoid Yields when the results are ready
We always need to check for calculation results before yielding the
system otherwise we will delay outcomes

Fixes https://gitlab.com/kicad/code/kicad/issues/12228
2022-09-14 13:30:04 -07:00
Jeff Young c30a557810 ADDED netclass assignment from PCB canvas.
Fixes https://gitlab.com/kicad/code/kicad/issues/5975
2022-09-03 19:29:59 +01:00
Jeff Young 2dc6300501 Move EDA_ITEM bounding boxes to BOX2I. 2022-08-31 10:16:55 +01:00
Jeff Young aa2ad3b44c Move KICAD_T[] to std::initializer_list<KICAD_T>. 2022-08-20 10:28:11 +01:00
Seth Hillbrand 35ac39844f Clean up some auto usage
Don't make new copies of shared_ptr if we can use references.  Keep auto
usage down to hard-to-type-out sequences
2022-08-15 11:29:45 -07:00
Jeff Young a9536b5de9 CHANGED netclass assignments now done via canvas or via patterns. 2022-08-14 22:56:29 +01:00
Jeff Young 96f01d33c8 Performance improvements.
1) Move a bunch of std::map's to std::unordered_map to get constant-time
look-ups
2) Lengthen progress-reporting intervals to spend more time doing work
and less time talking about it
3) Reverse order of SHAPE_LINE_CHAINs in thermal intersection checks to
make (much) better use of bbox caches
4) Don't re-generate bboxes we already have
5) Fix some autos that weren't by reference (and were therefore copying
large datasets)
6) Rename delta progressDelta so it's easier to search for in future
7) Get rid of a few more autos (because I don't like them)
8) Pass large items to lambdas by reference

Fixes https://gitlab.com/kicad/code/kicad/issues/12130
2022-08-03 11:59:42 +01:00
jean-pierre charras 4d48376eae Fix some warnings detected by PVS-STUDIO (not used vars) 2022-07-26 16:00:14 +02:00
Jeff Young f41af10007 Clean up hole shapes for safety (smart pointer) and consistency. 2022-07-22 23:06:07 +01:00
Seth Hillbrand 03c279ffd4 ADDED: Threadpool
Thread pools are long-lasting executors that have close to zero overhead
when launching new jobs.  This is advantageous over creating new threads
as we can use this for threading smalling jobs and smaller quanta.  It
also avoids the heuristics needed to determine the optimal number of
threads to spawn
2022-06-24 22:59:24 +00:00
Jeff Young 82ebc247b8 More performance enhancements for DRC. 2022-06-18 19:47:11 +01:00
Jeff Young 3f502b313d Don't return false when a particular item doesn't connect.
We still have to search all the other items, as they might connect.
2022-05-23 10:26:18 +01:00
Seth Hillbrand 442aae19d9 Separate flashing check for connectivity
When building the connectivity database, we should not be using the
connectivity to check for shapes.

To make this deterministic, we introduce two flags (ALWAYS_FLASH and
NEVER_FLASH) that are used with connectivity building to determine
whether a pad is flashed for connectivity or not.  ZONE <-> PAD/VIA
connectivity will be checked with ALWAYS_FLASHED and all other
connectivity will be checked with NEVER_FLASHED if they are marked for
potential annular ring removal.  If they are not marked for removal,
they will be checked ALWAYS_FLASHED.

Fixes https://gitlab.com/kicad/code/kicad/issues/11114
2022-03-16 17:30:01 -07:00
Jeff Young cabcaf933c Cleanup. 2022-03-16 14:56:32 +00:00
jean-pierre charras 7fb4a2c0a5 CONNECTIVITY_DATA::IsConnectedOnLayer(): fix crash in some cases.
Fix crash when a zone do not have filled areas on a given layer.
2022-03-12 19:31:46 +01:00
Jeff Young 0a8718cd1d Fix issue when we ask if a pad is connected to a zone we're in the middle of filling. 2022-03-12 14:17:53 +00:00
Jeff Young eb9ccea559 Performance improvement. 2022-03-10 13:46:42 +00:00
Jeff Young fed5bcbdf6 Improvements for pads/vias in zones which knockout other zones.
1) Drop tiny islands which might cause connection problems.
2) Cleanup some dead code in filler
3) Don't estabilish a connection to an island that is fully covered
by whatever its connecting to.

Fixes https://gitlab.com/kicad/code/kicad/issues/11036
2022-03-05 18:59:53 +00:00
Seth Hillbrand b5c2f0d39a Remove the open array in favor of std containers
The containers allow iteration, size knowledge and lower bug surface
2022-03-03 16:03:26 -08:00