Merge [266] Plakat

This commit is contained in:
Claude committed 2026-11-16 16:25:04 +00:00
commit 9df2075c83
18 files changed
+429 -85

No files matched your search

+13
View File
@@ -117,6 +117,19 @@ describe("sectionline — Name der neuen Ebene", () => {
});
});
describe("sectionline — Ansichten nach Himmelsrichtung [266]", () => {
it("benennt neue Ansichten nach der gezeigten Seite, nicht nach Buchstaben", () => {
const p = projectWith([]);
// a→b nach Osten, Blick nach Norden: Linie südlich des Hauses = „Ansicht Süd“ (wie die Beispielprojekte).
expect(nextLevelName(p, "elevation")).toBe("Ansicht Süd");
const north = commitLine(p, { x: 5, y: 8 }, { x: 0, y: 8 }, "elevation").drawingLevels.at(-1)!;
expect(north.name).toBe("Ansicht Nord");
// Gleiche Richtung zweimal: Nummer statt Namensgleichheit.
const again = commitLine(commitLine(p, a, b, "elevation"), a, b, "elevation").drawingLevels.at(-1)!;
expect(again.name).toBe("Ansicht Süd 2");
});
});
describe("sectionline — geknickter Schnitt [176]", () => {
it("weitere Klicks werden Knickpunkte, Enter beendet; Doppelklick-Punkt zählt nicht doppelt", () => {
const p = projectWith([{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false }]);
+6 -2
View File
@@ -60,8 +60,12 @@ function lineDraft(ctx: CommandContext, pts: Vec2[], cursor: Vec2 | null): ToolD
* Vorlage, Buchstaben A, B, … nach Anzahl der Ebenen dieser Art); zu kurze Linien (< 0.1 m) → nichts.
*/
function lineMutation(ctx: CommandContext, a: Vec2, b: Vec2, kind: LineKind, bends: Vec2[] = []) {
const key = kind === "section" ? "cmd.sectionline.newSection" : "cmd.sectionline.newElevation";
return createMutation(ctx, { cmd: "sectionline", a, b, kind, name: t(key, { letter: "\u0001" }), ...(bends.length ? { bends } : {}) });
// [266] Ansichten heissen nach der Himmelsrichtung (Plan oben = Norden; \u0002 ersetzt der Kern), Schnitte nach Buchstaben.
if (kind === "elevation") {
const dirs = (["north", "east", "south", "west"] as const).map((d) => t(`cmd.sectionline.dir.${d}`));
return createMutation(ctx, { cmd: "sectionline", a, b, kind, name: t("cmd.sectionline.newElevation", { dir: "\u0002" }), dirs });
}
return createMutation(ctx, { cmd: "sectionline", a, b, kind, name: t("cmd.sectionline.newSection", { letter: "\u0001" }), ...(bends.length ? { bends } : {}) });
}
interface LineIdle extends CommandState {
+8 -3
View File
@@ -2106,7 +2106,11 @@ export const de = {
"cmd.sectionline.kind.section": "Schnitt",
"cmd.sectionline.kind.elevation": "Ansicht",
"cmd.sectionline.newSection": "Schnitt {letter}",
"cmd.sectionline.newElevation": "Ansicht {letter}",
"cmd.sectionline.newElevation": "Ansicht {dir}",
"cmd.sectionline.dir.north": "Nord",
"cmd.sectionline.dir.east": "Ost",
"cmd.sectionline.dir.south": "Süd",
"cmd.sectionline.dir.west": "West",
"cmd.opening.label": "Öffnung",
"cmd.opening.windowLabel": "Fenster",
"cmd.opening.doorLabel": "Tür",
@@ -4051,10 +4055,11 @@ export const de = {
"presentation.scale.common": "gemeinsamer Massstab",
"presentation.target.sheet": "Neues Blatt (Format wählen)",
"presentation.elevations": "Ansichten",
"presentation.section": "Schnitt",
"presentation.noSection": "Kein Schnitt",
"presentation.section": "Schnitte",
"presentation.noSection": "Keine Schnitte vorhanden",
"presentation.sheet": "Blatt",
"presentation.sketch": "Skizzenstil (gezeigte Ebenen)",
"presentation.autoDim": "Aussenbemassung der Grundrisse ergänzen (wo sie fehlt)",
"presentation.hint": "Vorgabe 1:200 (Wettbewerb); „automatisch“ wählt den grössten Massstab, der aufs Blatt passt; je Ansicht ist ein eigener wählbar; die Ausschnitte folgen der Ansichtsvorlage „Präsentation“.",
"presentation.create": "Erstellen",
"presentation.sheetName": "Präsentationsplan",
+8 -3
View File
@@ -2095,7 +2095,11 @@ export const en: Record<TranslationKey, string> = {
"cmd.sectionline.kind.section": "Section",
"cmd.sectionline.kind.elevation": "Elevation",
"cmd.sectionline.newSection": "Section {letter}",
"cmd.sectionline.newElevation": "Elevation {letter}",
"cmd.sectionline.newElevation": "Elevation {dir}",
"cmd.sectionline.dir.north": "North",
"cmd.sectionline.dir.east": "East",
"cmd.sectionline.dir.south": "South",
"cmd.sectionline.dir.west": "West",
"cmd.opening.label": "Opening",
"cmd.opening.windowLabel": "Window",
"cmd.opening.doorLabel": "Door",
@@ -4037,10 +4041,11 @@ export const en: Record<TranslationKey, string> = {
"presentation.scale.common": "Common scale",
"presentation.target.sheet": "New sheet (choose format)",
"presentation.elevations": "Elevations",
"presentation.section": "Section",
"presentation.noSection": "No section",
"presentation.section": "Sections",
"presentation.noSection": "No sections available",
"presentation.sheet": "Sheet",
"presentation.sketch": "Sketch style (shown views)",
"presentation.autoDim": "Add exterior dimensions to the plans (where missing)",
"presentation.hint": "Default 1:200 (competition); “automatic” picks the largest scale that fits the sheet; each view can have its own scale; the views follow the “Presentation” view template.",
"presentation.create": "Create",
"presentation.sheetName": "Presentation sheet",
+2 -2
View File
@@ -75,10 +75,10 @@ describe("Beispielprojekt Wettbewerb", () => {
expect(p.rooms!.filter((r) => r.name === "Wohnen/Essen").length).toBe(6);
});
it("Präsentationsplan A1 mit Grundrissen, Ansichten und Schnitt; Situation", () => {
it("Präsentationsplan A1 mit Grundrissen, Ansichten und beiden Schnitten; Situation", () => {
const sheet = p.layouts!.find((l) => l.name.includes("Präsentation"));
expect(sheet?.paper).toBe("a1");
expect(sheet!.viewports.length).toBe(3 + 4 + 1);
expect(sheet!.viewports.length).toBe(3 + 4 + 2);
expect(sheet!.viewports.every((v) => v.scaleDenominator === 200)).toBe(true);
const sit = p.layouts!.find((l) => l.id === "lay-situation");
expect(sit?.viewports[0].scaleDenominator).toBe(500);
+77 -9
View File
@@ -38,7 +38,7 @@ describe("[66] Präsentationsplan", () => {
const d = presentationDefaults(project);
expect(d.floors.length).toBeGreaterThanOrEqual(4);
expect(d.elevationIds.length).toBeGreaterThan(0);
expect(d.sectionId).not.toBeNull();
expect(d.sectionIds.length).toBeGreaterThan(0);
expect([d.paper, d.orientation]).toEqual(["a1", "landscape"]);
expect(d.sketch).toBe(false);
});
@@ -56,7 +56,7 @@ describe("[66] Präsentationsplan", () => {
expect(st().undoDepth).toBe(1);
const p = st().project;
const lay = p.layouts!.find((l) => l.id === layoutId)!;
expect(lay.viewports.length).toBe(o.floors.length + elevations + 1);
expect(lay.viewports.length).toBe(o.floors.length + elevations + o.sectionIds.length);
expect(lay.masterId).toBeTruthy();
const size = sheetSizeMm(lay.paper, lay.orientation);
for (const [i, v] of lay.viewports.entries()) {
@@ -97,7 +97,7 @@ describe("[66] Präsentationsplan", () => {
it("gewählte Geschosse, ohne Ansichten/Schnitt, Skizze an, A3: kleinerer Massstab", () => {
const floors = project.drawingLevels.filter((l) => l.kind === "floor" && !l.layoutId).slice(0, 2).map((l) => l.id);
const res = presentationSheetOps(project, { floors, elevationIds: [], scale: null, sectionId: null, paper: "a3", orientation: "landscape", sketch: true }, LABELS, "t2")!;
const res = presentationSheetOps(project, { floors, elevationIds: [], scale: null, sectionIds: [], paper: "a3", orientation: "landscape", sketch: true }, LABELS, "t2")!;
expect(res.plan.items.map((i) => i.levelId)).toEqual(floors);
expect(res.plan.scale).toBeGreaterThanOrEqual(100);
st().applyChange(res.ops);
@@ -107,7 +107,7 @@ describe("[66] Präsentationsplan", () => {
});
it("nichts gewählt ⇒ null, Projekt unverändert", () => {
expect(presentationSheetOps(project, { floors: [], elevationIds: [], scale: null, sectionId: null, paper: "a1", orientation: "landscape", sketch: false }, LABELS, "t3")).toBeNull();
expect(presentationSheetOps(project, { floors: [], elevationIds: [], scale: null, sectionIds: [], paper: "a1", orientation: "landscape", sketch: false }, LABELS, "t3")).toBeNull();
});
it("[224] Vorschlag: leere Geschosse nicht vorgewählt, Vorgabe 1:200", () => {
@@ -170,7 +170,7 @@ describe("[66] Präsentationsplan", () => {
it("[224] fester Massstab und Massstab je Viewport landen in Ausschnitt und Viewport", () => {
const floors = project.drawingLevels.filter((l) => l.kind === "floor" && !l.layoutId).slice(0, 2).map((l) => l.id);
const res = presentationSheetOps(project, { floors, elevationIds: [], scale: 200, scales: { [floors[1]]: 100 }, sectionId: null, paper: "a1", orientation: "landscape", sketch: false }, LABELS, "t4")!;
const res = presentationSheetOps(project, { floors, elevationIds: [], scale: 200, scales: { [floors[1]]: 100 }, sectionIds: [], paper: "a1", orientation: "landscape", sketch: false }, LABELS, "t4")!;
expect(res.plan.scale).toBe(200);
expect(res.plan.items.map((i) => i.scale)).toEqual([200, 100]);
st().applyChange(res.ops);
@@ -181,7 +181,7 @@ describe("[66] Präsentationsplan", () => {
it("[224] Plakat-Vorlage als Ziel: Master der Vorlage, Viewports unter der Kopfzeile", () => {
const floors = project.drawingLevels.filter((l) => l.kind === "floor" && !l.layoutId).slice(0, 2).map((l) => l.id);
const res = presentationSheetOps(project, { floors, elevationIds: [], scale: 200, sectionId: null, paper: "a4", orientation: "portrait", sketch: false, poster: "poster-a1-landscape" }, LABELS, "t5")!;
const res = presentationSheetOps(project, { floors, elevationIds: [], scale: 200, sectionIds: [], paper: "a4", orientation: "portrait", sketch: false, poster: "poster-a1-landscape" }, LABELS, "t5")!;
st().applyChange(res.ops);
const p = st().project;
const lay = p.layouts!.find((l) => l.id === res.layoutId)!;
@@ -202,7 +202,8 @@ describe("[66] Präsentationsplan", () => {
st().applyChange(res.ops);
const q = st().project;
const tpl = q.viewTemplates!.find((t) => t.id === PRESENTATION_TEMPLATE_ID)!;
const show = new Set(Object.entries(q.viewSnapshots!.find((v) => v.id === "vs-pres-t6-0")!.layerVisibility).filter(([, v]) => v).map(([k]) => k));
// Marken ([266]) liegen weit ums Haus und werden vom Ausschnitt bewusst beschnitten: ohne sie vergleichen.
const show = new Set(Object.entries(q.viewSnapshots!.find((v) => v.id === "vs-pres-t6-0")!.layerVisibility).filter(([k, v]) => v && k !== "91").map(([k]) => k));
for (const it of res.plan.items.filter((i) => i.group === 0)) {
const b = generatePlan(q, it.levelId, show, undefined, tpl.detail, false, true, true, 200, false, false).bounds;
// Rahmen um die eigene Bildmitte (deckungsgleiche Grundrisse) umfasst das ganze Ausmass (hier ohne fernen Kontext).
@@ -295,7 +296,9 @@ describe("[66] Präsentationsplan", () => {
it("[208] Plakat mit Situation, Tabellen und Bild-Rahmen: alles im Satzspiegel, ohne Überlappung, feste Massstäbe, Blatt bis unten gefüllt", () => {
st().loadProject(buildWettbewerbSampleProject());
const p = st().project;
const o = { ...presentationDefaults(p), scale: 200, poster: "poster-a1-landscape", extras: POSTER_EXTRAS_DEFAULT };
// [266] Mit Schnitt-/Ansichtsmarken brauchen die Grundrisse mehr Rand: Auswahl so, dass alles auf ein Blatt passt.
const d = presentationDefaults(p);
const o = { ...d, elevationIds: d.elevationIds.slice(0, 1), sectionIds: [], scale: 200, poster: "poster-a1-landscape", extras: POSTER_EXTRAS_DEFAULT };
const plan = planPresentationSheet(p, o);
expect(plan.pages ?? 1).toBe(1);
expect(plan.fits).toBe(true);
@@ -313,7 +316,10 @@ describe("[66] Präsentationsplan", () => {
for (const i of plan.items) expect(i.scale).toBe(i.kind === "situation" ? 500 : 200);
// Situation steht am Anfang (oben links).
const sit = plan.items.find((i) => i.kind === "situation")!;
expect([sit.xMm, sit.yMm]).toEqual([m.marginMm, m.contentTopMm]);
// [266] Freier Platz wird als Weissraum verteilt: die Situation steht an der ersten Zeile, nicht zwingend direkt unter der Kopfzeile.
expect(sit.xMm).toBe(m.marginMm);
expect(sit.yMm).toBeGreaterThanOrEqual(m.contentTopMm);
expect(Math.min(...plan.items.map((i) => i.yMm))).toBe(sit.yMm);
const left = m.marginMm;
const right = 841 - m.marginMm;
const bottom = 594 - m.marginMm;
@@ -360,4 +366,66 @@ describe("[66] Präsentationsplan", () => {
expect(plan.tables).toEqual([]);
expect(plan.image ?? null).toBeNull();
}, 60_000);
// [266] Befunde aus dem Wettbewerbs-Durchlauf: Marken, mehrere Schnitte, Aussenbemassung, Planzeichen der Situation, Bildgrösse.
it("[266] Schnitt-/Ansichtsmarken sind in den Plakat-Grundrissen sichtbar, mehrere Schnitte wählbar", () => {
const sections = project.drawingLevels.filter((l) => l.kind === "section").map((l) => l.id);
expect(sections.length).toBeGreaterThanOrEqual(2);
const floors = project.drawingLevels.filter((l) => l.kind === "floor" && !l.layoutId && levelHasContent(project, l.id)).slice(0, 2).map((l) => l.id);
const res = presentationSheetOps(project, { floors, elevationIds: [], scale: 200, sectionIds: sections, paper: "a1", orientation: "landscape", sketch: false, poster: "poster-a1-landscape" }, LABELS, "m1")!;
st().applyChange(res.ops);
const q = st().project;
const lay = q.layouts!.find((l) => l.id === res.layoutId)!;
expect(lay.viewports).toHaveLength(floors.length + sections.length);
const snap = (i: number) => q.viewSnapshots!.find((v) => v.id === lay.viewports[i].snapshotId)!;
expect(snap(0).layerVisibility["91"]).toBe(true);
// Ohne Schnitte und Ansichten bleibt die Vorlage (Marken aus).
const none = presentationSheetOps(st().project, { floors, elevationIds: [], scale: 200, sectionIds: [], paper: "a1", orientation: "landscape", sketch: false, poster: "poster-a1-landscape" }, LABELS, "m2")!;
st().applyChange(none.ops);
expect(st().project.viewSnapshots!.find((v) => v.id === "vs-pres-m2-0")!.layerVisibility["91"]).toBe(false);
}, 60_000);
it("[266] Aussenbemassung wird für Grundrisse ohne Ketten ergänzt, vorhandene bleiben", () => {
const strip = { ...project, drawings2d: project.drawings2d.filter((d) => !d.id.startsWith("autodim-")) };
st().loadProject(strip);
const p = st().project;
const floors = p.drawingLevels.filter((l) => l.kind === "floor" && !l.layoutId && levelHasContent(p, l.id)).slice(0, 2).map((l) => l.id);
const base = { floors, elevationIds: [], scale: 200, sectionIds: [], paper: "a1" as const, orientation: "landscape" as const, sketch: false };
const off = presentationSheetOps(p, base, LABELS, "d0")!;
st().applyChange(off.ops);
expect(st().project.drawings2d.some((d) => d.id.startsWith("autodim-"))).toBe(false);
st().loadProject(strip);
const on = presentationSheetOps(st().project, { ...base, autoDim: true }, LABELS, "d1")!;
st().applyChange(on.ops);
for (const f of floors) expect(st().project.drawings2d.some((d) => d.id.startsWith(`autodim-${f}-`) && d.categoryCode === "81")).toBe(true);
// Zweiter Lauf: nichts doppelt (die Ketten tragen feste Ids).
const n = st().project.drawings2d.filter((d) => d.id.startsWith("autodim-")).length;
const again = presentationSheetOps(st().project, { ...base, autoDim: true }, LABELS, "d2")!;
st().applyChange(again.ops);
expect(st().project.drawings2d.filter((d) => d.id.startsWith("autodim-")).length).toBe(n);
}, 90_000);
it("[266] Situation: Planzeichen am Rahmenrand statt in der Zeichnung, Bild nicht grösser als der grösste Plan", () => {
st().loadProject(buildWettbewerbSampleProject());
const p = st().project;
const o = { ...presentationDefaults(p), scale: 200, poster: "poster-a1-portrait", extras: POSTER_EXTRAS_DEFAULT };
const res = presentationSheetOps(p, o, LABELS, "s1")!;
st().applyChange(res.ops);
const q = st().project;
const sit = res.plan.items.find((i) => i.kind === "situation")!;
const lay = q.layouts!.find((l) => l.id === res.layoutId)!;
const sitSnap = q.viewSnapshots!.find((v) => v.id === lay.viewports[0].snapshotId)!;
expect(sitSnap.layerVisibility["84"]).toBe(false);
const grp = q.groups!.find((g) => g.id === "grp-pres-s1-sit-n")!;
const arrow = q.drawings2d.filter((d) => grp.drawingIds.includes(d.id) && d.geom.shape === "circle");
expect(arrow).toHaveLength(1);
// Mitte des Nordpfeils: unter dem Rahmen der Situation (Papier-mm = Modell-m × 1000).
const c = (arrow[0].geom as { center: { x: number; y: number } }).center;
expect(-c.y * 1000).toBeGreaterThan(sit.yMm + sit.heightMm);
const plans = res.plan.items.filter((i) => i.group === 0);
expect(res.plan.image!.heightMm).toBeLessThanOrEqual(Math.max(...plans.map((i) => i.heightMm), 0.14 * 700) + 1e-6);
// Weissraum: der Inhalt reicht auf Blatt 1 nicht nur ins obere Drittel.
const bottoms = [...res.plan.items, ...(res.plan.tables ?? []), ...(res.plan.image ? [res.plan.image] : [])].filter((i) => (i.page ?? 0) === 0).map((i) => i.yMm + i.heightMm);
expect(Math.max(...bottoms)).toBeGreaterThan(841 * 0.6);
}, 90_000);
});
+67 -26
View File
@@ -28,7 +28,7 @@ import { addedItems, addItems, patchItem } from "../core/opsBuild";
import { standardModelViews, standardsMergeOps } from "../model/standards";
import { imageAspect } from "../model/layoutImages";
import { createLayout, createMasterLayout, createSheetLevel, sheetMmToModel, sheetSizeMm } from "../model/layoutModel";
import { SHADOW_CATEGORY } from "../model/derivedCategories";
import { SECTION_MARK_CATEGORY, SHADOW_CATEGORY, SYMBOL_CATEGORY } from "../model/derivedCategories";
import { createPosterMaster, findPosterMaster, posterMetrics, posterTemplate, scaleLabelMetrics } from "../model/posterTemplates";
/** Id der Standard-Ansichtsvorlage „Präsentation" (`standards.rs`). */
@@ -41,8 +41,8 @@ export interface PresentationOptions {
floors: string[];
/** Gewählte Ansichten (Ebenen der Art `elevation`) in Blattreihenfolge. */
elevationIds: string[];
/** Ein Schnitt (Ebene der Art `section`) oder keiner. */
sectionId: string | null;
/** [266] Gewählte Schnitte (Ebenen der Art `section`) in Blattreihenfolge. */
sectionIds: string[];
paper: LayoutPaperFormat;
orientation: LayoutOrientation;
/** Skizzenstil ([67]) für die gezeigten Ebenen. */
@@ -51,6 +51,8 @@ export interface PresentationOptions {
scale: number | null;
/** [224] Massstab je Ebene (übersteuert `scale`). */
scales?: Record<string, number>;
/** [266] Aussenbemassung (Befehl `autodim`, Gesamtmass je Seite) für die Grundrisse ergänzen, wo sie fehlt. Fehlt die Angabe: nein. */
autoDim?: boolean;
/** [224] Plakat-Vorlage ([208], Schlüssel in `POSTER_TEMPLATES`) als Ziel; fehlt sie, gilt `paper`/`orientation`. */
poster?: string;
/** [208] Zusätzliche Plakat-Inhalte (nur mit `poster`): Situation 1:500, Tabellen, 3D-Bild-Platzhalter. */
@@ -160,7 +162,7 @@ export function levelHasContent(project: Project, levelId: string): boolean {
return false;
}
/** Vorschlag für den Dialog: Geschosse mit Inhalt, alle Ansichten, erster Schnitt, 1:200; Blatt des meistgenutzten Masters, sonst A1 quer. */
/** Vorschlag für den Dialog: Geschosse mit Inhalt, alle Ansichten und Schnitte, Aussenbemassung, 1:200; Blatt des meistgenutzten Masters, sonst A1 quer. */
export function presentationDefaults(project: Project): PresentationOptions {
const levels = project.drawingLevels;
const masters = project.masterLayouts ?? [];
@@ -171,11 +173,12 @@ export function presentationDefaults(project: Project): PresentationOptions {
return {
floors: levels.filter((l) => isFloor(l) && levelHasContent(project, l.id)).map((l) => l.id),
elevationIds: levels.filter((l) => l.kind === "elevation").map((l) => l.id),
sectionId: levels.find((l) => l.kind === "section")?.id ?? null,
sectionIds: levels.filter((l) => l.kind === "section").map((l) => l.id),
paper: usable ? master.paper : "a1",
orientation: usable ? master.orientation : "landscape",
sketch: false,
scale: PRESENTATION_DEFAULT_SCALE,
autoDim: true,
};
}
@@ -209,10 +212,12 @@ function categoryCodes(cats: readonly LayerCategory[], out: string[] = []): stri
* Umgebung (Kataster, Strassen, Baurecht, Gelände, Höhenlinien — dafür gibt es den Situationsplan): sonst
* bestimmen Parzelle und Geländemodell Grösse und Massstab jeder Zeichnung.
*/
function presentationVisibility(project: Project, t: ViewTemplate): Record<string, boolean> {
function presentationVisibility(project: Project, t: ViewTemplate, marks = false): Record<string, boolean> {
const vis: Record<string, boolean> = {};
for (const c of categoryCodes(project.layers)) vis[c] = true;
const out: Record<string, boolean> = { ...vis, ...(t.layerVisibility ?? {}) };
// [266] Schnitt- und Ansichtsmarken im Grundriss, wenn das Blatt Schnitte/Ansichten zeigt (die Vorlage blendet sie sonst aus).
if (marks) out[SECTION_MARK_CATEGORY] = true;
for (const c of siteCodes(project)) out[c] = false;
return out;
}
@@ -241,7 +246,7 @@ function chosenLevels(project: Project, o: PresentationOptions): { id: string; g
const out: { id: string; group: number }[] = [];
for (const id of o.floors) if (byId.get(id) && isFloor(byId.get(id)!)) out.push({ id, group: 0 });
for (const id of o.elevationIds) if (byId.get(id)?.kind === "elevation") out.push({ id, group: 1 });
if (o.sectionId && byId.get(o.sectionId)?.kind === "section") out.push({ id: o.sectionId, group: 2 });
for (const id of o.sectionIds ?? []) if (byId.get(id)?.kind === "section") out.push({ id, group: 2 });
return out;
}
@@ -301,7 +306,8 @@ function situationLevelId(project: Project, o: PresentationOptions): string | un
function situationVisibility(project: Project, t: ViewTemplate): Record<string, boolean> {
const vis: Record<string, boolean> = {};
for (const c of categoryCodes(project.layers)) vis[c] = true;
return { ...vis, ...(t.layerVisibility ?? {}), [SHADOW_CATEGORY]: false };
// Nordpfeil und Massstabsbalken setzt das Blatt an den Rahmenrand ([266]): in der Zeichnung lägen sie auf Parzelle oder Strasse.
return { ...vis, ...(t.layerVisibility ?? {}), [SHADOW_CATEGORY]: false, [SYMBOL_CATEGORY]: false };
}
/** Die Vorlage „Situation WBW“ des Projekts bzw. aus den Standards (dann fehlt sie im Projekt und muss mit angelegt werden). */
@@ -318,6 +324,13 @@ function posterTextMetrics(size: { w: number; h: number }): { sizeMm: number; dy
return { sizeMm: m.sizeMm, dyMm: m.dyMm, bandMm: m.dyMm + m.sizeMm * 0.8, tablePt: Math.round((Math.min(size.w, size.h) / 594) * 13) };
}
/**
* [266] Zeigt das Plakat Schnitte oder Ansichten (dann stehen deren Marken in den Grundrissen)? Nur beim Plakat: dort gibt der
* Kern jedem Grundriss einen Ausschnitt um das Haus (mit Platz für die Marken); ein gewöhnliches Blatt zeigt das ganze Ausmass,
* und Marken weit vom Haus würden die Pläne vergrössern. Die Marken folgen den Linien des Projekts (auch ungewählter Schnitte).
*/
const showsMarks = (o: PresentationOptions) => !!o.poster && (o.elevationIds.length > 0 || (o.sectionIds ?? []).length > 0);
/** Massstab und Rahmen aus dem Kern (ohne das Projekt zu ändern). */
export function planPresentationSheet(project: Project, o: PresentationOptions): PresentationPlan {
const { template } = presentationTemplate(project);
@@ -326,7 +339,7 @@ export function planPresentationSheet(project: Project, o: PresentationOptions):
// Plakat: Kopfzeile und Ränder der Vorlage, kein Schriftfeld des Masters.
const poster = o.poster && posterTemplate(o.poster) ? posterMetrics(size.w, size.h) : null;
const levels = chosenLevels(project, o);
const vis = presentationVisibility(project, template);
const vis = presentationVisibility(project, template, showsMarks(o));
let posterReq: Record<string, unknown> | undefined;
if (poster) {
const ex = o.extras;
@@ -357,6 +370,7 @@ export function planPresentationSheet(project: Project, o: PresentationOptions):
template,
...(o.scale ? { scale: o.scale } : {}),
scales: o.scales ?? {},
...(showsMarks(o) ? { marks: true } : {}),
...(poster ? { marginMm: poster.marginMm, topMm: poster.contentTopMm } : {}),
...(posterReq ? { poster: posterReq } : {}),
});
@@ -437,6 +451,22 @@ function lastLayoutImage(project: Project): LayoutImage | undefined {
return all[all.length - 1];
}
/**
* [266] Aussenbemassung (Gesamtmasse je Gebäudeseite, Befehl `autodim`) für die gezeigten Grundrisse, wo sie noch fehlt: ohne
* Bemassung gibt ein Wettbewerbsplan 1:200 keine Hausgrösse an. Vorhandene Ketten bleiben (auch von Hand verschobene).
*/
function autoDimOps(project: Project, plan: PresentationPlan, cat: string, stamp: string): CoreOp[] {
const out: CoreOp[] = [];
const done = new Set<string>();
for (const it of plan.items) {
if (it.group !== 0 || it.kind === "situation" || done.has(it.levelId)) continue;
done.add(it.levelId);
if (project.drawings2d.some((d) => d.levelId === it.levelId && d.id.startsWith(`autodim-${it.levelId}-`))) continue;
out.push(...documentFor(project).cmdOps({ cmd: "autodim", ctx: { level: it.levelId, cat }, scale: it.scale, stamp }));
}
return out;
}
/**
* Ops für das Präsentationsblatt (ein Undo-Schritt, wenn sie zusammen angewendet werden): Layout mit
* Blatt-Ebene und Master (neu, falls keiner zum Format passt), je Ebene ein an „Präsentation" gebundener
@@ -456,6 +486,7 @@ export function presentationSheetOps(
const { template, isNew } = presentationTemplate(project);
const ops: CoreOp[] = [];
if (isNew) ops.push(...addItems("viewTemplates", [template]));
if (o.autoDim) ops.push(...autoDimOps(project, plan, annotationCategory(project), stamp));
const sheet = targetSheet(o);
const tpl = o.poster ? posterTemplate(o.poster) : undefined;
let master = masterFor(project, o);
@@ -484,7 +515,7 @@ export function presentationSheetOps(
masterId: master.id,
}));
const sheetLevels = layouts.map((l) => createSheetLevel(`sheet-${l.id}`, l));
const vis = presentationVisibility(project, template);
const vis = presentationVisibility(project, template, showsMarks(o));
const cat = annotationCategory(project);
const byId = new Map(project.drawingLevels.map((l) => [l.id, l]));
const snaps: ViewSnapshot[] = [];
@@ -537,25 +568,33 @@ export function presentationSheetOps(
: 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.
const firstFloor = plan.items.find((it) => it.group === 0 && it.kind !== "situation");
if (firstFloor) {
const lvl = sheetLevels[firstFloor.page ?? 0].id;
const cx = firstFloor.xMm + firstFloor.widthMm - 8;
const cy = firstFloor.yMm + firstFloor.heightMm + 4.8;
const north = northArrow(stamp, lvl, cat, cx, cy, 3.6, labels.north);
// Nordpfeil rechts neben dem Titel des ersten Grundrisses, Massstabsbalken links davon, sofern er den Titel nicht berührt
// (Breite grob 0.65 × Schrifthöhe je Zeichen). [266] Dasselbe für die Situation am Rahmenrand unter dem Plan: in der Zeichnung
// lägen die Planzeichen auf Parzelle oder Strasse. Ist der Rahmen so schmal, dass schon der Pfeil den Titel berührt (kleines
// Haus), steht der Pfeil in der oberen rechten Ecke des Rahmens und der Balken entfällt.
const symbols = (it: PresentationItem, key: string, title: string, ids: { n: string; s: string }) => {
const lvl = sheetLevels[it.page ?? 0].id;
const titleEnd = tpl
? it.xMm + labelM.sizeMm * 3.6 + title.length * labelM.sizeMm * 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;
const north = northArrow(key, lvl, cat, cx, cy, 3.6, labels.north);
drawings.push(...north);
group(`grp-pres-${stamp}-n`, labels.northGroup, north);
// Massstabsbalken links vom Nordpfeil, sofern er den Titel nicht berührt (Breite grob 0.65 × Schrifthöhe je Zeichen).
const bar = scaleBar(stamp, lvl, cat, cx - 3.6 - 10, cy - 1, firstFloor.scale);
const title = byId.get(firstFloor.levelId)!.name;
const titleEnd = firstFloor.xMm + FRAME_PAD_MM + (title.length + 8) * 4 * 0.65;
group(ids.n, labels.northGroup, north);
if (!beside) return;
const bar = scaleBar(key, lvl, cat, cx - 3.6 - 10, cy - 1, it.scale);
const barLeft = Math.min(...bar.flatMap((d) => (d.geom.shape === "polyline" ? d.geom.pts.map((p) => p.x * 1000) : [])));
if (barLeft - 6 > titleEnd) {
drawings.push(...bar);
group(`grp-pres-${stamp}-s`, labels.scaleBarGroup, bar);
group(ids.s, labels.scaleBarGroup, bar);
}
}
};
const firstFloor = plan.items.find((it) => it.group === 0 && it.kind !== "situation");
if (firstFloor) symbols(firstFloor, stamp, byId.get(firstFloor.levelId)!.name, { n: `grp-pres-${stamp}-n`, s: `grp-pres-${stamp}-s` });
const sit = plan.items.find((it) => it.kind === "situation");
if (sit) symbols(sit, `${stamp}-sit`, labels.situation ?? byId.get(sit.levelId)!.name, { n: `grp-pres-${stamp}-sit-n`, s: `grp-pres-${stamp}-sit-s` });
// [208] Blatt-Tabellen mit Titel im Band darüber.
const fontPt = posterTextMetrics(size).tablePt;
for (const tb of plan.tables ?? []) {
@@ -585,12 +624,14 @@ export function presentationSheetOps(
images[box.page].push({ ...existing, id: `img-pres-${stamp}`, xMm: box.xMm, yMm: box.yMm, widthMm: w, heightMm: h });
} else {
const ph = labels.imagePlaceholder ?? "";
const size1 = labelM.sizeMm * 1.6;
// Schrift passt sich dem Rahmen an (ein kleines Haus gibt ein kleines Bild-Rahmen).
const size1 = Math.min(labelM.sizeMm * 1.6, (box.widthMm * 0.9) / (Math.max(ph.length, 1) * 0.55));
const sizeHint = Math.min(labelM.sizeMm, (box.widthMm * 0.92) / (Math.max((labels.imageHint ?? "").length, 1) * 0.5));
drawings.push(
sheetRect(`d-pres-${stamp}-ph0`, lvl, cat, box.xMm, box.yMm, box.widthMm, box.heightMm, { weightMm: 0.35, color: "#8a8a8a" }),
sheetText(`d-pres-${stamp}-ph1`, lvl, cat, box.xMm + box.widthMm / 2 - ph.length * size1 * 0.27, box.yMm + box.heightMm / 2, ph, size1, true),
);
if (labels.imageHint) drawings.push(sheetText(`d-pres-${stamp}-ph2`, lvl, cat, box.xMm + box.widthMm / 2 - labels.imageHint.length * labelM.sizeMm * 0.25, box.yMm + box.heightMm / 2 + size1 * 1.5, labels.imageHint, labelM.sizeMm));
if (labels.imageHint) drawings.push(sheetText(`d-pres-${stamp}-ph2`, lvl, cat, box.xMm + box.widthMm / 2 - labels.imageHint.length * sizeHint * 0.25, box.yMm + box.heightMm / 2 + size1 * 1.5, labels.imageHint, sizeHint));
}
}
layouts.forEach((l, k) => {
+25 -16
View File
@@ -60,9 +60,11 @@ export const PresentationDialogHost = memo(function PresentationDialogHost({
set({ floors: floors.map((f) => f.id).filter((f) => (f === id ? on : opts.floors.includes(f))) });
const toggleElevation = (id: string, on: boolean) =>
set({ elevationIds: elevations.map((e) => e.id).filter((e) => (e === id ? on : opts.elevationIds.includes(e))) });
const toggleSection = (id: string, on: boolean) =>
set({ sectionIds: sections.map((x) => x.id).filter((x) => (x === id ? on : opts.sectionIds.includes(x))) });
const toggleTable = (kind: PosterTableKind, on: boolean): PosterTableKind[] =>
(["areas", "siteProof"] as const).filter((k) => (k === kind ? on : (opts.extras?.tables ?? []).includes(k)));
const empty = opts.floors.length === 0 && opts.elevationIds.length === 0 && !opts.sectionId;
const empty = opts.floors.length === 0 && opts.elevationIds.length === 0 && opts.sectionIds.length === 0;
// [224] Massstab je Viewport: "" = gemeinsamer Massstab.
const scaleOf = (id: string) => String(opts.scales?.[id] ?? "");
const setScaleOf = (id: string, v: string) => {
@@ -132,21 +134,19 @@ export const PresentationDialogHost = memo(function PresentationDialogHost({
</section>
<section className="imp-section">
<div className="imp-section-title">{t("presentation.section")}</div>
<select
className="imp-select"
data-testid="presentation-section"
aria-label={t("presentation.section")}
value={opts.sectionId ?? ""}
onChange={(e) => set({ sectionId: e.target.value || null })}
>
<option value="">{t("presentation.noSection")}</option>
{sections.map((s) => (
<option key={s.id} value={s.id}>
{s.name}
</option>
))}
</select>
{opts.sectionId && <div style={{ display: "flex", marginTop: 4 }}>{scaleSelect(opts.sectionId)}</div>}
{sections.length === 0 && <div style={{ color: "var(--muted)" }}>{t("presentation.noSection")}</div>}
{sections.map((sec) => (
<label key={sec.id} className="imp-check" style={{ display: "flex", gap: 6, alignItems: "center" }}>
<input
type="checkbox"
data-testid={`presentation-section-${sec.id}`}
checked={opts.sectionIds.includes(sec.id)}
onChange={(ev) => toggleSection(sec.id, ev.target.checked)}
/>
{sec.name}
{scaleSelect(sec.id)}
</label>
))}
</section>
<section className="imp-section">
<div className="imp-section-title">{t("presentation.sheet")}</div>
@@ -241,6 +241,15 @@ export const PresentationDialogHost = memo(function PresentationDialogHost({
/>
{t("presentation.sketch")}
</label>
<label className="imp-check" style={{ display: "flex", gap: 6, alignItems: "center" }}>
<input
type="checkbox"
data-testid="presentation-autodim"
checked={!!opts.autoDim}
onChange={(e) => set({ autoDim: e.target.checked })}
/>
{t("presentation.autoDim")}
</label>
</section>
<p style={{ fontSize: 11, color: "var(--muted)", margin: "4px 0 0" }}>{t("presentation.hint")}</p>
</div>