138 Commits

Author SHA1 Message Date
John Beard
1e587b15ae Pcbnew: point editor: use a behavior class for textboxes
Saving the best for last - the one that wound me up enough to
start this process - textboxes, which sometimes, but not always
behave like rectangles.

Rather than some exciting multiple inheritance of
RECTANGLE_POINT_EDIT_BEHAVIOR and a hypothetical rotated
rectangle behavior, delegate the rectangular behavior to
static helpers in the rectangle one.

They still can't be edited when rotated, but at least now there
is some hope that it's tractable!
2024-11-03 06:00:39 +08:00
John Beard
c66caf3e11 Pcbnew: point editor: move dimensions to a behavior class
Especially the aligned dims are fiddly, but all the
dimensions need the array size to be carefully kept
controlled, which is now part of the invariant of
each behavior.
2024-11-03 06:00:39 +08:00
John Beard
90e49a42e7 Pcbnew: point editor: use behavior class for generators
This also changes the interface on the GENERATOR classes
to no longer take a shared_ptr - these methods are synchronous
and don't store (shared) ownership of the EDIT_POINTs.
2024-11-03 06:00:39 +08:00
John Beard
d12ad6820b Pcbnew: point editor: move pads to a behavior class
Hopefully, this will make the extra logic for padstacks
more localised, rather than splitting it up throughout
PCB_POINT_EDITOR.
2024-11-03 06:00:39 +08:00
John Beard
dd7d90089d Pcbnew: point editor: zones use a behavior class
Mostly defers to the same logic as for polygons.
2024-11-03 06:00:39 +08:00
John Beard
268d7854e0 Pcbnew: point editor: tablecells use a behavior class 2024-11-03 06:00:39 +08:00
John Beard
736c955a21 Pcbnew: point editor: move reference image to a behavior class
This is a fiddly one that is good to encapsulate.
2024-11-03 06:00:39 +08:00
John Beard
5a6af05759 Pcbnew: point editor: move bezier to a behavior 2024-11-03 06:00:39 +08:00
John Beard
97e59b773f Pcbnew: point editor: move polygons to a behaviour class
There's a slight flicker when a polygon is edited, but
that was there before.
2024-11-03 06:00:39 +08:00
John Beard
4f840599b5 Pcbnew: point editor: use behavior for circles
This is a pretty straightforward one
(though there was a latent bug here because both CIRCLE
and ARC used CIRC_CENTER for the constrainer. If an ARC
and CIRCLE center were not the same index (and nothing says they
have to be) that could be wrong or crash.
2024-11-03 06:00:39 +08:00
John Beard
f1f011e49d Pcbnew: point editor: move arcs to a behaviour class
This is a good example of an edit behaviour that had a lot
of code in PCB_POINT_EDITOR that was only used for a single
item type. Many of these (now static) functions will probably
find use in other places arcs crop up like filleted shapes
and also in eeschema.

But for now, keep it simpler and keep them near where they
are used.
2024-11-03 06:00:39 +08:00
John Beard
57100c9352 Pcbnew: point editor: use a behavior class for rectangles 2024-11-03 06:00:39 +08:00
John Beard
5071541f4b Pcbnew: rework point editor behavior handling
This introduces the POINT_EDITOR_BEHAVIOR class, which
allows a "behavior" to be defined, which covers the creation
of edit points, updating the points on edit, and pushing the
edited points back into the object.

This keeps the logic for a single item "type" (e.g. a SEGMENT
or TEXTBOX, etc) in one place, rather than fragmneted throughout
the POINT_EDITOR class, where the invariants like point count
are difficult to keep track of as the TOOL progresses.

For now, it's implemented as an optional class, just for SEGMENT
and other tpyes work as before. Adding new types is then a
"pin-compatible" drop-in process.
2024-11-03 06:00:39 +08:00
John Beard
88e028bc24 Pcbnew: fix textbox point editing
When in rectangle mode, it still needs to act like a rectangle, but
it doesn't go through the usual PCB_SHAPE handler (even though it is
a PCB_SHAPE too).
2024-11-02 20:21:53 +08:00
John Beard
0278c13018 Point editors: allow moving rectangles by center 2024-10-26 16:30:22 +08: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
Jon Evans
56e0811516 Phase 2 of padstack support
CHANGED: PCB file format now supports saving/loading complex padstacks

CHANGED: PTH pads are now rendered per copper layer in the copper color;
         the PTH pad color is no longer used.

ADDED: support for importing complex pad stacks from Altium PCBs

Enforce padstack-aware access to pad properties across KiCad

Fixes https://gitlab.com/kicad/code/kicad/-/issues/8182
2024-10-01 19:55:03 -04: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
5305953de8 Pcbnew: Allow create corner/split on arcs 2024-09-28 13:27:38 +01:00
John Beard
7ba772bc4c Pad.h doesn't need geometry_utils.h
Saves 200+ files from a rebuild if you touch it.
2024-09-28 13:24:26 +01:00
John Beard
114e86a7ed Reference image: also account for origin via prop mgr
When scaling via the properties panel, also keep the
transform origin fixed in the same way as when
drag-editing.
2024-09-27 23:05:45 +01:00
John Beard
ebfe9df8f9 Reference image: add a transform origin
This is stored as an offset from the image position,
which is the centre of the image.  When interactively edited, the
transform origin stays in place. This makes it easier to scale an image
around some fixed feature in the image.

For now this is not saved out to the format, so it
reinitialises to (0, 0) each time. This means scale around
the midpoint, which is the current behaviour.
2024-09-27 17:14:08 +01:00
John Beard
30e51f7d1a Pcbnew: Show some helper lines in point editor
Some shapes, like arcs and beziers have "lines" that
can be useful to see when editing, but aren't directly
editable and may not overlap the object's own lines.

So make it possible to, indepedently:

 - Turn off the centre-point drag handle affordance
 - Show the actual line segment on screen.
2024-09-26 10:17:23 +01:00
Jon Evans
1895ec58a0 Fix various compile warnings 2024-09-18 18:51:02 -04: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
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
45bc23a8a5 Pcbnew: keep dimension text aligned when dragging points
This is quite fiddly to do in a way that doesn't have wierd
effects, and is shared between ALIGNED and ORTHOGONAL dimensions,
so break it out to a little helper class that handles the
stored state and fiddling with the geometry.
2024-09-06 20:33:08 +01:00
Jeff Young
e6a5669d02 Use ORIGIN_TRANSFORMS in Mover Corner To... dialog.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/18479
2024-08-18 13:01:38 -06:00
Jeff Young
0682987eb9 Cleanup atrophied code. 2024-07-08 14:27:25 +01: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
e8c96a8a20 Fixups for a9ae86ee
Correcting a couple mistakes and clarifying rounding
2024-05-31 17:31:50 -07:00
Seth Hillbrand
a9ae86eefd Cleanup geometry functions
Added Distance(VECTOR2) function that returns a double.  Removed
superfluous EuclideanNorm, GetLineLength, integer constructor for
EDA_ANGLE (this promotes to double in the CTOR), DistanceLinePoint and
HitTestPoints

Also extended the size for arc calculations that get distances to center
points to avoid overflow
2024-05-31 12:26:37 -07:00
Jeff Young
d761b4f22f RIP LIB_TEXTBOX and LIB_SHAPE. 2024-04-16 16:31:16 +01:00
Jeff Young
e445249720 ADDED: PCB tables. 2024-02-24 20:05:51 +00:00
Alex
3eb3fc9d1e Fix PCB arc edit point order. 2024-01-18 13:51:32 +03:00
Jeff Young
455fae45d8 Support point editing of inverted rectangles.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/16595
2024-01-17 15:27:48 +00:00
Alex Shvartzkop
f99505e190 Fix arc editing bugs when endpoints match.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/16532
2024-01-16 16:17:45 +03:00
Jeff Young
2661e7a8ee Fix over-zealous copy/paste and add a few more comments. 2023-12-06 13:08:22 +00:00
Jeff Young
b13590f4c0 Use preview items instead of highlightNets & status popup
The router preview item can be specific to the part that is being
tuned, rather than the whole net.  It's also less visually noisy as
it doesn't dim/undim the rest of the board.

Using kigfx preview items for the status keeps us from having a bunch
of focus issues with the status popup window.
2023-12-02 16:15:43 +00:00
Jeff Young
791aa64950 Functionally it's a "reference image".
The implementation happens to be a "bitmap".

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15932
2023-10-24 15:44:21 +01:00
Jeff Young
ad676e22b8 Don't push a commit we don't own. 2023-10-22 20:35:14 +01:00
Jeff Young
16ec0faa7a Reduce line-breaking.
Also simplifies handling of generator properties dialogs.
2023-10-19 11:19:57 +01:00
Jeff Young
89011e888c More modern look & feel for tuning status popup.
(Also includes min and max info, and move string processing out
of router.)
2023-10-17 13:30:58 +01:00
Jeff Young
390bd44f18 Cleanup. 2023-10-17 13:30:58 +01:00
Jeff Young
d916e650f1 Tuning status popup for point editor. 2023-10-10 11:55:57 +01:00
Alex Shvartzkop
be72e07e61 Introduce PCB_GENERATOR. 2023-10-08 02:41:17 +00:00
Alex Shvartzkop
280fe976c4 Add a re-entrancy guard to PCB_POINT_EDITOR. 2023-10-07 03:51:52 +03:00
Marek Roszko
22b733209d Fail GAL on its header leaking audit
Maybe we should rethink directly accessing GAL so much, but at least 600 files didn't need GAL leaked into them due to view_overlay.h
2023-09-18 19:52:27 -04:00
Jeff Young
d6b75c64e1 ADDED: custom-shaped pad spoke templates. 2023-09-13 23:34:25 +01:00