Commit Graph

276 Commits

Author SHA1 Message Date
Wayne Stambaugh 175b474c3e Coverity issue fixes.
Fixes issues #280412, #314755, #329615, #332459, #332157, #332167,
2021-06-30 18:08:49 -04:00
jean-pierre charras 17737af130 Fix some issues related to SHAPE_ARC:
- Some are related to shape errors when the allowed error to approximate circle
by segment is large and arc radius small.
- fix the actual error used in ConvertToPolyline().
- Use SHAPE_ARC::DefaultAccuracyForPCB() instead of a fixed value as extra margin
in zones. It should not change something, because it is also a fixed value
(5 micrometers), but it is not a magic number.
-TransformArcToPolygon() fix some issues and add a new algo, based on the arc actual
outline shape (initial algo is still available in code, just in case).
2021-06-30 13:33:49 +02:00
jean-pierre charras bcb5618315 Fix incorrect calculation in TransformCircleToPolygon(), only noticeable
when the allowed aError is (unusually) large.
2021-06-28 18:51:37 +02:00
jean-pierre charras fa49b54f93 Fix minor issue in TransformCircleToPolygon() when aError is set to a large value.
pcb_painter.cpp: add (but not activate) compil option to show the conversion
of SHAPE_ARC::ConvertToPolyline as segments, for debug purposes.
2021-06-28 15:50:16 +02:00
jean-pierre charras 9a865b1989 Fix a typo and a minor compil warning 2021-06-28 14:37:35 +02:00
jean-pierre charras 310adedf85 Add GetCircleToSegmentError() to geometry/geometry_utils.
This function returns the error created by a circle to segment approximation.
2021-06-26 18:57:07 +02:00
jean-pierre charras 3c81403424 Refinements in Arc to Polygon transform: slightly better shapes of arc ends.
Note also the transform is still not good: the same parameters are applied
to convert inner arc, outer arc and middle arc of a thick arc to segments.
But these parameters depend on arc radius (or circle radius) value.
2021-06-26 14:20:55 +02:00
jean-pierre charras 31d7a0a8d1 TransformArcToPolygon(): slightly better approximation of arc.
The error between the "right" shape and the polygon is slightly smaller.
The approximations of the inner arc and the outer arc are better, but not perfect.
Also add (for test and debug purpose only) the code to show the polygon when
drawing a PCB_ARC (currently disabled)
2021-06-25 18:46:16 +02:00
jean-pierre charras 1d6ad4a52a SHAPE_ARC::ConvertToPolyline(): fix ugly approximation for some arcs.
Arcs with small radius can be approximated with very few segments.
However, if the thickness is large, relative to the radius, the approximation
must be based on the external radius, not the arc radius.
The difference can be significant.
This is especially noticeable for these graphic arcs in filled zones.
2021-06-23 18:30:02 +02:00
jean-pierre charras 0ff1f6f69c Try to fix a include order (Windows only, to fix aCI/CD error) 2021-06-16 20:04:32 +02:00
jean-pierre charras aeb479b46f Fix an issue with pythons scripts running outside Kicad (Windows specific).
When running a python script is run from a console, outside Kicad, a wxWidgets
alert was always show (even in release mode)
This is due to calling wxStandardPaths::Get() with no wxApp open( i.e. wxTheApp == O)
The fix uses a dummy wxApp in this case.
2021-06-16 10:18:39 +02:00
Seth Hillbrand a04d6401c1 Transform arcs more accurately
Segment approximation for arcs leaves small "indents" where the rounded
edges of two segments don't quite meet.

This gives closer approximation by calculating the inner and outer joint
points based on the radius, eliminating the indents.
2021-06-11 14:26:38 -07:00
luz paz f968fc8719 Fix source comment / documentation typos 2021-06-09 19:32:58 +00:00
david-beinder 053bd66650 Fix localization of OS unsupported message, disallow bug reports from W7 2021-06-09 19:01:54 +00:00
Marek Roszko ffa87e69c6 Remove/replace some stdint.h includes 2021-06-08 21:17:57 -04:00
Marek Roszko 69d7a23e1c Start cleaning out wx/wx.h in cpp files 2021-06-07 18:20:47 -04:00
Michal Schulz f923649801 If NSError contains recovery suggestion string, append it to error message as it was until now. However, if recovery string is NIL, do not append it at all.
This MR fixes the "error message\n\n(null)".
2021-06-06 14:24:08 +00:00
Jeff Young 53a75a4961 Fix actual-clearance handling in arc collision routines.
Fixes https://gitlab.com/kicad/code/kicad/issues/8407
2021-06-03 18:33:59 +01:00
Jeff Young 976e756b02 Formatting. 2021-06-03 18:33:59 +01:00
Seth Hillbrand 059f79dfdb Re-remove KiROUND from header
Moves routines requiring KiROUND (and util.h by extension) to the cpp
file
2021-06-03 08:44:17 -07:00
Marek Roszko 29783f125b Eliminate one wxRect constructor in BOX2
The only usage auto converted to BOX2D anyway...
2021-06-03 01:27:15 -04:00
Seth Hillbrand cf1c75ecd4 Handle rounding errors in seg length calculation
SQRT needs to be passed through KiROUND before returning otherwise,
truncation errrors will accumulate between routing and DRC

Fixes https://gitlab.com/kicad/code/kicad/issues/8541
2021-06-02 16:42:35 -07:00
Marek Roszko c294d28275 Split POLY_GRID_PARTITION to a cpp file
Not entirely a lightweight class
2021-06-02 18:31:30 -04:00
Marek Roszko 13abb9f947 Shift some seg functions to the cpp file 2021-06-02 18:31:30 -04:00
jean-pierre charras b6de4da686 Fix compatibility with wxWidgets 3.0.x
Fixes #8533
https://gitlab.com/kicad/code/kicad/issues/8533
2021-06-02 10:02:20 +02:00
Marek Roszko 0b4a680dbb Hotglue wxLogDebug into math/util.h without the global include 2021-06-02 00:26:16 -04:00
Marek Roszko cf2bb5692a Remove the wxLog calls from math/util.h for now
This was leaking windows headers and partial wx headers to 1084 compilation units......
This also means math/util.h is leaking to 1084 compilation units which seems a bit high too.
2021-06-01 18:44:22 -04:00
Jeff Young 46d746c9da Performance optimizations. 2021-06-01 23:11:54 +01:00
Tomasz Wlostowski 2d8264124d geometry: SHAPE_LINE_CHAIN::PathLength() now can accept the maximum index of the segment to calculate the length to 2021-05-29 00:13:24 +02:00
Tomasz Wlostowski 7553b7b092 geometry: add minimum distance threshold parameter to SHAPE_LINE_CHAIN::Find()/FindSegment() 2021-05-29 00:13:24 +02:00
Tomasz Wlostowski b3fb7190df geometry: SEG::Contains() should use Distance(), not SquaredDistance() for correct rounding 2021-05-29 00:13:24 +02:00
Tomasz Wlostowski e7fe8c4ddb geometry: rework SHAPE_LINE_CHAIN::Intersect() to explicitly indicate touching vertices and remove references to SEGs from INTERSECTION structure 2021-05-29 00:13:24 +02:00
Jon Evans f30ebbde33 Fix accuracy of tuning path calculation when measuring arcs
Fixes https://gitlab.com/kicad/code/kicad/-/issues/8401
2021-05-10 21:22:51 -04:00
Ian McInerney 30c92fc5d1 Disable OSX automatic window tabbing 2021-05-09 12:59:57 +01:00
Tomasz Wlostowski dc70df6036 kiplatform: check for null window handle in IsWindowActive(). 2021-04-27 14:13:16 +02:00
Jon Evans 715c61ac9f PNS: Fix yet more arc edge cases
Fixes https://gitlab.com/kicad/code/kicad/-/issues/8150
2021-04-12 19:59:55 -04:00
Jon Evans 1c431d9929 PNS: Fix some off-by-one errors with arc dragging 2021-04-11 22:12:53 -04:00
Jon Evans f5ef60c2f2 PNS: Fix shoving segment after arc 2021-04-11 18:06:21 -04:00
Jon Evans a26fc6d65d PNS: Fix several issues with arc dragging
Do not merge vertices that belong to different arcs
Fix start segment identification after arcs
Fix free-angle drag after arc

Fixes https://gitlab.com/kicad/code/kicad/-/issues/8173
Fixes https://gitlab.com/kicad/code/kicad/-/issues/8150
2021-04-11 17:56:40 -04:00
jean-pierre charras 258fd07939 Fix a compil issue (at least on msys2) 2021-04-11 17:32:40 +02:00
Jon Evans 7ba110bd77 PNS: Fix dragging of segments with arcs in line 2021-04-11 10:18:57 -04:00
Thomas Pointhuber a30894e5a1 Allow SHAPE_LINE_CHAIN and SHAPE_ARC to be mirrored using a SEG 2021-04-11 13:27:25 +00:00
Jeff Young e04c820442 Formatting. 2021-04-09 14:02:13 +01:00
Roberto Fernandez Bautista b7bd7246af SHAPE_LINE_CHAIN::Split: Add integers before incrementing the iterator
Partially Fixes https://gitlab.com/kicad/code/kicad/-/issues/8131
2021-04-07 11:28:02 +00:00
Roberto Fernandez Bautista 235688e459 Less restrictive Arc Track Dragging tool
Use the connecting straight tracks even if not exactly parallel - allow
an error margin configurable in ADVANCED_CFG (default 1 degree). Also
be less strict about end point matching and use the width of the track
as the criteria to determine suitability.

Finally, delete any short lengths of track at the end of the operation
and amend the arc end points to keep connectivity.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/7967
2021-04-06 12:52:01 +00:00
Marcus A. Romer 1632707d9b Replace tabs with spaces 2021-04-05 01:13:39 +00:00
Jon Evans 2c05d99d9f SHAPE_POLY_SET: Fix segment collision testing
It appears as though there was an optimization to skip testing segments if
one of their endpoints (and only the A point) was inside.  Unclear the reason
for this, but I'm going to assume that it was intended to optimize the case
where both points are inside (like the point case above it).
2021-04-04 20:12:45 -04:00
Jon Evans 5bc1e55272 SHAPE_LINE_CHAIN: Don't crash if inserting point at the end 2021-04-04 19:38:54 -04:00
Jon Evans bd6539885b Fix SHAPE_POLY_SET::SquaredDistanceToPolygon ignoring aNearest if unlucky 2021-04-04 19:38:54 -04:00
Jon Evans 3c1a8f8c88 Fix MSW build, take 2 2021-04-02 20:16:25 -04:00