@twinfinity/printing 5.0.3-ci.28538-beta
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/README.md +208 -0
- package/dist/BuildInfo.d.ts +25 -0
- package/dist/BuildInfo.d.ts.map +1 -0
- package/dist/BuildInfo.js +15 -0
- package/dist/BuildInfo.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/layout/analyzeTemplate.d.ts +29 -0
- package/dist/layout/analyzeTemplate.d.ts.map +1 -0
- package/dist/layout/analyzeTemplate.js +168 -0
- package/dist/layout/analyzeTemplate.js.map +1 -0
- package/dist/layout/clipUtils.d.ts +18 -0
- package/dist/layout/clipUtils.d.ts.map +1 -0
- package/dist/layout/clipUtils.js +165 -0
- package/dist/layout/clipUtils.js.map +1 -0
- package/dist/layout/colorConstants.d.ts +11 -0
- package/dist/layout/colorConstants.d.ts.map +1 -0
- package/dist/layout/colorConstants.js +14 -0
- package/dist/layout/colorConstants.js.map +1 -0
- package/dist/layout/elementKinds.d.ts +21 -0
- package/dist/layout/elementKinds.d.ts.map +1 -0
- package/dist/layout/elementKinds.js +17 -0
- package/dist/layout/elementKinds.js.map +1 -0
- package/dist/layout/exportDrawing.d.ts +143 -0
- package/dist/layout/exportDrawing.d.ts.map +1 -0
- package/dist/layout/exportDrawing.js +146 -0
- package/dist/layout/exportDrawing.js.map +1 -0
- package/dist/layout/filters.d.ts +33 -0
- package/dist/layout/filters.d.ts.map +1 -0
- package/dist/layout/filters.js +77 -0
- package/dist/layout/filters.js.map +1 -0
- package/dist/layout/geometryConstants.d.ts +8 -0
- package/dist/layout/geometryConstants.d.ts.map +1 -0
- package/dist/layout/geometryConstants.js +10 -0
- package/dist/layout/geometryConstants.js.map +1 -0
- package/dist/layout/index.d.ts +86 -0
- package/dist/layout/index.d.ts.map +1 -0
- package/dist/layout/index.js +363 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/layout/itemBuilders.d.ts +29 -0
- package/dist/layout/itemBuilders.d.ts.map +1 -0
- package/dist/layout/itemBuilders.js +135 -0
- package/dist/layout/itemBuilders.js.map +1 -0
- package/dist/layout/labelsRender.d.ts +29 -0
- package/dist/layout/labelsRender.d.ts.map +1 -0
- package/dist/layout/labelsRender.js +109 -0
- package/dist/layout/labelsRender.js.map +1 -0
- package/dist/layout/legendConstants.d.ts +12 -0
- package/dist/layout/legendConstants.d.ts.map +1 -0
- package/dist/layout/legendConstants.js +12 -0
- package/dist/layout/legendConstants.js.map +1 -0
- package/dist/layout/legendRender.d.ts +13 -0
- package/dist/layout/legendRender.d.ts.map +1 -0
- package/dist/layout/legendRender.js +424 -0
- package/dist/layout/legendRender.js.map +1 -0
- package/dist/layout/legendRows.d.ts +26 -0
- package/dist/layout/legendRows.d.ts.map +1 -0
- package/dist/layout/legendRows.js +45 -0
- package/dist/layout/legendRows.js.map +1 -0
- package/dist/layout/legendUtils.d.ts +21 -0
- package/dist/layout/legendUtils.d.ts.map +1 -0
- package/dist/layout/legendUtils.js +110 -0
- package/dist/layout/legendUtils.js.map +1 -0
- package/dist/layout/metadata.d.ts +43 -0
- package/dist/layout/metadata.d.ts.map +1 -0
- package/dist/layout/metadata.js +191 -0
- package/dist/layout/metadata.js.map +1 -0
- package/dist/layout/model.d.ts +15 -0
- package/dist/layout/model.d.ts.map +1 -0
- package/dist/layout/model.js +310 -0
- package/dist/layout/model.js.map +1 -0
- package/dist/layout/options.d.ts +17 -0
- package/dist/layout/options.d.ts.map +1 -0
- package/dist/layout/options.js +2 -0
- package/dist/layout/options.js.map +1 -0
- package/dist/layout/presets.d.ts +23 -0
- package/dist/layout/presets.d.ts.map +1 -0
- package/dist/layout/presets.js +41 -0
- package/dist/layout/presets.js.map +1 -0
- package/dist/layout/qrRender.d.ts +13 -0
- package/dist/layout/qrRender.d.ts.map +1 -0
- package/dist/layout/qrRender.js +97 -0
- package/dist/layout/qrRender.js.map +1 -0
- package/dist/layout/renderDrawing.d.ts +62 -0
- package/dist/layout/renderDrawing.d.ts.map +1 -0
- package/dist/layout/renderDrawing.js +555 -0
- package/dist/layout/renderDrawing.js.map +1 -0
- package/dist/layout/renderUtils.d.ts +36 -0
- package/dist/layout/renderUtils.d.ts.map +1 -0
- package/dist/layout/renderUtils.js +117 -0
- package/dist/layout/renderUtils.js.map +1 -0
- package/dist/layout/sectionValidation.d.ts +3 -0
- package/dist/layout/sectionValidation.d.ts.map +1 -0
- package/dist/layout/sectionValidation.js +2 -0
- package/dist/layout/sectionValidation.js.map +1 -0
- package/dist/layout/templateVariables.d.ts +137 -0
- package/dist/layout/templateVariables.d.ts.map +1 -0
- package/dist/layout/templateVariables.js +295 -0
- package/dist/layout/templateVariables.js.map +1 -0
- package/dist/layout/typeGuards.d.ts +5 -0
- package/dist/layout/typeGuards.d.ts.map +1 -0
- package/dist/layout/typeGuards.js +9 -0
- package/dist/layout/typeGuards.js.map +1 -0
- package/dist/layout/types.d.ts +816 -0
- package/dist/layout/types.d.ts.map +1 -0
- package/dist/layout/types.js +2 -0
- package/dist/layout/types.js.map +1 -0
- package/dist/layout/utils.d.ts +9 -0
- package/dist/layout/utils.d.ts.map +1 -0
- package/dist/layout/utils.js +84 -0
- package/dist/layout/utils.js.map +1 -0
- package/dist/layout/validation.d.ts +7 -0
- package/dist/layout/validation.d.ts.map +1 -0
- package/dist/layout/validation.js +352 -0
- package/dist/layout/validation.js.map +1 -0
- package/dist/layout/validationHelpers.d.ts +15 -0
- package/dist/layout/validationHelpers.d.ts.map +1 -0
- package/dist/layout/validationHelpers.js +43 -0
- package/dist/layout/validationHelpers.js.map +1 -0
- package/dist/layout/validationUtils.d.ts +5 -0
- package/dist/layout/validationUtils.d.ts.map +1 -0
- package/dist/layout/validationUtils.js +5 -0
- package/dist/layout/validationUtils.js.map +1 -0
- package/dist/layout/viewportPrep.d.ts +47 -0
- package/dist/layout/viewportPrep.d.ts.map +1 -0
- package/dist/layout/viewportPrep.js +275 -0
- package/dist/layout/viewportPrep.js.map +1 -0
- package/dist/layout/viewportRender.d.ts +42 -0
- package/dist/layout/viewportRender.d.ts.map +1 -0
- package/dist/layout/viewportRender.js +337 -0
- package/dist/layout/viewportRender.js.map +1 -0
- package/dist/layout/viewportUtils.d.ts +9 -0
- package/dist/layout/viewportUtils.d.ts.map +1 -0
- package/dist/layout/viewportUtils.js +40 -0
- package/dist/layout/viewportUtils.js.map +1 -0
- package/dist/layout/warnings.d.ts +2 -0
- package/dist/layout/warnings.d.ts.map +1 -0
- package/dist/layout/warnings.js +4 -0
- package/dist/layout/warnings.js.map +1 -0
- package/dist/printToPdf.d.ts +38 -0
- package/dist/printToPdf.d.ts.map +1 -0
- package/dist/printToPdf.js +79 -0
- package/dist/printToPdf.js.map +1 -0
- package/dist/printToSvg.d.ts +11 -0
- package/dist/printToSvg.d.ts.map +1 -0
- package/dist/printToSvg.js +168 -0
- package/dist/printToSvg.js.map +1 -0
- package/dist/sections.d.ts +118 -0
- package/dist/sections.d.ts.map +1 -0
- package/dist/sections.js +839 -0
- package/dist/sections.js.map +1 -0
- package/dist/templates/default-template.json +137 -0
- package/dist/types.d.ts +54 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/package.json +47 -0
- package/src/BuildInfo.ts +41 -0
- package/src/index.ts +10 -0
- package/src/layout/analyzeTemplate.ts +218 -0
- package/src/layout/clipUtils.ts +193 -0
- package/src/layout/colorConstants.ts +16 -0
- package/src/layout/elementKinds.ts +35 -0
- package/src/layout/exportDrawing.ts +206 -0
- package/src/layout/filters.ts +80 -0
- package/src/layout/geometryConstants.ts +11 -0
- package/src/layout/index.ts +671 -0
- package/src/layout/itemBuilders.ts +159 -0
- package/src/layout/labelsRender.ts +170 -0
- package/src/layout/legendConstants.ts +11 -0
- package/src/layout/legendRender.ts +543 -0
- package/src/layout/legendRows.ts +62 -0
- package/src/layout/legendUtils.ts +144 -0
- package/src/layout/metadata.ts +210 -0
- package/src/layout/model.ts +372 -0
- package/src/layout/options.ts +17 -0
- package/src/layout/presets.ts +51 -0
- package/src/layout/qrRender.ts +126 -0
- package/src/layout/qrcode.d.ts +2 -0
- package/src/layout/renderDrawing.ts +710 -0
- package/src/layout/renderUtils.ts +138 -0
- package/src/layout/sectionValidation.ts +2 -0
- package/src/layout/templateVariables.ts +317 -0
- package/src/layout/typeGuards.ts +9 -0
- package/src/layout/types.ts +835 -0
- package/src/layout/utils.ts +85 -0
- package/src/layout/validation.ts +392 -0
- package/src/layout/validationHelpers.ts +59 -0
- package/src/layout/validationUtils.ts +6 -0
- package/src/layout/viewportPrep.ts +351 -0
- package/src/layout/viewportRender.ts +442 -0
- package/src/layout/viewportUtils.ts +50 -0
- package/src/layout/warnings.ts +3 -0
- package/src/printToPdf.ts +108 -0
- package/src/printToSvg.ts +188 -0
- package/src/sections.ts +1019 -0
- package/src/templates/default-template.json +137 -0
- package/src/types.ts +49 -0
- package/templates/default-a0-landscape.json +209 -0
- package/templates/default-a0-portrait.json +195 -0
- package/templates/default-a1-landscape.json +167 -0
- package/templates/default-a1-portrait.json +153 -0
- package/templates/default-a3-landscape.json +111 -0
- package/templates/default-a3-portrait.json +125 -0
- package/templates/default-a4-landscape.json +97 -0
- package/templates/default-a4-portrait.json +97 -0
- package/templates/template-schema.json +1395 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewportRender.d.ts","sourceRoot":"/","sources":["layout/viewportRender.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAG1F,KAAK,SAAS,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AA8B1C,eAAO,MAAM,qBAAqB,GAC9B,IAAI,eAAe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B,CAAC,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IACzC,iBAAiB,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IAC5C,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACvG,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC/B,KACF,MAAM,EAqPR,CAAC"}
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { escapeAttr, getPathValue, resolvePath } from './renderUtils';
|
|
2
|
+
import { rotateBounds, pickScale } from './viewportUtils';
|
|
3
|
+
import { matchesV2Filter } from './filters';
|
|
4
|
+
import { isRecord, getProp } from './typeGuards';
|
|
5
|
+
// Debug overlay for clip polygons. Keep false for normal builds.
|
|
6
|
+
const DEBUG_CLIP_OVERLAY = false;
|
|
7
|
+
const matTranslate = (tx, ty) => [1, 0, 0, 1, tx, ty];
|
|
8
|
+
const matScale = (sx, sy) => [sx, 0, 0, sy, 0, 0];
|
|
9
|
+
const matRotateDeg = (deg) => {
|
|
10
|
+
const rad = (deg * Math.PI) / 180;
|
|
11
|
+
const c = Math.cos(rad);
|
|
12
|
+
const s = Math.sin(rad);
|
|
13
|
+
return [c, s, -s, c, 0, 0];
|
|
14
|
+
};
|
|
15
|
+
const matMultiply = (m1, m2) => {
|
|
16
|
+
const [a1, b1, c1, d1, e1, f1] = m1;
|
|
17
|
+
const [a2, b2, c2, d2, e2, f2] = m2;
|
|
18
|
+
return [
|
|
19
|
+
a1 * a2 + c1 * b2,
|
|
20
|
+
b1 * a2 + d1 * b2,
|
|
21
|
+
a1 * c2 + c1 * d2,
|
|
22
|
+
b1 * c2 + d1 * d2,
|
|
23
|
+
a1 * e2 + c1 * f2 + e1,
|
|
24
|
+
b1 * e2 + d1 * f2 + f1
|
|
25
|
+
];
|
|
26
|
+
};
|
|
27
|
+
const matApply = (m, p) => {
|
|
28
|
+
const [a, b, c, d, e, f] = m;
|
|
29
|
+
return { x: a * p.x + c * p.y + e, y: b * p.x + d * p.y + f };
|
|
30
|
+
};
|
|
31
|
+
export const renderViewportElement = (vp, baseModel, dataWithViewport, preferredScales, scales, assetMap, viewportScales, viewportClipPolygonsLocal, viewportClipBounds, viewportClipLabels, viewportClipStyles, viewportHighlight, viewportRenderInfo, warnings, legendColorMaps, precomputed) => {
|
|
32
|
+
const parts = [];
|
|
33
|
+
if (!baseModel) {
|
|
34
|
+
// Warning already pushed by viewportPrep; avoid duplicate.
|
|
35
|
+
return parts;
|
|
36
|
+
}
|
|
37
|
+
const model = baseModel;
|
|
38
|
+
let renderWidthModel = precomputed?.effectiveWidthModel ?? model.widthModel;
|
|
39
|
+
let renderHeightModel = precomputed?.effectiveHeightModel ?? model.heightModel;
|
|
40
|
+
let renderCenterModelX = precomputed?.renderCenterModelX ?? renderWidthModel * 0.5;
|
|
41
|
+
let renderCenterModelY = precomputed?.renderCenterModelY ?? renderHeightModel * 0.5;
|
|
42
|
+
const clipBounds = viewportClipBounds[vp.id];
|
|
43
|
+
const clipLocal = viewportClipPolygonsLocal[vp.id];
|
|
44
|
+
const hasClip = !!clipBounds && Array.isArray(clipLocal) && clipLocal.length > 0;
|
|
45
|
+
if (hasClip) {
|
|
46
|
+
renderWidthModel = clipBounds.width;
|
|
47
|
+
renderHeightModel = clipBounds.height;
|
|
48
|
+
renderCenterModelX = (clipBounds.minX + clipBounds.maxX) * 0.5;
|
|
49
|
+
renderCenterModelY = (clipBounds.minY + clipBounds.maxY) * 0.5;
|
|
50
|
+
}
|
|
51
|
+
const scaleInfo = viewportScales[vp.id] ??
|
|
52
|
+
pickScale(vp, { ...model, widthModel: renderWidthModel, heightModel: renderHeightModel }, preferredScales, scales);
|
|
53
|
+
const rotationDeg = vp.rotationDeg ?? 0;
|
|
54
|
+
const mmPerModel = scaleInfo.mmPerModelUnit;
|
|
55
|
+
const contentWidthMm = renderWidthModel * mmPerModel;
|
|
56
|
+
const contentHeightMm = renderHeightModel * mmPerModel;
|
|
57
|
+
const rotated = rotateBounds(contentWidthMm, contentHeightMm, rotationDeg);
|
|
58
|
+
const centerX = vp.align === 'topLeft' ? vp.xMm + rotated.width / 2 : vp.xMm + vp.widthMm / 2;
|
|
59
|
+
const centerY = vp.align === 'topLeft' ? vp.yMm + rotated.height / 2 : vp.yMm + vp.heightMm / 2;
|
|
60
|
+
const contentOffsetX = vp.align === 'topLeft' ? vp.xMm : vp.xMm + Math.max(0, (vp.widthMm - rotated.width) * 0.5);
|
|
61
|
+
const contentOffsetY = vp.align === 'topLeft' ? vp.yMm : vp.yMm + Math.max(0, (vp.heightMm - rotated.height) * 0.5);
|
|
62
|
+
const clipPolysLocal = clipLocal;
|
|
63
|
+
let clipId = null;
|
|
64
|
+
const clipDebugPolys = [];
|
|
65
|
+
const clipStyle = viewportClipStyles[vp.id];
|
|
66
|
+
const clipStroke = clipStyle?.stroke;
|
|
67
|
+
const clipStrokeWidth = clipStyle?.strokeWidthMm;
|
|
68
|
+
const clipStrokeOpacity = clipStyle?.strokeOpacity;
|
|
69
|
+
const clipFill = clipStyle?.fill;
|
|
70
|
+
const clipFillOpacity = clipStyle?.fillOpacity;
|
|
71
|
+
const transformAttr = `translate(${centerX} ${centerY}) rotate(${rotationDeg}) scale(${mmPerModel}) translate(${-renderCenterModelX} ${-renderCenterModelY})`;
|
|
72
|
+
// Debug: log model bounds and path breakdown
|
|
73
|
+
// if (model.transform) {
|
|
74
|
+
// console.log(`[DEBUG MODEL vp="${vp.id}"] Model bounds: viewMinX=${model.transform.viewMinX.toFixed(2)} viewMaxX=${model.transform.viewMaxX?.toFixed(2)} viewMinZ=${model.transform.viewMinZ.toFixed(2)} viewMaxZ=${model.transform.viewMaxZ.toFixed(2)} viewWidth=${model.transform.viewWidth.toFixed(2)} viewHeight=${model.transform.viewHeight.toFixed(2)}`);
|
|
75
|
+
// if (model.rawPaths) {
|
|
76
|
+
// const fills = model.rawPaths.filter(p => p.meta?.isFill);
|
|
77
|
+
// const segments = model.rawPaths.filter(p => p.meta?.isSegment);
|
|
78
|
+
// const other = model.rawPaths.filter(p => !p.meta?.isFill && !p.meta?.isSegment);
|
|
79
|
+
// console.log(`[DEBUG MODEL vp="${vp.id}"] Path breakdown: ${model.rawPaths.length} total (${fills.length} fills, ${segments.length} segments, ${other.length} other)`);
|
|
80
|
+
// // Sample a few segment paths
|
|
81
|
+
// const sampleSegments = segments.slice(0, 3);
|
|
82
|
+
// sampleSegments.forEach((seg, idx) => {
|
|
83
|
+
// console.log(`[DEBUG MODEL vp="${vp.id}"] Segment ${idx}: class=${seg.meta?.class} fill=${seg.fill} stroke=${seg.stroke} strokeWidth=${seg.strokeWidth} d=${seg.d.substring(0, 50)}...`);
|
|
84
|
+
// });
|
|
85
|
+
// // Check if geometryTransform is present
|
|
86
|
+
// if (model.geometryTransform) {
|
|
87
|
+
// console.log(`[DEBUG MODEL vp="${vp.id}"] geometryTransform="${model.geometryTransform}"`);
|
|
88
|
+
// } else {
|
|
89
|
+
// console.log(`[DEBUG MODEL vp="${vp.id}"] WARNING: geometryTransform is MISSING!`);
|
|
90
|
+
// }
|
|
91
|
+
// }
|
|
92
|
+
// }
|
|
93
|
+
// Guard: detect NaN/Infinity in computed transform values
|
|
94
|
+
if (!Number.isFinite(centerX) ||
|
|
95
|
+
!Number.isFinite(centerY) ||
|
|
96
|
+
!Number.isFinite(mmPerModel) ||
|
|
97
|
+
!Number.isFinite(renderCenterModelX) ||
|
|
98
|
+
!Number.isFinite(renderCenterModelY)) {
|
|
99
|
+
warnings.push(`Viewport '${vp.id}' has non-finite transform values (centerX=${centerX}, centerY=${centerY}, mmPerModel=${mmPerModel}). Skipping render.`);
|
|
100
|
+
return parts;
|
|
101
|
+
}
|
|
102
|
+
// console.log(`[DEBUG CLIP APPLY vp="${vp.id}"] clipPolysLocal exists: ${!!clipPolysLocal}, length: ${clipPolysLocal?.length ?? 0}`);
|
|
103
|
+
if (clipPolysLocal && clipPolysLocal.length) {
|
|
104
|
+
// console.log(`[DEBUG CLIP APPLY vp="${vp.id}"] *** APPLYING CLIP-PATH *** with ${clipPolysLocal.length} polygons`);
|
|
105
|
+
if (clipPolysLocal.every((poly) => !poly.length)) {
|
|
106
|
+
warnings.push(`Viewport '${vp.id}' clip has no points after prep; skipping clip.`);
|
|
107
|
+
}
|
|
108
|
+
clipId = `clip-${vp.id}-${parts.length}`;
|
|
109
|
+
const polyPartsPage = [];
|
|
110
|
+
// Clip polygon points are in model-view coordinates (not SVG-internal),
|
|
111
|
+
// so transform them with outer only (model-view → page). Do NOT apply
|
|
112
|
+
// geometryTransform — that maps SVG-internal → model-view, which is only
|
|
113
|
+
// correct for path data inside the <g transform="geometryTransform"> group.
|
|
114
|
+
const outer = matMultiply(matTranslate(centerX, centerY), matMultiply(matRotateDeg(rotationDeg), matMultiply(matScale(mmPerModel, mmPerModel), matTranslate(-renderCenterModelX, -renderCenterModelY))));
|
|
115
|
+
// Debug: log clip polygon bounds
|
|
116
|
+
let clipMinX = Infinity, clipMaxX = -Infinity, clipMinY = Infinity, clipMaxY = -Infinity;
|
|
117
|
+
clipPolysLocal.forEach((poly) => {
|
|
118
|
+
poly.forEach((p) => {
|
|
119
|
+
if (p.x < clipMinX)
|
|
120
|
+
clipMinX = p.x;
|
|
121
|
+
if (p.x > clipMaxX)
|
|
122
|
+
clipMaxX = p.x;
|
|
123
|
+
if (p.y < clipMinY)
|
|
124
|
+
clipMinY = p.y;
|
|
125
|
+
if (p.y > clipMaxY)
|
|
126
|
+
clipMaxY = p.y;
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
// console.log(`[DEBUG CLIP vp="${vp.id}"] Local bounds: x=${clipMinX.toFixed(2)}..${clipMaxX.toFixed(2)} y=${clipMinY.toFixed(2)}..${clipMaxY.toFixed(2)} (w=${(clipMaxX - clipMinX).toFixed(2)} h=${(clipMaxY - clipMinY).toFixed(2)})`);
|
|
130
|
+
clipPolysLocal.forEach((poly) => {
|
|
131
|
+
const pagePtsArr = poly.map((p) => matApply(outer, p));
|
|
132
|
+
const pagePts = pagePtsArr.map((p) => `${p.x},${p.y}`).join(' ');
|
|
133
|
+
polyPartsPage.push(`<polygon points="${pagePts}" />`);
|
|
134
|
+
if (clipStroke || clipFill) {
|
|
135
|
+
clipDebugPolys.push(`<polygon points="${pagePts}"` +
|
|
136
|
+
(clipStroke ? ` stroke="${escapeAttr(clipStroke)}"` : '') +
|
|
137
|
+
(clipStrokeWidth ? ` stroke-width="${clipStrokeWidth}"` : '') +
|
|
138
|
+
(clipStrokeOpacity !== undefined ? ` stroke-opacity="${clipStrokeOpacity}"` : '') +
|
|
139
|
+
(clipFill ? ` fill="${escapeAttr(clipFill)}"` : ' fill="none"') +
|
|
140
|
+
(clipFillOpacity !== undefined ? ` fill-opacity="${clipFillOpacity}"` : '') +
|
|
141
|
+
` />`);
|
|
142
|
+
}
|
|
143
|
+
if (DEBUG_CLIP_OVERLAY) {
|
|
144
|
+
clipDebugPolys.push(`<polygon points="${pagePts}" stroke="#ff00ff" stroke-width="0.4" fill="#000000" fill-opacity="0.35" />`);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
parts.push(`<defs><clipPath id="${clipId}" clipPathUnits="userSpaceOnUse">${polyPartsPage.join('')}</clipPath></defs>`);
|
|
148
|
+
}
|
|
149
|
+
parts.push(`<g${clipId ? ` clip-path="url(#${clipId})"` : ''}>`);
|
|
150
|
+
parts.push(`<g transform="${transformAttr}">`);
|
|
151
|
+
// Render fill polygons below structural lines
|
|
152
|
+
const allowedGids = viewportHighlight[vp.id]?.gids ?? null;
|
|
153
|
+
const fillSvg = buildFillSvg(vp, dataWithViewport, model, allowedGids, legendColorMaps);
|
|
154
|
+
if (fillSvg)
|
|
155
|
+
parts.push(fillSvg);
|
|
156
|
+
// Debug: log sample path coordinates from model.groupSvg
|
|
157
|
+
if (clipId && model.rawPaths && model.rawPaths.length > 0) {
|
|
158
|
+
const asMeta = (m) => m != null && typeof m === 'object'
|
|
159
|
+
? m
|
|
160
|
+
: undefined;
|
|
161
|
+
const samplePath = model.rawPaths.find((p) => {
|
|
162
|
+
const pm = asMeta(p.meta);
|
|
163
|
+
return pm?.isSegment || (!pm?.isFill && !pm?.class);
|
|
164
|
+
});
|
|
165
|
+
if (samplePath) {
|
|
166
|
+
const dMatch = samplePath.d.match(/M([\d.-]+)\s+([\d.-]+)/);
|
|
167
|
+
if (dMatch) {
|
|
168
|
+
// console.log(`[DEBUG PATH vp="${vp.id}"] Sample wall path starts at x=${dMatch[1]} y=${dMatch[2]} (world coords, will be transformed by geometryTransform)`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// Compensate stroke-widths for the viewport scale transform.
|
|
173
|
+
// Paths have stroke-width in model units; the scale(mmPerModel) transform
|
|
174
|
+
// would make them thinner/thicker depending on zoom. Dividing by mmPerModel
|
|
175
|
+
// ensures strokes render at their intended mm size regardless of viewport scale.
|
|
176
|
+
const compensatedSvg = model.groupSvg.replace(/stroke-width="([0-9.eE+-]+)"/g, (_, w) => `stroke-width="${parseFloat(w) / mmPerModel}"`);
|
|
177
|
+
parts.push(compensatedSvg);
|
|
178
|
+
parts.push('</g>');
|
|
179
|
+
parts.push('</g>');
|
|
180
|
+
if (clipDebugPolys.length) {
|
|
181
|
+
parts.push(`<g pointer-events="none">${clipDebugPolys.join('')}</g>`);
|
|
182
|
+
}
|
|
183
|
+
viewportRenderInfo[vp.id] = {
|
|
184
|
+
mmPerModel,
|
|
185
|
+
contentWidthMm: rotated.width,
|
|
186
|
+
contentHeightMm: rotated.height,
|
|
187
|
+
offsetX: contentOffsetX,
|
|
188
|
+
offsetY: contentOffsetY,
|
|
189
|
+
rotationDeg,
|
|
190
|
+
transform: model.transform,
|
|
191
|
+
centerX,
|
|
192
|
+
centerY,
|
|
193
|
+
centerModelX: renderCenterModelX,
|
|
194
|
+
centerModelY: renderCenterModelY
|
|
195
|
+
};
|
|
196
|
+
if (vp.border) {
|
|
197
|
+
const borderStroke = vp.border.stroke ?? '#000';
|
|
198
|
+
const borderWidth = vp.border.strokeWidthMm ?? 0.25;
|
|
199
|
+
parts.push(`<rect x="${vp.xMm}" y="${vp.yMm}" width="${vp.widthMm}" height="${vp.heightMm}" stroke="${escapeAttr(borderStroke)}" stroke-width="${borderWidth}" fill="none"${vp.border.dashed ? ' stroke-dasharray="4 2"' : ''} />`);
|
|
200
|
+
}
|
|
201
|
+
if (vp.northArrow) {
|
|
202
|
+
const arrow = vp.northArrow;
|
|
203
|
+
const asset = assetMap.get(arrow.assetId);
|
|
204
|
+
const size = arrow.sizeMm ?? 12;
|
|
205
|
+
const offsetX = arrow.offsetXMm ?? 8;
|
|
206
|
+
const offsetY = arrow.offsetYMm ?? 8;
|
|
207
|
+
const arrowX = vp.xMm + vp.widthMm - offsetX - size;
|
|
208
|
+
const arrowY = vp.yMm + offsetY;
|
|
209
|
+
const arrowRotation = arrow.rotationDeg ?? 0;
|
|
210
|
+
if (!asset) {
|
|
211
|
+
warnings.push(`Missing asset '${arrow.assetId}' for north arrow on viewport '${vp.id}'.`);
|
|
212
|
+
}
|
|
213
|
+
else if (asset.src) {
|
|
214
|
+
parts.push(`<image href="${escapeAttr(asset.src)}" x="${arrowX}" y="${arrowY}" width="${size}" height="${size}" transform="rotate(${arrowRotation}, ${arrowX + size / 2}, ${arrowY + size / 2})" />`);
|
|
215
|
+
}
|
|
216
|
+
else if (asset.content) {
|
|
217
|
+
parts.push(`<g transform="translate(${arrowX} ${arrowY}) rotate(${arrowRotation} ${size / 2} ${size / 2})">${asset.content}</g>`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return parts;
|
|
221
|
+
};
|
|
222
|
+
// ---------------------------------------------------------------------------
|
|
223
|
+
// Fill polygon rendering
|
|
224
|
+
// ---------------------------------------------------------------------------
|
|
225
|
+
/**
|
|
226
|
+
* Build SVG fill polygons from viewport fill rules and item data.
|
|
227
|
+
* Returns an SVG fragment in model-view coordinates (same space as model.groupSvg),
|
|
228
|
+
* or null if no fills should be rendered.
|
|
229
|
+
*/
|
|
230
|
+
function buildFillSvg(vp, data, model, allowedGids, legendColorMaps) {
|
|
231
|
+
const fills = vp.fills;
|
|
232
|
+
if (!fills?.length || !model.transform)
|
|
233
|
+
return null;
|
|
234
|
+
const items = getPathValue(data, `viewports.${vp.id}.items`);
|
|
235
|
+
if (!Array.isArray(items) || !items.length)
|
|
236
|
+
return null;
|
|
237
|
+
const { viewMinX, viewMaxZ } = model.transform;
|
|
238
|
+
const parts = [];
|
|
239
|
+
for (const rule of fills) {
|
|
240
|
+
const opacity = rule.fillOpacity ?? 0.35;
|
|
241
|
+
// Find items matching this fill rule
|
|
242
|
+
let matching = items.filter((item) => isRecord(item) ? matchesV2Filter(item, rule.class, rule.where) : false);
|
|
243
|
+
// Filter by allowed GIDs (from clip polygon center point test)
|
|
244
|
+
// Only apply if BOTH: clip filtering is active AND this fill rule opts in via matchClipFilter
|
|
245
|
+
if (allowedGids !== null && rule.matchClipFilter === true) {
|
|
246
|
+
matching = matching.filter((item) => {
|
|
247
|
+
const gid = getProp(item, 'gid') ?? getProp(item, 'id');
|
|
248
|
+
return gid !== null && gid !== undefined && allowedGids.has(String(gid));
|
|
249
|
+
});
|
|
250
|
+
// console.log(`[DEBUG FILL vp="${vp.id}"] Clip filter applied (matchClipFilter=true): ${beforeFilter} → ${matching.length} items (allowedGids.size=${allowedGids.size})`);
|
|
251
|
+
}
|
|
252
|
+
else if (rule.matchClipFilter === true) {
|
|
253
|
+
// console.log(`[DEBUG FILL vp="${vp.id}"] Fill rule has matchClipFilter=true but no clip polygon active`);
|
|
254
|
+
}
|
|
255
|
+
// console.log(`[DEBUG FILL vp="${vp.id}"] Fill rule (class="${rule.class}", where=${JSON.stringify(rule.where)}) matched ${matching.length} items`);
|
|
256
|
+
// if (matching.length > 0) {
|
|
257
|
+
// console.log(`[DEBUG FILL vp="${vp.id}"] First matched item:`, {
|
|
258
|
+
// gid: getProp(matching[0], 'gid'),
|
|
259
|
+
// name: getProp(matching[0], 'name'),
|
|
260
|
+
// ifcClass: getProp(matching[0], 'ifcClass'),
|
|
261
|
+
// propertySets: getProp(matching[0], 'propertySets'),
|
|
262
|
+
// polylines: Array.isArray(getProp(matching[0], 'polylines')) ? (getProp(matching[0], 'polylines') as any[]).length : 0
|
|
263
|
+
// });
|
|
264
|
+
// }
|
|
265
|
+
if (!matching.length)
|
|
266
|
+
continue;
|
|
267
|
+
for (const item of matching) {
|
|
268
|
+
const polylines = getProp(item, 'polylines');
|
|
269
|
+
if (!Array.isArray(polylines))
|
|
270
|
+
continue;
|
|
271
|
+
// Resolve fill color for this item
|
|
272
|
+
const color = getProp(item, 'color');
|
|
273
|
+
let fillColor;
|
|
274
|
+
if (rule.fill === 'sample') {
|
|
275
|
+
if (!color)
|
|
276
|
+
continue; // no sampled color available
|
|
277
|
+
fillColor = `rgb(${color[0]},${color[1]},${color[2]})`;
|
|
278
|
+
}
|
|
279
|
+
else if (rule.fill === 'legend') {
|
|
280
|
+
// Use color from legend color map
|
|
281
|
+
const legendColorMap = legendColorMaps?.get(vp.id);
|
|
282
|
+
if (!legendColorMap) {
|
|
283
|
+
console.warn(`[FILL] fill="legend" specified but no legend color map found for viewport "${vp.id}". Available viewports:`, Array.from(legendColorMaps?.keys() ?? []));
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
// Find matching legend entry - need to determine which property to use for lookup
|
|
287
|
+
// For now, try common properties (can be made configurable later)
|
|
288
|
+
let legendKey;
|
|
289
|
+
const possibleKeys = ['spacename', 'BIP.spacename', 'name'];
|
|
290
|
+
for (const key of possibleKeys) {
|
|
291
|
+
const value = resolvePath(item, key);
|
|
292
|
+
if (value !== undefined && value !== null) {
|
|
293
|
+
legendKey = String(value);
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
if (!legendKey || !legendColorMap.has(legendKey)) {
|
|
298
|
+
// No matching color in legend, skip this item
|
|
299
|
+
// if (legendKey) {
|
|
300
|
+
// console.log(`[FILL] No color mapping for "${legendKey}" (property: ${matchedProperty}). Available keys:`, Array.from(legendColorMap.keys()));
|
|
301
|
+
// }
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
fillColor = legendColorMap.get(legendKey);
|
|
305
|
+
// console.log(`[FILL] ✓ Matched "${legendKey}" -> ${fillColor}`);
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
fillColor = rule.fill;
|
|
309
|
+
}
|
|
310
|
+
// console.log(`[FILL] Processing ${polylines.length} polyline(s) for item with color ${fillColor}`);
|
|
311
|
+
for (const polyline of polylines) {
|
|
312
|
+
const points = isRecord(polyline) ? getProp(polyline, 'points') : null;
|
|
313
|
+
if (!Array.isArray(points) || points.length < 3)
|
|
314
|
+
continue;
|
|
315
|
+
// Build path in model-view coordinates
|
|
316
|
+
const pathParts = [];
|
|
317
|
+
for (let i = 0; i < points.length; i++) {
|
|
318
|
+
const pt = points[i];
|
|
319
|
+
const px = isRecord(pt) ? getProp(pt, 'x') : null;
|
|
320
|
+
const pz = isRecord(pt) ? getProp(pt, 'z') : null;
|
|
321
|
+
if (!Number.isFinite(px) || !Number.isFinite(pz))
|
|
322
|
+
continue;
|
|
323
|
+
const mx = px - viewMinX;
|
|
324
|
+
const my = viewMaxZ - pz;
|
|
325
|
+
pathParts.push(i === 0 ? `M ${mx} ${my}` : `L ${mx} ${my}`);
|
|
326
|
+
}
|
|
327
|
+
if (pathParts.length < 3)
|
|
328
|
+
continue;
|
|
329
|
+
pathParts.push('Z');
|
|
330
|
+
parts.push(`<path d="${pathParts.join(' ')}" fill="${escapeAttr(fillColor)}" fill-opacity="${opacity}" stroke="none"/>`);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
// console.log(`[FILL] Generated ${parts.length} fill polygon(s) for viewport "${vp.id}"`);
|
|
335
|
+
return parts.length ? `<g>${parts.join('')}</g>` : null;
|
|
336
|
+
}
|
|
337
|
+
//# sourceMappingURL=viewportRender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewportRender.js","sourceRoot":"/","sources":["layout/viewportRender.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGjD,iEAAiE;AACjE,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAIjC,MAAM,YAAY,GAAG,CAAC,EAAU,EAAE,EAAU,EAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAC3E,MAAM,QAAQ,GAAG,CAAC,EAAU,EAAE,EAAU,EAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACvE,MAAM,YAAY,GAAG,CAAC,GAAW,EAAO,EAAE;IACtC,MAAM,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IAClC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,OAAO,CAAC,CAAC,EAAE,CAA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CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;gBAChE,CAAC;gBACD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;oBAAE,SAAS;gBACnC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACpB,KAAK,CAAC,IAAI,CACN,YAAY,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,UAAU,CAAC,SAAS,CAAC,mBAAmB,OAAO,mBAAmB,CAC/G,CAAC;YACN,CAAC;QACL,CAAC;IACL,CAAC;IAED,2FAA2F;IAC3F,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5D,CAAC","sourcesContent":["import { escapeAttr, getPathValue, resolvePath } from './renderUtils';\r\nimport { rotateBounds, pickScale } from './viewportUtils';\r\nimport { ViewportRenderInfo } from './labelsRender';\r\nimport { matchesV2Filter } from './filters';\r\nimport { ComputedViewportScale, SvgModelView, ViewportElement, AssetSpec } from './types';\r\nimport { isRecord, getProp } from './typeGuards';\r\n\r\ntype PolyPoint = { x: number; y: number };\r\n// Debug overlay for clip polygons. Keep false for normal builds.\r\nconst DEBUG_CLIP_OVERLAY = false;\r\n\r\ntype Mat = [number, number, number, number, number, number]; // a b c d e f\r\n\r\nconst matTranslate = (tx: number, ty: number): Mat => [1, 0, 0, 1, tx, ty];\r\nconst matScale = (sx: number, sy: number): Mat => [sx, 0, 0, sy, 0, 0];\r\nconst matRotateDeg = (deg: number): Mat => {\r\n const rad = (deg * Math.PI) / 180;\r\n const c = Math.cos(rad);\r\n const s = Math.sin(rad);\r\n return [c, s, -s, c, 0, 0];\r\n};\r\nconst matMultiply = (m1: Mat, m2: Mat): Mat => {\r\n const [a1, b1, c1, d1, e1, f1] = m1;\r\n const [a2, b2, c2, d2, e2, f2] = m2;\r\n return [\r\n a1 * a2 + c1 * b2,\r\n b1 * a2 + d1 * b2,\r\n a1 * c2 + c1 * d2,\r\n b1 * c2 + d1 * d2,\r\n a1 * e2 + c1 * f2 + e1,\r\n b1 * e2 + d1 * f2 + f1\r\n ];\r\n};\r\nconst matApply = (m: Mat, p: PolyPoint): PolyPoint => {\r\n const [a, b, c, d, e, f] = m;\r\n return { x: a * p.x + c * p.y + e, y: b * p.x + d * p.y + f };\r\n};\r\nexport const renderViewportElement = (\r\n vp: ViewportElement,\r\n baseModel: SvgModelView | null,\r\n dataWithViewport: any,\r\n preferredScales: number[],\r\n scales: Record<string, { preferredScales?: number[] }>,\r\n assetMap: Map<string, AssetSpec>,\r\n viewportScales: Record<string, ComputedViewportScale>,\r\n viewportClipPolygonsLocal: Record<string, Array<Array<PolyPoint>>>,\r\n viewportClipBounds: Record<\r\n string,\r\n { minX: number; maxX: number; minY: number; maxY: number; width: number; height: number }\r\n >,\r\n viewportClipLabels: Record<string, boolean>,\r\n viewportClipStyles: Record<\r\n string,\r\n { stroke?: string; strokeWidthMm?: number; strokeOpacity?: number; fill?: string; fillOpacity?: number }\r\n >,\r\n viewportHighlight: Record<string, { gids: Set<string> | null; styles: any }>,\r\n viewportRenderInfo: Record<string, ViewportRenderInfo>,\r\n warnings: string[],\r\n legendColorMaps?: Map<string, Map<string, string>>,\r\n precomputed?: {\r\n effectiveWidthModel?: number;\r\n effectiveHeightModel?: number;\r\n clipPolygonsMm?: Array<Array<PolyPoint>>;\r\n clipPolygonsLocal?: Array<Array<PolyPoint>>;\r\n clipBounds?: { minX: number; maxX: number; minY: number; maxY: number; width: number; height: number };\r\n renderCenterModelX?: number;\r\n renderCenterModelY?: number;\r\n }\r\n): string[] => {\r\n const parts: string[] = [];\r\n if (!baseModel) {\r\n // Warning already pushed by viewportPrep; avoid duplicate.\r\n return parts;\r\n }\r\n\r\n const model = baseModel;\r\n let renderWidthModel = precomputed?.effectiveWidthModel ?? model.widthModel;\r\n let renderHeightModel = precomputed?.effectiveHeightModel ?? model.heightModel;\r\n let renderCenterModelX = precomputed?.renderCenterModelX ?? renderWidthModel * 0.5;\r\n let renderCenterModelY = precomputed?.renderCenterModelY ?? renderHeightModel * 0.5;\r\n\r\n const clipBounds = viewportClipBounds[vp.id];\r\n const clipLocal = viewportClipPolygonsLocal[vp.id];\r\n const hasClip = !!clipBounds && Array.isArray(clipLocal) && clipLocal.length > 0;\r\n if (hasClip) {\r\n renderWidthModel = clipBounds!.width;\r\n renderHeightModel = clipBounds!.height;\r\n renderCenterModelX = (clipBounds!.minX + clipBounds!.maxX) * 0.5;\r\n renderCenterModelY = (clipBounds!.minY + clipBounds!.maxY) * 0.5;\r\n }\r\n\r\n const scaleInfo =\r\n viewportScales[vp.id] ??\r\n pickScale(\r\n vp,\r\n { ...model, widthModel: renderWidthModel, heightModel: renderHeightModel },\r\n preferredScales,\r\n scales\r\n );\r\n const rotationDeg = vp.rotationDeg ?? 0;\r\n const mmPerModel = scaleInfo.mmPerModelUnit;\r\n const contentWidthMm = renderWidthModel * mmPerModel;\r\n const contentHeightMm = renderHeightModel * mmPerModel;\r\n const rotated = rotateBounds(contentWidthMm, contentHeightMm, rotationDeg);\r\n\r\n const centerX = vp.align === 'topLeft' ? vp.xMm + rotated.width / 2 : vp.xMm + vp.widthMm / 2;\r\n const centerY = vp.align === 'topLeft' ? vp.yMm + rotated.height / 2 : vp.yMm + vp.heightMm / 2;\r\n\r\n const contentOffsetX = vp.align === 'topLeft' ? vp.xMm : vp.xMm + Math.max(0, (vp.widthMm - rotated.width) * 0.5);\r\n const contentOffsetY = vp.align === 'topLeft' ? vp.yMm : vp.yMm + Math.max(0, (vp.heightMm - rotated.height) * 0.5);\r\n\r\n const clipPolysLocal = clipLocal;\r\n let clipId: string | null = null;\r\n const clipDebugPolys: string[] = [];\r\n const clipStyle = viewportClipStyles[vp.id];\r\n const clipStroke = clipStyle?.stroke;\r\n const clipStrokeWidth = clipStyle?.strokeWidthMm;\r\n const clipStrokeOpacity = clipStyle?.strokeOpacity;\r\n const clipFill = clipStyle?.fill;\r\n const clipFillOpacity = clipStyle?.fillOpacity;\r\n const transformAttr = `translate(${centerX} ${centerY}) rotate(${rotationDeg}) scale(${mmPerModel}) translate(${-renderCenterModelX} ${-renderCenterModelY})`;\r\n\r\n // Debug: log model bounds and path breakdown\r\n // if (model.transform) {\r\n // console.log(`[DEBUG MODEL vp=\"${vp.id}\"] Model bounds: viewMinX=${model.transform.viewMinX.toFixed(2)} viewMaxX=${model.transform.viewMaxX?.toFixed(2)} viewMinZ=${model.transform.viewMinZ.toFixed(2)} viewMaxZ=${model.transform.viewMaxZ.toFixed(2)} viewWidth=${model.transform.viewWidth.toFixed(2)} viewHeight=${model.transform.viewHeight.toFixed(2)}`);\r\n\r\n // if (model.rawPaths) {\r\n // const fills = model.rawPaths.filter(p => p.meta?.isFill);\r\n // const segments = model.rawPaths.filter(p => p.meta?.isSegment);\r\n // const other = model.rawPaths.filter(p => !p.meta?.isFill && !p.meta?.isSegment);\r\n // console.log(`[DEBUG MODEL vp=\"${vp.id}\"] Path breakdown: ${model.rawPaths.length} total (${fills.length} fills, ${segments.length} segments, ${other.length} other)`);\r\n\r\n // // Sample a few segment paths\r\n // const sampleSegments = segments.slice(0, 3);\r\n // sampleSegments.forEach((seg, idx) => {\r\n // console.log(`[DEBUG MODEL vp=\"${vp.id}\"] Segment ${idx}: class=${seg.meta?.class} fill=${seg.fill} stroke=${seg.stroke} strokeWidth=${seg.strokeWidth} d=${seg.d.substring(0, 50)}...`);\r\n // });\r\n\r\n // // Check if geometryTransform is present\r\n // if (model.geometryTransform) {\r\n // console.log(`[DEBUG MODEL vp=\"${vp.id}\"] geometryTransform=\"${model.geometryTransform}\"`);\r\n // } else {\r\n // console.log(`[DEBUG MODEL vp=\"${vp.id}\"] WARNING: geometryTransform is MISSING!`);\r\n // }\r\n // }\r\n // }\r\n\r\n // Guard: detect NaN/Infinity in computed transform values\r\n if (\r\n !Number.isFinite(centerX) ||\r\n !Number.isFinite(centerY) ||\r\n !Number.isFinite(mmPerModel) ||\r\n !Number.isFinite(renderCenterModelX) ||\r\n !Number.isFinite(renderCenterModelY)\r\n ) {\r\n warnings.push(\r\n `Viewport '${vp.id}' has non-finite transform values (centerX=${centerX}, centerY=${centerY}, mmPerModel=${mmPerModel}). Skipping render.`\r\n );\r\n return parts;\r\n }\r\n\r\n // console.log(`[DEBUG CLIP APPLY vp=\"${vp.id}\"] clipPolysLocal exists: ${!!clipPolysLocal}, length: ${clipPolysLocal?.length ?? 0}`);\r\n if (clipPolysLocal && clipPolysLocal.length) {\r\n // console.log(`[DEBUG CLIP APPLY vp=\"${vp.id}\"] *** APPLYING CLIP-PATH *** with ${clipPolysLocal.length} polygons`);\r\n if (clipPolysLocal.every((poly) => !poly.length)) {\r\n warnings.push(`Viewport '${vp.id}' clip has no points after prep; skipping clip.`);\r\n }\r\n clipId = `clip-${vp.id}-${parts.length}`;\r\n const polyPartsPage: string[] = [];\r\n // Clip polygon points are in model-view coordinates (not SVG-internal),\r\n // so transform them with outer only (model-view → page). Do NOT apply\r\n // geometryTransform — that maps SVG-internal → model-view, which is only\r\n // correct for path data inside the <g transform=\"geometryTransform\"> group.\r\n const outer = matMultiply(\r\n matTranslate(centerX, centerY),\r\n matMultiply(\r\n matRotateDeg(rotationDeg),\r\n matMultiply(matScale(mmPerModel, mmPerModel), matTranslate(-renderCenterModelX, -renderCenterModelY))\r\n )\r\n );\r\n\r\n // Debug: log clip polygon bounds\r\n let clipMinX = Infinity,\r\n clipMaxX = -Infinity,\r\n clipMinY = Infinity,\r\n clipMaxY = -Infinity;\r\n clipPolysLocal.forEach((poly) => {\r\n poly.forEach((p) => {\r\n if (p.x < clipMinX) clipMinX = p.x;\r\n if (p.x > clipMaxX) clipMaxX = p.x;\r\n if (p.y < clipMinY) clipMinY = p.y;\r\n if (p.y > clipMaxY) clipMaxY = p.y;\r\n });\r\n });\r\n // console.log(`[DEBUG CLIP vp=\"${vp.id}\"] Local bounds: x=${clipMinX.toFixed(2)}..${clipMaxX.toFixed(2)} y=${clipMinY.toFixed(2)}..${clipMaxY.toFixed(2)} (w=${(clipMaxX - clipMinX).toFixed(2)} h=${(clipMaxY - clipMinY).toFixed(2)})`);\r\n\r\n clipPolysLocal.forEach((poly) => {\r\n const pagePtsArr = poly.map((p) => matApply(outer, p));\r\n const pagePts = pagePtsArr.map((p) => `${p.x},${p.y}`).join(' ');\r\n polyPartsPage.push(`<polygon points=\"${pagePts}\" />`);\r\n if (clipStroke || clipFill) {\r\n clipDebugPolys.push(\r\n `<polygon points=\"${pagePts}\"` +\r\n (clipStroke ? ` stroke=\"${escapeAttr(clipStroke)}\"` : '') +\r\n (clipStrokeWidth ? ` stroke-width=\"${clipStrokeWidth}\"` : '') +\r\n (clipStrokeOpacity !== undefined ? ` stroke-opacity=\"${clipStrokeOpacity}\"` : '') +\r\n (clipFill ? ` fill=\"${escapeAttr(clipFill)}\"` : ' fill=\"none\"') +\r\n (clipFillOpacity !== undefined ? ` fill-opacity=\"${clipFillOpacity}\"` : '') +\r\n ` />`\r\n );\r\n }\r\n if (DEBUG_CLIP_OVERLAY) {\r\n clipDebugPolys.push(\r\n `<polygon points=\"${pagePts}\" stroke=\"#ff00ff\" stroke-width=\"0.4\" fill=\"#000000\" fill-opacity=\"0.35\" />`\r\n );\r\n }\r\n });\r\n parts.push(\r\n `<defs><clipPath id=\"${clipId}\" clipPathUnits=\"userSpaceOnUse\">${polyPartsPage.join('')}</clipPath></defs>`\r\n );\r\n }\r\n\r\n parts.push(`<g${clipId ? ` clip-path=\"url(#${clipId})\"` : ''}>`);\r\n parts.push(`<g transform=\"${transformAttr}\">`);\r\n\r\n // Render fill polygons below structural lines\r\n const allowedGids = viewportHighlight[vp.id]?.gids ?? null;\r\n const fillSvg = buildFillSvg(vp, dataWithViewport, model, allowedGids, legendColorMaps);\r\n if (fillSvg) parts.push(fillSvg);\r\n\r\n // Debug: log sample path coordinates from model.groupSvg\r\n if (clipId && model.rawPaths && model.rawPaths.length > 0) {\r\n const asMeta = (m: unknown): { isSegment?: boolean; isFill?: boolean; class?: string } | undefined =>\r\n m != null && typeof m === 'object'\r\n ? (m as { isSegment?: boolean; isFill?: boolean; class?: string })\r\n : undefined;\r\n const samplePath = model.rawPaths.find((p) => {\r\n const pm = asMeta(p.meta);\r\n return pm?.isSegment || (!pm?.isFill && !pm?.class);\r\n });\r\n if (samplePath) {\r\n const dMatch = samplePath.d.match(/M([\\d.-]+)\\s+([\\d.-]+)/);\r\n if (dMatch) {\r\n // console.log(`[DEBUG PATH vp=\"${vp.id}\"] Sample wall path starts at x=${dMatch[1]} y=${dMatch[2]} (world coords, will be transformed by geometryTransform)`);\r\n }\r\n }\r\n }\r\n\r\n // Compensate stroke-widths for the viewport scale transform.\r\n // Paths have stroke-width in model units; the scale(mmPerModel) transform\r\n // would make them thinner/thicker depending on zoom. Dividing by mmPerModel\r\n // ensures strokes render at their intended mm size regardless of viewport scale.\r\n const compensatedSvg = model.groupSvg.replace(\r\n /stroke-width=\"([0-9.eE+-]+)\"/g,\r\n (_, w) => `stroke-width=\"${parseFloat(w) / mmPerModel}\"`\r\n );\r\n parts.push(compensatedSvg);\r\n parts.push('</g>');\r\n parts.push('</g>');\r\n\r\n if (clipDebugPolys.length) {\r\n parts.push(`<g pointer-events=\"none\">${clipDebugPolys.join('')}</g>`);\r\n }\r\n\r\n viewportRenderInfo[vp.id] = {\r\n mmPerModel,\r\n contentWidthMm: rotated.width,\r\n contentHeightMm: rotated.height,\r\n offsetX: contentOffsetX,\r\n offsetY: contentOffsetY,\r\n rotationDeg,\r\n transform: model.transform!,\r\n centerX,\r\n centerY,\r\n centerModelX: renderCenterModelX,\r\n centerModelY: renderCenterModelY\r\n };\r\n\r\n if (vp.border) {\r\n const borderStroke = vp.border.stroke ?? '#000';\r\n const borderWidth = vp.border.strokeWidthMm ?? 0.25;\r\n parts.push(\r\n `<rect x=\"${vp.xMm}\" y=\"${vp.yMm}\" width=\"${vp.widthMm}\" height=\"${vp.heightMm}\" stroke=\"${escapeAttr(\r\n borderStroke\r\n )}\" stroke-width=\"${borderWidth}\" fill=\"none\"${vp.border.dashed ? ' stroke-dasharray=\"4 2\"' : ''} />`\r\n );\r\n }\r\n\r\n if (vp.northArrow) {\r\n const arrow = vp.northArrow;\r\n const asset = assetMap.get(arrow.assetId);\r\n const size = arrow.sizeMm ?? 12;\r\n const offsetX = arrow.offsetXMm ?? 8;\r\n const offsetY = arrow.offsetYMm ?? 8;\r\n const arrowX = vp.xMm + vp.widthMm - offsetX - size;\r\n const arrowY = vp.yMm + offsetY;\r\n const arrowRotation = arrow.rotationDeg ?? 0;\r\n if (!asset) {\r\n warnings.push(`Missing asset '${arrow.assetId}' for north arrow on viewport '${vp.id}'.`);\r\n } else if (asset.src) {\r\n parts.push(\r\n `<image href=\"${escapeAttr(asset.src)}\" x=\"${arrowX}\" y=\"${arrowY}\" width=\"${size}\" height=\"${size}\" transform=\"rotate(${arrowRotation}, ${arrowX + size / 2}, ${\r\n arrowY + size / 2\r\n })\" />`\r\n );\r\n } else if (asset.content) {\r\n parts.push(\r\n `<g transform=\"translate(${arrowX} ${arrowY}) rotate(${arrowRotation} ${size / 2} ${size / 2})\">${asset.content}</g>`\r\n );\r\n }\r\n }\r\n\r\n return parts;\r\n};\r\n\r\n// ---------------------------------------------------------------------------\r\n// Fill polygon rendering\r\n// ---------------------------------------------------------------------------\r\n\r\n/**\r\n * Build SVG fill polygons from viewport fill rules and item data.\r\n * Returns an SVG fragment in model-view coordinates (same space as model.groupSvg),\r\n * or null if no fills should be rendered.\r\n */\r\nfunction buildFillSvg(\r\n vp: ViewportElement,\r\n data: any,\r\n model: SvgModelView,\r\n allowedGids: Set<string> | null,\r\n legendColorMaps?: Map<string, Map<string, string>>\r\n): string | null {\r\n const fills = vp.fills;\r\n if (!fills?.length || !model.transform) return null;\r\n\r\n const items = getPathValue(data, `viewports.${vp.id}.items`);\r\n if (!Array.isArray(items) || !items.length) return null;\r\n\r\n const { viewMinX, viewMaxZ } = model.transform;\r\n const parts: string[] = [];\r\n\r\n for (const rule of fills) {\r\n const opacity = rule.fillOpacity ?? 0.35;\r\n // Find items matching this fill rule\r\n let matching = items.filter((item: unknown) =>\r\n isRecord(item) ? matchesV2Filter(item, rule.class, rule.where) : false\r\n );\r\n\r\n // Filter by allowed GIDs (from clip polygon center point test)\r\n // Only apply if BOTH: clip filtering is active AND this fill rule opts in via matchClipFilter\r\n if (allowedGids !== null && rule.matchClipFilter === true) {\r\n matching = matching.filter((item: unknown) => {\r\n const gid = getProp(item, 'gid') ?? getProp(item, 'id');\r\n return gid !== null && gid !== undefined && allowedGids.has(String(gid));\r\n });\r\n // console.log(`[DEBUG FILL vp=\"${vp.id}\"] Clip filter applied (matchClipFilter=true): ${beforeFilter} → ${matching.length} items (allowedGids.size=${allowedGids.size})`);\r\n } else if (rule.matchClipFilter === true) {\r\n // console.log(`[DEBUG FILL vp=\"${vp.id}\"] Fill rule has matchClipFilter=true but no clip polygon active`);\r\n }\r\n // console.log(`[DEBUG FILL vp=\"${vp.id}\"] Fill rule (class=\"${rule.class}\", where=${JSON.stringify(rule.where)}) matched ${matching.length} items`);\r\n // if (matching.length > 0) {\r\n // console.log(`[DEBUG FILL vp=\"${vp.id}\"] First matched item:`, {\r\n // gid: getProp(matching[0], 'gid'),\r\n // name: getProp(matching[0], 'name'),\r\n // ifcClass: getProp(matching[0], 'ifcClass'),\r\n // propertySets: getProp(matching[0], 'propertySets'),\r\n // polylines: Array.isArray(getProp(matching[0], 'polylines')) ? (getProp(matching[0], 'polylines') as any[]).length : 0\r\n // });\r\n // }\r\n if (!matching.length) continue;\r\n\r\n for (const item of matching) {\r\n const polylines = getProp(item, 'polylines');\r\n if (!Array.isArray(polylines)) continue;\r\n\r\n // Resolve fill color for this item\r\n const color = getProp(item, 'color') as [number, number, number, number] | undefined;\r\n let fillColor: string;\r\n if (rule.fill === 'sample') {\r\n if (!color) continue; // no sampled color available\r\n fillColor = `rgb(${color[0]},${color[1]},${color[2]})`;\r\n } else if (rule.fill === 'legend') {\r\n // Use color from legend color map\r\n const legendColorMap = legendColorMaps?.get(vp.id);\r\n if (!legendColorMap) {\r\n console.warn(\r\n `[FILL] fill=\"legend\" specified but no legend color map found for viewport \"${vp.id}\". Available viewports:`,\r\n Array.from(legendColorMaps?.keys() ?? [])\r\n );\r\n continue;\r\n }\r\n // Find matching legend entry - need to determine which property to use for lookup\r\n // For now, try common properties (can be made configurable later)\r\n let legendKey: string | undefined;\r\n const possibleKeys = ['spacename', 'BIP.spacename', 'name'];\r\n for (const key of possibleKeys) {\r\n const value = resolvePath(item, key);\r\n if (value !== undefined && value !== null) {\r\n legendKey = String(value);\r\n break;\r\n }\r\n }\r\n if (!legendKey || !legendColorMap.has(legendKey)) {\r\n // No matching color in legend, skip this item\r\n // if (legendKey) {\r\n // console.log(`[FILL] No color mapping for \"${legendKey}\" (property: ${matchedProperty}). Available keys:`, Array.from(legendColorMap.keys()));\r\n // }\r\n continue;\r\n }\r\n fillColor = legendColorMap.get(legendKey)!;\r\n // console.log(`[FILL] ✓ Matched \"${legendKey}\" -> ${fillColor}`);\r\n } else {\r\n fillColor = rule.fill;\r\n }\r\n\r\n // console.log(`[FILL] Processing ${polylines.length} polyline(s) for item with color ${fillColor}`);\r\n for (const polyline of polylines) {\r\n const points = isRecord(polyline) ? getProp(polyline, 'points') : null;\r\n if (!Array.isArray(points) || points.length < 3) continue;\r\n\r\n // Build path in model-view coordinates\r\n const pathParts: string[] = [];\r\n for (let i = 0; i < points.length; i++) {\r\n const pt = points[i];\r\n const px = isRecord(pt) ? getProp(pt, 'x') : null;\r\n const pz = isRecord(pt) ? getProp(pt, 'z') : null;\r\n if (!Number.isFinite(px) || !Number.isFinite(pz)) continue;\r\n const mx = (px as number) - viewMinX;\r\n const my = viewMaxZ - (pz as number);\r\n pathParts.push(i === 0 ? `M ${mx} ${my}` : `L ${mx} ${my}`);\r\n }\r\n if (pathParts.length < 3) continue;\r\n pathParts.push('Z');\r\n parts.push(\r\n `<path d=\"${pathParts.join(' ')}\" fill=\"${escapeAttr(fillColor)}\" fill-opacity=\"${opacity}\" stroke=\"none\"/>`\r\n );\r\n }\r\n }\r\n }\r\n\r\n // console.log(`[FILL] Generated ${parts.length} fill polygon(s) for viewport \"${vp.id}\"`);\r\n return parts.length ? `<g>${parts.join('')}</g>` : null;\r\n}\r\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ComputedViewportScale, SvgModelView, ViewportElement } from './types';
|
|
2
|
+
export declare const rotateBounds: (width: number, height: number, rotationDeg: number) => {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const pickScale: (viewport: ViewportElement, model: SvgModelView, preferred: number[], scalePresets: Record<string, {
|
|
7
|
+
preferredScales?: number[];
|
|
8
|
+
}>) => ComputedViewportScale;
|
|
9
|
+
//# sourceMappingURL=viewportUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewportUtils.d.ts","sourceRoot":"/","sources":["layout/viewportUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/E,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,EAAE,QAAQ,MAAM,EAAE,aAAa,MAAM,KAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAQhH,CAAC;AAEF,eAAO,MAAM,SAAS,GAClB,UAAU,eAAe,EACzB,OAAO,YAAY,EACnB,WAAW,MAAM,EAAE,EACnB,cAAc,MAAM,CAAC,MAAM,EAAE;IAAE,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,KAC7D,qBA+BF,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { uniquePositiveDenoms } from './utils';
|
|
2
|
+
export const rotateBounds = (width, height, rotationDeg) => {
|
|
3
|
+
if (!rotationDeg)
|
|
4
|
+
return { width, height };
|
|
5
|
+
const rad = (rotationDeg * Math.PI) / 180;
|
|
6
|
+
const cos = Math.cos(rad);
|
|
7
|
+
const sin = Math.sin(rad);
|
|
8
|
+
const rotatedWidth = Math.abs(width * cos) + Math.abs(height * sin);
|
|
9
|
+
const rotatedHeight = Math.abs(width * sin) + Math.abs(height * cos);
|
|
10
|
+
return { width: rotatedWidth, height: rotatedHeight };
|
|
11
|
+
};
|
|
12
|
+
export const pickScale = (viewport, model, preferred, scalePresets) => {
|
|
13
|
+
const scalePresetName = viewport.scalePreset;
|
|
14
|
+
const scalePreset = scalePresetName && scalePresets[scalePresetName] ? scalePresets[scalePresetName] : null;
|
|
15
|
+
const denoms = viewport.scaleMode === 'fixed' && viewport.fixedScaleDenom
|
|
16
|
+
? [viewport.fixedScaleDenom]
|
|
17
|
+
: uniquePositiveDenoms(viewport.preferredScales ?? scalePreset?.preferredScales ?? preferred);
|
|
18
|
+
const rotationDeg = viewport.rotationDeg ?? 0;
|
|
19
|
+
let selectedDenom = denoms[denoms.length - 1];
|
|
20
|
+
let selectedMmPerModel = 1000 / selectedDenom;
|
|
21
|
+
let fits = false;
|
|
22
|
+
for (const denom of denoms) {
|
|
23
|
+
const mmPerModel = 1000 / denom;
|
|
24
|
+
const widthMm = model.widthModel * mmPerModel;
|
|
25
|
+
const heightMm = model.heightModel * mmPerModel;
|
|
26
|
+
const rotated = rotateBounds(widthMm, heightMm, rotationDeg);
|
|
27
|
+
if (rotated.width <= viewport.widthMm && rotated.height <= viewport.heightMm) {
|
|
28
|
+
selectedDenom = denom;
|
|
29
|
+
selectedMmPerModel = mmPerModel;
|
|
30
|
+
fits = true;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
denom: selectedDenom,
|
|
36
|
+
mmPerModelUnit: selectedMmPerModel,
|
|
37
|
+
fits
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
//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,CAAC,SAAS,KAAK,OAAO,IAAI,QAAQ,CAAC,eAAe;QACtD,CAAC,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC;QAC5B,CAAC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,eAAe,IAAI,WAAW,EAAE,eAAe,IAAI,SAAS,CAAC,CAAC;IAEtG,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,IAAI,CAAC,CAAC;IAC9C,IAAI,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC9C,IAAI,kBAAkB,GAAG,IAAI,GAAG,aAAa,CAAC;IAC9C,IAAI,IAAI,GAAG,KAAK,CAAC;IAEjB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACzB,MAAM,UAAU,GAAG,IAAI,GAAG,KAAK,CAAC;QAChC,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,GAAG,UAAU,CAAC;QAC9C,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,GAAG,UAAU,CAAC;QAChD,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;QAC7D,IAAI,OAAO,CAAC,KAAK,IAAI,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAC3E,aAAa,GAAG,KAAK,CAAC;YACtB,kBAAkB,GAAG,UAAU,CAAC;YAChC,IAAI,GAAG,IAAI,CAAC;YACZ,MAAM;QACV,CAAC;IACL,CAAC;IAED,OAAO;QACH,KAAK,EAAE,aAAa;QACpB,cAAc,EAAE,kBAAkB;QAClC,IAAI;KACP,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { uniquePositiveDenoms } from './utils';\r\nimport { ComputedViewportScale, SvgModelView, ViewportElement } from './types';\r\n\r\nexport const rotateBounds = (width: number, height: number, rotationDeg: number): { width: number; height: number } => {\r\n if (!rotationDeg) return { width, height };\r\n const rad = (rotationDeg * Math.PI) / 180;\r\n const cos = Math.cos(rad);\r\n const sin = Math.sin(rad);\r\n const rotatedWidth = Math.abs(width * cos) + Math.abs(height * sin);\r\n const rotatedHeight = Math.abs(width * sin) + Math.abs(height * cos);\r\n return { width: rotatedWidth, height: rotatedHeight };\r\n};\r\n\r\nexport const pickScale = (\r\n viewport: ViewportElement,\r\n model: SvgModelView,\r\n preferred: number[],\r\n scalePresets: Record<string, { preferredScales?: number[] }>\r\n): ComputedViewportScale => {\r\n const scalePresetName = viewport.scalePreset;\r\n const scalePreset = scalePresetName && scalePresets[scalePresetName] ? scalePresets[scalePresetName] : null;\r\n const denoms =\r\n viewport.scaleMode === 'fixed' && viewport.fixedScaleDenom\r\n ? [viewport.fixedScaleDenom]\r\n : uniquePositiveDenoms(viewport.preferredScales ?? scalePreset?.preferredScales ?? preferred);\r\n\r\n const rotationDeg = viewport.rotationDeg ?? 0;\r\n let selectedDenom = denoms[denoms.length - 1];\r\n let selectedMmPerModel = 1000 / selectedDenom;\r\n let fits = false;\r\n\r\n for (const denom of denoms) {\r\n const mmPerModel = 1000 / denom;\r\n const widthMm = model.widthModel * mmPerModel;\r\n const heightMm = model.heightModel * mmPerModel;\r\n const rotated = rotateBounds(widthMm, heightMm, rotationDeg);\r\n if (rotated.width <= viewport.widthMm && rotated.height <= viewport.heightMm) {\r\n selectedDenom = denom;\r\n selectedMmPerModel = mmPerModel;\r\n fits = true;\r\n break;\r\n }\r\n }\r\n\r\n return {\r\n denom: selectedDenom,\r\n mmPerModelUnit: selectedMmPerModel,\r\n fits\r\n };\r\n};\r\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warnings.d.ts","sourceRoot":"/","sources":["layout/warnings.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,GAAI,UAAU,MAAM,EAAE,EAAE,SAAS,MAAM,KAAG,IAEjE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warnings.js","sourceRoot":"/","sources":["layout/warnings.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAkB,EAAE,OAAe,EAAQ,EAAE;IACrE,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["export const pushWarning = (warnings: string[], message: string): void => {\r\n warnings.push(message);\r\n};\r\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PDF export via jsPDF + svg2pdf.js
|
|
3
|
+
*
|
|
4
|
+
* These are optional peer dependencies. Functions will throw at runtime if not installed.
|
|
5
|
+
*/
|
|
6
|
+
export interface PrintToPdfOptions {
|
|
7
|
+
svgMarkup: string;
|
|
8
|
+
fileName?: string;
|
|
9
|
+
pageFormat?: 'a0' | 'a1' | 'a2' | 'a3' | 'a4';
|
|
10
|
+
orientation?: 'portrait' | 'landscape';
|
|
11
|
+
marginMm?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Export an SVG string to a PDF file.
|
|
15
|
+
* Requires jspdf and svg2pdf.js as peer dependencies.
|
|
16
|
+
*/
|
|
17
|
+
export declare function printToPdf(options: PrintToPdfOptions): Promise<Blob>;
|
|
18
|
+
/**
|
|
19
|
+
* Export an SVG string directly as a downloadable SVG file.
|
|
20
|
+
*/
|
|
21
|
+
export declare function printToSvgFile(svgMarkup: string, fileName: string): void;
|
|
22
|
+
export interface ExportSectionToPdfOptions {
|
|
23
|
+
svgMarkup: string;
|
|
24
|
+
fileName: string;
|
|
25
|
+
pageSizeMm?: {
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
};
|
|
29
|
+
openInNewTab?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function exportSectionToPdf(options: ExportSectionToPdfOptions): Promise<void>;
|
|
32
|
+
export interface ExportSectionToSvgOptions {
|
|
33
|
+
svgMarkup: string;
|
|
34
|
+
fileName: string;
|
|
35
|
+
openInNewTab?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare function exportSectionToSvg(options: ExportSectionToSvgOptions): void;
|
|
38
|
+
//# sourceMappingURL=printToPdf.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"printToPdf.d.ts","sourceRoot":"/","sources":["printToPdf.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,iBAAiB;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC9C,WAAW,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2C1E;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAQxE;AAGD,MAAM,WAAW,yBAAyB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAK1F;AAED,MAAM,WAAW,yBAAyB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,IAAI,CAU3E"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PDF export via jsPDF + svg2pdf.js
|
|
3
|
+
*
|
|
4
|
+
* These are optional peer dependencies. Functions will throw at runtime if not installed.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Export an SVG string to a PDF file.
|
|
8
|
+
* Requires jspdf and svg2pdf.js as peer dependencies.
|
|
9
|
+
*/
|
|
10
|
+
export async function printToPdf(options) {
|
|
11
|
+
// Dynamic imports for optional peer dependencies (installed by consumer, not this package)
|
|
12
|
+
let jspdfModule;
|
|
13
|
+
try {
|
|
14
|
+
// @ts-expect-error — optional peer dependency resolved at runtime
|
|
15
|
+
jspdfModule = await import('jspdf');
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
throw new Error('jspdf is required for PDF export. Install it: bun add jspdf');
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
// @ts-expect-error — optional peer dependency resolved at runtime
|
|
22
|
+
await import('svg2pdf.js');
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
throw new Error('svg2pdf.js is required for PDF export. Install it: bun add svg2pdf.js');
|
|
26
|
+
}
|
|
27
|
+
const { jsPDF } = jspdfModule;
|
|
28
|
+
const format = options.pageFormat ?? 'a3';
|
|
29
|
+
const orientation = options.orientation ?? 'landscape';
|
|
30
|
+
const margin = options.marginMm ?? 10;
|
|
31
|
+
const doc = new jsPDF({ format, orientation, unit: 'mm' });
|
|
32
|
+
const pageWidth = doc.internal.pageSize.getWidth();
|
|
33
|
+
const pageHeight = doc.internal.pageSize.getHeight();
|
|
34
|
+
const parser = new DOMParser();
|
|
35
|
+
const svgDoc = parser.parseFromString(options.svgMarkup, 'image/svg+xml');
|
|
36
|
+
const svgElement = svgDoc.documentElement;
|
|
37
|
+
await doc.svg(svgElement, {
|
|
38
|
+
x: margin,
|
|
39
|
+
y: margin,
|
|
40
|
+
width: pageWidth - margin * 2,
|
|
41
|
+
height: pageHeight - margin * 2
|
|
42
|
+
});
|
|
43
|
+
const blob = doc.output('blob');
|
|
44
|
+
if (options.fileName) {
|
|
45
|
+
doc.save(options.fileName);
|
|
46
|
+
}
|
|
47
|
+
return blob;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Export an SVG string directly as a downloadable SVG file.
|
|
51
|
+
*/
|
|
52
|
+
export function printToSvgFile(svgMarkup, fileName) {
|
|
53
|
+
const blob = new Blob([svgMarkup], { type: 'image/svg+xml' });
|
|
54
|
+
const url = URL.createObjectURL(blob);
|
|
55
|
+
const link = document.createElement('a');
|
|
56
|
+
link.href = url;
|
|
57
|
+
link.download = fileName;
|
|
58
|
+
link.click();
|
|
59
|
+
URL.revokeObjectURL(url);
|
|
60
|
+
}
|
|
61
|
+
export async function exportSectionToPdf(options) {
|
|
62
|
+
await printToPdf({
|
|
63
|
+
svgMarkup: options.svgMarkup,
|
|
64
|
+
fileName: options.fileName
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
export function exportSectionToSvg(options) {
|
|
68
|
+
if (options.openInNewTab) {
|
|
69
|
+
const blob = new Blob([options.svgMarkup], { type: 'image/svg+xml' });
|
|
70
|
+
const url = URL.createObjectURL(blob);
|
|
71
|
+
window.open(url, '_blank');
|
|
72
|
+
// Revoke after a delay to allow the new tab to load the blob
|
|
73
|
+
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
printToSvgFile(options.svgMarkup, options.fileName);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=printToPdf.js.map
|