Commit Graph

708 Commits

Author SHA1 Message Date
Roberto Fernandez Bautista 4de4347baa SHAPE_ARC::Collide( aSeg ) must check segment end points as candidates
The edge case is when the segment is completely contained inside the arc
(This partially reverts b4835c8208 and
adds the missing test cases)
2021-12-14 16:14:56 +00:00
Roberto Fernandez Bautista b4835c8208 Add test case for SHAPE_ARC::Collide( seg ) + remove unneeded candidates
Followup to commit 01068e0d41
2021-12-13 18:06:11 +00:00
Seth Hillbrand 1b1bf8a17b Better handling of escaped characters in STEP parser
Fixes https://gitlab.com/kicad/code/kicad/issues/9897
2021-12-08 15:55:42 -08:00
Tomasz Wlostowski 01068e0d41 geometry: fix SHAPE_ARC/SEG collision
The arc2segment collision should at also include the arc endpoint projections on the segment being tested. Not sure it covers all possible cases, though.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/9023
2021-12-09 00:37:58 +01:00
jean-pierre charras 0dad504e91 POLY_GRID_PARTITION: detect a divide by 0, set a wxASSERT and avoid the crash. 2021-12-08 16:07:11 +01:00
Roberto Fernandez Bautista 2d1ad52212 SHAPE_LINE_CHAIN: Fix arc indices rotation after merging duplicate points
Fixes https://gitlab.com/kicad/code/kicad/-/issues/9843
2021-12-05 15:12:09 +00:00
Roberto Fernandez Bautista c463818b57 SHAPE_LINE_CHAIN: Only fix up arc indices if last pt is part of an arc
Fixes https://gitlab.com/kicad/code/kicad/-/issues/9843
2021-12-03 22:04:55 +00:00
Jon Evans 0570c22732 Use point collision test for zero-length segments
SEG::SquaredDistance( SEG& ) does not do the right thing
for segments with zero length at the moment.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9791
2021-11-27 09:08:34 -05:00
Jon Evans b4342d813b Fix SHAPE_LINE_CHAIN::Slice when end is an arc followed by a point
Fixes https://gitlab.com/kicad/code/kicad/-/issues/9770
2021-11-25 10:05:33 -05:00
Tomasz Wlostowski 5d2f3257da libs/kimath: user-settable distance threshold for SEG::ApproxParallel() 2021-11-22 01:35:12 +01:00
Roberto Fernandez Bautista 1026c24c65 SHAPE_LINE_CHAIN fix rotation of indices after going through Clipper
Clipper might mess up the rotation of the indices such that an arc can be split between
the end point and wrap around to the start point. Detect if this happened and fix it as
required.

Also, handle arcs at the last segment of the chain correctly, meaning we can have arcs
towards the end of the chain that finish at the starting point of the chain.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9670
2021-11-20 16:47:08 +00:00
Roberto Fernandez Bautista d47bd3a04d Rewrite broken collision routine SHAPE_ARC::Collide( SEG& aSeg ) 2021-11-15 14:04:37 +00:00
Roberto Fernandez Bautista cb7e57fb43 CIRCLE::IntersectLine fix incorrect algorithm documentation comments 2021-11-15 14:04:37 +00:00
Roberto Fernandez Bautista 0c3da0f072 Implement true arc collisions for arcs inside a SHAPE_LINE_CHAIN 2021-11-15 14:04:37 +00:00
Marek Roszko f5fc9fa11f Another auto proxy tweak 2021-11-13 21:23:32 -05:00
Marek Roszko 73f40b11ee Some more cleanup 2021-11-11 23:58:34 -05:00
Marek Roszko 009bb7f033 Add missing WinHttpOpen to resolve pac proxies 2021-11-11 22:56:45 -05:00
Marek Roszko b20317ca84 Some minor cleanup of the proxy detect 2021-11-11 22:47:21 -05:00
Marek Roszko e2926f69a5 Add support to fetch windows proxy config for use with curl
Fix https://gitlab.com/kicad/code/kicad/-/issues/9594
2021-11-11 09:30:10 -05:00
Jeff Young d66487c383 Make sure RTree bounding box is at least as big as hole.
Fixes https://gitlab.com/kicad/code/kicad/issues/9526
2021-11-05 14:29:10 +00:00
Johannes Pfister 64f77b3596 PNS: Add support for 90-degree corner modes
Fixes https://gitlab.com/kicad/code/kicad/-/issues/6902
2021-11-03 02:14:23 +00:00
jean-pierre charras 29c3601061 SHAPE_POLY_SET: add FullPointCount(), mainly for statistics and debug. 2021-10-24 15:06:24 +02:00
Jeff Young 9b9e379aa0 Overhaul arc internal model to not over-specify information. 2021-10-15 12:45:43 +01:00
Roberto Fernandez Bautista 9e557d84c6 Ensure appended arcs are valid arcs (start, mid, end cannot be collinear)
Fixes https://gitlab.com/kicad/code/kicad/-/issues/9380
2021-10-13 18:58:21 +01:00
Roberto Fernandez Bautista 4b8ca18bf7 Remove unfinished code for handling arcs in SHAPE_POLY_SET::booleanOp
Boolean Ops on polygons with arcs are not supported (the only exception
is Simplify)

Also fix a bug in SHAPE_LINE_CHAIN::splitArc that resulted in an
exception

Partially fixes https://gitlab.com/kicad/code/kicad/-/issues/9380
2021-10-13 18:29:32 +01:00
Seth Hillbrand c1e6fdfb47 Polygon triangulation: Check for broken remainders
If the last three points of a tesselation are concave, we will never be
able to triangulate them.  They were likely formed from a bad polygon,
so we will drop the triangle and return completed

Fixes https://gitlab.com/kicad/code/kicad/issues/9380
2021-10-12 12:14:42 -07:00
Seth Hillbrand 52bbfb9109 Remove dependency of dot size on linear mils
Changes a dot to be a square pixel (linewidth x linewidth).  This allows
the removal of IU dependencies and ensures that a dot is always visible
on screen.  Also makes sure that cairo is setting the current linewidth
during its stroke routines

Fixes https://gitlab.com/kicad/code/kicad/issues/9362
2021-10-10 09:40:26 -07:00
Jeff Young f606679164 Proper numeric sorting for intersheet refs.
Also expunges the horrifically named std::remove and std::remove_if
(neither of which remove anything).
2021-10-01 18:29:21 +01:00
Jon Evans e2368b733c Allow selection of NPTH pads with zero copper size
Fixes https://gitlab.com/kicad/code/kicad/-/issues/9249
2021-09-26 18:17:50 -04:00
Roberto Fernandez Bautista 4abee7c2eb Fix SHAPE_LINE_CHAIN::Split when inserting a point on an arc
Ensure the arc is split into two at the point specified.

Partly fixes https://gitlab.com/kicad/code/kicad/-/issues/9023
Additional work required to ensure that the shove state is preserved.
2021-09-26 15:15:51 +01:00
Jeff Young 46949abe4a Don't scroll to highlight an object already visible. 2021-09-25 15:31:52 +01:00
Seth Hillbrand 28bd734313 Prevent invalid paths in fracture
We are not always sure of the path validity in fracture.  Nominally, the
Clipper Simplify routine should remove invalid parts but in the case
where it doesn't, we need to recover gracefully, even if the output
polygon is not valid.

Fixes https://gitlab.com/kicad/code/kicad/issues/9199
2021-09-21 10:49:39 -07:00
Jeff Young 7a993c0211 Add support mode for dark mode to SCINTILLA_TRICKS.
Also removes the return value from the BITMAP_STORE's themeChanged
method as it will provide the wrong answer for the second frame it's
called on.

Also hooked up ACTION_TOOLBAR, the app launcher, and the project tree
to the wx event for system color changes so they change on the fly.

Fixes https://gitlab.com/kicad/code/kicad/issues/6026
2021-09-14 00:18:50 +01:00
Jeff Young f64abcba36 Restore BBoxCache usage for zone fill performance. 2021-09-09 16:43:47 +01:00
Marek Roszko 3b7f5a3db7 Remove the native cursor for moving on Windows to avoid visual conflicts
Fix #8801
2021-09-04 18:27:02 -04:00
Roberto Fernandez Bautista ed39b33d74 Fix edge case in CIRCLE::Intersect that caused a divide-by-zero crash
Also add some additional test cases.
2021-08-25 19:11:19 +01:00
Jon Evans 80355f04a9 Fix SHAPE_LINE_CHAIN::Replace at end of chain 2021-08-13 16:59:45 -04:00
Roberto Fernandez Bautista d9cf939ba1 SHAPE_LINE_CHAIN::Replace Don't call front() or back() if empty
Fixes https://gitlab.com/kicad/code/kicad/-/issues/8949
2021-08-12 16:32:06 +01:00
Roberto Fernandez Bautista ab3564f12d Fix formatting in prior commit 2021-08-11 17:40:23 +01:00
Roberto Fernandez Bautista 22df01183d Fix edge cases in CIRCLE::Intersect that were causing KiROUND overflow 2021-08-11 17:31:27 +01:00
Roberto Fernandez Bautista 11fc74920c Fix infinite loop in SHAPE_LINE_CHAIN::Slice
Was resulting in infinite loop due to wrong calculation
in NextShape.
2021-08-09 21:10:33 +01:00
Roberto Fernandez Bautista ae87dc686a Fix SHAPE_LINE_CHAIN::NearestPoint when aAllowInternalShapePoints=false
Fixes https://gitlab.com/kicad/code/kicad/-/issues/8770
2021-08-08 20:58:20 +01:00
Roberto Fernandez Bautista 1edb96cc5b Fix SHAPE_LINE_CHAIN::Slice(), splitting arcs when required 2021-08-08 19:09:54 +01:00
Roberto Fernandez Bautista eaf8eb284a Add true arc-to-polyline collisions 2021-08-05 17:45:12 +01:00
Roberto Fernandez Bautista dd65ce9523 Simplify & move new arc collision code into Kimath library
Don't need to check intersections with the circle, just fix the
calculated "projected" point from the end points.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/8234
2021-08-05 17:45:12 +01:00
Roberto Fernandez Bautista b6be10f05c Fix CIRCLE::Intersect( const SEG& aSeg ) and add unit tests 2021-08-05 17:45:12 +01:00
Roberto Fernandez Bautista 318435aedb Add more test cases: simulate zone fill around arc + diff pair meander 2021-08-05 17:45:11 +01:00
jean-pierre charras b6664eecf2 arc: fix incorrect arc center calculation for angle < 0 or > 180 deg 2021-08-05 18:15:55 +02:00
Jeff Young c00f4ed5d2 Add regression tests for track cleaner. 2021-08-03 16:17:18 +01:00
david-beinder 3a833debea ShapeToPolygon: implement negative inflation
Fixes https://gitlab.com/kicad/code/kicad/-/issues/8859
2021-07-28 10:37:56 +00:00
Wayne Stambaugh 369d813a32 Pass std::string by reference instead of on the stack where applicable. 2021-07-27 13:30:05 -04:00
Wayne Stambaugh 78e5e98ea0 Pass VECTOR2I objects by reference instead of on the stack. 2021-07-27 08:41:27 -04:00
Wayne Stambaugh 8fd83cbb95 Pass wxPoint objects by reference instead of on the stack. 2021-07-26 15:35:33 -04:00
Jeff Young 4760480f40 Quiet compiler warnings. 2021-07-22 13:03:17 +01:00
david-beinder 937e4b1d8c ShapeToPoly: Fix outline/arc intersection for large expansions
Fixes https://gitlab.com/kicad/code/kicad/-/issues/8820
Adds shortcut code path for 90deg corners
Segments are now actually symetrical
Refactored and commented the code
2021-07-22 11:53:08 +00:00
Wayne Stambaugh bf80b9c04c Last of the NULL expunging. 2021-07-20 10:32:22 -04:00
Wayne Stambaugh 4c457b5ed3 More NULL expunging. 2021-07-18 14:31:55 -04:00
jean-pierre charras 25e9d17722 Fix a boost compatibility with old boost versions.
(replace boost::optional::has_value() by its definition is_initialized())
2021-07-16 14:01:26 +02:00
david-beinder 8b3ccab0a3 Implement explicit polygon construction for most pad shapes
Fixes https://gitlab.com/kicad/code/kicad/-/issues/8650
2021-07-13 14:51:58 +00:00
jean-pierre charras 54b6f51633 DSN export: export RECT and ARC shapes (on silkscreen layer) from footprints
Also export arc track segments as lines. (Freerouter does not support QARCs)
Fixes #8769
https://gitlab.com/kicad/code/kicad/issues/8769
2021-07-11 18:15:40 +02:00
jean-pierre charras ec64e8ad5b TransformRingToPolygon(): fix incorrect approximation of the hole. 2021-07-06 13:59:05 +02:00
Roberto Fernandez Bautista 72435c78af Fix out of bounds crash in SHAPE_LINE_CHAIN::splitArc
Check that the index references a point that is part of an arc
2021-07-05 20:29:24 +01:00
jean-pierre charras 515669284a convert_basic_shapes_to_polygon: some enhancements:
- allows setting a minimal seg count for circles and rounded end segments.
- When using ERROR_OUTSIDE, ensure the arc correction is the actual value
needed by the segment count, not the max value allowed
2021-07-05 17:46:02 +02:00
Jon Evans 3103ff9aa3 Fix display of filled polygons with arcs in the outline 2021-07-04 12:10:59 -04:00
Jon Evans ddc20dadc0 Formatting and spelling tweaks 2021-07-03 15:43:40 -04:00
Roberto Fernandez Bautista cee5920d5c Remove dead code (SHAPE_LINE_CHAIN::DetectArcs) 2021-07-03 19:37:50 +00:00
Roberto Fernandez Bautista 778c64de88 Implement ClearArcs() and check curved polys don't get a booleanOp
We cannot (yet) support passing several curved outlines through clipper.
In these cases, the caller should ClearArcs() before processing.
2021-07-03 19:37:50 +00:00
Roberto Fernandez Bautista 260a9d0540 Use ZFillFunction to modify arcs post clipper (does not fully work yet)
Added a unit test to verify union and intersection of polygons result
in desired results: subject + clip - intersect == union
2021-07-03 19:37:50 +00:00
Roberto Fernandez Bautista 437e2783fb Use Clipper Z value to detect arcs post clipper 2021-07-03 19:37:50 +00:00
Roberto Fernandez Bautista a9a8aa8243 SHAPE_LINE_CHAIN splitArc on Insert, Remove and Replace
This ensures that the arc shapes remain correct after removing
a point belonging to an arc or inserting a point in the middle
of an arc.

Simplify implementation of Replace( ..., aP ). Now a Remove
operation followed by an Insert operation.

Improve QA test for SHAPE_LINE_CHAIN Append, Insert and Replace

Implement SHAPE_LINE_CHAIN::splitArc to break up an arc into two

Implement SHAPE_ARC::ConstructFromStartEndCenter and add qa test
2021-07-03 19:37:50 +00:00
Roberto Fernandez Bautista 3f73d8c2b5 SHAPE_LINE_CHAIN::Area() should always be positive
The algorithm relied on the assumption that the points were
ordered anti-clockwise. When ordered in a clockwise fashion, the
result was correct but negative.

Refer to https://www.mathopenref.com/coordpolygonarea2.html
for more information.
2021-07-03 19:37:50 +00:00
Roberto Fernandez Bautista c3051ba48a Refactor SHAPE_LINE_CHAIN to allow two shapes per point
m_shapes now has two possible indices. The first one is populated if
the point is associated with an arc and the second index is populated
if the point is shared between two arcs.
2021-07-03 19:37:50 +00:00
Roberto Fernandez Bautista c1361ae173 SHAPE_POLY_SET: Detect arcs after boolean operations 2021-07-03 19:37:50 +00:00
Roberto Fernandez Bautista 3ee8b4825c Implement SHAPE_LINE_CHAIN::DetectArcs and add qa test 2021-07-03 19:37:50 +00:00
Roberto Fernandez Bautista 14c3d9055e Add CIRCLE::Contains( VECTOR2I aP ) and add unit tests 2021-07-03 19:37:50 +00:00
Seth Hillbrand a28d9f17e8 WIP 2021-07-03 19:37:50 +00:00
Seth Hillbrand 8521deb38d De-scope ClipperLib namespace 2021-07-03 19:37:50 +00:00
Seth Hillbrand 6c224156f5 Adding conversion from points to arcs
Allows detection of arcs from segments in a SHAPE_LINE_CHAIN, converting
them to SHAPE_ARCs in the chain
2021-07-03 19:37:50 +00:00
Seth Hillbrand 5b2be906b8 Removing CLIPPER poly support 2021-07-03 19:37:50 +00:00
Seth Hillbrand 4f4deece6d ADDED support for reading/writing arcs in polys
This adds support for reading and writing arc elements in polygons.
2021-07-03 19:37:50 +00:00
Marek Roszko eff75b630f Get rid of anonymous struct typedefs
We are using C++14 where there is no reason for this and is banned in C++20 under P1766R1. MSVC generates a warning under C++14 as a reminder.
2021-07-01 18:28:41 -04:00
Wayne Stambaugh 507a88524a KiCad internal library header file housekeeping. 2021-07-01 13:46:38 -04:00
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
Jon Evans 80eee2decb Fix MSW build 2021-04-02 20:13:10 -04:00
Ian McInerney 8ea18c0639 Don't steal focus from other windows on GTK
Before, it was possible for the canvas to steal the
focus if the cursor was only moved over it and not
clicked. Now, the canvas will only take the focus if
the frame is active.

Fixes https://gitlab.com/kicad/code/kicad/issues/7233
2021-04-03 00:17:28 +01:00
Jeff Young b6f2941a06 Another try a allowing touching courtyards.
Fixes https://gitlab.com/kicad/code/kicad/issues/8076
2021-03-31 22:54:30 +01:00
Ian McInerney 41f88dbabc Refactor platform-specific init into two phases
The first phase is for the environment before the OS
apps are created, and the second phase is for after
the OS app is created but before all of our processing.

Fixes https://gitlab.com/kicad/code/kicad/issues/7992
2021-03-23 19:11:08 +00:00
Jon Evans cdb352bb24 Allow finding kicad_3dsg when running from build dir
This might also come in handy later when we use more dynamic libs
2021-03-21 09:16:47 -04:00
Jon Evans f1c599fa4d Tweak PCB selection behavior to reduce unintuitive behavior
We were discarding shapes too aggressively for having a
larger area than a shape underneath.

Let's also try showing fewer disambiguation menus, in particular
always preferring items on the active layer when the candidates
include overlapping items of similar area on other layers.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/7949
2021-03-20 13:11:51 -04:00
Roberto Fernandez Bautista e4b99b9bb5 Fix SHAPE_ARC::Collide and add Unit Tests 2021-03-20 16:11:43 +00:00
Marek Roszko 917e368db3 Add missing header that broke msvc builds 2021-03-20 10:28:35 -04:00
Jon Evans 61c9645220 Fix Windows build 2021-03-19 18:36:16 -04:00
Ian McInerney 008f0d55c3 Add an interceptor for GTK error messages to hide them
wxWidgets seems to cause GTK to spam messages to the terminal,
and we have no control over that. So lets hide the messages
so no one complains about them. If people really want to see
them, they can add the KICAD_SHOW_GTK_MESSAGES build flag to CMake
and they can watch them scroll past.
2021-03-19 22:05:00 +00:00
Ian McInerney 3036683a2c Move platform-specific init tasks into KIPLATFORM 2021-03-19 21:26:07 +00:00
Seth Hillbrand 48bd564639 Add Dark mode detection to MacOS 2021-03-16 21:58:42 +00:00
Jon Evans a9f86c6f3d Enable icon themes for Windows
Windows 10 "dark mode" is not supported and likely won't be,
but high-contrast mode and manual color theme editing is still
possible.
2021-03-14 15:39:47 -04:00
Dominik Wernberger e2aa7be4b3 Added a lot of consts and refactored a few lines 2021-03-08 12:49:48 -08:00
Mikolaj Wielgus 0f22b54cd8 Clip the leader lines properly when using circular text frame
Fixes https://gitlab.com/kicad/code/kicad/issues/7810
2021-03-07 21:19:19 +00:00
Tomasz Wlostowski 87ea540953 Fix whitespace errors 2021-02-25 17:18:23 +01:00
Tomasz Wlostowski f7f5e67f56 geometry: SHAPE_LINE_CHAIN::Simplify() now correctly simplifies last 3 colinear vertices 2021-02-25 17:18:23 +01:00
Tomasz Wlostowski baacb9c85a geometry: fix MTV calculation for simple polygons 2021-02-25 17:18:23 +01:00
Seth Hillbrand 507ca9bc73 Add DPI scaling to KIPLATFORM
GTK needs to check current scaling but wx doesn't provide this
functionality in 3.0, so we can bypass by going straight to the source.
2021-02-22 17:38:27 -08:00
Jeff Young e89f9db438 Footprint disallow layer checking needs to be based on courtyards.
Fixes https://gitlab.com/kicad/code/kicad/issues/7620
2021-02-20 14:13:36 +00:00
Jon Evans 079203c345 Change Linux documents path to XDG_DATA_HOME
Fixes https://gitlab.com/kicad/code/kicad/-/issues/7543
2021-02-17 20:25:50 -05:00
Roberto Fernandez Bautista 2d66abdc89 CADSTAR PCB Archive Importer: More improvements to loading of zones
Adds a new function Area() to SHAPE_POLY_SET
2021-02-10 18:49:21 +00:00
Jon Evans 1ba7bebce6 Handle lack of a Documents directory 2021-02-09 20:15:30 -05:00
Marek Roszko 872184fe8b Revert "Bump minimum required CMake version to 3.10"
This reverts commit a475f45753.
2021-02-09 18:46:13 -05:00
Jon Evans 9728ceab0d Fall back to explicit documents path if XDG special dirs are missing
Fixes https://gitlab.com/kicad/code/kicad/-/issues/7452
2021-02-08 20:21:39 -05:00
Simon Richter a475f45753 Bump minimum required CMake version to 3.10
This allows us to remove even more workarounds
2021-02-08 12:23:08 +00:00
Jeff Young 90b3d0c96d Implement TransformShapeWithClearanceToPolygon for DIMENSIONs.
Fixes https://gitlab.com/kicad/code/kicad/issues/6890
2021-02-03 23:34:17 +00:00
Marek Roszko 06a515339c Correct pointless and bad buffer sizing in RegisterApplicationRestart 2021-02-01 15:36:07 -05:00
Seth Hillbrand 73886aecb1 Ensure partially triangulated polys are not valid
Moves rule area triangulation outside of layer iterator and keeps the
triangulation_valid flag false until the triangulation has been
completed.

Fixes https://gitlab.com/kicad/code/kicad/issues/7032
2021-01-29 16:33:57 -08:00
Marek Roszko a47e8af0d0 Fix up naming of the kiplatform helpers 2021-01-27 19:12:20 -05:00
Marek Roszko 299830350c Fix macos build error 2021-01-27 19:12:19 -05:00
Marek Roszko 34bcf1883d Blindly implement the macos fetch of cache dir 2021-01-27 19:12:19 -05:00
Marek Roszko daf9c4f319 Centralize the 3d cache path 2021-01-27 19:12:19 -05:00
Marek Roszko 8622565480 Add GetUserConfigDir 2021-01-27 19:12:18 -05:00
Marek Roszko 2bbc25a630 Use g_get_user_special_dir for documents dir on gtk 2021-01-27 19:12:18 -05:00
Marek Roszko 28c6967dbc Start trying to shuffle around path management 2021-01-27 19:12:18 -05:00
Wayne Stambaugh 6ab1144ea3 Fix broken Doxygen comment specifiers.
Please note, ///> is not a valid Doxygen comment specifier.  ///< is the
correct specifier to use for single line or short Doxygen comments.
2021-01-25 07:42:36 -05:00
Roberto Fernandez Bautista 99d203feae Clarify CIRCLE::ConstructFromTanTanPt
Remove unused bool aAlternateSolution and add doxygen comments
2021-01-24 16:41:11 +00:00
Roberto Fernandez Bautista 48823c0723 Formatting fixes and fix qa_kimath following rebase 2021-01-24 16:41:10 +00:00
Roberto Fernandez Bautista 19620cebe7 qa tests: fix test_circle 2021-01-24 16:41:10 +00:00
Roberto Fernandez Bautista 6ed5ed52b8 qa tests for CIRCLE geometry library 2021-01-24 16:41:10 +00:00
Roberto Fernandez Bautista b6a50d2f74 qa tests for SEG perpendicularity and parallelism 2021-01-24 16:41:10 +00:00
Roberto Fernandez Bautista 6e7ae93cc8 EDIT_TOOL::DragArcTrack Fix incorrect undo history when items are deleted
Need to make sure we only apply one COMMIT operation per object before calling COMMIT::Push() or COMMIT::Revert()
2021-01-24 16:41:10 +00:00
Roberto Fernandez Bautista 2b5c1bae97 CHANGED: Dragging a curved track starts an interactive resizing of it, keeping start an end points tangent 2021-01-24 16:41:10 +00:00
Seth Hillbrand b8dfcb34c4 Revert "Use less-sophisticated arc editing math."
This reverts commit 3b424d3868.  And fixes
issue with rouding causing arc errors
2021-01-18 12:44:27 -08:00
Mikolaj Wielgus 00a9910149 Fix misplaced parenthesis in VECTOR2<T>::Resize()
Fixes https://gitlab.com/kicad/code/kicad/issues/7045
2021-01-16 09:41:14 +00:00
Dominik Wernberger dc02ec9758 Remove a few const_cast 2021-01-12 20:51:31 +00:00
Dominik Wernberger ac94d72d2d Add more const specifiers 2021-01-12 20:51:31 +00:00
Tomasz Wlostowski 7994c59169 libs/kimath: POLY_GRID_PARTITION must use truncating (round-to-zero) rescale function for correct grid generation. 2021-01-10 00:04:57 +01:00
Seth Hillbrand b2cfd7f479 Fix rounding issues
Rescaling and rotating has been leaving 1nm errors due to integer
truncation in VECTOR2I.  This rounds integers using KiROUND before
returning
2021-01-09 13:05:58 -08:00
Jon Evans 31dd04fa96 Fix ToVector to return world coordinates
Fixes https://gitlab.com/kicad/code/kicad/-/issues/7002
2021-01-08 13:52:39 -05:00
Jon Evans c3eb8dccda Fix typo in DIRECTION_45 ctor 2021-01-07 19:13:05 -05:00
Seth Hillbrand a342bb9ab3 Standardize rounding in 64-bit rescale
32-bit rescale still uses truncation until we can determine how this
affects poly_grid_partition
2021-01-07 11:21:05 -08:00
Seth Hillbrand 77acf85310 Revert "Standardize rescale"
poly_grid_partition appears to depend on integer calculation for large
scaling

This reverts commit eef16fe717.
2021-01-07 10:36:06 -08:00
hoijui 6ca9a42251 Removes 3 other instances of a potential encoding problem
Signed-off-by: hoijui <hoijui.quaero@gmail.com>
2021-01-07 17:36:49 +00:00
hoijui e34b829242 Prevent an encoding error when generating python API DoxyGen
Signed-off-by: hoijui <hoijui.quaero@gmail.com>
2021-01-07 17:36:49 +00:00
Jon Evans 0234b7278a PNS: Make DIRECTION_45 North be up everywhere
Fixes https://gitlab.com/kicad/code/kicad/-/issues/6935
2021-01-06 21:47:06 -05:00
Seth Hillbrand eef16fe717 Standardize rescale
Rescale was returning differing results based on 32-bit vs 64-bit
implementations.  Speed difference here appears to be positive.
2021-01-06 17:52:14 -08:00
Jeff Young 2a088e5c7b Add conversion of circles to zones and enable in footprint editor.
Also rule areas, of course.

Fixes https://gitlab.com/kicad/code/kicad/issues/6966
2021-01-06 17:21:49 +00:00
Jon Evans 7431d5c985 PNS: First pass at updating meander placers for arcs
Fixes https://gitlab.com/kicad/code/kicad/-/issues/6464
2021-01-05 17:57:21 -05:00
Jon Evans 8619086cf2 PNS: re-enable optimization of colinear segs in lines with arcs 2021-01-05 17:57:21 -05:00
Jon Evans 8901e71fc8 PNS: Fix loop removal, make walkaround less broken for arcs 2021-01-05 17:57:21 -05:00
Jon Evans aebb571dc9 Short-circuit arc generation if we are on a diagonal 2021-01-05 17:57:21 -05:00
Seth Hillbrand 5a97764319 Make segment contain its edge
This allows segment snapping along its diagonals to the grid.

Fixes https://gitlab.com/kicad/code/kicad/issues/6924
2021-01-03 12:47:33 -08:00
Jon Evans eaffacbc85 PNS: construct initial lines with arcs more precisely 2021-01-02 23:57:09 -05:00
Jon Evans af4c6393bb Fix arc collisions to account for width
This was causing arcs to be really hard to start routing from
2021-01-02 22:01:05 -05:00
Jon Evans 73248ab219 PNS: correct initial segment direction for posture solver 2020-12-31 13:05:43 -05:00
Jon Evans 111c644a82 Don't append zero-length arcs 2020-12-31 13:05:43 -05:00
Jon Evans fbdf31d35a Prevent creating arcs with slightly offset endpoints 2020-12-31 13:05:43 -05:00
Jon Evans 23c9eddf2d Cleanup 2020-12-30 18:29:41 -05:00
Jon Evans 79502a0d88 PNS: A new approach to arc placement
Fixes https://gitlab.com/kicad/code/kicad/-/issues/6334
2020-12-30 18:23:24 -05:00
Jeff Young af2219ba7f Finish implementation of hole clearance checking.
It appears we never did via hole testing, and pad hole testing didn't
appear to get much testing.
2020-12-25 22:32:19 +00:00
Jon Evans ea351fde69 Recache polygon triangulation when mirroring
Fixes https://gitlab.com/kicad/code/kicad/-/issues/6265
2020-12-20 10:45:24 -05:00
Marek Roszko 33dbc8ccd1 Add IsNetworkPath to kiplatform 2020-12-15 19:28:58 -05:00
Marek Roszko d67cf2f9af Replace wxFile usage with wxFFile
Buffered libc wxFFile is better thinking about syscall wxFile going wrong.
2020-12-12 13:16:23 -05:00
Jeff Young bc484784fc Make sure zones are triangulated for DRC.
Normally this happens as a side-effect of rendering them but if done
from a script (or test case) this won't happen.

Fixes https://gitlab.com/kicad/code/kicad/issues/6635
2020-12-12 15:27:46 +00:00
Jeff Young f08b7f098f Cleanup. 2020-12-12 15:27:46 +00:00
Jeff Young 807eef1208 Better error reporting to try and catch 6635. 2020-12-12 12:22:52 +00:00
Jeff Young 2c2630ef9e Formatting. 2020-12-12 03:43:41 +00:00
Ian McInerney be4b6ec06a Cleanup compiler warnings 2020-12-09 23:13:33 +00:00
Jeff Young 37178e3751 Formatting. 2020-11-29 14:02:46 +00:00
jean-pierre charras 68625494f3 specctra_export: fix an issue with custom and chamfered/round rect pads.
Is some cases a created pad stack name had the same name as an other pad stack
having a slightly different shape, thus creating pads with a incorrect shape on board.

Fixes #6495
https://gitlab.com/kicad/code/kicad/issues/6495
2020-11-25 13:57:46 +01:00
Jeff Young 9c7c05c161 Mostly formatting cleanup but a few type-casting cleanups too. 2020-11-24 22:16:41 +00:00
Marek Roszko 45598f2933 Add handling of DXF arbitrary axis/extrusions
This fixes some DXFs imports where unforunately CAD tools like SolidWorks
randomly decide to mirror circle definitions across the "z" axis (resulting in x or y axis flips in 2d)
Most likely live projection from 3D to 2D drawings introduces this.
However this is DXF specification to describe it so obtusely with vectors for a 2d drawing.
2020-11-23 21:24:38 -05:00
Werni 0e44f5128c Add const specifiers 2020-11-18 19:50:36 +00:00
Jeff Young a3a409b438 Fix crash bug when deleting files with spaces in names. 2020-11-14 14:15:02 +00:00
jean-pierre charras 7265f84358 fix PAD::TransformShapeWithClearanceToPolygon() incorrect calculation in some cases.
For round rect pads, when the arc error was OUTSIDE, the shape was too big and creates
bad shape for chamfered round rect pads.
For chamfered pads, when the clearance value was not 0, the chamfer was not at the
right place.
2020-11-14 08:50:58 +01:00
Jeff Young 63773809d0 Formatting. 2020-11-10 18:08:25 +00:00
Jeff Young 791a50b493 Remove work-around in favour of real fix in Clipper. 2020-11-04 11:21:45 +00:00
Jeff Young 55c25f3cc4 Work around a round-off bug in Clipper.
Fixes https://gitlab.com/kicad/code/kicad/issues/6260
2020-11-02 17:43:13 +00:00
Jeff Young 6bf29deb7f Improve formatting. 2020-10-31 17:25:08 +00:00
Werni a7d5d1f091 Add more consts all over the place 2020-10-27 11:03:35 +00:00
Jeff Young d1c73cb1d5 Clean up MODULE effective shape memory handling. 2020-10-25 23:38:21 +00:00
Jeff Young 31cc100669 Don't make clients deal with nested SHAPE_COMPOUNDs. 2020-10-25 18:17:58 +00:00
jean-pierre charras d6f91c810f Fix a few compil and Coverity warnings. 2020-10-25 10:02:07 +01:00
Jeff Young 59f3fefd17 When polygonizing arcs don't use synthesized center and angle.
Start, mid and end are the "real" properties and come with less
error.

Also collapses two arc polygonization routines into one.

Also fixes DRC checks to be cognizant of arc approximation error.

Fixes https://gitlab.com/kicad/code/kicad/issues/6039
2020-10-23 23:55:45 +01:00
Jeff Young 1cb7fbaab1 Fix errors in arc polygonization and test case.
1) Tests can't expect accuracies around 1 to work.  PCBNew defaults
to 5000.
2) Tests shouldn't artifically expand tolerance just to match the
results.
3) Tests should guarantee that end point is on arc, not just close
to it.
4) Standard polygonization of a circle is inside so splitting the
error needs to increase radius, not decrease.
5) Special-case first and last points so that they're exact.
2020-10-23 23:55:45 +01:00
Seth Hillbrand 19bf594aa0 Remove unused point in polygon test
There can be only one.
2020-10-23 12:13:09 -07:00
Jeff Young 58c006bc45 Register properties for ARC elements so we can get their netclass.
Also improves GAL arc drawing and polygonization.

Fixes https://gitlab.com/kicad/code/kicad/issues/6039
2020-10-23 14:27:36 +01:00
Tomasz Wlostowski 5b4f463c38 kimath: SHAPE_POLY_SET::Format() outputs C++-like code now, like other shapes 2020-10-23 01:18:01 +02:00
Tomasz Wlostowski a8074ed37d kimath: POLY_GRID_PARTITION now uses safer degeneracy (overlapping edges/'slits') handling mechanism. Also added some explanation of the algorithm used. 2020-10-23 01:17:54 +02:00
Wayne Stambaugh 8185a416b9 Fix broken build on Linux with gcc. 2020-10-22 08:36:28 -04:00
Jeff Young 9ff49277e1 Add implicit rule generation for keepout areas.
Also implements collision detection for SHAPE_POLY_SET.

Fixes https://gitlab.com/kicad/code/kicad/issues/6105
2020-10-22 10:41:21 +01:00
Jeff Young bfd04926b5 Performance improvement for polyset fracture. 2020-10-20 22:26:47 +01:00
Roberto Fernandez Bautista 006c462d8f ADDED: Fillet Tracks tool in pcbnew
Select two or more track segments and run the "Fillet Tracks" tool.
2020-10-20 21:23:05 +00:00
Ian McInerney 06f01d0d8a Add platform-specific code to allow wxChoice to ellipsize
Fixes https://gitlab.com/kicad/code/kicad/issues/5377
2020-10-17 23:20:13 +01:00
Jeff Young bbe7573d1c Performance enhancements to roundrect pads and clearance outlines.
Aka: avoid Clipper at all costs.

Fixes https://gitlab.com/kicad/code/kicad/issues/5900
2020-10-14 15:56:43 +01:00
Jeff Young 54dc91a623 Account for segment width in aActual calculation.
Fixes https://gitlab.com/kicad/code/kicad/issues/5990
2020-10-14 15:56:32 +01:00
Jeff Young 1703729269 Require explicit decl of maxError and errorLocations.
This should reduce both performance issues and clearance issues.
2020-10-13 13:49:07 +01:00
Marek Roszko 88102bca46 Kick the refresh timer for GAL on Win32 with a terrible hack 2020-10-11 21:44:46 -04:00
Jon Evans 14c2937fc3 Implement IsDarkTheme for GTK 2020-10-10 14:55:32 -04:00
Jon Evans cc563d254f Add MSW implementation for IsDarkTheme (for future)
As noted, we can't enable this yet as wxWidgets does
not automatically apply a dark theme to the system
colors.
2020-10-10 14:15:30 -04:00
Ian McInerney 48a5907412 Remove extraneous debug statements 2020-10-08 17:56:54 +01:00
Tomasz Wlostowski db9e111838 kimath: SHAPE_POLY_SET should re-parent triangulated polygons when copied/cloned 2020-10-08 15:22:17 +02:00
Jeff Young 2f49db49bf Fix fly-off arc handles and move Arc Properties to start/end/angle.
Fixes https://gitlab.com/kicad/code/kicad/issues/5791
2020-10-08 11:33:32 +01:00
Mark Roszko d9485129c8 Implement more context specific cursors using both stock and custom cursors. 2020-10-08 00:50:28 +00:00
Ian McInerney 16374e9ae1 Ensure string is chosen correctly 2020-10-07 23:23:43 +01:00
Tomasz Wlostowski 8fb154e04e geometry: SHAPE_RECT: use SquaredDistance() for collision detection 2020-10-07 16:36:37 +02:00
Tomasz Wlostowski d6fa81036b geometry: SEG::NearestPoint(SEG) now returns points only on (this) segment 2020-10-07 16:36:37 +02:00
Tomasz Wlostowski 1ef120ff4f geometry: SHAPE::Format() now outputs C-like code for easy test cases... 2020-10-07 16:36:37 +02:00
Tomasz Wlostowski 7ffef32ea0 geometry: placeholder method for converting compounds to simple polygons [wip] 2020-10-07 16:36:37 +02:00
Tomasz Wlostowski bd27d38d9a DRAW_PANEL_GAL: added DebugOverlay() method, creating a temporary overlay for drawing debug graphics 2020-10-07 16:36:37 +02:00
Jeff Young 18a3c4c1db Fix some fairly catastrophic bugs in shape collision optimization.
I did a little too much copy & paste last time around....
2020-10-05 22:32:07 +01:00
Mark Roszko a28a0e14ba Fix conversion warnings 2020-10-05 10:41:14 +00:00
Jeff Young 8dd7777108 Handle closed shape-line-chain with circle collisions. 2020-10-04 19:40:18 +01:00
Jeff Young f9cfd31351 0 is always a collision (whether clearance is 0 or not). 2020-10-04 13:21:01 +01:00
Jeff Young f4f578b755 Add closed-shape handling to SHAPE_LINE_CHAIN collision routines. 2020-10-04 13:21:01 +01:00
Jeff Young bf67648562 Support optional location reporting in SHAPE collisions.
Also fixes a few bugs in the collision routines.
2020-09-28 23:28:33 +01:00
Tomasz Wlostowski 482767a850 libs/kimath: implement indexable subshape support for SHAPE_COMPOUND and SHAPE_POLY_SET 2020-09-27 16:45:46 +02:00
Ian McInerney c5feccca53 Add stub functions in KIPLATFORM to detect dark mode
These haven't been written yet, but current code can
be adapted to use these now.
2020-09-20 01:43:27 +01:00
Jeff Young d402d93487 Implement shape routines for DIMENSION_Ts.
This allows them to participate in DRC and PNS.

Fixes https://gitlab.com/kicad/code/kicad/issues/5712
2020-09-19 14:16:00 +01:00
Jeff Young 0f3d2147aa Performance enhancements for DRC. 2020-09-17 20:13:39 +01:00
Seth Hillbrand 08bf5f4b4e ADDED: 45° snapping for rectangles aka Squares
The snap obeys only the Ctrl key and not the global preference setting
for drawsegments because rectangles are _always_ on H/V lines when drawn

Fixes https://gitlab.com/kicad/code/kicad/issues/5607
2020-09-15 11:22:26 -07:00
jean-pierre charras 9f85730987 Make SHAPE_POLY_SET::CacheTriangulation() behavior same as previously.
Previously, SHAPE_POLY_SET::CacheTriangulation() was able to handle polygons
with holes.
Due to recent changes, CacheTriangulation( true ) handle polygons with holes,
but CacheTriangulation( false ) did not handle polygons with holes, due to a
missing call to Fracture(), lost in latest changes.
This is now fixed.

Fixes #5606
https://gitlab.com/kicad/code/kicad/issues/5606
2020-09-13 17:55:59 +02:00
Seth Hillbrand 35d993988d Comment update 2020-09-11 09:48:39 -07:00
Seth Hillbrand 03f510ff0d Ensure segmented polys have outlines
In the event the calculation removes outlines, we need to keep the
original polygon

Fixes https://gitlab.com/kicad/code/kicad/issues/5594
2020-09-11 08:45:11 -07:00
Jeff Young 6b4a6f4d3e Restore min seg limit for rounded-corner pads.
It suffered from a cacophony of errors, starting with an errant
comment that made it later look like a bug.  Sigh.
2020-09-11 14:41:45 +01:00
Jeff Young e2bc7557cc Clean up arc/circle polygonization.
1) For a while now we've been using a calculated seg count from a given
maxError, and a correction factor to push the radius out so that all
the error is outside the arc/circle.  However, the second calculation
(which pre-dates the first) is pretty much just the inverse of the first
(and yields nothing more than maxError back). This is particularly
sub-optimal given the cost of trig functions.

2) There are a lot of old optimizations to reduce segcounts in certain
situations, someting that our error-based calculation compensates for
 anyway.  (Smaller radii need fewer segments to meet the maxError
condition.) But perhaps more importantly we now surface maxError in the
UI and we don't really want to call it "Max deviation except when it's
not".

3) We were also clamping the segCount twice: once in the calculation
routine and once in most of it's callers.  Furthermore, the caller
clamping was inconsistent (both in being done and in the clamping
value). We now clamp only in the calculation routine.

4) There's no reason to use the correction factors in the 3Dviewer;
it's just a visualization and whether the polygonization error is
inside or outside the shape isn't really material.

5) The arc-correction-disabling stuff (used for solder mask layer) was
somewhat fragile in that it depended on the caller to turn it back on
afterwards.  It's now only exposed as a RAII object which  automatically
cleans up when it goes out of scope.

6) There were also bugs in a couple of the polygonization routines where
we'd accumulate round-off error in adding up the segments and end up with
an overly long last segment (which of course would voilate the error
max). This was the cause of the linked bug and also some issues with vias
that we had fudged in the past with extra clearance.

Fixes https://gitlab.com/kicad/code/kicad/issues/5567
2020-09-11 11:23:49 +01:00
Seth Hillbrand 08d4e91f3b Change partitions to fixed size
Partititioning small polygons causes excessive partitions when we use a
fixed number of cells per side.  Partitioning by size keeps the
partition count limited and speeds the calculations.

Also adds an option to not partition the grid for elements (like 3d
raytracing) that do not need it.

Fixes https://gitlab.com/kicad/code/kicad/issues/5579
2020-09-10 09:31:20 -07:00
Roberto Fernandez Bautista b1343ca281 Fix NormalizeAngleNeg to be (-360, 0] 2020-09-08 21:21:21 +00:00
Roberto Fernandez Bautista a9ef38e6c8 CADSTAR PCB Archive Importer: Load Board shapes 2020-09-08 21:21:20 +00:00
Seth Hillbrand 37e268c162 Remove incorrect short-circuit of rotate 2020-09-08 14:10:23 -07:00
Seth Hillbrand efb03b7482 Optimize loading new footprints
When loading footprints, we need to skip the triangulation trigger in
rotate.  If the triangulation cache is invalid when starting the
rotation, do not retriangulate after the rotation.
2020-09-08 11:17:50 -07:00
Tomasz Wlostowski aee06e46b0 SHAPE_POLY_SET: split polygons into rectangular cell grids to obtain more regular triangulations 2020-09-08 01:31:42 +02:00
Tomasz Wlostowski 83ac2070fe BOX2: allow constructing a zero-sized BOX2 from a single point 2020-09-08 01:31:42 +02:00
Tomasz Wlostowski 74623b8c98 geometry: derive SHAPE_LINE_CHAIN, SHAPE_SIMPLE and SHAPE_POLY_SET::TRIANGULATED_POLYGON::TRI from a common base class allowing to simplify collision detection 2020-09-08 01:31:42 +02:00
Tomasz Wlostowski eb6e1c4f90 geometry: handle collisions of null shapes 2020-09-08 01:31:42 +02:00
Tomasz Wlostowski 5096ac815f libs/kimath: introducing empty shape object (SHAPE_NULL) 2020-09-08 01:31:42 +02:00
Mark Roszko 9f128f942c Move shutdown blocker to kiplatform 2020-09-01 10:14:51 +00:00
Jon Evans fa8655511e Enable converting segments to arcs
Fixes https://gitlab.com/kicad/code/kicad/-/issues/1957
2020-08-29 12:13:51 -04:00
Ian McInerney a0d84e94fd Use move to trash to the project manager instead of immediate delete
CHANGED: Delete in the project manager now moves files to the trash can

Fixes https://gitlab.com/kicad/code/kicad/-/issues/2499
2020-08-28 23:00:43 +00:00
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
Seth Hillbrand afc94fdec3 PNS: Be better about handling multiple layers
Rather than adding pads/vias multiple times for each layer, we introduce
the "alternate shape" idiom to PNS that allows us to optionally place
the collision constraint on the hole instead of the pad for those
vias/pads that have inner layers removed.

Fixes https://gitlab.com/kicad/code/kicad/issues/5158

Fixes https://gitlab.com/kicad/code/kicad/issues/5198

Fixes https://gitlab.com/kicad/code/kicad/issues/5195
2020-08-16 12:39:15 -07:00
Jeff Young 463100d67f Remove a long-standing hack to keep divots out of adjacent zones.
The new algorithm unions any adjacent zones before doing the
chamfer/fillet and then subtracts the other zones back out afterwards.

Fixes https://gitlab.com/kicad/code/kicad/issues/3812
2020-08-12 22:20:08 +01:00
Seth Hillbrand 7c455f2357 First pass at DRC RTree functionality
This implements a copper-layer RTree with functions for iterating over
the elements in a copper layer and providing Nearest Neighbor returns
for BOARD_CONNECTED_ITEMS
2020-08-11 16:52:29 -07:00
Simon Richter 71882a7b0e Add <algorithm> for std::min/std::max 2020-07-31 03:29:55 +00:00
jean-pierre charras 265f28afe1 Fix a minor compil warning and a Coverity warning 2020-07-30 10:40:51 +02:00
Tomasz Wlostowski 32bd31a1b8 libs/kimath: implement BBox() and Size() methods in SHAPE_COMPOUND 2020-07-29 23:14:03 +02:00
Tomasz Wlostowski 747f2eb948 kimath: fix MTV and actual clearance calculation for SHAPE_COMPOUNDs 2020-07-29 23:14:03 +02:00
Tomasz Wlostowski 48f87dedc9 Implement collisions for SHAPE_COMPOUND 2020-07-29 23:14:03 +02:00
Tomasz Wlostowski b03044d3d1 kimath/geometry: starting with SHAPE_COMPOUND 2020-07-29 23:14:03 +02:00
Marek Roszko 9278660b10 Add support for the windows application restart api 2020-07-28 14:32:39 -04:00
Ian McInerney d5ff02ad55 Fix compiler warning - those extra brackets aren't needed 2020-07-18 23:55:27 +01:00
Seth Hillbrand 3aeb3c8f99 Fix case of 360° arc handling
A 360° arc will have the mid point on the opposite side of the circle
from both the start and end points.  This will make both slopes the
same, leading to a degeneracy in the calculation.  We address this by
noting that the center will be halfway between the midpoint and the
start point.
2020-07-18 13:03:39 -07:00
Seth Hillbrand 854e7a4928 SHAPE_POLY_SET: AddHole should return the hole idx
Returning the poly index is not useful as it does not allow the use of
other SHAPE_POLY_SET Hole* functions that expect to get the indices of
holes rather than the outline
2020-07-18 13:03:22 -07:00
Simon Richter c407e96b14 std::min/std::max requires <algorithm> 2020-07-11 15:46:57 +02:00
Jeff Young d85a707385 Move rest of DRC to SHAPE collision architecture. 2020-07-06 20:00:50 +01:00
jean-pierre charras 5d5706b8be Fix incorrect Rotate() functions for shapes circles and arcs.
VECTOR2I::Rotate( double aAngle ) returns a rotated point, but does change
the object itself.

Fixes #4810
https://gitlab.com/kicad/code/kicad/issues/4810
2020-07-06 13:50:55 +02:00
Jeff Young 5bc6389477 Comments. 2020-07-05 19:53:04 +01:00
jean-pierre charras 82da739786 Better calculations in TransformRoundChamferedRectToPolygon().
the old calculations was creating a slightly too small shape for rounded corners.

Now the polygon is outside the perfect shape (as required to create a shape with clearance)

Fixes #4805
https://gitlab.com/kicad/code/kicad/issues/4805
2020-07-05 19:32:07 +02:00
Ian McInerney b5adf5bb21 Only try to remove the implicit conversion warning if it is supported 2020-07-03 02:59:19 +01:00
Ian McInerney c27207500d Cleanup some compiler warnings 2020-07-03 00:10:31 +01:00
Jeff Young 2cfd6ba978 Fix a couple of integer overflows. 2020-07-02 22:52:37 +01:00
Jeff Young 9940931b0f Fix null dereference in DRC checking. 2020-07-02 22:23:28 +01:00
Jeff Young eb1ff80d57 SHAPE collision fixes.
1) An actual distance of 0 is still a collision, even if the allowed
distance is 0.
2) Be consitent about edges and interiors.  Everyone expect the edge
of a RECT to be part of the RECT; same with a CIRCLE.  SHAPE_POLY_SET
shouldn't be any different.  (And SHAPE_LINE_CHAIN was a split-
personality with the edge considered part of it for Collide() but not
for PointInside()).
2020-07-02 21:38:37 +01:00
Jeff Young 441dfa30f0 Return individual custom pad shapes instead of a SHAPE_POLY_SET.
Also implements an optional pointer to return the actual distance
from all the SHAPE collision routines.

Fixes https://gitlab.com/kicad/code/kicad/issues/4774
2020-07-02 17:09:15 +01:00
Jon Evans 32b7b0c617 Fix filled zone rotation and move operations 2020-06-30 22:26:30 -04:00
Jeff Young 25c5c35176 Fix compile error on Linux. 2020-06-30 19:15:11 +01:00
Jeff Young 40a72d9530 Add SH_RECT handling to 3D shape conversion.
Also add some debugging for not-implemented shape cases in other
places to catch simmilar issues in future.

Fixes https://gitlab.com/kicad/code/kicad/issues/4757
2020-06-30 18:32:31 +01:00
Jeff Young da2b7071b4 WYSISYG custom pad editor.
Fixes https://gitlab.com/kicad/code/kicad/issues/2153

Fixes https://gitlab.com/kicad/code/kicad/issues/2305
2020-06-27 14:37:01 +01: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
Jeff Young d89f8407e0 Const fixes. 2020-06-22 20:36:54 +01:00
Seth Hillbrand 08c61e6788 Ensure triangulation follows moving zone
Dragging filled zones in OpenGL was extremely slow due to the
invalidated triangulation cache.  Moving the zone should also move the
triangles and keep the cache valid.
2020-06-17 19:43:11 -07:00
Seth Hillbrand a5500973a2 Fix SHAPE_ARC hittest and adjust radius return
The hittest needs to use distance calc rather than squared distance.
This also adjusts the radius value to be double as to avoid unneeded
loss of precision
2020-06-13 11:23:21 -07:00
Seth Hillbrand a8ab668122 Move SHAPE_ARC to start->mid->end format
The arc shapes need to connect with their adjacent points.  By storing
the relevant points, we allow exact point matching on both ends of the
arc as well as localize point storage.
2020-06-13 11:23:14 -07:00
Seth Hillbrand df7b67e109 Fix missing virtual dtor 2020-06-11 11:26:55 -07:00
jean-pierre charras 64231a8491 fix a minor wxWidgets alert and a outdated comment. 2020-06-09 14:12:38 +02:00
Jeff Young 904687affb Fix typos. 2020-06-04 22:44:03 +01:00
Jeff Young 0ddf53397f Make sure CvPcb gets its Cancel button fixed up.
It's no longer a DIALOG_SHIM so it can't depend on its fixup.

Fixes https://gitlab.com/kicad/code/kicad/issues/4611
2020-06-04 22:35:01 +01:00
Ian McInerney a843c74529 Add new kiplatform library for platform-specific code
* Implement ReparentQuasiModal for OSX natively
* Implement ForceFocus of OSX natively

This change means we no longer rely on the kicad-specific functions in our osx wx fork.
2020-06-03 14:58:54 +00:00
Jeff Young 13493437d0 Add hole-inside-courtyard DRC checks.
One for NPTH and one for PTH; both default to "ignore".

Fixes https://gitlab.com/kicad/code/kicad/issues/3434
2020-05-14 22:02:47 +01:00
Jeff Young dfe4a00d43 Add distance reporting for copper item DRC tests.
Also adds some performance improvements.
2020-05-01 18:49:42 +01:00
Jeff Young a56191b658 Add distances to a bunch of DRC violation reports. 2020-05-01 18:49:42 +01:00
jean-pierre charras 25d7c0cae2 Opencascade: fix min version: OCE=0.18, OCC=6.9.0
Fix also a few minor Coverity warnings.
2020-04-16 10:22:20 +02:00
Tomasz Wlostowski 88d0092e43 libs: added POINT_INSIDE_TRACKER, a state-based class to track if a point is inside/outisde a dynamically built closed polyline 2020-04-15 13:00:48 +02:00
Tomasz Wlostowski 9b2fbae706 geometry: don't copy stuff in SHAPE_POLY_SET::GetRelativeIndices. Huge performance improvement for large polygons 2020-04-15 13:00:48 +02:00
jean-pierre charras b68bdc22d7 Fix in kicadpcb reader. Update dialog export step
kicad2step: code cleanup, and more activity messages displayed
2020-04-15 10:51:35 +02:00
Ian McInerney 37a4dd927b Allow deletion of zone cutout areas
ADDED: Ability to delete zone cutout areas

Fixes https://gitlab.com/kicad/code/kicad/issues/4188
2020-04-14 17:57:47 +01:00
jean-pierre charras 3e247a70d5 Gerber plot: new algo to generate solder mask layers with non 0 min thickness mask
Previously, all overlapping polygons (pads and min thickness areas to remove) were
merged.
Drawback: pads attributes are lost. In Gerber this is annoying.
Now the pads are plot as flashed or Regions items, and min thickness areas are added
but shapes are not merged and keep their attributes.
2020-03-28 16:32:46 +01:00
jean-pierre charras 78a7c7dfe0 Zones: fix a crash when adding a zone cutout to a zone having already holes.
Fixes #4039
https://gitlab.com/kicad/code/kicad/issues/4039
2020-03-12 14:42:32 +01:00
Wayne Stambaugh bc7df3239c Start unit tests for math library trigonometry functions.
This only tests the InterceptsPositiveX() and InterceptsNegativeX() used
for finding the midpoint of an arc.

Tidy up some of the trigo.h header Doxygen comments.
2020-03-05 07:34:26 -05:00
Wayne Stambaugh 9d6f64da9a Implement symbol library s-expression parser.
This implements all existing symbol library object support and the ability
to save and load symbol library files between file formats for round robin
testing.
2020-03-03 08:06:23 -05:00
Tomasz Wlostowski b7aea6f14c kimath: fix warning 2020-02-28 23:17:15 +01:00
Seth Hillbrand 797ff00367 Cleanup header
Missing function causes issues in Python now that the routine is gone.
2020-02-27 14:25:43 -08:00
Tomasz Wlostowski a42b86d3ac geometry: missing return in SEG::Contains() 2020-02-27 22:02:56 +01:00
Tomasz Wlostowski f8f21ea81c geometry: SHAPE_LINE_CHAIN::Intersect should report each unique intersection only once 2020-02-27 22:02:56 +01:00
Tomasz Wlostowski 7b8fe9c1af geometry: allow constructing SHAPE_LINE_CHAINs from a flat vector of ints 2020-02-27 22:02:56 +01:00
Tomasz Wlostowski fa04174ecf geometry: Contains(SEG) method in SEG 2020-02-27 22:02:56 +01: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
Seth Hillbrand c52b3ce0e4 SHAPE_LINE_CHAIN: Add ability to insert arcs
Creates new substructure for arc management.  Existing functions provide
wrapper to use SHAPE_LINE_CHAIN as normal, without arcs while also
permitting the addition of arcs into the chain
2020-02-21 23:51:58 +00:00
jean-pierre charras 0ae3d0216a Fix a compil warning 2020-02-16 09:47:33 +01:00
Ian McInerney a0698723b9 Auto-rotate sheet pins onto the top and bottom when moving
Fixes https://gitlab.com/kicad/code/kicad/issues/2178
2020-02-15 18:45:10 +00:00
jean-pierre charras 48ae188b15 Zone filler: fix a few issues, in Smoothed Polygons mode.
- Fix non optimal shape of solid polygons after inflate transform.
- Add a small extra clearance ((2 microns) when creating clearance areas
(especially, convert arc to polygons create small differences)
- Add a small threshold (1 micron) in drc test distances to avoid false positives
- fix a minor issue in TransformOvalToPolygon that created sometimes a not perfect shape

Fixes #3812
https://gitlab.com/kicad/code/kicad/issues/3812
2020-01-26 18:19:24 +01:00
Seth Hillbrand c4fff95078 PNS: Detect collisions including newline width
The new line collision search uses BBox() to check for colliding
objects.  BBox in the SHAPE_LINE_CHAIN did not include width as the
chains were assumed to be zero-width.  This is not the case for
PNS::LINE elements.

We mostly don't notice this because DRC checks for SEGMENT collisions
but it becomes obvious/annoying when we cannot place a track for unknown
reasons and the snap-back doesn't take line width into account.

Fixes #3776 | https://gitlab.com/kicad/code/kicad/issues/3776
2020-01-17 11:23:08 -08:00
Jeff Young 45ca0a5ab8 Avoid divide-by-zero. 2020-01-15 18:50:47 +00:00
Ian McInerney 6e8f06e042 Fixup some issues in libkimath
* Perform floating-point computations when needed
* Specify to use the default equality operator
2020-01-11 21:27:38 +00:00
Seth Hillbrand 7c28c3838a Comment-only changes
Makes class comments conform to coding standards
2020-01-10 16:43:01 -08:00
Ian McInerney 9e5d52f92d Cleanup 2020-01-08 01:49:51 +00:00
Ian McInerney ffa30d75a3 Replace round_nearest with KiROUND 2020-01-07 23:27:29 +00:00
Ian McInerney 13b6028e1b Refactor all math into a new kimath library
* Split up the thirdparty code into the thirdparty folder (#3637)
* Create a new kimath static library containing all the math functions

This is part of cleaning the build system for #1906.
2020-01-07 17:12:59 +00:00
Seth Hillbrand 4d2e953f42 Cleanup: Replace C-only deprecated headers
This replaces headers deprecated by C++14 with their equivalent
replacement
2019-12-05 11:03:15 -08:00
Jeff Young b5904b0401 Installment one of project Save As... feature.
ADD: Adds Save As... to the File menu for the project window.

Fixes: lp:594051
* https://bugs.launchpad.net/kicad/+bug/594051
2019-11-09 20:22:44 +00:00
Seth Hillbrand 5151cd0bfe C++14: Remove unused make_unique.h
Also removes header references now that we are in C++14, this is
built-in to the std
2019-08-07 09:27:31 -07:00
John Beard a045642b7e Sexpr: Do not leak memory on parse exception
Use std::unique_ptr to guard against leaking the new'd pointers
in SEXPR lists if there is an exception during parse.

This was noticable during the Sexpr/ParseExceptions unit test.

Fixes: lp:1830209
* https://bugs.launchpad.net/kicad/+bug/1830209
2019-05-23 13:52:39 +01:00
John Beard f7d35cf94b Sexpr: needs to be a STATIC lib
Fedora COPR builds with -DBUILD_SHARED_LIBS:BOOL=ON, which
means this breaks until the sexpr lib target is explicitly
STATIC
2019-04-24 17:31:22 +01:00
John Beard 03214b5dea Sexpr/QA: Split out the sexpr classes into a reusable lib and test
The SEXPR class is a useful general-purpose S-Expression library
class and can (maybe) be used else where. It also should get
test coverage, as even if noone else uses it, it's critical for the
kicad2step exporter.

Also add some test coverage for some kicad2step routines. For now,
they're not useful outside kicad2step, but they are at least a useful
reference for S-Expression parsing.
2019-04-17 10:52:56 +01:00