@seatmap-fyi/map-domain 0.1.0-alpha.57 → 0.1.0-alpha.59
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/schema.d.ts +4 -0
- package/dist/schema.js +1 -0
- package/dist/section-layout.d.ts +51 -2
- package/dist/section-layout.interface.d.ts +2 -1
- package/dist/section-layout.js +43 -14
- package/dist/section-scale.d.ts +6 -1
- package/dist/section-scale.js +77 -15
- package/dist/sections.js +7 -4
- package/package.json +1 -1
package/dist/schema.d.ts
CHANGED
|
@@ -3215,6 +3215,10 @@ export declare const zonesSchema: z.ZodArray<z.ZodObject<{
|
|
|
3215
3215
|
export declare const uuidSchema: z.ZodString;
|
|
3216
3216
|
export declare const dimensionSchema: z.ZodNumber;
|
|
3217
3217
|
export declare const coordinateSchema: z.ZodNumber;
|
|
3218
|
+
export declare const pointSchema: z.ZodObject<{
|
|
3219
|
+
x: z.ZodNumber;
|
|
3220
|
+
y: z.ZodNumber;
|
|
3221
|
+
}, z.core.$strict>;
|
|
3218
3222
|
export declare const rotationSchema: z.ZodNumber;
|
|
3219
3223
|
export declare const positiveCountSchema: z.ZodNumber;
|
|
3220
3224
|
export declare const labelSequenceSchema: z.ZodObject<{
|
package/dist/schema.js
CHANGED
|
@@ -704,6 +704,7 @@ export const zonesSchema = documentSchema.shape.zones.unwrap();
|
|
|
704
704
|
export const uuidSchema = uuid;
|
|
705
705
|
export const dimensionSchema = dimension;
|
|
706
706
|
export const coordinateSchema = coordinate;
|
|
707
|
+
export const pointSchema = point;
|
|
707
708
|
export const rotationSchema = angle;
|
|
708
709
|
export const positiveCountSchema = finite.int().min(1).max(DocumentLimits.PhysicalSeats);
|
|
709
710
|
export const labelSequenceSchema = sequence;
|
package/dist/section-layout.d.ts
CHANGED
|
@@ -1,17 +1,35 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { type PhysicalDocumentV1 } from "./physical-document.interface.js";
|
|
3
3
|
import { SectionLayoutSaveKind, type SectionTransformInput } from "./section-layout.interface.js";
|
|
4
|
-
export { SectionLayoutSaveKind, type SectionLayoutInput, type SectionTransformInput, } from "./section-layout.interface.js";
|
|
4
|
+
export { SectionLayoutSaveKind, type SectionCornerScaleInput, type SectionLayoutInput, type SectionTransformInput, } from "./section-layout.interface.js";
|
|
5
5
|
export declare const sectionRotationInputSchema: z.ZodObject<{
|
|
6
6
|
sectionId: z.ZodUUID;
|
|
7
7
|
rotationDeg: z.ZodNumber;
|
|
8
8
|
}, z.core.$strict>;
|
|
9
|
+
export declare const sectionCornerScaleInputSchema: z.ZodObject<{
|
|
10
|
+
sectionId: z.ZodUUID;
|
|
11
|
+
scaleFactor: z.ZodNumber;
|
|
12
|
+
pivotM: z.ZodObject<{
|
|
13
|
+
x: z.ZodNumber;
|
|
14
|
+
y: z.ZodNumber;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
}, z.core.$strict>;
|
|
9
17
|
export declare const sectionTransformInputSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
10
18
|
sectionId: z.ZodUUID;
|
|
11
19
|
rotationDeg: z.ZodNumber;
|
|
20
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
21
|
+
sectionId: z.ZodUUID;
|
|
22
|
+
rotationDeltaDeg: z.ZodNumber;
|
|
12
23
|
}, z.core.$strict>, z.ZodObject<{
|
|
13
24
|
sectionId: z.ZodUUID;
|
|
14
25
|
scalePercent: z.ZodNumber;
|
|
26
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
27
|
+
sectionId: z.ZodUUID;
|
|
28
|
+
scaleFactor: z.ZodNumber;
|
|
29
|
+
pivotM: z.ZodObject<{
|
|
30
|
+
x: z.ZodNumber;
|
|
31
|
+
y: z.ZodNumber;
|
|
32
|
+
}, z.core.$strict>;
|
|
15
33
|
}, z.core.$strict>]>;
|
|
16
34
|
export declare const sectionLayoutInputSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
17
35
|
sectionId: z.ZodUUID;
|
|
@@ -20,9 +38,19 @@ export declare const sectionLayoutInputSchema: z.ZodUnion<readonly [z.ZodObject<
|
|
|
20
38
|
}, z.core.$strict>, z.ZodUnion<readonly [z.ZodObject<{
|
|
21
39
|
sectionId: z.ZodUUID;
|
|
22
40
|
rotationDeg: z.ZodNumber;
|
|
41
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
42
|
+
sectionId: z.ZodUUID;
|
|
43
|
+
rotationDeltaDeg: z.ZodNumber;
|
|
23
44
|
}, z.core.$strict>, z.ZodObject<{
|
|
24
45
|
sectionId: z.ZodUUID;
|
|
25
46
|
scalePercent: z.ZodNumber;
|
|
47
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
48
|
+
sectionId: z.ZodUUID;
|
|
49
|
+
scaleFactor: z.ZodNumber;
|
|
50
|
+
pivotM: z.ZodObject<{
|
|
51
|
+
x: z.ZodNumber;
|
|
52
|
+
y: z.ZodNumber;
|
|
53
|
+
}, z.core.$strict>;
|
|
26
54
|
}, z.core.$strict>]>, z.ZodObject<{
|
|
27
55
|
sectionId: z.ZodUUID;
|
|
28
56
|
fill: z.ZodObject<{
|
|
@@ -50,9 +78,19 @@ export declare const sectionLayoutSaveSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
50
78
|
}, z.core.$strict>, z.ZodUnion<readonly [z.ZodObject<{
|
|
51
79
|
sectionId: z.ZodUUID;
|
|
52
80
|
rotationDeg: z.ZodNumber;
|
|
81
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
82
|
+
sectionId: z.ZodUUID;
|
|
83
|
+
rotationDeltaDeg: z.ZodNumber;
|
|
53
84
|
}, z.core.$strict>, z.ZodObject<{
|
|
54
85
|
sectionId: z.ZodUUID;
|
|
55
86
|
scalePercent: z.ZodNumber;
|
|
87
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
88
|
+
sectionId: z.ZodUUID;
|
|
89
|
+
scaleFactor: z.ZodNumber;
|
|
90
|
+
pivotM: z.ZodObject<{
|
|
91
|
+
x: z.ZodNumber;
|
|
92
|
+
y: z.ZodNumber;
|
|
93
|
+
}, z.core.$strict>;
|
|
56
94
|
}, z.core.$strict>]>, z.ZodObject<{
|
|
57
95
|
sectionId: z.ZodUUID;
|
|
58
96
|
fill: z.ZodObject<{
|
|
@@ -80,9 +118,19 @@ export declare const sectionLayoutSaveSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
80
118
|
}, z.core.$strict>, z.ZodUnion<readonly [z.ZodObject<{
|
|
81
119
|
sectionId: z.ZodUUID;
|
|
82
120
|
rotationDeg: z.ZodNumber;
|
|
121
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
122
|
+
sectionId: z.ZodUUID;
|
|
123
|
+
rotationDeltaDeg: z.ZodNumber;
|
|
83
124
|
}, z.core.$strict>, z.ZodObject<{
|
|
84
125
|
sectionId: z.ZodUUID;
|
|
85
126
|
scalePercent: z.ZodNumber;
|
|
127
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
128
|
+
sectionId: z.ZodUUID;
|
|
129
|
+
scaleFactor: z.ZodNumber;
|
|
130
|
+
pivotM: z.ZodObject<{
|
|
131
|
+
x: z.ZodNumber;
|
|
132
|
+
y: z.ZodNumber;
|
|
133
|
+
}, z.core.$strict>;
|
|
86
134
|
}, z.core.$strict>]>, z.ZodObject<{
|
|
87
135
|
sectionId: z.ZodUUID;
|
|
88
136
|
fill: z.ZodObject<{
|
|
@@ -103,5 +151,6 @@ export declare const sectionLayoutSaveSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
103
151
|
}, z.core.$strict>]>;
|
|
104
152
|
beforeRevision: z.ZodNumber;
|
|
105
153
|
}, z.core.$strict>], "kind">;
|
|
106
|
-
|
|
154
|
+
export declare function sectionCornerScaleMinimum(document: PhysicalDocumentV1, sectionId: SectionTransformInput["sectionId"]): number;
|
|
155
|
+
/** Transform the existing outline and its editable contents. */
|
|
107
156
|
export declare function transformSection(document: PhysicalDocumentV1, input: SectionTransformInput): PhysicalDocumentV1 | undefined;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
|
-
import type { sectionLayoutInputSchema, sectionTransformInputSchema } from "./section-layout.js";
|
|
2
|
+
import type { sectionCornerScaleInputSchema, sectionLayoutInputSchema, sectionTransformInputSchema } from "./section-layout.js";
|
|
3
3
|
export declare enum SectionLayoutSaveKind {
|
|
4
4
|
Apply = "apply",
|
|
5
5
|
Undo = "undo"
|
|
6
6
|
}
|
|
7
|
+
export type SectionCornerScaleInput = z.infer<typeof sectionCornerScaleInputSchema>;
|
|
7
8
|
export type SectionTransformInput = z.infer<typeof sectionTransformInputSchema>;
|
|
8
9
|
export type SectionLayoutInput = z.infer<typeof sectionLayoutInputSchema>;
|
package/dist/section-layout.js
CHANGED
|
@@ -9,18 +9,33 @@ import { sectionGrowInputSchema } from "./section-fill.js";
|
|
|
9
9
|
import { sectionRefitInputSchema } from "./section-refit.js";
|
|
10
10
|
import { sectionOutlineSampleCenter, sectionOutlineSamplingScale } from "./section-outline-refit.js";
|
|
11
11
|
import { SectionLayoutSaveKind } from "./section-layout.interface.js";
|
|
12
|
+
import { pointSchema } from "./schema.js";
|
|
12
13
|
import { sectionCatalog } from "./sections.js";
|
|
13
|
-
import { scaleSectionLayout } from "./section-scale.js";
|
|
14
|
+
import { minimumCornerScale, scaleSectionLayout } from "./section-scale.js";
|
|
14
15
|
export { SectionLayoutSaveKind, } from "./section-layout.interface.js";
|
|
15
16
|
export const sectionRotationInputSchema = z.strictObject({
|
|
16
17
|
sectionId: z.uuid(),
|
|
17
18
|
rotationDeg: z.number().int().min(SectionRotation.min).max(SectionRotation.max),
|
|
18
19
|
});
|
|
20
|
+
const sectionGripRotationInputSchema = z.strictObject({
|
|
21
|
+
sectionId: z.uuid(),
|
|
22
|
+
rotationDeltaDeg: z.number().min(SectionRotation.min).max(SectionRotation.max),
|
|
23
|
+
});
|
|
19
24
|
const sectionScaleInputSchema = z.strictObject({
|
|
20
25
|
sectionId: z.uuid(),
|
|
21
26
|
scalePercent: z.number().min(SectionScale.min).max(SectionScale.max),
|
|
22
27
|
});
|
|
23
|
-
export const
|
|
28
|
+
export const sectionCornerScaleInputSchema = z.strictObject({
|
|
29
|
+
sectionId: z.uuid(),
|
|
30
|
+
scaleFactor: z.number().positive(),
|
|
31
|
+
pivotM: pointSchema,
|
|
32
|
+
});
|
|
33
|
+
export const sectionTransformInputSchema = z.union([
|
|
34
|
+
sectionRotationInputSchema,
|
|
35
|
+
sectionGripRotationInputSchema,
|
|
36
|
+
sectionScaleInputSchema,
|
|
37
|
+
sectionCornerScaleInputSchema,
|
|
38
|
+
]);
|
|
24
39
|
export const sectionLayoutInputSchema = z.union([
|
|
25
40
|
sectionRefitInputSchema,
|
|
26
41
|
sectionTransformInputSchema,
|
|
@@ -37,37 +52,51 @@ export const sectionLayoutSaveSchema = z.discriminatedUnion("kind", [
|
|
|
37
52
|
beforeRevision: z.number().int().positive(),
|
|
38
53
|
}),
|
|
39
54
|
]);
|
|
40
|
-
|
|
55
|
+
export function sectionCornerScaleMinimum(document, sectionId) {
|
|
56
|
+
const entry = sectionCatalog(document).entries.get(sectionId);
|
|
57
|
+
return minimumCornerScale(document, entry?.editableObjects ?? new Set());
|
|
58
|
+
}
|
|
59
|
+
/** Transform the existing outline and its editable contents. */
|
|
41
60
|
export function transformSection(document, input) {
|
|
42
61
|
const { sectionId } = input;
|
|
43
62
|
const section = document.sections.find(({ id }) => id === sectionId);
|
|
44
63
|
if (!section?.outline)
|
|
45
64
|
return;
|
|
46
65
|
const { outline } = section;
|
|
47
|
-
const currentScale = section.scalePercent ?? SectionScale.initial;
|
|
48
|
-
const currentRotation = section.rotationDeg ?? SectionRotation.initial;
|
|
49
|
-
const scaling = "scalePercent" in input;
|
|
50
|
-
if (scaling ? input.scalePercent === currentScale : input.rotationDeg === currentRotation)
|
|
51
|
-
return document;
|
|
52
66
|
const entry = sectionCatalog(document).entries.get(sectionId);
|
|
53
|
-
|
|
67
|
+
if ("scaleFactor" in input) {
|
|
68
|
+
const factor = Math.max(minimumCornerScale(document, entry.editableObjects), input.scaleFactor);
|
|
69
|
+
if (factor === 1)
|
|
70
|
+
return document;
|
|
71
|
+
return scaleSectionLayout(document, sectionId, entry.editableObjects, { pivot: input.pivotM, factor });
|
|
72
|
+
}
|
|
73
|
+
const gripRotation = "rotationDeltaDeg" in input;
|
|
74
|
+
const curved = !gripRotation && (outline.edgeCurvature?.some(Boolean) || polygonCornerFillets(outline).some(Boolean));
|
|
54
75
|
const sampleCenter = curved ? sectionOutlineSampleCenter(outline, sectionOutlineSamplingScale(section)) : undefined;
|
|
55
|
-
if (
|
|
76
|
+
if ("scalePercent" in input) {
|
|
56
77
|
const { scalePercent } = input;
|
|
78
|
+
const currentScale = section.scalePercent ?? SectionScale.initial;
|
|
79
|
+
if (scalePercent === currentScale)
|
|
80
|
+
return document;
|
|
57
81
|
const factor = scalePercent / currentScale;
|
|
58
82
|
const { minX, minY, maxX, maxY } = pointsBounds(outline.outer);
|
|
59
83
|
const pivot = sampleCenter ?? { x: (minX + maxX) / 2, y: (minY + maxY) / 2 };
|
|
60
|
-
return scaleSectionLayout(document, sectionId, entry.editableObjects, pivot,
|
|
84
|
+
return scaleSectionLayout(document, sectionId, entry.editableObjects, { pivot, factor, scalePercent });
|
|
61
85
|
}
|
|
62
|
-
const
|
|
63
|
-
|
|
86
|
+
const delta = gripRotation
|
|
87
|
+
? input.rotationDeltaDeg
|
|
88
|
+
: input.rotationDeg - (section.rotationDeg ?? SectionRotation.initial);
|
|
89
|
+
if (delta === 0)
|
|
90
|
+
return document;
|
|
64
91
|
const rotated = transformLayout(document, {
|
|
65
92
|
sections: [sectionId],
|
|
66
93
|
objects: [...compactRowTargets(document, entry.editableObjects)],
|
|
67
94
|
pivot: sampleCenter ?? sectionOutlinePivot(outline),
|
|
68
95
|
}, { x: 0, y: 0 }, delta);
|
|
96
|
+
if (gripRotation)
|
|
97
|
+
return rotated;
|
|
69
98
|
return {
|
|
70
99
|
...rotated,
|
|
71
|
-
sections: rotated.sections.map((item) =>
|
|
100
|
+
sections: rotated.sections.map((item) => item.id === sectionId ? { ...item, rotationDeg: input.rotationDeg } : item),
|
|
72
101
|
};
|
|
73
102
|
}
|
package/dist/section-scale.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import { type PhysicalDocumentV1, type PointM, type UUID } from "./physical-document.interface.js";
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function minimumCornerScale(document: PhysicalDocumentV1, targets: ReadonlySet<UUID>): number;
|
|
3
|
+
export declare function scaleSectionLayout(document: PhysicalDocumentV1, sectionId: UUID, targets: ReadonlySet<UUID>, { pivot, factor, scalePercent }: {
|
|
4
|
+
pivot: PointM;
|
|
5
|
+
factor: number;
|
|
6
|
+
scalePercent?: number;
|
|
7
|
+
}): PhysicalDocumentV1;
|
package/dist/section-scale.js
CHANGED
|
@@ -4,16 +4,37 @@ import { LayoutUnitM } from "./geometry/units.js";
|
|
|
4
4
|
import { AreaKind, DecorationKind, SeatingKind, ShapeKind, } from "./physical-document.interface.js";
|
|
5
5
|
const SectionPitchUnits = { min: 14, max: 80 };
|
|
6
6
|
const SectionRoundRadiusUnitsMin = 18;
|
|
7
|
-
|
|
7
|
+
// A corner drag can reduce an empty Section to 10%. Rows stop at a 16-unit seat pitch.
|
|
8
|
+
const CornerMinimumFactor = 0.1;
|
|
9
|
+
const CornerMinimumPitchM = 16 * LayoutUnitM;
|
|
10
|
+
export function minimumCornerScale(document, targets) {
|
|
11
|
+
let minimum = CornerMinimumFactor;
|
|
12
|
+
for (const group of document.seatingGroups) {
|
|
13
|
+
if (!("rows" in group))
|
|
14
|
+
continue;
|
|
15
|
+
for (const [index, row] of group.rows.entries()) {
|
|
16
|
+
if (!targets.has(row.id))
|
|
17
|
+
continue;
|
|
18
|
+
const layout = resolveRowLayout(group, index);
|
|
19
|
+
if (layout)
|
|
20
|
+
minimum = Math.max(minimum, CornerMinimumPitchM / layout.seatPitchM);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return Math.min(1, minimum);
|
|
24
|
+
}
|
|
25
|
+
export function scaleSectionLayout(document, sectionId, targets, { pivot, factor, scalePercent }) {
|
|
26
|
+
const numericScale = scalePercent !== undefined;
|
|
8
27
|
const scalePoint = (point, origin = pivot) => ({
|
|
9
28
|
x: origin.x + (point.x - origin.x) * factor,
|
|
10
29
|
y: origin.y + (point.y - origin.y) * factor,
|
|
11
30
|
});
|
|
12
31
|
const scaleLocalPoint = ({ x, y }) => ({ x: x * factor, y: y * factor });
|
|
32
|
+
const scaleSize = ({ width, height }) => ({ width: width * factor, height: height * factor });
|
|
13
33
|
const scalePolygon = (polygon, mapPoint) => ({
|
|
14
34
|
...polygon,
|
|
15
35
|
outer: polygon.outer.map(mapPoint),
|
|
16
36
|
holes: polygon.holes.map((ring) => ring.map(mapPoint)),
|
|
37
|
+
...(!numericScale && polygon.cornerRadiusM !== undefined && { cornerRadiusM: polygon.cornerRadiusM * factor }),
|
|
17
38
|
});
|
|
18
39
|
const matrices = worldMatrices(document);
|
|
19
40
|
const moveDrawable = (entity) => {
|
|
@@ -26,34 +47,73 @@ export function scaleSectionLayout(document, sectionId, targets, pivot, scalePer
|
|
|
26
47
|
if (!targets.has(area.id))
|
|
27
48
|
return area;
|
|
28
49
|
const moved = moveDrawable(area);
|
|
29
|
-
if (moved.kind !== AreaKind.GeneralAdmission)
|
|
50
|
+
if (numericScale && moved.kind !== AreaKind.GeneralAdmission)
|
|
30
51
|
return moved;
|
|
31
52
|
const { shape } = moved;
|
|
53
|
+
if (shape.kind === ShapeKind.Polygon) {
|
|
54
|
+
return { ...moved, shape: { ...shape, boundary: scalePolygon(shape.boundary, scaleLocalPoint) } };
|
|
55
|
+
}
|
|
32
56
|
return {
|
|
33
57
|
...moved,
|
|
34
|
-
shape:
|
|
35
|
-
|
|
36
|
-
|
|
58
|
+
shape: {
|
|
59
|
+
...shape,
|
|
60
|
+
widthM: shape.widthM * factor,
|
|
61
|
+
heightM: shape.heightM * factor,
|
|
62
|
+
cornerRadiusM: numericScale ? shape.cornerRadiusM : shape.cornerRadiusM * factor,
|
|
63
|
+
},
|
|
37
64
|
};
|
|
38
65
|
};
|
|
39
66
|
const scaleArtwork = (art) => {
|
|
40
67
|
if (!targets.has(art.id))
|
|
41
68
|
return art;
|
|
42
69
|
const moved = moveDrawable(art);
|
|
43
|
-
if (moved.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
70
|
+
if (!numericScale && moved.style?.strokeWidthM !== undefined) {
|
|
71
|
+
moved.style = { ...moved.style, strokeWidthM: moved.style.strokeWidthM * factor };
|
|
72
|
+
}
|
|
73
|
+
switch (moved.kind) {
|
|
74
|
+
case DecorationKind.Line:
|
|
75
|
+
return { ...moved, pointsM: moved.pointsM.map(scaleLocalPoint) };
|
|
76
|
+
case DecorationKind.Polygon: {
|
|
77
|
+
const result = { ...moved, boundary: scalePolygon(moved.boundary, scaleLocalPoint) };
|
|
78
|
+
if (!numericScale && moved.stage?.sizeM)
|
|
79
|
+
result.stage = { ...moved.stage, sizeM: scaleSize(moved.stage.sizeM) };
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
case DecorationKind.Rectangle:
|
|
83
|
+
return numericScale
|
|
84
|
+
? moved
|
|
85
|
+
: { ...moved, sizeM: scaleSize(moved.sizeM), cornerRadiusM: moved.cornerRadiusM * factor };
|
|
86
|
+
case DecorationKind.Circle:
|
|
87
|
+
return numericScale ? moved : { ...moved, radiusM: moved.radiusM * factor };
|
|
88
|
+
case DecorationKind.Text:
|
|
89
|
+
return numericScale ? moved : { ...moved, fontSizeM: moved.fontSizeM * factor };
|
|
90
|
+
case DecorationKind.Icon:
|
|
91
|
+
case DecorationKind.Image:
|
|
92
|
+
return numericScale ? moved : { ...moved, sizeM: scaleSize(moved.sizeM) };
|
|
93
|
+
}
|
|
48
94
|
};
|
|
49
95
|
const scaleGroup = (group) => {
|
|
50
96
|
if (group.kind === SeatingKind.Round || group.kind === SeatingKind.Rectangular) {
|
|
51
97
|
if (!targets.has(group.id))
|
|
52
98
|
return group;
|
|
53
|
-
if (group.kind === SeatingKind.Rectangular)
|
|
54
|
-
|
|
99
|
+
if (group.kind === SeatingKind.Rectangular) {
|
|
100
|
+
if (numericScale)
|
|
101
|
+
return moveDrawable(group);
|
|
102
|
+
const { widthM, depthM, chairPitchM } = group.recipe;
|
|
103
|
+
return moveDrawable({
|
|
104
|
+
...group,
|
|
105
|
+
recipe: {
|
|
106
|
+
...group.recipe,
|
|
107
|
+
widthM: widthM * factor,
|
|
108
|
+
depthM: depthM * factor,
|
|
109
|
+
...(chairPitchM !== undefined && { chairPitchM: chairPitchM * factor }),
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
}
|
|
55
113
|
const radiusUnits = Math.round((group.recipe.diameterM / (2 * LayoutUnitM)) * factor);
|
|
56
|
-
const diameterM =
|
|
114
|
+
const diameterM = numericScale
|
|
115
|
+
? 2 * Math.max(SectionRoundRadiusUnitsMin, radiusUnits) * LayoutUnitM
|
|
116
|
+
: group.recipe.diameterM * factor;
|
|
57
117
|
return moveDrawable({ ...group, recipe: { ...group.recipe, diameterM } });
|
|
58
118
|
}
|
|
59
119
|
if (!group.rows.some(({ id }) => targets.has(id)))
|
|
@@ -90,7 +150,9 @@ export function scaleSectionLayout(document, sectionId, targets, pivot, scalePer
|
|
|
90
150
|
const offset = rowPlacementOffset(group, index, row.offsetM);
|
|
91
151
|
const origin = scalePoint({ x: layout.originM.x + offset.x, y: layout.originM.y + offset.y }, localPivot);
|
|
92
152
|
const pitchUnits = Math.round((layout.seatPitchM / LayoutUnitM) * factor);
|
|
93
|
-
const seatPitchM =
|
|
153
|
+
const seatPitchM = numericScale
|
|
154
|
+
? Math.min(SectionPitchUnits.max, Math.max(SectionPitchUnits.min, pitchUnits)) * LayoutUnitM
|
|
155
|
+
: layout.seatPitchM * factor;
|
|
94
156
|
return {
|
|
95
157
|
...row,
|
|
96
158
|
layout: { ...layout, originM: { x: origin.x - offset.x, y: origin.y - offset.y }, seatPitchM },
|
|
@@ -114,7 +176,7 @@ export function scaleSectionLayout(document, sectionId, targets, pivot, scalePer
|
|
|
114
176
|
return section;
|
|
115
177
|
return {
|
|
116
178
|
...section,
|
|
117
|
-
scalePercent,
|
|
179
|
+
...(numericScale && { scalePercent }),
|
|
118
180
|
outline: scalePolygon(section.outline, (point) => scalePoint(point)),
|
|
119
181
|
...(section.labelPlacement
|
|
120
182
|
? { labelPlacement: { ...section.labelPlacement, positionM: scalePoint(section.labelPlacement.positionM) } }
|
package/dist/sections.js
CHANGED
|
@@ -87,12 +87,13 @@ export function sectionCatalog(document) {
|
|
|
87
87
|
y: sum.y + point.y / art.pointsM.length,
|
|
88
88
|
}), { x: 0, y: 0 }));
|
|
89
89
|
}
|
|
90
|
-
else if (!rectangularGate)
|
|
90
|
+
else if (art.kind !== DecorationKind.Text && !rectangularGate)
|
|
91
91
|
point = center(decorationBounds(art, matrix));
|
|
92
92
|
anchors.push({
|
|
93
93
|
id: art.id,
|
|
94
94
|
floorId: art.floorId ?? null,
|
|
95
95
|
point,
|
|
96
|
+
decorationKind: art.kind,
|
|
96
97
|
rectangularGate,
|
|
97
98
|
parentId: art.parentId,
|
|
98
99
|
});
|
|
@@ -139,12 +140,14 @@ export function sectionCatalog(document) {
|
|
|
139
140
|
return catalog;
|
|
140
141
|
}
|
|
141
142
|
function containsAnchor(boundary, anchor) {
|
|
142
|
-
|
|
143
|
+
const textOrLine = anchor.decorationKind === DecorationKind.Text || anchor.decorationKind === DecorationKind.Line;
|
|
144
|
+
if (!textOrLine && !anchor.rectangularGate)
|
|
143
145
|
return classifyBoundary(boundary, anchor.point) !== BoundaryLocation.Outside;
|
|
144
|
-
//
|
|
146
|
+
// Text and line anchors use the half-open outline and exclude every cutout wall.
|
|
145
147
|
const { outer, holes } = boundary.polygon;
|
|
148
|
+
const holeEdges = anchor.rectangularGate ? RingEdgeMode.HalfOpen : RingEdgeMode.Closed;
|
|
146
149
|
return (containsPoint(outer, anchor.point, RingEdgeMode.HalfOpen) &&
|
|
147
|
-
!holes.some((hole) => containsPoint(hole, anchor.point,
|
|
150
|
+
!holes.some((hole) => containsPoint(hole, anchor.point, holeEdges)));
|
|
148
151
|
}
|
|
149
152
|
function center(bounds) {
|
|
150
153
|
return { x: (bounds.minX + bounds.maxX) / 2, y: (bounds.minY + bounds.maxY) / 2 };
|