From c6f4832ee4f27ef55cbfee0b556a6297425f0e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1n=20D=C3=A9nes?= Date: Sat, 16 Apr 2022 12:44:55 +0200 Subject: [PATCH] Single key column name simplification --- roadmap.md | 12 ++++---- src/points.js | 17 ++++++----- src/utils.js | 2 +- test/points/default.yaml | 6 +++- test/points/default___demo_dxf.dxf | 48 ++++++++++++++++++++++++++++++ test/points/default___points.json | 46 ++++++++++++++++++++++++++++ 6 files changed, 116 insertions(+), 15 deletions(-) diff --git a/roadmap.md b/roadmap.md index ddc1433..aa7d531 100644 --- a/roadmap.md +++ b/roadmap.md @@ -6,27 +6,27 @@ ### Major -- key-level access to full anchors +- Gut standalone 3d output, only different scripts for different integrations +- Key-level access to full anchors - this could provide extra variables `padding`, `spread`, `splay` for custom layout purposes - make row anchors cumulative, too (like columns), so fingers arcs and other edits can happen -- remove `_default` suffix for only column keys (like for single point zones) - Restructure pcb point/footprint filtering - Use the same `what`/`where` infrastructure as outlines - Collapse params/nets/anchors into a single hierarchy from the user's POV - Add per-footprint mirror support - Add some way for footprints to be able to "resist" the mirroring-related special treatment of negative X shift, rotation, etc. - Merge, generalize, uniform-ize and externalize footprints! - - Separate npm package for dependency, onnx-like incremental opset versioning + - onnx-like incremental opset versioning - Template for creating them, built-in variables they can use, documentation, external links, etc. - Add access to whole set of points + filtering logic, so they can implement their own connection logic as well maybe (see daisy chaining) - Also considering how (or, on which layer) they define their silks, universal mirroring behaviour, etc. - Rename class to designator in this context (https://en.wikipedia.org/wiki/Reference_designator#Designators) - - Include raw kicad footprint integrations - - pull torik's script to be able to convert raw kicad footprints into positionable ergogen ones - - have a `dummy` footprint which can just be updated from schematic ### Minor +- Include raw kicad footprint integrations + - pull torik's script to be able to convert raw kicad footprints into positionable ergogen ones + - have a `dummy` footprint which can just be updated from schematic - Shift/rotate/scale for outline elements before layout - Allow footprints to publish outlines - Make these usable in the `outlines` section through a new `what` diff --git a/src/points.js b/src/points.js index 0d48cc8..def23a5 100644 --- a/src/points.js +++ b/src/points.js @@ -294,13 +294,16 @@ exports.parse = (config, units) => { // creating new points let new_points = render_zone(zone_name, zone, anchor, global_key, units) - // simplifying the names in individual point "zones" - const new_keys = Object.keys(new_points) - const individual_key = `${zone_name}_default_default` - if (new_keys.length == 1 && new_keys[0] == individual_key) { - new_points[zone_name] = new_points[individual_key] - new_points[zone_name].meta.name = zone_name - delete new_points[individual_key] + // simplifying the names in individual point "zones" and single-key columns + while (Object.keys(new_points).some(k => k.endsWith('_default'))) { + for (const key of Object.keys(new_points)) { + if (key.endsWith('_default')) { + const new_key = key.slice(0, -8) + new_points[new_key] = new_points[key] + new_points[new_key].meta.name = new_key + delete new_points[key] + } + } } // adjusting new points diff --git a/src/utils.js b/src/utils.js index 2acf1b0..de9cb5f 100644 --- a/src/utils.js +++ b/src/utils.js @@ -26,7 +26,7 @@ exports.template = (str, vals={}) => { const replacement = deep(vals, match[1]) || '' res = res.substring(0, match.index + shift) + replacement - + res.substring(match.index + match[0].length) + + res.substring(match.index + shift + match[0].length) shift += replacement.length - match[0].length } return res diff --git a/test/points/default.yaml b/test/points/default.yaml index f767592..71c99b6 100644 --- a/test/points/default.yaml +++ b/test/points/default.yaml @@ -1 +1,5 @@ -points.zones.matrix: \ No newline at end of file +points.zones: + matrix: + single_key_column: + columns: + named: \ No newline at end of file diff --git a/test/points/default___demo_dxf.dxf b/test/points/default___demo_dxf.dxf index 8082f61..d28ab98 100644 --- a/test/points/default___demo_dxf.dxf +++ b/test/points/default___demo_dxf.dxf @@ -93,6 +93,54 @@ LINE 21 9 0 +LINE +8 +0 +10 +-9 +20 +9 +11 +9 +21 +9 +0 +LINE +8 +0 +10 +9 +20 +9 +11 +9 +21 +-9 +0 +LINE +8 +0 +10 +9 +20 +-9 +11 +-9 +21 +-9 +0 +LINE +8 +0 +10 +-9 +20 +-9 +11 +-9 +21 +9 +0 ENDSEC 0 EOF \ No newline at end of file diff --git a/test/points/default___points.json b/test/points/default___points.json index 667bfc4..c4ad48d 100644 --- a/test/points/default___points.json +++ b/test/points/default___points.json @@ -41,5 +41,51 @@ 0 ] } + }, + "single_key_column_named": { + "x": 0, + "y": 0, + "r": 0, + "meta": { + "stagger": 0, + "spread": 0, + "splay": 0, + "origin": [ + 0, + 0 + ], + "orient": 0, + "shift": [ + 0, + 0 + ], + "rotate": 0, + "width": 18, + "height": 18, + "padding": 19, + "autobind": 10, + "skip": false, + "asym": "both", + "colrow": "named_default", + "name": "single_key_column_named", + "zone": { + "columns": { + "named": null + }, + "name": "single_key_column" + }, + "col": { + "rows": {}, + "key": {}, + "name": "named" + }, + "row": "default", + "bind": [ + 0, + 0, + 0, + 0 + ] + } } }