Commit Graph

788 Commits

Author SHA1 Message Date
John Beard fa7e842c8c Rework item distribution
This splits the tool into two separate tools: by center and
by even gaps. Previously, this was automatically decided, based on
if the items could have any gaps between them. This was unintuitive
as it would appear to arrange by centre point sometimes but not others.
When items aren't all the same width, the results can then be very
different, based only on the starting positions.

The new behaviour is to have a dedicated tool for each, which echos
how graphical programs like Inkscape manage this.

The by-gaps method is then extended to work for overlapping items
(when items overlap, the overlaps are made equal). The logic is
centralised in kimath/geometry, and some QA is added. This should
make it easier to extend to eeschema, for example.

This also (attempts to) address some rounding issues which could
cause minor, but compounding, errors to build up along the list
of items.

Also, fix bugs in the collection filtering - previously items
like markers were filtered out only after the selection size
was used to compute the gaps between items.
2024-05-05 03:35:09 +08:00
Seth Hillbrand 022dce2d1b Fix out of bounds access opportunity 2024-05-02 15:12:43 -07:00
Seth Hillbrand 339cf3f2e2 Fix simplify routine for last segment
The last segment of a track could be removed when the iterator does not
correctly loop.  Keeping the ll within bounds and checking for
equivalency instead of comparison works for last point
2024-04-30 16:11:20 -07:00
Seth Hillbrand 8b5564629a Optimize TestSegmentHitFast
Check for co-linear points (common occurence) before using expensive
EuclideanNorm
2024-04-29 17:48:32 -07:00
Seth Hillbrand 9e83a7bcb3 Update SHAPE_LINE_CHAIN::Simplify to better handle small diff
When simplifying, a small difference in successive points would allow a
larger difference than aMaxError to be removed.  This change checks the
intermediate points during removal to ensure we don't get overzelous
2024-04-29 17:48:32 -07:00
Alex Shvartzkop e26778c599 Require Wayland 1.20 libraries.
KiCad doesn't build with older versions due to missing definitions.
2024-04-27 16:48:49 +03:00
Jeff Young c59ed0bbb7 Flip symbol editor's Y axis to match other editors. 2024-04-27 13:47:56 +01:00
Marek Roszko b22bc2737e Hackfix macOS to keep erc/drc on top
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14356
2024-04-26 00:49:22 -04:00
Marek Roszko 60d5780c1c Fix win32 proxy parsing when the old IE options for scheme based configuration was set
If you uncheck in the old IE options "Use the same proxy server for all protocols", then it returns an annoying string
like http=blah:1232;https=blah:1232;ftp=blah:2321 which we have to parse.
2024-04-25 21:24:58 -04:00
Alex Shvartzkop cf6d30706b More clang build fixes. 2024-04-23 21:50:22 +03:00
Alex Shvartzkop 124b511037 Fix build on clang. 2024-04-23 21:44:55 +03:00
Alex Shvartzkop b1180d9377 Fix some warnings. 2024-04-23 16:34:07 +00:00
Alex Shvartzkop 865e3a9f3c Improvements when working closer to 32-bit integer limits.
- Changes BOX2 size to extended coordinates.
- Adds BOX2ISafe to construct a BOX2I that will fit in int32.
- Adds more checks.
- Safer computations.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17670
2024-04-23 16:34:07 +00:00
Alex Shvartzkop 5e70883ef6 Add self-intersection check algo for arcs in SHAPE_LINE_CHAIN. 2024-04-23 19:25:23 +03:00
Alex Shvartzkop fcdaa4a59e Cache center point and radius along with BBox in SHAPE_ARC. 2024-04-23 19:25:23 +03:00
Jeff Young e8be782687 Mostly clean-up, but also bug fixes with bounding boxes. 2024-04-22 11:16:14 +01:00
Wayne Stambaugh d79619edd1 Minor net navigator improvements.
Ignore bus member connection subgraphs.  They do not have a valid net
name nor do they contain schematic items.  This prevents empty nodes
from being added to the tree.  They can be reintroduced in the future
if someone wants to pursue it.

Freeze the wxTreeCtrl while populating it and thaw when done to prevent
any unnecessary repainting.

Add profiling to test how long it takes to rebuild the net navigator.
The recently added populate the navigator with all nets when no net
is highlighted has exposed some potential performances issues with some
versions of wxWidgets on certain platforms.  Namely wxWidgets 3.2.4 on
Linux GTK.

Fix an issue where a sheet name change would not update the highlighted
net navigator resulting in a stale human readable sheet path.

Prevent the highlighted net navigator from being rebuilt twice when
loading a schematic.  SCH_EDIT_FRAME::RefreshNetNavigator() was being
called from both SCH_EDIT_FRAME::UpdateHierarchyNavigator() and
SCH_EDIT_FRAME::RecalculateConnectivity().

Add a new trace helper "KICAD_UI_PROFILE" to show trace output when
profiling user interface performance.  It's used in the net navigator
profiling mentioned above.

Reuse PROF_TIMER::Show() to generate string for PROF_TIMER::to_string().
2024-04-17 14:31:50 -04:00
Seth Hillbrand 59f99d9a6a Re-add routine to remove duplicate points
The router needs to elimitate duplicate points but keep colinear
segments.  This re-creates the partial routine from the old Simplify()
function

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17582
2024-04-10 17:25:58 -07:00
JamesJ 9853b300d7 Check a SHAPE_POLY_SET outline exists before attempting to get it by index
Fixes https://gitlab.com/kicad/code/kicad/-/issues/17687
2024-04-06 18:45:39 +01:00
Jon Evans 6bd02cae6d Refactor; add user control over API server 2024-04-02 19:51:18 -04:00
Jon Evans a3b6ab48a4 Add a new plugin system for the new API 2024-04-02 19:51:16 -04:00
Jon Evans f613cd1cb4 ADDED: A new IPC API based on protobuf and nng
Details, documentation, and language bindings are works in
progress and will be evolving over the course of KiCad 9
development.
2024-04-02 19:34:36 -04:00
Seth Hillbrand 8260c174e9 Prevent OOB access in polygon split
Check for vertex placement against original size.  Since we are
potentially adding vertices that are out of order with the original
polygon, we only want to check against the first set of vertices when
checking for polygon collision

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17664
2024-04-02 11:22:59 -07:00
Seth Hillbrand 553e4a25bf Tidy up some remaining triangulation cases
Found and fixed a few corner cases where triangulation point removal
could reset expected points
2024-04-01 11:48:12 -07:00
Jeff Young 1b22c92177 Fix extra space. 2024-04-01 17:45:02 +01:00
Jeff Young 78bec3f1ba Fix fishy logic in SHAPE_LINE_CHAIN::Collide(). 2024-04-01 17:03:15 +01:00
Seth Hillbrand 06b199fd41 Do not use cache when we modify vertices
When we add vertices to the tesselation routines, we cannot reuse these
without the original vertex points.

It may be possible to copy and modify the vertices from the hint data so
that they are properly positioned but naive attempts (moving based on
first point) did not work, so for now, we disable the hint cache when
the vertex sizes do not match as this prevents OOB access

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17621
2024-03-31 15:00:46 -07:00
Jeff Young dfa16eda95 Fix copy/pasta in SHAPE_LINE_CHAIN::Collide().
Fixes https://gitlab.com/kicad/code/kicad/-/issues/17636
2024-03-31 18:12:33 +01:00
Seth Hillbrand 6c05f2c67c Move logging message after vertex check
When creating the list, we may have fewer than needed vertices, which
prevents calculating the area
2024-03-29 16:47:07 -07:00
Seth Hillbrand c3f6a84d66 Update triangulation to handle poly-intersection
Polygon intersections happen against the original outline, not against
the currently remaining polygon.  This avoids pathalogical cases

Adds new simplification system to avoid duplicated points
Adds new edge-splitting algorithm to provide additional fall-back
Verifies that polygon cuts do not swap holes for outlines (negative
area)

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17559
2024-03-28 10:16:24 -07:00
Céleste Wouters e98c9f283f Improve SHAPE_POLY_SET fracture performance
Refactors `SHAPE_POLY_SET::fractureSingle()` to be more efficient, while
not changing the actual algorithm:

* increase cache locality by using contiguous arrays instead of what was
effectively a linked list
* reduce latency and jitter by replacing per-edge allocator calls with
ahead-of-time std::vector reserves
* increase cache efficiency by making the vertex struct smaller
* replace O(n^2) leftmost edge search with O(n log n) std::sort
* sort the polygons instead of the edges
* cut iteration count in half in the remaining O(polygons * edges) part
2024-03-27 21:19:02 +00:00
Seth Hillbrand a793fa8b17 Fix typo in triangulation return 2024-03-22 11:08:38 -07:00
Seth Hillbrand 6b915049d1 Check singular arcs connection
Even if there are no other segments in the line chain, we still should
check for arc connections in cases of individual arcs on a line chain
2024-03-22 10:41:42 -07:00
Seth Hillbrand a58e7b37ff Skip small triangles
The minor triangles cost the same amount of compute time as larger ones
but do not have a material effect on the zone display.  This skips these
minor triangles when earcutting
2024-03-21 13:57:57 -07:00
Seth Hillbrand 7e7fec69f6 Add logging and area check to tesselation
Logging is useful when we find an area that cannot be triangulated.
This will be used to generated test cases.

Skipping minor untesselated areas means that the polygon will still be
considered fully tesselated (and not sent back again and again) even if
the tesselation misses an area less than the configured limit.
Currently, this is 31^2nm.
2024-03-21 13:57:57 -07:00
Seth Hillbrand 4f03bb2fb6 Update triangulation 2024-03-21 13:57:57 -07:00
Mark Roszko de6c0fcf25 Fix build breakage due to missing header 2024-03-21 03:15:14 +00:00
Jon Evans f00f47df13 wxWidgets 3.3 compatibility: explicit wxString conversion 2024-03-20 22:02:41 -04:00
Seth Hillbrand 4e6cd0d293 Forward and reverse test for point in poly collisions 2024-03-18 15:51:14 -07:00
StefanBruens e07b4ce8e4 Fix triangulationValid check race for zone fill
The m_triangulationValid flag is used in several places without holding
the mutex, thus it should only ever be set when the triangulation is
guaranteed to be valid.

This can either be done by protecting both data and flag by the same
mutex, or updating the flag only after the triangulation has finished.

Also fix the case when the triangulation actually fails, the flag should
not be set in this case.

While at it, simplify the recalculation check. Only if both the
triangulation is valid, and the data hash is unchanged the recalculation
can be skipped - this is typically the case when two threads try to
update the cache concurrently, the second one will block at the mutex,
and will see the valid data after the first thread has finished.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17180
2024-03-14 22:26:23 +00:00
Seth Hillbrand 81cb6d0c3f Fix race condition in zone fill
When checking collisions, the SHAPE_POLY_SET::Collide() routine is not
const because it will regenerate the triangulation cache if it is out of
date (using a const_cast, grrr).  This sidesteps the issue by assigning
a mutex to the triangulation caching

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17180
2024-03-13 10:35:40 -07:00
Alex Shvartzkop 463b609993 Disable infinite panning when using XWayland.
Cursor warping doesn't work properly in this scenario.

https://gitlab.com/kicad/code/kicad/-/issues/14109
2024-03-12 10:31:23 +03:00
Seth Hillbrand 347c50b26d Handle issue with alternate SHAPE_LINE_CHAIN
SHAPE_LINE_CHAIN_BASE can include things that are not SHAPE_LINE_CHAIN
like the triangle SHAPE_LINE primitive.  To check arcs, we need to avoid
these elements as they do not have the full SHAPE_LINE_CHAIN class
available.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17327
2024-03-11 17:21:09 -07:00
Seth Hillbrand 3cc1617f5a Fix slow selection time when calculating clearance
The clearance between two zones could be rather slow.  This was in part
to trying to do triangle-triangle collisions between zones when we only
need outline collision and in part to the shape_line_chain collision
routine.  The shape_line_chain collisions don't need to recreate
segments on each iteration and should instead create them once and using
this to check all collisions

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17327
2024-03-11 16:32:24 -07:00
Alex Shvartzkop 4d66a8ebdb Fix rendering/plotting of arcs with tiny angle and huge radius.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/17343
2024-03-09 02:07:24 +03:00
jean-pierre charras 5ac8449e1f Minor compil and Coverity fixes 2024-03-06 13:05:21 +01:00
Alex Shvartzkop 85b1978408 Use 64-bit type to represent microseconds.
int and long are 32-bit on Windows, causing overflows.
2024-03-03 21:40:26 +03:00
Jan Wichmann 5cdf9fe8a0 Don't show hidden directories and files in the project tree browser
Fixes https://gitlab.com/kicad/code/kicad/-/issues/16207
2024-03-03 16:43:43 +00:00
Roberto Fernandez Bautista 43e1b36d4d SHAPE_LINE_CHAIN: Fix indices rotation after clipper
Also fix IsArcStart and IsArcEnd functions to work with chains that only
have arcs.
2024-03-02 12:09:09 +00:00
Roberto Fernandez Bautista 0d340d0610 SHAPE_LINE_CHAIN: Move .h definitions to .cpp
No functional changes, just allow faster rebuilds
2024-03-02 12:09:09 +00:00