@tscircuit/pcb-viewer 1.11.296 → 1.11.298
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 +105 -492
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -6019,6 +6019,15 @@ var getBoundsOfPcbElements = (elements) => {
|
|
|
6019
6019
|
let maxY = Number.NEGATIVE_INFINITY;
|
|
6020
6020
|
for (const elm of elements) {
|
|
6021
6021
|
if (!elm.type.startsWith("pcb_")) continue;
|
|
6022
|
+
if (elm.type === "pcb_smtpad" && elm.shape === "polygon" && Array.isArray(elm.points)) {
|
|
6023
|
+
for (const point of elm.points) {
|
|
6024
|
+
minX = Math.min(minX, point.x);
|
|
6025
|
+
minY = Math.min(minY, point.y);
|
|
6026
|
+
maxX = Math.max(maxX, point.x);
|
|
6027
|
+
maxY = Math.max(maxY, point.y);
|
|
6028
|
+
}
|
|
6029
|
+
continue;
|
|
6030
|
+
}
|
|
6022
6031
|
let centerX;
|
|
6023
6032
|
let centerY;
|
|
6024
6033
|
let width;
|
|
@@ -7575,344 +7584,6 @@ var convertElementToPrimitives = (element, allElements) => {
|
|
|
7575
7584
|
}
|
|
7576
7585
|
return [];
|
|
7577
7586
|
}
|
|
7578
|
-
case "pcb_plated_hole": {
|
|
7579
|
-
if (element.shape === "circle") {
|
|
7580
|
-
const { x, y, hole_diameter, outer_diameter } = element;
|
|
7581
|
-
return [
|
|
7582
|
-
{
|
|
7583
|
-
_pcb_drawing_object_id: `circle_${globalPcbDrawingObjectCount++}`,
|
|
7584
|
-
pcb_drawing_type: "circle",
|
|
7585
|
-
x,
|
|
7586
|
-
y,
|
|
7587
|
-
r: outer_diameter / 2,
|
|
7588
|
-
// TODO support layer on pcb_plated_hole
|
|
7589
|
-
layer: "top",
|
|
7590
|
-
_element: element,
|
|
7591
|
-
_parent_pcb_component,
|
|
7592
|
-
_parent_source_component,
|
|
7593
|
-
_source_port
|
|
7594
|
-
},
|
|
7595
|
-
{
|
|
7596
|
-
_pcb_drawing_object_id: `circle_${globalPcbDrawingObjectCount++}`,
|
|
7597
|
-
pcb_drawing_type: "circle",
|
|
7598
|
-
x,
|
|
7599
|
-
y,
|
|
7600
|
-
r: hole_diameter / 2,
|
|
7601
|
-
// TODO support layer on pcb_plated_hole
|
|
7602
|
-
layer: "drill",
|
|
7603
|
-
_element: element
|
|
7604
|
-
// double highlights are annoying
|
|
7605
|
-
// _element: element,
|
|
7606
|
-
}
|
|
7607
|
-
];
|
|
7608
|
-
} else if (element.shape === "oval") {
|
|
7609
|
-
const { x, y, outer_height, outer_width, hole_height, hole_width } = element;
|
|
7610
|
-
return [
|
|
7611
|
-
{
|
|
7612
|
-
_pcb_drawing_object_id: `oval_${globalPcbDrawingObjectCount++}`,
|
|
7613
|
-
pcb_drawing_type: "oval",
|
|
7614
|
-
x,
|
|
7615
|
-
y,
|
|
7616
|
-
rX: outer_width / 2,
|
|
7617
|
-
rY: outer_height / 2,
|
|
7618
|
-
layer: "top",
|
|
7619
|
-
// TODO: Confirm layer handling for oval plated holes
|
|
7620
|
-
_element: element,
|
|
7621
|
-
_parent_pcb_component,
|
|
7622
|
-
_parent_source_component,
|
|
7623
|
-
_source_port
|
|
7624
|
-
},
|
|
7625
|
-
{
|
|
7626
|
-
_pcb_drawing_object_id: `oval_${globalPcbDrawingObjectCount++}`,
|
|
7627
|
-
_element: element,
|
|
7628
|
-
pcb_drawing_type: "oval",
|
|
7629
|
-
x,
|
|
7630
|
-
y,
|
|
7631
|
-
rX: hole_width / 2,
|
|
7632
|
-
rY: hole_height / 2,
|
|
7633
|
-
layer: "drill"
|
|
7634
|
-
}
|
|
7635
|
-
];
|
|
7636
|
-
} else if (element.shape === "pill") {
|
|
7637
|
-
const { x, y, outer_height, outer_width, hole_height, hole_width } = element;
|
|
7638
|
-
return [
|
|
7639
|
-
{
|
|
7640
|
-
_pcb_drawing_object_id: `pill_${globalPcbDrawingObjectCount++}`,
|
|
7641
|
-
pcb_drawing_type: "pill",
|
|
7642
|
-
x,
|
|
7643
|
-
y,
|
|
7644
|
-
w: outer_width,
|
|
7645
|
-
h: outer_height,
|
|
7646
|
-
layer: "top",
|
|
7647
|
-
// TODO: Confirm layer handling for oval plated holes
|
|
7648
|
-
_element: element,
|
|
7649
|
-
_parent_pcb_component,
|
|
7650
|
-
_parent_source_component,
|
|
7651
|
-
_source_port,
|
|
7652
|
-
ccw_rotation: element.ccw_rotation
|
|
7653
|
-
},
|
|
7654
|
-
{
|
|
7655
|
-
_pcb_drawing_object_id: `pill_${globalPcbDrawingObjectCount++}`,
|
|
7656
|
-
_element: element,
|
|
7657
|
-
pcb_drawing_type: "pill",
|
|
7658
|
-
x,
|
|
7659
|
-
y,
|
|
7660
|
-
w: hole_width,
|
|
7661
|
-
h: hole_height,
|
|
7662
|
-
layer: "drill",
|
|
7663
|
-
ccw_rotation: element.ccw_rotation
|
|
7664
|
-
}
|
|
7665
|
-
];
|
|
7666
|
-
} else if (element.shape === "circular_hole_with_rect_pad") {
|
|
7667
|
-
const {
|
|
7668
|
-
x,
|
|
7669
|
-
y,
|
|
7670
|
-
hole_diameter,
|
|
7671
|
-
rect_pad_width,
|
|
7672
|
-
rect_pad_height,
|
|
7673
|
-
rect_border_radius
|
|
7674
|
-
} = element;
|
|
7675
|
-
const hole_offset_x = element.hole_offset_x ?? 0;
|
|
7676
|
-
const hole_offset_y = element.hole_offset_y ?? 0;
|
|
7677
|
-
return [
|
|
7678
|
-
{
|
|
7679
|
-
_pcb_drawing_object_id: `rect_${globalPcbDrawingObjectCount++}`,
|
|
7680
|
-
pcb_drawing_type: "rect",
|
|
7681
|
-
x,
|
|
7682
|
-
y,
|
|
7683
|
-
w: rect_pad_width,
|
|
7684
|
-
h: rect_pad_height,
|
|
7685
|
-
layer: "top",
|
|
7686
|
-
// Rectangular pad on top layer
|
|
7687
|
-
_element: element,
|
|
7688
|
-
_parent_pcb_component,
|
|
7689
|
-
_parent_source_component,
|
|
7690
|
-
_source_port,
|
|
7691
|
-
roundness: rect_border_radius
|
|
7692
|
-
},
|
|
7693
|
-
{
|
|
7694
|
-
_pcb_drawing_object_id: `rect_${globalPcbDrawingObjectCount++}`,
|
|
7695
|
-
pcb_drawing_type: "rect",
|
|
7696
|
-
x,
|
|
7697
|
-
y,
|
|
7698
|
-
w: rect_pad_width,
|
|
7699
|
-
h: rect_pad_height,
|
|
7700
|
-
layer: "bottom",
|
|
7701
|
-
// Rectangular pad on bottom layer
|
|
7702
|
-
_element: element,
|
|
7703
|
-
_parent_pcb_component,
|
|
7704
|
-
_parent_source_component,
|
|
7705
|
-
_source_port,
|
|
7706
|
-
roundness: rect_border_radius
|
|
7707
|
-
},
|
|
7708
|
-
{
|
|
7709
|
-
_pcb_drawing_object_id: `circle_${globalPcbDrawingObjectCount++}`,
|
|
7710
|
-
_element: element,
|
|
7711
|
-
pcb_drawing_type: "circle",
|
|
7712
|
-
x: x + hole_offset_x,
|
|
7713
|
-
y: y + hole_offset_y,
|
|
7714
|
-
r: hole_diameter / 2,
|
|
7715
|
-
layer: "drill"
|
|
7716
|
-
// Circular hole in drill layer
|
|
7717
|
-
}
|
|
7718
|
-
];
|
|
7719
|
-
} else if (element.shape === "pill_hole_with_rect_pad") {
|
|
7720
|
-
const {
|
|
7721
|
-
x,
|
|
7722
|
-
y,
|
|
7723
|
-
hole_width,
|
|
7724
|
-
hole_height,
|
|
7725
|
-
rect_pad_width,
|
|
7726
|
-
rect_pad_height,
|
|
7727
|
-
rect_border_radius
|
|
7728
|
-
} = element;
|
|
7729
|
-
return [
|
|
7730
|
-
{
|
|
7731
|
-
_pcb_drawing_object_id: `rect_${globalPcbDrawingObjectCount++}`,
|
|
7732
|
-
pcb_drawing_type: "rect",
|
|
7733
|
-
x,
|
|
7734
|
-
y,
|
|
7735
|
-
w: rect_pad_width,
|
|
7736
|
-
h: rect_pad_height,
|
|
7737
|
-
layer: "top",
|
|
7738
|
-
// Rectangular pad on top layer
|
|
7739
|
-
_element: element,
|
|
7740
|
-
_parent_pcb_component,
|
|
7741
|
-
_parent_source_component,
|
|
7742
|
-
_source_port,
|
|
7743
|
-
roundness: rect_border_radius
|
|
7744
|
-
},
|
|
7745
|
-
{
|
|
7746
|
-
_pcb_drawing_object_id: `rect_${globalPcbDrawingObjectCount++}`,
|
|
7747
|
-
pcb_drawing_type: "rect",
|
|
7748
|
-
x,
|
|
7749
|
-
y,
|
|
7750
|
-
w: rect_pad_width,
|
|
7751
|
-
h: rect_pad_height,
|
|
7752
|
-
layer: "bottom",
|
|
7753
|
-
// Rectangular pad on bottom layer
|
|
7754
|
-
_element: element,
|
|
7755
|
-
_parent_pcb_component,
|
|
7756
|
-
_parent_source_component,
|
|
7757
|
-
_source_port,
|
|
7758
|
-
roundness: rect_border_radius
|
|
7759
|
-
},
|
|
7760
|
-
{
|
|
7761
|
-
_pcb_drawing_object_id: `pill_${globalPcbDrawingObjectCount++}`,
|
|
7762
|
-
_element: element,
|
|
7763
|
-
pcb_drawing_type: "pill",
|
|
7764
|
-
x,
|
|
7765
|
-
y,
|
|
7766
|
-
w: hole_width,
|
|
7767
|
-
h: hole_height,
|
|
7768
|
-
layer: "drill"
|
|
7769
|
-
// Pill-shaped hole in drill layer
|
|
7770
|
-
}
|
|
7771
|
-
];
|
|
7772
|
-
} else if (element.shape === "rotated_pill_hole_with_rect_pad") {
|
|
7773
|
-
const {
|
|
7774
|
-
x,
|
|
7775
|
-
y,
|
|
7776
|
-
hole_width,
|
|
7777
|
-
hole_height,
|
|
7778
|
-
hole_ccw_rotation,
|
|
7779
|
-
rect_pad_width,
|
|
7780
|
-
rect_pad_height,
|
|
7781
|
-
rect_ccw_rotation,
|
|
7782
|
-
rect_border_radius
|
|
7783
|
-
} = element;
|
|
7784
|
-
return [
|
|
7785
|
-
{
|
|
7786
|
-
_pcb_drawing_object_id: `rect_${globalPcbDrawingObjectCount++}`,
|
|
7787
|
-
pcb_drawing_type: "rect",
|
|
7788
|
-
x,
|
|
7789
|
-
y,
|
|
7790
|
-
w: rect_pad_width,
|
|
7791
|
-
h: rect_pad_height,
|
|
7792
|
-
layer: "top",
|
|
7793
|
-
// Rectangular pad on top layer
|
|
7794
|
-
_element: element,
|
|
7795
|
-
_parent_pcb_component,
|
|
7796
|
-
_parent_source_component,
|
|
7797
|
-
_source_port,
|
|
7798
|
-
ccw_rotation: rect_ccw_rotation,
|
|
7799
|
-
roundness: rect_border_radius
|
|
7800
|
-
},
|
|
7801
|
-
{
|
|
7802
|
-
_pcb_drawing_object_id: `rect_${globalPcbDrawingObjectCount++}`,
|
|
7803
|
-
pcb_drawing_type: "rect",
|
|
7804
|
-
x,
|
|
7805
|
-
y,
|
|
7806
|
-
w: rect_pad_width,
|
|
7807
|
-
h: rect_pad_height,
|
|
7808
|
-
layer: "bottom",
|
|
7809
|
-
// Rectangular pad on bottom layer
|
|
7810
|
-
_element: element,
|
|
7811
|
-
_parent_pcb_component,
|
|
7812
|
-
_parent_source_component,
|
|
7813
|
-
_source_port,
|
|
7814
|
-
ccw_rotation: rect_ccw_rotation,
|
|
7815
|
-
roundness: rect_border_radius
|
|
7816
|
-
},
|
|
7817
|
-
{
|
|
7818
|
-
_pcb_drawing_object_id: `pill_${globalPcbDrawingObjectCount++}`,
|
|
7819
|
-
_element: element,
|
|
7820
|
-
pcb_drawing_type: "pill",
|
|
7821
|
-
x,
|
|
7822
|
-
y,
|
|
7823
|
-
w: hole_width,
|
|
7824
|
-
h: hole_height,
|
|
7825
|
-
layer: "drill",
|
|
7826
|
-
// Pill-shaped hole in drill layer
|
|
7827
|
-
ccw_rotation: hole_ccw_rotation
|
|
7828
|
-
}
|
|
7829
|
-
];
|
|
7830
|
-
} else if (element.shape === "hole_with_polygon_pad") {
|
|
7831
|
-
const {
|
|
7832
|
-
x,
|
|
7833
|
-
y,
|
|
7834
|
-
pad_outline,
|
|
7835
|
-
hole_shape,
|
|
7836
|
-
hole_diameter,
|
|
7837
|
-
hole_width,
|
|
7838
|
-
hole_height,
|
|
7839
|
-
layers
|
|
7840
|
-
} = element;
|
|
7841
|
-
const hole_offset_x = distance2.parse(
|
|
7842
|
-
element.hole_offset_x ?? 0
|
|
7843
|
-
);
|
|
7844
|
-
const hole_offset_y = distance2.parse(
|
|
7845
|
-
element.hole_offset_y ?? 0
|
|
7846
|
-
);
|
|
7847
|
-
const pcb_outline = pad_outline;
|
|
7848
|
-
const padPrimitives = [];
|
|
7849
|
-
if (pcb_outline && Array.isArray(pcb_outline)) {
|
|
7850
|
-
const translatedPoints = normalizePolygonPoints(pcb_outline).map(
|
|
7851
|
-
(p) => ({ x: p.x + x, y: p.y + y })
|
|
7852
|
-
);
|
|
7853
|
-
for (const layer of layers || ["top", "bottom"]) {
|
|
7854
|
-
padPrimitives.push({
|
|
7855
|
-
_pcb_drawing_object_id: `polygon_${globalPcbDrawingObjectCount++}`,
|
|
7856
|
-
pcb_drawing_type: "polygon",
|
|
7857
|
-
points: translatedPoints,
|
|
7858
|
-
layer,
|
|
7859
|
-
_element: element,
|
|
7860
|
-
_parent_pcb_component,
|
|
7861
|
-
_parent_source_component,
|
|
7862
|
-
_source_port
|
|
7863
|
-
});
|
|
7864
|
-
}
|
|
7865
|
-
}
|
|
7866
|
-
const holeCenter = {
|
|
7867
|
-
x: x + hole_offset_x,
|
|
7868
|
-
y: y + hole_offset_y
|
|
7869
|
-
};
|
|
7870
|
-
const holePrimitives = [];
|
|
7871
|
-
if (hole_shape === "circle") {
|
|
7872
|
-
holePrimitives.push({
|
|
7873
|
-
_pcb_drawing_object_id: `circle_${globalPcbDrawingObjectCount++}`,
|
|
7874
|
-
pcb_drawing_type: "circle",
|
|
7875
|
-
x: holeCenter.x,
|
|
7876
|
-
y: holeCenter.y,
|
|
7877
|
-
r: (hole_diameter ?? 0) / 2,
|
|
7878
|
-
layer: "drill",
|
|
7879
|
-
_element: element,
|
|
7880
|
-
_parent_pcb_component,
|
|
7881
|
-
_parent_source_component
|
|
7882
|
-
});
|
|
7883
|
-
} else if (hole_shape === "oval") {
|
|
7884
|
-
holePrimitives.push({
|
|
7885
|
-
_pcb_drawing_object_id: `oval_${globalPcbDrawingObjectCount++}`,
|
|
7886
|
-
pcb_drawing_type: "oval",
|
|
7887
|
-
x: holeCenter.x,
|
|
7888
|
-
y: holeCenter.y,
|
|
7889
|
-
rX: (hole_width ?? 0) / 2,
|
|
7890
|
-
rY: (hole_height ?? 0) / 2,
|
|
7891
|
-
layer: "drill",
|
|
7892
|
-
_element: element,
|
|
7893
|
-
_parent_pcb_component,
|
|
7894
|
-
_parent_source_component
|
|
7895
|
-
});
|
|
7896
|
-
} else if (hole_shape === "pill" || hole_shape === "rotated_pill") {
|
|
7897
|
-
holePrimitives.push({
|
|
7898
|
-
_pcb_drawing_object_id: `pill_${globalPcbDrawingObjectCount++}`,
|
|
7899
|
-
pcb_drawing_type: "pill",
|
|
7900
|
-
x: holeCenter.x,
|
|
7901
|
-
y: holeCenter.y,
|
|
7902
|
-
w: hole_width ?? 0,
|
|
7903
|
-
h: hole_height ?? 0,
|
|
7904
|
-
layer: "drill",
|
|
7905
|
-
_element: element,
|
|
7906
|
-
_parent_pcb_component,
|
|
7907
|
-
_parent_source_component,
|
|
7908
|
-
ccw_rotation: element.ccw_rotation
|
|
7909
|
-
});
|
|
7910
|
-
}
|
|
7911
|
-
return [...padPrimitives, ...holePrimitives];
|
|
7912
|
-
} else {
|
|
7913
|
-
return [];
|
|
7914
|
-
}
|
|
7915
|
-
}
|
|
7916
7587
|
case "pcb_keepout": {
|
|
7917
7588
|
if (element.shape === "circle") {
|
|
7918
7589
|
const { center, radius } = element;
|
|
@@ -8047,87 +7718,6 @@ var convertElementToPrimitives = (element, allElements) => {
|
|
|
8047
7718
|
});
|
|
8048
7719
|
return primitives;
|
|
8049
7720
|
}
|
|
8050
|
-
case "pcb_silkscreen_rect": {
|
|
8051
|
-
return [
|
|
8052
|
-
{
|
|
8053
|
-
_pcb_drawing_object_id: `rect_${globalPcbDrawingObjectCount++}`,
|
|
8054
|
-
pcb_drawing_type: "rect",
|
|
8055
|
-
x: element.center.x,
|
|
8056
|
-
y: element.center.y,
|
|
8057
|
-
w: element.width,
|
|
8058
|
-
h: element.height,
|
|
8059
|
-
layer: element.layer === "bottom" ? "bottom_silkscreen" : "top_silkscreen",
|
|
8060
|
-
stroke_width: element.stroke_width,
|
|
8061
|
-
is_filled: element.is_filled,
|
|
8062
|
-
has_stroke: element.has_stroke,
|
|
8063
|
-
is_stroke_dashed: element.is_stroke_dashed,
|
|
8064
|
-
roundness: element.corner_radius,
|
|
8065
|
-
_element: element
|
|
8066
|
-
}
|
|
8067
|
-
];
|
|
8068
|
-
}
|
|
8069
|
-
case "pcb_silkscreen_circle": {
|
|
8070
|
-
return [
|
|
8071
|
-
{
|
|
8072
|
-
_pcb_drawing_object_id: `circle_${globalPcbDrawingObjectCount++}`,
|
|
8073
|
-
pcb_drawing_type: "circle",
|
|
8074
|
-
x: element.center.x,
|
|
8075
|
-
y: element.center.y,
|
|
8076
|
-
r: element.radius,
|
|
8077
|
-
layer: element.layer === "bottom" ? "bottom_silkscreen" : "top_silkscreen"
|
|
8078
|
-
}
|
|
8079
|
-
];
|
|
8080
|
-
}
|
|
8081
|
-
case "pcb_silkscreen_oval": {
|
|
8082
|
-
return [
|
|
8083
|
-
{
|
|
8084
|
-
_pcb_drawing_object_id: `oval_${globalPcbDrawingObjectCount++}`,
|
|
8085
|
-
pcb_drawing_type: "oval",
|
|
8086
|
-
x: element.center.x,
|
|
8087
|
-
y: element.center.y,
|
|
8088
|
-
rX: element.radius_x / 2,
|
|
8089
|
-
rY: element.radius_y / 2,
|
|
8090
|
-
layer: element.layer === "bottom" ? "bottom_silkscreen" : "top_silkscreen"
|
|
8091
|
-
}
|
|
8092
|
-
];
|
|
8093
|
-
}
|
|
8094
|
-
// @ts-ignore
|
|
8095
|
-
case "pcb_silkscreen_pill": {
|
|
8096
|
-
return [
|
|
8097
|
-
{
|
|
8098
|
-
_pcb_drawing_object_id: `pill_${globalPcbDrawingObjectCount++}`,
|
|
8099
|
-
pcb_drawing_type: "pill",
|
|
8100
|
-
// @ts-ignore
|
|
8101
|
-
x: element.center.x,
|
|
8102
|
-
// @ts-ignore
|
|
8103
|
-
y: element.center.y,
|
|
8104
|
-
// @ts-ignore
|
|
8105
|
-
w: element.width,
|
|
8106
|
-
// @ts-ignore
|
|
8107
|
-
h: element.height,
|
|
8108
|
-
layer: (
|
|
8109
|
-
// @ts-ignore
|
|
8110
|
-
element.layer === "bottom" ? "bottom_silkscreen" : "top_silkscreen"
|
|
8111
|
-
)
|
|
8112
|
-
}
|
|
8113
|
-
];
|
|
8114
|
-
}
|
|
8115
|
-
case "pcb_silkscreen_line": {
|
|
8116
|
-
return [
|
|
8117
|
-
{
|
|
8118
|
-
_pcb_drawing_object_id: `line_${globalPcbDrawingObjectCount++}`,
|
|
8119
|
-
pcb_drawing_type: "line",
|
|
8120
|
-
x1: element.x1,
|
|
8121
|
-
y1: element.y1,
|
|
8122
|
-
x2: element.x2,
|
|
8123
|
-
y2: element.y2,
|
|
8124
|
-
width: 0.1,
|
|
8125
|
-
// TODO add strokewidth
|
|
8126
|
-
squareCap: false,
|
|
8127
|
-
layer: element.layer === "bottom" ? "bottom_silkscreen" : "top_silkscreen"
|
|
8128
|
-
}
|
|
8129
|
-
];
|
|
8130
|
-
}
|
|
8131
7721
|
case "pcb_fabrication_note_rect": {
|
|
8132
7722
|
const rectElement = element;
|
|
8133
7723
|
const layer = rectElement.layer === "bottom" ? "bottom_fabrication" : "top_fabrication";
|
|
@@ -8156,73 +7746,28 @@ var convertElementToPrimitives = (element, allElements) => {
|
|
|
8156
7746
|
}
|
|
8157
7747
|
];
|
|
8158
7748
|
}
|
|
8159
|
-
case "pcb_fabrication_note_path":
|
|
8160
|
-
|
|
8161
|
-
const
|
|
8162
|
-
|
|
8163
|
-
route
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
layer,
|
|
8182
|
-
_element: element,
|
|
8183
|
-
_parent_pcb_component,
|
|
8184
|
-
_parent_source_component,
|
|
8185
|
-
_source_port
|
|
8186
|
-
};
|
|
8187
|
-
}).filter(Boolean);
|
|
8188
|
-
} else if (type === "pcb_fabrication_note_path") {
|
|
8189
|
-
layer = "top_fabrication";
|
|
8190
|
-
return route.slice(0, -1).map((point, index) => {
|
|
8191
|
-
const nextPoint = route[index + 1];
|
|
8192
|
-
return {
|
|
8193
|
-
_pcb_drawing_object_id: `line_${globalPcbDrawingObjectCount++}`,
|
|
8194
|
-
pcb_drawing_type: "line",
|
|
8195
|
-
x1: point.x,
|
|
8196
|
-
y1: point.y,
|
|
8197
|
-
x2: nextPoint.x,
|
|
8198
|
-
y2: nextPoint.y,
|
|
8199
|
-
width: element.stroke_width ?? 0.1,
|
|
8200
|
-
squareCap: false,
|
|
8201
|
-
layer,
|
|
8202
|
-
color: element.color,
|
|
8203
|
-
_element: element,
|
|
8204
|
-
_parent_pcb_component,
|
|
8205
|
-
_parent_source_component,
|
|
8206
|
-
_source_port
|
|
8207
|
-
};
|
|
8208
|
-
}).filter(Boolean);
|
|
8209
|
-
}
|
|
8210
|
-
}
|
|
8211
|
-
case "pcb_silkscreen_text": {
|
|
8212
|
-
return [
|
|
8213
|
-
{
|
|
8214
|
-
_pcb_drawing_object_id: `text_${globalPcbDrawingObjectCount++}`,
|
|
8215
|
-
pcb_drawing_type: "text",
|
|
8216
|
-
x: element.anchor_position.x,
|
|
8217
|
-
y: element.anchor_position.y,
|
|
8218
|
-
layer: element.layer === "bottom" ? "bottom_silkscreen" : "top_silkscreen",
|
|
8219
|
-
align: element.anchor_alignment ?? "center",
|
|
8220
|
-
text: element.text,
|
|
8221
|
-
size: element.font_size,
|
|
8222
|
-
// Add the required 'size' property
|
|
8223
|
-
ccw_rotation: element.ccw_rotation
|
|
8224
|
-
}
|
|
8225
|
-
];
|
|
7749
|
+
case "pcb_fabrication_note_path": {
|
|
7750
|
+
const { route } = element;
|
|
7751
|
+
const layer = "top_fabrication";
|
|
7752
|
+
return route.slice(0, -1).map((point, index) => {
|
|
7753
|
+
const nextPoint = route[index + 1];
|
|
7754
|
+
return {
|
|
7755
|
+
_pcb_drawing_object_id: `line_${globalPcbDrawingObjectCount++}`,
|
|
7756
|
+
pcb_drawing_type: "line",
|
|
7757
|
+
x1: point.x,
|
|
7758
|
+
y1: point.y,
|
|
7759
|
+
x2: nextPoint.x,
|
|
7760
|
+
y2: nextPoint.y,
|
|
7761
|
+
width: element.stroke_width ?? 0.1,
|
|
7762
|
+
squareCap: false,
|
|
7763
|
+
layer,
|
|
7764
|
+
color: element.color,
|
|
7765
|
+
_element: element,
|
|
7766
|
+
_parent_pcb_component,
|
|
7767
|
+
_parent_source_component,
|
|
7768
|
+
_source_port
|
|
7769
|
+
};
|
|
7770
|
+
}).filter(Boolean);
|
|
8226
7771
|
}
|
|
8227
7772
|
case "pcb_copper_text": {
|
|
8228
7773
|
return convertPcbCopperTextToPrimitive(element, {
|
|
@@ -9326,10 +8871,10 @@ var Drawer = class {
|
|
|
9326
8871
|
...DEFAULT_DRAW_ORDER.filter(
|
|
9327
8872
|
(l) => !layersToShiftToTop.includes(l)
|
|
9328
8873
|
),
|
|
8874
|
+
...associatedSilkscreen ? [associatedSilkscreen] : [],
|
|
9329
8875
|
foregroundLayer,
|
|
9330
8876
|
...maskWithCopperLayerForForeground ? [maskWithCopperLayerForForeground] : [],
|
|
9331
|
-
"drill"
|
|
9332
|
-
...associatedSilkscreen ? [associatedSilkscreen] : []
|
|
8877
|
+
"drill"
|
|
9333
8878
|
];
|
|
9334
8879
|
order.forEach((layer, i) => {
|
|
9335
8880
|
const canvas = canvasLayerMap[layer];
|
|
@@ -9859,6 +9404,43 @@ var drawPrimitives = (drawer, primitives) => {
|
|
|
9859
9404
|
}
|
|
9860
9405
|
};
|
|
9861
9406
|
|
|
9407
|
+
// src/lib/draw-silkscreen.ts
|
|
9408
|
+
import {
|
|
9409
|
+
DEFAULT_PCB_COLOR_MAP,
|
|
9410
|
+
CircuitToCanvasDrawer
|
|
9411
|
+
} from "circuit-to-canvas";
|
|
9412
|
+
var PCB_VIEWER_COLOR_MAP = {
|
|
9413
|
+
...DEFAULT_PCB_COLOR_MAP,
|
|
9414
|
+
silkscreen: {
|
|
9415
|
+
top: colors_default.board.f_silks,
|
|
9416
|
+
bottom: colors_default.board.b_silks
|
|
9417
|
+
}
|
|
9418
|
+
};
|
|
9419
|
+
function isSilkscreenElement(element) {
|
|
9420
|
+
return element.type.includes("pcb_silkscreen");
|
|
9421
|
+
}
|
|
9422
|
+
function drawSilkscreenElementsForLayer(canvas, elements, layers, realToCanvasMat) {
|
|
9423
|
+
const drawer = new CircuitToCanvasDrawer(canvas);
|
|
9424
|
+
drawer.configure({
|
|
9425
|
+
colorOverrides: PCB_VIEWER_COLOR_MAP
|
|
9426
|
+
});
|
|
9427
|
+
drawer.realToCanvasMat = realToCanvasMat;
|
|
9428
|
+
const silkscreenElements = elements.filter(isSilkscreenElement);
|
|
9429
|
+
drawer.drawElements(silkscreenElements, { layers });
|
|
9430
|
+
}
|
|
9431
|
+
|
|
9432
|
+
// src/lib/draw-plated-hole.ts
|
|
9433
|
+
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer2 } from "circuit-to-canvas";
|
|
9434
|
+
function isPlatedHole(element) {
|
|
9435
|
+
return element.type === "pcb_plated_hole";
|
|
9436
|
+
}
|
|
9437
|
+
function drawPlatedHolePads(canvas, elements, layers, realToCanvasMat) {
|
|
9438
|
+
const drawer = new CircuitToCanvasDrawer2(canvas);
|
|
9439
|
+
drawer.realToCanvasMat = realToCanvasMat;
|
|
9440
|
+
const platedHoleElements = elements.filter(isPlatedHole);
|
|
9441
|
+
drawer.drawElements(platedHoleElements, { layers });
|
|
9442
|
+
}
|
|
9443
|
+
|
|
9862
9444
|
// src/components/CanvasPrimitiveRenderer.tsx
|
|
9863
9445
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
9864
9446
|
var orderedLayers = [
|
|
@@ -9883,6 +9465,7 @@ var orderedLayers = [
|
|
|
9883
9465
|
];
|
|
9884
9466
|
var CanvasPrimitiveRenderer = ({
|
|
9885
9467
|
primitives,
|
|
9468
|
+
elements,
|
|
9886
9469
|
transform,
|
|
9887
9470
|
grid,
|
|
9888
9471
|
width = 500,
|
|
@@ -9910,8 +9493,36 @@ var CanvasPrimitiveRenderer = ({
|
|
|
9910
9493
|
drawer.foregroundLayer = selectedLayer;
|
|
9911
9494
|
const filteredPrimitives = isShowingSolderMask ? primitives : primitives.filter((p) => !p.layer?.includes("soldermask"));
|
|
9912
9495
|
drawPrimitives(drawer, filteredPrimitives);
|
|
9496
|
+
if (transform) {
|
|
9497
|
+
const topCanvas = canvasRefs.current.top;
|
|
9498
|
+
if (topCanvas) {
|
|
9499
|
+
drawPlatedHolePads(topCanvas, elements, ["top_copper"], transform);
|
|
9500
|
+
}
|
|
9501
|
+
const bottomCanvas = canvasRefs.current.bottom;
|
|
9502
|
+
if (bottomCanvas) {
|
|
9503
|
+
drawPlatedHolePads(bottomCanvas, elements, ["bottom_copper"], transform);
|
|
9504
|
+
}
|
|
9505
|
+
const topSilkscreenCanvas = canvasRefs.current.top_silkscreen;
|
|
9506
|
+
if (topSilkscreenCanvas) {
|
|
9507
|
+
drawSilkscreenElementsForLayer(
|
|
9508
|
+
topSilkscreenCanvas,
|
|
9509
|
+
elements,
|
|
9510
|
+
["top_silkscreen"],
|
|
9511
|
+
transform
|
|
9512
|
+
);
|
|
9513
|
+
}
|
|
9514
|
+
const bottomSilkscreenCanvas = canvasRefs.current.bottom_silkscreen;
|
|
9515
|
+
if (bottomSilkscreenCanvas) {
|
|
9516
|
+
drawSilkscreenElementsForLayer(
|
|
9517
|
+
bottomSilkscreenCanvas,
|
|
9518
|
+
elements,
|
|
9519
|
+
["bottom_silkscreen"],
|
|
9520
|
+
transform
|
|
9521
|
+
);
|
|
9522
|
+
}
|
|
9523
|
+
}
|
|
9913
9524
|
drawer.orderAndFadeLayers();
|
|
9914
|
-
}, [primitives, transform, selectedLayer, isShowingSolderMask]);
|
|
9525
|
+
}, [primitives, elements, transform, selectedLayer, isShowingSolderMask]);
|
|
9915
9526
|
return /* @__PURE__ */ jsxs(
|
|
9916
9527
|
"div",
|
|
9917
9528
|
{
|
|
@@ -13946,7 +13557,7 @@ import { css as css3 } from "@emotion/css";
|
|
|
13946
13557
|
// package.json
|
|
13947
13558
|
var package_default = {
|
|
13948
13559
|
name: "@tscircuit/pcb-viewer",
|
|
13949
|
-
version: "1.11.
|
|
13560
|
+
version: "1.11.297",
|
|
13950
13561
|
main: "dist/index.js",
|
|
13951
13562
|
type: "module",
|
|
13952
13563
|
repository: "tscircuit/pcb-viewer",
|
|
@@ -13970,7 +13581,7 @@ var package_default = {
|
|
|
13970
13581
|
"@semantic-release/npm": "^9.0.1",
|
|
13971
13582
|
"@semantic-release/release-notes-generator": "^10.0.3",
|
|
13972
13583
|
"@swc/core": "^1.4.12",
|
|
13973
|
-
"@tscircuit/circuit-json-util": "^0.0.
|
|
13584
|
+
"@tscircuit/circuit-json-util": "^0.0.75",
|
|
13974
13585
|
"@tscircuit/eagle-xml-converter": "^1.0.0",
|
|
13975
13586
|
"@types/bun": "latest",
|
|
13976
13587
|
"@types/color": "^3.0.6",
|
|
@@ -13999,7 +13610,8 @@ var package_default = {
|
|
|
13999
13610
|
"@tscircuit/alphabet": "^0.0.9",
|
|
14000
13611
|
"@tscircuit/math-utils": "^0.0.29",
|
|
14001
13612
|
"@vitejs/plugin-react": "^5.0.2",
|
|
14002
|
-
"circuit-json": "^0.0.
|
|
13613
|
+
"circuit-json": "^0.0.347",
|
|
13614
|
+
"circuit-to-canvas": "^0.0.31",
|
|
14003
13615
|
"circuit-to-svg": "^0.0.271",
|
|
14004
13616
|
color: "^4.2.3",
|
|
14005
13617
|
"react-supergrid": "^1.0.10",
|
|
@@ -14944,6 +14556,7 @@ var CanvasElementsRenderer = (props) => {
|
|
|
14944
14556
|
{
|
|
14945
14557
|
transform,
|
|
14946
14558
|
primitives,
|
|
14559
|
+
elements: elementsToRender,
|
|
14947
14560
|
width: props.width,
|
|
14948
14561
|
height: props.height,
|
|
14949
14562
|
grid: props.grid
|