Commit Graph

173 Commits

Author SHA1 Message Date
Wayne Stambaugh ede39780e2 Remove all debugging output that cannot be disabled.
The use of printf, wxLogDebug, and std::err/std::out causes excessive
debugging output which makes finding specific debugging messages more
difficult than it needs to be.

There is still some debugging output in test code that really needs to
be moved into a unit test.

Add debugging output section to the coding policy regarding debugging
output.
2020-08-18 10:17:36 -04:00
Jon Evans bd14f8a82a ADDED: New appearance control widget for PcbNew
Featuring:
- Layer view presets
- Per-type opacity for tracks, vias, pads, zones
- Net and netclass color and visibility controls

CHANGED: Simplified object visibilty controls

Fixes https://gitlab.com/kicad/code/kicad/-/issues/1951
Fixes https://gitlab.com/kicad/code/kicad/-/issues/1981
Fixes https://gitlab.com/kicad/code/kicad/-/issues/2003
Fixes https://gitlab.com/kicad/code/kicad/-/issues/2173
Fixes https://gitlab.com/kicad/code/kicad/-/issues/2254
Fixes https://gitlab.com/kicad/code/kicad/-/issues/4325
2020-08-15 15:24:28 -04:00
Seth Hillbrand b8b3d5c16d pcbnew: Remove all threading from dynamic ratsnest
The last remaining threaded operation in dynamic ratsnest was the
recalculation of the dynamic connectivity map.  Because we do not
require any of the extra features of the connectivity map, we can get
away with a lightweight move of the anchors to update the ratsnest.  The
resulting connectivity tree is not valid but it is not needed for the
ratsnest, which only needs a list of nets/anchors.
2020-08-14 17:48:33 -07:00
Seth Hillbrand 027b6c8cf9 Account for via width in connectivity
Fixes https://gitlab.com/kicad/code/kicad/issues/5176
2020-08-13 20:31:17 -07:00
Seth Hillbrand b351bec0d7 Handle blind/buried vias in connectivity 2020-08-13 20:14:23 -07:00
Seth Hillbrand f36c158696 Remove via contact minimum from connectivity check
Connectivity takes an absolute approach to whether elements are
connected.  DRC will be adjusted to check to illegal necks that are less
than the board minimum width
2020-08-10 14:47:49 -07:00
Seth Hillbrand e5ab97994d pcbnew: Fix error in proximity calc for zones
Zone ContainsPoint() accuracy should be calculating the radial distance
and so does not need to be halved.
2020-08-10 14:46:34 -07:00
Seth Hillbrand 5096deeb3b pcbnew: Handle module ratsnest
Ensure we display the module ratsnest appropriately
2020-08-10 12:09:32 -07:00
Seth Hillbrand 5fc6b74c89 ADDED: Remove unused pads
This option removes copper layers from pads and vias where they are not
connected to other board elements.  This allows the inner layers to be
more closely routed if the via landing pad is not needed.

Fixes https://gitlab.com/kicad/code/kicad/issues/1835
2020-08-10 03:27:26 +00:00
Seth Hillbrand f615b026d9 pcbnew: Account for zone expansion in conn
Connecting zone-to-zone, we need to allow for the stroke-width in
old-style polygons.

Also, speed up the calculation by skipping zone points that do not fall
inside the matching BBox

Fixes https://gitlab.com/kicad/code/kicad/issues/5043
2020-08-07 15:59:39 -07:00
Seth Hillbrand 406de56964 pcbnew: Prevent use of non-connected item in ratsnest
We need to be careful in the connectivity system to always use
dyn_cast/dynamic_cast and check the return when dealing with board
items.  Getting non-connected items will result in null nets when
propagated.

Fixes https://gitlab.com/kicad/code/kicad/issues/5082
2020-08-07 13:38:51 -07:00
Jeff Young 6a4f611e61 Special handling for connecting vias in hatched zones.
Fixes https://gitlab.com/kicad/code/kicad/issues/2568
2020-08-06 00:03:00 +01:00
Seth Hillbrand 8a0be64ad4 Ensure dangling test takes track width into account
When running a hit test to check if the anchors are connected, we should
loosen the check for tracks to account for the width.  Otherwise
connected anchors can be connected in the system but test positive for
IsDangling()

Fixes https://gitlab.com/kicad/code/kicad/issues/5027
2020-08-05 13:17:29 -07:00
Seth Hillbrand a5a56c46c3 Remove INTRUSIVE_LIST from CN_ITEM
Intrusive lists made the connectivity search not thread-safe.  Using
iterators for item deletion provides the same order performance while
keeping the container thread-localized
2020-07-28 09:29:32 -07:00
Jeff Young bf445c1a95 Performance enhancements.
1) cache pad polygon outlines
   huge improvement in connectivity performance and a decent
   improvement in DRC performance
2) don't pre-allocate CONTEXT stack
   significant improvement in DRC rule performance
2) don't keep re-encoding strings
   decent improvement in DRC rule performance
2020-07-25 13:03:33 +01:00
Seth Hillbrand 54aaade47e 'const void' is not a return type 2020-07-02 11:43:18 -07:00
Jon Evans f8bfb2bc16 Fix several issues with multilayer zones
- Properly refill if layer set is modified
- Fix some threading issues with island removal
- Fix copy constructor

Fixes https://gitlab.com/kicad/code/kicad/-/issues/4765
2020-07-01 20:51:44 -04:00
Jon Evans 1d5e4f86af ADDED: Copper zone island removal is now configurable
ADDED: Zones and keepouts can now be named (for DRC)

Fixes https://gitlab.com/kicad/code/kicad/-/issues/4392
2020-06-28 09:09:38 -04:00
Jon Evans 0d4ee39f75 CHANGED: Copper zones can be on more than one layer
Fixes https://gitlab.com/kicad/code/kicad/-/issues/1963
2020-06-28 08:52:37 -04:00
Seth Hillbrand 4ef02fd699 Replace TTL delauney triangulator
Removes the TTL triangulator in favor of the delaunator triangulator.
This removes the only AGPL code in the KiCad codebase and therefore
allows the full project to be licensed under the GPLv3.
2020-06-25 18:45:27 +00:00
Seth Hillbrand 4c5f3cb5be Fix crash when moving non-connected
Non connected items do not have netcodes, so shouldn't be included in
the calculation for ratsnest
2020-06-24 14:22:01 -07:00
Seth Hillbrand a2ad84f84d Revise Kruskal implementation
This updates the Kruskal algorithm to a faster variant utilizing a
compressed disjoint set and heap
2020-06-23 14:35:23 -07:00
Seth Hillbrand 104ff29e5f Remove delauney computations from dynamic ratsnest
Avoids additional calculations on movement by using cached ratsnest for
internal nets and keeping bicolored line calc for others.

Fixes https://gitlab.com/kicad/code/kicad/issues/1865
2020-06-22 20:37:31 -07:00
Jeff Young d01b29ab37 Cleanup pad geometry handling.
There were a lot of plotters, exporters, etc. that were rolling their
own implementations.

This also introduces a lazily-built set of SHAPE objects for doing
collision detection and some forms of rendering (and later DRC).
2020-06-22 22:28:37 +01:00
Seth Hillbrand 8c57821e9b pcbnew: Move ratsnest items to separate folder 2020-06-16 11:15:14 -07:00
Jeff Young aedc624340 Add DRC checks for dangling vias and tracks.
Fixes https://gitlab.com/kicad/code/kicad/issues/1999
2020-05-14 22:02:47 +01:00
Oleg Endo ff5828fc33 fix formatting and update comments 2020-04-21 13:23:56 +00:00
Oleg Endo 4c7471eb79 add more constness to connecivity algo
also make ForEachAnchor inlineable, like ForEachItem.
remove some unused function declarations.
2020-04-21 13:23:56 +00:00
Oleg Endo 3de5b98316 improve performance of CONNECTIVITY_DATA::GetNetItems
- CN_CONNECTIVITY_ALGO::ForEachItem
move implementation to header, so that a lambda can be inlined by the
compiler.  improves iteration performance x2

- CN_ITEM::Net
move implementation to header, so that it can be inlined by the
compiler.

- CONNECTIVITY_DATA::GetNetItems
don't use std::set to filter out duplicates.  use std::unique on sorted
vector.  use a bitset to perform type check.
2020-04-21 13:23:56 +00:00
Seth Hillbrand 3d151ebd71 Cleanup connectivity parts
Removes unneeded casts from the connectivity algo.
2020-03-05 12:41:54 -08:00
Seth Hillbrand 8c19b4b6ae pcbnew: Adding arcs to PNS
This is allows ARCs in tracks to be synchronized with
the PNS router.  Note this does not yet include the UI components
to route curved traces
2020-02-21 16:11:41 -08:00
Ian McInerney 43abd53b19 Clarify limits of the if statement 2020-01-11 21:28:25 +00:00
Seth Hillbrand 7c28c3838a Comment-only changes
Makes class comments conform to coding standards
2020-01-10 16:43:01 -08:00
Seth Hillbrand c6f5df134c Minor speed cleanup
This adjusts iterators to use const reference when only used for
copy.  It also ensures pre-allocation of vectors when size is known
ahead of time.
2019-12-05 14:20:59 -08:00
Seth Hillbrand a2edf9c442 Unified update to C++14 std::make_unique
This update replaces the existing uses of unique pointer creation with
the C++14 std::make_unique call that provides proper memory release in
event of an exception.
2019-12-05 10:43:55 -08:00
Jeff Young c29a0b1966 Fix geometry error in connectivity algorithm.
For custom pad shapes were were calculating cardinal points off
of the bounding box.  However, the bounding box must be rotated
around the pad's position, rather than its shapePos -- which is
an issue since any thermal spokes will be rotated around the
shapePos.

Of course we don't really need to sort that out because we're
doing an intersection of the pad's boundary polygon with a vector
from the shapePos out to the cardianl point -- so we really just
need the cardinal point to be "out there".  So I've changed it
to use use INT_MAX / 2.

Fixes: lp:1851703
* https://bugs.launchpad.net/kicad/+bug/1851703
2019-11-10 14:52:01 +00:00
Jeff Young a6a4973324 Handle rotation for N/S/E/W pad cardinal points.
Fixes: lp:1844727
* https://bugs.launchpad.net/kicad/+bug/1844727
2019-11-05 17:22:51 +00:00
Jeff Young 429c7055e9 Some performance enhancements contributed by Oleg Endo.
Fixes: lp:1846438
* https://bugs.launchpad.net/kicad/+bug/1846438
2019-10-04 19:41:40 +01:00
Jeff Young 0ad9ddb3a6 Use cached bounding boxes for performance.
Fixes: lp:1846438
* https://bugs.launchpad.net/kicad/+bug/1846438
2019-10-04 11:45:08 +01:00
Seth Hillbrand 4d8949371f conn: Connect pads to anchor points not geo center
Pads may include offsets that allow the user to shift the connection
point of the pad.  This is captured by the pad m_Pos but not by
ShapePos().  When testing connectivity, we need to get the offset
position.
2019-09-19 13:49:12 -07:00
Seth Hillbrand b7128639f8 connectivity: Check all anchors for connection
With pads, we should check available anchor points for each connection,
increasing probability of finding connection to match fill algorithm

Fixes: lp:1844661
* https://bugs.launchpad.net/kicad/+bug/1844661
2019-09-19 12:44:40 -07:00
Seth Hillbrand 820c2d2722 pcbnew: Fix error in connecitivty calculation
Point in polygon should test against half the stroke width as the stroke
is performed _on_ the polygon edge.
2019-08-23 10:45:41 -07:00
Seth Hillbrand 18b6bdf5dd Use cached bbox for connectivity
On large boards, connectivity checks are hotspots.  We use the cached
bbox to avoid re-computing polygons for pads.
2019-08-23 10:45:41 -07:00
Jeff Young 809a4e3c0e Improve connectivity tests for pads.
We now test N, S, E and W as well as center.

Fixes: lp:1840721
* https://bugs.launchpad.net/kicad/+bug/1840721
2019-08-23 17:44:10 +01:00
jean-pierre charras dd702cd53d Remove pads not on copper layers (just on tech layers) from connectivity calculation.
Pads not on copper layers now do not have a netname, and are no longer taken in account in connectivity.
Especially it avoid creating useless rats-nests for these pads.
2019-07-25 13:08:41 +02:00
jean-pierre charras c9ccd8a642 Fix broken TRACKS_CLEANER algo to merge collinear track segments. 2019-06-28 20:23:09 +02:00
jean-pierre charras 71aafb6eb3 Pcbnew, connectivity: fix incorrect detection of dangling track ends when a end is inside a zone.
This end was not detected as connected by the IsDangling method.
Fix incorrect cleaning of dangling tracks in track cleaner.
Remove also a dead code.
The merge co-linear track segments is still full bugged in track cleaner.
2019-06-28 15:25:50 +02:00
Tomasz Włostowski 51b9319246 pcbnew: updated connectivity algorithm to support JP's no-outline zones 2019-06-12 20:57:31 +02:00
Seth Hillbrand 90f06c56a9 Add mutex to connectivity
We were piggy-backing on the includes from previous files that no longer
have mutex.
2019-06-05 15:55:52 -07:00
Seth Hillbrand 9163ac543a pcbnew: Move pads to std::deque 2019-06-01 16:23:54 -07:00
Jon Evans 52a9e68093 Store items changed by connectivity algorithm in undo list
Fixes: lp:1828442
* https://bugs.launchpad.net/kicad/+bug/1828442

(cherry picked from commit fb80ee5a0e)
2019-05-24 21:56:37 -04:00
Seth Hillbrand 6f7475dcd3 pcbnew: Prevent no-connects from driving clusters
The no-connect net (0) should never drive the net of a cluster.
Otherwise, tracks connecting between unconnected pads and connected pads
can acquire net 0 incorrectly.
2019-05-21 19:29:29 -07:00
Jeff Young dae41b7460 Remove legacy segment-based zones.
Give the user the option of cancelling a file open if there are
segment zones; otherwise they're converted to polygon fills.

Fixes: lp:1823087
* https://bugs.launchpad.net/kicad/+bug/1823087
2019-04-12 20:19:23 +01:00
jean-pierre charras fdfe5eabfb Fix incorrect detection of filled zones changes in DRC check.
Commit 6006703798 fixed a crash but broke the filled zones changes detection.
Filled zones were always seen as not up to date due to the fact the filled areas were cleared too early.

The up to date detection is also optimized: the old filled polygons are no longer stored.
Instead of, the MD5_HASH is calculated and stored before clearing the filled polygons.
2019-03-21 15:27:05 +01:00
John Beard e6a6266f3d Build: libpolygon provides its own includes
Libpolygon can provide its own includes via target_include_dirs PUBLIC.
This means any linking targets do not need to specifiy them manually.

As common requires polygon, the polygon dep is also now no longer
required downstream of libcommon, as it's transisitvely implied
by libcommon's target_link_libraries.

This resolves a circular dependency previously detected and also
simplifies CMakeLists.
2019-02-04 19:29:31 -08:00
John Beard bb2ae8e13b Bitmaps: move bitmap defs to bitmaps library
The bitmap definitions (BITMAP_DEF and so on) do not
have any dependencies on other libs, including WX. This
means the bitmaps library can be isolated from the other
dependencies.

Common now depends on bitmaps, and libraries that depend
on common can pick it up from the common target_link_libraries,
as it is PUBLIC. This means a lot of targets no longer
need manual bitmap linkage.

This avoids a circular dependency that was previously reported
by static analysis.

Avoiding pulling in WX and other headers into the include
tree of each bitmap .cpp is a huge speed up (around 10x) in
compilation, and the generated static library is also 10x
smaller (20MB vs 200MB)

Add common as a link library to pnsrouter,connectivity.
THese library do still use common code (including bitmaps,
via base_screen.h) and this allows them to pick up the libcommon
includes correctly.
2019-02-04 19:29:31 -08:00
Seth Hillbrand 5182fe15d3 Minor code formatting 2019-01-17 19:17:34 -08:00
Tomasz Włostowski 9657039af2 pcbnew: multiple fixes concerning track->pad net propagation used by Track/Via properties dialog:
- Added ignore netcode option to CONNECTIVITY_DATA::GetConnectedItems()
- PlaceModule() now ensures the module added to the board (and thus to the connectivity database) has correct bounding box necessary for R-trees to work
- Use recursive connected pad search so that the new net is propagated to all pads

Fixes: lp:1787961
* https://bugs.launchpad.net/kicad/+bug/1787961
2019-01-18 02:53:29 +01:00
Seth Hillbrand 55f2a79957 pcbnew: locking connectivity using RAII
Rather than depend on proper unlocking for each exit, we move the
connectivity lock mutex into an RAII-type configuration that
automatically unlocks on exit.
2018-12-20 11:04:08 -08:00
Seth Hillbrand 7b2f245283 pcbnew: Tracks cleanup use connectivity database
Rather than duplicating the connectivity calculations in determining
whether a track is dangling, we utilize the current database to find the
number of connected items for an anchor item when feasible.

Multiple anchors such as tracks still need additional logic.

Fixes: lp:1805479
* https://bugs.launchpad.net/kicad/+bug/1805479
2018-11-27 11:17:59 -08:00
Seth Hillbrand a24bd9baa1 pcbnew: Adjust default update rate to 100ms
10ms was too fast to update the progress reporter and actually slowed
the process down for many machines.
2018-11-06 09:28:12 -08:00
Seth Hillbrand ed1c8eee9e async: Ensure threads are started async
It is possible for an async thread to simply be deferred if not
specifically set to async.  In which case, until the return value is
requested, the loop may simply wait.
2018-10-26 22:30:06 -07:00
Seth Hillbrand 59fb6d8851 Threading: Moving connectivity search to std::async
By decoupling from std::thread, we can avoid the wait/sleep cycle in
checking the std::atomic completion variable.  The std::future variables
are immediately returning without the additional atomic check cycle.
2018-10-26 18:00:43 -07:00
Seth Hillbrand 2d8f1df293 Threading: Minimize thread usage
This minimizes the thread usage, particularly during online actions such
as moving items and routing.

UpdateRatsnest:  Minimized the number of atomics by utilizing future
promise.  Avoided updating node-less nets.  Node-less nets are common in
the dynamic ratsnest because the net vector is created from the board
nets by value but only populated with a subset.  So the dynamic ratsnest
calculation always saw every net as dirty and spun up extra threads.

searchConnections: ParallelThreadCount is no longer lower bounded.
Small item counts are handled inline rather than with a separate thread.
2018-10-25 14:19:43 -07:00
Seth Hillbrand a0e4e23c14 Ratsnest: Keep connectivity data local
The dynamic ratsnest did not need to have a smart pointer to the
temporary connectivity data.
2018-10-24 13:43:09 -07:00
Seth Hillbrand ec38a5cd10 Threading: Replacing sleep with yield for active wait
Some windows machines seem prone to sleeping for excessive times.  When
called in the main thread, this may prevent the system from responding
to Windows 'Are you alive?' calls.
2018-10-24 10:37:25 -07:00
jean-pierre charras 0f247264f8 Pcbnew: DRC ignores first net of list of nets to test.
Fixes: lp:1798985
https://bugs.launchpad.net/kicad/+bug/1798985
2018-10-21 17:01:58 +02:00
Seth Hillbrand e1f30a3b38 pcbnew: Fix single-net connectivity
Ensure that changes affecting fewer than 4 nets still get updates in the
ratsnest.
2018-10-18 17:11:58 -07:00
Seth Hillbrand 38c5b025c8 Ratsnest: iterate only over dirty nets
Rather than forcing each thread to iterate over the full nets list to
find the dirty items, we collect the dirty items first before asking the
threads to address them.  This prevents thread spinning.  We also
amortize the cost of calculating on an 8-net per thread basis rather
than 2.
2018-10-17 17:07:29 -07:00
Seth Hillbrand 4a730e6c54 pcbnew: refactor connectivity locking
Locks protect the std::set in each item.  Devolving the mutex to the
CN_ITEM allows multiple threads to make simultaneous connections to
different items where they do not conflict.
2018-10-12 17:07:31 -07:00
Seth Hillbrand 59adb109a6 Organizing connectivity
Moved large routines out of headers in into cpp.  Moved trivial routines
into headers.
2018-10-12 16:31:09 -07:00
Seth Hillbrand cfaf7c1f23 pcbnew: re-organizing connectivity
The connectivity files were unwieldy.  This separates them logically
into data, algo and items where the items classes are those that hold,
surprise, surprise, the items, lists and clusters.
2018-10-12 16:31:09 -07:00
Seth Hillbrand 4460313104 pcbnew: Separating connectivity to subdir 2018-10-12 16:31:09 -07:00