@tscircuit/core 0.0.872 → 0.0.874
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/index.d.ts +21 -0
- package/dist/index.js +152 -68
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -660,6 +660,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
660
660
|
x: string | number;
|
|
661
661
|
y: string | number;
|
|
662
662
|
}>, z.ZodString]>, "many">>;
|
|
663
|
+
pcbStraightLine: z.ZodOptional<z.ZodBoolean>;
|
|
663
664
|
schDisplayLabel: z.ZodOptional<z.ZodString>;
|
|
664
665
|
schStroke: z.ZodOptional<z.ZodString>;
|
|
665
666
|
highlightColor: z.ZodOptional<z.ZodString>;
|
|
@@ -695,6 +696,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
695
696
|
x: number;
|
|
696
697
|
y: number;
|
|
697
698
|
})[] | undefined;
|
|
699
|
+
pcbStraightLine?: boolean | undefined;
|
|
698
700
|
schDisplayLabel?: string | undefined;
|
|
699
701
|
schStroke?: string | undefined;
|
|
700
702
|
}, {
|
|
@@ -724,6 +726,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
724
726
|
x: string | number;
|
|
725
727
|
y: string | number;
|
|
726
728
|
})[] | undefined;
|
|
729
|
+
pcbStraightLine?: boolean | undefined;
|
|
727
730
|
schDisplayLabel?: string | undefined;
|
|
728
731
|
schStroke?: string | undefined;
|
|
729
732
|
}>, z.ZodObject<{
|
|
@@ -780,6 +783,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
780
783
|
x: string | number;
|
|
781
784
|
y: string | number;
|
|
782
785
|
}>, z.ZodString]>, "many">>;
|
|
786
|
+
pcbStraightLine: z.ZodOptional<z.ZodBoolean>;
|
|
783
787
|
schDisplayLabel: z.ZodOptional<z.ZodString>;
|
|
784
788
|
schStroke: z.ZodOptional<z.ZodString>;
|
|
785
789
|
highlightColor: z.ZodOptional<z.ZodString>;
|
|
@@ -823,6 +827,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
823
827
|
x: number;
|
|
824
828
|
y: number;
|
|
825
829
|
})[] | undefined;
|
|
830
|
+
pcbStraightLine?: boolean | undefined;
|
|
826
831
|
schDisplayLabel?: string | undefined;
|
|
827
832
|
schStroke?: string | undefined;
|
|
828
833
|
}, {
|
|
@@ -855,6 +860,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
855
860
|
x: string | number;
|
|
856
861
|
y: string | number;
|
|
857
862
|
})[] | undefined;
|
|
863
|
+
pcbStraightLine?: boolean | undefined;
|
|
858
864
|
schDisplayLabel?: string | undefined;
|
|
859
865
|
schStroke?: string | undefined;
|
|
860
866
|
}>]>;
|
|
@@ -3240,6 +3246,11 @@ declare class Panel extends Group<typeof panelProps> {
|
|
|
3240
3246
|
height: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
|
|
3241
3247
|
children: zod.ZodOptional<zod.ZodAny>;
|
|
3242
3248
|
noSolderMask: zod.ZodOptional<zod.ZodBoolean>;
|
|
3249
|
+
panelizationMethod: zod.ZodOptional<zod.ZodEnum<["tab-routing", "none"]>>;
|
|
3250
|
+
boardGap: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
3251
|
+
tabWidth: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
3252
|
+
tabLength: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
3253
|
+
mouseBites: zod.ZodOptional<zod.ZodBoolean>;
|
|
3243
3254
|
}, "strip", zod.ZodTypeAny, {
|
|
3244
3255
|
width: number;
|
|
3245
3256
|
height: number;
|
|
@@ -3484,6 +3495,11 @@ declare class Panel extends Group<typeof panelProps> {
|
|
|
3484
3495
|
schPack?: boolean | undefined;
|
|
3485
3496
|
schMatchAdapt?: boolean | undefined;
|
|
3486
3497
|
noSolderMask?: boolean | undefined;
|
|
3498
|
+
panelizationMethod?: "none" | "tab-routing" | undefined;
|
|
3499
|
+
boardGap?: number | undefined;
|
|
3500
|
+
tabWidth?: number | undefined;
|
|
3501
|
+
tabLength?: number | undefined;
|
|
3502
|
+
mouseBites?: boolean | undefined;
|
|
3487
3503
|
}, {
|
|
3488
3504
|
width: string | number;
|
|
3489
3505
|
height: string | number;
|
|
@@ -3730,6 +3746,11 @@ declare class Panel extends Group<typeof panelProps> {
|
|
|
3730
3746
|
schPack?: boolean | undefined;
|
|
3731
3747
|
schMatchAdapt?: boolean | undefined;
|
|
3732
3748
|
noSolderMask?: boolean | undefined;
|
|
3749
|
+
panelizationMethod?: "none" | "tab-routing" | undefined;
|
|
3750
|
+
boardGap?: string | number | undefined;
|
|
3751
|
+
tabWidth?: string | number | undefined;
|
|
3752
|
+
tabLength?: string | number | undefined;
|
|
3753
|
+
mouseBites?: boolean | undefined;
|
|
3733
3754
|
}>;
|
|
3734
3755
|
};
|
|
3735
3756
|
get isGroup(): boolean;
|
package/dist/index.js
CHANGED
|
@@ -6457,6 +6457,9 @@ function Trace_doInitialPcbTraceRender(trace) {
|
|
|
6457
6457
|
if (props.pcbPath && props.pcbPath.length > 0) {
|
|
6458
6458
|
return;
|
|
6459
6459
|
}
|
|
6460
|
+
if (props.pcbStraightLine) {
|
|
6461
|
+
return;
|
|
6462
|
+
}
|
|
6460
6463
|
if (!subcircuit._shouldUseTraceByTraceRouting()) {
|
|
6461
6464
|
return;
|
|
6462
6465
|
}
|
|
@@ -6718,7 +6721,9 @@ function Trace_doInitialPcbManualTraceRender(trace) {
|
|
|
6718
6721
|
const { db } = trace.root;
|
|
6719
6722
|
const { _parsedProps: props } = trace;
|
|
6720
6723
|
const subcircuit = trace.getSubcircuit();
|
|
6721
|
-
|
|
6724
|
+
const hasPcbPath = props.pcbPath !== void 0;
|
|
6725
|
+
const wantsStraightLine = Boolean(props.pcbStraightLine);
|
|
6726
|
+
if (!hasPcbPath && !wantsStraightLine) return;
|
|
6722
6727
|
const { allPortsFound, ports, portsWithSelectors } = trace._findConnectedPorts();
|
|
6723
6728
|
if (!allPortsFound) return;
|
|
6724
6729
|
const portsWithoutMatchedPcbPrimitive = [];
|
|
@@ -6738,6 +6743,51 @@ function Trace_doInitialPcbManualTraceRender(trace) {
|
|
|
6738
6743
|
});
|
|
6739
6744
|
return;
|
|
6740
6745
|
}
|
|
6746
|
+
const width = trace._getExplicitTraceThickness() ?? trace.getSubcircuit()._parsedProps.minTraceWidth ?? 0.16;
|
|
6747
|
+
if (wantsStraightLine && !hasPcbPath) {
|
|
6748
|
+
if (!ports || ports.length < 2) {
|
|
6749
|
+
trace.renderError("pcbStraightLine requires exactly two connected ports");
|
|
6750
|
+
return;
|
|
6751
|
+
}
|
|
6752
|
+
const [startPort, endPort] = ports;
|
|
6753
|
+
const startLayers = startPort.getAvailablePcbLayers();
|
|
6754
|
+
const endLayers = endPort.getAvailablePcbLayers();
|
|
6755
|
+
const sharedLayer = startLayers.find((layer3) => endLayers.includes(layer3));
|
|
6756
|
+
const layer2 = sharedLayer ?? startLayers[0] ?? endLayers[0] ?? "top";
|
|
6757
|
+
const startPos = startPort._getGlobalPcbPositionAfterLayout();
|
|
6758
|
+
const endPos = endPort._getGlobalPcbPositionAfterLayout();
|
|
6759
|
+
const route2 = [
|
|
6760
|
+
{
|
|
6761
|
+
route_type: "wire",
|
|
6762
|
+
x: startPos.x,
|
|
6763
|
+
y: startPos.y,
|
|
6764
|
+
width,
|
|
6765
|
+
layer: layer2,
|
|
6766
|
+
start_pcb_port_id: startPort.pcb_port_id
|
|
6767
|
+
},
|
|
6768
|
+
{
|
|
6769
|
+
route_type: "wire",
|
|
6770
|
+
x: endPos.x,
|
|
6771
|
+
y: endPos.y,
|
|
6772
|
+
width,
|
|
6773
|
+
layer: layer2,
|
|
6774
|
+
end_pcb_port_id: endPort.pcb_port_id
|
|
6775
|
+
}
|
|
6776
|
+
];
|
|
6777
|
+
const traceLength2 = getTraceLength(route2);
|
|
6778
|
+
const pcb_trace2 = db.pcb_trace.insert({
|
|
6779
|
+
route: route2,
|
|
6780
|
+
source_trace_id: trace.source_trace_id,
|
|
6781
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
6782
|
+
pcb_group_id: trace.getGroup()?.pcb_group_id ?? void 0,
|
|
6783
|
+
trace_length: traceLength2
|
|
6784
|
+
});
|
|
6785
|
+
trace._portsRoutedOnPcb = ports;
|
|
6786
|
+
trace.pcb_trace_id = pcb_trace2.pcb_trace_id;
|
|
6787
|
+
trace._insertErrorIfTraceIsOutsideBoard(route2, ports);
|
|
6788
|
+
return;
|
|
6789
|
+
}
|
|
6790
|
+
if (!props.pcbPath) return;
|
|
6741
6791
|
let anchorPort;
|
|
6742
6792
|
if (props.pcbPathRelativeTo) {
|
|
6743
6793
|
anchorPort = portsWithSelectors.find(
|
|
@@ -6752,7 +6802,6 @@ function Trace_doInitialPcbManualTraceRender(trace) {
|
|
|
6752
6802
|
}
|
|
6753
6803
|
const otherPort = ports.find((p) => p !== anchorPort) ?? ports[1];
|
|
6754
6804
|
const layer = anchorPort.getAvailablePcbLayers()[0] || "top";
|
|
6755
|
-
const width = trace._getExplicitTraceThickness() ?? trace.getSubcircuit()._parsedProps.minTraceWidth ?? 0.16;
|
|
6756
6805
|
const anchorPos = anchorPort._getGlobalPcbPositionAfterLayout();
|
|
6757
6806
|
const otherPos = otherPort._getGlobalPcbPositionAfterLayout();
|
|
6758
6807
|
const route = [];
|
|
@@ -14333,14 +14382,9 @@ import { panelProps } from "@tscircuit/props";
|
|
|
14333
14382
|
import { distance as distance9 } from "circuit-json";
|
|
14334
14383
|
|
|
14335
14384
|
// lib/utils/panels/generate-panel-tabs-and-mouse-bites.ts
|
|
14336
|
-
var
|
|
14337
|
-
|
|
14338
|
-
|
|
14339
|
-
TAB_TO_SPACE_RATIO: 5,
|
|
14340
|
-
MOUSE_BITE_DIAMETER: 0.2,
|
|
14341
|
-
MOUSE_BITE_SPACING: 0.1,
|
|
14342
|
-
MOUSE_BITES_PER_GAP: 5
|
|
14343
|
-
};
|
|
14385
|
+
var DEFAULT_PANEL_MARGIN = 5;
|
|
14386
|
+
var DEFAULT_TAB_LENGTH = 5;
|
|
14387
|
+
var DEFAULT_TAB_WIDTH = 2;
|
|
14344
14388
|
function rectanglesOverlap(rect1, rect2) {
|
|
14345
14389
|
const r1Left = rect1.center.x - rect1.width / 2;
|
|
14346
14390
|
const r1Right = rect1.center.x + rect1.width / 2;
|
|
@@ -14363,7 +14407,12 @@ function pointOverlapsRectangle(point, radius, rect) {
|
|
|
14363
14407
|
const distanceY = point.y - closestY;
|
|
14364
14408
|
return distanceX * distanceX + distanceY * distanceY <= radius * radius;
|
|
14365
14409
|
}
|
|
14366
|
-
function generateTabsForEdge(
|
|
14410
|
+
function generateTabsForEdge({
|
|
14411
|
+
board,
|
|
14412
|
+
edge,
|
|
14413
|
+
otherBoards,
|
|
14414
|
+
options
|
|
14415
|
+
}) {
|
|
14367
14416
|
const tabs = [];
|
|
14368
14417
|
if (!board.width || !board.height) return tabs;
|
|
14369
14418
|
const boardLeft = board.center.x - board.width / 2;
|
|
@@ -14382,9 +14431,15 @@ function generateTabsForEdge(board, edge, existingTabs, otherBoards) {
|
|
|
14382
14431
|
isHorizontal = false;
|
|
14383
14432
|
edgeCenter = edge === "right" ? boardRight : boardLeft;
|
|
14384
14433
|
}
|
|
14385
|
-
const totalTabWidth =
|
|
14386
|
-
|
|
14387
|
-
|
|
14434
|
+
const totalTabWidth = options.tabLength;
|
|
14435
|
+
let fixedSpacing = options.boardGap;
|
|
14436
|
+
if (options.mouseBites) {
|
|
14437
|
+
const mouseBiteDiameter = options.tabWidth * 0.45;
|
|
14438
|
+
const mouseBiteSpacing = mouseBiteDiameter * 0.1;
|
|
14439
|
+
const mouseBitesPerGap = Math.max(2, Math.ceil(options.tabLength / 2));
|
|
14440
|
+
const minSpacingForMouseBites = mouseBitesPerGap * mouseBiteDiameter + (mouseBitesPerGap - 1) * mouseBiteSpacing;
|
|
14441
|
+
fixedSpacing = minSpacingForMouseBites * 1.1;
|
|
14442
|
+
}
|
|
14388
14443
|
let numTabs = Math.floor(
|
|
14389
14444
|
(edgeLength - fixedSpacing) / (totalTabWidth + fixedSpacing)
|
|
14390
14445
|
);
|
|
@@ -14409,13 +14464,13 @@ function generateTabsForEdge(board, edge, existingTabs, otherBoards) {
|
|
|
14409
14464
|
axisStart = Math.max(axisStart, boardStart);
|
|
14410
14465
|
axisEnd = Math.min(axisEnd, boardEnd);
|
|
14411
14466
|
if (isCornerTab) {
|
|
14412
|
-
if (isFirstTab) axisStart -=
|
|
14413
|
-
if (isLastTab) axisEnd +=
|
|
14467
|
+
if (isFirstTab) axisStart -= options.tabWidth;
|
|
14468
|
+
if (isLastTab) axisEnd += options.tabWidth;
|
|
14414
14469
|
}
|
|
14415
14470
|
if (axisEnd <= axisStart) continue;
|
|
14416
14471
|
const axisCenterOffset = (axisStart + axisEnd) / 2;
|
|
14417
14472
|
const axisLength = axisEnd - axisStart;
|
|
14418
|
-
const crossAxisOffset = edge === "top" || edge === "right" ?
|
|
14473
|
+
const crossAxisOffset = edge === "top" || edge === "right" ? options.tabWidth / 2 : -options.tabWidth / 2;
|
|
14419
14474
|
const tabCenter = isHorizontal ? {
|
|
14420
14475
|
x: board.center.x + axisCenterOffset,
|
|
14421
14476
|
y: edgeCenter + crossAxisOffset
|
|
@@ -14423,8 +14478,8 @@ function generateTabsForEdge(board, edge, existingTabs, otherBoards) {
|
|
|
14423
14478
|
x: edgeCenter + crossAxisOffset,
|
|
14424
14479
|
y: board.center.y + axisCenterOffset
|
|
14425
14480
|
};
|
|
14426
|
-
const tabWidth = isHorizontal ? axisLength :
|
|
14427
|
-
const tabHeight = isHorizontal ?
|
|
14481
|
+
const tabWidth = isHorizontal ? axisLength : options.tabWidth;
|
|
14482
|
+
const tabHeight = isHorizontal ? options.tabWidth : axisLength;
|
|
14428
14483
|
const newTab = {
|
|
14429
14484
|
center: tabCenter,
|
|
14430
14485
|
width: tabWidth,
|
|
@@ -14449,7 +14504,13 @@ function generateTabsForEdge(board, edge, existingTabs, otherBoards) {
|
|
|
14449
14504
|
}
|
|
14450
14505
|
return tabs;
|
|
14451
14506
|
}
|
|
14452
|
-
function generateMouseBitesForEdge(
|
|
14507
|
+
function generateMouseBitesForEdge({
|
|
14508
|
+
board,
|
|
14509
|
+
edge,
|
|
14510
|
+
edgeTabs,
|
|
14511
|
+
allBoards,
|
|
14512
|
+
options
|
|
14513
|
+
}) {
|
|
14453
14514
|
const mouseBites = [];
|
|
14454
14515
|
if (edgeTabs.length === 0) return mouseBites;
|
|
14455
14516
|
if (!board.width || !board.height) return mouseBites;
|
|
@@ -14458,8 +14519,11 @@ function generateMouseBitesForEdge(board, edge, edgeTabs, allTabs, allBoards, ex
|
|
|
14458
14519
|
const boardBottom = board.center.y - board.height / 2;
|
|
14459
14520
|
const boardTop = board.center.y + board.height / 2;
|
|
14460
14521
|
const isHorizontal = edge === "top" || edge === "bottom";
|
|
14522
|
+
const mouseBiteDiameter = options.tabWidth * 0.45;
|
|
14523
|
+
const mouseBiteSpacing = mouseBiteDiameter * 0.1;
|
|
14524
|
+
const mouseBitesPerGap = Math.max(2, Math.ceil(options.tabLength / 2));
|
|
14461
14525
|
let mouseBitePosition;
|
|
14462
|
-
const radius =
|
|
14526
|
+
const radius = mouseBiteDiameter / 2;
|
|
14463
14527
|
if (edge === "top") {
|
|
14464
14528
|
mouseBitePosition = boardTop;
|
|
14465
14529
|
} else if (edge === "bottom") {
|
|
@@ -14489,14 +14553,14 @@ function generateMouseBitesForEdge(board, edge, edgeTabs, allTabs, allBoards, ex
|
|
|
14489
14553
|
gapEnd = tab2.center.y - tab2.height / 2;
|
|
14490
14554
|
}
|
|
14491
14555
|
const gapLength = gapEnd - gapStart;
|
|
14492
|
-
const totalMouseBiteWidth =
|
|
14493
|
-
const totalSpacing = (
|
|
14556
|
+
const totalMouseBiteWidth = mouseBitesPerGap * mouseBiteDiameter;
|
|
14557
|
+
const totalSpacing = (mouseBitesPerGap - 1) * mouseBiteSpacing;
|
|
14494
14558
|
if (gapLength < totalMouseBiteWidth + totalSpacing) continue;
|
|
14495
14559
|
const gapCenter = (gapStart + gapEnd) / 2;
|
|
14496
|
-
for (let j = 0; j <
|
|
14497
|
-
const posOffset = (j - (
|
|
14560
|
+
for (let j = 0; j < mouseBitesPerGap; j++) {
|
|
14561
|
+
const posOffset = (j - (mouseBitesPerGap - 1) / 2) * (mouseBiteDiameter + mouseBiteSpacing);
|
|
14498
14562
|
const newMouseBite = isHorizontal ? { x: gapCenter + posOffset, y: mouseBitePosition } : { x: mouseBitePosition, y: gapCenter + posOffset };
|
|
14499
|
-
const radius2 =
|
|
14563
|
+
const radius2 = mouseBiteDiameter / 2;
|
|
14500
14564
|
let overlapsBoard = false;
|
|
14501
14565
|
for (const otherBoard of allBoards) {
|
|
14502
14566
|
if (!otherBoard.width || !otherBoard.height) continue;
|
|
@@ -14516,45 +14580,50 @@ function generateMouseBitesForEdge(board, edge, edgeTabs, allTabs, allBoards, ex
|
|
|
14516
14580
|
}
|
|
14517
14581
|
return mouseBites;
|
|
14518
14582
|
}
|
|
14519
|
-
function generatePanelTabsAndMouseBites(boards) {
|
|
14583
|
+
function generatePanelTabsAndMouseBites(boards, options) {
|
|
14520
14584
|
const allTabCutouts = [];
|
|
14521
14585
|
const allMouseBites = [];
|
|
14522
14586
|
for (let boardIndex = 0; boardIndex < boards.length; boardIndex++) {
|
|
14523
14587
|
const board = boards[boardIndex];
|
|
14524
14588
|
const otherBoards = boards.filter((_, i) => i !== boardIndex);
|
|
14525
14589
|
for (const edge of ["top", "bottom", "left", "right"]) {
|
|
14526
|
-
const edgeTabs = generateTabsForEdge(
|
|
14527
|
-
board,
|
|
14528
|
-
edge,
|
|
14529
|
-
allTabCutouts,
|
|
14530
|
-
otherBoards
|
|
14531
|
-
);
|
|
14532
|
-
allTabCutouts.push(...edgeTabs);
|
|
14533
|
-
const edgeMouseBites = generateMouseBitesForEdge(
|
|
14590
|
+
const edgeTabs = generateTabsForEdge({
|
|
14534
14591
|
board,
|
|
14535
14592
|
edge,
|
|
14536
|
-
edgeTabs,
|
|
14537
|
-
allTabCutouts,
|
|
14538
14593
|
otherBoards,
|
|
14539
|
-
|
|
14540
|
-
);
|
|
14541
|
-
|
|
14594
|
+
options
|
|
14595
|
+
});
|
|
14596
|
+
allTabCutouts.push(...edgeTabs);
|
|
14597
|
+
if (options.mouseBites) {
|
|
14598
|
+
const edgeMouseBites = generateMouseBitesForEdge({
|
|
14599
|
+
board,
|
|
14600
|
+
edge,
|
|
14601
|
+
edgeTabs,
|
|
14602
|
+
allBoards: otherBoards,
|
|
14603
|
+
options
|
|
14604
|
+
});
|
|
14605
|
+
allMouseBites.push(...edgeMouseBites);
|
|
14606
|
+
}
|
|
14542
14607
|
}
|
|
14543
14608
|
}
|
|
14544
|
-
const tabCutouts = allTabCutouts.map((tab, index) =>
|
|
14545
|
-
|
|
14546
|
-
|
|
14547
|
-
|
|
14548
|
-
|
|
14549
|
-
|
|
14550
|
-
|
|
14551
|
-
|
|
14552
|
-
|
|
14609
|
+
const tabCutouts = allTabCutouts.map((tab, index) => {
|
|
14610
|
+
const tabWidthDimension = Math.min(tab.width, tab.height);
|
|
14611
|
+
return {
|
|
14612
|
+
type: "pcb_cutout",
|
|
14613
|
+
pcb_cutout_id: `panel_tab_${index}`,
|
|
14614
|
+
shape: "rect",
|
|
14615
|
+
center: tab.center,
|
|
14616
|
+
width: tab.width,
|
|
14617
|
+
height: tab.height,
|
|
14618
|
+
corner_radius: tabWidthDimension / 2
|
|
14619
|
+
};
|
|
14620
|
+
});
|
|
14621
|
+
const mouseBiteDiameter = options.tabWidth * 0.45;
|
|
14553
14622
|
const mouseBiteHoles = allMouseBites.map((bite, index) => ({
|
|
14554
14623
|
type: "pcb_hole",
|
|
14555
14624
|
pcb_hole_id: `panel_mouse_bite_${index}`,
|
|
14556
14625
|
hole_shape: "circle",
|
|
14557
|
-
hole_diameter:
|
|
14626
|
+
hole_diameter: mouseBiteDiameter,
|
|
14558
14627
|
x: bite.x,
|
|
14559
14628
|
y: bite.y
|
|
14560
14629
|
}));
|
|
@@ -14600,6 +14669,8 @@ var Panel = class extends Group6 {
|
|
|
14600
14669
|
(b) => b.props.pcbX === void 0 && b.props.pcbY === void 0
|
|
14601
14670
|
);
|
|
14602
14671
|
if (unpositionedBoards.length > 0 && !hasAnyPositionedBoards) {
|
|
14672
|
+
const tabWidth = this._parsedProps.tabWidth ?? DEFAULT_TAB_WIDTH;
|
|
14673
|
+
const boardGap = this._parsedProps.boardGap ?? tabWidth;
|
|
14603
14674
|
const gridCols = Math.ceil(Math.sqrt(unpositionedBoards.length));
|
|
14604
14675
|
const gridRows = Math.ceil(unpositionedBoards.length / gridCols);
|
|
14605
14676
|
const colWidths = Array(gridCols).fill(0);
|
|
@@ -14613,17 +14684,17 @@ var Panel = class extends Group6 {
|
|
|
14613
14684
|
colWidths[col] = Math.max(colWidths[col], pcbBoard.width);
|
|
14614
14685
|
rowHeights[row] = Math.max(rowHeights[row], pcbBoard.height);
|
|
14615
14686
|
});
|
|
14616
|
-
const totalGridWidth = colWidths.reduce((a, b) => a + b, 0) + (gridCols > 1 ? (gridCols - 1) *
|
|
14617
|
-
const totalGridHeight = rowHeights.reduce((a, b) => a + b, 0) + (gridRows > 1 ? (gridRows - 1) *
|
|
14687
|
+
const totalGridWidth = colWidths.reduce((a, b) => a + b, 0) + (gridCols > 1 ? (gridCols - 1) * boardGap : 0);
|
|
14688
|
+
const totalGridHeight = rowHeights.reduce((a, b) => a + b, 0) + (gridRows > 1 ? (gridRows - 1) * boardGap : 0);
|
|
14618
14689
|
const startX = -totalGridWidth / 2;
|
|
14619
14690
|
const startY = -totalGridHeight / 2;
|
|
14620
14691
|
const rowYOffsets = [startY];
|
|
14621
14692
|
for (let i = 0; i < gridRows - 1; i++) {
|
|
14622
|
-
rowYOffsets.push(rowYOffsets[i] + rowHeights[i] +
|
|
14693
|
+
rowYOffsets.push(rowYOffsets[i] + rowHeights[i] + boardGap);
|
|
14623
14694
|
}
|
|
14624
14695
|
const colXOffsets = [startX];
|
|
14625
14696
|
for (let i = 0; i < gridCols - 1; i++) {
|
|
14626
|
-
colXOffsets.push(colXOffsets[i] + colWidths[i] +
|
|
14697
|
+
colXOffsets.push(colXOffsets[i] + colWidths[i] + boardGap);
|
|
14627
14698
|
}
|
|
14628
14699
|
unpositionedBoards.forEach((board, i) => {
|
|
14629
14700
|
const col = i % gridCols;
|
|
@@ -14657,9 +14728,8 @@ var Panel = class extends Group6 {
|
|
|
14657
14728
|
if (isFinite(minX)) {
|
|
14658
14729
|
const boundsWidth = maxX - minX;
|
|
14659
14730
|
const boundsHeight = maxY - minY;
|
|
14660
|
-
const
|
|
14661
|
-
const
|
|
14662
|
-
const newPanelHeight = boundsHeight + 2 * margin;
|
|
14731
|
+
const newPanelWidth = boundsWidth + 2 * DEFAULT_PANEL_MARGIN;
|
|
14732
|
+
const newPanelHeight = boundsHeight + 2 * DEFAULT_PANEL_MARGIN;
|
|
14663
14733
|
db.pcb_panel.update(this.pcb_panel_id, {
|
|
14664
14734
|
width: newPanelWidth,
|
|
14665
14735
|
height: newPanelHeight
|
|
@@ -14667,15 +14737,29 @@ var Panel = class extends Group6 {
|
|
|
14667
14737
|
}
|
|
14668
14738
|
}
|
|
14669
14739
|
if (this._tabsAndMouseBitesGenerated) return;
|
|
14670
|
-
const
|
|
14671
|
-
const
|
|
14672
|
-
if (
|
|
14673
|
-
|
|
14674
|
-
|
|
14675
|
-
|
|
14676
|
-
|
|
14677
|
-
|
|
14678
|
-
|
|
14740
|
+
const props = this._parsedProps;
|
|
14741
|
+
const panelizationMethod = props.panelizationMethod ?? "tab-routing";
|
|
14742
|
+
if (panelizationMethod !== "none") {
|
|
14743
|
+
const childBoardIds = childBoardInstances.map((c) => c.pcb_board_id).filter((id) => !!id);
|
|
14744
|
+
const boardsInPanel = db.pcb_board.list().filter((b) => childBoardIds.includes(b.pcb_board_id));
|
|
14745
|
+
if (boardsInPanel.length === 0) return;
|
|
14746
|
+
const tabWidth = props.tabWidth ?? DEFAULT_TAB_WIDTH;
|
|
14747
|
+
const boardGap = props.boardGap ?? tabWidth;
|
|
14748
|
+
const { tabCutouts, mouseBiteHoles } = generatePanelTabsAndMouseBites(
|
|
14749
|
+
boardsInPanel,
|
|
14750
|
+
{
|
|
14751
|
+
boardGap,
|
|
14752
|
+
tabWidth,
|
|
14753
|
+
tabLength: props.tabLength ?? DEFAULT_TAB_LENGTH,
|
|
14754
|
+
mouseBites: props.mouseBites ?? true
|
|
14755
|
+
}
|
|
14756
|
+
);
|
|
14757
|
+
for (const tabCutout of tabCutouts) {
|
|
14758
|
+
db.pcb_cutout.insert(tabCutout);
|
|
14759
|
+
}
|
|
14760
|
+
for (const mouseBiteHole of mouseBiteHoles) {
|
|
14761
|
+
db.pcb_hole.insert(mouseBiteHole);
|
|
14762
|
+
}
|
|
14679
14763
|
}
|
|
14680
14764
|
this._tabsAndMouseBitesGenerated = true;
|
|
14681
14765
|
}
|
|
@@ -18493,7 +18577,7 @@ import { identity as identity6 } from "transformation-matrix";
|
|
|
18493
18577
|
var package_default = {
|
|
18494
18578
|
name: "@tscircuit/core",
|
|
18495
18579
|
type: "module",
|
|
18496
|
-
version: "0.0.
|
|
18580
|
+
version: "0.0.873",
|
|
18497
18581
|
types: "dist/index.d.ts",
|
|
18498
18582
|
main: "dist/index.js",
|
|
18499
18583
|
module: "dist/index.js",
|
|
@@ -18537,7 +18621,7 @@ var package_default = {
|
|
|
18537
18621
|
"@tscircuit/math-utils": "^0.0.29",
|
|
18538
18622
|
"@tscircuit/miniflex": "^0.0.4",
|
|
18539
18623
|
"@tscircuit/ngspice-spice-engine": "^0.0.3",
|
|
18540
|
-
"@tscircuit/props": "^0.0.
|
|
18624
|
+
"@tscircuit/props": "^0.0.410",
|
|
18541
18625
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
18542
18626
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
18543
18627
|
"@tscircuit/schematic-trace-solver": "^v0.0.45",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.874",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@tscircuit/math-utils": "^0.0.29",
|
|
46
46
|
"@tscircuit/miniflex": "^0.0.4",
|
|
47
47
|
"@tscircuit/ngspice-spice-engine": "^0.0.3",
|
|
48
|
-
"@tscircuit/props": "^0.0.
|
|
48
|
+
"@tscircuit/props": "^0.0.410",
|
|
49
49
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
50
50
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
51
51
|
"@tscircuit/schematic-trace-solver": "^v0.0.45",
|