Commit Graph

7645 Commits

Author SHA1 Message Date
Jeff Young 4da7c180c2 Apply KiCad look & feel to DRC Rules Editor. 2026-03-07 19:28:46 +00:00
Seth Hillbrand 1cf4284930 IPC-2581: use schematic revision for BOM
The BOM revision in IPC-2581 export was hardcoded to "1.0"
instead of reflecting the actual design revision.

The project file stores two separate fields: bomRev for
explicit user overrides set in the PCBnew export dialog or
via --bom-rev on the CLI, and schRevision for the value
auto-propagated from eeschema.
2026-03-06 09:13:56 -08:00
Seth Hillbrand 1eb3f5f3eb Recover OpenGL after sleep/wake context loss
When the GPU context is invalidated by sleep/wake or a driver
reset, glMapBuffer fails with GL_OUT_OF_MEMORY and the renderer
permanently falls back to Cairo. Instead, attempt a full OpenGL
GAL reinit once before giving up. SwitchBackend recreates all
GPU resources and SetGAL triggers clearGroupCache so every
cached item is regenerated on the next frame. A flag prevents
infinite retry loops and resets after each successful paint.
2026-03-05 08:25:31 -08:00
Damjan Prerad 700df8720d DRC Rule Editor: Fix soldermask 'silver' typo to 'sliver' in DRC Rule Editor 2026-03-05 14:30:48 +01:00
Seth Hillbrand 9c6f99e0dd Fix import lockup on non-PCB files
LAYER_RANGE enters an infinite loop when constructed with
layer_count < 2. The next_layer() arithmetic underflows,
producing unreachable termination values, so the iterator
increments forever. This happens during board import when a
file produces a board with zero copper layers.

Clamp layer_count to a minimum of 2 in the LAYER_RANGE
constructor since F_Cu and B_Cu are always present.

Add content validation to the Fabmaster plugin, which
previously accepted any .txt file based on extension alone.
CanReadBoard now scans for !-delimited rows containing
known Fabmaster column headers before claiming the file.
2026-03-04 17:37:03 -08:00
Seth Hillbrand e60e619655 Fix data race in library manager row cache
Background library loading threads call GetRow() through
loadFromScope(), which writes to m_rowCache concurrently
with the main thread clearing it in loadTables(). The
unsynchronized access corrupts the map's red-black tree,
causing a double-free crash when switching projects.

Add m_rowCacheMutex to protect all m_rowCache accesses.
Also replace std::tie with std::make_tuple to avoid
unnecessary temporary conversions, and use a single
find() instead of contains() followed by at().
2026-03-04 12:32:57 -08:00
Seth Hillbrand 02f31c8de1 Fix empty symbol chooser previews on first load
Add an aAllowSkip parameter to DoRePaint that gates both skip
checks.  onPaint and ForceRefresh pass false so they always
execute the full GL/Cairo cycle.  The rate-limited Refresh path
continues to pass true (the default), preserving the GPU
utilization improvement from b728c08b7a.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23325
2026-03-04 08:11:02 -08:00
John Beard 6c5b1bbc8b Pcbnew: Allow to skip layer mapping using advanced config
Clicking Automap/OK was fun for a bit.
2026-03-04 23:28:31 +08:00
Jon Evans aa21aacd72 Improve efficiency of power symbol filtering
Calling GetLibSymbol for every node is quite expensive,
put this info into the node directly instead.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23267
2026-03-03 21:26:09 -05:00
Jon Evans a66db54bc5 Cache library manager row lookup 2026-03-03 21:26:09 -05:00
Jon Evans f06a303384 Symbol chooser performance improvements
Cache LIB_SYMBOL properties used for chooser filtering
Reduce copying during creation of chooser widgets

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23267
2026-03-03 21:26:07 -05:00
Seth Hillbrand b404b30fb9 Fix integer overflow in THROTTLE first call
Initializing m_last to time_point::min() causes signed integer
overflow when computing now - m_last, since the nanosecond
difference exceeds int64_t range. Initialize to now - interval
instead so the first Ready() call passes naturally.
2026-03-03 12:30:32 -08:00
Seth Hillbrand 18c025f21f Skip redundant VIEW updates and repaints
Add m_hasPendingItemUpdates to VIEW so UpdateItems() can
return immediately when no item has queued update flags.
The flag is set wherever m_requiredUpdate is modified and
cleared at the end of UpdateItems().

In DoRePaint(), check the new flag alongside IsDirty() and
cursor movement to skip both item processing and the GL
draw cycle when nothing has changed. Route onPaint through
Refresh() so the existing frame-rate throttle applies to
native paint events as well.
2026-03-03 11:33:10 -08:00
Seth Hillbrand fff428dcd6 Add THROTTLE class and DrainPendingEvents
Five call sites independently reimplemented the same
time-gated throttle pattern.  This consolidates them all
into a single THROTTLE class backed by steady_clock.

Three call sites duplicated the wxWidgets YieldFor workaround
for timer-event backlog (wxWidgets issue #26192). This replaces them
with a shared DrainPendingEvents free function.
2026-03-03 11:33:10 -08:00
Seth Hillbrand 2c4368be85 Fix crash opening footprint chooser after project switch
PG_FPID_EDITOR is registered in wxPropertyGrid's global editor
registry and persists across SCH_PROPERTIES_PANEL lifetimes.
UpdateFrame() didn't update the netlist callback lambda.

To fix this, we add an UpdateCallback() to PG_FPID_EDITOR and
call it alongside UpdateFrame() when reusing an existing
editor instance.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23307
2026-03-02 11:50:30 -08:00
Seth Hillbrand 314429373c pcbnew: Update zone manager
Update zone manager to improve usability. Filter zones based on layers,
provide move to top/move to bottom actions, global arrow key navigation,
zoom preservation across zone switches, right-click zoom-to-fit on the
preview canvas, and pixel-aligned icons for top/bottom move buttons.
2026-03-01 22:07:19 -08:00
Damjan Prerad c753d6cd34 DRC Rule Editor: Add skew field to matched length diff pair constr.
The matched length diff pair panel had skew data in the constraint class
but no UI field to display or edit it. Added a dedicated overlay panel
with min/opt/max length plus max skew fields, a new bitmap showing a
diff pair with length arrows and skew indicator.
2026-03-01 12:14:16 +01:00
Alex Shvartzkop 21db4a0238 Avoid sorting layers after setting each layer rendering order in VIEW.
Saves 100 ms when opening Choose Symbol dialog.
2026-02-28 13:47:03 +03:00
Seth Hillbrand 1e2a2fb02c Fix minor safety and visibility issues
Move onUpdateUI from public to private in EDA_BASE_FRAME since
it is an internal event handler bound via Bind(), not part of
the public API.

Capture the empty-check result before erasing rows in
library_manager.cpp to avoid using invalidated iterators from
the subrange returned by std::ranges::remove_if.

Add null guards to the netHighlightCond toolbar condition
lambda in PCB_EDIT_FRAME to prevent null dereference during
shutdown, matching the pattern used by other toolbar
conditions fixed in f962de966b.
2026-02-27 19:13:47 -08:00
Seth Hillbrand fbe31e5d36 Consolidate wxEVT_UPDATE_UI handlers to a single dispatcher
SearchDynamicEventTable does a linear scan through all dynamic
Bind entries for every dispatched event, regardless of event type.

Replace the per-action Bind() calls with a single wxID_ANY handler
that dispatches to the existing m_uiUpdateMap through a hash map.
This reduces the per-event scan from around 150 to about 1 for all
event types.  This is particularly noticeable during high frequency
events like mouse drag.
2026-02-27 15:21:23 -08:00
Damjan Prerad e2a9f06420 Fix uninitialized m_isNew causing asterisk on all DRC Rule Editor tree items
The default constructor of RULE_EDITOR_DATA_BASE left m_isNew
uninitialized. On Linux, the garbage memory value was assigned
causing IsNew() to return true for every rule and appending
astersix to all tree items.

Fix by adding a default member initializer: m_isNew = false.
2026-02-26 11:34:41 +01:00
Damjan Prerad cf80df280c Fix ghost windows appearing in macOS Mission Control when using DRC Rule Editor
Clicking on rules in the tree created a wxDragImage each time, which on
macOS opens a hidden full-screen window. These windows were never cleaned
up and piled up as ghost windows in Mission Control.

Removed wxDragImage and replaced drag feedback with a highlight
on the drop target item.
2026-02-26 00:13:34 +01:00
Alex Shvartzkop 4889204ec5 Include glad before glcanvas. 2026-02-26 00:08:47 +03:00
Seth Hillbrand f826061434 Move DRC Rule Editor out from behind AC 2026-02-24 16:32:02 -08:00
Seth Hillbrand 930dc9933c Update bitmaps 2026-02-24 10:28:11 -08:00
Damjan Prerad ea06a64cdd DRC Rule Editor: Remove duplicate hole-to-hole clearance constraint
Remove HOLE_TO_HOLE_CLEARANCE from the rule editor as it generates the same
DRC rule as HOLE_TO_HOLE_DISTANCE.
2026-02-24 17:26:37 +01:00
Ian McInerney 2c4a4cd8f0 Fix the font selector "Leave Unchanged" option in global edit dialogs
Fixes https://gitlab.com/kicad/code/kicad/-/issues/23190
2026-02-24 15:56:50 +00:00
Seth Hillbrand 08bb3601bd Increase LINE_READER max line length to 16 MB
The previous 1 MB limit caused "Maximum line length exceeded" errors
when loading schematics containing large embedded images or other long
quoted tokens.  The S-expression parser (DSNLEXER) requires entire
quoted strings to fit within a single line buffer, so Prettify cannot
split them across lines.  Raise the limit from 1 MB to 16 MB and add
regression tests.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23162
2026-02-24 07:55:24 -08:00
Damjan Prerad 7cd08db76b DRC Rule Editor: Consolidate uVia constraints into Via Style panel
Merge Minimum uVia Hole and Minimum uVia Diameter constraints
into the existing Via Style panel. Remove unused optimum/preferred
diameter and hole size fields.

Add a via type dropdown (Any/Through/Micro/Blind/Buried) used to
generate the appropriate A.Via_Type condition clause in the DRC.
Strip the via type condition on rule load to prevent duplication
on save cycles.
2026-02-24 15:46:49 +01:00
Alex Shvartzkop 00094984ed Slightly optimize PAD::IsOnCopperLayer(). 2026-02-24 00:55:09 +03:00
Seth Hillbrand c0a6a139cf Add $INSUNITS header variable to DXF export
The DXF exporter was missing the $INSUNITS header variable, which tells
CAD software what physical units the drawing coordinates represent. Without
it, other programs have no reliable way to determine the coordinate scale.

Add $INSUNITS to the HEADER section alongside the existing $MEASUREMENT
variable. When exporting in millimeters, $INSUNITS is set to 4; when
exporting in inches, it is set to 1.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23181
2026-02-23 12:14:49 -08:00
Seth Hillbrand 085cb15666 Fix crash when plotting from Python API without GUI
GAL::computeWorldScale() called Pgm() unconditionally, which
crashes with SIGSEGV when running from standalone Python where
PGM_BASE is never initialized. This affected all non-PDF plot
formats (DXF, SVG, Gerber) because they render text through
CALLBACK_GAL, whose base GAL constructor calls computeWorldScale().
PDF was unaffected because it has its own native text rendering
that never creates a CALLBACK_GAL.

Use PgmOrNull() instead

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23171
2026-02-23 12:03:16 -08:00
Seth Hillbrand 076d62b8a4 Fix countersink angle unit conversion
The angle is stored internally in decidegrees but was read and
written without applying the required scale factor in two places.

Also adds missing includes to toolbars_pcb_editor.cpp to fix a
build failure from 855c996475.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/23134
2026-02-23 10:56:11 -08:00
Seth Hillbrand d9a3c17991 Fix startup wizard skipping privacy settings after migration
When the user imported settings from a previous version during the
startup wizard, the settings provider's Finish() reloaded all settings
from the migrated files. This changed the in-memory state so
data_collection_prompt became true (from the old version). The Finish
loop then re-evaluated NeedsUserInput() for each provider, causing
the privacy provider to be skipped

Fix this by tracking which providers had their wizard pages shown
using a flag

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23051
2026-02-22 19:11:17 -08:00
Damjan Prerad e46f56f120 DRC Rule Editor: Rename 'Minimum through hole' to 'Minimum drill size' and update constraint bitmaps
Update constraint SVG source files to use the standard KiCad color
palette, reposition textboxes, and add missing eda_text.h include
in toolbars_pcb_editor.cpp
2026-02-22 23:45:18 +01:00
Jeff Young d7761d08c2 Better reporting when multiple footprints share the same RefDes.
Also guards access to fields in variant m_fields map.
2026-02-22 20:05:47 +00:00
Alex Shvartzkop 3fa40e05dc Use GLAD for OpenGL loading instead of GLEW.
This allows us to pick GLX on X11 and EGL on Wayland
at runtime when building with wxWidgets 3.3.2+

GLEW only allowed to choose between GLX/EGL at compile time.

This also removes KICAD_USE_EGL option, KiCad will use
whatever wxWidgets was built with.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20647
2026-02-22 14:56:40 +03:00
Damjan Prerad 0d924b5bdd Remove redundant DRC rule editor panels and rename silk clearance bitmap
Remove MINIMUM_TRACK_WIDTH, BASIC_CLEARANCE, BOARD_OUTLINE_CLEARANCE,
and MINIMUM_ITEM_CLEARANCE panels from the DRC rule editor. These were
redundant with ROUTING_WIDTH, MINIMUM_CLEARANCE, COPPER_TO_EDGE_CLEARANCE,
and SILK_TO_SILK_CLEARANCE respectively. Rename the minimum_item_clearance
bitmap to silk_to_silk_clearance and assign it to the silk clearance panel.
Revert matcher claim changes for HOLE_SIZE and MINIMUM_VIA_DIAMETER.
2026-02-20 20:00:47 +01:00
Jeff Young 7b7fc35c9c Move value property to PCB_FOOTPRINT_FIELD_PROPERTY.
(Also reworks things a little to give the fields a
more expected order.)
2026-02-20 18:56:52 +00:00
Alex Shvartzkop 7fd1688b5d Fix build with wx master on GTK. 2026-02-20 12:12:06 +03:00
Alex Shvartzkop 405d299dd5 Fix "returning reference to local temporary object" 2026-02-20 11:05:04 +03:00
Seth Hillbrand d7460bc5fe Fix rule editor dialog sizing inflation
DIALOG_SHIM::Show() and finishDialogSettings() both
call SetSizeHints(), which computes the best size from
the full unconstrained scrolled content area. This
inflated the dialog to unusable heights.

Move size correction logic into the base class by
overriding Show() to cap minimum height at 500px and
resetting to m_initialSize after finishDialogSettings().
Remove the duplicate size fixups from the derived DRC
editor's TransferDataToWindow(). Increase default
initial height from 680 to 800.
2026-02-19 21:59:39 -08:00
Seth Hillbrand ee8b2bebce Store dialog geometry in DPI-independent pixels to prevent size ratcheting
On mixed-DPI multi-monitor setups, dialog sizes grow each time they are
reopened because logical pixel values change when a window moves between
monitors with different scaling factors. The std::max comparison during
restore guarantees monotonic growth since the DPI-scaled value always
exceeds the previously saved unscaled value.

Store width and height as DIP (device-independent pixels) using ToDIP()
on save and FromDIP() on restore. This makes the persisted size stable
regardless of which monitor the dialog was on when closed. A "dip" flag
in the JSON differentiates new DIP-format values from legacy logical
pixel values, which are converted in place on first load.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20120
2026-02-19 15:21:30 -08:00
Alex Shvartzkop aff91bd47a Improve GLX/EGL reporting. 2026-02-19 23:40:05 +03:00
Seth Hillbrand 8da6e447cd Remove orphaned constraint bitmap enum values
Remove 15 BITMAPS enum values that have no registered image data
in bitmap_info.cpp and no remaining code references. These were
placeholders for constraint types that either never got SVG artwork
or used different naming than the generated bitmaps.

Removed: constraint_net_antenna, constraint_short_circuit,
constraint_unrouted, constraint_allow_fillet_outside_zone_outline,
constraint_silk_to_silk_clearance, constraint_minimum_acute_angle,
constraint_matched_length_all_traces_in_group,
constraint_absolute_length, constraint_parallel_limit,
constraint_daisy_chain_stub, constraint_daisy_chain_stub_2,
constraint_corner_style, constraint_smd_corner,
constraint_smd_entry, constraint_smd_to_plane_plus
2026-02-19 07:59:39 -08:00
Seth Hillbrand 34ff7a5977 Minor cleanups
Remove stale m_ShowRepairSchematic member from
advanced_config.h left behind when RepairSchematic() was
retired. Remove unnecessary const_cast in wxExecute call
in jobs_runner.cpp. Fix stray semicolon after return in
pcb_barcode.cpp and use >= ZINT_ERROR instead of truthiness
for the ZBarcode_Buffer_Vector return check.
2026-02-18 20:16:44 -08:00
Seth Hillbrand 42cfb95fe7 Fix canvas losing keyboard focus after closing properties dialog
When a dialog closes with the mouse hovering over an auxiliary panel
(e.g. the properties panel), focus would land on that panel instead
of the drawing canvas, breaking hotkey operation until the user moved
the mouse back over the canvas.

Set focus directly on the parent frame's tool canvas when closing
dialogs via Show(false) and ShowQuasiModal(), falling back to the
parent window when no canvas is available.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20926
2026-02-18 12:42:07 -08:00
Damjan Prerad 391b87cfa8 Add vertical scrolling to DRC Rule Editor content panel
Wrap the right side content area in a wxScrolledWindow so that rule
panels remain accessible when many constraints are added.
RefreshContentScrollArea() function is called on resize,
rule switch and and dynamic condition changes.
2026-02-18 11:45:38 +01:00
Seth Hillbrand 23629c4cc6 Flip associated layer when flipping reference images
PCB_REFERENCE_IMAGE::Flip() was the only board item type that did not
call SetLayer(GetBoard()->FlipLayer(GetLayer())) during a flip operation.

Also avoids expensive re-encoding and wxBitmap rebuid processes to speed
up swapping

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23059
2026-02-17 12:31:04 -08:00
Seth Hillbrand b728c08b7a Reduce OpenGL GPU utilization by rate-limiting redraws
The GAL draw panel was rendering far more frames than needed, causing
100% GPU utilization on systems where vsync was unavailable or disabled.
Three changes address this:

Refresh() now enforces a minimum period between renders. With vsync
active the guard is 3ms (the driver throttles via SwapBuffers). Without
vsync a 16ms floor caps rendering at 60 FPS, preventing GPU saturation.

DoRePaint() tracks the cursor position and skips the entire GL cycle
when neither the view is clean and the cursor doesn't move

OnEvent() delegates directly to the rate-limited Refresh() instead of
maintaining its own adaptive throttle with a RequestRefresh() idle
fallback that fired immediately and provided no actual throttling.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19112
2026-02-17 11:54:33 -08:00