@tscircuit/cli 0.1.901 → 0.1.902
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/main.js +759 -349
- package/dist/lib/index.js +683 -273
- package/package.json +2 -2
package/dist/cli/main.js
CHANGED
|
@@ -54868,7 +54868,7 @@ var require_utils2 = __commonJS((exports2) => {
|
|
|
54868
54868
|
}
|
|
54869
54869
|
}
|
|
54870
54870
|
};
|
|
54871
|
-
function
|
|
54871
|
+
function identity5(input) {
|
|
54872
54872
|
return input;
|
|
54873
54873
|
}
|
|
54874
54874
|
function stringToArrayLike(str, array) {
|
|
@@ -54944,7 +54944,7 @@ var require_utils2 = __commonJS((exports2) => {
|
|
|
54944
54944
|
}
|
|
54945
54945
|
var transform = {};
|
|
54946
54946
|
transform["string"] = {
|
|
54947
|
-
string:
|
|
54947
|
+
string: identity5,
|
|
54948
54948
|
array: function(input) {
|
|
54949
54949
|
return stringToArrayLike(input, new Array(input.length));
|
|
54950
54950
|
},
|
|
@@ -54960,7 +54960,7 @@ var require_utils2 = __commonJS((exports2) => {
|
|
|
54960
54960
|
};
|
|
54961
54961
|
transform["array"] = {
|
|
54962
54962
|
string: arrayLikeToString,
|
|
54963
|
-
array:
|
|
54963
|
+
array: identity5,
|
|
54964
54964
|
arraybuffer: function(input) {
|
|
54965
54965
|
return new Uint8Array(input).buffer;
|
|
54966
54966
|
},
|
|
@@ -54978,7 +54978,7 @@ var require_utils2 = __commonJS((exports2) => {
|
|
|
54978
54978
|
array: function(input) {
|
|
54979
54979
|
return arrayLikeToArrayLike(new Uint8Array(input), new Array(input.byteLength));
|
|
54980
54980
|
},
|
|
54981
|
-
arraybuffer:
|
|
54981
|
+
arraybuffer: identity5,
|
|
54982
54982
|
uint8array: function(input) {
|
|
54983
54983
|
return new Uint8Array(input);
|
|
54984
54984
|
},
|
|
@@ -54994,7 +54994,7 @@ var require_utils2 = __commonJS((exports2) => {
|
|
|
54994
54994
|
arraybuffer: function(input) {
|
|
54995
54995
|
return input.buffer;
|
|
54996
54996
|
},
|
|
54997
|
-
uint8array:
|
|
54997
|
+
uint8array: identity5,
|
|
54998
54998
|
nodebuffer: function(input) {
|
|
54999
54999
|
return nodejsUtils.newBufferFrom(input);
|
|
55000
55000
|
}
|
|
@@ -55010,7 +55010,7 @@ var require_utils2 = __commonJS((exports2) => {
|
|
|
55010
55010
|
uint8array: function(input) {
|
|
55011
55011
|
return arrayLikeToArrayLike(input, new Uint8Array(input.length));
|
|
55012
55012
|
},
|
|
55013
|
-
nodebuffer:
|
|
55013
|
+
nodebuffer: identity5
|
|
55014
55014
|
};
|
|
55015
55015
|
exports2.transformTo = function(outputType, input) {
|
|
55016
55016
|
if (!input) {
|
|
@@ -74384,7 +74384,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
74384
74384
|
import { execSync as execSync2 } from "node:child_process";
|
|
74385
74385
|
var import_semver2 = __toESM2(require_semver2(), 1);
|
|
74386
74386
|
// package.json
|
|
74387
|
-
var version = "0.1.
|
|
74387
|
+
var version = "0.1.901";
|
|
74388
74388
|
var package_default = {
|
|
74389
74389
|
name: "@tscircuit/cli",
|
|
74390
74390
|
main: "dist/cli/main.js",
|
|
@@ -74415,7 +74415,7 @@ var package_default = {
|
|
|
74415
74415
|
chokidar: "4.0.1",
|
|
74416
74416
|
"circuit-json": "0.0.325",
|
|
74417
74417
|
"circuit-json-to-gltf": "^0.0.58",
|
|
74418
|
-
"circuit-json-to-kicad": "^0.0.
|
|
74418
|
+
"circuit-json-to-kicad": "^0.0.71",
|
|
74419
74419
|
"circuit-json-to-readable-netlist": "^0.0.13",
|
|
74420
74420
|
"circuit-json-to-spice": "^0.0.10",
|
|
74421
74421
|
"circuit-json-to-tscircuit": "^0.0.9",
|
|
@@ -76361,44 +76361,62 @@ import {
|
|
|
76361
76361
|
Setup
|
|
76362
76362
|
} from "kicadts";
|
|
76363
76363
|
import { PcbNet } from "kicadts";
|
|
76364
|
-
import { Footprint
|
|
76365
|
-
import { applyToPoint as
|
|
76364
|
+
import { Footprint } from "kicadts";
|
|
76365
|
+
import { applyToPoint as applyToPoint10 } from "transformation-matrix";
|
|
76366
|
+
import { FpCircle, Stroke as Stroke3 } from "kicadts";
|
|
76367
|
+
import { FpCircle as FpCircle2, Stroke as Stroke4 } from "kicadts";
|
|
76368
|
+
import { FpRect, Stroke as Stroke5 } from "kicadts";
|
|
76369
|
+
import { FpRect as FpRect2, Stroke as Stroke6 } from "kicadts";
|
|
76370
|
+
import { FpRect as FpRect3, Stroke as Stroke7 } from "kicadts";
|
|
76371
|
+
import { FpPoly, Pts as Pts3, Xy as Xy3, Stroke as Stroke8 } from "kicadts";
|
|
76372
|
+
import"kicadts";
|
|
76373
|
+
import { FpText, TextEffects as TextEffects4, TextEffectsFont as TextEffectsFont4 } from "kicadts";
|
|
76374
|
+
import { applyToPoint as applyToPoint5, rotate, identity } from "transformation-matrix";
|
|
76375
|
+
import { FpText as FpText3, TextEffects as TextEffects5, TextEffectsFont as TextEffectsFont5 } from "kicadts";
|
|
76376
|
+
import { applyToPoint as applyToPoint6, rotate as rotate2, identity as identity2 } from "transformation-matrix";
|
|
76377
|
+
import { FootprintModel } from "kicadts";
|
|
76366
76378
|
import {
|
|
76367
76379
|
FootprintPad,
|
|
76368
76380
|
PadPrimitives,
|
|
76369
76381
|
PadPrimitiveGrPoly,
|
|
76370
|
-
Pts as
|
|
76371
|
-
Xy as
|
|
76382
|
+
Pts as Pts4,
|
|
76383
|
+
Xy as Xy4,
|
|
76372
76384
|
PadOptions,
|
|
76373
76385
|
PadNet
|
|
76374
76386
|
} from "kicadts";
|
|
76375
76387
|
import {
|
|
76376
|
-
applyToPoint as
|
|
76388
|
+
applyToPoint as applyToPoint7,
|
|
76377
76389
|
compose as compose2,
|
|
76378
76390
|
translate as translate2,
|
|
76379
76391
|
scale as scale2,
|
|
76380
|
-
rotate
|
|
76392
|
+
rotate as rotate3
|
|
76381
76393
|
} from "transformation-matrix";
|
|
76382
76394
|
import { FootprintPad as FootprintPad2, PadDrill, PadNet as PadNet2 } from "kicadts";
|
|
76383
|
-
import { applyToPoint as applyToPoint6, rotate as rotate2, identity } from "transformation-matrix";
|
|
76384
|
-
import { FootprintPad as FootprintPad3, PadDrill as PadDrill2 } from "kicadts";
|
|
76385
|
-
import { applyToPoint as applyToPoint7, rotate as rotate3, identity as identity2 } from "transformation-matrix";
|
|
76386
|
-
import { FpText, TextEffects as TextEffects4, TextEffectsFont as TextEffectsFont4 } from "kicadts";
|
|
76387
76395
|
import { applyToPoint as applyToPoint8, rotate as rotate4, identity as identity3 } from "transformation-matrix";
|
|
76396
|
+
import { FootprintPad as FootprintPad3, PadDrill as PadDrill2 } from "kicadts";
|
|
76397
|
+
import { applyToPoint as applyToPoint9, rotate as rotate5, identity as identity4 } from "transformation-matrix";
|
|
76388
76398
|
import { Segment, SegmentNet } from "kicadts";
|
|
76389
|
-
import { applyToPoint as applyToPoint10 } from "transformation-matrix";
|
|
76390
|
-
import { Via, ViaNet } from "kicadts";
|
|
76391
76399
|
import { applyToPoint as applyToPoint11 } from "transformation-matrix";
|
|
76400
|
+
import { Via, ViaNet } from "kicadts";
|
|
76401
|
+
import { applyToPoint as applyToPoint12 } from "transformation-matrix";
|
|
76392
76402
|
import { GrLine } from "kicadts";
|
|
76393
|
-
import { applyToPoint as applyToPoint13 } from "transformation-matrix";
|
|
76394
76403
|
import {
|
|
76404
|
+
At,
|
|
76395
76405
|
GrText,
|
|
76396
|
-
TextEffects as
|
|
76397
|
-
TextEffectsFont as
|
|
76398
|
-
TextEffectsJustify as TextEffectsJustify3
|
|
76399
|
-
At
|
|
76406
|
+
TextEffects as TextEffects6,
|
|
76407
|
+
TextEffectsFont as TextEffectsFont6,
|
|
76408
|
+
TextEffectsJustify as TextEffectsJustify3
|
|
76400
76409
|
} from "kicadts";
|
|
76401
|
-
import { applyToPoint as
|
|
76410
|
+
import { applyToPoint as applyToPoint13 } from "transformation-matrix";
|
|
76411
|
+
import { applyToPoint as applyToPoint15 } from "transformation-matrix";
|
|
76412
|
+
import {
|
|
76413
|
+
GrText as GrText2,
|
|
76414
|
+
TextEffects as TextEffects7,
|
|
76415
|
+
TextEffectsFont as TextEffectsFont7,
|
|
76416
|
+
TextEffectsJustify as TextEffectsJustify4,
|
|
76417
|
+
At as At2
|
|
76418
|
+
} from "kicadts";
|
|
76419
|
+
import { applyToPoint as applyToPoint14 } from "transformation-matrix";
|
|
76402
76420
|
import { cju as cju3 } from "@tscircuit/circuit-json-util";
|
|
76403
76421
|
import { cju as cju4 } from "@tscircuit/circuit-json-util";
|
|
76404
76422
|
import { parseKicadSexpr, KicadSch as KicadSch2 } from "kicadts";
|
|
@@ -76406,12 +76424,12 @@ import {
|
|
|
76406
76424
|
parseKicadSexpr as parseKicadSexpr2,
|
|
76407
76425
|
KicadPcb as KicadPcb2,
|
|
76408
76426
|
FootprintModel as FootprintModel2,
|
|
76409
|
-
At as
|
|
76427
|
+
At as At3,
|
|
76410
76428
|
EmbeddedFonts as EmbeddedFonts4,
|
|
76411
76429
|
FootprintAttr,
|
|
76412
76430
|
Property,
|
|
76413
|
-
TextEffects as
|
|
76414
|
-
TextEffectsFont as
|
|
76431
|
+
TextEffects as TextEffects8,
|
|
76432
|
+
TextEffectsFont as TextEffectsFont8
|
|
76415
76433
|
} from "kicadts";
|
|
76416
76434
|
import { KicadSymbolLib } from "kicadts";
|
|
76417
76435
|
import { parseKicadMod } from "kicadts";
|
|
@@ -76419,8 +76437,8 @@ import {
|
|
|
76419
76437
|
parseKicadSexpr as parseKicadSexpr3,
|
|
76420
76438
|
Footprint as Footprint3,
|
|
76421
76439
|
Property as Property2,
|
|
76422
|
-
TextEffects as
|
|
76423
|
-
TextEffectsFont as
|
|
76440
|
+
TextEffects as TextEffects9,
|
|
76441
|
+
TextEffectsFont as TextEffectsFont9
|
|
76424
76442
|
} from "kicadts";
|
|
76425
76443
|
import { parseKicadMod as parseKicadMod2 } from "kicadts";
|
|
76426
76444
|
import {
|
|
@@ -76428,9 +76446,9 @@ import {
|
|
|
76428
76446
|
SymbolPinNames as SymbolPinNames2,
|
|
76429
76447
|
SymbolPinNumbers as SymbolPinNumbers2,
|
|
76430
76448
|
SymbolProperty as SymbolProperty4,
|
|
76431
|
-
TextEffects as
|
|
76432
|
-
TextEffectsFont as
|
|
76433
|
-
TextEffectsJustify as
|
|
76449
|
+
TextEffects as TextEffects10,
|
|
76450
|
+
TextEffectsFont as TextEffectsFont10,
|
|
76451
|
+
TextEffectsJustify as TextEffectsJustify5
|
|
76434
76452
|
} from "kicadts";
|
|
76435
76453
|
import { KicadSymbolLib as KicadSymbolLib2 } from "kicadts";
|
|
76436
76454
|
var ConverterStage = class {
|
|
@@ -76684,7 +76702,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
76684
76702
|
schematicComponent,
|
|
76685
76703
|
description: this.getDescription(sourceComp),
|
|
76686
76704
|
keywords: this.getKeywords(sourceComp),
|
|
76687
|
-
fpFilters: this.getFpFilters(sourceComp),
|
|
76705
|
+
fpFilters: this.getFpFilters(sourceComp, schematicSymbol.name),
|
|
76688
76706
|
footprintRef: footprintName ? `tscircuit:${footprintName}` : "",
|
|
76689
76707
|
referencePrefix: getReferencePrefixForComponent(sourceComp)
|
|
76690
76708
|
});
|
|
@@ -76694,9 +76712,23 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
76694
76712
|
const circles = circuitJson.filter((el) => el.type === "schematic_circle" && el.schematic_symbol_id === schematicSymbolId);
|
|
76695
76713
|
const lines = circuitJson.filter((el) => el.type === "schematic_line" && el.schematic_symbol_id === schematicSymbolId);
|
|
76696
76714
|
const paths = circuitJson.filter((el) => el.type === "schematic_path" && el.schematic_symbol_id === schematicSymbolId);
|
|
76697
|
-
let ports = circuitJson.filter((el) => el.type === "schematic_port" && el.schematic_symbol_id === schematicSymbolId);
|
|
76715
|
+
let ports = circuitJson.filter((el) => el.type === "schematic_port" && ("schematic_symbol_id" in el) && el.schematic_symbol_id === schematicSymbolId);
|
|
76698
76716
|
if (ports.length === 0 && schematicComponentId) {
|
|
76699
|
-
ports = circuitJson.filter((el) => el.type === "schematic_port" && el.schematic_component_id === schematicComponentId && el.display_pin_label);
|
|
76717
|
+
ports = circuitJson.filter((el) => el.type === "schematic_port" && el.schematic_component_id === schematicComponentId && el.display_pin_label !== undefined);
|
|
76718
|
+
if (ports.length === 0) {
|
|
76719
|
+
const allPorts = circuitJson.filter((el) => el.type === "schematic_port" && el.schematic_component_id === schematicComponentId);
|
|
76720
|
+
const seenPinNumbers = /* @__PURE__ */ new Set;
|
|
76721
|
+
ports = allPorts.filter((port) => {
|
|
76722
|
+
const pinNum = port.pin_number;
|
|
76723
|
+
if (pinNum !== undefined) {
|
|
76724
|
+
if (seenPinNumbers.has(pinNum)) {
|
|
76725
|
+
return false;
|
|
76726
|
+
}
|
|
76727
|
+
seenPinNumbers.add(pinNum);
|
|
76728
|
+
}
|
|
76729
|
+
return true;
|
|
76730
|
+
});
|
|
76731
|
+
}
|
|
76700
76732
|
}
|
|
76701
76733
|
const primitives2 = [];
|
|
76702
76734
|
for (const circle of circles) {
|
|
@@ -76705,7 +76737,8 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
76705
76737
|
x: circle.center?.x ?? 0,
|
|
76706
76738
|
y: circle.center?.y ?? 0,
|
|
76707
76739
|
radius: circle.radius ?? 0.5,
|
|
76708
|
-
fill: circle.is_filled ?? false
|
|
76740
|
+
fill: circle.is_filled ?? false,
|
|
76741
|
+
fillColor: circle.fill_color
|
|
76709
76742
|
});
|
|
76710
76743
|
}
|
|
76711
76744
|
for (const line of lines) {
|
|
@@ -76721,7 +76754,9 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
76721
76754
|
if (path14.points && path14.points.length > 0) {
|
|
76722
76755
|
primitives2.push({
|
|
76723
76756
|
type: "path",
|
|
76724
|
-
points: path14.points
|
|
76757
|
+
points: path14.points,
|
|
76758
|
+
fill: path14.is_filled ?? false,
|
|
76759
|
+
fillColor: path14.fill_color
|
|
76725
76760
|
});
|
|
76726
76761
|
}
|
|
76727
76762
|
}
|
|
@@ -76931,7 +76966,10 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
76931
76966
|
return "U IC chip";
|
|
76932
76967
|
return "";
|
|
76933
76968
|
}
|
|
76934
|
-
getFpFilters(sourceComp) {
|
|
76969
|
+
getFpFilters(sourceComp, symbolName) {
|
|
76970
|
+
if (symbolName) {
|
|
76971
|
+
return `${symbolName}*`;
|
|
76972
|
+
}
|
|
76935
76973
|
if (sourceComp?.ftype === "simple_resistor")
|
|
76936
76974
|
return "R_*";
|
|
76937
76975
|
if (sourceComp?.ftype === "simple_capacitor")
|
|
@@ -76948,10 +76986,12 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
76948
76986
|
const drawingSymbol = new SchematicSymbol({
|
|
76949
76987
|
libraryId: `${libId.split(":")[1]}_0_1`
|
|
76950
76988
|
});
|
|
76951
|
-
const
|
|
76989
|
+
const GRID_ALIGNED_SCALE = 15.24;
|
|
76990
|
+
const standardScale = this.ctx.c2kMatSch?.a || 15;
|
|
76991
|
+
const symbolScale = isChip ? standardScale : GRID_ALIGNED_SCALE;
|
|
76952
76992
|
for (const primitive of symbolData.primitives || []) {
|
|
76953
76993
|
if (primitive.type === "path" && primitive.points) {
|
|
76954
|
-
const fillType = isChip ? "background" : "none";
|
|
76994
|
+
const fillType = isChip || primitive.fill ? "background" : "none";
|
|
76955
76995
|
const polyline = this.createPolylineFromPoints({
|
|
76956
76996
|
points: primitive.points,
|
|
76957
76997
|
scale: symbolScale,
|
|
@@ -77016,7 +77056,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
77016
77056
|
stroke.type = "default";
|
|
77017
77057
|
c._sxStroke = stroke;
|
|
77018
77058
|
const fill = new SymbolCircleFill;
|
|
77019
|
-
fill.type = primitive.fill ? "
|
|
77059
|
+
fill.type = primitive.fill ? "background" : "none";
|
|
77020
77060
|
c._sxFill = fill;
|
|
77021
77061
|
return circle;
|
|
77022
77062
|
}
|
|
@@ -77036,7 +77076,9 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
77036
77076
|
pin.pinGraphicStyle = "line";
|
|
77037
77077
|
const { x, y, angle } = this.calculatePinPosition(port, symbolData.center, symbolData.size, isChip, i, schematicComponent);
|
|
77038
77078
|
pin.at = [x, y, angle];
|
|
77039
|
-
|
|
77079
|
+
const CHIP_PIN_LENGTH = 6;
|
|
77080
|
+
const CUSTOM_SYMBOL_PIN_LENGTH = 2.54;
|
|
77081
|
+
pin.length = isChip ? CHIP_PIN_LENGTH : CUSTOM_SYMBOL_PIN_LENGTH;
|
|
77040
77082
|
const nameFont = new TextEffectsFont;
|
|
77041
77083
|
nameFont.size = { height: 1.27, width: 1.27 };
|
|
77042
77084
|
const nameEffects = new TextEffects({ font: nameFont });
|
|
@@ -77055,11 +77097,13 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
77055
77097
|
return pinSymbol;
|
|
77056
77098
|
}
|
|
77057
77099
|
calculatePinPosition(port, center, size, isChip, portIndex, schematicComponent) {
|
|
77058
|
-
const
|
|
77100
|
+
const GRID_ALIGNED_SCALE = 15.24;
|
|
77101
|
+
const standardScale = this.ctx.c2kMatSch?.a || 15;
|
|
77102
|
+
const symbolScale = isChip ? standardScale : GRID_ALIGNED_SCALE;
|
|
77059
77103
|
let portX = port.x ?? 0;
|
|
77060
77104
|
let portY = port.y ?? 0;
|
|
77061
77105
|
let usingCircuitJsonPort = false;
|
|
77062
|
-
if (portIndex !== undefined && schematicComponent) {
|
|
77106
|
+
if (isChip && portIndex !== undefined && schematicComponent) {
|
|
77063
77107
|
const schematicPorts = this.ctx.db.schematic_port.list().filter((p) => p.schematic_component_id === schematicComponent.schematic_component_id).sort((a, b) => (a.pin_number || 0) - (b.pin_number || 0));
|
|
77064
77108
|
if (schematicPorts[portIndex]) {
|
|
77065
77109
|
const schPort = schematicPorts[portIndex];
|
|
@@ -77093,7 +77137,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
77093
77137
|
}
|
|
77094
77138
|
let x = scaled.x;
|
|
77095
77139
|
let y = scaled.y;
|
|
77096
|
-
const
|
|
77140
|
+
const CHIP_PIN_LENGTH = 6;
|
|
77097
77141
|
if (isChip && size) {
|
|
77098
77142
|
const halfWidth = size.width / 2 * symbolScale;
|
|
77099
77143
|
const halfHeight = size.height / 2 * symbolScale;
|
|
@@ -77108,34 +77152,26 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
77108
77152
|
let angle = 0;
|
|
77109
77153
|
if (isHorizontalPin) {
|
|
77110
77154
|
if (dx > 0) {
|
|
77155
|
+
angle = 180;
|
|
77111
77156
|
if (isChip) {
|
|
77112
|
-
|
|
77113
|
-
x = x + chipPinLength;
|
|
77114
|
-
} else {
|
|
77115
|
-
angle = 0;
|
|
77157
|
+
x = x + CHIP_PIN_LENGTH;
|
|
77116
77158
|
}
|
|
77117
77159
|
} else {
|
|
77160
|
+
angle = 0;
|
|
77118
77161
|
if (isChip) {
|
|
77119
|
-
|
|
77120
|
-
x = x - chipPinLength;
|
|
77121
|
-
} else {
|
|
77122
|
-
angle = 180;
|
|
77162
|
+
x = x - CHIP_PIN_LENGTH;
|
|
77123
77163
|
}
|
|
77124
77164
|
}
|
|
77125
77165
|
} else {
|
|
77126
77166
|
if (dy > 0) {
|
|
77167
|
+
angle = 270;
|
|
77127
77168
|
if (isChip) {
|
|
77128
|
-
|
|
77129
|
-
y = y + chipPinLength;
|
|
77130
|
-
} else {
|
|
77131
|
-
angle = 90;
|
|
77169
|
+
y = y + CHIP_PIN_LENGTH;
|
|
77132
77170
|
}
|
|
77133
77171
|
} else {
|
|
77172
|
+
angle = 90;
|
|
77134
77173
|
if (isChip) {
|
|
77135
|
-
|
|
77136
|
-
y = y - chipPinLength;
|
|
77137
|
-
} else {
|
|
77138
|
-
angle = 270;
|
|
77174
|
+
y = y - CHIP_PIN_LENGTH;
|
|
77139
77175
|
}
|
|
77140
77176
|
}
|
|
77141
77177
|
}
|
|
@@ -77377,6 +77413,13 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
|
|
|
77377
77413
|
description: "Switch"
|
|
77378
77414
|
};
|
|
77379
77415
|
}
|
|
77416
|
+
if (sourceComp.ftype === "simple_potentiometer") {
|
|
77417
|
+
return {
|
|
77418
|
+
reference,
|
|
77419
|
+
value: sourceComp.display_max_resistance || "",
|
|
77420
|
+
description: "Potentiometer"
|
|
77421
|
+
};
|
|
77422
|
+
}
|
|
77380
77423
|
return {
|
|
77381
77424
|
reference,
|
|
77382
77425
|
value: name,
|
|
@@ -77781,10 +77824,13 @@ var CircuitJsonToKicadSchConverter = class {
|
|
|
77781
77824
|
};
|
|
77782
77825
|
var InitializePcbStage = class extends ConverterStage {
|
|
77783
77826
|
_step() {
|
|
77784
|
-
const { kicadPcb } = this.ctx;
|
|
77827
|
+
const { kicadPcb, db } = this.ctx;
|
|
77785
77828
|
if (!kicadPcb) {
|
|
77786
77829
|
throw new Error("KicadPcb instance not initialized in context");
|
|
77787
77830
|
}
|
|
77831
|
+
const pcbBoard = db.pcb_board?.list()?.[0];
|
|
77832
|
+
const numLayers = pcbBoard?.num_layers ?? 2;
|
|
77833
|
+
this.ctx.numLayers = numLayers;
|
|
77788
77834
|
kicadPcb.version = 20241229;
|
|
77789
77835
|
const paper = new Paper2;
|
|
77790
77836
|
paper.size = "A4";
|
|
@@ -77797,27 +77843,13 @@ var InitializePcbStage = class extends ConverterStage {
|
|
|
77797
77843
|
kicadPcb.setup = setup;
|
|
77798
77844
|
const layers = new PcbLayers;
|
|
77799
77845
|
const layerDefinitions = [
|
|
77800
|
-
new PcbLayerDefinition({ index: 0, name: "F.Cu", type: "signal" })
|
|
77801
|
-
new PcbLayerDefinition({ index: 2, name: "B.Cu", type: "signal" }),
|
|
77802
|
-
new PcbLayerDefinition({ index: 9, name: "F.Adhes", type: "user" }),
|
|
77803
|
-
new PcbLayerDefinition({ index: 11, name: "B.Adhes", type: "user" }),
|
|
77804
|
-
new PcbLayerDefinition({ index: 13, name: "F.Paste", type: "user" }),
|
|
77805
|
-
new PcbLayerDefinition({ index: 15, name: "B.Paste", type: "user" }),
|
|
77806
|
-
new PcbLayerDefinition({ index: 5, name: "F.SilkS", type: "user" }),
|
|
77807
|
-
new PcbLayerDefinition({ index: 7, name: "B.SilkS", type: "user" }),
|
|
77808
|
-
new PcbLayerDefinition({ index: 1, name: "F.Mask", type: "user" }),
|
|
77809
|
-
new PcbLayerDefinition({ index: 3, name: "B.Mask", type: "user" }),
|
|
77810
|
-
new PcbLayerDefinition({ index: 20, name: "Dwgs.User", type: "user" }),
|
|
77811
|
-
new PcbLayerDefinition({ index: 21, name: "Cmts.User", type: "user" }),
|
|
77812
|
-
new PcbLayerDefinition({ index: 22, name: "Eco1.User", type: "user" }),
|
|
77813
|
-
new PcbLayerDefinition({ index: 23, name: "Eco2.User", type: "user" }),
|
|
77814
|
-
new PcbLayerDefinition({ index: 24, name: "Edge.Cuts", type: "user" }),
|
|
77815
|
-
new PcbLayerDefinition({ index: 25, name: "Margin", type: "user" }),
|
|
77816
|
-
new PcbLayerDefinition({ index: 17, name: "B.CrtYd", type: "user" }),
|
|
77817
|
-
new PcbLayerDefinition({ index: 16, name: "F.CrtYd", type: "user" }),
|
|
77818
|
-
new PcbLayerDefinition({ index: 19, name: "B.Fab", type: "user" }),
|
|
77819
|
-
new PcbLayerDefinition({ index: 18, name: "F.Fab", type: "user" })
|
|
77846
|
+
new PcbLayerDefinition({ index: 0, name: "F.Cu", type: "signal" })
|
|
77820
77847
|
];
|
|
77848
|
+
for (let i = 1;i < numLayers - 1; i++) {
|
|
77849
|
+
layerDefinitions.push(new PcbLayerDefinition({ index: i, name: `In${i}.Cu`, type: "signal" }));
|
|
77850
|
+
}
|
|
77851
|
+
layerDefinitions.push(new PcbLayerDefinition({ index: 31, name: "B.Cu", type: "signal" }));
|
|
77852
|
+
layerDefinitions.push(new PcbLayerDefinition({ index: 32, name: "B.Adhes", type: "user" }), new PcbLayerDefinition({ index: 33, name: "F.Adhes", type: "user" }), new PcbLayerDefinition({ index: 34, name: "B.Paste", type: "user" }), new PcbLayerDefinition({ index: 35, name: "F.Paste", type: "user" }), new PcbLayerDefinition({ index: 36, name: "B.SilkS", type: "user" }), new PcbLayerDefinition({ index: 37, name: "F.SilkS", type: "user" }), new PcbLayerDefinition({ index: 38, name: "B.Mask", type: "user" }), new PcbLayerDefinition({ index: 39, name: "F.Mask", type: "user" }), new PcbLayerDefinition({ index: 40, name: "Dwgs.User", type: "user" }), new PcbLayerDefinition({ index: 41, name: "Cmts.User", type: "user" }), new PcbLayerDefinition({ index: 42, name: "Eco1.User", type: "user" }), new PcbLayerDefinition({ index: 43, name: "Eco2.User", type: "user" }), new PcbLayerDefinition({ index: 44, name: "Edge.Cuts", type: "user" }), new PcbLayerDefinition({ index: 45, name: "Margin", type: "user" }), new PcbLayerDefinition({ index: 46, name: "B.CrtYd", type: "user" }), new PcbLayerDefinition({ index: 47, name: "F.CrtYd", type: "user" }), new PcbLayerDefinition({ index: 48, name: "B.Fab", type: "user" }), new PcbLayerDefinition({ index: 49, name: "F.Fab", type: "user" }));
|
|
77821
77853
|
layers.definitions = layerDefinitions;
|
|
77822
77854
|
kicadPcb.layers = layers;
|
|
77823
77855
|
this.finished = true;
|
|
@@ -77903,6 +77935,269 @@ function generateDeterministicUuid(data) {
|
|
|
77903
77935
|
const hash = simpleHash(data);
|
|
77904
77936
|
return `${hash.slice(0, 8)}-${hash.slice(8, 12)}-${hash.slice(12, 16)}-${hash.slice(16, 20)}-${hash.slice(20, 32)}`;
|
|
77905
77937
|
}
|
|
77938
|
+
function convertSilkscreenCircles(silkscreenCircles, componentCenter) {
|
|
77939
|
+
const fpCircles = [];
|
|
77940
|
+
for (const circle of silkscreenCircles) {
|
|
77941
|
+
const relX = circle.center.x - componentCenter.x;
|
|
77942
|
+
const relY = -(circle.center.y - componentCenter.y);
|
|
77943
|
+
const layerMap = {
|
|
77944
|
+
top: "F.SilkS",
|
|
77945
|
+
bottom: "B.SilkS"
|
|
77946
|
+
};
|
|
77947
|
+
const kicadLayer = layerMap[circle.layer] || circle.layer || "F.SilkS";
|
|
77948
|
+
const fpCircle = new FpCircle({
|
|
77949
|
+
center: { x: relX, y: relY },
|
|
77950
|
+
end: { x: relX + circle.radius, y: relY },
|
|
77951
|
+
layer: kicadLayer,
|
|
77952
|
+
stroke: new Stroke3,
|
|
77953
|
+
fill: false
|
|
77954
|
+
});
|
|
77955
|
+
if (fpCircle.stroke) {
|
|
77956
|
+
fpCircle.stroke.width = circle.stroke_width || 0.05;
|
|
77957
|
+
fpCircle.stroke.type = "default";
|
|
77958
|
+
}
|
|
77959
|
+
fpCircles.push(fpCircle);
|
|
77960
|
+
}
|
|
77961
|
+
return fpCircles;
|
|
77962
|
+
}
|
|
77963
|
+
function convertCourtyardCircles(courtyardCircles, componentCenter) {
|
|
77964
|
+
const fpCircles = [];
|
|
77965
|
+
for (const circle of courtyardCircles) {
|
|
77966
|
+
const relX = circle.center.x - componentCenter.x;
|
|
77967
|
+
const relY = -(circle.center.y - componentCenter.y);
|
|
77968
|
+
const layerMap = {
|
|
77969
|
+
top: "F.CrtYd",
|
|
77970
|
+
bottom: "B.CrtYd"
|
|
77971
|
+
};
|
|
77972
|
+
const kicadLayer = layerMap[circle.layer] || "F.CrtYd";
|
|
77973
|
+
const fpCircle = new FpCircle2({
|
|
77974
|
+
center: { x: relX, y: relY },
|
|
77975
|
+
end: { x: relX + circle.radius, y: relY },
|
|
77976
|
+
layer: kicadLayer,
|
|
77977
|
+
stroke: new Stroke4,
|
|
77978
|
+
fill: false
|
|
77979
|
+
});
|
|
77980
|
+
if (fpCircle.stroke) {
|
|
77981
|
+
fpCircle.stroke.width = 0.05;
|
|
77982
|
+
fpCircle.stroke.type = "default";
|
|
77983
|
+
}
|
|
77984
|
+
fpCircles.push(fpCircle);
|
|
77985
|
+
}
|
|
77986
|
+
return fpCircles;
|
|
77987
|
+
}
|
|
77988
|
+
function convertFabricationNoteRects(fabRects, componentCenter) {
|
|
77989
|
+
const fpRects = [];
|
|
77990
|
+
for (const rect of fabRects) {
|
|
77991
|
+
const relX = rect.center.x - componentCenter.x;
|
|
77992
|
+
const relY = -(rect.center.y - componentCenter.y);
|
|
77993
|
+
const halfW = rect.width / 2;
|
|
77994
|
+
const halfH = rect.height / 2;
|
|
77995
|
+
const layerMap = {
|
|
77996
|
+
top: "F.Fab",
|
|
77997
|
+
bottom: "B.Fab"
|
|
77998
|
+
};
|
|
77999
|
+
const kicadLayer = layerMap[rect.layer] || rect.layer || "F.Fab";
|
|
78000
|
+
const fpRect = new FpRect({
|
|
78001
|
+
start: { x: relX - halfW, y: relY - halfH },
|
|
78002
|
+
end: { x: relX + halfW, y: relY + halfH },
|
|
78003
|
+
layer: kicadLayer,
|
|
78004
|
+
stroke: new Stroke5,
|
|
78005
|
+
fill: false
|
|
78006
|
+
});
|
|
78007
|
+
if (fpRect.stroke) {
|
|
78008
|
+
fpRect.stroke.width = rect.stroke_width || 0.1;
|
|
78009
|
+
fpRect.stroke.type = "default";
|
|
78010
|
+
}
|
|
78011
|
+
fpRects.push(fpRect);
|
|
78012
|
+
}
|
|
78013
|
+
return fpRects;
|
|
78014
|
+
}
|
|
78015
|
+
function convertNoteRects(noteRects, componentCenter) {
|
|
78016
|
+
const fpRects = [];
|
|
78017
|
+
for (const rect of noteRects) {
|
|
78018
|
+
const relX = rect.center.x - componentCenter.x;
|
|
78019
|
+
const relY = -(rect.center.y - componentCenter.y);
|
|
78020
|
+
const halfW = rect.width / 2;
|
|
78021
|
+
const halfH = rect.height / 2;
|
|
78022
|
+
const kicadLayer = "F.Fab";
|
|
78023
|
+
const fpRect = new FpRect2({
|
|
78024
|
+
start: { x: relX - halfW, y: relY - halfH },
|
|
78025
|
+
end: { x: relX + halfW, y: relY + halfH },
|
|
78026
|
+
layer: kicadLayer,
|
|
78027
|
+
stroke: new Stroke6,
|
|
78028
|
+
fill: false
|
|
78029
|
+
});
|
|
78030
|
+
if (fpRect.stroke) {
|
|
78031
|
+
fpRect.stroke.width = rect.stroke_width || 0.1;
|
|
78032
|
+
fpRect.stroke.type = "default";
|
|
78033
|
+
}
|
|
78034
|
+
fpRects.push(fpRect);
|
|
78035
|
+
}
|
|
78036
|
+
return fpRects;
|
|
78037
|
+
}
|
|
78038
|
+
function convertCourtyardRects(courtyardRects, componentCenter) {
|
|
78039
|
+
const fpRects = [];
|
|
78040
|
+
for (const rect of courtyardRects) {
|
|
78041
|
+
const relX = rect.center.x - componentCenter.x;
|
|
78042
|
+
const relY = -(rect.center.y - componentCenter.y);
|
|
78043
|
+
const halfW = rect.width / 2;
|
|
78044
|
+
const halfH = rect.height / 2;
|
|
78045
|
+
const layerMap = {
|
|
78046
|
+
top: "F.CrtYd",
|
|
78047
|
+
bottom: "B.CrtYd"
|
|
78048
|
+
};
|
|
78049
|
+
const kicadLayer = layerMap[rect.layer] || "F.CrtYd";
|
|
78050
|
+
const fpRect = new FpRect3({
|
|
78051
|
+
start: { x: relX - halfW, y: relY - halfH },
|
|
78052
|
+
end: { x: relX + halfW, y: relY + halfH },
|
|
78053
|
+
layer: kicadLayer,
|
|
78054
|
+
stroke: new Stroke7,
|
|
78055
|
+
fill: false
|
|
78056
|
+
});
|
|
78057
|
+
if (fpRect.stroke) {
|
|
78058
|
+
fpRect.stroke.width = 0.05;
|
|
78059
|
+
fpRect.stroke.type = "default";
|
|
78060
|
+
}
|
|
78061
|
+
fpRects.push(fpRect);
|
|
78062
|
+
}
|
|
78063
|
+
return fpRects;
|
|
78064
|
+
}
|
|
78065
|
+
function convertCourtyardOutlines(courtyardOutlines, componentCenter) {
|
|
78066
|
+
const fpPolys = [];
|
|
78067
|
+
for (const outline of courtyardOutlines) {
|
|
78068
|
+
if (!outline.outline || outline.outline.length < 2)
|
|
78069
|
+
continue;
|
|
78070
|
+
const layerMap = {
|
|
78071
|
+
top: "F.CrtYd",
|
|
78072
|
+
bottom: "B.CrtYd"
|
|
78073
|
+
};
|
|
78074
|
+
const kicadLayer = layerMap[outline.layer] || "F.CrtYd";
|
|
78075
|
+
const xyPoints = outline.outline.map((point) => {
|
|
78076
|
+
const relX = point.x - componentCenter.x;
|
|
78077
|
+
const relY = -(point.y - componentCenter.y);
|
|
78078
|
+
return new Xy3(relX, relY);
|
|
78079
|
+
});
|
|
78080
|
+
const fpPoly = new FpPoly;
|
|
78081
|
+
fpPoly.points = new Pts3(xyPoints);
|
|
78082
|
+
fpPoly.layer = kicadLayer;
|
|
78083
|
+
fpPoly.fill = false;
|
|
78084
|
+
const stroke = new Stroke8;
|
|
78085
|
+
stroke.width = 0.05;
|
|
78086
|
+
stroke.type = "default";
|
|
78087
|
+
fpPoly.stroke = stroke;
|
|
78088
|
+
fpPolys.push(fpPoly);
|
|
78089
|
+
}
|
|
78090
|
+
return fpPolys;
|
|
78091
|
+
}
|
|
78092
|
+
function createFpTextFromCircuitJson({
|
|
78093
|
+
textElement,
|
|
78094
|
+
componentCenter,
|
|
78095
|
+
componentRotation = 0
|
|
78096
|
+
}) {
|
|
78097
|
+
if (!textElement.text || !textElement.anchor_position) {
|
|
78098
|
+
return null;
|
|
78099
|
+
}
|
|
78100
|
+
const relativeX = textElement.anchor_position.x - componentCenter.x;
|
|
78101
|
+
const relativeY = -(textElement.anchor_position.y - componentCenter.y);
|
|
78102
|
+
const rotationMatrix = componentRotation !== 0 ? rotate(componentRotation * Math.PI / 180) : identity();
|
|
78103
|
+
const rotatedPos = applyToPoint5(rotationMatrix, {
|
|
78104
|
+
x: relativeX,
|
|
78105
|
+
y: relativeY
|
|
78106
|
+
});
|
|
78107
|
+
const relativePosition = {
|
|
78108
|
+
x: rotatedPos.x,
|
|
78109
|
+
y: rotatedPos.y
|
|
78110
|
+
};
|
|
78111
|
+
const layerMap = {
|
|
78112
|
+
top: "F.SilkS",
|
|
78113
|
+
bottom: "B.SilkS"
|
|
78114
|
+
};
|
|
78115
|
+
const kicadLayer = layerMap[textElement.layer] || textElement.layer || "F.SilkS";
|
|
78116
|
+
const fontSize = (textElement.font_size || 1) / 1.5;
|
|
78117
|
+
const font = new TextEffectsFont4;
|
|
78118
|
+
font.size = { width: fontSize, height: fontSize };
|
|
78119
|
+
const textEffects = new TextEffects4({
|
|
78120
|
+
font
|
|
78121
|
+
});
|
|
78122
|
+
const rotation = textElement.ccw_rotation || 0;
|
|
78123
|
+
return new FpText({
|
|
78124
|
+
type: "user",
|
|
78125
|
+
text: textElement.text,
|
|
78126
|
+
position: {
|
|
78127
|
+
x: relativePosition.x,
|
|
78128
|
+
y: relativePosition.y,
|
|
78129
|
+
angle: rotation
|
|
78130
|
+
},
|
|
78131
|
+
layer: kicadLayer,
|
|
78132
|
+
effects: textEffects
|
|
78133
|
+
});
|
|
78134
|
+
}
|
|
78135
|
+
function convertSilkscreenTexts(silkscreenTexts, componentCenter, componentRotation, sourceComponentName) {
|
|
78136
|
+
const fpTexts = [];
|
|
78137
|
+
for (const textElement of silkscreenTexts) {
|
|
78138
|
+
const fpText = createFpTextFromCircuitJson({
|
|
78139
|
+
textElement,
|
|
78140
|
+
componentCenter,
|
|
78141
|
+
componentRotation
|
|
78142
|
+
});
|
|
78143
|
+
if (fpText) {
|
|
78144
|
+
if (sourceComponentName && textElement.text === sourceComponentName) {
|
|
78145
|
+
fpText.type = "reference";
|
|
78146
|
+
}
|
|
78147
|
+
fpTexts.push(fpText);
|
|
78148
|
+
}
|
|
78149
|
+
}
|
|
78150
|
+
return fpTexts;
|
|
78151
|
+
}
|
|
78152
|
+
function convertNoteTexts(noteTexts, componentCenter, componentRotation) {
|
|
78153
|
+
const fpTexts = [];
|
|
78154
|
+
for (const textElement of noteTexts) {
|
|
78155
|
+
const relX = textElement.anchor_position.x - componentCenter.x;
|
|
78156
|
+
const relY = -(textElement.anchor_position.y - componentCenter.y);
|
|
78157
|
+
const rotationMatrix = componentRotation !== 0 ? rotate2(componentRotation * Math.PI / 180) : identity2();
|
|
78158
|
+
const rotatedPos = applyToPoint6(rotationMatrix, { x: relX, y: relY });
|
|
78159
|
+
const fontSize = textElement.font_size || 1;
|
|
78160
|
+
const font = new TextEffectsFont5;
|
|
78161
|
+
font.size = { width: fontSize, height: fontSize };
|
|
78162
|
+
const textEffects = new TextEffects5({ font });
|
|
78163
|
+
const fpText = new FpText3({
|
|
78164
|
+
type: "user",
|
|
78165
|
+
text: textElement.text,
|
|
78166
|
+
position: { x: rotatedPos.x, y: rotatedPos.y, angle: 0 },
|
|
78167
|
+
layer: "F.Fab",
|
|
78168
|
+
effects: textEffects
|
|
78169
|
+
});
|
|
78170
|
+
fpTexts.push(fpText);
|
|
78171
|
+
}
|
|
78172
|
+
return fpTexts;
|
|
78173
|
+
}
|
|
78174
|
+
function create3DModelsFromCadComponent(cadComponent, componentCenter) {
|
|
78175
|
+
const models = [];
|
|
78176
|
+
const modelUrl = cadComponent.model_step_url || cadComponent.model_wrl_url;
|
|
78177
|
+
if (!modelUrl)
|
|
78178
|
+
return models;
|
|
78179
|
+
const model = new FootprintModel(modelUrl);
|
|
78180
|
+
if (cadComponent.position) {
|
|
78181
|
+
model.offset = {
|
|
78182
|
+
x: (cadComponent.position.x || 0) - componentCenter.x,
|
|
78183
|
+
y: -((cadComponent.position.y || 0) - componentCenter.y),
|
|
78184
|
+
z: cadComponent.position.z || 0
|
|
78185
|
+
};
|
|
78186
|
+
}
|
|
78187
|
+
if (cadComponent.rotation) {
|
|
78188
|
+
model.rotate = {
|
|
78189
|
+
x: cadComponent.rotation.x || 0,
|
|
78190
|
+
y: cadComponent.rotation.y || 0,
|
|
78191
|
+
z: cadComponent.rotation.z || 0
|
|
78192
|
+
};
|
|
78193
|
+
}
|
|
78194
|
+
if (cadComponent.model_unit_to_mm_scale_factor) {
|
|
78195
|
+
const scale4 = cadComponent.model_unit_to_mm_scale_factor;
|
|
78196
|
+
model.scale = { x: scale4, y: scale4, z: scale4 };
|
|
78197
|
+
}
|
|
78198
|
+
models.push(model);
|
|
78199
|
+
return models;
|
|
78200
|
+
}
|
|
77906
78201
|
function createSmdPadFromCircuitJson({
|
|
77907
78202
|
pcbPad,
|
|
77908
78203
|
componentCenter,
|
|
@@ -77923,8 +78218,8 @@ function createSmdPadFromCircuitJson({
|
|
|
77923
78218
|
} else {
|
|
77924
78219
|
throw new Error("Pad must have either x/y coordinates or points array");
|
|
77925
78220
|
}
|
|
77926
|
-
const cj2kicadMatrix = compose2(componentRotation !== 0 ?
|
|
77927
|
-
const rotatedPos =
|
|
78221
|
+
const cj2kicadMatrix = compose2(componentRotation !== 0 ? rotate3(componentRotation * Math.PI / 180) : { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }, scale2(1, -1), translate2(-componentCenter.x, -componentCenter.y));
|
|
78222
|
+
const rotatedPos = applyToPoint7(cj2kicadMatrix, {
|
|
77928
78223
|
x: padX,
|
|
77929
78224
|
y: padY
|
|
77930
78225
|
});
|
|
@@ -77947,11 +78242,11 @@ function createSmdPadFromCircuitJson({
|
|
|
77947
78242
|
const points = pcbPad.points;
|
|
77948
78243
|
const pointTransformMatrix = compose2(scale2(1, -1), translate2(-padX, -padY));
|
|
77949
78244
|
const relativePoints = points.map((p) => {
|
|
77950
|
-
const transformed =
|
|
77951
|
-
return new
|
|
78245
|
+
const transformed = applyToPoint7(pointTransformMatrix, { x: p.x, y: p.y });
|
|
78246
|
+
return new Xy4(transformed.x, transformed.y);
|
|
77952
78247
|
});
|
|
77953
78248
|
const grPoly = new PadPrimitiveGrPoly;
|
|
77954
|
-
grPoly.contours = [new
|
|
78249
|
+
grPoly.contours = [new Pts4(relativePoints)];
|
|
77955
78250
|
grPoly.width = 0;
|
|
77956
78251
|
grPoly.filled = true;
|
|
77957
78252
|
padPrimitives = new PadPrimitives;
|
|
@@ -77992,6 +78287,24 @@ function createSmdPadFromCircuitJson({
|
|
|
77992
78287
|
}
|
|
77993
78288
|
return pad;
|
|
77994
78289
|
}
|
|
78290
|
+
function convertSmdPads(pcbPads, componentCenter, componentRotation, componentId, startPadNumber, getNetInfo) {
|
|
78291
|
+
const pads = [];
|
|
78292
|
+
let padNumber = startPadNumber;
|
|
78293
|
+
for (const pcbPad of pcbPads) {
|
|
78294
|
+
const netInfo = getNetInfo(pcbPad.pcb_port_id);
|
|
78295
|
+
const pad = createSmdPadFromCircuitJson({
|
|
78296
|
+
pcbPad,
|
|
78297
|
+
componentCenter,
|
|
78298
|
+
padNumber,
|
|
78299
|
+
componentRotation,
|
|
78300
|
+
netInfo,
|
|
78301
|
+
componentId
|
|
78302
|
+
});
|
|
78303
|
+
pads.push(pad);
|
|
78304
|
+
padNumber++;
|
|
78305
|
+
}
|
|
78306
|
+
return { pads, nextPadNumber: padNumber };
|
|
78307
|
+
}
|
|
77995
78308
|
function createThruHolePadFromCircuitJson({
|
|
77996
78309
|
platedHole,
|
|
77997
78310
|
componentCenter,
|
|
@@ -78005,8 +78318,8 @@ function createThruHolePadFromCircuitJson({
|
|
|
78005
78318
|
}
|
|
78006
78319
|
const relativeX = platedHole.x - componentCenter.x;
|
|
78007
78320
|
const relativeY = -(platedHole.y - componentCenter.y);
|
|
78008
|
-
const rotationMatrix = componentRotation !== 0 ?
|
|
78009
|
-
const rotatedPos =
|
|
78321
|
+
const rotationMatrix = componentRotation !== 0 ? rotate4(componentRotation * Math.PI / 180) : identity3();
|
|
78322
|
+
const rotatedPos = applyToPoint8(rotationMatrix, {
|
|
78010
78323
|
x: relativeX,
|
|
78011
78324
|
y: relativeY
|
|
78012
78325
|
});
|
|
@@ -78022,7 +78335,7 @@ function createThruHolePadFromCircuitJson({
|
|
|
78022
78335
|
y: platedHole.hole_offset_y ?? 0
|
|
78023
78336
|
};
|
|
78024
78337
|
if (rawOffset.x !== 0 || rawOffset.y !== 0) {
|
|
78025
|
-
const rotatedOffset =
|
|
78338
|
+
const rotatedOffset = applyToPoint8(rotationMatrix, {
|
|
78026
78339
|
x: -rawOffset.x,
|
|
78027
78340
|
y: rawOffset.y
|
|
78028
78341
|
});
|
|
@@ -78105,6 +78418,26 @@ function createThruHolePadFromCircuitJson({
|
|
|
78105
78418
|
}
|
|
78106
78419
|
return pad;
|
|
78107
78420
|
}
|
|
78421
|
+
function convertPlatedHoles(platedHoles, componentCenter, componentRotation, componentId, startPadNumber, getNetInfo) {
|
|
78422
|
+
const pads = [];
|
|
78423
|
+
let padNumber = startPadNumber;
|
|
78424
|
+
for (const platedHole of platedHoles) {
|
|
78425
|
+
const netInfo = getNetInfo(platedHole.pcb_port_id);
|
|
78426
|
+
const pad = createThruHolePadFromCircuitJson({
|
|
78427
|
+
platedHole,
|
|
78428
|
+
componentCenter,
|
|
78429
|
+
padNumber,
|
|
78430
|
+
componentRotation,
|
|
78431
|
+
netInfo,
|
|
78432
|
+
componentId
|
|
78433
|
+
});
|
|
78434
|
+
if (pad) {
|
|
78435
|
+
pads.push(pad);
|
|
78436
|
+
padNumber++;
|
|
78437
|
+
}
|
|
78438
|
+
}
|
|
78439
|
+
return { pads, nextPadNumber: padNumber };
|
|
78440
|
+
}
|
|
78108
78441
|
function createNpthPadFromCircuitJson({
|
|
78109
78442
|
pcbHole,
|
|
78110
78443
|
componentCenter,
|
|
@@ -78115,8 +78448,8 @@ function createNpthPadFromCircuitJson({
|
|
|
78115
78448
|
}
|
|
78116
78449
|
const relativeX = pcbHole.x - componentCenter.x;
|
|
78117
78450
|
const relativeY = -(pcbHole.y - componentCenter.y);
|
|
78118
|
-
const rotationMatrix = componentRotation !== 0 ?
|
|
78119
|
-
const rotatedPos =
|
|
78451
|
+
const rotationMatrix = componentRotation !== 0 ? rotate5(componentRotation * Math.PI / 180) : identity4();
|
|
78452
|
+
const rotatedPos = applyToPoint9(rotationMatrix, {
|
|
78120
78453
|
x: relativeX,
|
|
78121
78454
|
y: relativeY
|
|
78122
78455
|
});
|
|
@@ -78158,48 +78491,19 @@ function createNpthPadFromCircuitJson({
|
|
|
78158
78491
|
uuid: crypto.randomUUID()
|
|
78159
78492
|
});
|
|
78160
78493
|
}
|
|
78161
|
-
function
|
|
78162
|
-
|
|
78163
|
-
|
|
78164
|
-
|
|
78165
|
-
|
|
78166
|
-
|
|
78167
|
-
|
|
78494
|
+
function convertNpthHoles(pcbHoles, componentCenter, componentRotation) {
|
|
78495
|
+
const pads = [];
|
|
78496
|
+
for (const pcbHole of pcbHoles) {
|
|
78497
|
+
const pad = createNpthPadFromCircuitJson({
|
|
78498
|
+
pcbHole,
|
|
78499
|
+
componentCenter,
|
|
78500
|
+
componentRotation
|
|
78501
|
+
});
|
|
78502
|
+
if (pad) {
|
|
78503
|
+
pads.push(pad);
|
|
78504
|
+
}
|
|
78168
78505
|
}
|
|
78169
|
-
|
|
78170
|
-
const relativeY = -(textElement.anchor_position.y - componentCenter.y);
|
|
78171
|
-
const rotationMatrix = componentRotation !== 0 ? rotate4(componentRotation * Math.PI / 180) : identity3();
|
|
78172
|
-
const rotatedPos = applyToPoint8(rotationMatrix, {
|
|
78173
|
-
x: relativeX,
|
|
78174
|
-
y: relativeY
|
|
78175
|
-
});
|
|
78176
|
-
const relativePosition = {
|
|
78177
|
-
x: rotatedPos.x,
|
|
78178
|
-
y: rotatedPos.y
|
|
78179
|
-
};
|
|
78180
|
-
const layerMap = {
|
|
78181
|
-
top: "F.SilkS",
|
|
78182
|
-
bottom: "B.SilkS"
|
|
78183
|
-
};
|
|
78184
|
-
const kicadLayer = layerMap[textElement.layer] || textElement.layer || "F.SilkS";
|
|
78185
|
-
const fontSize = (textElement.font_size || 1) / 1.5;
|
|
78186
|
-
const font = new TextEffectsFont4;
|
|
78187
|
-
font.size = { width: fontSize, height: fontSize };
|
|
78188
|
-
const textEffects = new TextEffects4({
|
|
78189
|
-
font
|
|
78190
|
-
});
|
|
78191
|
-
const rotation = textElement.ccw_rotation || 0;
|
|
78192
|
-
return new FpText({
|
|
78193
|
-
type: "user",
|
|
78194
|
-
text: textElement.text,
|
|
78195
|
-
position: {
|
|
78196
|
-
x: relativePosition.x,
|
|
78197
|
-
y: relativePosition.y,
|
|
78198
|
-
angle: rotation
|
|
78199
|
-
},
|
|
78200
|
-
layer: kicadLayer,
|
|
78201
|
-
effects: textEffects
|
|
78202
|
-
});
|
|
78506
|
+
return pads;
|
|
78203
78507
|
}
|
|
78204
78508
|
var AddFootprintsStage = class extends ConverterStage {
|
|
78205
78509
|
componentsProcessed = 0;
|
|
@@ -78225,33 +78529,6 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
78225
78529
|
const cadComponents = this.ctx.db.cad_component?.list() || [];
|
|
78226
78530
|
return cadComponents.find((cad) => cad.pcb_component_id === pcbComponentId);
|
|
78227
78531
|
}
|
|
78228
|
-
create3DModelsFromCadComponent(cadComponent, componentCenter) {
|
|
78229
|
-
const models = [];
|
|
78230
|
-
const modelUrl = cadComponent.model_step_url || cadComponent.model_wrl_url;
|
|
78231
|
-
if (!modelUrl)
|
|
78232
|
-
return models;
|
|
78233
|
-
const model = new FootprintModel(modelUrl);
|
|
78234
|
-
if (cadComponent.position) {
|
|
78235
|
-
model.offset = {
|
|
78236
|
-
x: (cadComponent.position.x || 0) - componentCenter.x,
|
|
78237
|
-
y: -((cadComponent.position.y || 0) - componentCenter.y),
|
|
78238
|
-
z: cadComponent.position.z || 0
|
|
78239
|
-
};
|
|
78240
|
-
}
|
|
78241
|
-
if (cadComponent.rotation) {
|
|
78242
|
-
model.rotate = {
|
|
78243
|
-
x: cadComponent.rotation.x || 0,
|
|
78244
|
-
y: cadComponent.rotation.y || 0,
|
|
78245
|
-
z: cadComponent.rotation.z || 0
|
|
78246
|
-
};
|
|
78247
|
-
}
|
|
78248
|
-
if (cadComponent.model_unit_to_mm_scale_factor) {
|
|
78249
|
-
const scale4 = cadComponent.model_unit_to_mm_scale_factor;
|
|
78250
|
-
model.scale = { x: scale4, y: scale4, z: scale4 };
|
|
78251
|
-
}
|
|
78252
|
-
models.push(model);
|
|
78253
|
-
return models;
|
|
78254
|
-
}
|
|
78255
78532
|
constructor(input, ctx) {
|
|
78256
78533
|
super(input, ctx);
|
|
78257
78534
|
this.pcbComponents = this.ctx.db.pcb_component.list();
|
|
@@ -78272,7 +78549,7 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
78272
78549
|
const sourceComponent = component.source_component_id ? this.ctx.db.source_component.get(component.source_component_id) : null;
|
|
78273
78550
|
const cadComponent = this.getCadComponentForPcbComponent(component.pcb_component_id);
|
|
78274
78551
|
const footprintName = sourceComponent ? getKicadCompatibleComponentName(sourceComponent, cadComponent) : "Unknown";
|
|
78275
|
-
const transformedPos =
|
|
78552
|
+
const transformedPos = applyToPoint10(c2kMatPcb, {
|
|
78276
78553
|
x: component.center.x,
|
|
78277
78554
|
y: component.center.y
|
|
78278
78555
|
});
|
|
@@ -78285,66 +78562,43 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
78285
78562
|
});
|
|
78286
78563
|
const fpTexts = footprint.fpTexts;
|
|
78287
78564
|
const pcbSilkscreenTexts = this.ctx.db.pcb_silkscreen_text?.list().filter((text) => text.pcb_component_id === component.pcb_component_id) || [];
|
|
78288
|
-
|
|
78289
|
-
|
|
78290
|
-
|
|
78291
|
-
componentCenter: component.center,
|
|
78292
|
-
componentRotation: component.rotation || 0
|
|
78293
|
-
});
|
|
78294
|
-
if (fpText) {
|
|
78295
|
-
if (sourceComponent?.name && textElement.text === sourceComponent.name) {
|
|
78296
|
-
fpText.type = "reference";
|
|
78297
|
-
}
|
|
78298
|
-
fpTexts.push(fpText);
|
|
78299
|
-
}
|
|
78300
|
-
}
|
|
78565
|
+
fpTexts.push(...convertSilkscreenTexts(pcbSilkscreenTexts, component.center, component.rotation || 0, sourceComponent?.name));
|
|
78566
|
+
const pcbNoteTexts = this.ctx.db.pcb_note_text?.list().filter((text) => text.pcb_component_id === component.pcb_component_id) || [];
|
|
78567
|
+
fpTexts.push(...convertNoteTexts(pcbNoteTexts, component.center, component.rotation || 0));
|
|
78301
78568
|
footprint.fpTexts = fpTexts;
|
|
78302
|
-
const pcbPads = this.ctx.db.pcb_smtpad?.list().filter((pad) => pad.pcb_component_id === component.pcb_component_id) || [];
|
|
78303
78569
|
const fpPads = footprint.fpPads;
|
|
78304
|
-
|
|
78305
|
-
|
|
78306
|
-
|
|
78307
|
-
|
|
78308
|
-
pcbPad,
|
|
78309
|
-
componentCenter: component.center,
|
|
78310
|
-
padNumber,
|
|
78311
|
-
componentRotation: component.rotation || 0,
|
|
78312
|
-
netInfo,
|
|
78313
|
-
componentId: component.pcb_component_id
|
|
78314
|
-
});
|
|
78315
|
-
fpPads.push(pad);
|
|
78316
|
-
padNumber++;
|
|
78317
|
-
}
|
|
78570
|
+
const getNetInfo = (pcbPortId) => this.getNetInfoForPcbPort(pcbPortId);
|
|
78571
|
+
const pcbPads = this.ctx.db.pcb_smtpad?.list().filter((pad) => pad.pcb_component_id === component.pcb_component_id) || [];
|
|
78572
|
+
const { pads: smdPads, nextPadNumber } = convertSmdPads(pcbPads, component.center, component.rotation || 0, component.pcb_component_id, 1, getNetInfo);
|
|
78573
|
+
fpPads.push(...smdPads);
|
|
78318
78574
|
const pcbPlatedHoles = this.ctx.db.pcb_plated_hole?.list().filter((hole) => hole.pcb_component_id === component.pcb_component_id) || [];
|
|
78319
|
-
|
|
78320
|
-
|
|
78321
|
-
const pad = createThruHolePadFromCircuitJson({
|
|
78322
|
-
platedHole,
|
|
78323
|
-
componentCenter: component.center,
|
|
78324
|
-
padNumber,
|
|
78325
|
-
componentRotation: component.rotation || 0,
|
|
78326
|
-
netInfo,
|
|
78327
|
-
componentId: component.pcb_component_id
|
|
78328
|
-
});
|
|
78329
|
-
if (pad) {
|
|
78330
|
-
fpPads.push(pad);
|
|
78331
|
-
padNumber++;
|
|
78332
|
-
}
|
|
78333
|
-
}
|
|
78575
|
+
const { pads: thruHolePads } = convertPlatedHoles(pcbPlatedHoles, component.center, component.rotation || 0, component.pcb_component_id, nextPadNumber, getNetInfo);
|
|
78576
|
+
fpPads.push(...thruHolePads);
|
|
78334
78577
|
const pcbHoles = this.ctx.db.pcb_hole?.list().filter((hole) => hole.subcircuit_id === component.subcircuit_id) || [];
|
|
78335
|
-
|
|
78336
|
-
|
|
78337
|
-
pcbHole,
|
|
78338
|
-
componentCenter: component.center,
|
|
78339
|
-
componentRotation: component.rotation || 0
|
|
78340
|
-
});
|
|
78341
|
-
if (pad) {
|
|
78342
|
-
fpPads.push(pad);
|
|
78343
|
-
}
|
|
78344
|
-
}
|
|
78578
|
+
const npthPads = convertNpthHoles(pcbHoles, component.center, component.rotation || 0);
|
|
78579
|
+
fpPads.push(...npthPads);
|
|
78345
78580
|
footprint.fpPads = fpPads;
|
|
78581
|
+
const pcbSilkscreenCircles = this.ctx.db.pcb_silkscreen_circle?.list().filter((circle) => circle.pcb_component_id === component.pcb_component_id) || [];
|
|
78582
|
+
const fpCircles = footprint.fpCircles ?? [];
|
|
78583
|
+
fpCircles.push(...convertSilkscreenCircles(pcbSilkscreenCircles, component.center));
|
|
78584
|
+
const pcbCourtyardCircles = this.ctx.db.pcb_courtyard_circle?.list().filter((circle) => circle.pcb_component_id === component.pcb_component_id) || [];
|
|
78585
|
+
fpCircles.push(...convertCourtyardCircles(pcbCourtyardCircles, component.center));
|
|
78586
|
+
footprint.fpCircles = fpCircles;
|
|
78587
|
+
const pcbFabRects = this.ctx.db.pcb_fabrication_note_rect?.list().filter((rect) => rect.pcb_component_id === component.pcb_component_id) || [];
|
|
78588
|
+
const fpRects = footprint.fpRects ?? [];
|
|
78589
|
+
fpRects.push(...convertFabricationNoteRects(pcbFabRects, component.center));
|
|
78590
|
+
const pcbNoteRects = this.ctx.db.pcb_note_rect?.list().filter((rect) => rect.pcb_component_id === component.pcb_component_id) || [];
|
|
78591
|
+
fpRects.push(...convertNoteRects(pcbNoteRects, component.center));
|
|
78592
|
+
const pcbCourtyardRects = this.ctx.db.pcb_courtyard_rect?.list().filter((rect) => rect.pcb_component_id === component.pcb_component_id) || [];
|
|
78593
|
+
fpRects.push(...convertCourtyardRects(pcbCourtyardRects, component.center));
|
|
78594
|
+
footprint.fpRects = fpRects;
|
|
78595
|
+
const pcbCourtyardOutlines = this.ctx.db.pcb_courtyard_outline?.list().filter((outline) => outline.pcb_component_id === component.pcb_component_id) || [];
|
|
78596
|
+
const fpPolys = convertCourtyardOutlines(pcbCourtyardOutlines, component.center);
|
|
78597
|
+
if (fpPolys.length > 0) {
|
|
78598
|
+
footprint.fpPolys = fpPolys;
|
|
78599
|
+
}
|
|
78346
78600
|
if (cadComponent) {
|
|
78347
|
-
const models =
|
|
78601
|
+
const models = create3DModelsFromCadComponent(cadComponent, component.center);
|
|
78348
78602
|
if (models.length > 0) {
|
|
78349
78603
|
footprint.models = models;
|
|
78350
78604
|
}
|
|
@@ -78358,6 +78612,29 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
78358
78612
|
return this.ctx.kicadPcb;
|
|
78359
78613
|
}
|
|
78360
78614
|
};
|
|
78615
|
+
var circuitJsonLayerToKicadLayer = {
|
|
78616
|
+
top: "F.Cu",
|
|
78617
|
+
bottom: "B.Cu",
|
|
78618
|
+
inner1: "In1.Cu",
|
|
78619
|
+
inner2: "In2.Cu",
|
|
78620
|
+
inner3: "In3.Cu",
|
|
78621
|
+
inner4: "In4.Cu",
|
|
78622
|
+
inner5: "In5.Cu",
|
|
78623
|
+
inner6: "In6.Cu"
|
|
78624
|
+
};
|
|
78625
|
+
function getKicadLayer(circuitJsonLayer) {
|
|
78626
|
+
if (!circuitJsonLayer)
|
|
78627
|
+
return "F.Cu";
|
|
78628
|
+
return circuitJsonLayerToKicadLayer[circuitJsonLayer] || circuitJsonLayer || "F.Cu";
|
|
78629
|
+
}
|
|
78630
|
+
function getViaLayers(numLayers) {
|
|
78631
|
+
const layers = ["F.Cu"];
|
|
78632
|
+
for (let i = 1;i < numLayers - 1; i++) {
|
|
78633
|
+
layers.push(`In${i}.Cu`);
|
|
78634
|
+
}
|
|
78635
|
+
layers.push("B.Cu");
|
|
78636
|
+
return layers;
|
|
78637
|
+
}
|
|
78361
78638
|
var AddTracesStage = class extends ConverterStage {
|
|
78362
78639
|
tracesProcessed = 0;
|
|
78363
78640
|
pcbTraces = [];
|
|
@@ -78382,14 +78659,15 @@ var AddTracesStage = class extends ConverterStage {
|
|
|
78382
78659
|
this.tracesProcessed++;
|
|
78383
78660
|
return;
|
|
78384
78661
|
}
|
|
78662
|
+
let lastKnownLayer = trace.route[0]?.layer;
|
|
78385
78663
|
for (let i = 0;i < trace.route.length - 1; i++) {
|
|
78386
78664
|
const startPoint = trace.route[i];
|
|
78387
78665
|
const endPoint = trace.route[i + 1];
|
|
78388
|
-
const transformedStart =
|
|
78666
|
+
const transformedStart = applyToPoint11(c2kMatPcb, {
|
|
78389
78667
|
x: startPoint.x,
|
|
78390
78668
|
y: startPoint.y
|
|
78391
78669
|
});
|
|
78392
|
-
const transformedEnd =
|
|
78670
|
+
const transformedEnd = applyToPoint11(c2kMatPcb, {
|
|
78393
78671
|
x: endPoint.x,
|
|
78394
78672
|
y: endPoint.y
|
|
78395
78673
|
});
|
|
@@ -78421,11 +78699,8 @@ var AddTracesStage = class extends ConverterStage {
|
|
|
78421
78699
|
netInfo = pcbNetMap.get(connectivityKey);
|
|
78422
78700
|
}
|
|
78423
78701
|
}
|
|
78424
|
-
const
|
|
78425
|
-
|
|
78426
|
-
bottom: "B.Cu"
|
|
78427
|
-
};
|
|
78428
|
-
const kicadLayer = layerMap[startPoint.layer] || startPoint.layer || "F.Cu";
|
|
78702
|
+
const segmentLayerSource = startPoint.layer ?? endPoint.layer ?? lastKnownLayer;
|
|
78703
|
+
const kicadLayer = getKicadLayer(segmentLayerSource);
|
|
78429
78704
|
const segmentData = `segment:${transformedStart.x},${transformedStart.y}:${transformedEnd.x},${transformedEnd.y}:${kicadLayer}:${netInfo?.id ?? 0}`;
|
|
78430
78705
|
const segment = new Segment({
|
|
78431
78706
|
start: { x: transformedStart.x, y: transformedStart.y },
|
|
@@ -78438,6 +78713,12 @@ var AddTracesStage = class extends ConverterStage {
|
|
|
78438
78713
|
const segments = kicadPcb.segments;
|
|
78439
78714
|
segments.push(segment);
|
|
78440
78715
|
kicadPcb.segments = segments;
|
|
78716
|
+
if (startPoint.layer) {
|
|
78717
|
+
lastKnownLayer = startPoint.layer;
|
|
78718
|
+
}
|
|
78719
|
+
if (endPoint.layer) {
|
|
78720
|
+
lastKnownLayer = endPoint.layer;
|
|
78721
|
+
}
|
|
78441
78722
|
}
|
|
78442
78723
|
this.tracesProcessed++;
|
|
78443
78724
|
}
|
|
@@ -78465,7 +78746,7 @@ var AddViasStage = class extends ConverterStage {
|
|
|
78465
78746
|
return;
|
|
78466
78747
|
}
|
|
78467
78748
|
const via = this.pcbVias[this.viasProcessed];
|
|
78468
|
-
const transformedPos =
|
|
78749
|
+
const transformedPos = applyToPoint12(c2kMatPcb, {
|
|
78469
78750
|
x: via.x,
|
|
78470
78751
|
y: via.y
|
|
78471
78752
|
});
|
|
@@ -78507,12 +78788,14 @@ var AddViasStage = class extends ConverterStage {
|
|
|
78507
78788
|
netInfo = pcbNetMap.get(connectivityKey);
|
|
78508
78789
|
}
|
|
78509
78790
|
}
|
|
78791
|
+
const numLayers = this.ctx.numLayers ?? 2;
|
|
78792
|
+
const viaLayers = via.layers ? via.layers.map((l) => l === "top" ? "F.Cu" : l === "bottom" ? "B.Cu" : `In${l.replace("inner", "")}.Cu`) : getViaLayers(numLayers);
|
|
78510
78793
|
const viaData = `via:${transformedPos.x},${transformedPos.y}:${via.outer_diameter || 0.8}:${via.hole_diameter || 0.4}:${netInfo?.id ?? 0}`;
|
|
78511
78794
|
const kicadVia = new Via({
|
|
78512
78795
|
at: [transformedPos.x, transformedPos.y],
|
|
78513
78796
|
size: via.outer_diameter || 0.8,
|
|
78514
78797
|
drill: via.hole_diameter || 0.4,
|
|
78515
|
-
layers:
|
|
78798
|
+
layers: viaLayers,
|
|
78516
78799
|
net: new ViaNet(netInfo?.id ?? 0),
|
|
78517
78800
|
uuid: generateDeterministicUuid(viaData)
|
|
78518
78801
|
});
|
|
@@ -78525,6 +78808,62 @@ var AddViasStage = class extends ConverterStage {
|
|
|
78525
78808
|
return this.ctx.kicadPcb;
|
|
78526
78809
|
}
|
|
78527
78810
|
};
|
|
78811
|
+
function createFabricationNoteTextFromCircuitJson({
|
|
78812
|
+
textElement,
|
|
78813
|
+
c2kMatPcb
|
|
78814
|
+
}) {
|
|
78815
|
+
if (!textElement.text || !textElement.anchor_position) {
|
|
78816
|
+
return null;
|
|
78817
|
+
}
|
|
78818
|
+
const transformedPos = applyToPoint13(c2kMatPcb, {
|
|
78819
|
+
x: textElement.anchor_position.x,
|
|
78820
|
+
y: textElement.anchor_position.y
|
|
78821
|
+
});
|
|
78822
|
+
const layerMap = {
|
|
78823
|
+
top: "F.Fab",
|
|
78824
|
+
bottom: "B.Fab"
|
|
78825
|
+
};
|
|
78826
|
+
const kicadLayer = layerMap[textElement.layer] || textElement.layer || "F.Fab";
|
|
78827
|
+
const fontSize = (textElement.font_size || 1) / 1.5;
|
|
78828
|
+
const font = new TextEffectsFont6;
|
|
78829
|
+
font.size = { width: fontSize, height: fontSize };
|
|
78830
|
+
const justify = new TextEffectsJustify3;
|
|
78831
|
+
const anchorAlignment = textElement.anchor_alignment || "center";
|
|
78832
|
+
switch (anchorAlignment) {
|
|
78833
|
+
case "top_left":
|
|
78834
|
+
justify.horizontal = "left";
|
|
78835
|
+
justify.vertical = "top";
|
|
78836
|
+
break;
|
|
78837
|
+
case "top_right":
|
|
78838
|
+
justify.horizontal = "right";
|
|
78839
|
+
justify.vertical = "top";
|
|
78840
|
+
break;
|
|
78841
|
+
case "bottom_left":
|
|
78842
|
+
justify.horizontal = "left";
|
|
78843
|
+
justify.vertical = "bottom";
|
|
78844
|
+
break;
|
|
78845
|
+
case "bottom_right":
|
|
78846
|
+
justify.horizontal = "right";
|
|
78847
|
+
justify.vertical = "bottom";
|
|
78848
|
+
break;
|
|
78849
|
+
case "center":
|
|
78850
|
+
break;
|
|
78851
|
+
}
|
|
78852
|
+
const textEffects = new TextEffects6({
|
|
78853
|
+
font
|
|
78854
|
+
});
|
|
78855
|
+
if (anchorAlignment !== "center") {
|
|
78856
|
+
textEffects.justify = justify;
|
|
78857
|
+
}
|
|
78858
|
+
const position = new At([transformedPos.x, transformedPos.y, 0]);
|
|
78859
|
+
const grText = new GrText({
|
|
78860
|
+
text: textElement.text,
|
|
78861
|
+
layer: kicadLayer,
|
|
78862
|
+
effects: textEffects
|
|
78863
|
+
});
|
|
78864
|
+
grText.position = position;
|
|
78865
|
+
return grText;
|
|
78866
|
+
}
|
|
78528
78867
|
function createGrTextFromCircuitJson({
|
|
78529
78868
|
textElement,
|
|
78530
78869
|
c2kMatPcb
|
|
@@ -78532,7 +78871,7 @@ function createGrTextFromCircuitJson({
|
|
|
78532
78871
|
if (!textElement.text || !textElement.anchor_position) {
|
|
78533
78872
|
return null;
|
|
78534
78873
|
}
|
|
78535
|
-
const transformedPos =
|
|
78874
|
+
const transformedPos = applyToPoint14(c2kMatPcb, {
|
|
78536
78875
|
x: textElement.anchor_position.x,
|
|
78537
78876
|
y: textElement.anchor_position.y
|
|
78538
78877
|
});
|
|
@@ -78542,9 +78881,9 @@ function createGrTextFromCircuitJson({
|
|
|
78542
78881
|
};
|
|
78543
78882
|
const kicadLayer = layerMap[textElement.layer] || textElement.layer || "F.SilkS";
|
|
78544
78883
|
const fontSize = (textElement.font_size || 1) / 1.5;
|
|
78545
|
-
const font = new
|
|
78884
|
+
const font = new TextEffectsFont7;
|
|
78546
78885
|
font.size = { width: fontSize, height: fontSize };
|
|
78547
|
-
const justify = new
|
|
78886
|
+
const justify = new TextEffectsJustify4;
|
|
78548
78887
|
const anchorAlignment = textElement.anchor_alignment || "center";
|
|
78549
78888
|
switch (anchorAlignment) {
|
|
78550
78889
|
case "top_left":
|
|
@@ -78566,15 +78905,15 @@ function createGrTextFromCircuitJson({
|
|
|
78566
78905
|
case "center":
|
|
78567
78906
|
break;
|
|
78568
78907
|
}
|
|
78569
|
-
const textEffects = new
|
|
78908
|
+
const textEffects = new TextEffects7({
|
|
78570
78909
|
font
|
|
78571
78910
|
});
|
|
78572
78911
|
if (anchorAlignment !== "center") {
|
|
78573
78912
|
textEffects.justify = justify;
|
|
78574
78913
|
}
|
|
78575
78914
|
const rotation = textElement.ccw_rotation || 0;
|
|
78576
|
-
const position = new
|
|
78577
|
-
const grText = new
|
|
78915
|
+
const position = new At2([transformedPos.x, transformedPos.y, rotation]);
|
|
78916
|
+
const grText = new GrText2({
|
|
78578
78917
|
text: textElement.text,
|
|
78579
78918
|
layer: kicadLayer,
|
|
78580
78919
|
effects: textEffects
|
|
@@ -78600,11 +78939,11 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
78600
78939
|
const endPoint = path14.route[i + 1];
|
|
78601
78940
|
if (!startPoint || !endPoint)
|
|
78602
78941
|
continue;
|
|
78603
|
-
const transformedStart =
|
|
78942
|
+
const transformedStart = applyToPoint15(c2kMatPcb, {
|
|
78604
78943
|
x: startPoint.x,
|
|
78605
78944
|
y: startPoint.y
|
|
78606
78945
|
});
|
|
78607
|
-
const transformedEnd =
|
|
78946
|
+
const transformedEnd = applyToPoint15(c2kMatPcb, {
|
|
78608
78947
|
x: endPoint.x,
|
|
78609
78948
|
y: endPoint.y
|
|
78610
78949
|
});
|
|
@@ -78636,6 +78975,18 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
78636
78975
|
kicadPcb.graphicTexts = graphicTexts;
|
|
78637
78976
|
}
|
|
78638
78977
|
}
|
|
78978
|
+
const fabricationNoteTexts = this.ctx.db.pcb_fabrication_note_text?.list() || [];
|
|
78979
|
+
for (const textElement of fabricationNoteTexts) {
|
|
78980
|
+
const grText = createFabricationNoteTextFromCircuitJson({
|
|
78981
|
+
textElement,
|
|
78982
|
+
c2kMatPcb
|
|
78983
|
+
});
|
|
78984
|
+
if (grText) {
|
|
78985
|
+
const graphicTexts = kicadPcb.graphicTexts;
|
|
78986
|
+
graphicTexts.push(grText);
|
|
78987
|
+
kicadPcb.graphicTexts = graphicTexts;
|
|
78988
|
+
}
|
|
78989
|
+
}
|
|
78639
78990
|
const pcbBoards = this.ctx.db.pcb_board?.list() || [];
|
|
78640
78991
|
if (pcbBoards.length > 0) {
|
|
78641
78992
|
const board = pcbBoards[0];
|
|
@@ -78656,7 +79007,7 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
78656
79007
|
{ x: board.center.x - halfWidth, y: board.center.y + halfHeight }
|
|
78657
79008
|
];
|
|
78658
79009
|
}
|
|
78659
|
-
const transformedCorners = corners.map((corner) =>
|
|
79010
|
+
const transformedCorners = corners.map((corner) => applyToPoint15(c2kMatPcb, corner));
|
|
78660
79011
|
for (let i = 0;i < transformedCorners.length; i++) {
|
|
78661
79012
|
const start = transformedCorners[i];
|
|
78662
79013
|
const end = transformedCorners[(i + 1) % transformedCorners.length];
|
|
@@ -78854,6 +79205,9 @@ var ExtractSymbolsStage = class extends ConverterStage {
|
|
|
78854
79205
|
if (!uniqueSymbols.has(symbolName)) {
|
|
78855
79206
|
symbol.libraryId = symbolName;
|
|
78856
79207
|
this.updateFootprintProperty(symbol, fpLibraryName);
|
|
79208
|
+
if (!isCustom) {
|
|
79209
|
+
this.snapPinPositionsToGrid(symbol);
|
|
79210
|
+
}
|
|
78857
79211
|
uniqueSymbols.set(symbolName, {
|
|
78858
79212
|
symbolName,
|
|
78859
79213
|
symbol,
|
|
@@ -78887,10 +79241,34 @@ var ExtractSymbolsStage = class extends ConverterStage {
|
|
|
78887
79241
|
const name = parts.length > 1 ? parts[1] : parts[0];
|
|
78888
79242
|
return name?.replace(/[\\\/]/g, "-").trim() || "symbol";
|
|
78889
79243
|
}
|
|
79244
|
+
snapPinPositionsToGrid(symbol) {
|
|
79245
|
+
const KICAD_GRID = 1.27;
|
|
79246
|
+
for (const subSymbol of symbol.subSymbols ?? []) {
|
|
79247
|
+
for (const pin of subSymbol.pins ?? []) {
|
|
79248
|
+
if (pin.at) {
|
|
79249
|
+
pin.at.x = Math.round(pin.at.x / KICAD_GRID) * KICAD_GRID;
|
|
79250
|
+
pin.at.y = Math.round(pin.at.y / KICAD_GRID) * KICAD_GRID;
|
|
79251
|
+
}
|
|
79252
|
+
}
|
|
79253
|
+
for (const polyline of subSymbol.polylines ?? []) {
|
|
79254
|
+
if (polyline.points?.points) {
|
|
79255
|
+
for (const pt of polyline.points.points) {
|
|
79256
|
+
if ("x" in pt && "y" in pt) {
|
|
79257
|
+
pt.x = Math.round(pt.x / KICAD_GRID) * KICAD_GRID;
|
|
79258
|
+
pt.y = Math.round(pt.y / KICAD_GRID) * KICAD_GRID;
|
|
79259
|
+
}
|
|
79260
|
+
}
|
|
79261
|
+
}
|
|
79262
|
+
}
|
|
79263
|
+
}
|
|
79264
|
+
}
|
|
78890
79265
|
getOutput() {
|
|
78891
79266
|
return this.ctx.libraryOutput;
|
|
78892
79267
|
}
|
|
78893
79268
|
};
|
|
79269
|
+
var KICAD_FP_VERSION = 20240108;
|
|
79270
|
+
var KICAD_FP_GENERATOR = "pcbnew";
|
|
79271
|
+
var KICAD_FP_GENERATOR_VERSION = "8.0";
|
|
78894
79272
|
function getBasename(filePath) {
|
|
78895
79273
|
const parts = filePath.split(/[/\\]/);
|
|
78896
79274
|
return parts[parts.length - 1] || filePath;
|
|
@@ -78954,9 +79332,12 @@ var ExtractFootprintsStage = class extends ConverterStage {
|
|
|
78954
79332
|
const footprintName = (parts.length > 1 ? parts[1] : parts[0])?.replace(/[\\\/]/g, "-").trim() || "footprint";
|
|
78955
79333
|
const isBuiltin = !customFootprintNames.has(footprintName);
|
|
78956
79334
|
footprint.libraryLink = footprintName;
|
|
78957
|
-
footprint.position =
|
|
79335
|
+
footprint.position = At3.from([0, 0, 0]);
|
|
78958
79336
|
footprint.locked = false;
|
|
78959
79337
|
footprint.placed = false;
|
|
79338
|
+
footprint.version = KICAD_FP_VERSION;
|
|
79339
|
+
footprint.generator = KICAD_FP_GENERATOR;
|
|
79340
|
+
footprint.generatorVersion = KICAD_FP_GENERATOR_VERSION;
|
|
78960
79341
|
if (!footprint.descr) {
|
|
78961
79342
|
footprint.descr = "";
|
|
78962
79343
|
}
|
|
@@ -78980,15 +79361,32 @@ var ExtractFootprintsStage = class extends ConverterStage {
|
|
|
78980
79361
|
footprint.path = undefined;
|
|
78981
79362
|
footprint.sheetfile = undefined;
|
|
78982
79363
|
footprint.sheetname = undefined;
|
|
78983
|
-
const defaultFont = new
|
|
79364
|
+
const defaultFont = new TextEffectsFont8;
|
|
78984
79365
|
defaultFont.size = { width: 1.27, height: 1.27 };
|
|
78985
79366
|
defaultFont.thickness = 0.15;
|
|
78986
|
-
const defaultEffects = new
|
|
79367
|
+
const defaultEffects = new TextEffects8({ font: defaultFont });
|
|
79368
|
+
const fpPads = footprint.fpPads ?? [];
|
|
79369
|
+
let minY = 0;
|
|
79370
|
+
let maxY = 0;
|
|
79371
|
+
for (const pad of fpPads) {
|
|
79372
|
+
const at = pad.at;
|
|
79373
|
+
const size = pad.size;
|
|
79374
|
+
if (at && size) {
|
|
79375
|
+
const padY = at.y ?? 0;
|
|
79376
|
+
const padHeight = size.height ?? 0;
|
|
79377
|
+
const padTop = padY - padHeight / 2;
|
|
79378
|
+
const padBottom = padY + padHeight / 2;
|
|
79379
|
+
minY = Math.min(minY, padTop);
|
|
79380
|
+
maxY = Math.max(maxY, padBottom);
|
|
79381
|
+
}
|
|
79382
|
+
}
|
|
79383
|
+
const refY = minY - 0.5;
|
|
79384
|
+
const valY = maxY + 0.5;
|
|
78987
79385
|
footprint.properties = [
|
|
78988
79386
|
new Property({
|
|
78989
79387
|
key: "Reference",
|
|
78990
|
-
value: "
|
|
78991
|
-
position: [0,
|
|
79388
|
+
value: "REF**",
|
|
79389
|
+
position: [0, refY, 0],
|
|
78992
79390
|
layer: "F.SilkS",
|
|
78993
79391
|
uuid: generateDeterministicUuid(`${footprintName}-property-Reference`),
|
|
78994
79392
|
effects: defaultEffects
|
|
@@ -78996,7 +79394,7 @@ var ExtractFootprintsStage = class extends ConverterStage {
|
|
|
78996
79394
|
new Property({
|
|
78997
79395
|
key: "Value",
|
|
78998
79396
|
value: "Val**",
|
|
78999
|
-
position: [0,
|
|
79397
|
+
position: [0, valY, 0],
|
|
79000
79398
|
layer: "F.Fab",
|
|
79001
79399
|
uuid: generateDeterministicUuid(`${footprintName}-property-Value`),
|
|
79002
79400
|
effects: defaultEffects
|
|
@@ -79238,6 +79636,23 @@ function renameKicadFootprint(params2) {
|
|
|
79238
79636
|
model3dSourcePaths: kicadFootprint.model3dSourcePaths
|
|
79239
79637
|
};
|
|
79240
79638
|
}
|
|
79639
|
+
function createTextEffects(metadataEffects) {
|
|
79640
|
+
const font = new TextEffectsFont9;
|
|
79641
|
+
if (metadataEffects?.font?.size) {
|
|
79642
|
+
font.size = {
|
|
79643
|
+
width: Number(metadataEffects.font.size.x),
|
|
79644
|
+
height: Number(metadataEffects.font.size.y)
|
|
79645
|
+
};
|
|
79646
|
+
} else {
|
|
79647
|
+
font.size = { width: 1.27, height: 1.27 };
|
|
79648
|
+
}
|
|
79649
|
+
if (metadataEffects?.font?.thickness !== undefined) {
|
|
79650
|
+
font.thickness = Number(metadataEffects.font.thickness);
|
|
79651
|
+
} else {
|
|
79652
|
+
font.thickness = 0.15;
|
|
79653
|
+
}
|
|
79654
|
+
return new TextEffects9({ font });
|
|
79655
|
+
}
|
|
79241
79656
|
function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
|
|
79242
79657
|
try {
|
|
79243
79658
|
const parsed = parseKicadSexpr3(kicadModString);
|
|
@@ -79256,10 +79671,6 @@ function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
|
|
|
79256
79671
|
}
|
|
79257
79672
|
if (metadata.embeddedFonts !== undefined) {}
|
|
79258
79673
|
if (metadata.properties) {
|
|
79259
|
-
const defaultFont = new TextEffectsFont7;
|
|
79260
|
-
defaultFont.size = { width: 1.27, height: 1.27 };
|
|
79261
|
-
defaultFont.thickness = 0.15;
|
|
79262
|
-
const defaultEffects = new TextEffects7({ font: defaultFont });
|
|
79263
79674
|
const newProperties = [];
|
|
79264
79675
|
const refMeta = metadata.properties.Reference;
|
|
79265
79676
|
newProperties.push(new Property2({
|
|
@@ -79272,7 +79683,7 @@ function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
|
|
|
79272
79683
|
] : [0, 0, 0],
|
|
79273
79684
|
layer: refMeta?.layer ?? "F.SilkS",
|
|
79274
79685
|
uuid: refMeta?.uuid ?? generateDeterministicUuid(`${footprintName}-property-Reference`),
|
|
79275
|
-
effects:
|
|
79686
|
+
effects: createTextEffects(refMeta?.effects),
|
|
79276
79687
|
hidden: refMeta?.hide
|
|
79277
79688
|
}));
|
|
79278
79689
|
const valMeta = metadata.properties.Value;
|
|
@@ -79286,7 +79697,7 @@ function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
|
|
|
79286
79697
|
] : [0, 0, 0],
|
|
79287
79698
|
layer: valMeta?.layer ?? "F.Fab",
|
|
79288
79699
|
uuid: valMeta?.uuid ?? generateDeterministicUuid(`${footprintName}-property-Value`),
|
|
79289
|
-
effects:
|
|
79700
|
+
effects: createTextEffects(valMeta?.effects),
|
|
79290
79701
|
hidden: valMeta?.hide
|
|
79291
79702
|
}));
|
|
79292
79703
|
const dsMeta = metadata.properties.Datasheet;
|
|
@@ -79300,7 +79711,7 @@ function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
|
|
|
79300
79711
|
] : [0, 0, 0],
|
|
79301
79712
|
layer: dsMeta?.layer ?? "F.Fab",
|
|
79302
79713
|
uuid: dsMeta?.uuid ?? generateDeterministicUuid(`${footprintName}-property-Datasheet`),
|
|
79303
|
-
effects:
|
|
79714
|
+
effects: createTextEffects(dsMeta?.effects),
|
|
79304
79715
|
hidden: dsMeta?.hide ?? true
|
|
79305
79716
|
}));
|
|
79306
79717
|
const descMeta = metadata.properties.Description;
|
|
@@ -79314,7 +79725,7 @@ function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
|
|
|
79314
79725
|
] : [0, 0, 0],
|
|
79315
79726
|
layer: descMeta?.layer ?? "F.Fab",
|
|
79316
79727
|
uuid: descMeta?.uuid ?? generateDeterministicUuid(`${footprintName}-property-Description`),
|
|
79317
|
-
effects:
|
|
79728
|
+
effects: createTextEffects(descMeta?.effects),
|
|
79318
79729
|
hidden: descMeta?.hide ?? true
|
|
79319
79730
|
}));
|
|
79320
79731
|
footprint.properties = newProperties;
|
|
@@ -79477,16 +79888,16 @@ var toNumber = (value, fallback) => {
|
|
|
79477
79888
|
return fallback;
|
|
79478
79889
|
return parsed;
|
|
79479
79890
|
};
|
|
79480
|
-
var
|
|
79891
|
+
var createTextEffects2 = (effectsMeta, fallback) => {
|
|
79481
79892
|
if (!effectsMeta)
|
|
79482
79893
|
return fallback;
|
|
79483
|
-
const effects = new
|
|
79894
|
+
const effects = new TextEffects10({
|
|
79484
79895
|
font: fallback?.font,
|
|
79485
79896
|
justify: fallback?.justify,
|
|
79486
79897
|
hiddenText: fallback?.hiddenText ?? false
|
|
79487
79898
|
});
|
|
79488
79899
|
if (!effects.font) {
|
|
79489
|
-
const defaultFont = new
|
|
79900
|
+
const defaultFont = new TextEffectsFont10;
|
|
79490
79901
|
defaultFont.size = { width: DEFAULT_TEXT_SIZE, height: DEFAULT_TEXT_SIZE };
|
|
79491
79902
|
effects.font = defaultFont;
|
|
79492
79903
|
}
|
|
@@ -79531,7 +79942,7 @@ var createJustify = (justifyInput) => {
|
|
|
79531
79942
|
if (!options.horizontal && !options.vertical && !options.mirror) {
|
|
79532
79943
|
return;
|
|
79533
79944
|
}
|
|
79534
|
-
return new
|
|
79945
|
+
return new TextEffectsJustify5(options);
|
|
79535
79946
|
};
|
|
79536
79947
|
var applySymbolProperty = (symbol, key, propertyMeta) => {
|
|
79537
79948
|
const existingProperty = symbol.properties.find((prop) => prop.key === key);
|
|
@@ -79541,7 +79952,7 @@ var applySymbolProperty = (symbol, key, propertyMeta) => {
|
|
|
79541
79952
|
toNumber(propertyMeta.at.y, 0),
|
|
79542
79953
|
toNumber(propertyMeta.at.rotation, 0)
|
|
79543
79954
|
] : existingProperty?.at;
|
|
79544
|
-
const nextEffects =
|
|
79955
|
+
const nextEffects = createTextEffects2(propertyMeta.effects, existingProperty?.effects);
|
|
79545
79956
|
if (existingProperty) {
|
|
79546
79957
|
existingProperty.value = propertyMeta.value;
|
|
79547
79958
|
if (nextId !== undefined) {
|
|
@@ -79601,7 +80012,9 @@ function applyKicadSymbolMetadata(kicadSymbol, metadata) {
|
|
|
79601
80012
|
}
|
|
79602
80013
|
return kicadSymbol;
|
|
79603
80014
|
}
|
|
80015
|
+
var addedSymbolNames = /* @__PURE__ */ new Set;
|
|
79604
80016
|
function classifyKicadSymbols(ctx) {
|
|
80017
|
+
addedSymbolNames.clear();
|
|
79605
80018
|
for (const extractedKicadComponent of ctx.extractedKicadComponents) {
|
|
79606
80019
|
classifySymbolsForComponent({
|
|
79607
80020
|
ctx,
|
|
@@ -79619,25 +80032,21 @@ function classifySymbolsForComponent({
|
|
|
79619
80032
|
const metadata = ctx.symbolMetadataMap.get(tscircuitComponentName);
|
|
79620
80033
|
for (const kicadSymbol of kicadSymbols) {
|
|
79621
80034
|
if (!kicadSymbol.isBuiltin) {
|
|
79622
|
-
|
|
79623
|
-
|
|
79624
|
-
|
|
80035
|
+
const symbolName = kicadSymbol.symbolName;
|
|
80036
|
+
if (addedSymbolNames.has(symbolName)) {
|
|
80037
|
+
continue;
|
|
80038
|
+
}
|
|
80039
|
+
addedSymbolNames.add(symbolName);
|
|
80040
|
+
if (hasCustomFootprint) {
|
|
80041
|
+
updateKicadSymbolFootprint({
|
|
79625
80042
|
kicadSymbol,
|
|
79626
|
-
|
|
80043
|
+
kicadLibraryName: ctx.kicadLibraryName,
|
|
80044
|
+
kicadFootprintName: tscircuitComponentName,
|
|
80045
|
+
isPcm: ctx.isPcm
|
|
79627
80046
|
});
|
|
79628
|
-
if (hasCustomFootprint) {
|
|
79629
|
-
updateKicadSymbolFootprint({
|
|
79630
|
-
kicadSymbol: renamedSymbol,
|
|
79631
|
-
kicadLibraryName: ctx.kicadLibraryName,
|
|
79632
|
-
kicadFootprintName: tscircuitComponentName,
|
|
79633
|
-
isPcm: ctx.isPcm
|
|
79634
|
-
});
|
|
79635
|
-
}
|
|
79636
|
-
const updatedSymbol = metadata ? applyKicadSymbolMetadata(renamedSymbol, metadata) : renamedSymbol;
|
|
79637
|
-
addUserSymbol({ ctx, kicadSymbol: updatedSymbol });
|
|
79638
|
-
} else {
|
|
79639
|
-
addUserSymbol({ ctx, kicadSymbol });
|
|
79640
80047
|
}
|
|
80048
|
+
const updatedSymbol = metadata ? applyKicadSymbolMetadata(kicadSymbol, metadata) : kicadSymbol;
|
|
80049
|
+
addUserSymbol({ ctx, kicadSymbol: updatedSymbol });
|
|
79641
80050
|
} else if (hasCustomFootprint && !hasAddedUserSymbol) {
|
|
79642
80051
|
hasAddedUserSymbol = true;
|
|
79643
80052
|
const renamedSymbol = renameKicadSymbol({
|
|
@@ -79664,10 +80073,11 @@ function addUserSymbol({
|
|
|
79664
80073
|
ctx,
|
|
79665
80074
|
kicadSymbol
|
|
79666
80075
|
}) {
|
|
79667
|
-
const
|
|
79668
|
-
if (
|
|
79669
|
-
|
|
80076
|
+
const alreadyExistsByName = ctx.userKicadSymbols.some((s) => s.symbolName === kicadSymbol.symbolName);
|
|
80077
|
+
if (alreadyExistsByName) {
|
|
80078
|
+
return;
|
|
79670
80079
|
}
|
|
80080
|
+
ctx.userKicadSymbols.push(kicadSymbol);
|
|
79671
80081
|
}
|
|
79672
80082
|
function addBuiltinSymbol({
|
|
79673
80083
|
ctx,
|
|
@@ -85023,7 +85433,7 @@ import {
|
|
|
85023
85433
|
import { convertCircuitJsonToGltf } from "circuit-json-to-gltf";
|
|
85024
85434
|
|
|
85025
85435
|
// node_modules/dsn-converter/dist/index.js
|
|
85026
|
-
import { applyToPoint as
|
|
85436
|
+
import { applyToPoint as applyToPoint16, scale as scale4 } from "transformation-matrix";
|
|
85027
85437
|
import { su as su4 } from "@tscircuit/soup-util";
|
|
85028
85438
|
import { su as su22 } from "@tscircuit/soup-util";
|
|
85029
85439
|
import Debug3 from "debug";
|
|
@@ -85191,7 +85601,7 @@ function processComponentsAndPads(componentGroups, circuitElements, pcb) {
|
|
|
85191
85601
|
const sourceComponent = su4(circuitElements).source_component.list().find((e) => e.source_component_id === pcbComponent?.source_component_id);
|
|
85192
85602
|
const footprintName = getFootprintName(sourceComponent, pcbComponent);
|
|
85193
85603
|
const componentName = sourceComponent?.name || "Unknown";
|
|
85194
|
-
const circuitSpaceCoordinates =
|
|
85604
|
+
const circuitSpaceCoordinates = applyToPoint16(transformMmToUm, pcbComponent.center);
|
|
85195
85605
|
if (!componentsByFootprint.has(footprintName)) {
|
|
85196
85606
|
componentsByFootprint.set(footprintName, []);
|
|
85197
85607
|
}
|
|
@@ -95268,7 +95678,7 @@ var any_circuit_element = external_exports.union([
|
|
|
95268
95678
|
var any_soup_element = any_circuit_element;
|
|
95269
95679
|
expectTypesMatch(true);
|
|
95270
95680
|
expectStringUnionsMatch(true);
|
|
95271
|
-
function
|
|
95681
|
+
function applyToPoint18(matrix, point2) {
|
|
95272
95682
|
return Array.isArray(point2) ? [
|
|
95273
95683
|
matrix.a * point2[0] + matrix.c * point2[1] + matrix.e,
|
|
95274
95684
|
matrix.b * point2[0] + matrix.d * point2[1] + matrix.f
|
|
@@ -95320,7 +95730,7 @@ function isUndefined2(val) {
|
|
|
95320
95730
|
return typeof val === "undefined";
|
|
95321
95731
|
}
|
|
95322
95732
|
var { cos, sin, PI } = Math;
|
|
95323
|
-
function
|
|
95733
|
+
function rotate6(angle, cx2, cy2) {
|
|
95324
95734
|
const cosAngle = cos(angle);
|
|
95325
95735
|
const sinAngle = sin(angle);
|
|
95326
95736
|
const rotationMatrix = {
|
|
@@ -95341,7 +95751,7 @@ function rotate5(angle, cx2, cy2) {
|
|
|
95341
95751
|
]);
|
|
95342
95752
|
}
|
|
95343
95753
|
function rotateDEG(angle, cx2 = undefined, cy2 = undefined) {
|
|
95344
|
-
return
|
|
95754
|
+
return rotate6(angle * PI / 180, cx2, cy2);
|
|
95345
95755
|
}
|
|
95346
95756
|
function scale6(sx2, sy2 = undefined, cx2 = undefined, cy2 = undefined) {
|
|
95347
95757
|
if (isUndefined2(sy2))
|
|
@@ -95363,7 +95773,7 @@ function scale6(sx2, sy2 = undefined, cx2 = undefined, cy2 = undefined) {
|
|
|
95363
95773
|
translate4(-cx2, -cy2)
|
|
95364
95774
|
]);
|
|
95365
95775
|
}
|
|
95366
|
-
function
|
|
95776
|
+
function identity5() {
|
|
95367
95777
|
return {
|
|
95368
95778
|
a: 1,
|
|
95369
95779
|
c: 0,
|
|
@@ -96237,25 +96647,25 @@ var oppositeSide = (sideOrDir) => {
|
|
|
96237
96647
|
};
|
|
96238
96648
|
var transformSchematicElement = (elm, matrix) => {
|
|
96239
96649
|
if (elm.type === "schematic_component") {
|
|
96240
|
-
elm.center =
|
|
96650
|
+
elm.center = applyToPoint18(matrix, elm.center);
|
|
96241
96651
|
} else if (elm.type === "schematic_port") {
|
|
96242
|
-
elm.center =
|
|
96652
|
+
elm.center = applyToPoint18(matrix, elm.center);
|
|
96243
96653
|
if (elm.facing_direction) {
|
|
96244
96654
|
elm.facing_direction = rotateDirection(elm.facing_direction, -(Math.atan2(matrix.b, matrix.a) / Math.PI) * 2);
|
|
96245
96655
|
}
|
|
96246
96656
|
} else if (elm.type === "schematic_text") {
|
|
96247
|
-
elm.position =
|
|
96657
|
+
elm.position = applyToPoint18(matrix, elm.position);
|
|
96248
96658
|
} else if (elm.type === "schematic_trace") {
|
|
96249
96659
|
const anyElm = elm;
|
|
96250
96660
|
anyElm.route = (anyElm.route ?? []).map((rp2) => {
|
|
96251
|
-
const tp2 =
|
|
96661
|
+
const tp2 = applyToPoint18(matrix, rp2);
|
|
96252
96662
|
rp2.x = tp2.x;
|
|
96253
96663
|
rp2.y = tp2.y;
|
|
96254
96664
|
return rp2;
|
|
96255
96665
|
});
|
|
96256
96666
|
if (Array.isArray(anyElm.junctions)) {
|
|
96257
96667
|
anyElm.junctions = anyElm.junctions.map((j2) => {
|
|
96258
|
-
const tp2 =
|
|
96668
|
+
const tp2 = applyToPoint18(matrix, j2);
|
|
96259
96669
|
j2.x = tp2.x;
|
|
96260
96670
|
j2.y = tp2.y;
|
|
96261
96671
|
return j2;
|
|
@@ -96263,18 +96673,18 @@ var transformSchematicElement = (elm, matrix) => {
|
|
|
96263
96673
|
}
|
|
96264
96674
|
if (Array.isArray(anyElm.edges)) {
|
|
96265
96675
|
anyElm.edges = anyElm.edges.map((e3) => {
|
|
96266
|
-
e3.from =
|
|
96267
|
-
e3.to =
|
|
96676
|
+
e3.from = applyToPoint18(matrix, e3.from);
|
|
96677
|
+
e3.to = applyToPoint18(matrix, e3.to);
|
|
96268
96678
|
return e3;
|
|
96269
96679
|
});
|
|
96270
96680
|
}
|
|
96271
96681
|
} else if (elm.type === "schematic_box") {
|
|
96272
|
-
const { x, y } =
|
|
96682
|
+
const { x, y } = applyToPoint18(matrix, { x: elm.x, y: elm.y });
|
|
96273
96683
|
elm.x = x;
|
|
96274
96684
|
elm.y = y;
|
|
96275
96685
|
} else if (elm.type === "schematic_line") {
|
|
96276
|
-
const { x: x12, y: y12 } =
|
|
96277
|
-
const { x: x22, y: y22 } =
|
|
96686
|
+
const { x: x12, y: y12 } = applyToPoint18(matrix, { x: elm.x1, y: elm.y1 });
|
|
96687
|
+
const { x: x22, y: y22 } = applyToPoint18(matrix, { x: elm.x2, y: elm.y2 });
|
|
96278
96688
|
elm.x1 = x12;
|
|
96279
96689
|
elm.y1 = y12;
|
|
96280
96690
|
elm.x2 = x22;
|
|
@@ -96289,20 +96699,20 @@ var transformPCBElement = (elm, matrix) => {
|
|
|
96289
96699
|
const tsr = decomposeTSR(matrix);
|
|
96290
96700
|
const flipPadWidthHeight = Math.round(tsr.rotation.angle / (Math.PI / 2)) % 2 === 1;
|
|
96291
96701
|
if (elm.type === "pcb_plated_hole" || elm.type === "pcb_hole" || elm.type === "pcb_via" || elm.type === "pcb_smtpad" || elm.type === "pcb_port") {
|
|
96292
|
-
const { x, y } =
|
|
96702
|
+
const { x, y } = applyToPoint18(matrix, {
|
|
96293
96703
|
x: Number(elm.x),
|
|
96294
96704
|
y: Number(elm.y)
|
|
96295
96705
|
});
|
|
96296
96706
|
elm.x = x;
|
|
96297
96707
|
elm.y = y;
|
|
96298
96708
|
} else if (elm.type === "pcb_keepout" || elm.type === "pcb_board") {
|
|
96299
|
-
elm.center =
|
|
96709
|
+
elm.center = applyToPoint18(matrix, elm.center);
|
|
96300
96710
|
} else if (elm.type === "pcb_silkscreen_text" || elm.type === "pcb_fabrication_note_text") {
|
|
96301
|
-
elm.anchor_position =
|
|
96711
|
+
elm.anchor_position = applyToPoint18(matrix, elm.anchor_position);
|
|
96302
96712
|
} else if (elm.type === "pcb_silkscreen_circle" || elm.type === "pcb_silkscreen_rect") {
|
|
96303
|
-
elm.center =
|
|
96713
|
+
elm.center = applyToPoint18(matrix, elm.center);
|
|
96304
96714
|
} else if (elm.type === "pcb_component") {
|
|
96305
|
-
elm.center =
|
|
96715
|
+
elm.center = applyToPoint18(matrix, elm.center);
|
|
96306
96716
|
elm.rotation = elm.rotation + tsr.rotation.angle / Math.PI * 180;
|
|
96307
96717
|
elm.rotation = elm.rotation % 360;
|
|
96308
96718
|
if (flipPadWidthHeight) {
|
|
@@ -96310,7 +96720,7 @@ var transformPCBElement = (elm, matrix) => {
|
|
|
96310
96720
|
}
|
|
96311
96721
|
} else if (elm.type === "pcb_silkscreen_path" || elm.type === "pcb_trace" || elm.type === "pcb_fabrication_note_path") {
|
|
96312
96722
|
elm.route = elm.route.map((rp2) => {
|
|
96313
|
-
const tp2 =
|
|
96723
|
+
const tp2 = applyToPoint18(matrix, rp2);
|
|
96314
96724
|
rp2.x = tp2.x;
|
|
96315
96725
|
rp2.y = tp2.y;
|
|
96316
96726
|
return rp2;
|
|
@@ -96318,14 +96728,14 @@ var transformPCBElement = (elm, matrix) => {
|
|
|
96318
96728
|
} else if (elm.type === "pcb_silkscreen_line") {
|
|
96319
96729
|
const p12 = { x: elm.x1, y: elm.y1 };
|
|
96320
96730
|
const p22 = { x: elm.x2, y: elm.y2 };
|
|
96321
|
-
const p1t =
|
|
96322
|
-
const p2t =
|
|
96731
|
+
const p1t = applyToPoint18(matrix, p12);
|
|
96732
|
+
const p2t = applyToPoint18(matrix, p22);
|
|
96323
96733
|
elm.x1 = p1t.x;
|
|
96324
96734
|
elm.y1 = p1t.y;
|
|
96325
96735
|
elm.x2 = p2t.x;
|
|
96326
96736
|
elm.y2 = p2t.y;
|
|
96327
96737
|
} else if (elm.type === "cad_component") {
|
|
96328
|
-
const newPos =
|
|
96738
|
+
const newPos = applyToPoint18(matrix, {
|
|
96329
96739
|
x: elm.position.x,
|
|
96330
96740
|
y: elm.position.y
|
|
96331
96741
|
});
|
|
@@ -97184,7 +97594,7 @@ var E = (t, o) => {
|
|
|
97184
97594
|
}), c = a.map((p) => ({ ...p, ..._(n, p) }));
|
|
97185
97595
|
return { primitives: m, center: l, ports: c, size: y, ...o };
|
|
97186
97596
|
};
|
|
97187
|
-
var
|
|
97597
|
+
var At4 = (t, o) => {
|
|
97188
97598
|
let { newOrientation: i, overrides: l } = o, a = { up: Math.PI / 2, right: 0, down: -Math.PI / 2, left: -Math.PI }, y = sr(i ? a[i] : Math.PI / 2, t.center.x, t.center.y), { primitives: n, center: m, size: c, ports: p } = t, x = n.map((h) => {
|
|
97189
97599
|
switch (h = { ...h }, h.type) {
|
|
97190
97600
|
case "path":
|
|
@@ -97202,7 +97612,7 @@ var At3 = (t, o) => {
|
|
|
97202
97612
|
}), f = p.map((h) => ({ ...h, ..._(y, h) })), d = _t(x);
|
|
97203
97613
|
return { primitives: x, center: m, ports: f, size: { width: d.maxX - d.minX, height: d.maxY - d.minY }, ...l };
|
|
97204
97614
|
};
|
|
97205
|
-
var r = (t, o = "down", i = {}) =>
|
|
97615
|
+
var r = (t, o = "down", i = {}) => At4(t, { newOrientation: o, overrides: i });
|
|
97206
97616
|
var nr = class {
|
|
97207
97617
|
symbol;
|
|
97208
97618
|
constructor(o) {
|
|
@@ -97215,7 +97625,7 @@ var nr = class {
|
|
|
97215
97625
|
return this.symbol = { ...this.symbol, ports: this.symbol.ports.map((l) => l.labels.includes(o) ? { ...l, labels: i } : l) }, this;
|
|
97216
97626
|
}
|
|
97217
97627
|
rotateRightFacingSymbol(o) {
|
|
97218
|
-
return this.symbol =
|
|
97628
|
+
return this.symbol = At4(this.symbol, { newOrientation: o }), this;
|
|
97219
97629
|
}
|
|
97220
97630
|
computeSize() {
|
|
97221
97631
|
let o = _t(this.symbol.primitives);
|
|
@@ -97281,7 +97691,7 @@ function s(t) {
|
|
|
97281
97691
|
var wp = { paths: { path43: { type: "path", points: [{ x: -0.06, y: 0.19 }, { x: -0.06, y: -0.12 }], color: "primary", fill: false }, "path43-6": { type: "path", points: [{ x: 0.02, y: 0.13 }, { x: 0.02, y: -0.06 }], color: "primary", fill: false }, path44: { type: "path", points: [{ x: -0.06, y: 0.03 }, { x: -0.45, y: 0.03 }], color: "primary", fill: false }, "path44-0": { type: "path", points: [{ x: 0.45, y: 0.03 }, { x: 0.03, y: 0.03 }], color: "primary", fill: false } }, texts: { top1: { type: "text", text: "{REF}", x: -0.03, y: 0.27 }, bottom1: { type: "text", text: "{VAL}", x: -0.03, y: -0.28 } }, refblocks: { left1: { x: -0.45, y: 0.03 }, right1: { x: 0.45, y: 0.03 } }, bounds: { minX: -0.47, maxX: 0.47, minY: -0.38, maxY: 0.27, width: 0.95, height: 0.29, centerX: 0, centerY: 0.06 }, circles: {} };
|
|
97282
97692
|
var { paths: Cf, texts: Ap, bounds: Ht, refblocks: Pp, circles: Nf } = wp;
|
|
97283
97693
|
var Zt = s({ primitives: [...Object.values(Cf), ...Object.values(Nf), { ...Ap.top1, anchor: "middle_bottom" }, { ...Ap.bottom1, anchor: "middle_top" }], ports: [{ ...Pp.left1, labels: ["1"] }, { ...Pp.right1, labels: ["2"] }], size: { width: Ht.width, height: Ht.height }, center: { x: Ht.centerX, y: Ht.centerY } });
|
|
97284
|
-
var Sp =
|
|
97694
|
+
var Sp = At4(Zt, { newOrientation: "up" });
|
|
97285
97695
|
var j = { paths: { path1: { type: "path", points: [{ x: -0.53, y: 0.05 }, { x: -0.25, y: 0.05 }], color: "primary", fill: false }, path2: { type: "path", points: [{ x: 0.28, y: 0.05 }, { x: 0.57, y: 0.05 }], color: "primary", fill: false }, path3: { type: "path", points: [{ x: 0.02, y: 0.18 }, { x: 0.28, y: 0.18 }, { x: 0.28, y: -0.09 }, { x: -0.25, y: -0.09 }, { x: -0.25, y: 0.18 }, { x: 0.02, y: 0.18 }], color: "primary", fill: false } }, texts: { top1: { type: "text", text: "{REF}", x: 0, y: 0.25 }, bottom1: { type: "text", text: "{VAL}", x: 0, y: -0.25 } }, refblocks: { left1: { x: -0.53, y: 0.05 }, right1: { x: 0.57, y: 0.05 } }, bounds: { minX: -0.56, maxX: 0.56, minY: -0.25, maxY: 0.25, width: 1.12, height: 0.5, centerX: 0, centerY: 0 }, circles: {} };
|
|
97286
97696
|
var { paths: Bf, texts: q5, bounds: Fp, refblocks: Rp, circles: qf } = j;
|
|
97287
97697
|
var Tp = e({ primitives: [...Object.values(Bf), ...Object.values(qf), { type: "text", text: "{REF}", x: -0.16, y: 0.2294553499999995 }, { type: "text", text: "{VAL}", x: 0.16, y: 0.2294553499999995 }], ports: [{ ...Rp.left1, labels: ["1"] }, { ...Rp.right1, labels: ["2"] }], center: { x: Fp.centerX, y: Fp.centerY } }).changeTextAnchor("{VAL}", "middle_bottom").rotateRightFacingSymbol("down").labelPort("left1", ["1"]).labelPort("right1", ["2"]).changeTextAnchor("{REF}", "middle_left").build();
|
|
@@ -97503,7 +97913,7 @@ Ir.x = 0.46;
|
|
|
97503
97913
|
Ir.y += 0.265;
|
|
97504
97914
|
Br.y -= 0.265;
|
|
97505
97915
|
Br.x = 0.46;
|
|
97506
|
-
var
|
|
97916
|
+
var Xy5 = Nr;
|
|
97507
97917
|
var Ly = { paths: { path11: { type: "path", points: [{ x: -0.38, y: 0.06 }, { x: -0.14, y: 0.06 }], color: "primary", fill: false }, "path11-0": { type: "path", points: [{ x: -0.09, y: 0.07 }, { x: 0.1, y: 0.2 }], color: "primary", fill: false }, path12: { type: "path", points: [{ x: 0.13, y: 0.06 }, { x: 0.38, y: 0.06 }], color: "primary", fill: false }, "path11-5": { type: "path", points: [{ x: -0.38, y: -0.17 }, { x: -0.14, y: -0.17 }], color: "primary", fill: false }, "path11-0-3": { type: "path", points: [{ x: -0.09, y: -0.16 }, { x: 0.1, y: -0.03 }], color: "primary", fill: false }, "path12-0": { type: "path", points: [{ x: 0.13, y: -0.17 }, { x: 0.38, y: -0.17 }], color: "primary", fill: false } }, texts: { top1: { type: "text", text: "{REF}", x: 0, y: 0.42 }, bottom1: { type: "text", text: "{VAL}", x: 0, y: -0.42 } }, refblocks: { left1: { x: -0.38, y: -0.17 }, left3: { x: -0.38, y: 0.06 }, right1: { x: 0.38, y: -0.17 }, right3: { x: 0.38, y: 0.06 } }, bounds: { minX: -0.4, maxX: 0.4, minY: -0.4, maxY: 0.4, width: 0.81, height: 0.79, centerX: 0, centerY: 0 }, circles: { "circle-4": { type: "circle", x: 0.1, y: 0.06, radius: 0.02, color: "primary", fill: false }, "circle-2": { type: "circle", x: 0.1, y: -0.17, radius: 0.02, color: "primary", fill: false }, "circle-3": { type: "circle", x: -0.11, y: 0.06, radius: 0.02, color: "primary", fill: false }, "circle-1": { type: "circle", x: -0.11, y: -0.17, radius: 0.02, color: "primary", fill: false } } };
|
|
97508
97918
|
var q = e(Ly).labelPort("left1", ["1"]).labelPort("right1", ["2"]).labelPort("right3", ["4"]).labelPort("left3", ["3"]).changeTextAnchor("{REF}", "middle_bottom").changeTextAnchor("{VAL}", "middle_top").build();
|
|
97509
97919
|
var qr = r(q, "down");
|
|
@@ -98374,7 +98784,7 @@ var jb = Il.primitives.find((t) => t.type === "text" && t.text === "{VAL}");
|
|
|
98374
98784
|
Vb.anchor = "middle_left";
|
|
98375
98785
|
jb.anchor = "middle_right";
|
|
98376
98786
|
var tf = Il;
|
|
98377
|
-
var ef = { ac_voltmeter_down: Wl, ac_voltmeter_horz: Zl, ac_voltmeter_left: Kl, ac_voltmeter_right: ep, ac_voltmeter_up: op, ac_voltmeter_vert: lp, avalanche_diode_down: ap, avalanche_diode_horz: yp, avalanche_diode_left: sp, avalanche_diode_right: mp, avalanche_diode_up: fp, avalanche_diode_vert: cp, backward_diode_down: bp, backward_diode_left: Ut, backward_diode_right: up, backward_diode_up: vp, battery_horz: Zt, battery_vert: Sp, boxresistor_down: Tp, boxresistor_left: Xp, boxresistor_right: jp, boxresistor_small_down: zp, boxresistor_small_left: Jp, boxresistor_small_right: Mp, boxresistor_small_up: Np, boxresistor_up: qp, bridged_ground_down: Up, bridged_ground_left: Zp, bridged_ground_right: re, bridged_ground_up: ta, capacitor_down: ra, capacitor_left: oa, capacitor_polarized_down: la, capacitor_polarized_left: pa, capacitor_polarized_right: ya, capacitor_polarized_up: sa, capacitor_right: ma, capacitor_up: fa, constant_current_diode_down: ca, constant_current_diode_horz: da, constant_current_diode_left: _a, constant_current_diode_right: ga, constant_current_diode_up: va, constant_current_diode_vert: Aa, crystal_4pin_down: Pa, crystal_4pin_left: Sa, crystal_4pin_right: Fa, crystal_4pin_up: Ra, crystal_down: Ea, crystal_left: Ya, crystal_right: Xa, crystal_up: Va, darlington_pair_transistor_down: ja, darlington_pair_transistor_horz: ka, darlington_pair_transistor_left: za, darlington_pair_transistor_right: Oa, darlington_pair_transistor_up: Ja, darlington_pair_transistor_vert: $a, dc_ammeter_horz: Pt, dc_ammeter_vert: Ia, dc_voltmeter_down: qa, dc_voltmeter_horz: Ga, dc_voltmeter_left: Wa, dc_voltmeter_right: Za, dc_voltmeter_up: Ka, dc_voltmeter_vert: ey, diac_down: ry, diac_horz: oy, diac_left: iy, diac_right: ly, diac_up: py, diac_vert: ay, digital_ground_down: xy, digital_ground_left: my, digital_ground_right: fy, digital_ground_up: cy, diode_down: by, diode_left: _y, diode_right: C, diode_up: gy, dpdt_normally_closed_switch_down: vy, dpdt_normally_closed_switch_left: wy, dpdt_normally_closed_switch_right: N, dpdt_normally_closed_switch_up: Ay, dpdt_switch_down: Sy, dpdt_switch_left: Fy, dpdt_switch_right: I, dpdt_switch_up: Ry, dpst_normally_closed_switch_down: Ey, dpst_normally_closed_switch_left: Yy, dpst_normally_closed_switch_right: B, dpst_normally_closed_switch_up:
|
|
98787
|
+
var ef = { ac_voltmeter_down: Wl, ac_voltmeter_horz: Zl, ac_voltmeter_left: Kl, ac_voltmeter_right: ep, ac_voltmeter_up: op, ac_voltmeter_vert: lp, avalanche_diode_down: ap, avalanche_diode_horz: yp, avalanche_diode_left: sp, avalanche_diode_right: mp, avalanche_diode_up: fp, avalanche_diode_vert: cp, backward_diode_down: bp, backward_diode_left: Ut, backward_diode_right: up, backward_diode_up: vp, battery_horz: Zt, battery_vert: Sp, boxresistor_down: Tp, boxresistor_left: Xp, boxresistor_right: jp, boxresistor_small_down: zp, boxresistor_small_left: Jp, boxresistor_small_right: Mp, boxresistor_small_up: Np, boxresistor_up: qp, bridged_ground_down: Up, bridged_ground_left: Zp, bridged_ground_right: re, bridged_ground_up: ta, capacitor_down: ra, capacitor_left: oa, capacitor_polarized_down: la, capacitor_polarized_left: pa, capacitor_polarized_right: ya, capacitor_polarized_up: sa, capacitor_right: ma, capacitor_up: fa, constant_current_diode_down: ca, constant_current_diode_horz: da, constant_current_diode_left: _a, constant_current_diode_right: ga, constant_current_diode_up: va, constant_current_diode_vert: Aa, crystal_4pin_down: Pa, crystal_4pin_left: Sa, crystal_4pin_right: Fa, crystal_4pin_up: Ra, crystal_down: Ea, crystal_left: Ya, crystal_right: Xa, crystal_up: Va, darlington_pair_transistor_down: ja, darlington_pair_transistor_horz: ka, darlington_pair_transistor_left: za, darlington_pair_transistor_right: Oa, darlington_pair_transistor_up: Ja, darlington_pair_transistor_vert: $a, dc_ammeter_horz: Pt, dc_ammeter_vert: Ia, dc_voltmeter_down: qa, dc_voltmeter_horz: Ga, dc_voltmeter_left: Wa, dc_voltmeter_right: Za, dc_voltmeter_up: Ka, dc_voltmeter_vert: ey, diac_down: ry, diac_horz: oy, diac_left: iy, diac_right: ly, diac_up: py, diac_vert: ay, digital_ground_down: xy, digital_ground_left: my, digital_ground_right: fy, digital_ground_up: cy, diode_down: by, diode_left: _y, diode_right: C, diode_up: gy, dpdt_normally_closed_switch_down: vy, dpdt_normally_closed_switch_left: wy, dpdt_normally_closed_switch_right: N, dpdt_normally_closed_switch_up: Ay, dpdt_switch_down: Sy, dpdt_switch_left: Fy, dpdt_switch_right: I, dpdt_switch_up: Ry, dpst_normally_closed_switch_down: Ey, dpst_normally_closed_switch_left: Yy, dpst_normally_closed_switch_right: B, dpst_normally_closed_switch_up: Xy5, dpst_switch_down: Vy, dpst_switch_left: jy, dpst_switch_right: q, dpst_switch_up: ky2, ferrite_bead_down: Oy, ferrite_bead_left: Jy, ferrite_bead_right: Te, ferrite_bead_up: Re, filled_diode_down: My, filled_diode_horz: Ny, filled_diode_left: By, filled_diode_right: Dy, filled_diode_up: Uy, filled_diode_vert: Hy, frequency_meter_horz: St, frequency_meter_vert: tx, fuse_horz: Oe, fuse_vert: ox, ground_down: ix, ground_horz: lx, ground_left: px, ground_right: ax, ground_up: yx, ground_vert: xx, gunn_diode_horz: sx, gunn_diode_vert: mx, icled_down: fx, icled_left: hx, icled_right: D, icled_up: cx, igbt_transistor_horz: Je, igbt_transistor_vert: _x, illuminated_push_button_normally_open_horz: $e, illuminated_push_button_normally_open_vert: wx, inductor_down: Fx, inductor_left: Rx, inductor_right: ut, inductor_up: Ce, laser_diode_down: Tx, laser_diode_left: Ex, laser_diode_right: G, laser_diode_up: Yx, led_down: jx, led_left: kx, led_right: vt, led_up: Ie, light_dependent_resistor_horz: qe, light_dependent_resistor_vert: Cx, mosfet_depletion_normally_on_horz: Ge, mosfet_depletion_normally_on_vert: qx, mushroom_head_normally_open_momentary_horz: We, mushroom_head_normally_open_momentary_vert: Wx, n_channel_d_mosfet_transistor_horz: Qe, n_channel_d_mosfet_transistor_vert: ts2, n_channel_e_mosfet_transistor_horz: t0, n_channel_e_mosfet_transistor_vert: ls, njfet_transistor_horz: r0, njfet_transistor_vert: ss, not_connected_down: fs38, not_connected_left: hs, not_connected_right: U, not_connected_up: cs, npn_bipolar_transistor_down: ds, npn_bipolar_transistor_horz: bs, npn_bipolar_transistor_left: _s, npn_bipolar_transistor_right: gs, npn_bipolar_transistor_up: us, npn_bipolar_transistor_vert: vs, opamp_no_power_down: As, opamp_no_power_left: Ps, opamp_no_power_right: W, opamp_no_power_up: Ss, opamp_with_power_down: Rs, opamp_with_power_left: Ts, opamp_with_power_right: H, opamp_with_power_up: Es, p_channel_d_mosfet_transistor_horz: x0, p_channel_d_mosfet_transistor_vert: js, p_channel_e_mosfet_transistor_horz: m0, p_channel_e_mosfet_transistor_vert: $s, photodiode_horz: n0, photodiode_vert: Is, pjfet_transistor_horz: h0, pjfet_transistor_vert: Us, pnp_bipolar_transistor_down: Ws, pnp_bipolar_transistor_horz: Hs, pnp_bipolar_transistor_left: Zs, pnp_bipolar_transistor_right: Qs, pnp_bipolar_transistor_up: Ks, pnp_bipolar_transistor_vert: tm, potentiometer_horz: v0, potentiometer_vert: im, potentiometer2_down: ym, potentiometer2_left: xm, potentiometer2_right: Z, potentiometer2_up: sm, potentiometer3_down: mm, potentiometer3_left: nm, potentiometer3_right: fm, potentiometer3_up: hm, power_factor_meter_horz: R0, power_factor_meter_vert: _m, push_button_normally_closed_momentary_horz: E0, push_button_normally_closed_momentary_vert: wm, push_button_normally_open_momentary_horz: X0, push_button_normally_open_momentary_vert: Fm, rail_down: Tm, rail_left: Ym, rail_right: Lm, rail_up: jm, rectifier_diode_horz: j0, rectifier_diode_vert: Om, resistor_down: $m, resistor_left: Cm, resistor_right: Im, resistor_up: qm, resonator_down: Gm, resonator_horz: N0, resonator_left: Um, resonator_right: et, resonator_up: Wm, resonator_vert: Hm, schottky_diode_down: Qm, schottky_diode_left: Km, schottky_diode_right: rt, schottky_diode_up: tn, silicon_controlled_rectifier_horz: I0, silicon_controlled_rectifier_vert: on2, solderjumper2_bridged12_down: ln, solderjumper2_bridged12_left: pn, solderjumper2_bridged12_right: an, solderjumper2_bridged12_up: yn, solderjumper2_down: xn, solderjumper2_left: sn, solderjumper2_right: mn, solderjumper2_up: nn, solderjumper3_bridged12_down: fn, solderjumper3_bridged12_left: hn, solderjumper3_bridged12_right: cn, solderjumper3_bridged12_up: dn, solderjumper3_bridged123_down: bn, solderjumper3_bridged123_left: _n, solderjumper3_bridged123_right: gn, solderjumper3_bridged123_up: un, solderjumper3_bridged23_down: vn, solderjumper3_bridged23_left: wn, solderjumper3_bridged23_right: An, solderjumper3_bridged23_up: Pn, solderjumper3_down: Sn, solderjumper3_left: Fn, solderjumper3_right: Rn, solderjumper3_up: Tn, spdt_normally_closed_switch_down: Yn, spdt_normally_closed_switch_left: Xn, spdt_normally_closed_switch_right: xt, spdt_normally_closed_switch_up: Ln, spdt_switch_down: jn, spdt_switch_left: kn, spdt_switch_right: st, spdt_switch_up: zn, spst_normally_closed_switch_down: On, spst_normally_closed_switch_left: Jn, spst_normally_closed_switch_right: mt, spst_normally_closed_switch_up: $n, spst_switch_down: Mn, spst_switch_left: Cn, spst_switch_right: nt, spst_switch_up: Nn, square_wave_down: In, square_wave_left: Bn, square_wave_right: qn, square_wave_up: Dn, step_recovery_diode_horz: B0, step_recovery_diode_vert: Gn, tachometer_horz: Yt, tachometer_vert: Zn, testpoint_down: t1, testpoint_left: e1, testpoint_right: ht, testpoint_up: i1, tilted_ground_down: p1, tilted_ground_left: a1, tilted_ground_right: wt, tilted_ground_up: D0, triac_horz: G0, triac_vert: s1, tunnel_diode_horz: W0, tunnel_diode_vert: h1, unijunction_transistor_horz: Z0, unijunction_transistor_vert: u1, usbc: w1, var_meter_horz: K0, var_meter_vert: S1, varactor_diode_horz: er, varactor_diode_vert: E1, varistor_horz: or, varistor_vert: V1, varmeter_horz: Xt, varmeter_vert: O1, vcc_down: J1, vcc_left: $1, vcc_right: M1, vcc_up: C1, volt_meter_horz: lr, volt_meter_vert: N1, watt_hour_meter_horz: Lt, watt_hour_meter_vert: D1, wattmeter_horz: Vt, wattmeter_vert: H1, zener_diode_horz: xr, zener_diode_vert: tf };
|
|
98378
98788
|
var gM = Object.fromEntries(Object.keys(ef).map((t) => [t, t]));
|
|
98379
98789
|
function doesLineIntersectLine([a12, a22], [b12, b22], {
|
|
98380
98790
|
lineThickness = 0
|
|
@@ -130790,10 +131200,10 @@ var gt2 = class {
|
|
|
130790
131200
|
return o22 = Et2(t3.slice(e22, s22 + 1)), xt2(o22, this.toBBox), o22;
|
|
130791
131201
|
n22 || (n22 = Math.ceil(Math.log(i22) / Math.log(a22)), a22 = Math.ceil(i22 / Math.pow(a22, n22 - 1))), o22 = Et2([]), o22.leaf = false, o22.height = n22;
|
|
130792
131202
|
const r22 = Math.ceil(i22 / a22), h22 = r22 * Math.ceil(Math.sqrt(a22));
|
|
130793
|
-
|
|
131203
|
+
At6(t3, e22, s22, h22, this.compareMinX);
|
|
130794
131204
|
for (let i3 = e22;i3 <= s22; i3 += h22) {
|
|
130795
131205
|
const e32 = Math.min(i3 + h22 - 1, s22);
|
|
130796
|
-
|
|
131206
|
+
At6(t3, i3, e32, r22, this.compareMinY);
|
|
130797
131207
|
for (let s32 = i3;s32 <= e32; s32 += r22) {
|
|
130798
131208
|
const i4 = Math.min(s32 + r22 - 1, e32);
|
|
130799
131209
|
o22.children.push(this._build(t3, s32, i4, n22 - 1));
|
|
@@ -130912,7 +131322,7 @@ function Tt2(t3, e22) {
|
|
|
130912
131322
|
function Et2(t3) {
|
|
130913
131323
|
return { children: t3, height: 1, leaf: true, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
|
|
130914
131324
|
}
|
|
130915
|
-
function
|
|
131325
|
+
function At6(t3, e22, s22, n22, i22) {
|
|
130916
131326
|
const o22 = [e22, s22];
|
|
130917
131327
|
for (;o22.length; ) {
|
|
130918
131328
|
if ((s22 = o22.pop()) - (e22 = o22.pop()) <= n22)
|
|
@@ -155576,7 +155986,7 @@ function rectanglePolygon({
|
|
|
155576
155986
|
if (rotationDeg) {
|
|
155577
155987
|
const matrix2 = rotateDEG(rotationDeg, cx2, cy2);
|
|
155578
155988
|
const rotatedCorners = corners.map((pt22) => {
|
|
155579
|
-
const p22 =
|
|
155989
|
+
const p22 = applyToPoint18(matrix2, { x: pt22.x, y: pt22.y });
|
|
155580
155990
|
return new Point$3(p22.x, p22.y);
|
|
155581
155991
|
});
|
|
155582
155992
|
poly = new Polygon$1(rotatedCorners);
|
|
@@ -155641,7 +156051,7 @@ function computeOverlapDistance(compPoly, boardPoly, componentCenter, componentW
|
|
|
155641
156051
|
}
|
|
155642
156052
|
const matrix2 = rotateDEG(rotationDeg, componentCenter.x, componentCenter.y);
|
|
155643
156053
|
const rotatePoint3 = (pt22) => {
|
|
155644
|
-
const p22 =
|
|
156054
|
+
const p22 = applyToPoint18(matrix2, pt22);
|
|
155645
156055
|
return new Point$3(p22.x, p22.y);
|
|
155646
156056
|
};
|
|
155647
156057
|
const rotatedPoints = corners.concat(midpoints).map(rotatePoint3);
|
|
@@ -156650,25 +157060,25 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
156650
157060
|
computePcbPropsTransform() {
|
|
156651
157061
|
const { _parsedProps: props } = this;
|
|
156652
157062
|
const rotation5 = this._getPcbRotationBeforeLayout() ?? 0;
|
|
156653
|
-
const matrix2 = compose4(translate4(props.pcbX ?? 0, props.pcbY ?? 0),
|
|
157063
|
+
const matrix2 = compose4(translate4(props.pcbX ?? 0, props.pcbY ?? 0), rotate6(rotation5 * Math.PI / 180));
|
|
156654
157064
|
return matrix2;
|
|
156655
157065
|
}
|
|
156656
157066
|
_computePcbGlobalTransformBeforeLayout() {
|
|
156657
157067
|
const manualPlacement = this.getSubcircuit()._getPcbManualPlacementForComponent(this);
|
|
156658
157068
|
if (manualPlacement && this.props.pcbX === undefined && this.props.pcbY === undefined) {
|
|
156659
157069
|
const rotation5 = this._getPcbRotationBeforeLayout() ?? 0;
|
|
156660
|
-
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ??
|
|
157070
|
+
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity5(), compose4(translate4(manualPlacement.x, manualPlacement.y), rotate6(rotation5 * Math.PI / 180)));
|
|
156661
157071
|
}
|
|
156662
157072
|
if (this.isPcbPrimitive) {
|
|
156663
157073
|
const primitiveContainer = this.getPrimitiveContainer();
|
|
156664
157074
|
if (primitiveContainer) {
|
|
156665
157075
|
const isFlipped = primitiveContainer._parsedProps.layer === "bottom";
|
|
156666
157076
|
if (isFlipped) {
|
|
156667
|
-
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ??
|
|
157077
|
+
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity5(), flipY(), this.computePcbPropsTransform());
|
|
156668
157078
|
}
|
|
156669
157079
|
}
|
|
156670
157080
|
}
|
|
156671
|
-
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ??
|
|
157081
|
+
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity5(), this.computePcbPropsTransform());
|
|
156672
157082
|
}
|
|
156673
157083
|
getPrimitiveContainer() {
|
|
156674
157084
|
if (this.isPrimitiveContainer)
|
|
@@ -156715,7 +157125,7 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
156715
157125
|
const manualPlacementTransform = this._getSchematicGlobalManualPlacementTransform(this);
|
|
156716
157126
|
if (manualPlacementTransform)
|
|
156717
157127
|
return manualPlacementTransform;
|
|
156718
|
-
return compose4(this.parent?.computeSchematicGlobalTransform?.() ??
|
|
157128
|
+
return compose4(this.parent?.computeSchematicGlobalTransform?.() ?? identity5(), this.computeSchematicPropsTransform());
|
|
156719
157129
|
}
|
|
156720
157130
|
_getSchematicSymbolName() {
|
|
156721
157131
|
const { _parsedProps: props } = this;
|
|
@@ -156801,7 +157211,7 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
156801
157211
|
return null;
|
|
156802
157212
|
for (const position2 of placementConfigPositions) {
|
|
156803
157213
|
if (isMatchingSelector(component, position2.selector) || component.props.name === position2.selector) {
|
|
156804
|
-
const center2 =
|
|
157214
|
+
const center2 = applyToPoint18(this._computePcbGlobalTransformBeforeLayout(), position2.center);
|
|
156805
157215
|
return center2;
|
|
156806
157216
|
}
|
|
156807
157217
|
}
|
|
@@ -156818,7 +157228,7 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
156818
157228
|
return null;
|
|
156819
157229
|
for (const position2 of placementConfigPositions) {
|
|
156820
157230
|
if (isMatchingSelector(component, position2.selector) || component.props.name === position2.selector) {
|
|
156821
|
-
const center2 =
|
|
157231
|
+
const center2 = applyToPoint18(this.computeSchematicGlobalTransform(), position2.center);
|
|
156822
157232
|
return center2;
|
|
156823
157233
|
}
|
|
156824
157234
|
}
|
|
@@ -156831,20 +157241,20 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
156831
157241
|
for (const position2 of manualEdits.schematic_placements ?? []) {
|
|
156832
157242
|
if (isMatchingSelector(component, position2.selector) || component.props.name === position2.selector) {
|
|
156833
157243
|
if (position2.relative_to === "group_center") {
|
|
156834
|
-
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ??
|
|
157244
|
+
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity5(), translate4(position2.center.x, position2.center.y));
|
|
156835
157245
|
}
|
|
156836
157246
|
}
|
|
156837
157247
|
}
|
|
156838
157248
|
return null;
|
|
156839
157249
|
}
|
|
156840
157250
|
_getGlobalPcbPositionBeforeLayout() {
|
|
156841
|
-
return
|
|
157251
|
+
return applyToPoint18(this._computePcbGlobalTransformBeforeLayout(), {
|
|
156842
157252
|
x: 0,
|
|
156843
157253
|
y: 0
|
|
156844
157254
|
});
|
|
156845
157255
|
}
|
|
156846
157256
|
_getGlobalSchematicPositionBeforeLayout() {
|
|
156847
|
-
return
|
|
157257
|
+
return applyToPoint18(this.computeSchematicGlobalTransform(), { x: 0, y: 0 });
|
|
156848
157258
|
}
|
|
156849
157259
|
get root() {
|
|
156850
157260
|
return this.parent?.root ?? null;
|
|
@@ -157289,7 +157699,7 @@ var createInstanceFromReactElement = (reactElm) => {
|
|
|
157289
157699
|
this.children.push(instance);
|
|
157290
157700
|
},
|
|
157291
157701
|
computePcbGlobalTransform() {
|
|
157292
|
-
return
|
|
157702
|
+
return identity5();
|
|
157293
157703
|
}
|
|
157294
157704
|
};
|
|
157295
157705
|
const containerErrors = [];
|
|
@@ -157759,7 +158169,7 @@ var SmtPad = class extends PrimitiveComponent2 {
|
|
|
157759
158169
|
});
|
|
157760
158170
|
} else if (props.shape === "polygon") {
|
|
157761
158171
|
const transformedPoints = props.points.map((point5) => {
|
|
157762
|
-
const transformed =
|
|
158172
|
+
const transformed = applyToPoint18(globalTransform, {
|
|
157763
158173
|
x: distance.parse(point5.x),
|
|
157764
158174
|
y: distance.parse(point5.y)
|
|
157765
158175
|
});
|
|
@@ -157936,7 +158346,7 @@ var SilkscreenPath = class extends PrimitiveComponent2 {
|
|
|
157936
158346
|
pcb_component_id,
|
|
157937
158347
|
layer,
|
|
157938
158348
|
route: props.route.map((p22) => {
|
|
157939
|
-
const transformedPosition =
|
|
158349
|
+
const transformedPosition = applyToPoint18(transform2, {
|
|
157940
158350
|
x: p22.x,
|
|
157941
158351
|
y: p22.y
|
|
157942
158352
|
});
|
|
@@ -158019,7 +158429,7 @@ var PcbTrace = class extends PrimitiveComponent2 {
|
|
|
158019
158429
|
const parentTransform = this._computePcbGlobalTransformBeforeLayout();
|
|
158020
158430
|
const transformedRoute = props.route.map((point5) => {
|
|
158021
158431
|
const { x: x22, y: y22, ...restOfPoint } = point5;
|
|
158022
|
-
const transformedPoint =
|
|
158432
|
+
const transformedPoint = applyToPoint18(parentTransform, { x: x22, y: y22 });
|
|
158023
158433
|
if (point5.route_type === "wire" && point5.layer) {
|
|
158024
158434
|
return {
|
|
158025
158435
|
...transformedPoint,
|
|
@@ -158525,7 +158935,7 @@ var Cutout = class extends PrimitiveComponent2 {
|
|
|
158525
158935
|
inserted_pcb_cutout = db.pcb_cutout.insert(circleData);
|
|
158526
158936
|
} else if (props.shape === "polygon") {
|
|
158527
158937
|
const transform2 = this._computePcbGlobalTransformBeforeLayout();
|
|
158528
|
-
const transformedPoints = props.points.map((p22) =>
|
|
158938
|
+
const transformedPoints = props.points.map((p22) => applyToPoint18(transform2, p22));
|
|
158529
158939
|
const polygonData = {
|
|
158530
158940
|
shape: "polygon",
|
|
158531
158941
|
points: transformedPoints,
|
|
@@ -159226,7 +159636,7 @@ var Port = class extends PrimitiveComponent2 {
|
|
|
159226
159636
|
}
|
|
159227
159637
|
}
|
|
159228
159638
|
const transform2 = compose4(parentNormalComponent.computeSchematicGlobalTransform(), translate4(-symbol.center.x, -symbol.center.y));
|
|
159229
|
-
return
|
|
159639
|
+
return applyToPoint18(transform2, schematicSymbolPortDef);
|
|
159230
159640
|
}
|
|
159231
159641
|
const parentBoxDim = parentNormalComponent?._getSchematicBoxDimensions();
|
|
159232
159642
|
if (parentBoxDim && this.props.pinNumber !== undefined) {
|
|
@@ -159234,7 +159644,7 @@ var Port = class extends PrimitiveComponent2 {
|
|
|
159234
159644
|
if (!localPortPosition) {
|
|
159235
159645
|
throw new Error(`Couldn't find position for schematic_port for port ${this.getString()} inside of the schematic box`);
|
|
159236
159646
|
}
|
|
159237
|
-
return
|
|
159647
|
+
return applyToPoint18(parentNormalComponent.computeSchematicGlobalTransform(), localPortPosition);
|
|
159238
159648
|
}
|
|
159239
159649
|
throw new Error(`Couldn't find position for schematic_port for port ${this.getString()}`);
|
|
159240
159650
|
}
|
|
@@ -161837,7 +162247,7 @@ function Trace_doInitialPcbManualTraceRender(trace) {
|
|
|
161837
162247
|
layer,
|
|
161838
162248
|
start_pcb_port_id: anchorPort.pcb_port_id
|
|
161839
162249
|
});
|
|
161840
|
-
const transform2 = anchorPort?._computePcbGlobalTransformBeforeLayout?.() ||
|
|
162250
|
+
const transform2 = anchorPort?._computePcbGlobalTransformBeforeLayout?.() || identity5();
|
|
161841
162251
|
for (const pt22 of props.pcbPath) {
|
|
161842
162252
|
let coordinates;
|
|
161843
162253
|
let isGlobalPosition = false;
|
|
@@ -161863,7 +162273,7 @@ function Trace_doInitialPcbManualTraceRender(trace) {
|
|
|
161863
162273
|
coordinates = { x: pt22.x, y: pt22.y };
|
|
161864
162274
|
isGlobalPosition = false;
|
|
161865
162275
|
}
|
|
161866
|
-
const finalCoordinates = isGlobalPosition ? coordinates :
|
|
162276
|
+
const finalCoordinates = isGlobalPosition ? coordinates : applyToPoint18(transform2, coordinates);
|
|
161867
162277
|
route.push({
|
|
161868
162278
|
route_type: "wire",
|
|
161869
162279
|
x: finalCoordinates.x,
|
|
@@ -164052,7 +164462,7 @@ var TraceHint = class extends PrimitiveComponent2 {
|
|
|
164052
164462
|
return [];
|
|
164053
164463
|
const globalTransform = this._computePcbGlobalTransformBeforeLayout();
|
|
164054
164464
|
return offsets.map((offset) => ({
|
|
164055
|
-
...
|
|
164465
|
+
...applyToPoint18(globalTransform, offset),
|
|
164056
164466
|
via: offset.via,
|
|
164057
164467
|
to_layer: offset.to_layer,
|
|
164058
164468
|
trace_width: offset.trace_width
|
|
@@ -165936,7 +166346,7 @@ var applyPackOutput = (group, packOutput, clusterMap) => {
|
|
|
165936
166346
|
if (!member)
|
|
165937
166347
|
continue;
|
|
165938
166348
|
const originalCenter2 = member.center;
|
|
165939
|
-
const transformMatrix2 = compose4(group._computePcbGlobalTransformBeforeLayout(), translate4(center2.x + rotatedRel.x, center2.y + rotatedRel.y),
|
|
166349
|
+
const transformMatrix2 = compose4(group._computePcbGlobalTransformBeforeLayout(), translate4(center2.x + rotatedRel.x, center2.y + rotatedRel.y), rotate6(angleRad), translate4(-originalCenter2.x, -originalCenter2.y));
|
|
165940
166350
|
const related = db.toArray().filter((elm) => ("pcb_component_id" in elm) && elm.pcb_component_id === memberId);
|
|
165941
166351
|
transformPCBElements(related, transformMatrix2);
|
|
165942
166352
|
updateCadRotation({
|
|
@@ -165958,7 +166368,7 @@ var applyPackOutput = (group, packOutput, clusterMap) => {
|
|
|
165958
166368
|
}
|
|
165959
166369
|
const originalCenter2 = pcbComponent.center;
|
|
165960
166370
|
const rotationDegrees2 = ccwRotationDegrees ?? ccwRotationOffset ?? 0;
|
|
165961
|
-
const transformMatrix2 = compose4(group._computePcbGlobalTransformBeforeLayout(), translate4(center2.x, center2.y),
|
|
166371
|
+
const transformMatrix2 = compose4(group._computePcbGlobalTransformBeforeLayout(), translate4(center2.x, center2.y), rotate6(rotationDegrees2 * Math.PI / 180), translate4(-originalCenter2.x, -originalCenter2.y));
|
|
165962
166372
|
const related = db.toArray().filter((elm) => ("pcb_component_id" in elm) && elm.pcb_component_id === componentId);
|
|
165963
166373
|
transformPCBElements(related, transformMatrix2);
|
|
165964
166374
|
updateCadRotation({
|
|
@@ -165974,7 +166384,7 @@ var applyPackOutput = (group, packOutput, clusterMap) => {
|
|
|
165974
166384
|
continue;
|
|
165975
166385
|
const originalCenter = pcbGroup.center;
|
|
165976
166386
|
const rotationDegrees = ccwRotationDegrees ?? ccwRotationOffset ?? 0;
|
|
165977
|
-
const transformMatrix = compose4(group._computePcbGlobalTransformBeforeLayout(), translate4(center2.x, center2.y),
|
|
166387
|
+
const transformMatrix = compose4(group._computePcbGlobalTransformBeforeLayout(), translate4(center2.x, center2.y), rotate6(rotationDegrees * Math.PI / 180), translate4(-originalCenter.x, -originalCenter.y));
|
|
165978
166388
|
const relatedElements = db.toArray().filter((elm) => {
|
|
165979
166389
|
if ("source_group_id" in elm && elm.source_group_id) {
|
|
165980
166390
|
if (elm.source_group_id === componentId) {
|
|
@@ -168367,7 +168777,7 @@ var Board = class extends Group6 {
|
|
|
168367
168777
|
this.pcb_board_id = null;
|
|
168368
168778
|
}
|
|
168369
168779
|
_computePcbGlobalTransformBeforeLayout() {
|
|
168370
|
-
return
|
|
168780
|
+
return identity5();
|
|
168371
168781
|
}
|
|
168372
168782
|
doInitialPcbDesignRuleChecks() {
|
|
168373
168783
|
if (this.root?.pcbDisabled)
|
|
@@ -169362,7 +169772,7 @@ var FabricationNotePath = class extends PrimitiveComponent2 {
|
|
|
169362
169772
|
layer,
|
|
169363
169773
|
color: props.color,
|
|
169364
169774
|
route: props.route.map((p22) => {
|
|
169365
|
-
const transformedPosition =
|
|
169775
|
+
const transformedPosition = applyToPoint18(transform2, {
|
|
169366
169776
|
x: p22.x,
|
|
169367
169777
|
y: p22.y
|
|
169368
169778
|
});
|
|
@@ -169423,13 +169833,13 @@ var FabricationNoteDimension = class extends PrimitiveComponent2 {
|
|
|
169423
169833
|
const target = this.getSubcircuit().selectOne(input);
|
|
169424
169834
|
if (!target) {
|
|
169425
169835
|
this.renderError(`FabricationNoteDimension could not find selector "${input}"`);
|
|
169426
|
-
return
|
|
169836
|
+
return applyToPoint18(transform2, { x: 0, y: 0 });
|
|
169427
169837
|
}
|
|
169428
169838
|
return target._getGlobalPcbPositionBeforeLayout();
|
|
169429
169839
|
}
|
|
169430
169840
|
const numericX = typeof input.x === "string" ? parseFloat(input.x) : input.x;
|
|
169431
169841
|
const numericY = typeof input.y === "string" ? parseFloat(input.y) : input.y;
|
|
169432
|
-
return
|
|
169842
|
+
return applyToPoint18(transform2, { x: numericX, y: numericY });
|
|
169433
169843
|
}
|
|
169434
169844
|
doInitialPcbPrimitiveRender() {
|
|
169435
169845
|
if (this.root?.pcbDisabled)
|
|
@@ -169509,8 +169919,8 @@ var PcbNoteLine = class extends PrimitiveComponent2 {
|
|
|
169509
169919
|
const subcircuit = this.getSubcircuit();
|
|
169510
169920
|
const group = this.getGroup();
|
|
169511
169921
|
const transform2 = this._computePcbGlobalTransformBeforeLayout();
|
|
169512
|
-
const start =
|
|
169513
|
-
const end =
|
|
169922
|
+
const start = applyToPoint18(transform2, { x: props.x1, y: props.y1 });
|
|
169923
|
+
const end = applyToPoint18(transform2, { x: props.x2, y: props.y2 });
|
|
169514
169924
|
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? undefined;
|
|
169515
169925
|
const pcb_note_line2 = db.pcb_note_line.insert({
|
|
169516
169926
|
pcb_component_id,
|
|
@@ -169549,7 +169959,7 @@ var PcbNoteRect = class extends PrimitiveComponent2 {
|
|
|
169549
169959
|
const { db } = this.root;
|
|
169550
169960
|
const { _parsedProps: props } = this;
|
|
169551
169961
|
const transform2 = this._computePcbGlobalTransformBeforeLayout();
|
|
169552
|
-
const center2 =
|
|
169962
|
+
const center2 = applyToPoint18(transform2, { x: 0, y: 0 });
|
|
169553
169963
|
const subcircuit = this.getSubcircuit();
|
|
169554
169964
|
const group = this.getGroup();
|
|
169555
169965
|
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? undefined;
|
|
@@ -169591,7 +170001,7 @@ var PcbNoteText = class extends PrimitiveComponent2 {
|
|
|
169591
170001
|
const { db } = this.root;
|
|
169592
170002
|
const { _parsedProps: props } = this;
|
|
169593
170003
|
const transform2 = this._computePcbGlobalTransformBeforeLayout();
|
|
169594
|
-
const anchorPosition =
|
|
170004
|
+
const anchorPosition = applyToPoint18(transform2, { x: 0, y: 0 });
|
|
169595
170005
|
const subcircuit = this.getSubcircuit();
|
|
169596
170006
|
const group = this.getGroup();
|
|
169597
170007
|
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? undefined;
|
|
@@ -169639,7 +170049,7 @@ var PcbNotePath = class extends PrimitiveComponent2 {
|
|
|
169639
170049
|
const { x: x22, y: y22, ...rest } = point5;
|
|
169640
170050
|
const numericX = typeof x22 === "string" ? parseFloat(x22) : x22;
|
|
169641
170051
|
const numericY = typeof y22 === "string" ? parseFloat(y22) : y22;
|
|
169642
|
-
const transformed =
|
|
170052
|
+
const transformed = applyToPoint18(transform2, { x: numericX, y: numericY });
|
|
169643
170053
|
return { ...rest, x: transformed.x, y: transformed.y };
|
|
169644
170054
|
});
|
|
169645
170055
|
const pcb_note_path2 = db.pcb_note_path.insert({
|
|
@@ -169679,13 +170089,13 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
|
|
|
169679
170089
|
const target = this.getSubcircuit().selectOne(`.${input}`);
|
|
169680
170090
|
if (!target) {
|
|
169681
170091
|
this.renderError(`PcbNoteDimension could not find selector "${input}"`);
|
|
169682
|
-
return
|
|
170092
|
+
return applyToPoint18(transform2, { x: 0, y: 0 });
|
|
169683
170093
|
}
|
|
169684
170094
|
return target._getGlobalPcbPositionBeforeLayout();
|
|
169685
170095
|
}
|
|
169686
170096
|
const numericX = typeof input.x === "string" ? parseFloat(input.x) : input.x;
|
|
169687
170097
|
const numericY = typeof input.y === "string" ? parseFloat(input.y) : input.y;
|
|
169688
|
-
return
|
|
170098
|
+
return applyToPoint18(transform2, { x: numericX, y: numericY });
|
|
169689
170099
|
}
|
|
169690
170100
|
doInitialPcbPrimitiveRender() {
|
|
169691
170101
|
if (this.root?.pcbDisabled)
|
|
@@ -170091,7 +170501,7 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
170091
170501
|
const connectedPorts = this._getConnectedPorts();
|
|
170092
170502
|
if (connectedPorts.length > 0) {
|
|
170093
170503
|
const portPos = connectedPorts[0]._getGlobalSchematicPositionBeforeLayout();
|
|
170094
|
-
const parentCenter =
|
|
170504
|
+
const parentCenter = applyToPoint18(this.parent?.computeSchematicGlobalTransform?.() ?? identity5(), { x: 0, y: 0 });
|
|
170095
170505
|
return translate4(portPos.x - parentCenter.x, portPos.y - parentCenter.y);
|
|
170096
170506
|
}
|
|
170097
170507
|
}
|
|
@@ -172232,22 +172642,22 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
|
|
|
172232
172642
|
for (const e22 of circuitElements) {
|
|
172233
172643
|
if (e22.type === "pcb_cutout") {
|
|
172234
172644
|
if (e22.shape === "polygon") {
|
|
172235
|
-
e22.points = e22.points.map((p22) =>
|
|
172645
|
+
e22.points = e22.points.map((p22) => applyToPoint18(matrix2, p22));
|
|
172236
172646
|
} else if (e22.shape === "circle" || e22.shape === "rect") {
|
|
172237
|
-
e22.center =
|
|
172647
|
+
e22.center = applyToPoint18(matrix2, e22.center);
|
|
172238
172648
|
} else if ("route" in e22) {
|
|
172239
172649
|
const cutoutPath = e22;
|
|
172240
|
-
cutoutPath.route = cutoutPath.route.map((p22) =>
|
|
172650
|
+
cutoutPath.route = cutoutPath.route.map((p22) => applyToPoint18(matrix2, p22));
|
|
172241
172651
|
}
|
|
172242
172652
|
} else if (e22.type === "pcb_smtpad" && e22.shape === "polygon") {
|
|
172243
|
-
e22.points = e22.points.map((p22) =>
|
|
172653
|
+
e22.points = e22.points.map((p22) => applyToPoint18(matrix2, p22));
|
|
172244
172654
|
}
|
|
172245
172655
|
}
|
|
172246
172656
|
const cad = circuitElements.find((e22) => e22.type === "cad_component");
|
|
172247
172657
|
if (cad) {
|
|
172248
172658
|
if (!cad.rotation)
|
|
172249
172659
|
cad.rotation = { x: 0, y: 0, z: 0 };
|
|
172250
|
-
const p22 =
|
|
172660
|
+
const p22 = applyToPoint18(matrix2, { x: cad.position.x, y: cad.position.y });
|
|
172251
172661
|
cad.position.x = p22.x;
|
|
172252
172662
|
cad.position.y = p22.y;
|
|
172253
172663
|
const side = pcb_component2.layer ?? "top";
|