[208] Plakat: Situation 1:500, Kennzahlen- und Baurecht-Tabelle, 3D-Bild-Rahmen auf dem Spaltenraster, weitere Plakate statt kleinerem Massstab, kein Schriftfeld bei Plakat-Vorlage

This commit is contained in:
Claude committed 2026-11-14 14:44:48 +00:00
1 parent 6eb0855b1c
commit 1269340fb2
14 files changed
+806 -33

No files matched your search

+2 -2
View File
@@ -94,8 +94,8 @@ export { AI_TOOLS, AI_BRIDGE_DEFAULT_PORT, aiText, aiToolDef, hmacHex, randomHex
export type { AiToolDef, AiToolResult, AiBridgeMsg } from "./aiToolDefs";
export { callAiTool } from "./aiTools";
export type { AiHost } from "./aiTools";
export { PRESENTATION_SCALES, PRESENTATION_DEFAULT_SCALE, levelHasContent, PRESENTATION_TEMPLATE_ID, presentationDefaults, presentationSheetOps, planPresentationSheet } from "../plan/presentationSheet";
export type { PresentationOptions, PresentationPlan, PresentationLabels } from "../plan/presentationSheet";
export { PRESENTATION_SCALES, POSTER_EXTRAS_DEFAULT, POSTER_SITUATION_SCALE, PRESENTATION_DEFAULT_SCALE, levelHasContent, PRESENTATION_TEMPLATE_ID, presentationDefaults, presentationSheetOps, planPresentationSheet } from "../plan/presentationSheet";
export type { PresentationOptions, PosterExtras, PosterTableKind, PresentationPlan, PresentationLabels } from "../plan/presentationSheet";
export { lineEndsOf, lineEndsCode, lineEndsFromCode, lineEndsSvgAttrs, planLineEndsProps, MITER_LIMIT as LINE_MITER_LIMIT } from "../model/lineEnds";
export type { LineEnds } from "../model/lineEnds";
export type { LineCap, LineJoin } from "../model/types";
+2 -2
View File
@@ -284,8 +284,8 @@ async function renderPage(
doc.setLineWidth(0.35);
doc.rect(5, 5, widthMm - 10, heightMm - 10);
}
const tb = resolveTitleBlock(project, layout, master);
drawTitleBlock(doc, widthMm, heightMm, tb, layout.paper, layout.orientation, ctx.includeRevision);
// [208] Plakat-Vorlage: Kopfzeile statt Schriftfeld.
if (!master.posterHeader) drawTitleBlock(doc, widthMm, heightMm, resolveTitleBlock(project, layout, master), layout.paper, layout.orientation, ctx.includeRevision);
if (master.posterHeader) drawPosterHeaderPdf(doc, project, layout, master, { w: widthMm, h: heightMm });
});
}
+11
View File
@@ -4032,6 +4032,17 @@ export const de = {
"presentation.done": "Präsentationsplan 1:{scale} mit {n} Ansichten erstellt",
"presentation.tooBig": "Präsentationsplan: passt auch 1:{scale} nicht ganz aufs Blatt – grösseres Format wählen",
"presentation.empty": "Präsentationsplan: keine Ansicht mit Inhalt gewählt",
"presentation.extras": "Plakat-Inhalt",
"presentation.extras.situation": "Situation 1:500",
"presentation.extras.areas": "Kennzahlen (SIA 416)",
"presentation.extras.siteProof": "Baurecht-Nachweis",
"presentation.extras.image": "Rahmen fürs 3D-Bild",
"presentation.situation": "Situation",
"presentation.table.areas": "Kennzahlen (SIA 416)",
"presentation.table.siteProof": "Baurecht-Nachweis",
"presentation.image.placeholder": "3D-Bild hier einsetzen",
"presentation.image.hint": "Rendering-Dialog: „Ins Layout einsetzen“, oder Knopf „Bild“ im Blatt",
"presentation.donePages": "Präsentationsplan 1:{scale} auf {pages} Plakaten erstellt",
"presentation.failed": "Präsentationsplan konnte nicht erstellt werden",
// [211] Rendering mit Blender/Cycles
"cmd.rendering.label": "Rendering…",
+11
View File
@@ -4018,6 +4018,17 @@ export const en: Record<TranslationKey, string> = {
"presentation.done": "Presentation sheet 1:{scale} with {n} views created",
"presentation.tooBig": "Presentation sheet: does not fully fit even at 1:{scale} – choose a larger format",
"presentation.empty": "Presentation sheet: no view with content chosen",
"presentation.extras": "Poster content",
"presentation.extras.situation": "Site plan 1:500",
"presentation.extras.areas": "Key figures (SIA 416)",
"presentation.extras.siteProof": "Zoning compliance",
"presentation.extras.image": "Frame for the 3D image",
"presentation.situation": "Site plan",
"presentation.table.areas": "Key figures (SIA 416)",
"presentation.table.siteProof": "Zoning compliance",
"presentation.image.placeholder": "Insert 3D image here",
"presentation.image.hint": "Rendering dialog: \"Insert into layout\", or the \"Image\" button on the sheet",
"presentation.donePages": "Presentation sheet 1:{scale} created on {pages} posters",
"presentation.failed": "Could not create the presentation sheet",
// [211] Rendering mit Blender/Cycles
"cmd.rendering.label": "Rendering…",
+82 -2
View File
@@ -5,10 +5,21 @@ import { generatePlan } from "./generatePlan";
import { getState } from "../state/appStore";
import { sheetSizeMm } from "../model/layoutModel";
import { posterMetrics } from "../model/posterTemplates";
import { PRESENTATION_TEMPLATE_ID, levelHasContent, presentationDefaults, presentationSheetOps } from "./presentationSheet";
import { POSTER_EXTRAS_DEFAULT, PRESENTATION_TEMPLATE_ID, levelHasContent, planPresentationSheet, presentationDefaults, presentationSheetOps } from "./presentationSheet";
import type { Project } from "../model/types";
const LABELS = { sheetName: "Präsentationsplan", masterName: "Planrahmen", north: "N", northGroup: "Nordpfeil", scaleBarGroup: "Massstabsbalken" };
const LABELS = {
sheetName: "Präsentationsplan",
masterName: "Planrahmen",
north: "N",
northGroup: "Nordpfeil",
scaleBarGroup: "Massstabsbalken",
situation: "Situation",
tableAreas: "Kennzahlen (SIA 416)",
tableSiteProof: "Baurecht-Nachweis",
imagePlaceholder: "3D-Bild hier einsetzen",
imageHint: "Hinweis",
};
const st = () => getState();
function overlaps(a: { xMm: number; yMm: number; widthMm: number; heightMm: number }, b: typeof a): boolean {
@@ -151,4 +162,73 @@ describe("[66] Präsentationsplan", () => {
expect(it.heightMm).toBeGreaterThanOrEqual(((b.maxY - b.minY) * 1000) / 200 - 1e-6);
}
}, 60_000);
// [208] Plakat als abgabefähiges Grundgerüst: Situation 1:500, Pläne 1:200, Tabellen, Bild-Rahmen auf dem 6-Spalten-Raster.
it("[208] Plakat mit Situation, Tabellen und Bild-Rahmen: alles im Satzspiegel, ohne Überlappung, feste Massstäbe, ≥ 70 % belegt", () => {
st().loadProject(buildWettbewerbSampleProject());
const p = st().project;
const o = { ...presentationDefaults(p), 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);
const m = posterMetrics(841, 594);
const band = plan.bandMm!;
type Box = { xMm: number; yMm: number; widthMm: number; heightMm: number };
const boxes: Box[] = [
...plan.items.map((i) => ({ ...i, heightMm: i.heightMm + band })),
...plan.tables!,
plan.image!,
];
expect(plan.items.filter((i) => i.kind === "situation")).toHaveLength(1);
expect(plan.tables!.map((t) => t.id)).toEqual(["areas", "siteProof"]);
expect(plan.image).toBeTruthy();
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]);
const left = m.marginMm;
const right = 841 - m.marginMm;
const bottom = 594 - m.marginMm;
for (const [k, b] of boxes.entries()) {
expect(b.xMm).toBeGreaterThanOrEqual(left - 1e-6);
expect(b.xMm + b.widthMm).toBeLessThanOrEqual(right + 1e-6);
expect(b.yMm).toBeGreaterThanOrEqual(m.contentTopMm - 1e-6);
expect(b.yMm + b.heightMm).toBeLessThanOrEqual(bottom + 1e-6);
for (const c of boxes.slice(k + 1)) expect(overlaps(b, c)).toBe(false);
}
const used = boxes.reduce((a, b) => a + b.widthMm * b.heightMm, 0);
expect(used / ((right - left) * (bottom - m.contentTopMm))).toBeGreaterThanOrEqual(0.7);
// Ops: ein Blatt, Viewports, zwei Blatt-Tabellen, Platzhalter-Beschriftung, Master ohne eigenes Schriftfeld nötig (posterHeader).
const res = presentationSheetOps(p, o, LABELS, "p1")!;
st().applyChange(res.ops);
const q = st().project;
const lay = q.layouts!.find((l) => l.id === res.layoutId)!;
expect(lay.viewports).toHaveLength(plan.items.length);
expect(lay.tables!.map((t) => t.source)).toEqual(["areas", "siteProof"]);
const sheet = q.drawingLevels.find((l) => l.layoutId === lay.id)!;
const texts = q.drawings2d.filter((d) => d.levelId === sheet.id && d.geom.shape === "text").map((d) => (d.geom as { text: string }).text);
expect(texts).toContain("3D-Bild hier einsetzen");
expect(texts).toContain("Situation");
expect(q.masterLayouts!.find((x) => x.id === lay.masterId)!.posterHeader).toBe(true);
expect(q.viewSnapshots!.find((v) => v.id === lay.viewports[0].snapshotId)!.templateId).toBe("std-vt-situation-wbw");
}, 90_000);
it("[208] zu viele Grundrisse für ein Blatt: zweites Plakat statt kleinerem Massstab", () => {
const o = { ...presentationDefaults(project), scale: 100, poster: "poster-a1-landscape", extras: POSTER_EXTRAS_DEFAULT };
const res = presentationSheetOps(project, o, LABELS, "p2")!;
expect(res.plan.pages).toBeGreaterThanOrEqual(2);
expect(res.layoutIds.length).toBe(res.plan.pages);
expect(res.plan.items.filter((i) => i.kind !== "situation").every((i) => i.scale === 100)).toBe(true);
st().applyChange(res.ops);
const lays = st().project.layouts!.filter((l) => res.layoutIds.includes(l.id));
expect(lays.every((l) => l.viewports.length > 0 || (l.tables ?? []).length > 0)).toBe(true);
}, 90_000);
it("[208] Plakat ohne Zusatzinhalt bleibt auf dem Raster (nur Pläne)", () => {
const o = { ...presentationDefaults(project), scale: 200, poster: "poster-a1-landscape" };
const plan = planPresentationSheet(project, o);
expect(plan.items.every((i) => i.kind === "view")).toBe(true);
expect(plan.tables).toEqual([]);
expect(plan.image ?? null).toBeNull();
}, 60_000);
});
+199 -20
View File
@@ -6,6 +6,8 @@
import type {
DetailLevel,
LayoutImage,
LayoutTable,
Drawing2D,
Drawing2DGeom,
DrawingLevel,
@@ -23,7 +25,8 @@ import type {
import type { CoreOp } from "../core/ops";
import { documentFor } from "../core/document";
import { addedItems, addItems, patchItem } from "../core/opsBuild";
import { standardsMergeOps } from "../model/standards";
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 { createPosterMaster, findPosterMaster, posterMetrics, posterTemplate, scaleLabelMetrics } from "../model/posterTemplates";
@@ -50,8 +53,31 @@ export interface PresentationOptions {
scales?: Record<string, number>;
/** [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. */
extras?: PosterExtras;
}
/** Kennzahlen (SIA 416) und Baurecht-Nachweis als Blatt-Tabellen. */
export type PosterTableKind = "areas" | "siteProof";
export interface PosterExtras {
/** Situationsplan 1:500 (Vorlage „Situation WBW“, Nordpfeil und Massstabsbalken aus der Modelldarstellung). */
situation: boolean;
tables: PosterTableKind[];
/** Rahmen fürs 3D-/Axonometrie-Bild: das zuletzt eingesetzte Bild des Projekts, sonst ein beschrifteter Platzhalter. */
image: boolean;
}
/** Vorgabe beim Wählen einer Plakat-Vorlage: alles, was zu einer Wettbewerbs-Abgabe gehört. */
export const POSTER_EXTRAS_DEFAULT: PosterExtras = { situation: true, tables: ["areas", "siteProof"], image: true };
/** Massstab der Situation auf dem Plakat. */
export const POSTER_SITUATION_SCALE = 500;
/** Id der Standard-Ansichtsvorlage „Situation WBW 1:500“ und ihrer Modelldarstellung (`standards.rs`). */
export const SITUATION_TEMPLATE_ID = "std-vt-situation-wbw";
const SITUATION_MODEL_VIEW_ID = "std-mv-situation-wbw";
/** Spalten der Kennzahlen-Tabelle: Fläche je Geschoss mit HNF/NNF/NF/VF/FF, GF und GV. */
const AREAS_COLUMNS = ["name", "hnf", "nnf", "nf", "vf", "ff", "gf", "gv"];
/** Massstäbe zur Wahl im Dialog (wie `SCALES` im Kern). */
export const PRESENTATION_SCALES = [50, 100, 200, 500, 1000] as const;
/** Vorgabe-Massstab für den Wettbewerb (WBW 1:200, Vorprojekt 1:100). */
@@ -59,6 +85,10 @@ export const PRESENTATION_DEFAULT_SCALE = 200;
export interface PresentationItem {
levelId: string;
/** [208] "situation": Situationsplan der Ebene (Vorlage „Situation WBW“); sonst der Ausschnitt der Ebene. */
kind?: "situation" | "view";
/** [208] Blatt (0-basiert) bei mehreren Plakaten. */
page?: number;
/** Massstab dieses Viewports (gemeinsam oder je Ebene gewählt). */
scale: number;
group: number;
@@ -68,11 +98,32 @@ export interface PresentationItem {
heightMm: number;
}
/** [208] Tabelle oder Bild-Rahmen auf dem Plakat (Papier-mm, `heightMm` mit Titelband oben bei Tabellen). */
export interface PosterBox {
page: number;
xMm: number;
yMm: number;
widthMm: number;
heightMm: number;
}
export interface PosterTableBox extends PosterBox {
id: PosterTableKind;
tableHeightMm: number;
bandMm: number;
}
export interface PresentationPlan {
scale: number;
fits: boolean;
items: PresentationItem[];
skipped: string[];
/** [208] Anzahl Plakate (Blätter); fehlt = 1. */
pages?: number;
tables?: PosterTableBox[];
image?: PosterBox | null;
/** [208] Titelband unter jedem Rahmen (mm). */
bandMm?: number;
}
/** Beschriftungen (vom Aufrufer über `t()`). */
@@ -84,6 +135,12 @@ export interface PresentationLabels {
/** [137] Gruppen-Namen von Nordpfeil und Massstabsbalken (Objekt-Info). */
northGroup?: string;
scaleBarGroup?: string;
/** [208] Titel des Situationsplans, der Tabellen und Platzhalter des 3D-Bilds auf dem Plakat. */
situation?: string;
tableAreas?: string;
tableSiteProof?: string;
imagePlaceholder?: string;
imageHint?: string;
}
const isFloor = (l: DrawingLevel) => l.kind === "floor" && !l.layoutId;
@@ -191,6 +248,34 @@ function masterFor(project: Project, o: PresentationOptions): MasterLayout | und
);
}
/** Erdgeschoss-Ebene für die Situation: das Geschoss mit Inhalt, dessen Oberkante der Höhe ±0.00 am nächsten liegt. */
function groundFloorId(project: Project, o: PresentationOptions): string | undefined {
const floors = project.drawingLevels.filter((l) => isFloor(l) && (o.floors.includes(l.id) || levelHasContent(project, l.id)));
const pool = floors.length > 0 ? floors : project.drawingLevels.filter(isFloor);
return (pool.find((l) => l.zeroLevel) ?? [...pool].sort((a, b) => Math.abs(a.baseElevation ?? 0) - Math.abs(b.baseElevation ?? 0))[0])?.id;
}
/** Sichtbarkeit des Situationsplans: alle Klassen ausser denen, die die Vorlage „Situation WBW“ ausblendet (Umgebung bleibt), ohne Schattenstudie. */
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 };
}
/** Die Vorlage „Situation WBW“ des Projekts bzw. aus den Standards (dann fehlt sie im Projekt und muss mit angelegt werden). */
function situationTemplate(project: Project): { template: ViewTemplate; isNew: boolean } | null {
const own = (project.viewTemplates ?? []).find((t) => t.id === SITUATION_TEMPLATE_ID);
if (own) return { template: own, isNew: false };
const std = (addedItems(standardsMergeOps(project), "viewTemplates") as ViewTemplate[]).find((t) => t.id === SITUATION_TEMPLATE_ID);
return std ? { template: std, isNew: true } : null;
}
/** Schrift und Titelband der Plakat-Blatt-Elemente (Papier-mm), nach Blattgrösse. */
function posterTextMetrics(size: { w: number; h: number }): { sizeMm: number; dyMm: number; bandMm: number; tablePt: number } {
const m = scaleLabelMetrics(size);
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) };
}
/** Massstab und Rahmen aus dem Kern (ohne das Projekt zu ändern). */
export function planPresentationSheet(project: Project, o: PresentationOptions): PresentationPlan {
const { template } = presentationTemplate(project);
@@ -200,6 +285,24 @@ export function planPresentationSheet(project: Project, o: PresentationOptions):
const poster = o.poster && posterTemplate(o.poster) ? posterMetrics(size.w, size.h) : null;
const levels = chosenLevels(project, o);
const vis = presentationVisibility(project, template);
let posterReq: Record<string, unknown> | undefined;
if (poster) {
const ex = o.extras;
const sit = ex?.situation ? situationTemplate(project) : null;
const sitLevel = sit && groundFloorId(project, o);
const m = posterTextMetrics(size);
const sitTpl = sit?.template ?? (project.viewTemplates ?? []).find((t) => t.id === SITUATION_TEMPLATE_ID);
posterReq = {
columns: poster.columns,
gutterMm: poster.gutterMm,
bandMm: m.bandMm,
...(sit && sitLevel && sitTpl
? { situation: { levelId: sitLevel, scale: POSTER_SITUATION_SCALE, layerVisibility: situationVisibility(project, sitTpl), detail: sitTpl.detail ?? "grob", template: sitTpl } }
: {}),
tables: (ex?.tables ?? []).map((id) => ({ id, source: id, fontPt: m.tablePt, ...(id === "areas" ? { columns: AREAS_COLUMNS } : {}) })),
image: !!ex?.image,
};
}
const text = JSON.stringify({
levels: levels.map((l) => l.id),
groups: levels.map((l) => l.group),
@@ -213,6 +316,7 @@ export function planPresentationSheet(project: Project, o: PresentationOptions):
...(o.scale ? { scale: o.scale } : {}),
scales: o.scales ?? {},
...(poster ? { marginMm: poster.marginMm, topMm: poster.contentTopMm } : {}),
...(posterReq ? { poster: posterReq } : {}),
});
return documentFor(project).query<PresentationPlan>("presentationSheet", [], text);
}
@@ -279,10 +383,24 @@ function annotationCategory(project: Project): string {
return (all.find((c) => /beschrift|text|annot/i.test(c.name)) ?? all.find((c) => c.code === "80") ?? all[0])?.code ?? "0";
}
/** Rechteck-Umriss (Papier-mm) als geschlossene Polylinie auf der Blatt-Ebene. */
function sheetRect(id: string, levelId: string, cat: string, x: number, y: number, w: number, h: number, extra: Partial<Drawing2D> = {}): Drawing2D {
const P = (px: number, py: number) => sheetMmToModel(px, py);
return sheetShape(id, levelId, cat, { shape: "polyline", closed: true, pts: [P(x, y), P(x + w, y), P(x + w, y + h), P(x, y + h)] }, extra);
}
/** Letztes Bild eines Layouts im Projekt (z. B. aus „Ins Layout einsetzen“ im Rendering-Dialog). */
function lastLayoutImage(project: Project): LayoutImage | undefined {
const all = (project.layouts ?? []).flatMap((l) => l.images ?? []);
return all[all.length - 1];
}
/**
* 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
* Ausschnitt und ein Viewport, Titel und Nordpfeil auf der Blatt-Ebene, Schatten/Skizze an den Ebenen.
* Plakat ([208]): zusätzlich Situation 1:500, Blatt-Tabellen (Kennzahlen, Baurecht) und ein Rahmen fürs 3D-Bild;
* passt der Inhalt nicht auf ein Blatt, entstehen weitere Plakate (`layoutIds`), die Massstäbe bleiben fest.
* `stamp` macht die Ids eindeutig. Keine Ebene mit Inhalt ⇒ `null`.
*/
export function presentationSheetOps(
@@ -290,7 +408,7 @@ export function presentationSheetOps(
o: PresentationOptions,
labels: PresentationLabels,
stamp: string,
): { ops: CoreOp[]; layoutId: string; plan: PresentationPlan } | null {
): { ops: CoreOp[]; layoutId: string; layoutIds: string[]; plan: PresentationPlan } | null {
const plan = planPresentationSheet(project, o);
if (plan.items.length === 0) return null;
const { template, isNew } = presentationTemplate(project);
@@ -307,58 +425,78 @@ export function presentationSheetOps(
master = { ...createMasterLayout(`mas-pres-${stamp}`, labels.masterName, sheet.paper, sheet.orientation), titleBlock: { ...(first?.titleBlock ?? {}) } };
ops.push(...addItems("masterLayouts", [master]));
}
const layoutId = `lay-pres-${stamp}`;
const layout: Layout = { ...createLayout(layoutId, labels.sheetName, sheet.paper, sheet.orientation), masterId: master.id };
const sheetLevel = createSheetLevel(`sheet-${layoutId}`, layout);
// Situation: Vorlage und Modelldarstellung „Situation WBW“ aus den Standards, falls das Projekt sie nicht hat.
const hasSituation = plan.items.some((it) => it.kind === "situation");
const sitTpl = hasSituation ? situationTemplate(project) : null;
if (sitTpl?.isNew) {
ops.push(...addItems("viewTemplates", [sitTpl.template]));
const mv = standardModelViews(project).find((m) => m.id === SITUATION_MODEL_VIEW_ID);
if (mv) ops.push(...addItems("modelViewOptions", [mv]));
}
const pages = Math.max(1, plan.pages ?? 1);
const layoutIds = Array.from({ length: pages }, (_, k) => (k === 0 ? `lay-pres-${stamp}` : `lay-pres-${stamp}-${k + 1}`));
const size = sheetSizeMm(sheet.paper, sheet.orientation);
const labelM = scaleLabelMetrics(size);
const layouts: Layout[] = layoutIds.map((id, k) => ({
...createLayout(id, pages > 1 ? `${labels.sheetName} ${k + 1}` : labels.sheetName, sheet.paper, sheet.orientation),
masterId: master.id,
}));
const sheetLevels = layouts.map((l) => createSheetLevel(`sheet-${l.id}`, l));
const vis = presentationVisibility(project, template);
const labelM = scaleLabelMetrics(sheetSizeMm(sheet.paper, sheet.orientation));
const cat = annotationCategory(project);
const byId = new Map(project.drawingLevels.map((l) => [l.id, l]));
const snaps: ViewSnapshot[] = [];
const vps: LayoutViewport[] = [];
const vps: LayoutViewport[][] = layouts.map(() => []);
const drawings: Drawing2D[] = [];
const tables: LayoutTable[][] = layouts.map(() => []);
const images: LayoutImage[][] = layouts.map(() => []);
// [137] Nordpfeil und Massstabsbalken als je eine Gruppe: ein Klick wählt, verschiebt und löscht sie als Ganzes.
const groups: Group[] = [];
const group = (id: string, name: string | undefined, members: Drawing2D[]) =>
groups.push({ id, name, wallIds: [], drawingIds: members.map((d) => d.id), ceilingIds: [], roomIds: [], stairIds: [], columnIds: [], roofIds: [], openingIds: [], groupIds: [] });
plan.items.forEach((it, i) => {
const page = it.page ?? 0;
const level = byId.get(it.levelId)!;
const snapId = `vs-pres-${stamp}-${i}`;
const isSit = it.kind === "situation";
const t = isSit && sitTpl ? sitTpl.template : template;
snaps.push({
id: snapId,
name: `${level.name} · ${template.name}`,
name: isSit ? `${labels.situation ?? level.name} · ${t.name}` : `${level.name} · ${t.name}`,
viewType: "grundriss",
view3d: "top",
scaleDenominator: it.scale,
detail: template.detail ?? "mittel",
detail: t.detail ?? "mittel",
activeLevelId: level.id,
// Grundrisse ohne die Schattenstudie des Projekts (Klasse „Schatten"): ihr Wurf läge über den Rahmen hinaus und
// würde beschnitten; die Schatten der Ansichten (Vorlage) bleiben.
layerVisibility: it.group === 0 ? { ...vis, [SHADOW_CATEGORY]: false } : vis,
layerVisibility: isSit ? situationVisibility(project, t) : it.group === 0 ? { ...vis, [SHADOW_CATEGORY]: false } : vis,
drawingVisibility: {},
...(template.enabledOverrideRuleIds ? { enabledOverrideRuleIds: [...template.enabledOverrideRuleIds] } : {}),
templateId: template.id,
...(!isSit && template.enabledOverrideRuleIds ? { enabledOverrideRuleIds: [...template.enabledOverrideRuleIds] } : {}),
templateId: t.id,
templateLinked: true,
} as ViewSnapshot);
vps.push({ id: `vp-pres-${stamp}-${i}`, snapshotId: snapId, xMm: it.xMm, yMm: it.yMm, widthMm: it.widthMm, heightMm: it.heightMm, scaleDenominator: it.scale });
vps[page].push({ id: `vp-pres-${stamp}-${i}`, snapshotId: snapId, xMm: it.xMm, yMm: it.yMm, widthMm: it.widthMm, heightMm: it.heightMm, scaleDenominator: it.scale });
const title = isSit ? (labels.situation ?? level.name) : level.name;
// Plakat: die Massstabsangabe des Masters steht links unter dem Viewport (Grundlinie `scaleLabelMetrics`);
// der Titel folgt rechts daneben auf derselben Linie, sonst überdecken sich beide.
drawings.push(
tpl
? sheetText(`d-pres-${stamp}-t${i}`, sheetLevel.id, cat, it.xMm + labelM.sizeMm * 3.6, it.yMm + it.heightMm + labelM.dyMm, level.name, 4, true)
: sheetText(`d-pres-${stamp}-t${i}`, sheetLevel.id, cat, it.xMm + FRAME_PAD_MM, it.yMm + it.heightMm + 6, `${level.name} 1:${it.scale}`, 4, true),
? 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 + 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);
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, sheetLevel.id, cat, cx, cy, 3.6, labels.north);
const north = northArrow(stamp, 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, sheetLevel.id, cat, cx - 3.6 - 10, cy - 1, firstFloor.scale);
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;
const barLeft = Math.min(...bar.flatMap((d) => (d.geom.shape === "polyline" ? d.geom.pts.map((p) => p.x * 1000) : [])));
@@ -367,16 +505,57 @@ export function presentationSheetOps(
group(`grp-pres-${stamp}-s`, labels.scaleBarGroup, bar);
}
}
ops.push(...addItems("layouts", [{ ...layout, viewports: vps }]), ...addItems("drawingLevels", [sheetLevel]));
// [208] Blatt-Tabellen mit Titel im Band darüber.
const fontPt = posterTextMetrics(size).tablePt;
for (const tb of plan.tables ?? []) {
const lvl = sheetLevels[tb.page].id;
const title = tb.id === "areas" ? labels.tableAreas : labels.tableSiteProof;
if (title) drawings.push(sheetText(`d-pres-${stamp}-tt-${tb.id}`, lvl, cat, tb.xMm, tb.yMm + labelM.sizeMm * 1.1, title, labelM.sizeMm, true));
tables[tb.page].push({
id: `tbl-pres-${stamp}-${tb.id}`,
source: tb.id,
xMm: tb.xMm,
yMm: tb.yMm + tb.bandMm,
widthMm: tb.widthMm,
fontSizePt: fontPt,
borders: "rows",
...(tb.id === "areas" ? { columns: AREAS_COLUMNS } : {}),
} as LayoutTable);
}
// [208] 3D-/Axonometrie-Bild: das letzte Layout-Bild des Projekts im Rahmen, sonst ein beschrifteter Platzhalter (nichts erfunden).
const box = plan.image;
if (box) {
const lvl = sheetLevels[box.page].id;
const existing = lastLayoutImage(project);
if (existing) {
const ar = imageAspect(existing);
const w = Math.min(box.widthMm, box.heightMm * ar);
const h = w / ar;
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;
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));
}
}
layouts.forEach((l, k) => {
ops.push(...addItems("layouts", [{ ...l, viewports: vps[k], ...(tables[k].length ? { tables: tables[k] } : {}), ...(images[k].length ? { images: images[k] } : {}) }]));
});
ops.push(...addItems("drawingLevels", sheetLevels));
ops.push(...addItems("viewSnapshots", snaps), ...addItems("drawings2d", drawings));
if (groups.length > 0) ops.push(...addItems("groups", groups));
// Schatten (Vorlage) für Ansichten/Schnitt, Skizze nach Wahl für alle gezeigten Ebenen.
for (const it of plan.items) {
if (it.kind === "situation") continue;
const level = byId.get(it.levelId)!;
const patch: Partial<DrawingLevel> = {};
if (it.group > 0 && template.shadows !== undefined && level.shadows !== template.shadows) patch.shadows = template.shadows;
if (o.sketch && !level.sketch) patch.sketch = true;
if (Object.keys(patch).length > 0) ops.push(...patchItem(project, "drawingLevels", level.id, patch));
}
return { ops, layoutId, plan };
return { ops, layoutId: layoutIds[0], layoutIds, plan };
}
+4 -2
View File
@@ -12,7 +12,7 @@ export function createPresentationSheet(o: PresentationOptions): string | null {
const res = presentationSheetOps(
st.project,
o,
{ sheetName: t("presentation.sheetName"), masterName: t("presentation.masterName", { format }), north: t("presentation.north"), northGroup: t("presentation.northGroup"), scaleBarGroup: t("presentation.scaleBarGroup") },
{ sheetName: t("presentation.sheetName"), masterName: t("presentation.masterName", { format }), north: t("presentation.north"), northGroup: t("presentation.northGroup"), scaleBarGroup: t("presentation.scaleBarGroup"), situation: t("presentation.situation"), tableAreas: t("presentation.table.areas"), tableSiteProof: t("presentation.table.siteProof"), imagePlaceholder: t("presentation.image.placeholder"), imageHint: t("presentation.image.hint") },
String(Date.now()),
);
if (!res) {
@@ -20,7 +20,9 @@ export function createPresentationSheet(o: PresentationOptions): string | null {
return null;
}
st.applyChange(res.ops);
if (res.plan.fits) st.notify(t("presentation.done", { scale: res.plan.scale, n: res.plan.items.length }), "info");
const pages = res.plan.pages ?? 1;
if (res.plan.fits && pages > 1) st.notify(t("presentation.donePages", { scale: res.plan.scale, pages }), "info");
else if (res.plan.fits) st.notify(t("presentation.done", { scale: res.plan.scale, n: res.plan.items.length }), "info");
else st.notify(t("presentation.tooBig", { scale: res.plan.scale }), "warning");
return res.layoutId;
} catch (e) {
+3 -2
View File
@@ -715,7 +715,8 @@ export function LayoutSheetPane({
)}
</g>
)}
{master && (
{/* [208] Plakat-Vorlage: die Kopfzeile trägt Kennwort und „Plan x/n“, ein zusätzliches Schriftfeld entfällt. */}
{master && !master.posterHeader && (
<g pointerEvents="none">
<TitleBlockSvg sheet={sheet} tb={titleBlock} paper={layout.paper} orientation={layout.orientation} />
{titleBlockSelected && (
@@ -1028,7 +1029,7 @@ export function LayoutSheetPane({
setSelectedLegendId(lg ? lg.id : null);
// Schriftfeld (liegt über den Viewports, nur mit Master gezeichnet).
const tbb = titleBlockBox(sheet);
const onTitle = !tableHit && !lg && !!master && !!handlers.onPatchTitleBlock &&
const onTitle = !tableHit && !lg && !!master && !master.posterHeader && !!handlers.onPatchTitleBlock &&
mm.xMm >= tbb.xMm && mm.xMm <= tbb.xMm + tbb.widthMm && mm.yMm >= tbb.yMm && mm.yMm <= tbb.yMm + tbb.heightMm;
setTitleBlockSelected(onTitle);
const imgHit = tableHit || lg || onTitle
+27 -2
View File
@@ -6,7 +6,7 @@
import { memo, useCallback, useEffect, useState } from "react";
import { t } from "../i18n";
import { enterConfirmsDialog, useModalFocus } from "./modalFocus";
import { PRESENTATION_SCALES, levelHasContent, presentationDefaults, type PresentationOptions } from "../core";
import { POSTER_EXTRAS_DEFAULT, PRESENTATION_SCALES, levelHasContent, presentationDefaults, type PosterTableKind, type PresentationOptions } from "../core";
import type { LayoutOrientation, LayoutPaperFormat } from "../model/types";
import { PAPER_FORMAT_GROUPS } from "../model/layoutModel";
import { POSTER_TEMPLATES, posterTemplateLabel } from "../model/posterTemplates";
@@ -60,6 +60,8 @@ 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 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;
// [224] Massstab je Viewport: "" = gemeinsamer Massstab.
const scaleOf = (id: string) => String(opts.scales?.[id] ?? "");
@@ -154,7 +156,7 @@ export const PresentationDialogHost = memo(function PresentationDialogHost({
data-testid="presentation-target"
aria-label={t("presentation.sheet")}
value={opts.poster ?? ""}
onChange={(e) => set({ poster: e.target.value || undefined })}
onChange={(e) => set({ poster: e.target.value || undefined, extras: e.target.value ? (opts.extras ?? POSTER_EXTRAS_DEFAULT) : undefined })}
>
<option value="">{t("presentation.target.sheet")}</option>
{POSTER_TEMPLATES.map((tpl) => (
@@ -206,6 +208,29 @@ export const PresentationDialogHost = memo(function PresentationDialogHost({
</div>
</div>
</section>
{poster && opts.extras && (
<section className="imp-section" data-testid="presentation-extras">
<div className="imp-section-title">{t("presentation.extras")}</div>
{(
[
["situation", t("presentation.extras.situation"), opts.extras.situation, (on: boolean) => ({ situation: on })],
["areas", t("presentation.extras.areas"), opts.extras.tables.includes("areas"), (on: boolean) => ({ tables: toggleTable("areas", on) })],
["siteProof", t("presentation.extras.siteProof"), opts.extras.tables.includes("siteProof"), (on: boolean) => ({ tables: toggleTable("siteProof", on) })],
["image", t("presentation.extras.image"), opts.extras.image, (on: boolean) => ({ image: on })],
] as const
).map(([key, label, on, patch]) => (
<label key={key} className="imp-check" style={{ display: "flex", gap: 6, alignItems: "center" }}>
<input
type="checkbox"
data-testid={`presentation-extra-${key}`}
checked={on}
onChange={(e) => set({ extras: { ...opts.extras!, ...patch(e.target.checked) } })}
/>
{label}
</label>
))}
</section>
)}
<section className="imp-section">
<label className="imp-check" style={{ display: "flex", gap: 6, alignItems: "center" }}>
<input