Files
Kikomali a075cd9f49 Insert PCB (Gerber): pick a board's zip or any of its files and the board goes in (#13189)
* claim: #12797

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Insert PCB (Gerber): board solid from the outline and drill files

`file.insert_gerber` reads a board outline Gerber (RS-274X) layer and
Excellon drill files and builds the board in its own component: a sketch
"Outline" on XY with the outline and every hole and slot (straight and
routed arcs, exact), and one extrude of the board's thickness as the body
"Board". The body is FR-4 (1.85 g/cm3) with a solder-mask colour on its top
and bottom and copper on the walls of plated holes. The component records
which files were read. One undo step; a failure leaves the design as it was.

Gerber is parsed with gerber_parser (MIT OR Apache-2.0) behind a pre-pass
that keeps every known panic in it unreachable; the Excellon reader is our
own (it reads the files KiCad and EasyEDA write, plating included).

Refs #12797.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Insert PCB: check the mask colour lands on the evaluated board's top and bottom

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Insert PCB: copper, mask and silk as hidden sketches, a print look, vias as texture

Each copper, mask and silk Gerber is read exactly and kept as a hidden sketch, and each side of
the board gets a print image. Vias (tagged ViaDrill, or plated and 0.5 mm or smaller when the
file has no tags) are not cut; they are drawn on the print and kept as holes to drill in a
hidden Vias sketch. Outlines drawn as hundreds of tiny lines are read as the arcs and lines they
trace (within 0.05 mm), which takes a slow board from minutes to seconds. The drill reader now
reads via tags and Altium TYPE sections per tool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Insert PCB: a window that reads a board's zip or folder and lists its layers

Insert PCB now asks for a file, the way Insert DXF and Insert SVG do: a zip, or any
file in the board's folder. A new read-only command, file.gerber_files, sorts the set
by what each file says (X2 file function, drill header), then a .gbrjob, then common
file names. The window lists every file with its layer (changeable), plus name,
thickness, finish and placement; OK runs file.insert_gerber with the set in one undo
step. file.insert_gerber takes `set` so a zip's entries can be named directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Insert PCB: picking the board inserts it, with no window; faster sketches

Insert PCB now works like Insert STEP: the board's zip, or any file in its
folder, is picked and the board goes in beside the window with the import
card, each file's layer found from what it says. The window that listed the
files is gone (file.gerber_files still says what would be used).

Adding many entities to a sketch no longer scans every id for each new one:
DXF, SVG and board layers with thousands of entities go in much faster
(Treasure_hunt: 2.4 s to 1.6 s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Insert PCB: drill files with X2 comments, boards among many files, dense layers

- A KiCad drill file carries `; #@! TF.FileFunction` comments in its
  Excellon header: it is read as a drill, not an unused Gerber layer.
- A board's files picked in a busy folder (Downloads) are still found:
  pictures and documents are left unread, and a folder with more files
  than a set has is read up to the set's limits instead of refused.
- A dense copper layer is split over sketches by the points its shapes
  add, not by how many shapes it has; a shape too large for any sketch
  is left out with a warning, and the sketches made are always reported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Insert PCB: the picker shows every board file type the set reader knows

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Insert PCB: on the web the board's zip is picked, since only the chosen file is uploaded

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Insert PCB: the web app refuses a picked file that isn't a zip

Some browsers (iPhone, iPad) don't filter the picker, and a single
uploaded file would be read with whatever was uploaded before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Insert PCB: test that the web app refuses a picked file that isn't a zip

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Insert PCB: use the shared ui-text crate for the web zip message, as main now does

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Insert PCB: file.gerber_files checks its keys first, and the key check lists set

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Insert PCB: files that are not a board's no longer use up the folder's file limit

A picked file's folder is read for the board's set. Only files that read as
Gerber, drill or job files count toward the set's limits now, and zips are
left unread, so many other files sorting first no longer hide the board.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* Insert PCB: name where the two board commands are tested in the kernel-case exemptions

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 09:00:40 +00:00

90 lines
3.3 KiB
TOML

[package]
name = "solidcraft-engine"
description = "SolidCraft engine: the session, the command registry (everything is a command), undo/redo and selection"
version.workspace = true
edition.workspace = true
license.workspace = true
[lints]
workspace = true
[features]
default = ["plugins"]
plugins = ["dep:craft-plugin-wasm"]
# Optional authored texture/HDR bytes; the command registry and metadata remain available.
bundled-render-library = []
raytrace-cpu = ["solidcraft-render/raytrace-cpu"]
# Turns on the parameter-contract audit recorder (`SOLIDCRAFT_PARAM_AUDIT`, see
# `src/schema/record.rs`), for checking a new contract against the whole test suite.
param-audit = []
solver-profiling = ["solidcraft-sketch/solver-profiling"]
# Compile the profiler in (solidcraft-profile/enabled): every app turns it on by default, so any
# build can be profiled; it records only once switched on (SOLIDCRAFT_PROFILE=1, the CLI's
# --profile, the app's preference, diagnostics.profile).
profile = ["solidcraft-profile/enabled"]
[[example]]
name = "sketch_analysis_bench"
required-features = ["solver-profiling"]
[[example]]
name = "sketch_drag_bench"
required-features = ["solver-profiling"]
[[example]]
name = "sketch_target_bench"
required-features = ["solver-profiling"]
[dependencies]
craft-plugin = { workspace = true }
solidcraft-viewport = { workspace = true }
# The printed look of an inserted circuit board (src/cmd/board_layers.rs): its layers drawn
# into an image; both already in the tree (ui-egui, render).
tiny-skia = { workspace = true }
png = { workspace = true }
solidcore-ops = { workspace = true }
solidcore-record = { workspace = true }
solidcraft-color = { workspace = true }
solidcraft-control = { workspace = true }
solidcraft-geom = { workspace = true }
solidcraft-sketch = { workspace = true }
solidcraft-kernel = { workspace = true }
solidcraft-doc = { workspace = true }
solidcraft-io = { workspace = true }
solidcraft-render = { workspace = true }
solidcraft-profile = { workspace = true }
# reference pictures for inspect.compare_picture (PNG and JPEG decode, PNG encode)
image = { workspace = true, features = ["jpeg"] }
serde = { workspace = true }
serde_json = { workspace = true }
sha2 = { workspace = true }
toml_edit = "0.25"
schemars = { workspace = true }
serde_path_to_error = { workspace = true }
thiserror = { workspace = true }
log = { workspace = true }
web-time = { workspace = true }
[dev-dependencies]
solidcore-ops = { workspace = true }
solidcraft-profile = { workspace = true, features = ["enabled"] }
# Model-cache tests also run in a source tarball build (no git commit).
solidcraft-io = { workspace = true, features = ["dxf-legacy-baseline-tests", "trust-unknown-source"] }
# Normal CI exercises profiling assertions without enabling the production feature.
solidcraft-sketch = { workspace = true, features = ["solver-profiling"] }
[[example]]
name = "render_resource_workflow"
required-features = ["raytrace-cpu"]
[[example]]
name = "wood_texture_workflow"
required-features = ["raytrace-cpu"]
[target.'cfg(any(target_arch = "x86_64", target_arch = "aarch64"))'.dependencies]
# Component-model sandbox; no WASI, cache deserialization, network or process imports.
craft-plugin-wasm = { workspace = true, optional = true }
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
wat = "1"