489 Commits

Author SHA1 Message Date
Wayne Stambaugh
73f31d2d80 Add test for ordinal schematic sheet paths. 2024-10-10 16:09:34 -04:00
John Beard
6ef078e9d8 QA: Provide a common implementation of wxAssertThrower
Saves all the unit test modules having to copy-paste the
(simple) function.
2024-10-10 09:28:29 +08:00
JamesJCode
98da64dce7 Fix multichannel QA 2024-10-10 02:25:29 +01:00
JamesJCode
a13bf1a8a6 Temporarily disable multichannel QA while updating file format 2024-10-10 02:12:55 +01: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
3d6d8b9946 Strip richio.h from headers that don't need them
Like the DSNLEXER header, this has visibility in over 700
files, whereas well under half actually use any of it
(quite a bit, but not all, of it actually via DSNLEXER)

Many places already forward-declare the OUTPUTFORMATTER type,
by doing that for the others, it still possible to use the
non-IO methods without having to see richio.h.
2024-10-04 18:06:18 +01: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
JamesJCode
d64a112971 Implement Component Classes
- Adds Component Class field to SCH_DIRECTIVE_LABEL
- Adds SCH_SYMBOLs to SCH_RULE_AREA item lists
- SCH_SYMBOLs resolve Component Class directives
- Netlist exporter / importer handles Component Class names
- Adds DRC expressions and functions
- Adds QA check for component class netlist export
2024-10-01 22:36:18 +01:00
Marek Roszko
d74caace0a Initial jobset creation and running within the CLI and GUI.
Incomplete, just pushing this before feature freeze, much fixing left
2024-09-30 20:04:53 -04:00
John Beard
76c328db84 SCH_PIN: Fix missing alt assign in copy ctor 2024-09-30 16:22:43 +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
Wayne Stambaugh
b9f11971ad Add test to determine if schematic is a complex hierarchy.
This test was added to the SCHEMATIC object along with QA tests to verify
the test works as expected.
2024-09-28 09:21:20 -04: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
Wayne Stambaugh
d8f71e6754 Add missing QA test source file. 2024-09-27 13:26:53 -04:00
Wayne Stambaugh
be72f22f54 Add check for schematic files shared by multiple projects.
This test was added to the SCHEMATIC object along with QA tests to verify
the test works as expected.
2024-09-27 13:09:50 -04: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
9eeab7a7a2 Dogbone: add test change missed in commit 2024-09-23 10:35:09 +01:00
John Beard
5ddbfd6fcd Dogbone: update tests
Need to use bigger numbers to avoid excessive rounding issues.
2024-09-20 11:27:19 +01:00
John Beard
a08a78a285 IBIS: Fix broken polarity parsing
A copy-paste-o meant that this wasn't working and
was also trashing the enable variable.

Add a test that loads an IBS file in the QA directory
that demonstrates this is fixed.
2024-09-19 06:35:43 +01:00
John Beard
2a158c192e IBIS: Avoid assigning an uninitialised variable
This would be OK if m_reporter were overwritten in the
derived ctor after being filled with junk in the base
ctor. But this is not always true - the null ctor doesn't
do it. So it can stick about and fool the null check.

Rather than just doing that, push the reponsibility for
maintaining the m_reporter invariant contract (if it isn't null,
you may use it) to the base class ctor.

And get rid of the shadowing m_reporter in KIBIS.
2024-09-19 06:35:43 +01:00
John Beard
a8f4dfd47d SYMBOL_BUFFER: Enforce non-null returns
SYMBOL_BUFFER GetSymbol and GetOriginal cannot return null,
as the SYMBOL_BUFFER class internally ensures that the
original and current symbol pointers are always filled
through checks in the ctor and setters.

This means that clients don't need to null-check the returns,
which is good because they mostly already do not.

Return references instead, to formalise the non-nullity of
these pointers and absolve the calling code of having to
consider if they might be null.
2024-09-19 06:35:43 +01:00
John Beard
06eab304e5 SYMBOL_LIBRARY_MANAGER: Formalise ownership when creating SYMBOL_BUFFERs
Previously, SYMBOL_BUFFER took plain pointers and took ownership
of it (plus the ownership of an internal new'd pointer).
Use unique_ptr to express this relationship more clearly and
safely.

Add a non-null assert in SYMBOL_BUFFER's ctor.

Use more restricted-scope variables in a couple of places where
a re-used variable was not required.

There are still memory-leak opportunities in here, for example
SaveBuffer new's things and can return without handing them over
or deleting.
2024-09-19 06:35:43 +01:00
John Beard
49a0318fe5 SYMBOL_LIBRARY_MANAGER: Clarify UpdateBuffer ownership
Again, this doesn't retain part-ownership of the pointer
and null is a wxCHECK failure. So hoist the null check
and then handle it as a ref (=non null, caller owns).

Also fixes a trivial mem leak in test_symbol_library_manager.cpp.
2024-09-19 06:35:43 +01:00
John Beard
a756b058ae SYMBOL_LIBRARY_MANAGER: Clarify ownership semantics
DeleteBuffer took a std::shared_ptr by value. This means
it claims to take (and keep) part-ownership of the pointed-to
item. However, this function does not take any ownership or
change the item, it just refers to it. It also does not null-check
the pointer. So it should be a const reference to the item.
Ownership semantics are then: the caller retains ownership
while the function executes.

(It also saves a shared_ptr ref count, but that won't be
important here).
2024-09-19 06:35:43 +01:00
John Beard
653d85f9fc Abstract LIB_TABLE IO to allow non-file-based tables
Mostly intended right now for allowing testing of library tables
to help with testing chained loading, but it also decouples the
idea of a library table from on-disk files in general.

All current (real) lib table implementations continue to use the
file-based IO.

This could be made more general (not just for tables) if really
needed.
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
Seth Hillbrand
977d9e4e72 Fix compile issue on Clang/Linux
Overloaded operator couldn't figure out if it wanted to check 32 or 64
bit ints
2024-09-12 15:10:29 -07:00
jean-pierre charras
c0c8ce087c Fix a QA test after the issue fixed by commit c8279dd4. 2024-09-12 20:45:17 +02: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
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
f47d9edf2e KIID: add test that the hashes do change 2024-09-08 22:42:30 +01:00
Seth Hillbrand
5e0abadb23 Reorganize layer numbering
F_Cu = 0
B_Cu = 2
Remaining internal copper layers are even and incrementing

Non-copper layers are odd and incrementing.

This means that we can no longer do things like:
for( PCB_LAYER_ID layer = F_Cu; layer <= B_Cu; ++layer)
Instead, we have the class LAYER_RANGE:
for( PCB_LAYER_ID layer : LAYER_RANGE( F_Cu, B_Cu) )

Similarly, gt/lt tests should not refer to the integer value of the
layer.  We have functions such as IsCopperLayer to test whether a layer
is copper or not.

When using the connectivity RTree, the third dimension is layer, so we
provide B_Cu with the special INT_MAX value, ensuring that elements
between F_Cu and B_Cu will be identified.  There is a new, special
function GetBoardLayer() for interfacing with CN_ITEMS

Similarly, PNS layers remain unchanged and sequential.  A set of
interface functions is provided to map PNS layers to Board layers and
back.  This allows the PNS_LAYER_RANGE to function as expected
2024-09-06 23:07:58 +00:00
John Beard
78cb6c1189 SEG: Correct sign in LineDistance 2024-09-06 19:26:58 +01:00
Seth Hillbrand
5ba50c26a9 Update embedded files hash to use Murmur3
SHA256 is fine for one-offs but for large libraries where we might be
running the hash on hundreds of files, the speed difference is
appreciable.  We don't require crytographic hashing, just a check that
the original file hasn't been corrupted so Murmur3 satisfies our basic
requirement.
2024-09-06 09:57:23 -07:00
Jeff Young
43177b7554 More test debug output. 2024-09-05 13:24:55 +01:00
Seth Hillbrand
3e5ca2ee7a Modify SHAPE_LINE_CHAIN::Simplify() to fix PNS
Issue raised by TomW, points included in new QA test where Simplify was
not properly removing colinear points.

Also removed TestSegmentHitFast() as the speed gains were minimal when
testing against the revised SEG::SquaredDistance routine in
TestSegmentHit()
2024-09-03 17:23:07 -07:00
Jeff Young
33efd9e0ef Revert single parsing because we use different parsers
for different model types.

Alos fix AKO & SUBCKT model handling, which can't be done
in parallel because they refer to other models.
2024-09-01 10:56:05 +01:00
Jeff Young
1959bacf08 Performance.
Don't parse PEGTL twice, once for modelType and once for
model itself.

Also don't do O(n^2) searches on parameter names when
reading libraries.

And, because it's still too slow, multi-thread it.
2024-08-31 18:51:28 +01:00
Seth Hillbrand
86c0aec468 Move zone connection filler out of AC
New algorithm to prevent zone fills that are smaller than the minimum
copper width.
2024-08-28 09:04:51 -07:00
John Beard
6167be1e98 QA: Remove duplicate function that exists in qa_utils 2024-08-28 13:49:36 +01:00
John Beard
1fb2d7fe26 Pcbnew: Snap to graphic/track intersections
Relates-To: https://gitlab.com/kicad/code/kicad/-/issues/2329
2024-08-28 13:49:36 +01:00
John Beard
0818ee1770 Pcbnew/FPedit: Add snap anchor type indicators
This allows to see what the current snap point is, which is useful when
zoomed in, or the point is like the corner of a rounded pad where it's
"in free space" and might not be immediately obvious.
2024-08-28 13:49:36 +01:00
Marek Roszko
b101c1a0c3 Enum class ELEM. 2024-08-18 21:09:37 -04:00
Marek Roszko
58e3c5bb6b Rename Type() to ProjectElementType() for _ELEM children 2024-08-18 20:30:45 -04:00
Jon Evans
d18d3ea6f4 Silence test debug output by default 2024-08-17 21:14:25 -04:00
Jon Evans
5d5d1210e4 Code style 2024-08-17 21:08:41 -04:00
Seth Hillbrand
9f4f3deec5 Don't use std::signbit for ints 2024-08-17 07:39:26 -07:00