7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-26 00:26:09 +00:00
Commit Graph

861 Commits

Author SHA1 Message Date
John Beard
a3a3f7648e Break ERROR_LOC out to its own header
Having this in geometry_utils.h means that touching
that header affects nearly every file, as this type is used
in EDA_SHAPE, BOARD_ITEM and SHAPE.
2024-09-11 22:08:36 +01:00
John Beard
5925f9c374 Break out some geom functions from dimension text adjustment
Put these in a separate header - they don't need to be available
whenever VECTOR2 is, but they are generic, reusable functions that
can have the corner cases defined and tested.
2024-09-11 22:08:36 +01:00
John Beard
80abdee90d Make hash constexpr
Probably doesn't add much directly, but it documents and
enforces the implied contract that the hash is fixed,
and could be used for, say, compile time hash tables.
2024-09-11 22:08:36 +01:00
John Beard
78cb6c1189 SEG: Correct sign in LineDistance 2024-09-06 19:26:58 +01:00
Seth Hillbrand
538b055c98 Remove ambiguity in MM3_HASH ctor 2024-09-06 10:31:16 -07:00
Seth Hillbrand
5ba50c26a9 Update embedded files hash to use Murmur3
SHA256 is fine for one-offs but for large libraries where we might be
running the hash on hundreds of files, the speed difference is
appreciable.  We don't require crytographic hashing, just a check that
the original file hasn't been corrupted so Murmur3 satisfies our basic
requirement.
2024-09-06 09:57:23 -07:00
Seth Hillbrand
3e5ca2ee7a Modify SHAPE_LINE_CHAIN::Simplify() to fix PNS
Issue raised by TomW, points included in new QA test where Simplify was
not properly removing colinear points.

Also removed TestSegmentHitFast() as the speed gains were minimal when
testing against the revised SEG::SquaredDistance routine in
TestSegmentHit()
2024-09-03 17:23:07 -07:00
Alex Shvartzkop
ebb418f22b Avoid some potential integer overflows in circle.cpp. 2024-08-29 00:35:38 +03:00
John Beard
1fb2d7fe26 Pcbnew: Snap to graphic/track intersections
Relates-To: https://gitlab.com/kicad/code/kicad/-/issues/2329
2024-08-28 13:49:36 +01:00
John Beard
0818ee1770 Pcbnew/FPedit: Add snap anchor type indicators
This allows to see what the current snap point is, which is useful when
zoomed in, or the point is like the corner of a rounded pad where it's
"in free space" and might not be immediately obvious.
2024-08-28 13:49:36 +01:00
Seth Hillbrand
fba2b7a04a Modify previous commit to correct logic
We are calculating the same value in two different ways.  If there is an
off-by-one issue in our calculation along axis, this still means that it
was a direct hit on the line as seen in the unit test cases
2024-08-16 17:05:39 -07:00
Lucas Dumont
f3bbf2b7bd Kimath: Squared distance can't be negative
Fixes https://gitlab.com/kicad/code/kicad/-/issues/18473
2024-08-16 17:05:39 -07:00
John Beard
c7fa61cd94 GTK: Enable IME cancellation on canvas focus
This means that it doesn't start consuming hotkeys for
IME composition in the main canvas on Linux.

Text boxes in dialogs and the property manager, for example,
still receive IME composition.

Relates-To: https://gitlab.com/kicad/code/kicad/-/issues/9882
2024-08-14 14:28:54 +01:00
John Beard
7fc367e688 Pcbnew: Add dogbone corner tool
This adds circular arcs in corners to allow for the router
cutter radius when routing a slot or corner that receives
a sharp corner.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/18512
2024-08-07 23:01:32 -06:00
Seth Hillbrand
c0d8d87364 Cleanup GetClampedCoords
Previous function would drop some KiROUND calls due to inability to
parse the () operator.  Using the _v template gets the constexpr check,
allowing us to avoid the conditional while running
2024-07-25 21:06:04 +02:00
Seth Hillbrand
368d98ef9e Add optional quiet param to KiRound 2024-07-25 21:05:49 +02:00
Seth Hillbrand
69849ba3ca Replace custom Clamp with std::clamp
Fixes bug in parser that had the elements in the wrong order due to our
custom version not matching the standard order
2024-07-25 19:17:17 +02:00
Seth Hillbrand
1be2d7f8b7 Optimize SEG::SquaredDistance
We don't actually need the closest point to figure out the distance.
Since this calculation is used everywhere, we see some non-negligible
gains by picking the length along the projection
2024-07-25 05:21:06 +02:00
Seth Hillbrand
433677fc21 Replace std::lexicographical_compare_three_way
On platforms that don't yet support the std:: version, we implement our
own, possibly slower, version of the 3-way compare
2024-07-24 18:03:29 +02:00
Seth Hillbrand
6ed537753c Avoid losing the last point when simplifying
line chains that are not closed should avoid simplifying between
beginning and end points.  Make sure that we keep the finishing point
for these chains

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

(cherry picked from commit b71eb1186f)
2024-07-20 13:03:44 -07:00
Alex Shvartzkop
63eac0382c Add bounds checking when slicing SHAPE_LINE_CHAIN from the middle of the last arc.
(and said arc is the last shape in the chain)

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18391
2024-07-19 01:56:44 +03:00
Alexander Rauth
9177e62718 correct polygon area calculation
When calculating a part of the polygon area and thus ending the polygon
at the specified vertex aEnd we  need to calculate and add the area below
the needed additional line from "aEnd" to "this" to close the resulting
partial polygon. As in this case VERTEX* p references "aEnd" after exiting
the do-while loop the correction  term in the if-statement was always
evaluated to zero. Change "aEnd" to "this" in the correction term.
2024-07-11 10:09:54 -07:00
Seth Hillbrand
77b1d367df Fixup copper connection wires
Use better check for ears, avoiding fracture points.
Be careful when insterting spikes to avoid changing indices for future
polys
2024-07-10 21:48:37 -07:00
Seth Hillbrand
845130ba9e ADDED: pcbnew fill avoids kissing fills
Previously, fills could end up just barely touching, leading to DRC
errors even if there was enough room to fill the remaining space.  This
was due to how we shrink/expand the zones to remove small features.  By
adding a zero-width line between points that should be connected, we
expand back to the correct width.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14130
2024-07-10 18:34:41 -07:00
Jeff Young
0682987eb9 Cleanup atrophied code. 2024-07-08 14:27:25 +01:00
Alex Shvartzkop
8532e1f9ec Optimize optimizeZoneToZoneAnchors.
Only do tests between 3 polygon pairs with closest bbox centers.
Only do tests between 5 parts of line chain pairs with closest bbox centers.

Gets OptimizeRNEdges down to 350 ms

See https://gitlab.com/kicad/code/kicad/-/issues/18148
2024-07-03 16:27:03 +00:00
Seth Hillbrand
0a55ca5e96 Add standard ToString representation of hash 2024-06-25 18:34:57 -07:00
Seth Hillbrand
a9d9d7ac06 Rearrange VERTEX and VERTEX_SET to please MSW/Apple 2024-06-25 18:04:53 -07:00
Seth Hillbrand
4fff28220e Extract common code into VERTEX_SET mixin
The VERTEX_SET is useful when we need to quickly find elements that are
close to each other.  Extracting to a mixin keeps the code from
diverging between implementations and simplifies that maintenance.
2024-06-25 12:19:56 -07:00
Seth Hillbrand
3c88b1ebc7 Suppress fallthrough warnings 2024-06-25 12:18:44 -07:00
Alex Shvartzkop
43be7491ff Add default constructor to MMH3_HASH. 2024-06-25 01:19:55 +03:00
Alex Shvartzkop
bee70bca7f Fix redefinition error in mmh3_hash.h. 2024-06-25 01:15:47 +03:00
dsa-t
cb41b53ab7 Use MurmurHash3_x64_128 (MMH3_HASH) for polygon checksum.
Improves performance when moving footprints.

See https://gitlab.com/kicad/code/kicad/-/issues/18148
2024-06-24 21:19:43 +00:00
Alex Shvartzkop
ec271c20db Slightly optimize SEG::NearestPoint. 2024-06-20 04:25:33 +03:00
Marek Roszko
7c35139505 std::sqrt is not constexpr until C++26 2024-06-19 07:34:58 -04:00
Seth Hillbrand
cde153c75f Avoid some overflows in KiROUND 2024-06-18 21:37:00 -07:00
Seth Hillbrand
bcf6b620a8 Large rework of BEZIER_POLY
Add direct handling of quadratic beziers to save compute time and number
of points.  Update cubic interpolation to reduce number of points
generated for a given smoothness

Cache data on open and used cached data to avoid multiple re-calcs

Remove minimum line length and number of segments and replace with
standard max error level.  Allows us to specify the tolerance of bezier
interpolation
2024-06-18 17:55:41 -07:00
Seth Hillbrand
e3231e6996 Rework VECTOR2D promotion rules
VECTOR + scalar = vector type (KiROUND when VECTOR is integral and
scalar is float)
VECTOR + VECTOR = common type vector

Implemented with concepts in template rules - SWIG compatible
2024-06-15 13:41:07 -07:00
Seth Hillbrand
f7450e5b37 Fix SWIG compile
SWIG doesn't like a lot of the new C++20 elements, so fall back to basic
cast that should get almost every case
2024-06-14 17:41:05 -07:00
Seth Hillbrand
6df16d053e Add specialization for unsigned scalar add/sub
Adding/subtracting an unsigned scalar to a signed vector should maintain
the same signed vector

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18212
2024-06-14 17:27:59 -07:00
Alex Shvartzkop
9d0ee029bc Add a upper >= lower check to Clamp.
Similar to std::clamp.
2024-06-12 23:05:33 +03:00
Alex Shvartzkop
e49d233923 Move BOX2I_MINMAX to separate header. 2024-06-12 23:05:33 +03:00
Seth Hillbrand
9d9028c979 Handle unsigned VECTOR2 casts
The previous overflow handling code casted the int_min value into an
unsigned, meaning that the min value and max value were almost the same,
clamping the output to unreasonable values.

Updated code handles floating points first, then does integer casting
through int64_t
2024-06-10 12:40:01 -07:00
Alex Shvartzkop
76b2741a92 Make sure to add start points to arcs in TransformOvalToPolygon.
Otherwise the long line segments can be non-parallel to the centerline.

This was the root cause of the slowdown in https://gitlab.com/kicad/code/kicad/-/issues/18156

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18156
2024-06-09 20:04:27 +03:00
Seth Hillbrand
31a0652c58 Force VECTOR2 templates to use standard promotion rules
This forces the operators -, +, * to use standard promotion rules when
operating on vectors of two different types.  Previously, this depended
on the order in which the operator was called, so subtracting a VECTOR2D
from a VECTOR2I could have a different result than negating the result
of subtracting the same vectors in the opposite order
2024-06-07 15:32:07 -07:00
Wayne Stambaugh
82b310f666 Do not update schematic editor net navigator when it's not shown.
Since the addition of all nets to the net navigator, performance on very
complex designs is unacceptable.  Not updating the net navigator is a
cheap and dirty short term fix.  Users with complex designs will not be
able to use the net navigator.  A better fix to resolve the performance
issues needs to be implemented.
2024-06-05 11:46:19 -04:00
Seth Hillbrand
08f181115b Use KiROUND for consistency
Ensure that it is clear we are rounding to nearest point
2024-06-04 08:55:42 -07:00
Seth Hillbrand
590bd6237d Fix off-by-one error in distance check for arcs 2024-06-03 16:29:06 -07:00
Seth Hillbrand
d44bf89b98 Update wayland file location
Fixes https://gitlab.com/kicad/code/kicad/-/issues/18141
2024-06-03 10:57:08 -07:00
Alex Shvartzkop
5742ba2ef1 Remove gdk header from unix environment.cpp. 2024-06-01 11:37:37 +03:00