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