[324] Präsentationsblatt füllt das Blatt: Reihen senkrecht verteilt, Plan-Grenzen mit Achsblasen/Masszahlen, Schriftfeld bricht Projektnamen um
This commit is contained in:
11 files changed
+184
-50
No files matched your search
@@ -33,6 +33,7 @@ import {
|
||||
findSnapshot,
|
||||
folderPdfPages,
|
||||
resolveTitleBlock,
|
||||
titleBlockNameLines,
|
||||
resolveViewportScale,
|
||||
SHEET_SCALE_DENOMINATOR,
|
||||
viewportCenterBounds,
|
||||
@@ -72,8 +73,10 @@ function drawTitleBlock(
|
||||
|
||||
doc.setTextColor(17, 17, 17);
|
||||
setPdfFont(doc, PDF_DEFAULT_FONT, true);
|
||||
const name = titleBlockNameLines(tb.projectName);
|
||||
doc.setFontSize(9 * name.scale);
|
||||
name.lines.forEach((l, i) => doc.text(l, x + 3, y + name.baselines[i]));
|
||||
doc.setFontSize(9);
|
||||
doc.text(clip(tb.projectName, 28), x + 3, y + 5.6);
|
||||
doc.text(tb.planNumber, x + boxW - 3, y + 5.6, { align: "right" });
|
||||
|
||||
setPdfFont(doc, PDF_DEFAULT_FONT);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import type { Layout, MasterLayout, Project } from "../model/types";
|
||||
import { t } from "../i18n/translate";
|
||||
import { effectiveSheetSizeMm, findMaster, resolveTitleBlock, type ResolvedTitleBlock } from "../model/layoutModel";
|
||||
import { effectiveSheetSizeMm, findMaster, resolveTitleBlock, titleBlockNameLines, type ResolvedTitleBlock } from "../model/layoutModel";
|
||||
import { imageGeometry } from "../model/layoutImages";
|
||||
import { posterHeaderItems, viewportScaleLabel, viewportVariantLabel } from "../model/posterTemplates";
|
||||
import { legendPlan, legendPrintSvg } from "./legendSvg";
|
||||
@@ -53,11 +53,12 @@ function titleBlockSvg(w: number, h: number, tb: ResolvedTitleBlock, layout: Lay
|
||||
const x = w - bw - 6;
|
||||
const y = h - bh - 6;
|
||||
const fmt = `${layout.paper.toUpperCase()} ${layout.orientation === "landscape" ? "quer" : "hoch"}`;
|
||||
const name = titleBlockNameLines(tb.projectName);
|
||||
const o: string[] = [
|
||||
`<rect x="${x}" y="${y}" width="${bw}" height="${bh}" fill="#fff" stroke="${INK}" stroke-width="0.35"/>`,
|
||||
`<line x1="${x}" y1="${y + 8}" x2="${x + bw}" y2="${y + 8}" stroke="${INK}" stroke-width="0.2"/>`,
|
||||
`<line x1="${x}" y1="${y + bh - 7}" x2="${x + bw}" y2="${y + bh - 7}" stroke="${INK}" stroke-width="0.2"/>`,
|
||||
textEl(x + 3, y + 5.6, clip(tb.projectName, 28), 3.2, { bold: true }),
|
||||
...name.lines.map((l, i) => textEl(x + 3, y + name.baselines[i], l, 3.2 * name.scale, { bold: true })),
|
||||
textEl(x + bw - 3, y + 5.6, tb.planNumber, 3.2, { bold: true, anchor: "end" }),
|
||||
textEl(x + 3, y + 13, clip(tb.sheetName, 36), 2.8),
|
||||
];
|
||||
|
||||
@@ -41,6 +41,7 @@ import {
|
||||
sheetModelToMm,
|
||||
sheetSizeMm,
|
||||
visibleCodesFromSnapshot,
|
||||
titleBlockNameLines,
|
||||
} from "./layoutModel";
|
||||
|
||||
/** Minimaler Ausschnitt (nur die im Layout-System genutzten Felder tragen Werte). */
|
||||
@@ -649,3 +650,16 @@ describe("Kern-Rechnung: Sonderfälle", () => {
|
||||
expect(tb.date).toBe("\u0085");
|
||||
});
|
||||
});
|
||||
|
||||
describe("[324] Schriftfeld: Projektname", () => {
|
||||
it("kurzer Name bleibt einzeilig, langer wird umgebrochen statt gekürzt", () => {
|
||||
const short = titleBlockNameLines("Musterhaus");
|
||||
expect(short.lines).toEqual(["Musterhaus"]);
|
||||
expect(short.scale).toBe(1);
|
||||
const long = titleBlockNameLines("Musterhaus komplex, Musterweg 7, Zürich");
|
||||
expect(long.lines.length).toBe(2);
|
||||
expect(long.lines.join(" ")).toBe("Musterhaus komplex, Musterweg 7, Zürich");
|
||||
expect(long.lines.every((l) => !l.includes("…"))).toBe(true);
|
||||
expect(long.scale).toBeLessThan(1);
|
||||
});
|
||||
});
|
||||
@@ -578,3 +578,20 @@ export function visibleCodesFromSnapshot(snap: ViewSnapshot): Set<string> {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* [324] Projektname im Schriftfeld (Kopfzeile 8 mm, Platz neben der Plan-Nr. für ≈ 28 Zeichen): zu lang ⇒ zwei Zeilen
|
||||
* in kleinerer Schrift (`scale` × Normalgrösse, Grundlinien in `baselines`, mm ab Oberkante des Felds) statt Kürzen;
|
||||
* nur was auch in zwei Zeilen nicht passt, endet mit „…".
|
||||
*/
|
||||
export function titleBlockNameLines(name: string, max = 28): { lines: string[]; scale: number; baselines: number[] } {
|
||||
const s = name.trim();
|
||||
if (s.length <= max) return { lines: [s], scale: 1, baselines: [5.6] };
|
||||
const per = Math.floor(max * 1.25);
|
||||
let cut = s.lastIndexOf(" ", per);
|
||||
if (cut < per * 0.4) cut = per;
|
||||
const first = s.slice(0, cut).trim();
|
||||
let rest = s.slice(cut).trim();
|
||||
if (rest.length > per) rest = rest.slice(0, per - 1) + "…";
|
||||
return { lines: [first, rest], scale: 0.8, baselines: [3.4, 6.8] };
|
||||
}
|
||||
@@ -35,8 +35,8 @@ describe("[66] Präsentationsplan", () => {
|
||||
project = st().project;
|
||||
});
|
||||
|
||||
// [323] Achskreise und Masszahlen der Aussenbemassung ragen über das Plan-Ausmass hinaus: der Rahmen lässt 8 mm Rand, nicht 4.
|
||||
it("[323] Präsentationsplan: Rahmen der Grundrisse mit 8 mm Rand um das gemeinsame Ausmass", () => {
|
||||
// [324] Achskreise und Masszahlen zählen im Plan-Ausmass mit (Kern `acc_bounds`): der Rahmen lässt nur 4 mm Rand.
|
||||
it("[324] Präsentationsplan: Rahmen der Grundrisse mit 4 mm Rand um das Ausmass samt Achskreisen", () => {
|
||||
const o = { ...presentationDefaults(project), scale: 200 };
|
||||
const plan = planPresentationSheet(project, o);
|
||||
const res = presentationSheetOps(project, o, LABELS, "p323")!;
|
||||
@@ -52,8 +52,20 @@ describe("[66] Präsentationsplan", () => {
|
||||
w = Math.max(w, ((b.maxX - b.minX) * 1000) / 200);
|
||||
}
|
||||
const eg = plan.items.find((i) => q.drawingLevels.find((l) => l.id === i.levelId)?.kind === "floor")!;
|
||||
expect(eg.heightMm).toBeGreaterThanOrEqual(h + 16 - 1e-6);
|
||||
expect(eg.widthMm).toBeGreaterThanOrEqual(w + 16 - 1e-6);
|
||||
expect(eg.heightMm).toBeGreaterThanOrEqual(h + 8 - 1e-6);
|
||||
expect(eg.widthMm).toBeGreaterThanOrEqual(w + 8 - 1e-6);
|
||||
});
|
||||
|
||||
it("[324] Blatt gefüllt: Viewports belegen ≥ 70 % der Blatthöhe, Schriftfeld bleibt frei", () => {
|
||||
const o = { ...presentationDefaults(project), scale: 200 };
|
||||
const plan = planPresentationSheet(project, o);
|
||||
expect(plan.fits).toBe(true);
|
||||
const top = Math.min(...plan.items.map((i) => i.yMm));
|
||||
const bottom = Math.max(...plan.items.map((i) => i.yMm + i.heightMm));
|
||||
const { h, w } = sheetSizeMm("a1", "landscape");
|
||||
expect((bottom - top) / h).toBeGreaterThanOrEqual(0.7);
|
||||
const tb = { xMm: w - 76, yMm: h - 36, widthMm: 70, heightMm: 30 };
|
||||
expect(plan.items.some((i) => overlaps(i, tb))).toBe(false);
|
||||
});
|
||||
|
||||
it("Vorschlag: alle Geschosse, Ansichten, ein Schnitt, A1 quer (Master)", () => {
|
||||
@@ -522,10 +534,11 @@ describe("[66] Präsentationsplan", () => {
|
||||
}, 90_000);
|
||||
|
||||
// [282] Passt der Plan im gewählten Massstab nicht: kein überlaufendes Blatt, sondern der grösste passende Massstab als Vorschlag.
|
||||
it("[282] Massstab-Vorschlag: 1:50 auf A4 passt nicht, vorgeschlagener Massstab passt", () => {
|
||||
// [324] A3 statt A4: das Ausmass zählt Achskreise und Masszahlen in Papier-Grösse mit, auf A4 hochkant passt der Wettbewerb auch bei 1:1000 nicht mehr.
|
||||
it("[282] Massstab-Vorschlag: 1:50 auf A3 passt nicht, vorgeschlagener Massstab passt", () => {
|
||||
st().loadProject(buildWettbewerbSampleProject());
|
||||
const p = st().project;
|
||||
const o = { ...presentationDefaults(p), paper: "a4" as const, orientation: "portrait" as const, scale: 50 };
|
||||
const o = { ...presentationDefaults(p), paper: "a3" as const, orientation: "portrait" as const, scale: 50 };
|
||||
expect(planPresentationSheet(p, o).fits).toBe(false);
|
||||
const s = fittingPresentationScale(p, o);
|
||||
expect(s).not.toBeNull();
|
||||
|
||||
@@ -37,8 +37,6 @@ import { generateAxoPlan } from "./toAxo";
|
||||
export const PRESENTATION_TEMPLATE_ID = "std-vt-praesentation";
|
||||
/** Rand zwischen Inhalt und Rahmen (mm, wie `FRAME_PAD_MM` im Kern). */
|
||||
const FRAME_PAD_MM = 4;
|
||||
/** [323] Rand im Präsentationsplan ohne Plakat (`SHEET_PAD_MM` im Kern). */
|
||||
const SHEET_PAD_MM = 8;
|
||||
|
||||
export interface PresentationOptions {
|
||||
/** Geschosse (Ebenen der Art `floor`) in Blattreihenfolge. */
|
||||
@@ -663,7 +661,7 @@ export function presentationSheetOps(
|
||||
drawings.push(
|
||||
tpl
|
||||
? sheetText(`d-pres-${stamp}-t${i}`, sheetLevels[page].id, cat, it.xMm + labelM.sizeMm * 3.6, it.yMm + it.heightMm + labelM.dyMm, title, labelM.sizeMm, true)
|
||||
: sheetText(`d-pres-${stamp}-t${i}`, sheetLevels[page].id, cat, it.xMm + SHEET_PAD_MM, it.yMm + it.heightMm + 6, `${title} 1:${it.scale}`, 4, true),
|
||||
: sheetText(`d-pres-${stamp}-t${i}`, sheetLevels[page].id, cat, it.xMm + FRAME_PAD_MM, it.yMm + it.heightMm + 6, `${title} 1:${it.scale}`, 4, true),
|
||||
);
|
||||
});
|
||||
// Nordpfeil rechts neben dem Titel des ersten Grundrisses, Massstabsbalken links davon, sofern er den Titel nicht berührt
|
||||
@@ -674,7 +672,7 @@ export function presentationSheetOps(
|
||||
const lvl = sheetLevels[it.page ?? 0].id;
|
||||
const titleEnd = tpl
|
||||
? it.xMm + labelM.sizeMm * 3.6 + title.length * labelM.sizeMm * 0.65
|
||||
: it.xMm + SHEET_PAD_MM + (title.length + 8) * 4 * 0.65;
|
||||
: it.xMm + FRAME_PAD_MM + (title.length + 8) * 4 * 0.65;
|
||||
const cx = it.xMm + it.widthMm - 8;
|
||||
const beside = cx - 8 > titleEnd;
|
||||
const cy = beside ? it.yMm + it.heightMm + 4.8 : it.yMm + 8;
|
||||
|
||||
@@ -53,6 +53,7 @@ import {
|
||||
findMaster,
|
||||
findSnapshot,
|
||||
resolveTitleBlock,
|
||||
titleBlockNameLines,
|
||||
resolveViewportScale,
|
||||
sheetMmToModel,
|
||||
sheetModelToMm,
|
||||
@@ -196,14 +197,17 @@ export function TitleBlockSvg({
|
||||
const x = sheet.w - boxW - pad;
|
||||
const y = sheet.h - boxH - pad;
|
||||
const fmt = `${paper.toUpperCase()} ${orientation === "landscape" ? "quer" : "hoch"}`;
|
||||
const name = titleBlockNameLines(tb.projectName);
|
||||
return (
|
||||
<g>
|
||||
<rect x={x} y={y} width={boxW} height={boxH} fill="#ffffff" stroke="#111111" strokeWidth={0.35} />
|
||||
<line x1={x} y1={y + 8} x2={x + boxW} y2={y + 8} stroke="#111111" strokeWidth={0.2} />
|
||||
<line x1={x} y1={y + boxH - 7} x2={x + boxW} y2={y + boxH - 7} stroke="#111111" strokeWidth={0.2} />
|
||||
<text x={x + 3} y={y + 5.6} fontSize={3.4} fontFamily="Helvetica, Arial, sans-serif" fontWeight="bold" fill="#111111">
|
||||
{clip(tb.projectName, 28)}
|
||||
</text>
|
||||
{name.lines.map((l, i) => (
|
||||
<text key={i} x={x + 3} y={y + name.baselines[i]} fontSize={3.4 * name.scale} fontFamily="Helvetica, Arial, sans-serif" fontWeight="bold" fill="#111111">
|
||||
{l}
|
||||
</text>
|
||||
))}
|
||||
<text x={x + boxW - 3} y={y + 5.6} fontSize={3.4} fontFamily="Helvetica, Arial, sans-serif" fontWeight="bold" fill="#111111" textAnchor="end">
|
||||
{tb.planNumber}
|
||||
</text>
|
||||
|
||||
Reference in new issue
Block a user