@tscircuit/pcb-viewer 1.11.280 → 1.11.281
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.js +43 -77
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10605,7 +10605,7 @@ function calculateDiagonalLabel(params) {
|
|
|
10605
10605
|
} = params;
|
|
10606
10606
|
const deltaX = dimensionEnd.x - dimensionStart.x;
|
|
10607
10607
|
const deltaY = dimensionEnd.y - dimensionStart.y;
|
|
10608
|
-
const
|
|
10608
|
+
const distance5 = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
10609
10609
|
const screenDeltaX = screenDimensionEnd.x - screenDimensionStart.x;
|
|
10610
10610
|
const screenDeltaY = screenDimensionEnd.y - screenDimensionStart.y;
|
|
10611
10611
|
const screenDistance = Math.sqrt(
|
|
@@ -10647,11 +10647,11 @@ function calculateDiagonalLabel(params) {
|
|
|
10647
10647
|
const x = midX + offsetX;
|
|
10648
10648
|
const y = midY + offsetY;
|
|
10649
10649
|
return {
|
|
10650
|
-
distance:
|
|
10650
|
+
distance: distance5,
|
|
10651
10651
|
screenDistance,
|
|
10652
10652
|
x,
|
|
10653
10653
|
y,
|
|
10654
|
-
show:
|
|
10654
|
+
show: distance5 > 0.01 && screenDistance > 30 && isDiagonal
|
|
10655
10655
|
};
|
|
10656
10656
|
}
|
|
10657
10657
|
|
|
@@ -10945,11 +10945,11 @@ var DimensionOverlay = ({
|
|
|
10945
10945
|
for (const snap of snappingPointsWithScreen) {
|
|
10946
10946
|
const dx = snap.screenPoint.x - screenPoint.x;
|
|
10947
10947
|
const dy = snap.screenPoint.y - screenPoint.y;
|
|
10948
|
-
const
|
|
10949
|
-
if (
|
|
10950
|
-
if (!bestMatch ||
|
|
10948
|
+
const distance5 = Math.hypot(dx, dy);
|
|
10949
|
+
if (distance5 > SNAP_THRESHOLD_PX) continue;
|
|
10950
|
+
if (!bestMatch || distance5 < bestMatch.distance) {
|
|
10951
10951
|
bestMatch = {
|
|
10952
|
-
distance:
|
|
10952
|
+
distance: distance5,
|
|
10953
10953
|
id: snap.id,
|
|
10954
10954
|
point: snap.point
|
|
10955
10955
|
};
|
|
@@ -11548,10 +11548,10 @@ var isInsideOfSmtpad = (elm, point, padding = 0) => {
|
|
|
11548
11548
|
};
|
|
11549
11549
|
var isInsideOfPlatedHole = (hole, point, padding = 0) => {
|
|
11550
11550
|
if (hole.shape === "circle") {
|
|
11551
|
-
const
|
|
11551
|
+
const distance5 = Math.sqrt(
|
|
11552
11552
|
(point.x - hole.x) ** 2 + (point.y - hole.y) ** 2
|
|
11553
11553
|
);
|
|
11554
|
-
return
|
|
11554
|
+
return distance5 <= hole.outer_diameter / 2 + padding;
|
|
11555
11555
|
} else if (hole.shape === "circular_hole_with_rect_pad") {
|
|
11556
11556
|
const dx = Math.abs(point.x - hole.x);
|
|
11557
11557
|
const dy = Math.abs(point.y - hole.y);
|
|
@@ -12379,7 +12379,7 @@ var ErrorOverlay = ({
|
|
|
12379
12379
|
|
|
12380
12380
|
// src/components/MouseElementTracker.tsx
|
|
12381
12381
|
import { pointToSegmentDistance } from "@tscircuit/math-utils";
|
|
12382
|
-
import { distance as
|
|
12382
|
+
import { distance as distance4 } from "circuit-json";
|
|
12383
12383
|
|
|
12384
12384
|
// src/lib/util/if-sets-match-exactly.ts
|
|
12385
12385
|
function ifSetsMatchExactly(set1, set2) {
|
|
@@ -12670,14 +12670,17 @@ var ElementOverlayBox = ({
|
|
|
12670
12670
|
import { applyToPoint as applyToPoint12 } from "transformation-matrix";
|
|
12671
12671
|
|
|
12672
12672
|
// src/components/GroupAnchorOffsetOverlay/calculateGroupBoundingBox.ts
|
|
12673
|
+
import { distance as distance3 } from "circuit-json";
|
|
12673
12674
|
var calculateGroupBoundingBox = (groupComponents) => {
|
|
12674
12675
|
const points = [];
|
|
12675
12676
|
for (const comp of groupComponents) {
|
|
12676
|
-
if (!comp.center
|
|
12677
|
+
if (!comp.center) {
|
|
12677
12678
|
continue;
|
|
12678
12679
|
}
|
|
12679
|
-
const
|
|
12680
|
-
const
|
|
12680
|
+
const width = typeof comp.width === "number" ? comp.width : distance3.parse(comp.width);
|
|
12681
|
+
const height = typeof comp.height === "number" ? comp.height : distance3.parse(comp.height);
|
|
12682
|
+
const halfWidth = width / 2;
|
|
12683
|
+
const halfHeight = height / 2;
|
|
12681
12684
|
points.push({ x: comp.center.x - halfWidth, y: comp.center.y - halfHeight });
|
|
12682
12685
|
points.push({ x: comp.center.x + halfWidth, y: comp.center.y + halfHeight });
|
|
12683
12686
|
}
|
|
@@ -12704,20 +12707,6 @@ var COLORS = {
|
|
|
12704
12707
|
LABEL_TEXT: "white"
|
|
12705
12708
|
};
|
|
12706
12709
|
|
|
12707
|
-
// src/components/GroupAnchorOffsetOverlay/findAnchorMarkerPosition.ts
|
|
12708
|
-
var findAnchorMarkerPosition = (anchor, bounds) => {
|
|
12709
|
-
const { minX, maxX, minY, maxY } = bounds;
|
|
12710
|
-
const distToLeft = Math.abs(anchor.x - minX);
|
|
12711
|
-
const distToRight = Math.abs(anchor.x - maxX);
|
|
12712
|
-
const distToTop = Math.abs(anchor.y - maxY);
|
|
12713
|
-
const distToBottom = Math.abs(anchor.y - minY);
|
|
12714
|
-
const minDist = Math.min(distToLeft, distToRight, distToTop, distToBottom);
|
|
12715
|
-
if (minDist === distToLeft) return { x: minX, y: anchor.y };
|
|
12716
|
-
if (minDist === distToRight) return { x: maxX, y: anchor.y };
|
|
12717
|
-
if (minDist === distToTop) return { x: anchor.x, y: maxY };
|
|
12718
|
-
return { x: anchor.x, y: minY };
|
|
12719
|
-
};
|
|
12720
|
-
|
|
12721
12710
|
// src/components/GroupAnchorOffsetOverlay/index.tsx
|
|
12722
12711
|
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
12723
12712
|
var GroupAnchorOffsetOverlay = ({
|
|
@@ -12725,8 +12714,7 @@ var GroupAnchorOffsetOverlay = ({
|
|
|
12725
12714
|
highlightedPrimitives,
|
|
12726
12715
|
transform,
|
|
12727
12716
|
containerWidth,
|
|
12728
|
-
containerHeight
|
|
12729
|
-
children
|
|
12717
|
+
containerHeight
|
|
12730
12718
|
}) => {
|
|
12731
12719
|
const is_showing_group_anchor_offsets = useGlobalStore(
|
|
12732
12720
|
(s) => s.is_showing_group_anchor_offsets
|
|
@@ -12738,14 +12726,20 @@ var GroupAnchorOffsetOverlay = ({
|
|
|
12738
12726
|
(p) => p._parent_pcb_component?.type === "pcb_component" || p._element?.type === "pcb_component"
|
|
12739
12727
|
);
|
|
12740
12728
|
if (!hoveredPrimitive) return null;
|
|
12741
|
-
const
|
|
12742
|
-
if (!
|
|
12743
|
-
|
|
12744
|
-
|
|
12745
|
-
|
|
12746
|
-
|
|
12747
|
-
|
|
12748
|
-
|
|
12729
|
+
const hoveredElement = hoveredPrimitive._parent_pcb_component || hoveredPrimitive._element;
|
|
12730
|
+
if (!hoveredElement) return null;
|
|
12731
|
+
let parentGroup;
|
|
12732
|
+
let targetCenter;
|
|
12733
|
+
if (hoveredElement.type === "pcb_component" && hoveredElement.position_mode === "relative_to_group_anchor") {
|
|
12734
|
+
parentGroup = elements.filter((el) => el.type === "pcb_group").find(
|
|
12735
|
+
(group) => group.pcb_group_id === hoveredElement.positioned_relative_to_pcb_group_id
|
|
12736
|
+
);
|
|
12737
|
+
targetCenter = hoveredElement.center;
|
|
12738
|
+
} else if ("pcb_group_id" in hoveredElement) {
|
|
12739
|
+
parentGroup = elements.filter((el) => el.type === "pcb_group").find((group) => group.pcb_group_id === hoveredElement.pcb_group_id);
|
|
12740
|
+
targetCenter = hoveredElement.center;
|
|
12741
|
+
}
|
|
12742
|
+
if (!parentGroup?.anchor_position || !targetCenter) return null;
|
|
12749
12743
|
const groupComponents = elements.filter((el) => el.type === "pcb_component").filter((comp) => comp.pcb_group_id === parentGroup.pcb_group_id);
|
|
12750
12744
|
const boundingBox = calculateGroupBoundingBox(groupComponents);
|
|
12751
12745
|
if (!boundingBox) return null;
|
|
@@ -12755,10 +12749,7 @@ var GroupAnchorOffsetOverlay = ({
|
|
|
12755
12749
|
minY: boundingBox.minY - VISUAL_CONFIG.GROUP_PADDING,
|
|
12756
12750
|
maxY: boundingBox.maxY + VISUAL_CONFIG.GROUP_PADDING
|
|
12757
12751
|
};
|
|
12758
|
-
const anchorMarkerPosition =
|
|
12759
|
-
parentGroup.anchor_position,
|
|
12760
|
-
groupBounds
|
|
12761
|
-
);
|
|
12752
|
+
const anchorMarkerPosition = parentGroup.anchor_position;
|
|
12762
12753
|
const offsetX = targetCenter.x - anchorMarkerPosition.x;
|
|
12763
12754
|
const offsetY = targetCenter.y - anchorMarkerPosition.y;
|
|
12764
12755
|
const anchorMarkerScreen = applyToPoint12(transform, anchorMarkerPosition);
|
|
@@ -12929,22 +12920,22 @@ var getPrimitivesUnderPoint = (primitives, rwPoint, transform) => {
|
|
|
12929
12920
|
for (const primitive of primitives) {
|
|
12930
12921
|
if (!primitive._element) continue;
|
|
12931
12922
|
if ("x1" in primitive && primitive._element?.type === "pcb_trace") {
|
|
12932
|
-
const
|
|
12923
|
+
const distance5 = pointToSegmentDistance(
|
|
12933
12924
|
{ x: rwPoint.x, y: rwPoint.y },
|
|
12934
12925
|
{ x: primitive.x1, y: primitive.y1 },
|
|
12935
12926
|
{ x: primitive.x2, y: primitive.y2 }
|
|
12936
12927
|
);
|
|
12937
12928
|
const lineWidth = primitive.width || 0.5;
|
|
12938
12929
|
const detectionThreshold = Math.max(lineWidth * 25, 2) / transform.a;
|
|
12939
|
-
if (
|
|
12930
|
+
if (distance5 < detectionThreshold) {
|
|
12940
12931
|
newMousedPrimitives.push(primitive);
|
|
12941
12932
|
}
|
|
12942
12933
|
continue;
|
|
12943
12934
|
}
|
|
12944
12935
|
if (primitive.pcb_drawing_type === "polygon") {
|
|
12945
12936
|
const points = primitive.points.map((point) => ({
|
|
12946
|
-
x:
|
|
12947
|
-
y:
|
|
12937
|
+
x: distance4.parse(point.x),
|
|
12938
|
+
y: distance4.parse(point.y)
|
|
12948
12939
|
}));
|
|
12949
12940
|
const boundingBox = getPolygonBoundingBox(points);
|
|
12950
12941
|
if (!boundingBox) continue;
|
|
@@ -12958,8 +12949,8 @@ var getPrimitivesUnderPoint = (primitives, rwPoint, transform) => {
|
|
|
12958
12949
|
}
|
|
12959
12950
|
if (primitive.pcb_drawing_type === "polygon_with_arcs") {
|
|
12960
12951
|
const points = primitive.brep_shape.outer_ring.vertices.map((v) => ({
|
|
12961
|
-
x:
|
|
12962
|
-
y:
|
|
12952
|
+
x: distance4.parse(v.x),
|
|
12953
|
+
y: distance4.parse(v.y)
|
|
12963
12954
|
}));
|
|
12964
12955
|
const boundingBox = getPolygonBoundingBox(points);
|
|
12965
12956
|
if (!boundingBox) continue;
|
|
@@ -13301,32 +13292,7 @@ var PcbGroupOverlay = ({
|
|
|
13301
13292
|
ctx.textBaseline = "middle";
|
|
13302
13293
|
ctx.fillText(labelText, labelX + labelPadding, labelY - labelHeight / 2);
|
|
13303
13294
|
if (group.anchor_position) {
|
|
13304
|
-
const
|
|
13305
|
-
const groupLeft = minX;
|
|
13306
|
-
const groupRight = maxX;
|
|
13307
|
-
const groupTop = maxY;
|
|
13308
|
-
const groupBottom = minY;
|
|
13309
|
-
let edgePoint = { x: anchor.x, y: anchor.y };
|
|
13310
|
-
const distToLeft = Math.abs(anchor.x - groupLeft);
|
|
13311
|
-
const distToRight = Math.abs(anchor.x - groupRight);
|
|
13312
|
-
const distToTop = Math.abs(anchor.y - groupTop);
|
|
13313
|
-
const distToBottom = Math.abs(anchor.y - groupBottom);
|
|
13314
|
-
const minDist = Math.min(
|
|
13315
|
-
distToLeft,
|
|
13316
|
-
distToRight,
|
|
13317
|
-
distToTop,
|
|
13318
|
-
distToBottom
|
|
13319
|
-
);
|
|
13320
|
-
if (minDist === distToLeft) {
|
|
13321
|
-
edgePoint = { x: groupLeft, y: anchor.y };
|
|
13322
|
-
} else if (minDist === distToRight) {
|
|
13323
|
-
edgePoint = { x: groupRight, y: anchor.y };
|
|
13324
|
-
} else if (minDist === distToTop) {
|
|
13325
|
-
edgePoint = { x: anchor.x, y: groupTop };
|
|
13326
|
-
} else {
|
|
13327
|
-
edgePoint = { x: anchor.x, y: groupBottom };
|
|
13328
|
-
}
|
|
13329
|
-
const anchorScreenPos = applyToPoint14(transform, edgePoint);
|
|
13295
|
+
const anchorScreenPos = applyToPoint14(transform, group.anchor_position);
|
|
13330
13296
|
ctx.strokeStyle = "white";
|
|
13331
13297
|
ctx.lineWidth = 1.5;
|
|
13332
13298
|
ctx.setLineDash([]);
|
|
@@ -13401,11 +13367,11 @@ var RatsNestOverlay = ({ transform, soup, children }) => {
|
|
|
13401
13367
|
connectedIds.forEach((id) => {
|
|
13402
13368
|
const pos = getElementPosition(id);
|
|
13403
13369
|
if (pos) {
|
|
13404
|
-
const
|
|
13370
|
+
const distance5 = Math.sqrt(
|
|
13405
13371
|
(sourcePoint.x - pos.x) ** 2 + (sourcePoint.y - pos.y) ** 2
|
|
13406
13372
|
);
|
|
13407
|
-
if (
|
|
13408
|
-
minDistance =
|
|
13373
|
+
if (distance5 < minDistance && distance5 > 0) {
|
|
13374
|
+
minDistance = distance5;
|
|
13409
13375
|
nearestPoint = pos;
|
|
13410
13376
|
}
|
|
13411
13377
|
}
|
|
@@ -13485,7 +13451,7 @@ import { css as css3 } from "@emotion/css";
|
|
|
13485
13451
|
// package.json
|
|
13486
13452
|
var package_default = {
|
|
13487
13453
|
name: "@tscircuit/pcb-viewer",
|
|
13488
|
-
version: "1.11.
|
|
13454
|
+
version: "1.11.280",
|
|
13489
13455
|
main: "dist/index.js",
|
|
13490
13456
|
type: "module",
|
|
13491
13457
|
repository: "tscircuit/pcb-viewer",
|