POC: "Import from file" panel — place a local .kicad_sym / .kicad_mod on the canvas - #41
Open
matejcsok-pcb wants to merge 1 commit into
Open
matejcsok-pcb wants to merge 1 commit into
matejcsok-pcb wants to merge 1 commit into
Conversation
…kicad_mod on the canvas Proof of concept for plugin-style item ingress: a floating panel (session menu → "Import from file") takes a symbol library or footprint file from the user's machine (file picker or drag-and-drop onto the panel), lets them pick a symbol when the library holds several, and places it where they next click on the canvas (Esc cancels; viewport centre is the fallback). No C++: the blob goes through the editors' existing collab items-apply bridge (Module.kicadCollabApplyItems), i.e. the clipboard-paste parsers — pcbnew takes a bare (footprint …) with an (at …) added, eeschema takes the clipboard dialect (lib_symbols …) + (symbol …) so the definition travels with the instance and a never-seen library works. The click maps CSS px → canvas px (HiDPI) → world IU through kicadCollabGetViewport, same as the comment pins. Known POC limits, documented in wasm/import-item.ts: the apply commits with SKIP_UNDO and is folded into the collab baseline (not undoable, not broadcast to peers); the symbol lands unannotated; placement is a commit, not an interactive drag. The follow-up route is one embind export per editor feeding placeSymbol / placeFootprint a pre-built item. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Proof of concept for plugin-style item ingress in the standalone editor: a floating Import from file panel (session menu → Import from file) that takes a
.kicad_symor.kicad_modfrom the user's machine and places it on the open eeschema / pcbnew canvas.How (no C++)
The blob goes through the editors' existing collab items-apply bridge,
Module.kicadCollabApplyItems, i.e. the clipboard-paste parsers:(footprint …); the panel adds(at x y)and caps the format version.(lib_symbols (symbol "Nick:Name" …)) (symbol (lib_id "Nick:Name") …)— the definition travels with the instance, so a library the editor has never seen still works.Click → position: CSS px → canvas px (rect ratio, HiDPI-safe) → world IU via
kicadCollabGetViewport, the same mapping the comment pins use.Files
wasm/import-item.ts— blob builders + click/viewport mapping (pure, unit-tested: 12 tests).components/ImportItemPanel.tsx— the panel.WasmTool.tsx,wasm-tool/SessionMenu.tsx— wiring + menu toggle.Verified
RandCplaced; the stored(at …)equals the mapped click exactly.R_0603_1608Metricplaced with pads / courtyard /REF**.vitest492 green,tsc --noEmitclean, no console errors from the feature.Known POC limits (documented in
wasm/import-item.ts)SKIP_UNDOand is folded into the collab baseline: not undoable, not broadcast to peers / the Y.Doc. Fine inapidoc mode (File→Save writes it), wrong forydocmode.R?) without instance data; Annotate fixes it.Follow-up route for the real feature
One embind export per editor feeding a pre-built item to
SCH_ACTIONS::placeSymbol/PCB_ACTIONS::placeFootprint(both take an item and go interactive at the cursor, with normal undo), plus registering the file as a runtime lib vialocalFileLibsSource+kicadLibsAddEntryso the stock chooser lists it. The wx-side browser→canvas file DnD hook (registerDragDropHandlers/Module._OnFileDropped) exists but has no JS half yet.🤖 Generated with Claude Code