@lucablockltd/ultimate-packaging 1.0.3 → 1.1.0
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/AGENTS_README.md +288 -106
- package/dist/index.d.mts +129 -23
- package/dist/index.d.ts +129 -23
- package/dist/index.js +1662 -411
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1659 -412
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -411,6 +411,7 @@ var AUTO_LAYOUT_THEME_CONFIG = {
|
|
|
411
411
|
};
|
|
412
412
|
|
|
413
413
|
// src/config.ts
|
|
414
|
+
var DEFAULT_FONT_DIMENSION_SIZE = 4.2;
|
|
414
415
|
var globalConfig = {};
|
|
415
416
|
function configurePackaging(config) {
|
|
416
417
|
globalConfig = config;
|
|
@@ -418,6 +419,9 @@ function configurePackaging(config) {
|
|
|
418
419
|
function getModelTheme() {
|
|
419
420
|
return { ...MODEL_THEME_CONFIG, ...globalConfig.modelTheme };
|
|
420
421
|
}
|
|
422
|
+
function getFontDimensionSize() {
|
|
423
|
+
return globalConfig.fontDimensionSize ?? DEFAULT_FONT_DIMENSION_SIZE;
|
|
424
|
+
}
|
|
421
425
|
function getAutoLayoutTheme() {
|
|
422
426
|
return { ...AUTO_LAYOUT_THEME_CONFIG, ...globalConfig.autoLayoutTheme };
|
|
423
427
|
}
|
|
@@ -1009,7 +1013,7 @@ var UNIT_FACTOR = {
|
|
|
1009
1013
|
in: 1 / 25.4
|
|
1010
1014
|
};
|
|
1011
1015
|
var PX_PER_MM = 96 / 25.4;
|
|
1012
|
-
function renderDimension(dim, i) {
|
|
1016
|
+
function renderDimension(dim, i, fs) {
|
|
1013
1017
|
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
1014
1018
|
const tick = 1.5;
|
|
1015
1019
|
if (orientation === "horizontal") {
|
|
@@ -1025,7 +1029,7 @@ function renderDimension(dim, i) {
|
|
|
1025
1029
|
x: midX,
|
|
1026
1030
|
y: y - 1.5,
|
|
1027
1031
|
textAnchor: "middle",
|
|
1028
|
-
fontSize:
|
|
1032
|
+
fontSize: fs,
|
|
1029
1033
|
fontFamily: "sans-serif",
|
|
1030
1034
|
fill: "#000",
|
|
1031
1035
|
children: label
|
|
@@ -1046,7 +1050,7 @@ function renderDimension(dim, i) {
|
|
|
1046
1050
|
y: midY - 1,
|
|
1047
1051
|
textAnchor: "middle",
|
|
1048
1052
|
dominantBaseline: "central",
|
|
1049
|
-
fontSize:
|
|
1053
|
+
fontSize: fs,
|
|
1050
1054
|
fontFamily: "sans-serif",
|
|
1051
1055
|
fill: "#000",
|
|
1052
1056
|
transform: `rotate(-90, ${x - 1.5}, ${midY})`,
|
|
@@ -1155,7 +1159,7 @@ var DIE_LINE_BECF_1010A = forwardRef(
|
|
|
1155
1159
|
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1156
1160
|
/* @__PURE__ */ jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
|
|
1157
1161
|
/* @__PURE__ */ jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
|
|
1158
|
-
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map(renderDimension) })
|
|
1162
|
+
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension(d, i, getFontDimensionSize())) })
|
|
1159
1163
|
] });
|
|
1160
1164
|
if (renderAs === "group") {
|
|
1161
1165
|
return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
@@ -1657,7 +1661,7 @@ var UNIT_FACTOR2 = {
|
|
|
1657
1661
|
in: 1 / 25.4
|
|
1658
1662
|
};
|
|
1659
1663
|
var PX_PER_MM2 = 96 / 25.4;
|
|
1660
|
-
function renderDimension2(dim, i) {
|
|
1664
|
+
function renderDimension2(dim, i, fs) {
|
|
1661
1665
|
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
1662
1666
|
const tick = 1.5;
|
|
1663
1667
|
if (orientation === "horizontal") {
|
|
@@ -1673,7 +1677,7 @@ function renderDimension2(dim, i) {
|
|
|
1673
1677
|
x: midX,
|
|
1674
1678
|
y: y - 1.5,
|
|
1675
1679
|
textAnchor: "middle",
|
|
1676
|
-
fontSize:
|
|
1680
|
+
fontSize: fs,
|
|
1677
1681
|
fontFamily: "sans-serif",
|
|
1678
1682
|
fill: "#000",
|
|
1679
1683
|
children: label
|
|
@@ -1694,7 +1698,7 @@ function renderDimension2(dim, i) {
|
|
|
1694
1698
|
y: midY - 1,
|
|
1695
1699
|
textAnchor: "middle",
|
|
1696
1700
|
dominantBaseline: "central",
|
|
1697
|
-
fontSize:
|
|
1701
|
+
fontSize: fs,
|
|
1698
1702
|
fontFamily: "sans-serif",
|
|
1699
1703
|
fill: "#000",
|
|
1700
1704
|
transform: `rotate(-90, ${x - 1.5}, ${midY})`,
|
|
@@ -1803,7 +1807,7 @@ var DIE_LINE_BECF_1030A = forwardRef(
|
|
|
1803
1807
|
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1804
1808
|
/* @__PURE__ */ jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
|
|
1805
1809
|
/* @__PURE__ */ jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
|
|
1806
|
-
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map(renderDimension2) })
|
|
1810
|
+
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension2(d, i, getFontDimensionSize())) })
|
|
1807
1811
|
] });
|
|
1808
1812
|
if (renderAs === "group") {
|
|
1809
1813
|
return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
@@ -2308,7 +2312,7 @@ var UNIT_FACTOR3 = {
|
|
|
2308
2312
|
in: 1 / 25.4
|
|
2309
2313
|
};
|
|
2310
2314
|
var PX_PER_MM3 = 96 / 25.4;
|
|
2311
|
-
function renderDimension3(dim, i) {
|
|
2315
|
+
function renderDimension3(dim, i, fs) {
|
|
2312
2316
|
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
2313
2317
|
const tick = 1.5;
|
|
2314
2318
|
if (orientation === "horizontal") {
|
|
@@ -2324,7 +2328,7 @@ function renderDimension3(dim, i) {
|
|
|
2324
2328
|
x: midX,
|
|
2325
2329
|
y: y - 1.5,
|
|
2326
2330
|
textAnchor: "middle",
|
|
2327
|
-
fontSize:
|
|
2331
|
+
fontSize: fs,
|
|
2328
2332
|
fontFamily: "sans-serif",
|
|
2329
2333
|
fill: "#000",
|
|
2330
2334
|
children: label
|
|
@@ -2345,7 +2349,7 @@ function renderDimension3(dim, i) {
|
|
|
2345
2349
|
y: midY - 1,
|
|
2346
2350
|
textAnchor: "middle",
|
|
2347
2351
|
dominantBaseline: "central",
|
|
2348
|
-
fontSize:
|
|
2352
|
+
fontSize: fs,
|
|
2349
2353
|
fontFamily: "sans-serif",
|
|
2350
2354
|
fill: "#000",
|
|
2351
2355
|
transform: `rotate(-90, ${x - 1.5}, ${midY})`,
|
|
@@ -2454,7 +2458,7 @@ var DIE_LINE_BECF_1040A = forwardRef(
|
|
|
2454
2458
|
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2455
2459
|
/* @__PURE__ */ jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
|
|
2456
2460
|
/* @__PURE__ */ jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
|
|
2457
|
-
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map(renderDimension3) })
|
|
2461
|
+
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension3(d, i, getFontDimensionSize())) })
|
|
2458
2462
|
] });
|
|
2459
2463
|
if (renderAs === "group") {
|
|
2460
2464
|
return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
@@ -2871,7 +2875,7 @@ var UNIT_FACTOR4 = {
|
|
|
2871
2875
|
in: 1 / 25.4
|
|
2872
2876
|
};
|
|
2873
2877
|
var PX_PER_MM4 = 96 / 25.4;
|
|
2874
|
-
function renderDimension4(dim, i) {
|
|
2878
|
+
function renderDimension4(dim, i, fs) {
|
|
2875
2879
|
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
2876
2880
|
const tick = 1.5;
|
|
2877
2881
|
if (orientation === "horizontal") {
|
|
@@ -2887,7 +2891,7 @@ function renderDimension4(dim, i) {
|
|
|
2887
2891
|
x: midX,
|
|
2888
2892
|
y: y - 1.5,
|
|
2889
2893
|
textAnchor: "middle",
|
|
2890
|
-
fontSize:
|
|
2894
|
+
fontSize: fs,
|
|
2891
2895
|
fontFamily: "sans-serif",
|
|
2892
2896
|
fill: "#000",
|
|
2893
2897
|
children: label
|
|
@@ -2908,7 +2912,7 @@ function renderDimension4(dim, i) {
|
|
|
2908
2912
|
y: midY - 1,
|
|
2909
2913
|
textAnchor: "middle",
|
|
2910
2914
|
dominantBaseline: "central",
|
|
2911
|
-
fontSize:
|
|
2915
|
+
fontSize: fs,
|
|
2912
2916
|
fontFamily: "sans-serif",
|
|
2913
2917
|
fill: "#000",
|
|
2914
2918
|
transform: `rotate(-90, ${x - 1.5}, ${midY})`,
|
|
@@ -3016,7 +3020,7 @@ var DIE_LINE_BECF_11D01 = forwardRef(
|
|
|
3016
3020
|
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3017
3021
|
/* @__PURE__ */ jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
|
|
3018
3022
|
/* @__PURE__ */ jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
|
|
3019
|
-
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map(renderDimension4) })
|
|
3023
|
+
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension4(d, i, getFontDimensionSize())) })
|
|
3020
3024
|
] });
|
|
3021
3025
|
if (renderAs === "group") {
|
|
3022
3026
|
return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
@@ -3130,129 +3134,1122 @@ var MODEL_BECF_11D01 = forwardRef(
|
|
|
3130
3134
|
}
|
|
3131
3135
|
);
|
|
3132
3136
|
|
|
3133
|
-
// src/
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
const endGx = Math.min(w - 1, Math.ceil((crossings[c + 1] - offsetX * resolution) / resolution));
|
|
3161
|
-
for (let gx = startGx; gx <= endGx; gx++) {
|
|
3162
|
-
data[gy * w + gx] = 1;
|
|
3163
|
-
}
|
|
3164
|
-
}
|
|
3165
|
-
}
|
|
3166
|
-
return { data, width: w, height: h, offsetX, offsetY };
|
|
3137
|
+
// src/components/dieline/bags-pillows/becf-12101/generate.ts
|
|
3138
|
+
var DIP = 15;
|
|
3139
|
+
var ROPE_R = 3;
|
|
3140
|
+
var ROPE_Y = 20;
|
|
3141
|
+
var D_MAX = 40;
|
|
3142
|
+
function calcD(c, b) {
|
|
3143
|
+
return Math.min(c - 2 - b / 2, D_MAX);
|
|
3144
|
+
}
|
|
3145
|
+
function calcKulak(b) {
|
|
3146
|
+
if (b <= 13) return b - 1;
|
|
3147
|
+
if (b <= 99) return 13;
|
|
3148
|
+
if (b <= 249) return 20;
|
|
3149
|
+
if (b <= 499) return 25;
|
|
3150
|
+
return 30;
|
|
3151
|
+
}
|
|
3152
|
+
function calcX(a) {
|
|
3153
|
+
return Math.min(a / 2, 110);
|
|
3154
|
+
}
|
|
3155
|
+
function getAutoCalcValues(attr) {
|
|
3156
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3157
|
+
const D = calcD(C, B);
|
|
3158
|
+
const kulak = glueArea ?? calcKulak(B);
|
|
3159
|
+
const X = calcX(A);
|
|
3160
|
+
return { d: D, kulak, dip: DIP, ropeR: ROPE_R, ropeY: ROPE_Y, ropeX: X };
|
|
3161
|
+
}
|
|
3162
|
+
function line5(x1, y1, x2, y2) {
|
|
3163
|
+
return `M${x1} ${y1} L${x2} ${y2}`;
|
|
3167
3164
|
}
|
|
3168
|
-
function
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3165
|
+
function circlePath(cx, cy, r) {
|
|
3166
|
+
return `M${cx - r} ${cy} A${r} ${r} 0 0 1 ${cx + r} ${cy} A${r} ${r} 0 0 1 ${cx - r} ${cy}`;
|
|
3167
|
+
}
|
|
3168
|
+
function generateBecf12101(attr) {
|
|
3169
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3170
|
+
const D = calcD(C, B);
|
|
3171
|
+
const kulak = glueArea ?? calcKulak(B);
|
|
3172
|
+
const X = calcX(A);
|
|
3173
|
+
const xFront = kulak;
|
|
3174
|
+
const xSide1 = kulak + A;
|
|
3175
|
+
const xSide1Mid = kulak + A + B / 2;
|
|
3176
|
+
const xBack = kulak + A + B;
|
|
3177
|
+
const xSide2 = kulak + 2 * A + B;
|
|
3178
|
+
const xSide2Mid = kulak + 2 * A + B + B / 2;
|
|
3179
|
+
const xEnd = kulak + 2 * A + 2 * B - 2;
|
|
3180
|
+
const yFoldTop = D;
|
|
3181
|
+
const yFoldBottomStart = D + C - B / 2;
|
|
3182
|
+
const yFoldBottom = D + C;
|
|
3183
|
+
const yBottomFlap = D + C + B / 2;
|
|
3184
|
+
const yEnd = D + C + B / 2 + DIP;
|
|
3185
|
+
const totalWidth = xEnd;
|
|
3186
|
+
const totalHeight = yEnd;
|
|
3187
|
+
const cut = [];
|
|
3188
|
+
const crease = [];
|
|
3189
|
+
cut.push(line5(0, 0, totalWidth, 0));
|
|
3190
|
+
cut.push(line5(totalWidth, 0, totalWidth, totalHeight));
|
|
3191
|
+
cut.push(line5(totalWidth, totalHeight, 0, totalHeight));
|
|
3192
|
+
cut.push(line5(0, totalHeight, 0, 0));
|
|
3193
|
+
cut.push(line5(kulak + B / 2, yBottomFlap, kulak + B / 2, yEnd));
|
|
3194
|
+
cut.push(line5(kulak + A - B / 2, yBottomFlap, kulak + A - B / 2, yEnd));
|
|
3195
|
+
cut.push(line5(kulak + A + B + B / 2, yBottomFlap, kulak + A + B + B / 2, yEnd));
|
|
3196
|
+
cut.push(line5(kulak + 2 * A + B - B / 2, yBottomFlap, kulak + 2 * A + B - B / 2, yEnd));
|
|
3197
|
+
const frontCx = kulak + A / 2;
|
|
3198
|
+
const backCx = kulak + A + B + A / 2;
|
|
3199
|
+
const ropeTopY = yFoldTop - ROPE_Y;
|
|
3200
|
+
const ropeBotY = yFoldTop + ROPE_Y;
|
|
3201
|
+
cut.push(circlePath(frontCx - X / 2, ropeTopY, ROPE_R));
|
|
3202
|
+
cut.push(circlePath(frontCx - X / 2, ropeBotY, ROPE_R));
|
|
3203
|
+
cut.push(circlePath(frontCx + X / 2, ropeTopY, ROPE_R));
|
|
3204
|
+
cut.push(circlePath(frontCx + X / 2, ropeBotY, ROPE_R));
|
|
3205
|
+
cut.push(circlePath(backCx - X / 2, ropeTopY, ROPE_R));
|
|
3206
|
+
cut.push(circlePath(backCx - X / 2, ropeBotY, ROPE_R));
|
|
3207
|
+
cut.push(circlePath(backCx + X / 2, ropeTopY, ROPE_R));
|
|
3208
|
+
cut.push(circlePath(backCx + X / 2, ropeBotY, ROPE_R));
|
|
3209
|
+
crease.push(line5(0, yFoldTop, totalWidth, yFoldTop));
|
|
3210
|
+
crease.push(line5(0, yFoldBottomStart, totalWidth, yFoldBottomStart));
|
|
3211
|
+
crease.push(line5(0, yFoldBottom, totalWidth, yFoldBottom));
|
|
3212
|
+
crease.push(line5(xFront, 0, xFront, totalHeight));
|
|
3213
|
+
crease.push(line5(xSide1, 0, xSide1, totalHeight));
|
|
3214
|
+
crease.push(line5(xSide1Mid, 0, xSide1Mid, totalHeight));
|
|
3215
|
+
crease.push(line5(xBack, 0, xBack, totalHeight));
|
|
3216
|
+
crease.push(line5(xSide2, 0, xSide2, totalHeight));
|
|
3217
|
+
crease.push(line5(xSide2Mid, 0, xSide2Mid, totalHeight));
|
|
3218
|
+
crease.push(line5(0, yFoldBottom - kulak, kulak + B / 2, yBottomFlap));
|
|
3219
|
+
crease.push(line5(kulak + A - B / 2, yBottomFlap, xSide1Mid, yFoldBottomStart));
|
|
3220
|
+
crease.push(line5(xSide1Mid, yFoldBottomStart, kulak + A + B + B / 2, yBottomFlap));
|
|
3221
|
+
crease.push(line5(kulak + 2 * A + B - B / 2, yBottomFlap, xSide2Mid, yFoldBottomStart));
|
|
3222
|
+
crease.push(line5(xSide2Mid, yFoldBottomStart, xEnd, D + C - 2));
|
|
3223
|
+
return { cut, crease, viewBox: { width: totalWidth, height: totalHeight } };
|
|
3224
|
+
}
|
|
3225
|
+
function generateOuterContour5(attr) {
|
|
3226
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3227
|
+
const D = calcD(C, B);
|
|
3228
|
+
const kulak = glueArea ?? calcKulak(B);
|
|
3229
|
+
const totalWidth = kulak + 2 * A + 2 * B - 2;
|
|
3230
|
+
const totalHeight = D + C + B / 2 + DIP;
|
|
3231
|
+
return [
|
|
3232
|
+
{ x: 0, y: 0 },
|
|
3233
|
+
{ x: totalWidth, y: 0 },
|
|
3234
|
+
{ x: totalWidth, y: totalHeight },
|
|
3235
|
+
{ x: 0, y: totalHeight }
|
|
3236
|
+
];
|
|
3237
|
+
}
|
|
3238
|
+
function offsetContour5(points, distance) {
|
|
3239
|
+
const n = points.length;
|
|
3240
|
+
const result = [];
|
|
3241
|
+
for (let i = 0; i < n; i++) {
|
|
3242
|
+
const prev = points[(i - 1 + n) % n];
|
|
3243
|
+
const curr = points[i];
|
|
3244
|
+
const next = points[(i + 1) % n];
|
|
3245
|
+
const e1x = curr.x - prev.x;
|
|
3246
|
+
const e1y = curr.y - prev.y;
|
|
3247
|
+
const e2x = next.x - curr.x;
|
|
3248
|
+
const e2y = next.y - curr.y;
|
|
3249
|
+
const len1 = Math.sqrt(e1x * e1x + e1y * e1y);
|
|
3250
|
+
const len2 = Math.sqrt(e2x * e2x + e2y * e2y);
|
|
3251
|
+
if (len1 === 0 || len2 === 0) {
|
|
3252
|
+
result.push(curr);
|
|
3175
3253
|
continue;
|
|
3176
3254
|
}
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3255
|
+
const n1x = e1y / len1;
|
|
3256
|
+
const n1y = -e1x / len1;
|
|
3257
|
+
const n2x = e2y / len2;
|
|
3258
|
+
const n2y = -e2x / len2;
|
|
3259
|
+
const ax = n1x + n2x;
|
|
3260
|
+
const ay = n1y + n2y;
|
|
3261
|
+
const aLen = Math.sqrt(ax * ax + ay * ay);
|
|
3262
|
+
if (aLen < 1e-3) {
|
|
3263
|
+
result.push({ x: curr.x + n1x * distance, y: curr.y + n1y * distance });
|
|
3264
|
+
continue;
|
|
3182
3265
|
}
|
|
3266
|
+
const nx = ax / aLen;
|
|
3267
|
+
const ny = ay / aLen;
|
|
3268
|
+
const dot = n1x * nx + n1y * ny;
|
|
3269
|
+
const d = distance / Math.max(dot, 0.1);
|
|
3270
|
+
result.push({ x: curr.x + nx * d, y: curr.y + ny * d });
|
|
3183
3271
|
}
|
|
3184
|
-
return
|
|
3272
|
+
return result;
|
|
3185
3273
|
}
|
|
3186
|
-
function
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
}
|
|
3192
|
-
}
|
|
3274
|
+
function contourToPath5(points) {
|
|
3275
|
+
if (points.length === 0) return "";
|
|
3276
|
+
let d = `M${points[0].x} ${points[0].y}`;
|
|
3277
|
+
for (let i = 1; i < points.length; i++) {
|
|
3278
|
+
d += ` L${points[i].x} ${points[i].y}`;
|
|
3193
3279
|
}
|
|
3280
|
+
d += " Z";
|
|
3281
|
+
return d;
|
|
3194
3282
|
}
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
}
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3283
|
+
function generateDimensions5(attr, unit) {
|
|
3284
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3285
|
+
const D = calcD(C, B);
|
|
3286
|
+
const kulak = glueArea ?? calcKulak(B);
|
|
3287
|
+
const factor = unit === "cm" ? 0.1 : unit === "in" ? 1 / 25.4 : 1;
|
|
3288
|
+
const suffix = unit;
|
|
3289
|
+
const fmt = (v) => `${(v * factor).toFixed(2)} ${suffix}`;
|
|
3290
|
+
const xFront = kulak;
|
|
3291
|
+
const xSide1 = kulak + A;
|
|
3292
|
+
const xBack = kulak + A + B;
|
|
3293
|
+
const yFoldTop = D;
|
|
3294
|
+
const yFoldBottom = D + C;
|
|
3295
|
+
const yEnd = D + C + B / 2 + DIP;
|
|
3296
|
+
const totalWidth = kulak + 2 * A + 2 * B - 2;
|
|
3297
|
+
const totalHeight = yEnd;
|
|
3298
|
+
const bottomSection = B / 2 + DIP;
|
|
3299
|
+
return [
|
|
3300
|
+
// Overall dimensions (outside)
|
|
3301
|
+
{
|
|
3302
|
+
x1: 0,
|
|
3303
|
+
y1: 0,
|
|
3304
|
+
x2: totalWidth,
|
|
3305
|
+
y2: 0,
|
|
3306
|
+
label: `Overall Width : ${fmt(totalWidth)}`,
|
|
3307
|
+
orientation: "horizontal",
|
|
3308
|
+
offset: -12
|
|
3309
|
+
},
|
|
3310
|
+
{
|
|
3311
|
+
x1: 0,
|
|
3312
|
+
y1: 0,
|
|
3313
|
+
x2: 0,
|
|
3314
|
+
y2: totalHeight,
|
|
3315
|
+
label: `Overall Height : ${fmt(totalHeight)}`,
|
|
3316
|
+
orientation: "vertical",
|
|
3317
|
+
offset: -12
|
|
3318
|
+
},
|
|
3319
|
+
// Height (C) — body area (centered on back panel)
|
|
3320
|
+
{
|
|
3321
|
+
x1: xBack + A * 0.6,
|
|
3322
|
+
y1: yFoldTop,
|
|
3323
|
+
x2: xBack + A * 0.6,
|
|
3324
|
+
y2: yFoldBottom,
|
|
3325
|
+
label: fmt(C),
|
|
3326
|
+
orientation: "vertical",
|
|
3327
|
+
offset: -10
|
|
3328
|
+
},
|
|
3329
|
+
// Top flap (D) (centered on back panel)
|
|
3330
|
+
{
|
|
3331
|
+
x1: xBack + A * 0.6,
|
|
3332
|
+
y1: 0,
|
|
3333
|
+
x2: xBack + A * 0.6,
|
|
3334
|
+
y2: yFoldTop,
|
|
3335
|
+
label: fmt(D),
|
|
3336
|
+
orientation: "vertical",
|
|
3337
|
+
offset: -10
|
|
3338
|
+
},
|
|
3339
|
+
// Bottom section (B/2 + _dip) (centered on back panel)
|
|
3340
|
+
{
|
|
3341
|
+
x1: xBack + A * 0.6,
|
|
3342
|
+
y1: yFoldBottom,
|
|
3343
|
+
x2: xBack + A * 0.6,
|
|
3344
|
+
y2: yEnd,
|
|
3345
|
+
label: fmt(bottomSection),
|
|
3346
|
+
orientation: "vertical",
|
|
3347
|
+
offset: -10
|
|
3348
|
+
},
|
|
3349
|
+
// Length (A) — front panel (centered vertically on body)
|
|
3350
|
+
{
|
|
3351
|
+
x1: xFront,
|
|
3352
|
+
y1: yFoldTop + C * 0.65,
|
|
3353
|
+
x2: xSide1,
|
|
3354
|
+
y2: yFoldTop + C * 0.65,
|
|
3355
|
+
label: fmt(A),
|
|
3356
|
+
orientation: "horizontal",
|
|
3357
|
+
offset: -20
|
|
3358
|
+
},
|
|
3359
|
+
// Width (B) — side panel (centered vertically on body)
|
|
3360
|
+
{
|
|
3361
|
+
x1: xSide1,
|
|
3362
|
+
y1: yFoldTop + C * 0.65,
|
|
3363
|
+
x2: xBack,
|
|
3364
|
+
y2: yFoldTop + C * 0.65,
|
|
3365
|
+
label: fmt(B),
|
|
3366
|
+
orientation: "horizontal",
|
|
3367
|
+
offset: -20
|
|
3368
|
+
},
|
|
3369
|
+
// Glue Area (kulak) — left glue flap width
|
|
3370
|
+
{
|
|
3371
|
+
x1: 0,
|
|
3372
|
+
y1: yFoldTop + C * 0.65,
|
|
3373
|
+
x2: xFront,
|
|
3374
|
+
y2: yFoldTop + C * 0.65,
|
|
3375
|
+
label: fmt(kulak),
|
|
3376
|
+
orientation: "horizontal",
|
|
3377
|
+
offset: -20
|
|
3378
|
+
}
|
|
3379
|
+
];
|
|
3233
3380
|
}
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3381
|
+
var MODEL_ID5 = "BECF-12101";
|
|
3382
|
+
var UNIT_FACTOR5 = {
|
|
3383
|
+
mm: 1,
|
|
3384
|
+
cm: 0.1,
|
|
3385
|
+
in: 1 / 25.4
|
|
3386
|
+
};
|
|
3387
|
+
var PX_PER_MM5 = 96 / 25.4;
|
|
3388
|
+
function renderDimension5(dim, i, fs) {
|
|
3389
|
+
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
3390
|
+
const tick = 1.5;
|
|
3391
|
+
if (orientation === "horizontal") {
|
|
3392
|
+
const y = y1 + offset;
|
|
3393
|
+
const midX = (x1 + x2) / 2;
|
|
3394
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
3395
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y, x2, y2: y, stroke: "#000", strokeWidth: 0.2 }),
|
|
3396
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y - tick, x2: x1, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
3397
|
+
/* @__PURE__ */ jsx("line", { x1: x2, y1: y - tick, x2, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
3398
|
+
/* @__PURE__ */ jsx(
|
|
3399
|
+
"text",
|
|
3400
|
+
{
|
|
3401
|
+
x: midX,
|
|
3402
|
+
y: y - 1.5,
|
|
3403
|
+
textAnchor: "middle",
|
|
3404
|
+
fontSize: fs,
|
|
3405
|
+
fontFamily: "sans-serif",
|
|
3406
|
+
fill: "#000",
|
|
3407
|
+
children: label
|
|
3408
|
+
}
|
|
3409
|
+
)
|
|
3410
|
+
] }, `dim-${i}`);
|
|
3246
3411
|
}
|
|
3247
|
-
|
|
3412
|
+
const x = x1 + offset;
|
|
3413
|
+
const midY = (y1 + y2) / 2;
|
|
3414
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
3415
|
+
/* @__PURE__ */ jsx("line", { x1: x, y1, x2: x, y2, stroke: "#000", strokeWidth: 0.2 }),
|
|
3416
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1, x2: x + tick, y2: y1, stroke: "#000", strokeWidth: 0.3 }),
|
|
3417
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1: y2, x2: x + tick, y2, stroke: "#000", strokeWidth: 0.3 }),
|
|
3418
|
+
/* @__PURE__ */ jsx(
|
|
3419
|
+
"text",
|
|
3420
|
+
{
|
|
3421
|
+
x: x - 1.5,
|
|
3422
|
+
y: midY - 1,
|
|
3423
|
+
textAnchor: "middle",
|
|
3424
|
+
dominantBaseline: "central",
|
|
3425
|
+
fontSize: fs,
|
|
3426
|
+
fontFamily: "sans-serif",
|
|
3427
|
+
fill: "#000",
|
|
3428
|
+
transform: `rotate(-90, ${x - 1.5}, ${midY})`,
|
|
3429
|
+
children: label
|
|
3430
|
+
}
|
|
3431
|
+
)
|
|
3432
|
+
] }, `dim-${i}`);
|
|
3248
3433
|
}
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3434
|
+
var DIE_LINE_BECF_12101 = forwardRef(
|
|
3435
|
+
({
|
|
3436
|
+
attributes,
|
|
3437
|
+
unit = "mm",
|
|
3438
|
+
isShowDimensions = false,
|
|
3439
|
+
renderAs = "svg"
|
|
3440
|
+
}, ref) => {
|
|
3441
|
+
const theme = useMemo(
|
|
3442
|
+
() => getModelTheme(),
|
|
3443
|
+
[]
|
|
3444
|
+
);
|
|
3445
|
+
const svgRef = useRef(null);
|
|
3446
|
+
const dieline = useMemo(() => generateBecf12101(attributes), [attributes]);
|
|
3447
|
+
const dimensions = useMemo(
|
|
3448
|
+
() => generateDimensions5(attributes, unit),
|
|
3449
|
+
[attributes, unit]
|
|
3450
|
+
);
|
|
3451
|
+
const factor = UNIT_FACTOR5[unit] ?? 1;
|
|
3452
|
+
const serializeSvg = useCallback(
|
|
3453
|
+
(showDimensions) => {
|
|
3454
|
+
const svg = svgRef.current;
|
|
3455
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
3456
|
+
const clone = svg.cloneNode(true);
|
|
3457
|
+
if (!showDimensions) {
|
|
3458
|
+
const dimGroup = clone.querySelector("#dimensions");
|
|
3459
|
+
dimGroup?.remove();
|
|
3460
|
+
}
|
|
3461
|
+
return new XMLSerializer().serializeToString(clone);
|
|
3462
|
+
},
|
|
3463
|
+
[]
|
|
3464
|
+
);
|
|
3465
|
+
useImperativeHandle(
|
|
3466
|
+
ref,
|
|
3467
|
+
() => {
|
|
3468
|
+
const auto = getAutoCalcValues(attributes);
|
|
3469
|
+
return {
|
|
3470
|
+
getAttributes: () => ({
|
|
3471
|
+
modelId: MODEL_ID5,
|
|
3472
|
+
overallWidth: dieline.viewBox.width * factor,
|
|
3473
|
+
overallHeight: dieline.viewBox.height * factor,
|
|
3474
|
+
length: attributes.length * factor,
|
|
3475
|
+
width: attributes.width * factor,
|
|
3476
|
+
height: attributes.height * factor,
|
|
3477
|
+
glueArea: auto.kulak * factor,
|
|
3478
|
+
d: auto.d * factor,
|
|
3479
|
+
kulak: auto.kulak * factor,
|
|
3480
|
+
dip: auto.dip * factor,
|
|
3481
|
+
ropeR: auto.ropeR * factor,
|
|
3482
|
+
ropeY: auto.ropeY * factor,
|
|
3483
|
+
ropeX: auto.ropeX * factor
|
|
3484
|
+
}),
|
|
3485
|
+
exportImage: async (options) => {
|
|
3486
|
+
const svgStr = serializeSvg(options.isShowDimension);
|
|
3487
|
+
const blob = new Blob([svgStr], {
|
|
3488
|
+
type: "image/svg+xml;charset=utf-8"
|
|
3489
|
+
});
|
|
3490
|
+
const url = URL.createObjectURL(blob);
|
|
3491
|
+
const img = new Image();
|
|
3492
|
+
await new Promise((resolve, reject) => {
|
|
3493
|
+
img.onload = () => resolve();
|
|
3494
|
+
img.onerror = reject;
|
|
3495
|
+
img.src = url;
|
|
3496
|
+
});
|
|
3497
|
+
const canvas = document.createElement("canvas");
|
|
3498
|
+
if (options.originalSize) {
|
|
3499
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM5);
|
|
3500
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM5);
|
|
3501
|
+
} else {
|
|
3502
|
+
canvas.width = 1920;
|
|
3503
|
+
canvas.height = 1080;
|
|
3504
|
+
}
|
|
3505
|
+
const ctx = canvas.getContext("2d");
|
|
3506
|
+
ctx.fillStyle = "#ffffff";
|
|
3507
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
3508
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
3509
|
+
URL.revokeObjectURL(url);
|
|
3510
|
+
return new Promise((resolve, reject) => {
|
|
3511
|
+
canvas.toBlob(
|
|
3512
|
+
(b) => b ? resolve(b) : reject(new Error("Export failed")),
|
|
3513
|
+
"image/png"
|
|
3514
|
+
);
|
|
3515
|
+
});
|
|
3516
|
+
},
|
|
3517
|
+
exportDimension: async () => {
|
|
3518
|
+
const dimData = generateDimensions5(attributes, unit);
|
|
3519
|
+
return exportDimensionPdf({
|
|
3520
|
+
modelId: MODEL_ID5,
|
|
3521
|
+
dieline,
|
|
3522
|
+
dimensions: dimData,
|
|
3523
|
+
attributes,
|
|
3524
|
+
unit,
|
|
3525
|
+
factor,
|
|
3526
|
+
theme
|
|
3527
|
+
});
|
|
3528
|
+
}
|
|
3529
|
+
};
|
|
3530
|
+
},
|
|
3531
|
+
[attributes, dieline, factor, unit, serializeSvg, theme]
|
|
3532
|
+
);
|
|
3533
|
+
const padding = isShowDimensions ? 15 : 0;
|
|
3534
|
+
const vbX = -padding;
|
|
3535
|
+
const vbY = -padding;
|
|
3536
|
+
const vbW = dieline.viewBox.width + padding * 2;
|
|
3537
|
+
const vbH = dieline.viewBox.height + padding * 2;
|
|
3538
|
+
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3539
|
+
/* @__PURE__ */ jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
|
|
3540
|
+
/* @__PURE__ */ jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
|
|
3541
|
+
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension5(d, i, getFontDimensionSize())) })
|
|
3542
|
+
] });
|
|
3543
|
+
if (renderAs === "group") {
|
|
3544
|
+
return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
3545
|
+
}
|
|
3546
|
+
return /* @__PURE__ */ jsx(
|
|
3547
|
+
"svg",
|
|
3548
|
+
{
|
|
3549
|
+
ref: svgRef,
|
|
3550
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3551
|
+
viewBox: `${vbX} ${vbY} ${vbW} ${vbH}`,
|
|
3552
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
3553
|
+
style: { backgroundColor: theme.colorBackground },
|
|
3554
|
+
children: svgChildren
|
|
3555
|
+
}
|
|
3556
|
+
);
|
|
3557
|
+
}
|
|
3558
|
+
);
|
|
3559
|
+
var CANVAS_BECF_12101 = forwardRef(
|
|
3560
|
+
(props, ref) => {
|
|
3561
|
+
const dieLineRef = useRef(null);
|
|
3562
|
+
const canvasRef = useRef(null);
|
|
3563
|
+
const {
|
|
3564
|
+
attributes
|
|
3565
|
+
} = props;
|
|
3566
|
+
const theme = useMemo(
|
|
3567
|
+
() => getModelTheme(),
|
|
3568
|
+
[]
|
|
3569
|
+
);
|
|
3570
|
+
const dieline = useMemo(() => generateBecf12101(attributes), [attributes]);
|
|
3571
|
+
const stablePadding = 15;
|
|
3572
|
+
const viewBox = useMemo(
|
|
3573
|
+
() => ({
|
|
3574
|
+
x: -stablePadding,
|
|
3575
|
+
y: -stablePadding,
|
|
3576
|
+
width: dieline.viewBox.width + stablePadding * 2,
|
|
3577
|
+
height: dieline.viewBox.height + stablePadding * 2
|
|
3578
|
+
}),
|
|
3579
|
+
[dieline.viewBox.width, dieline.viewBox.height]
|
|
3580
|
+
);
|
|
3581
|
+
const serializeCanvasSvg = useCallback((showDimensions) => {
|
|
3582
|
+
const svg = canvasRef.current?.getSvgElement();
|
|
3583
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
3584
|
+
const clone = svg.cloneNode(true);
|
|
3585
|
+
if (!showDimensions) {
|
|
3586
|
+
const dimGroup = clone.querySelector("#dimensions");
|
|
3587
|
+
dimGroup?.remove();
|
|
3588
|
+
}
|
|
3589
|
+
return new XMLSerializer().serializeToString(clone);
|
|
3590
|
+
}, []);
|
|
3591
|
+
useImperativeHandle(ref, () => ({
|
|
3592
|
+
getAttributes: () => dieLineRef.current.getAttributes(),
|
|
3593
|
+
exportImage: async (options) => {
|
|
3594
|
+
const svgStr = serializeCanvasSvg(options.isShowDimension);
|
|
3595
|
+
const blob = new Blob([svgStr], { type: "image/svg+xml;charset=utf-8" });
|
|
3596
|
+
const url = URL.createObjectURL(blob);
|
|
3597
|
+
const img = new Image();
|
|
3598
|
+
await new Promise((resolve, reject) => {
|
|
3599
|
+
img.onload = () => resolve();
|
|
3600
|
+
img.onerror = reject;
|
|
3601
|
+
img.src = url;
|
|
3602
|
+
});
|
|
3603
|
+
const canvas = document.createElement("canvas");
|
|
3604
|
+
if (options.originalSize) {
|
|
3605
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM5);
|
|
3606
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM5);
|
|
3607
|
+
} else {
|
|
3608
|
+
canvas.width = 1920;
|
|
3609
|
+
canvas.height = 1080;
|
|
3610
|
+
}
|
|
3611
|
+
const ctx = canvas.getContext("2d");
|
|
3612
|
+
ctx.fillStyle = "#ffffff";
|
|
3613
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
3614
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
3615
|
+
URL.revokeObjectURL(url);
|
|
3616
|
+
return new Promise((resolve, reject) => {
|
|
3617
|
+
canvas.toBlob(
|
|
3618
|
+
(b) => b ? resolve(b) : reject(new Error("Export failed")),
|
|
3619
|
+
"image/png"
|
|
3620
|
+
);
|
|
3621
|
+
});
|
|
3622
|
+
},
|
|
3623
|
+
exportDimension: () => dieLineRef.current.exportDimension(),
|
|
3624
|
+
resetView: () => canvasRef.current?.resetView(),
|
|
3625
|
+
fitView: () => canvasRef.current?.fitView()
|
|
3626
|
+
}), [serializeCanvasSvg, dieline.viewBox.width, dieline.viewBox.height]);
|
|
3627
|
+
return /* @__PURE__ */ jsx(
|
|
3628
|
+
BaseCanvas,
|
|
3629
|
+
{
|
|
3630
|
+
ref: canvasRef,
|
|
3631
|
+
viewBox,
|
|
3632
|
+
backgroundColor: theme.colorBackground,
|
|
3633
|
+
children: /* @__PURE__ */ jsx(DIE_LINE_BECF_12101, { ref: dieLineRef, ...props, renderAs: "group" })
|
|
3634
|
+
}
|
|
3635
|
+
);
|
|
3636
|
+
}
|
|
3637
|
+
);
|
|
3638
|
+
var MODEL_BECF_12101 = forwardRef(
|
|
3639
|
+
({ mode = "DIE_LINE", ...props }, ref) => {
|
|
3640
|
+
return /* @__PURE__ */ jsx(Fragment, { children: (() => {
|
|
3641
|
+
switch (mode) {
|
|
3642
|
+
case "DIE_LINE":
|
|
3643
|
+
return /* @__PURE__ */ jsx(CANVAS_BECF_12101, { ref, ...props });
|
|
3644
|
+
case "3D":
|
|
3645
|
+
return null;
|
|
3646
|
+
case "AUTO_LAYOUT":
|
|
3647
|
+
return /* @__PURE__ */ jsx(DIE_LINE_BECF_12101, { ref, ...props });
|
|
3648
|
+
default:
|
|
3649
|
+
return null;
|
|
3650
|
+
}
|
|
3651
|
+
})() });
|
|
3652
|
+
}
|
|
3653
|
+
);
|
|
3654
|
+
|
|
3655
|
+
// src/components/dieline/bags-pillows/becf-12109/generate.ts
|
|
3656
|
+
var DIP2 = 13;
|
|
3657
|
+
var ROPE_R2 = 3;
|
|
3658
|
+
var ROPE_Y2 = 20;
|
|
3659
|
+
var D_MAX2 = 40;
|
|
3660
|
+
var NOTCH_X = 3;
|
|
3661
|
+
var NOTCH_Y = 5;
|
|
3662
|
+
function calcD2(c, b) {
|
|
3663
|
+
return Math.min(c - 2 - b / 2, D_MAX2);
|
|
3664
|
+
}
|
|
3665
|
+
function calcKulak2(b) {
|
|
3666
|
+
if (b <= 13) return b - 1;
|
|
3667
|
+
if (b <= 99) return 13;
|
|
3668
|
+
if (b <= 249) return 20;
|
|
3669
|
+
if (b <= 499) return 25;
|
|
3670
|
+
return 30;
|
|
3671
|
+
}
|
|
3672
|
+
function calcX2(a) {
|
|
3673
|
+
return a / 2;
|
|
3674
|
+
}
|
|
3675
|
+
function getAutoCalcValues2(attr) {
|
|
3676
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3677
|
+
const D = calcD2(C, B);
|
|
3678
|
+
const kulak = glueArea ?? calcKulak2(B);
|
|
3679
|
+
const X = calcX2(A);
|
|
3680
|
+
return { d: D, kulak, dip: DIP2, ropeR: ROPE_R2, ropeY: ROPE_Y2, ropeX: X };
|
|
3681
|
+
}
|
|
3682
|
+
function line6(x1, y1, x2, y2) {
|
|
3683
|
+
return `M${x1} ${y1} L${x2} ${y2}`;
|
|
3684
|
+
}
|
|
3685
|
+
function circlePath2(cx, cy, r) {
|
|
3686
|
+
return `M${cx - r} ${cy} A${r} ${r} 0 0 1 ${cx + r} ${cy} A${r} ${r} 0 0 1 ${cx - r} ${cy}`;
|
|
3687
|
+
}
|
|
3688
|
+
function generateBecf12109(attr) {
|
|
3689
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3690
|
+
const D = calcD2(C, B);
|
|
3691
|
+
const kulak = glueArea ?? calcKulak2(B);
|
|
3692
|
+
const X = calcX2(A);
|
|
3693
|
+
const xFront = kulak;
|
|
3694
|
+
const xSide1 = kulak + A;
|
|
3695
|
+
const xSide1Mid = kulak + A + B / 2;
|
|
3696
|
+
const xBack = kulak + A + B;
|
|
3697
|
+
const xSide2 = kulak + 2 * A + B;
|
|
3698
|
+
const xSide2Mid = kulak + 2 * A + B + B / 2;
|
|
3699
|
+
const xEnd = kulak + 2 * A + 2 * B - 2;
|
|
3700
|
+
const yFoldTop = D;
|
|
3701
|
+
const yFoldBottomStart = D + C - B / 2;
|
|
3702
|
+
const yFoldBottom = D + C;
|
|
3703
|
+
const yNotchStart = yFoldBottom + NOTCH_Y;
|
|
3704
|
+
const yEnd = D + C + B / 2 + DIP2;
|
|
3705
|
+
const totalWidth = xEnd;
|
|
3706
|
+
const totalHeight = yEnd;
|
|
3707
|
+
const cut = [];
|
|
3708
|
+
const crease = [];
|
|
3709
|
+
cut.push(line6(0, 0, 0, yFoldBottom - kulak));
|
|
3710
|
+
cut.push(line6(0, 0, totalWidth, 0));
|
|
3711
|
+
cut.push(line6(totalWidth, 0, totalWidth, yFoldBottom));
|
|
3712
|
+
cut.push(line6(0, yFoldBottom - kulak, kulak, yFoldBottom));
|
|
3713
|
+
const boundaries = [xFront, xSide1, xBack, xSide2, xEnd];
|
|
3714
|
+
for (let i = 0; i < boundaries.length; i++) {
|
|
3715
|
+
const xb = boundaries[i];
|
|
3716
|
+
const isFirst = i === 0;
|
|
3717
|
+
const isLast = i === boundaries.length - 1;
|
|
3718
|
+
if (!isFirst) {
|
|
3719
|
+
cut.push(line6(xb - NOTCH_X, yNotchStart, xb - NOTCH_X, totalHeight));
|
|
3720
|
+
cut.push(line6(xb - NOTCH_X, yNotchStart, xb, yFoldBottom));
|
|
3721
|
+
}
|
|
3722
|
+
if (!isLast) {
|
|
3723
|
+
cut.push(line6(xb + NOTCH_X, yNotchStart, xb + NOTCH_X, totalHeight));
|
|
3724
|
+
cut.push(line6(xb + NOTCH_X, yNotchStart, xb, yFoldBottom));
|
|
3725
|
+
}
|
|
3726
|
+
}
|
|
3727
|
+
cut.push(line6(xFront + NOTCH_X, totalHeight, xSide1 - NOTCH_X, totalHeight));
|
|
3728
|
+
cut.push(line6(xSide1 + NOTCH_X, totalHeight, xBack - NOTCH_X, totalHeight));
|
|
3729
|
+
cut.push(line6(xBack + NOTCH_X, totalHeight, xSide2 - NOTCH_X, totalHeight));
|
|
3730
|
+
cut.push(line6(xSide2 + NOTCH_X, totalHeight, xEnd - NOTCH_X, totalHeight));
|
|
3731
|
+
const frontCx = kulak + A / 2;
|
|
3732
|
+
const backCx = kulak + A + B + A / 2;
|
|
3733
|
+
const ropeTopY = yFoldTop - ROPE_Y2;
|
|
3734
|
+
const ropeBotY = yFoldTop + ROPE_Y2;
|
|
3735
|
+
cut.push(circlePath2(frontCx - X / 2, ropeTopY, ROPE_R2));
|
|
3736
|
+
cut.push(circlePath2(frontCx - X / 2, ropeBotY, ROPE_R2));
|
|
3737
|
+
cut.push(circlePath2(frontCx + X / 2, ropeTopY, ROPE_R2));
|
|
3738
|
+
cut.push(circlePath2(frontCx + X / 2, ropeBotY, ROPE_R2));
|
|
3739
|
+
cut.push(circlePath2(backCx - X / 2, ropeTopY, ROPE_R2));
|
|
3740
|
+
cut.push(circlePath2(backCx - X / 2, ropeBotY, ROPE_R2));
|
|
3741
|
+
cut.push(circlePath2(backCx + X / 2, ropeTopY, ROPE_R2));
|
|
3742
|
+
cut.push(circlePath2(backCx + X / 2, ropeBotY, ROPE_R2));
|
|
3743
|
+
crease.push(line6(0, yFoldTop, totalWidth, yFoldTop));
|
|
3744
|
+
crease.push(line6(0, yFoldBottomStart, totalWidth, yFoldBottomStart));
|
|
3745
|
+
crease.push(line6(kulak, yFoldBottom, xEnd, yFoldBottom));
|
|
3746
|
+
crease.push(line6(xFront, 0, xFront, yFoldBottom));
|
|
3747
|
+
crease.push(line6(xSide1, 0, xSide1, yFoldBottom));
|
|
3748
|
+
crease.push(line6(xBack, 0, xBack, yFoldBottom));
|
|
3749
|
+
crease.push(line6(xSide2, 0, xSide2, yFoldBottom));
|
|
3750
|
+
crease.push(line6(xSide1Mid, 0, xSide1Mid, totalHeight));
|
|
3751
|
+
crease.push(line6(xSide2Mid, 0, xSide2Mid, totalHeight));
|
|
3752
|
+
crease.push(line6(xBack, yFoldBottom, xSide1Mid, yFoldBottomStart));
|
|
3753
|
+
crease.push(line6(xSide1Mid, yFoldBottomStart, xSide1, yFoldBottom));
|
|
3754
|
+
crease.push(line6(xSide2Mid, yFoldBottomStart, xSide2, yFoldBottom));
|
|
3755
|
+
crease.push(line6(xSide2Mid, yFoldBottomStart, xEnd, D + C - 2));
|
|
3756
|
+
return { cut, crease, viewBox: { width: totalWidth, height: totalHeight } };
|
|
3757
|
+
}
|
|
3758
|
+
function generateDimensions6(attr, unit) {
|
|
3759
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3760
|
+
const D = calcD2(C, B);
|
|
3761
|
+
const kulak = glueArea ?? calcKulak2(B);
|
|
3762
|
+
const factor = unit === "cm" ? 0.1 : unit === "in" ? 1 / 25.4 : 1;
|
|
3763
|
+
const suffix = unit;
|
|
3764
|
+
const fmt = (v) => `${(v * factor).toFixed(2)} ${suffix}`;
|
|
3765
|
+
const xFront = kulak;
|
|
3766
|
+
const xSide1 = kulak + A;
|
|
3767
|
+
const xBack = kulak + A + B;
|
|
3768
|
+
const yFoldTop = D;
|
|
3769
|
+
const yFoldBottom = D + C;
|
|
3770
|
+
const yEnd = D + C + B / 2 + DIP2;
|
|
3771
|
+
const totalWidth = kulak + 2 * A + 2 * B - 2;
|
|
3772
|
+
const totalHeight = yEnd;
|
|
3773
|
+
const bottomSection = B / 2 + DIP2;
|
|
3774
|
+
return [
|
|
3775
|
+
// Overall dimensions (outside)
|
|
3776
|
+
{
|
|
3777
|
+
x1: 0,
|
|
3778
|
+
y1: 0,
|
|
3779
|
+
x2: totalWidth,
|
|
3780
|
+
y2: 0,
|
|
3781
|
+
label: `Overall Width : ${fmt(totalWidth)}`,
|
|
3782
|
+
orientation: "horizontal",
|
|
3783
|
+
offset: -12
|
|
3784
|
+
},
|
|
3785
|
+
{
|
|
3786
|
+
x1: 0,
|
|
3787
|
+
y1: 0,
|
|
3788
|
+
x2: 0,
|
|
3789
|
+
y2: totalHeight,
|
|
3790
|
+
label: `Overall Height : ${fmt(totalHeight)}`,
|
|
3791
|
+
orientation: "vertical",
|
|
3792
|
+
offset: -12
|
|
3793
|
+
},
|
|
3794
|
+
// Height (C) — body area (centered on back panel)
|
|
3795
|
+
{
|
|
3796
|
+
x1: xBack + A * 0.6,
|
|
3797
|
+
y1: yFoldTop,
|
|
3798
|
+
x2: xBack + A * 0.6,
|
|
3799
|
+
y2: yFoldBottom,
|
|
3800
|
+
label: fmt(C),
|
|
3801
|
+
orientation: "vertical",
|
|
3802
|
+
offset: -10
|
|
3803
|
+
},
|
|
3804
|
+
// Top flap (D) (centered on back panel)
|
|
3805
|
+
{
|
|
3806
|
+
x1: xBack + A * 0.6,
|
|
3807
|
+
y1: 0,
|
|
3808
|
+
x2: xBack + A * 0.6,
|
|
3809
|
+
y2: yFoldTop,
|
|
3810
|
+
label: fmt(D),
|
|
3811
|
+
orientation: "vertical",
|
|
3812
|
+
offset: -10
|
|
3813
|
+
},
|
|
3814
|
+
// Bottom section (B/2 + _dip) (centered on back panel)
|
|
3815
|
+
{
|
|
3816
|
+
x1: xBack + A * 0.6,
|
|
3817
|
+
y1: yFoldBottom,
|
|
3818
|
+
x2: xBack + A * 0.6,
|
|
3819
|
+
y2: yEnd,
|
|
3820
|
+
label: fmt(bottomSection),
|
|
3821
|
+
orientation: "vertical",
|
|
3822
|
+
offset: -10
|
|
3823
|
+
},
|
|
3824
|
+
// Length (A) — front panel (centered vertically on body)
|
|
3825
|
+
{
|
|
3826
|
+
x1: xFront,
|
|
3827
|
+
y1: yFoldTop + C * 0.65,
|
|
3828
|
+
x2: xSide1,
|
|
3829
|
+
y2: yFoldTop + C * 0.65,
|
|
3830
|
+
label: fmt(A),
|
|
3831
|
+
orientation: "horizontal",
|
|
3832
|
+
offset: -20
|
|
3833
|
+
},
|
|
3834
|
+
// Width (B) — side panel (centered vertically on body)
|
|
3835
|
+
{
|
|
3836
|
+
x1: xSide1,
|
|
3837
|
+
y1: yFoldTop + C * 0.65,
|
|
3838
|
+
x2: xBack,
|
|
3839
|
+
y2: yFoldTop + C * 0.65,
|
|
3840
|
+
label: fmt(B),
|
|
3841
|
+
orientation: "horizontal",
|
|
3842
|
+
offset: -20
|
|
3843
|
+
},
|
|
3844
|
+
// Glue Area (kulak) — left glue flap width
|
|
3845
|
+
{
|
|
3846
|
+
x1: 0,
|
|
3847
|
+
y1: yFoldTop + C * 0.65,
|
|
3848
|
+
x2: xFront,
|
|
3849
|
+
y2: yFoldTop + C * 0.65,
|
|
3850
|
+
label: fmt(kulak),
|
|
3851
|
+
orientation: "horizontal",
|
|
3852
|
+
offset: -20
|
|
3853
|
+
}
|
|
3854
|
+
];
|
|
3855
|
+
}
|
|
3856
|
+
var MODEL_ID6 = "BECF-12109";
|
|
3857
|
+
var UNIT_FACTOR6 = {
|
|
3858
|
+
mm: 1,
|
|
3859
|
+
cm: 0.1,
|
|
3860
|
+
in: 1 / 25.4
|
|
3861
|
+
};
|
|
3862
|
+
var PX_PER_MM6 = 96 / 25.4;
|
|
3863
|
+
function renderDimension6(dim, i, fs) {
|
|
3864
|
+
const { x1, y1, x2, y2, label, orientation, offset } = dim;
|
|
3865
|
+
const tick = 1.5;
|
|
3866
|
+
if (orientation === "horizontal") {
|
|
3867
|
+
const y = y1 + offset;
|
|
3868
|
+
const midX = (x1 + x2) / 2;
|
|
3869
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
3870
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y, x2, y2: y, stroke: "#000", strokeWidth: 0.2 }),
|
|
3871
|
+
/* @__PURE__ */ jsx("line", { x1, y1: y - tick, x2: x1, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
3872
|
+
/* @__PURE__ */ jsx("line", { x1: x2, y1: y - tick, x2, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
|
|
3873
|
+
/* @__PURE__ */ jsx(
|
|
3874
|
+
"text",
|
|
3875
|
+
{
|
|
3876
|
+
x: midX,
|
|
3877
|
+
y: y - 1.5,
|
|
3878
|
+
textAnchor: "middle",
|
|
3879
|
+
fontSize: fs,
|
|
3880
|
+
fontFamily: "sans-serif",
|
|
3881
|
+
fill: "#000",
|
|
3882
|
+
children: label
|
|
3883
|
+
}
|
|
3884
|
+
)
|
|
3885
|
+
] }, `dim-${i}`);
|
|
3886
|
+
}
|
|
3887
|
+
const x = x1 + offset;
|
|
3888
|
+
const midY = (y1 + y2) / 2;
|
|
3889
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
3890
|
+
/* @__PURE__ */ jsx("line", { x1: x, y1, x2: x, y2, stroke: "#000", strokeWidth: 0.2 }),
|
|
3891
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1, x2: x + tick, y2: y1, stroke: "#000", strokeWidth: 0.3 }),
|
|
3892
|
+
/* @__PURE__ */ jsx("line", { x1: x - tick, y1: y2, x2: x + tick, y2, stroke: "#000", strokeWidth: 0.3 }),
|
|
3893
|
+
/* @__PURE__ */ jsx(
|
|
3894
|
+
"text",
|
|
3895
|
+
{
|
|
3896
|
+
x: x - 1.5,
|
|
3897
|
+
y: midY - 1,
|
|
3898
|
+
textAnchor: "middle",
|
|
3899
|
+
dominantBaseline: "central",
|
|
3900
|
+
fontSize: fs,
|
|
3901
|
+
fontFamily: "sans-serif",
|
|
3902
|
+
fill: "#000",
|
|
3903
|
+
transform: `rotate(-90, ${x - 1.5}, ${midY})`,
|
|
3904
|
+
children: label
|
|
3905
|
+
}
|
|
3906
|
+
)
|
|
3907
|
+
] }, `dim-${i}`);
|
|
3908
|
+
}
|
|
3909
|
+
var DIE_LINE_BECF_12109 = forwardRef(
|
|
3910
|
+
({
|
|
3911
|
+
attributes,
|
|
3912
|
+
unit = "mm",
|
|
3913
|
+
isShowDimensions = false,
|
|
3914
|
+
renderAs = "svg"
|
|
3915
|
+
}, ref) => {
|
|
3916
|
+
const theme = useMemo(
|
|
3917
|
+
() => getModelTheme(),
|
|
3918
|
+
[]
|
|
3919
|
+
);
|
|
3920
|
+
const svgRef = useRef(null);
|
|
3921
|
+
const dieline = useMemo(() => generateBecf12109(attributes), [attributes]);
|
|
3922
|
+
const dimensions = useMemo(
|
|
3923
|
+
() => generateDimensions6(attributes, unit),
|
|
3924
|
+
[attributes, unit]
|
|
3925
|
+
);
|
|
3926
|
+
const factor = UNIT_FACTOR6[unit] ?? 1;
|
|
3927
|
+
const serializeSvg = useCallback(
|
|
3928
|
+
(showDimensions) => {
|
|
3929
|
+
const svg = svgRef.current;
|
|
3930
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
3931
|
+
const clone = svg.cloneNode(true);
|
|
3932
|
+
if (!showDimensions) {
|
|
3933
|
+
const dimGroup = clone.querySelector("#dimensions");
|
|
3934
|
+
dimGroup?.remove();
|
|
3935
|
+
}
|
|
3936
|
+
return new XMLSerializer().serializeToString(clone);
|
|
3937
|
+
},
|
|
3938
|
+
[]
|
|
3939
|
+
);
|
|
3940
|
+
useImperativeHandle(
|
|
3941
|
+
ref,
|
|
3942
|
+
() => {
|
|
3943
|
+
const auto = getAutoCalcValues2(attributes);
|
|
3944
|
+
return {
|
|
3945
|
+
getAttributes: () => ({
|
|
3946
|
+
modelId: MODEL_ID6,
|
|
3947
|
+
overallWidth: dieline.viewBox.width * factor,
|
|
3948
|
+
overallHeight: dieline.viewBox.height * factor,
|
|
3949
|
+
length: attributes.length * factor,
|
|
3950
|
+
width: attributes.width * factor,
|
|
3951
|
+
height: attributes.height * factor,
|
|
3952
|
+
glueArea: auto.kulak * factor,
|
|
3953
|
+
d: auto.d * factor,
|
|
3954
|
+
kulak: auto.kulak * factor,
|
|
3955
|
+
dip: auto.dip * factor,
|
|
3956
|
+
ropeR: auto.ropeR * factor,
|
|
3957
|
+
ropeY: auto.ropeY * factor,
|
|
3958
|
+
ropeX: auto.ropeX * factor
|
|
3959
|
+
}),
|
|
3960
|
+
exportImage: async (options) => {
|
|
3961
|
+
const svgStr = serializeSvg(options.isShowDimension);
|
|
3962
|
+
const blob = new Blob([svgStr], {
|
|
3963
|
+
type: "image/svg+xml;charset=utf-8"
|
|
3964
|
+
});
|
|
3965
|
+
const url = URL.createObjectURL(blob);
|
|
3966
|
+
const img = new Image();
|
|
3967
|
+
await new Promise((resolve, reject) => {
|
|
3968
|
+
img.onload = () => resolve();
|
|
3969
|
+
img.onerror = reject;
|
|
3970
|
+
img.src = url;
|
|
3971
|
+
});
|
|
3972
|
+
const canvas = document.createElement("canvas");
|
|
3973
|
+
if (options.originalSize) {
|
|
3974
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM6);
|
|
3975
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM6);
|
|
3976
|
+
} else {
|
|
3977
|
+
canvas.width = 1920;
|
|
3978
|
+
canvas.height = 1080;
|
|
3979
|
+
}
|
|
3980
|
+
const ctx = canvas.getContext("2d");
|
|
3981
|
+
ctx.fillStyle = "#ffffff";
|
|
3982
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
3983
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
3984
|
+
URL.revokeObjectURL(url);
|
|
3985
|
+
return new Promise((resolve, reject) => {
|
|
3986
|
+
canvas.toBlob(
|
|
3987
|
+
(b) => b ? resolve(b) : reject(new Error("Export failed")),
|
|
3988
|
+
"image/png"
|
|
3989
|
+
);
|
|
3990
|
+
});
|
|
3991
|
+
},
|
|
3992
|
+
exportDimension: async () => {
|
|
3993
|
+
const dimData = generateDimensions6(attributes, unit);
|
|
3994
|
+
return exportDimensionPdf({
|
|
3995
|
+
modelId: MODEL_ID6,
|
|
3996
|
+
dieline,
|
|
3997
|
+
dimensions: dimData,
|
|
3998
|
+
attributes,
|
|
3999
|
+
unit,
|
|
4000
|
+
factor,
|
|
4001
|
+
theme
|
|
4002
|
+
});
|
|
4003
|
+
}
|
|
4004
|
+
};
|
|
4005
|
+
},
|
|
4006
|
+
[attributes, dieline, factor, unit, serializeSvg, theme]
|
|
4007
|
+
);
|
|
4008
|
+
const padding = isShowDimensions ? 15 : 0;
|
|
4009
|
+
const vbX = -padding;
|
|
4010
|
+
const vbY = -padding;
|
|
4011
|
+
const vbW = dieline.viewBox.width + padding * 2;
|
|
4012
|
+
const vbH = dieline.viewBox.height + padding * 2;
|
|
4013
|
+
const svgChildren = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4014
|
+
/* @__PURE__ */ jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
|
|
4015
|
+
/* @__PURE__ */ jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
|
|
4016
|
+
isShowDimensions && /* @__PURE__ */ jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension6(d, i, getFontDimensionSize())) })
|
|
4017
|
+
] });
|
|
4018
|
+
if (renderAs === "group") {
|
|
4019
|
+
return /* @__PURE__ */ jsx("g", { children: svgChildren });
|
|
4020
|
+
}
|
|
4021
|
+
return /* @__PURE__ */ jsx(
|
|
4022
|
+
"svg",
|
|
4023
|
+
{
|
|
4024
|
+
ref: svgRef,
|
|
4025
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
4026
|
+
viewBox: `${vbX} ${vbY} ${vbW} ${vbH}`,
|
|
4027
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
4028
|
+
style: { backgroundColor: theme.colorBackground },
|
|
4029
|
+
children: svgChildren
|
|
4030
|
+
}
|
|
4031
|
+
);
|
|
4032
|
+
}
|
|
4033
|
+
);
|
|
4034
|
+
var CANVAS_BECF_12109 = forwardRef(
|
|
4035
|
+
(props, ref) => {
|
|
4036
|
+
const dieLineRef = useRef(null);
|
|
4037
|
+
const canvasRef = useRef(null);
|
|
4038
|
+
const {
|
|
4039
|
+
attributes
|
|
4040
|
+
} = props;
|
|
4041
|
+
const theme = useMemo(
|
|
4042
|
+
() => getModelTheme(),
|
|
4043
|
+
[]
|
|
4044
|
+
);
|
|
4045
|
+
const dieline = useMemo(() => generateBecf12109(attributes), [attributes]);
|
|
4046
|
+
const stablePadding = 15;
|
|
4047
|
+
const viewBox = useMemo(
|
|
4048
|
+
() => ({
|
|
4049
|
+
x: -stablePadding,
|
|
4050
|
+
y: -stablePadding,
|
|
4051
|
+
width: dieline.viewBox.width + stablePadding * 2,
|
|
4052
|
+
height: dieline.viewBox.height + stablePadding * 2
|
|
4053
|
+
}),
|
|
4054
|
+
[dieline.viewBox.width, dieline.viewBox.height]
|
|
4055
|
+
);
|
|
4056
|
+
const serializeCanvasSvg = useCallback((showDimensions) => {
|
|
4057
|
+
const svg = canvasRef.current?.getSvgElement();
|
|
4058
|
+
if (!svg) throw new Error("SVG not mounted");
|
|
4059
|
+
const clone = svg.cloneNode(true);
|
|
4060
|
+
if (!showDimensions) {
|
|
4061
|
+
const dimGroup = clone.querySelector("#dimensions");
|
|
4062
|
+
dimGroup?.remove();
|
|
4063
|
+
}
|
|
4064
|
+
return new XMLSerializer().serializeToString(clone);
|
|
4065
|
+
}, []);
|
|
4066
|
+
useImperativeHandle(ref, () => ({
|
|
4067
|
+
getAttributes: () => dieLineRef.current.getAttributes(),
|
|
4068
|
+
exportImage: async (options) => {
|
|
4069
|
+
const svgStr = serializeCanvasSvg(options.isShowDimension);
|
|
4070
|
+
const blob = new Blob([svgStr], { type: "image/svg+xml;charset=utf-8" });
|
|
4071
|
+
const url = URL.createObjectURL(blob);
|
|
4072
|
+
const img = new Image();
|
|
4073
|
+
await new Promise((resolve, reject) => {
|
|
4074
|
+
img.onload = () => resolve();
|
|
4075
|
+
img.onerror = reject;
|
|
4076
|
+
img.src = url;
|
|
4077
|
+
});
|
|
4078
|
+
const canvas = document.createElement("canvas");
|
|
4079
|
+
if (options.originalSize) {
|
|
4080
|
+
canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM6);
|
|
4081
|
+
canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM6);
|
|
4082
|
+
} else {
|
|
4083
|
+
canvas.width = 1920;
|
|
4084
|
+
canvas.height = 1080;
|
|
4085
|
+
}
|
|
4086
|
+
const ctx = canvas.getContext("2d");
|
|
4087
|
+
ctx.fillStyle = "#ffffff";
|
|
4088
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
4089
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
4090
|
+
URL.revokeObjectURL(url);
|
|
4091
|
+
return new Promise((resolve, reject) => {
|
|
4092
|
+
canvas.toBlob(
|
|
4093
|
+
(b) => b ? resolve(b) : reject(new Error("Export failed")),
|
|
4094
|
+
"image/png"
|
|
4095
|
+
);
|
|
4096
|
+
});
|
|
4097
|
+
},
|
|
4098
|
+
exportDimension: () => dieLineRef.current.exportDimension(),
|
|
4099
|
+
resetView: () => canvasRef.current?.resetView(),
|
|
4100
|
+
fitView: () => canvasRef.current?.fitView()
|
|
4101
|
+
}), [serializeCanvasSvg, dieline.viewBox.width, dieline.viewBox.height]);
|
|
4102
|
+
return /* @__PURE__ */ jsx(
|
|
4103
|
+
BaseCanvas,
|
|
4104
|
+
{
|
|
4105
|
+
ref: canvasRef,
|
|
4106
|
+
viewBox,
|
|
4107
|
+
backgroundColor: theme.colorBackground,
|
|
4108
|
+
children: /* @__PURE__ */ jsx(DIE_LINE_BECF_12109, { ref: dieLineRef, ...props, renderAs: "group" })
|
|
4109
|
+
}
|
|
4110
|
+
);
|
|
4111
|
+
}
|
|
4112
|
+
);
|
|
4113
|
+
var MODEL_BECF_12109 = forwardRef(
|
|
4114
|
+
({ mode = "DIE_LINE", ...props }, ref) => {
|
|
4115
|
+
return /* @__PURE__ */ jsx(Fragment, { children: (() => {
|
|
4116
|
+
switch (mode) {
|
|
4117
|
+
case "DIE_LINE":
|
|
4118
|
+
return /* @__PURE__ */ jsx(CANVAS_BECF_12109, { ref, ...props });
|
|
4119
|
+
case "3D":
|
|
4120
|
+
return null;
|
|
4121
|
+
case "AUTO_LAYOUT":
|
|
4122
|
+
return /* @__PURE__ */ jsx(DIE_LINE_BECF_12109, { ref, ...props });
|
|
4123
|
+
default:
|
|
4124
|
+
return null;
|
|
4125
|
+
}
|
|
4126
|
+
})() });
|
|
4127
|
+
}
|
|
4128
|
+
);
|
|
4129
|
+
|
|
4130
|
+
// src/utils/autoLayout/rasterize.ts
|
|
4131
|
+
function rasterizePolygon(points, resolution) {
|
|
4132
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
4133
|
+
for (const p of points) {
|
|
4134
|
+
if (p.x < minX) minX = p.x;
|
|
4135
|
+
if (p.y < minY) minY = p.y;
|
|
4136
|
+
if (p.x > maxX) maxX = p.x;
|
|
4137
|
+
if (p.y > maxY) maxY = p.y;
|
|
4138
|
+
}
|
|
4139
|
+
const offsetX = Math.floor(minX / resolution);
|
|
4140
|
+
const offsetY = Math.floor(minY / resolution);
|
|
4141
|
+
const w = Math.ceil((maxX - offsetX * resolution) / resolution) + 1;
|
|
4142
|
+
const h = Math.ceil((maxY - offsetY * resolution) / resolution) + 1;
|
|
4143
|
+
const data = new Uint8Array(w * h);
|
|
4144
|
+
for (let gy = 0; gy < h; gy++) {
|
|
4145
|
+
const worldY = (offsetY + gy) * resolution + resolution / 2;
|
|
4146
|
+
const crossings = [];
|
|
4147
|
+
for (let i = 0, j = points.length - 1; i < points.length; j = i++) {
|
|
4148
|
+
const yi = points[i].y, yj = points[j].y;
|
|
4149
|
+
if (yi <= worldY && yj > worldY || yj <= worldY && yi > worldY) {
|
|
4150
|
+
const t = (worldY - yi) / (yj - yi);
|
|
4151
|
+
crossings.push(points[i].x + t * (points[j].x - points[i].x));
|
|
4152
|
+
}
|
|
4153
|
+
}
|
|
4154
|
+
crossings.sort((a, b) => a - b);
|
|
4155
|
+
for (let c = 0; c < crossings.length - 1; c += 2) {
|
|
4156
|
+
const startGx = Math.max(0, Math.floor((crossings[c] - offsetX * resolution) / resolution));
|
|
4157
|
+
const endGx = Math.min(w - 1, Math.ceil((crossings[c + 1] - offsetX * resolution) / resolution));
|
|
4158
|
+
for (let gx = startGx; gx <= endGx; gx++) {
|
|
4159
|
+
data[gy * w + gx] = 1;
|
|
4160
|
+
}
|
|
4161
|
+
}
|
|
4162
|
+
}
|
|
4163
|
+
return { data, width: w, height: h, offsetX, offsetY };
|
|
4164
|
+
}
|
|
4165
|
+
function canPlace(paperGrid, paperW, paperH, piece, px, py) {
|
|
4166
|
+
for (let y = 0; y < piece.height; y++) {
|
|
4167
|
+
const paperY = py + y;
|
|
4168
|
+
if (paperY < 0 || paperY >= paperH) {
|
|
4169
|
+
for (let x = 0; x < piece.width; x++) {
|
|
4170
|
+
if (piece.data[y * piece.width + x]) return false;
|
|
4171
|
+
}
|
|
4172
|
+
continue;
|
|
4173
|
+
}
|
|
4174
|
+
for (let x = 0; x < piece.width; x++) {
|
|
4175
|
+
if (!piece.data[y * piece.width + x]) continue;
|
|
4176
|
+
const paperX = px + x;
|
|
4177
|
+
if (paperX < 0 || paperX >= paperW) return false;
|
|
4178
|
+
if (paperGrid[paperY * paperW + paperX]) return false;
|
|
4179
|
+
}
|
|
4180
|
+
}
|
|
4181
|
+
return true;
|
|
4182
|
+
}
|
|
4183
|
+
function placePiece(paperGrid, paperW, piece, px, py) {
|
|
4184
|
+
for (let y = 0; y < piece.height; y++) {
|
|
4185
|
+
for (let x = 0; x < piece.width; x++) {
|
|
4186
|
+
if (piece.data[y * piece.width + x]) {
|
|
4187
|
+
paperGrid[(py + y) * paperW + (px + x)] = 1;
|
|
4188
|
+
}
|
|
4189
|
+
}
|
|
4190
|
+
}
|
|
4191
|
+
}
|
|
4192
|
+
|
|
4193
|
+
// src/utils/autoLayout/calculate/shared.ts
|
|
4194
|
+
var RESOLUTION = 1;
|
|
4195
|
+
function resolveGripperSide(paperWidth, paperHeight) {
|
|
4196
|
+
if (paperWidth >= paperHeight) return "bottom";
|
|
4197
|
+
return "left";
|
|
4198
|
+
}
|
|
4199
|
+
function computeUsableBounds(paperWidth, paperHeight, gripperSide, spacing, griper, colorbarDepth) {
|
|
4200
|
+
switch (gripperSide) {
|
|
4201
|
+
case "bottom":
|
|
4202
|
+
return {
|
|
4203
|
+
top: colorbarDepth + spacing,
|
|
4204
|
+
bottom: paperHeight - griper,
|
|
4205
|
+
left: spacing,
|
|
4206
|
+
right: paperWidth - spacing
|
|
4207
|
+
};
|
|
4208
|
+
case "top":
|
|
4209
|
+
return {
|
|
4210
|
+
top: griper,
|
|
4211
|
+
bottom: paperHeight - colorbarDepth - spacing,
|
|
4212
|
+
left: spacing,
|
|
4213
|
+
right: paperWidth - spacing
|
|
4214
|
+
};
|
|
4215
|
+
case "left":
|
|
4216
|
+
return {
|
|
4217
|
+
top: spacing,
|
|
4218
|
+
bottom: paperHeight - spacing,
|
|
4219
|
+
left: griper,
|
|
4220
|
+
right: paperWidth - colorbarDepth - spacing
|
|
4221
|
+
};
|
|
4222
|
+
case "right":
|
|
4223
|
+
return {
|
|
4224
|
+
top: spacing,
|
|
4225
|
+
bottom: paperHeight - spacing,
|
|
4226
|
+
left: colorbarDepth + spacing,
|
|
4227
|
+
right: paperWidth - griper
|
|
4228
|
+
};
|
|
4229
|
+
}
|
|
4230
|
+
}
|
|
4231
|
+
function normalizePoints(points, degrees) {
|
|
4232
|
+
const rad = degrees * Math.PI / 180;
|
|
4233
|
+
const cos = Math.cos(rad);
|
|
4234
|
+
const sin = Math.sin(rad);
|
|
4235
|
+
const rotated = points.map((p) => ({
|
|
4236
|
+
x: p.x * cos - p.y * sin,
|
|
4237
|
+
y: p.x * sin + p.y * cos
|
|
4238
|
+
}));
|
|
4239
|
+
let minX = Infinity, minY = Infinity;
|
|
4240
|
+
for (const p of rotated) {
|
|
4241
|
+
if (p.x < minX) minX = p.x;
|
|
4242
|
+
if (p.y < minY) minY = p.y;
|
|
4243
|
+
}
|
|
4244
|
+
return rotated.map((p) => ({ x: p.x - minX, y: p.y - minY }));
|
|
4245
|
+
}
|
|
4246
|
+
function computeDielineBBOffset(offsetContourPoints, dielineW, dielineH, degrees) {
|
|
4247
|
+
const rad = degrees * Math.PI / 180;
|
|
4248
|
+
const cos = Math.cos(rad);
|
|
4249
|
+
const sin = Math.sin(rad);
|
|
4250
|
+
let ocMinX = Infinity, ocMinY = Infinity;
|
|
4251
|
+
for (const p of offsetContourPoints) {
|
|
4252
|
+
const rx = p.x * cos - p.y * sin;
|
|
3256
4253
|
const ry = p.x * sin + p.y * cos;
|
|
3257
4254
|
if (rx < ocMinX) ocMinX = rx;
|
|
3258
4255
|
if (ry < ocMinY) ocMinY = ry;
|
|
@@ -3733,101 +4730,255 @@ function pairGrid2(rdA, rdB, bounds) {
|
|
|
3733
4730
|
}
|
|
3734
4731
|
const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
|
|
3735
4732
|
const gapRight = bounds.right - pairsRightEdge;
|
|
3736
|
-
for (const rdExtra of [rdA, rdB]) {
|
|
4733
|
+
for (const rdExtra of [rdA, rdB]) {
|
|
4734
|
+
const pe = rdExtra.profile;
|
|
4735
|
+
if (pe.width > gapRight) continue;
|
|
4736
|
+
const dxFromB = pairsRightEdge - (bounds.left + (pairCols - 1) * pairStepX + gapAB);
|
|
4737
|
+
const dxFromA = pairsRightEdge - bounds.left - (pairCols - 1) * pairStepX;
|
|
4738
|
+
const extraStepY = Math.max(
|
|
4739
|
+
findMinStepY(pA, pe, dxFromA),
|
|
4740
|
+
findMinStepY(pB, pe, dxFromB),
|
|
4741
|
+
findMinStepY(pe, pe, 0)
|
|
4742
|
+
);
|
|
4743
|
+
if (extraStepY <= 0) continue;
|
|
4744
|
+
const effectiveStepY = Math.max(pairStepY, extraStepY);
|
|
4745
|
+
const extraRows = Math.max(0, Math.floor((usableH - pe.height) / effectiveStepY) + 1);
|
|
4746
|
+
for (let r = 0; r < extraRows; r++) {
|
|
4747
|
+
const ox = pairsRightEdge;
|
|
4748
|
+
const oy = bounds.top + r * effectiveStepY;
|
|
4749
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
4750
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
4751
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
4752
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
4753
|
+
}
|
|
4754
|
+
}
|
|
4755
|
+
break;
|
|
4756
|
+
}
|
|
4757
|
+
const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
|
|
4758
|
+
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
4759
|
+
for (const rdExtra of [rdA, rdB]) {
|
|
4760
|
+
const pe = rdExtra.profile;
|
|
4761
|
+
if (pe.height > gapBottom) continue;
|
|
4762
|
+
const extraStepX = findMinStepX(pe, pe, 0);
|
|
4763
|
+
if (extraStepX <= 0) continue;
|
|
4764
|
+
const dyFromPairRow = pairsBottomEdge - (bounds.top + (pairRows - 1) * pairStepY);
|
|
4765
|
+
const stepFromA = findMinStepY(pA, pe, 0);
|
|
4766
|
+
const stepFromB = findMinStepY(pB, pe, gapAB);
|
|
4767
|
+
if (dyFromPairRow < stepFromA || dyFromPairRow < stepFromB) continue;
|
|
4768
|
+
const extraCols = Math.max(0, Math.floor((usableW - pe.width) / extraStepX) + 1);
|
|
4769
|
+
for (let c = 0; c < extraCols; c++) {
|
|
4770
|
+
const ox = bounds.left + c * extraStepX;
|
|
4771
|
+
const oy = pairsBottomEdge;
|
|
4772
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
4773
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
4774
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
4775
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
4776
|
+
}
|
|
4777
|
+
}
|
|
4778
|
+
break;
|
|
4779
|
+
}
|
|
4780
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
4781
|
+
}
|
|
4782
|
+
function verticalPairGrid(rdA, rdB, bounds) {
|
|
4783
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
4784
|
+
const gapAB_Y = findMinStepY(pA, pB, 0);
|
|
4785
|
+
if (gapAB_Y <= 0) return emptyResult();
|
|
4786
|
+
const vpairH = gapAB_Y + pB.height;
|
|
4787
|
+
const vpairW = Math.max(pA.width, pB.width);
|
|
4788
|
+
Math.max(pA.height, pB.height) + Math.abs(gapAB_Y);
|
|
4789
|
+
let vpairStepX = 0;
|
|
4790
|
+
{
|
|
4791
|
+
const stepXAA = findMinStepX(pA, pA, 0);
|
|
4792
|
+
const stepXAB = findMinStepX(pA, pB, -gapAB_Y);
|
|
4793
|
+
const stepXBA = findMinStepX(pB, pA, gapAB_Y);
|
|
4794
|
+
const stepXBB = findMinStepX(pB, pB, 0);
|
|
4795
|
+
vpairStepX = Math.max(stepXAA, stepXAB, stepXBA, stepXBB);
|
|
4796
|
+
}
|
|
4797
|
+
if (vpairStepX <= 0) return emptyResult();
|
|
4798
|
+
const vpairStepY = gapAB_Y + findMinStepY(pB, pA, 0);
|
|
4799
|
+
if (vpairStepY <= 0) return emptyResult();
|
|
4800
|
+
const usableW = bounds.right - bounds.left;
|
|
4801
|
+
const usableH = bounds.bottom - bounds.top;
|
|
4802
|
+
const cols = Math.max(0, Math.floor((usableW - vpairW) / vpairStepX) + 1);
|
|
4803
|
+
const rows = Math.max(0, Math.floor((usableH - vpairH) / vpairStepY) + 1);
|
|
4804
|
+
if (cols === 0 || rows === 0) return emptyResult();
|
|
4805
|
+
const placements = [];
|
|
4806
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
4807
|
+
for (let r = 0; r < rows; r++) {
|
|
4808
|
+
for (let c = 0; c < cols; c++) {
|
|
4809
|
+
const baseX = bounds.left + c * vpairStepX;
|
|
4810
|
+
const baseY = bounds.top + r * vpairStepY;
|
|
4811
|
+
placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
4812
|
+
if (baseX < minX) minX = baseX;
|
|
4813
|
+
if (baseY < minY) minY = baseY;
|
|
4814
|
+
if (baseX + pA.width > maxX) maxX = baseX + pA.width;
|
|
4815
|
+
if (baseY + pA.height > maxY) maxY = baseY + pA.height;
|
|
4816
|
+
const by = baseY + gapAB_Y;
|
|
4817
|
+
placements.push({ x: baseX + rdB.bbOffset.dx, y: by + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
4818
|
+
if (by + pB.height > maxY) maxY = by + pB.height;
|
|
4819
|
+
}
|
|
4820
|
+
}
|
|
4821
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
4822
|
+
}
|
|
4823
|
+
function computeLayoutForPaper3(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
4824
|
+
const rots = [0, 90, 180, 270];
|
|
4825
|
+
const rd = /* @__PURE__ */ new Map();
|
|
4826
|
+
for (const deg of rots) {
|
|
4827
|
+
rd.set(deg, prepareRotation3(contourPoints, dielineW, dielineH, deg));
|
|
4828
|
+
}
|
|
4829
|
+
const results = [];
|
|
4830
|
+
for (const deg of rots) {
|
|
4831
|
+
results.push(singleRotGrid(rd.get(deg), bounds));
|
|
4832
|
+
}
|
|
4833
|
+
const allPairs = [
|
|
4834
|
+
[0, 180],
|
|
4835
|
+
[90, 270],
|
|
4836
|
+
[0, 90],
|
|
4837
|
+
[0, 270],
|
|
4838
|
+
[90, 180],
|
|
4839
|
+
[180, 270]
|
|
4840
|
+
];
|
|
4841
|
+
for (const [a, b] of allPairs) {
|
|
4842
|
+
const rdA = rd.get(a), rdB = rd.get(b);
|
|
4843
|
+
const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
|
|
4844
|
+
if (stepA <= 0) continue;
|
|
4845
|
+
for (let off = 0; off < stepA; off += 1) {
|
|
4846
|
+
results.push(dualRotGrid(rdA, rdB, off, bounds));
|
|
4847
|
+
results.push(dualRotGrid(rdB, rdA, off, bounds));
|
|
4848
|
+
}
|
|
4849
|
+
}
|
|
4850
|
+
for (const [a, b] of allPairs) {
|
|
4851
|
+
results.push(pairGrid2(rd.get(a), rd.get(b), bounds));
|
|
4852
|
+
results.push(pairGrid2(rd.get(b), rd.get(a), bounds));
|
|
4853
|
+
}
|
|
4854
|
+
for (const [a, b] of allPairs) {
|
|
4855
|
+
results.push(verticalPairGrid(rd.get(a), rd.get(b), bounds));
|
|
4856
|
+
results.push(verticalPairGrid(rd.get(b), rd.get(a), bounds));
|
|
4857
|
+
}
|
|
4858
|
+
const singleResults = [];
|
|
4859
|
+
const multiResults = [];
|
|
4860
|
+
for (const r of results) {
|
|
4861
|
+
if (r.count === 0) continue;
|
|
4862
|
+
const rotations = new Set(r.placements.map((p) => p.rotation));
|
|
4863
|
+
if (rotations.size > 1) {
|
|
4864
|
+
multiResults.push(r);
|
|
4865
|
+
} else {
|
|
4866
|
+
singleResults.push(r);
|
|
4867
|
+
}
|
|
4868
|
+
}
|
|
4869
|
+
function pickBest(arr) {
|
|
4870
|
+
let b = arr[0] ?? emptyResult();
|
|
4871
|
+
let bArea = (b.maxX - b.minX) * (b.maxY - b.minY);
|
|
4872
|
+
for (const r of arr) {
|
|
4873
|
+
const area = (r.maxX - r.minX) * (r.maxY - r.minY);
|
|
4874
|
+
if (r.count > b.count || r.count === b.count && area < bArea) {
|
|
4875
|
+
b = r;
|
|
4876
|
+
bArea = area;
|
|
4877
|
+
}
|
|
4878
|
+
}
|
|
4879
|
+
return b;
|
|
4880
|
+
}
|
|
4881
|
+
const bestSingle = pickBest(singleResults);
|
|
4882
|
+
const bestMulti = pickBest(multiResults);
|
|
4883
|
+
const best = bestMulti.count >= bestSingle.count && bestMulti.count > 0 ? bestMulti : bestSingle;
|
|
4884
|
+
centerLayout(best, bounds);
|
|
4885
|
+
return {
|
|
4886
|
+
rotation: best.placements[0]?.rotation ?? 0,
|
|
4887
|
+
placements: best.placements,
|
|
4888
|
+
producedPerSheet: best.count
|
|
4889
|
+
};
|
|
4890
|
+
}
|
|
4891
|
+
|
|
4892
|
+
// src/utils/autoLayout/calculate/bags-pillows/becf-12101/index.ts
|
|
4893
|
+
function prepareRotation4(contourPoints, dielineW, dielineH, deg) {
|
|
4894
|
+
const rotated = normalizePoints(contourPoints, deg);
|
|
4895
|
+
return {
|
|
4896
|
+
profile: buildProfile(rotated),
|
|
4897
|
+
bbOffset: computeDielineBBOffset(contourPoints, dielineW, dielineH, deg),
|
|
4898
|
+
deg
|
|
4899
|
+
};
|
|
4900
|
+
}
|
|
4901
|
+
function pairGrid3(rdA, rdB, bounds) {
|
|
4902
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
4903
|
+
const gapAB = findMinStepX(pA, pB, 0);
|
|
4904
|
+
if (gapAB <= 0) return emptyResult();
|
|
4905
|
+
const pairW = gapAB + pB.width;
|
|
4906
|
+
const pairH = Math.max(pA.height, pB.height);
|
|
4907
|
+
const pairStepX = gapAB + findMinStepX(pB, pA, 0);
|
|
4908
|
+
const pairStepY = Math.max(
|
|
4909
|
+
findMinStepY(pA, pA, 0),
|
|
4910
|
+
findMinStepY(pA, pB, gapAB),
|
|
4911
|
+
findMinStepY(pB, pA, -gapAB),
|
|
4912
|
+
findMinStepY(pB, pB, 0)
|
|
4913
|
+
);
|
|
4914
|
+
if (pairStepX <= 0 || pairStepY <= 0) return emptyResult();
|
|
4915
|
+
const usableW = bounds.right - bounds.left;
|
|
4916
|
+
const usableH = bounds.bottom - bounds.top;
|
|
4917
|
+
const pairCols = Math.max(0, Math.floor((usableW - pairW) / pairStepX) + 1);
|
|
4918
|
+
const pairRows = Math.max(0, Math.floor((usableH - pairH) / pairStepY) + 1);
|
|
4919
|
+
if (pairCols === 0 || pairRows === 0) return emptyResult();
|
|
4920
|
+
const placements = [];
|
|
4921
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
4922
|
+
for (let r = 0; r < pairRows; r++) {
|
|
4923
|
+
for (let c = 0; c < pairCols; c++) {
|
|
4924
|
+
const baseX = bounds.left + c * pairStepX;
|
|
4925
|
+
const baseY = bounds.top + r * pairStepY;
|
|
4926
|
+
const oxA = baseX;
|
|
4927
|
+
const oyA = baseY;
|
|
4928
|
+
placements.push({ x: oxA + rdA.bbOffset.dx, y: oyA + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
4929
|
+
if (oxA < minX) minX = oxA;
|
|
4930
|
+
if (oyA < minY) minY = oyA;
|
|
4931
|
+
if (oxA + pA.width > maxX) maxX = oxA + pA.width;
|
|
4932
|
+
if (oyA + pA.height > maxY) maxY = oyA + pA.height;
|
|
4933
|
+
const oxB = baseX + gapAB;
|
|
4934
|
+
const oyB = baseY;
|
|
4935
|
+
placements.push({ x: oxB + rdB.bbOffset.dx, y: oyB + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
4936
|
+
if (oxB < minX) minX = oxB;
|
|
4937
|
+
if (oyB < minY) minY = oyB;
|
|
4938
|
+
if (oxB + pB.width > maxX) maxX = oxB + pB.width;
|
|
4939
|
+
if (oyB + pB.height > maxY) maxY = oyB + pB.height;
|
|
4940
|
+
}
|
|
4941
|
+
}
|
|
4942
|
+
const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
|
|
4943
|
+
const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
|
|
4944
|
+
const gapRight = bounds.right - pairsRightEdge;
|
|
4945
|
+
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
4946
|
+
const extraRotations = [rdA, rdB];
|
|
4947
|
+
for (const rdExtra of extraRotations) {
|
|
3737
4948
|
const pe = rdExtra.profile;
|
|
3738
|
-
if (pe.width
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
if (extraStepY <= 0) continue;
|
|
3747
|
-
const effectiveStepY = Math.max(pairStepY, extraStepY);
|
|
3748
|
-
const extraRows = Math.max(0, Math.floor((usableH - pe.height) / effectiveStepY) + 1);
|
|
3749
|
-
for (let r = 0; r < extraRows; r++) {
|
|
3750
|
-
const ox = pairsRightEdge;
|
|
3751
|
-
const oy = bounds.top + r * effectiveStepY;
|
|
3752
|
-
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
3753
|
-
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
3754
|
-
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
3755
|
-
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
4949
|
+
if (pe.width <= gapRight) {
|
|
4950
|
+
for (let r = 0; r < pairRows; r++) {
|
|
4951
|
+
const ox = pairsRightEdge;
|
|
4952
|
+
const oy = bounds.top + r * pairStepY;
|
|
4953
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
4954
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
4955
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
4956
|
+
}
|
|
3756
4957
|
}
|
|
4958
|
+
break;
|
|
3757
4959
|
}
|
|
3758
|
-
break;
|
|
3759
4960
|
}
|
|
3760
|
-
const
|
|
3761
|
-
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
3762
|
-
for (const rdExtra of [rdA, rdB]) {
|
|
4961
|
+
for (const rdExtra of extraRotations) {
|
|
3763
4962
|
const pe = rdExtra.profile;
|
|
3764
|
-
if (pe.height
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
for (let c = 0; c < extraCols; c++) {
|
|
3773
|
-
const ox = bounds.left + c * extraStepX;
|
|
3774
|
-
const oy = pairsBottomEdge;
|
|
3775
|
-
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
3776
|
-
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
3777
|
-
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
3778
|
-
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
4963
|
+
if (pe.height <= gapBottom) {
|
|
4964
|
+
for (let c = 0; c < pairCols; c++) {
|
|
4965
|
+
const oxA = bounds.left + c * pairStepX;
|
|
4966
|
+
const oy = pairsBottomEdge;
|
|
4967
|
+
if (oxA + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
4968
|
+
placements.push({ x: oxA + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
4969
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
4970
|
+
}
|
|
3779
4971
|
}
|
|
3780
|
-
|
|
3781
|
-
break;
|
|
3782
|
-
}
|
|
3783
|
-
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
3784
|
-
}
|
|
3785
|
-
function verticalPairGrid(rdA, rdB, bounds) {
|
|
3786
|
-
const pA = rdA.profile, pB = rdB.profile;
|
|
3787
|
-
const gapAB_Y = findMinStepY(pA, pB, 0);
|
|
3788
|
-
if (gapAB_Y <= 0) return emptyResult();
|
|
3789
|
-
const vpairH = gapAB_Y + pB.height;
|
|
3790
|
-
const vpairW = Math.max(pA.width, pB.width);
|
|
3791
|
-
Math.max(pA.height, pB.height) + Math.abs(gapAB_Y);
|
|
3792
|
-
let vpairStepX = 0;
|
|
3793
|
-
{
|
|
3794
|
-
const stepXAA = findMinStepX(pA, pA, 0);
|
|
3795
|
-
const stepXAB = findMinStepX(pA, pB, -gapAB_Y);
|
|
3796
|
-
const stepXBA = findMinStepX(pB, pA, gapAB_Y);
|
|
3797
|
-
const stepXBB = findMinStepX(pB, pB, 0);
|
|
3798
|
-
vpairStepX = Math.max(stepXAA, stepXAB, stepXBA, stepXBB);
|
|
3799
|
-
}
|
|
3800
|
-
if (vpairStepX <= 0) return emptyResult();
|
|
3801
|
-
const vpairStepY = gapAB_Y + findMinStepY(pB, pA, 0);
|
|
3802
|
-
if (vpairStepY <= 0) return emptyResult();
|
|
3803
|
-
const usableW = bounds.right - bounds.left;
|
|
3804
|
-
const usableH = bounds.bottom - bounds.top;
|
|
3805
|
-
const cols = Math.max(0, Math.floor((usableW - vpairW) / vpairStepX) + 1);
|
|
3806
|
-
const rows = Math.max(0, Math.floor((usableH - vpairH) / vpairStepY) + 1);
|
|
3807
|
-
if (cols === 0 || rows === 0) return emptyResult();
|
|
3808
|
-
const placements = [];
|
|
3809
|
-
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
3810
|
-
for (let r = 0; r < rows; r++) {
|
|
3811
|
-
for (let c = 0; c < cols; c++) {
|
|
3812
|
-
const baseX = bounds.left + c * vpairStepX;
|
|
3813
|
-
const baseY = bounds.top + r * vpairStepY;
|
|
3814
|
-
placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
3815
|
-
if (baseX < minX) minX = baseX;
|
|
3816
|
-
if (baseY < minY) minY = baseY;
|
|
3817
|
-
if (baseX + pA.width > maxX) maxX = baseX + pA.width;
|
|
3818
|
-
if (baseY + pA.height > maxY) maxY = baseY + pA.height;
|
|
3819
|
-
const by = baseY + gapAB_Y;
|
|
3820
|
-
placements.push({ x: baseX + rdB.bbOffset.dx, y: by + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
3821
|
-
if (by + pB.height > maxY) maxY = by + pB.height;
|
|
4972
|
+
break;
|
|
3822
4973
|
}
|
|
3823
4974
|
}
|
|
3824
4975
|
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
3825
4976
|
}
|
|
3826
|
-
function
|
|
4977
|
+
function computeLayoutForPaper4(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
3827
4978
|
const rots = [0, 90, 180, 270];
|
|
3828
4979
|
const rd = /* @__PURE__ */ new Map();
|
|
3829
4980
|
for (const deg of rots) {
|
|
3830
|
-
rd.set(deg,
|
|
4981
|
+
rd.set(deg, prepareRotation4(contourPoints, dielineW, dielineH, deg));
|
|
3831
4982
|
}
|
|
3832
4983
|
const results = [];
|
|
3833
4984
|
for (const deg of rots) {
|
|
@@ -3851,12 +5002,8 @@ function computeLayoutForPaper3(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
3851
5002
|
}
|
|
3852
5003
|
}
|
|
3853
5004
|
for (const [a, b] of allPairs) {
|
|
3854
|
-
results.push(
|
|
3855
|
-
results.push(
|
|
3856
|
-
}
|
|
3857
|
-
for (const [a, b] of allPairs) {
|
|
3858
|
-
results.push(verticalPairGrid(rd.get(a), rd.get(b), bounds));
|
|
3859
|
-
results.push(verticalPairGrid(rd.get(b), rd.get(a), bounds));
|
|
5005
|
+
results.push(pairGrid3(rd.get(a), rd.get(b), bounds));
|
|
5006
|
+
results.push(pairGrid3(rd.get(b), rd.get(a), bounds));
|
|
3860
5007
|
}
|
|
3861
5008
|
const singleResults = [];
|
|
3862
5009
|
const multiResults = [];
|
|
@@ -3919,6 +5066,14 @@ function resolveModelFunctions(modelId, attrs) {
|
|
|
3919
5066
|
offsetContour: offsetContour4
|
|
3920
5067
|
};
|
|
3921
5068
|
}
|
|
5069
|
+
case "BECF-12101": {
|
|
5070
|
+
const a = attrs;
|
|
5071
|
+
return {
|
|
5072
|
+
contour: generateOuterContour5(a),
|
|
5073
|
+
dieline: generateBecf12101(a),
|
|
5074
|
+
offsetContour: offsetContour5
|
|
5075
|
+
};
|
|
5076
|
+
}
|
|
3922
5077
|
case "BECF-1010A":
|
|
3923
5078
|
default: {
|
|
3924
5079
|
const a = attrs;
|
|
@@ -3938,16 +5093,26 @@ function resolveLayoutCalculator(modelId) {
|
|
|
3938
5093
|
return computeLayoutForPaper2;
|
|
3939
5094
|
case "BECF-1040A":
|
|
3940
5095
|
return computeLayoutForPaper3;
|
|
5096
|
+
case "BECF-12101":
|
|
5097
|
+
return computeLayoutForPaper4;
|
|
3941
5098
|
default:
|
|
3942
5099
|
return computeLayoutForPaperDefault;
|
|
3943
5100
|
}
|
|
3944
5101
|
}
|
|
3945
|
-
function calculateAutoLayout(
|
|
3946
|
-
const
|
|
5102
|
+
function calculateAutoLayout(rawConfig) {
|
|
5103
|
+
const config = {
|
|
5104
|
+
...rawConfig,
|
|
5105
|
+
layoutDistance: rawConfig.layoutDistance ?? 3,
|
|
5106
|
+
spacing: rawConfig.spacing ?? 5,
|
|
5107
|
+
griper: rawConfig.griper ?? 10,
|
|
5108
|
+
colorbarHeight: rawConfig.colorbarHeight ?? 5,
|
|
5109
|
+
isShowColorbar: rawConfig.isShowColorbar ?? true
|
|
5110
|
+
};
|
|
5111
|
+
const { contour, dieline, offsetContour: offsetContour6 } = resolveModelFunctions(
|
|
3947
5112
|
config.model.modelId,
|
|
3948
5113
|
config.model.attributes
|
|
3949
5114
|
);
|
|
3950
|
-
const offsetContourPoints = config.layoutDistance > 0 ?
|
|
5115
|
+
const offsetContourPoints = config.layoutDistance > 0 ? offsetContour6(contour, config.layoutDistance / 2) : contour;
|
|
3951
5116
|
const cbDepth = config.isShowColorbar ? config.colorbarHeight : 0;
|
|
3952
5117
|
const computeLayout = resolveLayoutCalculator(config.model.modelId);
|
|
3953
5118
|
const paperResults = [];
|
|
@@ -4292,6 +5457,22 @@ function renderDieLine(modelId, attrs) {
|
|
|
4292
5457
|
renderAs: "group"
|
|
4293
5458
|
}
|
|
4294
5459
|
);
|
|
5460
|
+
case "BECF-11D01":
|
|
5461
|
+
return /* @__PURE__ */ jsx(
|
|
5462
|
+
DIE_LINE_BECF_11D01,
|
|
5463
|
+
{
|
|
5464
|
+
attributes: attrs,
|
|
5465
|
+
renderAs: "group"
|
|
5466
|
+
}
|
|
5467
|
+
);
|
|
5468
|
+
case "BECF-12101":
|
|
5469
|
+
return /* @__PURE__ */ jsx(
|
|
5470
|
+
DIE_LINE_BECF_12101,
|
|
5471
|
+
{
|
|
5472
|
+
attributes: attrs,
|
|
5473
|
+
renderAs: "group"
|
|
5474
|
+
}
|
|
5475
|
+
);
|
|
4295
5476
|
case "BECF-1010A":
|
|
4296
5477
|
default:
|
|
4297
5478
|
return /* @__PURE__ */ jsx(
|
|
@@ -4341,9 +5522,9 @@ function getTransformedContour(normalizedPoints, x, y, rotation) {
|
|
|
4341
5522
|
}
|
|
4342
5523
|
return translatePolygon(rotated, x - rMinX, y - rMinY);
|
|
4343
5524
|
}
|
|
4344
|
-
function checkCollisions(items,
|
|
5525
|
+
function checkCollisions(items, shrunkContour, paperWidth, paperHeight) {
|
|
4345
5526
|
const polys = items.map(
|
|
4346
|
-
(item) => getTransformedContour(
|
|
5527
|
+
(item) => getTransformedContour(shrunkContour, item.x, item.y, item.rotation)
|
|
4347
5528
|
);
|
|
4348
5529
|
return items.map((item, i) => {
|
|
4349
5530
|
let colliding = false;
|
|
@@ -4401,7 +5582,10 @@ function ModifyLayout({
|
|
|
4401
5582
|
const [panX, setPanX] = useState(0);
|
|
4402
5583
|
const [panY, setPanY] = useState(0);
|
|
4403
5584
|
const theme = useMemo(() => getAutoLayoutTheme(), []);
|
|
4404
|
-
const
|
|
5585
|
+
const shrunkContour = useMemo(
|
|
5586
|
+
() => normalizeContour(offsetContour(offsetContourPoints, -0.15)),
|
|
5587
|
+
[offsetContourPoints]
|
|
5588
|
+
);
|
|
4405
5589
|
const pw = paperResult.paperWidth;
|
|
4406
5590
|
const ph = paperResult.paperHeight;
|
|
4407
5591
|
const padding = 20;
|
|
@@ -4414,7 +5598,7 @@ function ModifyLayout({
|
|
|
4414
5598
|
const cbDepth = config.isShowColorbar ? config.colorbarHeight : 0;
|
|
4415
5599
|
const layoutDistance = config.layoutDistance;
|
|
4416
5600
|
useEffect(() => {
|
|
4417
|
-
setItems((prev) => checkCollisions(prev,
|
|
5601
|
+
setItems((prev) => checkCollisions(prev, shrunkContour, pw, ph));
|
|
4418
5602
|
}, []);
|
|
4419
5603
|
const itemsRef = useRef(items);
|
|
4420
5604
|
itemsRef.current = items;
|
|
@@ -4431,7 +5615,7 @@ function ModifyLayout({
|
|
|
4431
5615
|
const updated = prev.map(
|
|
4432
5616
|
(it) => it.id === dragItemId ? { ...it, x: newX, y: newY } : it
|
|
4433
5617
|
);
|
|
4434
|
-
return checkCollisions(updated,
|
|
5618
|
+
return checkCollisions(updated, shrunkContour, pw, ph);
|
|
4435
5619
|
});
|
|
4436
5620
|
return;
|
|
4437
5621
|
}
|
|
@@ -4465,7 +5649,7 @@ function ModifyLayout({
|
|
|
4465
5649
|
window.removeEventListener("pointerup", handleMouseUp);
|
|
4466
5650
|
window.removeEventListener("pointercancel", handleMouseUp);
|
|
4467
5651
|
};
|
|
4468
|
-
}, [
|
|
5652
|
+
}, [shrunkContour, pw, ph, zoom, padding]);
|
|
4469
5653
|
const handleItemMouseDown = useCallback((e, itemId) => {
|
|
4470
5654
|
e.stopPropagation();
|
|
4471
5655
|
e.preventDefault();
|
|
@@ -4504,9 +5688,9 @@ function ModifyLayout({
|
|
|
4504
5688
|
const updated = prev.map(
|
|
4505
5689
|
(it) => it.id === selectedId ? { ...it, rotation: degrees } : it
|
|
4506
5690
|
);
|
|
4507
|
-
return checkCollisions(updated,
|
|
5691
|
+
return checkCollisions(updated, shrunkContour, pw, ph);
|
|
4508
5692
|
});
|
|
4509
|
-
}, [selectedId,
|
|
5693
|
+
}, [selectedId, shrunkContour, pw, ph]);
|
|
4510
5694
|
const handleAdd = useCallback(() => {
|
|
4511
5695
|
const newItem = {
|
|
4512
5696
|
id: `item-${nextItemId++}`,
|
|
@@ -4517,17 +5701,17 @@ function ModifyLayout({
|
|
|
4517
5701
|
};
|
|
4518
5702
|
setItems((prev) => {
|
|
4519
5703
|
const updated = [...prev, newItem];
|
|
4520
|
-
return checkCollisions(updated,
|
|
5704
|
+
return checkCollisions(updated, shrunkContour, pw, ph);
|
|
4521
5705
|
});
|
|
4522
5706
|
setSelectedId(newItem.id);
|
|
4523
|
-
}, [pw, ph, dielineViewBox,
|
|
5707
|
+
}, [pw, ph, dielineViewBox, shrunkContour]);
|
|
4524
5708
|
const handleRemove = useCallback((itemId) => {
|
|
4525
5709
|
setItems((prev) => {
|
|
4526
5710
|
const filtered = prev.filter((it) => it.id !== itemId);
|
|
4527
|
-
return checkCollisions(filtered,
|
|
5711
|
+
return checkCollisions(filtered, shrunkContour, pw, ph);
|
|
4528
5712
|
});
|
|
4529
5713
|
if (selectedId === itemId) setSelectedId(null);
|
|
4530
|
-
}, [selectedId,
|
|
5714
|
+
}, [selectedId, shrunkContour, pw, ph]);
|
|
4531
5715
|
const handleSubmit = useCallback(() => {
|
|
4532
5716
|
const validItems = items.filter((it) => !it.isColliding);
|
|
4533
5717
|
const placements = validItems.map((it) => ({
|
|
@@ -4857,6 +6041,17 @@ function resolveModel(modelId, attrs, layoutDistance) {
|
|
|
4857
6041
|
generateContour: (a) => generateOuterContour4(a)
|
|
4858
6042
|
};
|
|
4859
6043
|
}
|
|
6044
|
+
case "BECF-12101": {
|
|
6045
|
+
const typedAttrs = attrs;
|
|
6046
|
+
const contour = generateOuterContour5(typedAttrs);
|
|
6047
|
+
return {
|
|
6048
|
+
dieline: generateBecf12101(typedAttrs),
|
|
6049
|
+
contourPath: contourToPath5(contour),
|
|
6050
|
+
offsetContourPoints: layoutDistance > 0 ? offsetContour5(contour, layoutDistance / 2) : contour,
|
|
6051
|
+
generate: (a) => generateBecf12101(a),
|
|
6052
|
+
generateContour: (a) => generateOuterContour5(a)
|
|
6053
|
+
};
|
|
6054
|
+
}
|
|
4860
6055
|
case "BECF-1010A":
|
|
4861
6056
|
default: {
|
|
4862
6057
|
const typedAttrs = attrs;
|
|
@@ -4898,6 +6093,14 @@ function renderDieLine2(modelId, attrs) {
|
|
|
4898
6093
|
renderAs: "group"
|
|
4899
6094
|
}
|
|
4900
6095
|
);
|
|
6096
|
+
case "BECF-12101":
|
|
6097
|
+
return /* @__PURE__ */ jsx(
|
|
6098
|
+
DIE_LINE_BECF_12101,
|
|
6099
|
+
{
|
|
6100
|
+
attributes: attrs,
|
|
6101
|
+
renderAs: "group"
|
|
6102
|
+
}
|
|
6103
|
+
);
|
|
4901
6104
|
case "BECF-1010A":
|
|
4902
6105
|
default:
|
|
4903
6106
|
return /* @__PURE__ */ jsx(
|
|
@@ -4911,7 +6114,7 @@ function renderDieLine2(modelId, attrs) {
|
|
|
4911
6114
|
})();
|
|
4912
6115
|
}
|
|
4913
6116
|
var PAPER_GAP = 20;
|
|
4914
|
-
var
|
|
6117
|
+
var PX_PER_MM7 = 96 / 25.4;
|
|
4915
6118
|
var RESULT_PANEL_HEIGHT = 55;
|
|
4916
6119
|
var RESULT_GAP = 5;
|
|
4917
6120
|
function getOpposite2(side) {
|
|
@@ -5038,7 +6241,7 @@ function getDielineTransform2(x, y, rotation, w, h) {
|
|
|
5038
6241
|
}
|
|
5039
6242
|
}
|
|
5040
6243
|
var AUTO_LAYOUT = forwardRef(
|
|
5041
|
-
({ config, onResult, onModifiedPapers }, ref) => {
|
|
6244
|
+
({ config, onResult, onModifiedPapers, isShowSummary = true, isShowAction }, ref) => {
|
|
5042
6245
|
const canvasRef = useRef(null);
|
|
5043
6246
|
const [result, setResult] = useState(null);
|
|
5044
6247
|
const [modifiedPapers, setModifiedPapers] = useState([]);
|
|
@@ -5061,7 +6264,7 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5061
6264
|
);
|
|
5062
6265
|
const modelId = config?.model.modelId ?? "";
|
|
5063
6266
|
const attrs = config?.model.attributes;
|
|
5064
|
-
const layoutDistance = config?.layoutDistance ??
|
|
6267
|
+
const layoutDistance = config?.layoutDistance ?? 3;
|
|
5065
6268
|
const resolved = useMemo(
|
|
5066
6269
|
() => modelId && attrs ? resolveModel(modelId, attrs, layoutDistance) : null,
|
|
5067
6270
|
[modelId, attrs, layoutDistance]
|
|
@@ -5088,8 +6291,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5088
6291
|
const svg = document.createElementNS(svgNs, "svg");
|
|
5089
6292
|
svg.setAttribute("xmlns", svgNs);
|
|
5090
6293
|
svg.setAttribute("viewBox", `0 0 ${vw} ${vh}`);
|
|
5091
|
-
svg.setAttribute("width", String(Math.round(vw *
|
|
5092
|
-
svg.setAttribute("height", String(Math.round(vh *
|
|
6294
|
+
svg.setAttribute("width", String(Math.round(vw * PX_PER_MM7)));
|
|
6295
|
+
svg.setAttribute("height", String(Math.round(vh * PX_PER_MM7)));
|
|
5093
6296
|
const bg = document.createElementNS(svgNs, "rect");
|
|
5094
6297
|
bg.setAttribute("width", String(vw));
|
|
5095
6298
|
bg.setAttribute("height", String(vh));
|
|
@@ -5122,8 +6325,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5122
6325
|
img.src = url;
|
|
5123
6326
|
});
|
|
5124
6327
|
const canvas = document.createElement("canvas");
|
|
5125
|
-
canvas.width = Math.round(vw *
|
|
5126
|
-
canvas.height = Math.round(vh *
|
|
6328
|
+
canvas.width = Math.round(vw * PX_PER_MM7);
|
|
6329
|
+
canvas.height = Math.round(vh * PX_PER_MM7);
|
|
5127
6330
|
const ctx = canvas.getContext("2d");
|
|
5128
6331
|
ctx.fillStyle = "#ffffff";
|
|
5129
6332
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
@@ -5142,13 +6345,13 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5142
6345
|
if (!paperResult) throw new Error("Invalid paper index");
|
|
5143
6346
|
const dl = resolved.generate(attrs);
|
|
5144
6347
|
const cPath = contourToPath(resolved.generateContour(attrs));
|
|
5145
|
-
const dist = config.layoutDistance;
|
|
6348
|
+
const dist = config.layoutDistance ?? 3;
|
|
5146
6349
|
const svgNs = "http://www.w3.org/2000/svg";
|
|
5147
6350
|
const svg = document.createElementNS(svgNs, "svg");
|
|
5148
6351
|
svg.setAttribute("xmlns", svgNs);
|
|
5149
6352
|
svg.setAttribute("viewBox", `0 0 ${paperResult.paperWidth} ${paperResult.paperHeight}`);
|
|
5150
|
-
svg.setAttribute("width", String(Math.round(paperResult.paperWidth *
|
|
5151
|
-
svg.setAttribute("height", String(Math.round(paperResult.paperHeight *
|
|
6353
|
+
svg.setAttribute("width", String(Math.round(paperResult.paperWidth * PX_PER_MM7)));
|
|
6354
|
+
svg.setAttribute("height", String(Math.round(paperResult.paperHeight * PX_PER_MM7)));
|
|
5152
6355
|
const bg = document.createElementNS(svgNs, "rect");
|
|
5153
6356
|
bg.setAttribute("width", String(paperResult.paperWidth));
|
|
5154
6357
|
bg.setAttribute("height", String(paperResult.paperHeight));
|
|
@@ -5158,12 +6361,16 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5158
6361
|
svg.appendChild(bg);
|
|
5159
6362
|
const gripperSide = paperResult.gripperSide;
|
|
5160
6363
|
const colorbarSide = getOpposite2(gripperSide);
|
|
5161
|
-
const
|
|
5162
|
-
|
|
5163
|
-
|
|
6364
|
+
const colorbarHeight = config.colorbarHeight ?? 5;
|
|
6365
|
+
const isShowColorbar = config.isShowColorbar ?? true;
|
|
6366
|
+
const spacing = config.spacing ?? 5;
|
|
6367
|
+
const griper = config.griper ?? 10;
|
|
6368
|
+
const cbDepth = isShowColorbar ? colorbarHeight : 0;
|
|
6369
|
+
if (isShowColorbar) {
|
|
6370
|
+
appendColorbarToSvg(svg, svgNs, colorbarSide, colorbarHeight, paperResult.paperWidth, paperResult.paperHeight);
|
|
5164
6371
|
}
|
|
5165
|
-
if (
|
|
5166
|
-
const rects = getSpacingRects2(gripperSide, paperResult.paperWidth, paperResult.paperHeight,
|
|
6372
|
+
if (spacing > 0) {
|
|
6373
|
+
const rects = getSpacingRects2(gripperSide, paperResult.paperWidth, paperResult.paperHeight, spacing, griper, cbDepth);
|
|
5167
6374
|
for (const sr of rects) {
|
|
5168
6375
|
const r = document.createElementNS(svgNs, "rect");
|
|
5169
6376
|
r.setAttribute("x", String(sr.x));
|
|
@@ -5174,8 +6381,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5174
6381
|
svg.appendChild(r);
|
|
5175
6382
|
}
|
|
5176
6383
|
}
|
|
5177
|
-
if (
|
|
5178
|
-
appendGripperToSvg(svg, svgNs, gripperSide, paperResult.paperWidth, paperResult.paperHeight,
|
|
6384
|
+
if (griper > 0) {
|
|
6385
|
+
appendGripperToSvg(svg, svgNs, gripperSide, paperResult.paperWidth, paperResult.paperHeight, griper, theme.colorGriper);
|
|
5179
6386
|
}
|
|
5180
6387
|
if (dist > 0) {
|
|
5181
6388
|
const defs = document.createElementNS(svgNs, "defs");
|
|
@@ -5248,8 +6455,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5248
6455
|
img.src = url;
|
|
5249
6456
|
});
|
|
5250
6457
|
const canvas = document.createElement("canvas");
|
|
5251
|
-
canvas.width = Math.round(paperResult.paperWidth *
|
|
5252
|
-
canvas.height = Math.round(paperResult.paperHeight *
|
|
6458
|
+
canvas.width = Math.round(paperResult.paperWidth * PX_PER_MM7);
|
|
6459
|
+
canvas.height = Math.round(paperResult.paperHeight * PX_PER_MM7);
|
|
5253
6460
|
const ctx = canvas.getContext("2d");
|
|
5254
6461
|
ctx.fillStyle = theme.colorPaperFill;
|
|
5255
6462
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
@@ -5277,7 +6484,10 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5277
6484
|
unit: "mm",
|
|
5278
6485
|
format: [pw, ph]
|
|
5279
6486
|
});
|
|
5280
|
-
|
|
6487
|
+
const pdfColorbarHeight = config.colorbarHeight ?? 5;
|
|
6488
|
+
const pdfIsShowColorbar = config.isShowColorbar ?? true;
|
|
6489
|
+
const pdfGriper = config.griper ?? 10;
|
|
6490
|
+
if (pdfIsShowColorbar) {
|
|
5281
6491
|
const BASE_COLORS2 = ["#02FFFF", "#FF00FF", "#FFFF00", "#000000"];
|
|
5282
6492
|
const FADE_LEVELS2 = [1, 0.8, 0.6, 0.4, 0.2];
|
|
5283
6493
|
const fadeToWhite2 = (hex, opacity) => {
|
|
@@ -5295,7 +6505,7 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5295
6505
|
);
|
|
5296
6506
|
const count = colors.length;
|
|
5297
6507
|
const isHoriz = colorbarSide === "top" || colorbarSide === "bottom";
|
|
5298
|
-
const cbH =
|
|
6508
|
+
const cbH = pdfColorbarHeight;
|
|
5299
6509
|
colors.forEach((c, i) => {
|
|
5300
6510
|
doc.setFillColor(c.r, c.g, c.b);
|
|
5301
6511
|
if (isHoriz) {
|
|
@@ -5309,7 +6519,7 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5309
6519
|
}
|
|
5310
6520
|
});
|
|
5311
6521
|
}
|
|
5312
|
-
if (
|
|
6522
|
+
if (pdfGriper > 0) {
|
|
5313
6523
|
const hexToRgb2 = (hex) => ({
|
|
5314
6524
|
r: parseInt(hex.slice(1, 3), 16),
|
|
5315
6525
|
g: parseInt(hex.slice(3, 5), 16),
|
|
@@ -5317,7 +6527,7 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5317
6527
|
});
|
|
5318
6528
|
const gc = hexToRgb2(theme.colorGriper);
|
|
5319
6529
|
doc.setFillColor(gc.r, gc.g, gc.b);
|
|
5320
|
-
const depth =
|
|
6530
|
+
const depth = pdfGriper;
|
|
5321
6531
|
switch (gripperSide) {
|
|
5322
6532
|
case "bottom":
|
|
5323
6533
|
doc.rect(0, ph - depth, pw, depth, "F");
|
|
@@ -5442,7 +6652,8 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5442
6652
|
exportImage,
|
|
5443
6653
|
exportPdf
|
|
5444
6654
|
}), [result, getPackedResult, exportDielineImage, exportImage, exportPdf]);
|
|
5445
|
-
const
|
|
6655
|
+
const showAction = (action) => !isShowAction || isShowAction.includes(action);
|
|
6656
|
+
const paperOriginY = isShowSummary ? RESULT_PANEL_HEIGHT + RESULT_GAP : 0;
|
|
5446
6657
|
const viewBox = useMemo(() => {
|
|
5447
6658
|
if (allPapers.length === 0) {
|
|
5448
6659
|
return { x: 0, y: 0, width: 400, height: 300 };
|
|
@@ -5486,7 +6697,7 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5486
6697
|
}
|
|
5487
6698
|
const gripperSide = paperResult.gripperSide;
|
|
5488
6699
|
const colorbarSide = getOpposite2(gripperSide);
|
|
5489
|
-
const cbDepth = config.isShowColorbar ? config.colorbarHeight : 0;
|
|
6700
|
+
const cbDepth = config.isShowColorbar ?? true ? config.colorbarHeight ?? 5 : 0;
|
|
5490
6701
|
const panelW = paperResult.paperWidth;
|
|
5491
6702
|
const fontSize = Math.min(4, panelW / 30);
|
|
5492
6703
|
const padX = fontSize * 1.2;
|
|
@@ -5510,148 +6721,150 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5510
6721
|
curY += gap;
|
|
5511
6722
|
const exportBtnY = curY;
|
|
5512
6723
|
return /* @__PURE__ */ jsxs("g", { transform: `translate(${offsetX}, 0)`, children: [
|
|
5513
|
-
/* @__PURE__ */
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
"
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
"
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
"
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
"
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
"
|
|
5550
|
-
|
|
5551
|
-
|
|
6724
|
+
isShowSummary && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6725
|
+
/* @__PURE__ */ jsx(
|
|
6726
|
+
"rect",
|
|
6727
|
+
{
|
|
6728
|
+
x: 0,
|
|
6729
|
+
y: 0,
|
|
6730
|
+
width: panelW,
|
|
6731
|
+
height: RESULT_PANEL_HEIGHT,
|
|
6732
|
+
rx: 2,
|
|
6733
|
+
ry: 2,
|
|
6734
|
+
fill: "#f8fafc",
|
|
6735
|
+
stroke: "#d4dce7",
|
|
6736
|
+
strokeWidth: 0.3
|
|
6737
|
+
}
|
|
6738
|
+
),
|
|
6739
|
+
/* @__PURE__ */ jsx("text", { x: padX, y: titleY, fontSize: fontSize + 1, fontWeight: "bold", fill: "#0f172a", children: paperResult.paperName }),
|
|
6740
|
+
/* @__PURE__ */ jsxs("text", { x: padX, y: recY, fontSize, fontWeight: "bold", fill: rank === 1 ? "#10b981" : "#475569", children: [
|
|
6741
|
+
"Recommended: #",
|
|
6742
|
+
rank
|
|
6743
|
+
] }),
|
|
6744
|
+
/* @__PURE__ */ jsxs("text", { x: padX, y: perSheetY, fontSize, fill: "#475569", children: [
|
|
6745
|
+
"Produced per sheet: ",
|
|
6746
|
+
paperResult.producedPerSheet,
|
|
6747
|
+
" pcs"
|
|
6748
|
+
] }),
|
|
6749
|
+
/* @__PURE__ */ jsxs("text", { x: padX, y: sheetsY, fontSize, fill: "#475569", children: [
|
|
6750
|
+
"Sheets needed: ",
|
|
6751
|
+
paperResult.independentSheets
|
|
6752
|
+
] }),
|
|
6753
|
+
/* @__PURE__ */ jsxs("text", { x: padX, y: producedY, fontSize, fill: "#475569", children: [
|
|
6754
|
+
"Produced: ",
|
|
6755
|
+
paperResult.independentSheets * paperResult.producedPerSheet,
|
|
6756
|
+
" pcs (excess ",
|
|
6757
|
+
paperResult.independentSheets * paperResult.producedPerSheet - (config?.quantity ?? 0),
|
|
6758
|
+
")"
|
|
6759
|
+
] }),
|
|
6760
|
+
/* @__PURE__ */ jsxs("text", { x: padX, y: wasteY, fontSize, fill: "#475569", children: [
|
|
6761
|
+
"Waste per sheet: ",
|
|
6762
|
+
paperResult.wastePercent,
|
|
6763
|
+
"%"
|
|
6764
|
+
] }),
|
|
6765
|
+
showAction("EXPORT_SHEET") && /* @__PURE__ */ jsxs(
|
|
6766
|
+
"g",
|
|
6767
|
+
{
|
|
6768
|
+
style: { cursor: "pointer" },
|
|
6769
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
6770
|
+
onClick: () => handleExportImage(paperIdx),
|
|
6771
|
+
children: [
|
|
6772
|
+
/* @__PURE__ */ jsx(
|
|
6773
|
+
"rect",
|
|
6774
|
+
{
|
|
6775
|
+
x: padX,
|
|
6776
|
+
y: exportBtnY,
|
|
6777
|
+
width: exportBtnW,
|
|
6778
|
+
height: exportBtnH,
|
|
6779
|
+
rx: 1.5,
|
|
6780
|
+
ry: 1.5,
|
|
6781
|
+
fill: "#0f172a"
|
|
6782
|
+
}
|
|
6783
|
+
),
|
|
6784
|
+
/* @__PURE__ */ jsx(
|
|
6785
|
+
"text",
|
|
6786
|
+
{
|
|
6787
|
+
x: padX + exportBtnW / 2,
|
|
6788
|
+
y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
|
|
6789
|
+
textAnchor: "middle",
|
|
6790
|
+
fontSize,
|
|
6791
|
+
fill: "#fff",
|
|
6792
|
+
style: { pointerEvents: "none" },
|
|
6793
|
+
children: "Export Sheet"
|
|
6794
|
+
}
|
|
6795
|
+
)
|
|
6796
|
+
]
|
|
6797
|
+
}
|
|
6798
|
+
),
|
|
6799
|
+
showAction("EXPORT_PDF") && /* @__PURE__ */ jsxs(
|
|
6800
|
+
"g",
|
|
6801
|
+
{
|
|
6802
|
+
style: { cursor: "pointer" },
|
|
6803
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
6804
|
+
onClick: () => handleExportPdf(paperIdx),
|
|
6805
|
+
children: [
|
|
6806
|
+
/* @__PURE__ */ jsx(
|
|
6807
|
+
"rect",
|
|
6808
|
+
{
|
|
6809
|
+
x: padX + exportBtnW + fontSize * 2,
|
|
6810
|
+
y: exportBtnY,
|
|
6811
|
+
width: exportBtnW,
|
|
6812
|
+
height: exportBtnH,
|
|
6813
|
+
rx: 1.5,
|
|
6814
|
+
ry: 1.5,
|
|
6815
|
+
fill: "#1e40af"
|
|
6816
|
+
}
|
|
6817
|
+
),
|
|
6818
|
+
/* @__PURE__ */ jsx(
|
|
6819
|
+
"text",
|
|
6820
|
+
{
|
|
6821
|
+
x: padX + exportBtnW + fontSize * 2 + exportBtnW / 2,
|
|
6822
|
+
y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
|
|
6823
|
+
textAnchor: "middle",
|
|
6824
|
+
fontSize,
|
|
6825
|
+
fill: "#fff",
|
|
6826
|
+
style: { pointerEvents: "none" },
|
|
6827
|
+
children: "Export PDF"
|
|
6828
|
+
}
|
|
6829
|
+
)
|
|
6830
|
+
]
|
|
6831
|
+
}
|
|
6832
|
+
),
|
|
6833
|
+
showAction("MODIFY_LAYOUT") && paperResult.producedPerSheet > 0 && /* @__PURE__ */ jsxs(
|
|
6834
|
+
"g",
|
|
6835
|
+
{
|
|
6836
|
+
style: { cursor: "pointer" },
|
|
6837
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
6838
|
+
onClick: () => setModifyingPaper(paperResult),
|
|
6839
|
+
children: [
|
|
6840
|
+
/* @__PURE__ */ jsx(
|
|
6841
|
+
"rect",
|
|
6842
|
+
{
|
|
6843
|
+
x: padX + (exportBtnW + fontSize * 2) * 2,
|
|
6844
|
+
y: exportBtnY,
|
|
6845
|
+
width: exportBtnW,
|
|
6846
|
+
height: exportBtnH,
|
|
6847
|
+
rx: 1.5,
|
|
6848
|
+
ry: 1.5,
|
|
6849
|
+
fill: "#7c3aed"
|
|
6850
|
+
}
|
|
6851
|
+
),
|
|
6852
|
+
/* @__PURE__ */ jsx(
|
|
6853
|
+
"text",
|
|
6854
|
+
{
|
|
6855
|
+
x: padX + (exportBtnW + fontSize * 2) * 2 + exportBtnW / 2,
|
|
6856
|
+
y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
|
|
6857
|
+
textAnchor: "middle",
|
|
6858
|
+
fontSize,
|
|
6859
|
+
fill: "#fff",
|
|
6860
|
+
style: { pointerEvents: "none" },
|
|
6861
|
+
children: "Modify Layout"
|
|
6862
|
+
}
|
|
6863
|
+
)
|
|
6864
|
+
]
|
|
6865
|
+
}
|
|
6866
|
+
)
|
|
5552
6867
|
] }),
|
|
5553
|
-
/* @__PURE__ */ jsxs(
|
|
5554
|
-
"g",
|
|
5555
|
-
{
|
|
5556
|
-
style: { cursor: "pointer" },
|
|
5557
|
-
onPointerDown: (e) => e.stopPropagation(),
|
|
5558
|
-
onClick: () => handleExportImage(paperIdx),
|
|
5559
|
-
children: [
|
|
5560
|
-
/* @__PURE__ */ jsx(
|
|
5561
|
-
"rect",
|
|
5562
|
-
{
|
|
5563
|
-
x: padX,
|
|
5564
|
-
y: exportBtnY,
|
|
5565
|
-
width: exportBtnW,
|
|
5566
|
-
height: exportBtnH,
|
|
5567
|
-
rx: 1.5,
|
|
5568
|
-
ry: 1.5,
|
|
5569
|
-
fill: "#0f172a"
|
|
5570
|
-
}
|
|
5571
|
-
),
|
|
5572
|
-
/* @__PURE__ */ jsx(
|
|
5573
|
-
"text",
|
|
5574
|
-
{
|
|
5575
|
-
x: padX + exportBtnW / 2,
|
|
5576
|
-
y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
|
|
5577
|
-
textAnchor: "middle",
|
|
5578
|
-
fontSize,
|
|
5579
|
-
fill: "#fff",
|
|
5580
|
-
style: { pointerEvents: "none" },
|
|
5581
|
-
children: "Export Sheet"
|
|
5582
|
-
}
|
|
5583
|
-
)
|
|
5584
|
-
]
|
|
5585
|
-
}
|
|
5586
|
-
),
|
|
5587
|
-
/* @__PURE__ */ jsxs(
|
|
5588
|
-
"g",
|
|
5589
|
-
{
|
|
5590
|
-
style: { cursor: "pointer" },
|
|
5591
|
-
onPointerDown: (e) => e.stopPropagation(),
|
|
5592
|
-
onClick: () => handleExportPdf(paperIdx),
|
|
5593
|
-
children: [
|
|
5594
|
-
/* @__PURE__ */ jsx(
|
|
5595
|
-
"rect",
|
|
5596
|
-
{
|
|
5597
|
-
x: padX + exportBtnW + fontSize * 2,
|
|
5598
|
-
y: exportBtnY,
|
|
5599
|
-
width: exportBtnW,
|
|
5600
|
-
height: exportBtnH,
|
|
5601
|
-
rx: 1.5,
|
|
5602
|
-
ry: 1.5,
|
|
5603
|
-
fill: "#1e40af"
|
|
5604
|
-
}
|
|
5605
|
-
),
|
|
5606
|
-
/* @__PURE__ */ jsx(
|
|
5607
|
-
"text",
|
|
5608
|
-
{
|
|
5609
|
-
x: padX + exportBtnW + fontSize * 2 + exportBtnW / 2,
|
|
5610
|
-
y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
|
|
5611
|
-
textAnchor: "middle",
|
|
5612
|
-
fontSize,
|
|
5613
|
-
fill: "#fff",
|
|
5614
|
-
style: { pointerEvents: "none" },
|
|
5615
|
-
children: "Export PDF"
|
|
5616
|
-
}
|
|
5617
|
-
)
|
|
5618
|
-
]
|
|
5619
|
-
}
|
|
5620
|
-
),
|
|
5621
|
-
paperResult.producedPerSheet > 0 && /* @__PURE__ */ jsxs(
|
|
5622
|
-
"g",
|
|
5623
|
-
{
|
|
5624
|
-
style: { cursor: "pointer" },
|
|
5625
|
-
onPointerDown: (e) => e.stopPropagation(),
|
|
5626
|
-
onClick: () => setModifyingPaper(paperResult),
|
|
5627
|
-
children: [
|
|
5628
|
-
/* @__PURE__ */ jsx(
|
|
5629
|
-
"rect",
|
|
5630
|
-
{
|
|
5631
|
-
x: padX + (exportBtnW + fontSize * 2) * 2,
|
|
5632
|
-
y: exportBtnY,
|
|
5633
|
-
width: exportBtnW,
|
|
5634
|
-
height: exportBtnH,
|
|
5635
|
-
rx: 1.5,
|
|
5636
|
-
ry: 1.5,
|
|
5637
|
-
fill: "#7c3aed"
|
|
5638
|
-
}
|
|
5639
|
-
),
|
|
5640
|
-
/* @__PURE__ */ jsx(
|
|
5641
|
-
"text",
|
|
5642
|
-
{
|
|
5643
|
-
x: padX + (exportBtnW + fontSize * 2) * 2 + exportBtnW / 2,
|
|
5644
|
-
y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
|
|
5645
|
-
textAnchor: "middle",
|
|
5646
|
-
fontSize,
|
|
5647
|
-
fill: "#fff",
|
|
5648
|
-
style: { pointerEvents: "none" },
|
|
5649
|
-
children: "Modify Layout"
|
|
5650
|
-
}
|
|
5651
|
-
)
|
|
5652
|
-
]
|
|
5653
|
-
}
|
|
5654
|
-
),
|
|
5655
6868
|
/* @__PURE__ */ jsxs("g", { transform: `translate(0, ${paperOriginY})`, children: [
|
|
5656
6869
|
/* @__PURE__ */ jsx(
|
|
5657
6870
|
"rect",
|
|
@@ -5663,30 +6876,30 @@ var AUTO_LAYOUT = forwardRef(
|
|
|
5663
6876
|
strokeWidth: 0.5
|
|
5664
6877
|
}
|
|
5665
6878
|
),
|
|
5666
|
-
config.isShowColorbar && /* @__PURE__ */ jsx(
|
|
6879
|
+
(config.isShowColorbar ?? true) && /* @__PURE__ */ jsx(
|
|
5667
6880
|
Colorbar,
|
|
5668
6881
|
{
|
|
5669
6882
|
side: colorbarSide,
|
|
5670
|
-
colorbarHeight: config.colorbarHeight,
|
|
6883
|
+
colorbarHeight: config.colorbarHeight ?? 5,
|
|
5671
6884
|
paperWidth: paperResult.paperWidth,
|
|
5672
6885
|
paperHeight: paperResult.paperHeight
|
|
5673
6886
|
}
|
|
5674
6887
|
),
|
|
5675
|
-
config.spacing > 0 && getSpacingRects2(
|
|
6888
|
+
(config.spacing ?? 5) > 0 && getSpacingRects2(
|
|
5676
6889
|
gripperSide,
|
|
5677
6890
|
paperResult.paperWidth,
|
|
5678
6891
|
paperResult.paperHeight,
|
|
5679
|
-
config.spacing,
|
|
5680
|
-
config.griper,
|
|
6892
|
+
config.spacing ?? 5,
|
|
6893
|
+
config.griper ?? 10,
|
|
5681
6894
|
cbDepth
|
|
5682
6895
|
).map((r, i) => /* @__PURE__ */ jsx("rect", { x: r.x, y: r.y, width: r.w, height: r.h, fill: theme.colorSpacing }, `sp-${i}`)),
|
|
5683
|
-
config.griper > 0 && /* @__PURE__ */ jsx(
|
|
6896
|
+
(config.griper ?? 10) > 0 && /* @__PURE__ */ jsx(
|
|
5684
6897
|
Gripper,
|
|
5685
6898
|
{
|
|
5686
6899
|
side: gripperSide,
|
|
5687
6900
|
paperWidth: paperResult.paperWidth,
|
|
5688
6901
|
paperHeight: paperResult.paperHeight,
|
|
5689
|
-
depth: config.griper,
|
|
6902
|
+
depth: config.griper ?? 10,
|
|
5690
6903
|
fillColor: theme.colorGriper
|
|
5691
6904
|
}
|
|
5692
6905
|
),
|
|
@@ -5748,6 +6961,10 @@ var DIE_LINE_LAYOUT = forwardRef(
|
|
|
5748
6961
|
return /* @__PURE__ */ jsx(MODEL_BECF_1040A, { ref, ...props });
|
|
5749
6962
|
case "BECF-11D01":
|
|
5750
6963
|
return /* @__PURE__ */ jsx(MODEL_BECF_11D01, { ref, ...props });
|
|
6964
|
+
case "BECF-12101":
|
|
6965
|
+
return /* @__PURE__ */ jsx(MODEL_BECF_12101, { ref, ...props });
|
|
6966
|
+
case "BECF-12109":
|
|
6967
|
+
return /* @__PURE__ */ jsx(MODEL_BECF_12109, { ref, ...props });
|
|
5751
6968
|
default:
|
|
5752
6969
|
return null;
|
|
5753
6970
|
}
|
|
@@ -5784,12 +7001,19 @@ var BECF_1040A_DEFAULT_ATTRIBUTES = {
|
|
|
5784
7001
|
tuckFlap: 14
|
|
5785
7002
|
};
|
|
5786
7003
|
|
|
5787
|
-
// src/statics/
|
|
5788
|
-
var
|
|
7004
|
+
// src/statics/bags-pillows/becf-12101/DEFAULT_ATTRIBUTES.ts
|
|
7005
|
+
var BECF_12101_DEFAULT_ATTRIBUTES = {
|
|
7006
|
+
length: 100,
|
|
7007
|
+
width: 50,
|
|
7008
|
+
height: 150,
|
|
7009
|
+
glueArea: 13
|
|
7010
|
+
};
|
|
7011
|
+
|
|
7012
|
+
// src/statics/bags-pillows/becf-12109/DEFAULT_ATTRIBUTES.ts
|
|
7013
|
+
var BECF_12109_DEFAULT_ATTRIBUTES = {
|
|
5789
7014
|
length: 100,
|
|
5790
7015
|
width: 50,
|
|
5791
7016
|
height: 150,
|
|
5792
|
-
flapHeight: 50,
|
|
5793
7017
|
glueArea: 13
|
|
5794
7018
|
};
|
|
5795
7019
|
|
|
@@ -5816,15 +7040,38 @@ var modelList = [
|
|
|
5816
7040
|
dimension: ["DIE_LINE"],
|
|
5817
7041
|
attributes: { ...BECF_1030A_DEFAULT_ATTRIBUTES }
|
|
5818
7042
|
},
|
|
7043
|
+
// {
|
|
7044
|
+
// id: "BECF-11D01",
|
|
7045
|
+
// nameEN: "Standard Box BECF-11D01",
|
|
7046
|
+
// nameTH: "กล่องทั่วไป BECF-11D01",
|
|
7047
|
+
// dimension: ["DIE_LINE"],
|
|
7048
|
+
// attributes: { ...BECF_11D01_DEFAULT_ATTRIBUTES },
|
|
7049
|
+
// },
|
|
5819
7050
|
{
|
|
5820
|
-
id: "BECF-
|
|
5821
|
-
nameEN: "
|
|
5822
|
-
nameTH: "\
|
|
7051
|
+
id: "BECF-12101",
|
|
7052
|
+
nameEN: "SHOPPING BAGS TYPE A",
|
|
7053
|
+
nameTH: "\u0E16\u0E38\u0E07\u0E23\u0E49\u0E2D\u0E22\u0E40\u0E0A\u0E37\u0E2D\u0E01\u0E40\u0E1B\u0E35\u0E22 \u0E21\u0E31\u0E14\u0E1B\u0E21 A",
|
|
5823
7054
|
dimension: ["DIE_LINE"],
|
|
5824
|
-
attributes: { ...
|
|
7055
|
+
attributes: { ...BECF_12101_DEFAULT_ATTRIBUTES }
|
|
7056
|
+
},
|
|
7057
|
+
{
|
|
7058
|
+
id: "BECF-12109",
|
|
7059
|
+
nameEN: "SHOPPING BAGS TYPE B",
|
|
7060
|
+
nameTH: "\u0E16\u0E38\u0E07\u0E23\u0E49\u0E2D\u0E22\u0E40\u0E0A\u0E37\u0E2D\u0E01\u0E40\u0E1B\u0E35\u0E22 \u0E21\u0E31\u0E14\u0E1B\u0E21 B",
|
|
7061
|
+
dimension: ["DIE_LINE"],
|
|
7062
|
+
attributes: { ...BECF_12109_DEFAULT_ATTRIBUTES }
|
|
5825
7063
|
}
|
|
5826
7064
|
];
|
|
5827
7065
|
|
|
5828
|
-
|
|
7066
|
+
// src/statics/standard-boxes/becf-11d01/DEFAULT_ATTRIBUTES.ts
|
|
7067
|
+
var BECF_11D01_DEFAULT_ATTRIBUTES = {
|
|
7068
|
+
length: 100,
|
|
7069
|
+
width: 50,
|
|
7070
|
+
height: 150,
|
|
7071
|
+
flapHeight: 50,
|
|
7072
|
+
glueArea: 13
|
|
7073
|
+
};
|
|
7074
|
+
|
|
7075
|
+
export { AUTO_LAYOUT, AUTO_LAYOUT_THEME_CONFIG, BECF_1010A_DEFAULT_ATTRIBUTES, BECF_1030A_DEFAULT_ATTRIBUTES, BECF_1040A_DEFAULT_ATTRIBUTES, BECF_11D01_DEFAULT_ATTRIBUTES, BECF_12101_DEFAULT_ATTRIBUTES, BECF_12109_DEFAULT_ATTRIBUTES, Colorbar, DIE_LINE_LAYOUT, Gripper, MODEL_BECF_1010A, MODEL_BECF_1030A, MODEL_BECF_1040A, MODEL_BECF_11D01, MODEL_BECF_12101, MODEL_BECF_12109, MODEL_THEME_CONFIG, appendColorbarToSvg, appendGripperToSvg, calculateAutoLayout, configurePackaging, modelList };
|
|
5829
7076
|
//# sourceMappingURL=index.mjs.map
|
|
5830
7077
|
//# sourceMappingURL=index.mjs.map
|