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

907 Commits

Author SHA1 Message Date
Ian McInerney
2ddcc7a7ad Add error handling to posix function call 2024-12-31 00:18:10 +00:00
Seth Hillbrand
8724a7da09 Treat straight arcs as segments
When an arc has a very small curvature, we should not waste time with
the arc collision mode and instead just use the segment collision as it
is effectively the same result

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19422
2024-12-30 12:57:21 -08:00
Jon Evans
ca68ac0076 kinng: use longer lifetime for incoming message string 2024-12-30 09:32:11 -05:00
jean-pierre charras
f8ae28578f SHAPE_LINE_CHAIN() ctor: ensure arc info exists before trying to add it
Fixes https://gitlab.com/kicad/code/kicad/-/issues/19419
2024-12-30 11:47:30 +01:00
Marek Roszko
0e1b47427c Add a windows specific hack to make backups work past max length
Since backups are most likely to encounter max path limitations compared to other things we do in kicad
2024-12-29 19:54:11 -05:00
Marek Roszko
41d7711f06 Add a function to create long paths on windows 2024-12-29 18:21:49 -05:00
Seth Hillbrand
e9bc8cfe9d Give Clipper1 a Viking funeral
Clears out the last spot where we were only using Clipper1 (how'd I
miss that?) and remove all calls to the Clipper1 structures
2024-12-23 17:12:09 -08:00
John Beard
e2136db5c2 Fabmaster: handle squares, oblongs, and regular polygons.
Fabmaster supports at least triangles, hexagons x and y, octagons
and diamonds.
2024-12-03 20:08:12 +08:00
John Beard
926ef7677b Fabmaster: never add null holes to polygons
By adding points to holes as we go, we leave ourselves open
to adding invalid (<3 point) holes to the polygons. This causes
crashes if it happens, so we should never allow it to happen.

Instead of building holes in-place, construct them externally
and only add them if they are valid.

This probably wouldn't actually happen for a valid Fabmaster
file, but if it did, it would be bad new, and we shouldn't leave
crashable pathways facing user input.
2024-12-03 20:08:12 +08:00
jean-pierre charras
d3bcc81d5d libkimath: fix a link issue on mingw/msys2 build.
Remove option "use Clipper1" (now outdated) on all platforms.
Use of advanced config created the issue, so it is just disabled on msys2.
Should not change anything on other platforms.
2024-12-01 09:38:49 +01:00
Marek Roszko
904e0cd87e Silence build warning about int to double cast 2024-11-29 10:55:21 -05:00
John Beard
df933df416 Multichannel: split out some geometric routines
Putting them somewhere in the geom utils means they
can be reused, and also tested if needed.
2024-11-08 19:48:03 +08:00
Seth Hillbrand
7916b1ddb8 Fix error in PointInside
If we are checking a point that is inline with multiple segments, we
were counting both the entry and exit as crossings, leading to points
inside a polygon being registered as outside.  Changing the conditional
to only catch one crossing as required.

Adds a QA check to ensure that this remains fixed

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18377
2024-11-07 09:09:00 -08:00
Jon Evans
420ea9da9d Add some logging to KINNG 2024-11-05 18:38:27 -05:00
Jon Evans
d0b2334ceb PNS: Support via stacks 2024-11-04 21:30:38 -05:00
Tomasz Wlostowski
f7e37bf9f2 kimath: bring back the legacy SHAPE_LINE_CHAIN::Simplify() function
It looks like the new variant (with aMaxError) behaves in a subtly different way, resulting in router hiccups.

This needs more in-depth investigation, but for the moment, the older function does the job.
2024-11-02 19:59:09 +01:00
Andrej Valek
20ee4effdc ReparentModal: fix case when parent is not available
In some situations then parent window couldn't be available. Eg, when
eeschema is executed as standalone on macOS and trying to show
the global design block table dialog before the main frame exists.
So replace the assert with return and check the windows pointers bellow.
2024-10-31 14:42:53 +01:00
Armin Schoisswohl
f1abdfa1aa Modify Circle approximate segment count
Change number of segments of circles to be multiples of 8 and start rotated by delta/2.  This ensures that segments will be aligned to a 45°/90° grid

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18654
2024-10-28 20:40:05 +00:00
Andrej Valek
3ad92bc8db ShowModal: override method in DIALOG_SHIM
All DIALOG_SHIM dialogues which should be modal, has a problem on OSX
that parent could be lost. So call ReparentModal to fix this before
calling the base ShowModal method. This should fix the problem when
modal window has been hidden when windows were switched.

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

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/17460
2024-10-27 16:37:47 +00:00
Seth Hillbrand
8dda9b37fa Change zorder to use unsigned
Edge cases can happen where point + clearance is larger than the bbox.
This can cause the zOrder min and max to get switched as max get a high
bit and is negative.  Clamping to limit the input values and using
uint32 for the output solves the corner case
2024-10-24 17:40:25 -07:00
Seth Hillbrand
64ff47c594 Handle edge cases in kissing zones
When zone kisses happen from different polygons, we need to be careful
not to use the different polygons for ear comparisons or prev/next
pointers

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18654
2024-10-24 17:40:25 -07:00
John Beard
201b60c670 Point editor single-corner chamfer tool
Come up with a plausible default chamfer size, rather
than prompting every time with a modal (and then you have
to handle when the chanfer doesn't fit). This could be
changed if it's more annoying this way. But if we had
proper edge-dragging in zones, probably would be better
than setting a chanfer manually.

Also fix the GetNeighbourIndexes which seems to have
always been broken (but is not actually used by anything at
present).

Relates-To: https://gitlab.com/kicad/code/kicad/-/issues/16771
2024-10-13 11:10:49 +08:00
John Beard
4bad76825c Standardise clamp function
std::clamp and alg:clamp had different argument orders.
Since std::clamp is constexpr, we might as well just use
that now we have it.
2024-10-09 21:27:58 -06:00
John Beard
58669f2b9f BOX2: Correct a clamp
std::clamp is (v, min, max), but alg::clamp is (min, v, max).

I can't quite get my head round why this only causes test failures
on some platforms.
2024-10-09 11:42:16 +08:00
John Beard
55370e7520 QA: BOOST_CHECK to _TEST in some KiMath tests
This tells you the arguments when it fails.

BOOST_TEST is available in all our Boost.Test version.
Even if you didn't use it, these calls should have been
BOOST_TEST_EQUAL(A, B) which also tells you the
arguments on a test failure.
2024-10-09 11:42:16 +08:00
John Beard
91dca89116 Eeschema: Add indicator icons for pins with alt modes
This makes it easier to see which pins have alt modes
available. There is an option to turn them off.

The icon positions are chosen so they they shouldn't
interfere as far as possible:

* If the text is inside, the icon goes more inside
  the body
* If the text is above/below the pin, it goes away from
  the body

This means it won't collide with a symbol wall in
most cases, but some symbols with alt pins on opposing
sides may need to be widened if the icons are show.

Includes a rather fiddly refactor of the SCH_PIN painter
function, which needs quite a lot of massaging to allow
it to figure out where an icon would go. Quite a bit
of logic is broken out into smaller encapsulations with
less visible state to each chunk.

Icon modes for base-name-selected and alt-selected are
included, but only the former works due to information
being thrown away during the SCH_PAINTER tempPin
process.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/11069
2024-10-08 23:30:50 +08:00
John Beard
a4cbd0adb4 Sym edit: allow to drag pins with edges
Only applies when dragging an edge by the midpoint handle,
and only in the symbol editor if configured to do so.
2024-10-01 18:06:26 +01:00
John Beard
3f131e2011 Abstract REFERENCE_IMAGE to a separate class
Break the non-PCB-specfic parts of PCB_REFERENCE_IMAGE out
to a common REFERENCE_IMAGE class, which is then composed into
the PCB_REFERENCE_IMAGE. This will make it easier to bring the
transform origin logic to eeschema without repetition.
2024-09-30 10:20:20 +01:00
John Beard
889e24988b Reference image: avoid overflow on large scales
This has always been possible (especially through the properties
panel with large scales), but it's even easier if the transform
origin is near a manipulated corner.

Check and reject scales that result in an overflowed image box.
2024-09-28 13:24:26 +01:00
John Beard
215533f31a Unify flip direction handling
There was a gentle mish-mash of booleans, some with
true being left/right and some up/down, and some functions that
can flip in both axes (which is never actually done, and doesn't
really make geometric sense).

Replace all this with the FLIP_DIRECTION enum class, which makes
the intention completely unambiguous.

This also then allows a small scattering of simplifications,
because everything takes the same type and you don't have to
fiddle booleans to fit.
2024-09-27 17:13:13 +01:00
John Beard
4e2162fc97 Bezier: add the function to get point at t
Not of huge practical use on its own, but other maths will
need this.
2024-09-27 17:13:13 +01:00
John Beard
e2370c6e45 BEZIER: Avoid some copying in the ctor 2024-09-25 22:17:33 +01:00
John Beard
aea42a5cdf Pcbnew: handle connected copper circle points
Fixes: https://gitlab.com/kicad/code/kicad/-/issues/18774
2024-09-25 12:28:43 +01:00
John Beard
95beedb612 Dogbones: add slots for acute angles
It's actually not as hard as I thought, though
surely has wierd edge cases which users might need to
handle manually.
2024-09-22 13:45:19 +01:00
John Beard
a5e6f70122 Dogbone: handle small mouths even better
Including floating point roundoff, which can bite
for rectangles.
2024-09-20 10:57:07 +01:00
John Beard
671ecdf13c Dogbone: correct small mouth warning
It has to fit the cutter diameter, not the radius!

Also you can use SHAPE_ARC as a generic arc object.
2024-09-20 10:37:29 +01:00
John Beard
8fdb6d6e88 Feature: Exact item offset tool
This is a little bit like the bounding hull tool, but the
output is "exact" and it only supports the most common
source items.

By 'exact', this means that rounded corners are real arc
segments rather than polygonal approximations. Obviously,
this is rather tricky in the general case, and especially
for any concave shape or anything with a bezier in it.

Envisioned main uses:

* Creating courtyard and silkscreen offsets in footprints
* Making slots around line or arcs.

The one thing that it does not currently do, but which it might
plausibly do without reimplementing Clipper is convex polygons,
which would bring trapezoidal pad outsets for free. But that
is a stretch goal, and bounding hull can be used.
2024-09-19 06:35:43 +01:00
John Beard
1d2fb3ec82 Geom: add a simple OVAL type
Makes it easier to reason about oval shapes in geometric terms.

For now, this isn't a SHAPE, but it could be (and it's a
fairly common primitive, so it could be useful, though the
obvious use (clearance) is equivalent to a SEG with a clearance,
which is already a function that exists.
2024-09-19 06:35:43 +01:00
John Beard
99e1869987 Fix build: use same signature for alg::lexicographical_compare_three_way as std::
This makes it clearer that it is a polyfill-type affair
and make it easier to swap for the std:: one when the
compiler support is guaranteed.

Also avoid double underscores in parameter names,
as well as underscore-capital latter as they are reserved.
2024-09-18 06:56:03 +01:00
John Beard
f6a693475f BOX2: Add a KiROUND specialisation for BOX2D -> BOX2I 2024-09-11 22:35:35 +01:00
John Beard
5e9aba5555 Remove commented-out VECTOR2 dtor
It's been commented out for 11 years, so take the
opportunity while the header is being touched.
2024-09-11 22:35:35 +01:00
John Beard
49b8a5ce74 VECTOR2, BOX2: Add constexpr to many functions
In the core geometric types, this can provide some
useful optimisation opportunites.

As most trig functions and std::sqrt aren't constexpr
until C++26, anything that involves a vector length
can't be constexpr yet. But std::clamp and, importantly,
KiROUND are, which does allow quite a bit. And squared
sizes do work, as they are just multiplies, so size
comparisons work too.

The floating point equals-with-epsilon function can't
be directly made constexpr until C++23 (unless std::abs
is replaced with manual code, but that may then forgo
the use of intrinsics at runtime). And they're probably
not important to have at compile-time.

Add a few tests with static_asserts to show/prove that
some non-trivial operations can be done at compile time,
for example BOX2 merging.
2024-09-11 22:35:35 +01:00
John Beard
f4eb173c43 BOX2: By-value GetInflated method
This allows better value-semantics and const correctness.

This is a common method, as the Inflate method is
in-place:

  BOX2I inflated = other;
  // 'Inflated' is not inflated yet
  inflated.Inflate( delta );
  // Now it is inflated, but it's not const

This is annoying, as the 'inflated' box cannot easily
be made const. Instead:

  const BOX2I inflated = other.GetInflated( delta );
2024-09-11 22:35:35 +01:00
John Beard
7fe5caffa6 BOX2: Fix Inflate parameter type
If this is just 'int', BOX2D will not Inflate
as you might expect if given an non-integer parameter,
but will instead do a conversion.

Use coord_type, like the two-parameter Inflate method.

Add a test for this.
2024-09-11 22:35:35 +01:00
John Beard
b2be0d39bd Snapping: Add construction geometry snapping
This is a pretty major rework of the snapping system.
The GRID_HELPERs now have a separate CONSTRUCTION_MANAGER
which handles some of the state involving "construction
geometry".

This is fed with 'extended' geometry (e.g. "infinite" lines from
segments) for use in generating things like intersection points.
It also handles adding this geoemtry to a GAL view item
(CONSTRUCTION_GEOM) for display to the user.

The process is:

* A TOOL creates a GRID_HELPER
* Optionally, it pre-loads a "persistent" batch of construction
  geometry (e.g. for an item's original position)
* The grid helper finds useful snap 'anchors' as before, including
  those involving the construction items.
* Other items on the board can be 'activated' by snapping to one
  of their main points. Then, if it has construction geometry,
  it will be added to the display. At most 2 items of this kind of
  geometry are shown, plus the original item, to reduce avoid
  too much clutter.

The dashed snap lines state machine is also handled in the
CONSTRUCTION_MANAGER and displayed in the CONSTRUCTION_GEOM item.
2024-09-11 22:35:35 +01:00
John Beard
72e48aed52 Trigo: Add a GetRotated function to get a rotated VECTOR2I
This makes it easier to use value semantics and consts when
constructing geometry.
2024-09-11 22:08:36 +01:00
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