Commit Graph

817 Commits

Author SHA1 Message Date
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
Roberto Fernandez Bautista 8c22f8df31 SHAPE_LINE_CHAIN: Fix/unify constructors 2024-03-02 12:09:09 +00:00
Johannes Maibaum 15e963bb32 Don't leak blank_cursor on warp (X11)
Also, for completeness, unref cur_cursor which we ref'd before hiding
it.
2024-02-29 18:55:28 +00:00
jean-pierre charras 8ffd4f636a SHAPE_ARC::update_bbox(): use double instead of int to calculate radius, and
if the radius is too large (> INT_MAX/2), consider arc as a segment to avoid overflows.
Nor perfect, but it avoid some issues when calculating bbox.
2024-02-29 18:01:13 +01:00
Alex Shvartzkop d04d74c511 Highlight nets and show length tuning status when adding tuning patterns.
Also fixes length preview when hovering over joints.
Also prevents asserts when hovering over arcs.
Also prevents adding a tuning pattern on other tuning pattern.

(cherry picked from commit 711c6141a8)
2024-02-23 20:29:18 +03:00
Jeff Young ffa6adec96 Add a cache for TrueType contours and triangulation data.
Also returns minimumSegmentLength to its former value as
it doesn't appear to be required to fix
https://gitlab.com/kicad/code/kicad/-/issues/11463.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/16568
(cherry picked from commit 162e8962f7)
2024-02-23 16:53:29 +01:00
Seth Hillbrand 745c52c2b7 Update triangulation
Allow for overlapping points in input polygon.  This is relatively
common on a grid and should be used as potential split points to shave
additional ears

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16933
2024-02-12 15:20:08 -08:00
Jeff Young 11f5908761 Revert the SHAPE_ARC::Collide() part.
The arc width appears to be handled elsewhere (at least in
the test suite).

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16951
2024-02-12 17:51:14 +00:00
Seth Hillbrand c6c1dbb844 Don't skip caching triangulation for failure
Failed triangulation can have multiple causes but we don't have another
approach, so skipping the cache just causes the same issue to be raised
again and again

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16946
2024-02-12 09:39:22 -08:00
Jeff Young d5ac0ff768 Fix SHAPE_ARC::BBox() and Collide() to honour m_width.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/16951
2024-02-12 16:59:57 +00:00
Jeff Young 1ff36f23b8 Clean up stale TODOs. 2024-02-05 15:49:57 +00:00
Ian McInerney d44b04978a Allow enabling WXTRACE in release builds on all platforms
Setting the environment variable KICAD_ENABLE_WXTRACE now enables wx
trace logging on all platforms. MSW still requires its original
environment variables to be set to get the console displayed.
2024-02-02 14:21:33 +00:00
Alex Shvartzkop 1122d80388 Better support for arcs in tuning patterns. 2024-01-31 23:38:05 +03:00
Roberto Fernandez Bautista 7276486756 Finish fixing SHAPE_LINE_CHAIN::Slice 2024-01-31 19:17:46 +03:00
Roberto Fernandez Bautista 79aba50c23 Finish fixing SHAPE_LINE_CHAIN::NextShape and add tests 2024-01-31 19:17:46 +03:00
Roberto Fernandez Bautista e950475bc3 Add assert to SHAPE_LINE_CHAIN::Segment + Deduplicate code
CSegment should have the exact same logic as Segment

Also, moving definition to .cpp file to reduce need to rebuild every time
2024-01-31 19:17:46 +03:00
Roberto Fernandez Bautista effed5dfdf Fix SHAPE_LINE_CHAIN::Remove and SHAPE_LINE_CHAIN::RemoveShape 2024-01-31 19:17:46 +03:00
Roberto Fernandez Bautista 673e23c2e6 Fix and simplify SHAPE_LINE_CHAIN::Append( SHAPE_ARC ) + QA tests 2024-01-31 19:17:46 +03:00
Roberto Fernandez Bautista 34942290a2 SHAPE_LINE_CHAIN: Fix SetClosed() logic
SetClosed should unwrap the chain when there are coincident points at the
start.
2024-01-31 19:17:46 +03:00
Roberto Fernandez Bautista 7593863245 SHAPE_LINE_CHAIN: Fix and simplify ShapeCount()
Fixes https://gitlab.com/kicad/code/kicad/-/issues/15754
2024-01-31 19:17:46 +03:00
Roberto Fernandez Bautista c72ba189cf Fix SHAPE_LINE_CHAIN::Slice following NextShape() changes 2024-01-31 19:17:46 +03:00
Roberto Fernandez Bautista e9fbb36538 SHAPE_LINE_CHAIN: Fix and simplify NextShape() + remove PrevShape()
NextShape() function was too complex (trying to go back and forwards).
We only used PrevShape() in one place, so removed that usage.

Added QA tests
2024-01-31 19:17:46 +03:00
Roberto Fernandez Bautista 079478f989 EDA_ANGLE: use constexpr for constant angles
Remove all statics in the class and instead use constexpr to
ensure correct ordering
2024-01-31 19:17:46 +03:00
Seth Hillbrand 3cf8b718f3 Don't truncate if not needed 2024-01-26 09:11:11 -08:00
Marek Roszko 8f57a9bcf0 Fix spacemouse version check by pawning it off on wxWidgets
Version is a value not a key name. Also the registry returns things in wchars soooo lets just pawn off the encoding mess on wxWidgets

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16730
2024-01-24 19:04:50 -05:00
Jeff Young 8410a5e685 Coding conventions and cleanup. 2024-01-23 16:03:25 +00:00
Seth Hillbrand f1dacf7d92 Updated revision of polygon triangulation from 0a67dd3fdd
This maintains the primary goal of ensuring that bad splits do not allow
the triangulation process to continue.  Instead, we boot this back up to
the top-level where we will simplify the polygon before triangulating
again.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16624
2024-01-18 11:07:40 -08:00
Seth Hillbrand e4a0b9c7ed Revert "Revise triangulation"
This reverts commit 0a67dd3fdd.
2024-01-18 11:07:40 -08:00
Alex Shvartzkop d512e09eb8 std::isnan is not constexpr in C++17 2024-01-16 18:42:37 +03:00
Alex Shvartzkop 4c630e5aec KiROUND: make sure input type is floating point before checking for nan. 2024-01-16 17:25:46 +03:00
Alex Shvartzkop f99505e190 Fix arc editing bugs when endpoints match.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/16532
2024-01-16 16:17:45 +03:00
Jeff Young 33c97da0fa Performance enhancement. 2023-12-27 13:52:02 +00:00
Ian McInerney 5c334c147b Make some types auto-reference to prevent copies 2023-12-19 14:23:36 +00:00
Marek Roszko 5341af1a55 Add wxUniChar overload for nlohmann's internal char_traits 2023-12-18 22:10:39 -05:00
Wayne Stambaugh a4b38fbb80 Coverity warning fixes. 2023-12-18 16:09:13 -05:00
Jeff Young cfa55d958a performance efficiencies 2023-12-18 18:45:02 +00:00
Jeff Young 8251fca66a performance efficiencies 2023-12-18 17:39:29 +00:00
Jeff Young 11805d6696 performance efficiencies 2023-12-18 17:01:55 +00:00
Seth Hillbrand 0a67dd3fdd Revise triangulation
- Avoid double-splitting a single point
- Check for mid-line intersections
- Avoid splitting zero-area polygons
- Keep full z-list for intersection checks

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16241
2023-12-13 13:37:17 -08:00
Alex Shvartzkop bfcd087751 Add KiROUND for VECTOR2 types. 2023-12-02 17:08:56 +03:00
Alex Shvartzkop 2d9eee93e2 Fixes for length tuning patterns.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/16198
2023-12-01 08:44:10 +03:00
Seth Hillbrand daf178b64f Upgrade Clipper2 to 1.3.0
Fixes a number of minor inflation issues including slivers when
overlapping points are inflated

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16182
2023-11-28 16:02:39 -08:00
jean-pierre charras 7fd9226bec Fix issue in CalcArcCenter( VECTOR2D& aStart, VECTOR2D& aMid, VECTOR2D& aEnd )
It happens when the segment (aStart, aMid) is horizontal
Probably also when the segment (aEnd, aMid) is horizontal
Slopes with value 0.0 are set to double:: epsilon(), but it was a too small values
generating broken calculations.
Now set to 1e-10 (it seems working).
Fixes #16089
https://gitlab.com/kicad/code/kicad/-/issues/16089
2023-11-18 20:08:26 +01:00
Alex Shvartzkop 648b4a7689 TransformOvalToPolygon: make segments align at 45 deg angles. 2023-11-06 14:50:40 +03:00
Jeff Young 24ca7add42 Don't clamp arc centers quite so aggressively.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/16029
2023-11-06 00:45:19 +00:00
Wayne Stambaugh bfd3e71a88 Don't show integer overflow errors in release builds.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/15529
2023-10-28 15:06:32 -04:00
Wayne Stambaugh 84f58f36d4 Coding policy fixes. 2023-10-28 14:45:44 -04:00
Wayne Stambaugh b8310efd19 Coding policy, Doxygen comment, and spelling fixes. 2023-10-20 14:32:54 -04:00
Jon Evans dda14e68a2 Add macOS required libraries in kiplatform
Supersedes 36b0aa60
2023-10-20 11:26:22 -04:00
Alex Shvartzkop 28c72f0cf4 Fix secrets.cpp on Windows. 2023-10-20 18:20:14 +03:00
Seth Hillbrand 5c5a38af21 Update fixes for MacOS 2023-10-20 16:21:31 +02:00
Seth Hillbrand 7720ef3fae Add missing include in kicad_algo.h 2023-10-20 16:11:46 +02:00
Seth Hillbrand 91f28f84d7 Update MacOS security routines 2023-10-20 16:10:49 +02:00
Seth Hillbrand d99641be40 ADDED: Git integration support
Adds support for project-based git integration, branch support, commit,
revert and updates

Fixes https://gitlab.com/kicad/code/kicad/issues/10441
2023-10-20 12:51:47 +00:00
Alex Shvartzkop be1008cbd8 ADDED: Heal Shapes; Fix discontinuities in gfx import and Cleanup dialog. 2023-10-17 10:29:43 +03:00
Jeff Young 2b28580f0c Comments. 2023-10-15 17:59:11 +01:00
Mark Roszko 8b7af2b545 Fix broken 3dconnexion driver check
It essentially inverted it because version > min_win_version would return true, but then it would be checked against <= 0 which is false
2023-10-13 17:06:44 +00:00
Jeff Young 62d959ed0e Don't assume an error location for PAD::GetEffectivePolygon().
While ERROR_INSIDE was good for plotting, 3D generation, etc., it's
not good for generating router hulls.

Also reverts part of the change to always use polygons for PNS::SOLIDs.  A single shape in a SHAPE_COMPOUND will be faster (and
more accurate).

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14898
2023-10-13 13:59:26 +01:00
Alex Shvartzkop 8b21a260c9 Refactor MEANDER_PLACER_BASE::cutTunedLine to SHAPE_LINE_CHAIN::Split. 2023-10-08 02:41:17 +00:00
Alex Shvartzkop f9efed692d Pick location closest to aSeg.A in SHAPE_COMPOUND and SHAPE_RECT Collide. 2023-10-06 16:05:05 +03:00
Alex Shvartzkop 92ef40327d Add accuracy parameter to SHAPE_POLY_SET::PointOnEdge. 2023-10-06 15:56:46 +03:00
Alex Shvartzkop de0c1218c3 Add a method to offset line chains. 2023-10-06 15:50:37 +03:00
Alex Shvartzkop 8a22a8fa69 Add aExact to SHAPE_LINE_CHAIN::Split. 2023-10-06 15:50:37 +03:00
Alex Shvartzkop d7863b09c5 Move CORNER_STRATEGY out of SHAPE_POLY_SET. 2023-10-06 15:42:50 +03:00
Alex Shvartzkop 2cd630b47d Fix a bug causing lower segment count on holes when deflating polygons. 2023-10-06 15:36:42 +03:00
Jeff Young 40ef850bd3 Don't halve indicator icon size on Mac. 2023-10-01 19:01:02 +01:00
Seth Hillbrand 06428e0161 Remove unused 2023-09-27 18:05:21 -07:00
Alex Shvartzkop 3c40cb3fd3 Wayland: add global_remove handler, logging. 2023-09-27 18:06:57 +03:00
Alex Shvartzkop 3ee2086f95 Don't freak out when can't warp the pointer. 2023-09-22 05:10:42 +03:00
Clément Saccoccio a3bc3e138b Fixed frozen pointer for some GNOME/Wayland installation. 2023-09-21 17:09:50 +00:00
Seth Hillbrand c497abd8ee Fix MSW registry key for 3dconnection
See discussion at 7af5037ad7 (note_1568602292)
2023-09-21 09:55:11 -07:00
Alex Shvartzkop b6c0a3f60c Wayland: slightly better infinite drag release logic. 2023-09-18 17:42:09 +03:00