From b082064331c7ce508a6ec656f42206bff625cf45 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 5 Nov 2026 12:41:06 +0000 Subject: [PATCH 1/3] [139] Zauberstab heisst in der Befehlszeile zauberstab (zs); wand startet die Wand --- src/commands/cmds/wand.ts | 2 +- src/commands/registry.test.ts | 6 ++++++ src/commands/registry.ts | 5 ++--- src/tools/tools.ts | 2 +- website/content/docs/anleitung/befehlszeile.md | 5 ++--- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/commands/cmds/wand.ts b/src/commands/cmds/wand.ts index 24a3db28..443c37a3 100644 --- a/src/commands/cmds/wand.ts +++ b/src/commands/cmds/wand.ts @@ -22,7 +22,7 @@ const hatchOf = (s: WandState, ctx: CommandContext): string | undefined => s.sticky.hatch === NONE ? undefined : (usable(ctx)[s.sticky.hatch] ?? usable(ctx)[0])?.id; export const wandCommand: Command = { - name: "wand", + name: "zauberstab", labelKey: "cmd.wand.label", prompt: () => "cmd.wand.point", accepts: () => ["point", "option"], diff --git a/src/commands/registry.test.ts b/src/commands/registry.test.ts index 62497ac0..1228822f 100644 --- a/src/commands/registry.test.ts +++ b/src/commands/registry.test.ts @@ -71,4 +71,10 @@ describe("Körper-Befehle (truck)", () => { expect(resolveCommand("bool")?.name).toBe("solidbool"); expect(resolveCommand("verschneiden")?.name).toBe("solidbool"); }); + + it("wand startet die Wand, zauberstab/zs den Zauberstab", () => { + expect(resolveCommand("wand")?.name).toBe("wall"); + expect(resolveCommand("zauberstab")?.name).toBe("zauberstab"); + expect(resolveCommand("zs")?.name).toBe("zauberstab"); + }); }); diff --git a/src/commands/registry.ts b/src/commands/registry.ts index f03d8c4f..ce396b45 100644 --- a/src/commands/registry.ts +++ b/src/commands/registry.ts @@ -107,7 +107,7 @@ export const COMMANDS: Record = { scalebar: scalebarCommand, revcloud: revcloudCommand, pointmarker: pointmarkerCommand, - wand: wandCommand, + zauberstab: wandCommand, wipeout: wipeoutCommand, text: textCommand, leader: leaderCommand, @@ -223,8 +223,7 @@ export const ALIASES: Record = { wolke: "revcloud", revisionswolke: "revcloud", pm: "pointmarker", - zs: "wand", - zauberstab: "wand", + zs: "zauberstab", punkt: "pointmarker", knoten: "pointmarker", wo: "wipeout", diff --git a/src/tools/tools.ts b/src/tools/tools.ts index 784b49c1..44dd57ba 100644 --- a/src/tools/tools.ts +++ b/src/tools/tools.ts @@ -43,7 +43,7 @@ const TOOLS: Record = { scalebar: { labelKey: "tool.scalebar", hintKey: "tool.scalebar.hint", command: "scalebar" }, revcloud: { labelKey: "tool.revcloud", hintKey: "tool.revcloud.hint", command: "revcloud" }, pointmarker: { labelKey: "tool.pointmarker", hintKey: "tool.pointmarker.hint", command: "pointmarker" }, - wand: { labelKey: "tool.wand", hintKey: "tool.wand.hint", command: "wand" }, + wand: { labelKey: "tool.wand", hintKey: "tool.wand.hint", command: "zauberstab" }, grid: { labelKey: "tool.grid", hintKey: "tool.grid.hint", command: "grid" }, wipeout: { labelKey: "tool.wipeout", hintKey: "tool.wipeout.hint", command: "wipeout" }, text: { labelKey: "tool.text", hintKey: "tool.text.hint", command: "text" }, diff --git a/website/content/docs/anleitung/befehlszeile.md b/website/content/docs/anleitung/befehlszeile.md index 8c7389a9..64809b8f 100644 --- a/website/content/docs/anleitung/befehlszeile.md +++ b/website/content/docs/anleitung/befehlszeile.md @@ -22,8 +22,7 @@ ohne Fokus in der Befehlszeile sind dagegen Tastenkürzel (`m` Verschieben, - Eigene Kürzel legt man unter *Einstellungen → Allgemein → Befehlszeilen-Kürzel* an. -Kürzel werden vor dem Vervollständigen geprüft. Darum startet `wand` die -**Wand** und nicht den Zauberstab – für den gibt es `zs` oder `zauberstab`. +`wand` startet die **Wand**; der Zauberstab heisst `zauberstab` (Kürzel `zs`). Den Einzelbuchstaben `r` gibt es absichtlich nicht: er ist für relative Koordinaten reserviert. @@ -135,7 +134,7 @@ Stand 5.11.2026, aus der Befehlsliste des Programms (`src/commands/registry.ts`) | `spline` | Spline | `sp` | Glatte Kurve durch Punkte | | `bezier` | Bezier | `bz` | Bézierkurve | | `wipeout` | Maskenregion | `wo`, `maske`, `maskierung` | Fläche, die Darunterliegendes abdeckt | -| `wand` | Zauberstab | `zs`, `zauberstab` | Klick in umschlossene Fläche → Umriss mit Schraffur (Kürzel `zs`, nicht `wand`!) | +| `zauberstab` | Zauberstab | `zs` | Klick in umschlossene Fläche → Umriss mit Schraffur | | `grid` | Achsraster | `axes`, `achsraster`, `achsen` | Rechtwinkliges oder radiales Achsraster mit Achsköpfen | | `block` | Block einfügen | `bl`, `symbol` | Block (Symbol) platzieren | | `defblock` | Block definieren | `db`, `blockdef` | Auswahl als Block speichern | From 7e968b6b1a31b8350e751b1dff0e95d55f35931b Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 5 Nov 2026 12:41:06 +0000 Subject: [PATCH 2/3] [139] Cmd/Strg+S speichert, +Shift+S speichert unter, Teilen auf Cmd/Strg+Shift+J --- src/App.tsx | 4 ++++ src/i18n/de.ts | 1 + src/i18n/en.ts | 1 + src/native/appMenu.ts | 8 +++++++- src/native/projectFile.ts | 8 ++++++++ src/state/keyboardShortcuts.test.ts | 9 +++++++++ src/state/keyboardShortcuts.ts | 2 +- src/state/useKeyboardShortcuts.ts | 2 +- src/state/useProjectFileActions.ts | 18 ++++++++++++++---- src/ui/AppMenuBar.tsx | 3 +++ website/content/docs/anleitung/probleme.md | 1 - .../content/docs/anleitung/tastenkuerzel.md | 10 +++++----- 12 files changed, 54 insertions(+), 13 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 3c1de60e..e746dd9d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1191,6 +1191,7 @@ export default function App() { loadImportLayout, setImportPdfOptions, onSaveProject, + onSaveProjectAs, onNewProject, onNewProjectFromSample, onNewProjectFromComplexSample, @@ -1373,6 +1374,7 @@ export default function App() { onNewProjectFromTemplate, onOpenProject, onSaveProject, + onSaveProjectAs, onImport: () => dxfInputRef.current?.click(), onExportPdf: () => setExportOpen(true), onExportDxf: () => setExportDxfOpen(true), @@ -2003,6 +2005,7 @@ export default function App() { onNewProjectFromTemplate, onOpenProject, onSaveProject, + onSaveProjectAs, onImport: () => dxfInputRef.current?.click(), onImportPointCloud: () => openPointCloudFileDialog(), onImportMesh: () => openMeshFileDialog(), @@ -2172,6 +2175,7 @@ export default function App() { onNewProjectFromTemplate={ev.onNewProjectFromTemplate} onOpenProject={ev.onOpenProject} onSaveProject={ev.onSaveProject} + onSaveProjectAs={ev.onSaveProjectAs} onImport={ev.onImport} onImportPointCloud={ev.onImportPointCloud} onImportMesh={ev.onImportMesh} diff --git a/src/i18n/de.ts b/src/i18n/de.ts index f0068026..bacb6319 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -134,6 +134,7 @@ export const de = { "menu.native.newFromComplexSample": "Musterhaus (komplex)", "menu.native.newFromTemplateFile": "Vorlagendatei wählen …", "menu.native.open": "Öffnen …", + "menu.native.save": "Speichern", "menu.native.saveAs": "Speichern unter …", "menu.native.import": "Importieren …", "menu.native.export": "Exportieren", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index d6582352..f968b095 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -132,6 +132,7 @@ export const en: Record = { "menu.native.newFromComplexSample": "Sample House (Complex)", "menu.native.newFromTemplateFile": "Choose Template File…", "menu.native.open": "Open…", + "menu.native.save": "Save", "menu.native.saveAs": "Save As…", "menu.native.import": "Import…", "menu.native.export": "Export", diff --git a/src/native/appMenu.ts b/src/native/appMenu.ts index c849221c..ed5d6339 100644 --- a/src/native/appMenu.ts +++ b/src/native/appMenu.ts @@ -26,6 +26,7 @@ export interface NativeAppMenuHandlers { onNewProjectFromTemplate: () => void; onOpenProject: () => void; onSaveProject: () => void; + onSaveProjectAs: () => void; onImport: () => void; onExportPdf: () => void; onExportDxf: () => void; @@ -173,10 +174,15 @@ export function useNativeAppMenu( action: () => handlersRef.current.onOpenProject(), }), await MenuItem.new({ - text: t("menu.native.saveAs"), + text: t("menu.native.save"), accelerator: "CmdOrCtrl+S", action: () => handlersRef.current.onSaveProject(), }), + await MenuItem.new({ + text: t("menu.native.saveAs"), + accelerator: "CmdOrCtrl+Shift+S", + action: () => handlersRef.current.onSaveProjectAs(), + }), await MenuItem.new({ text: t("menu.native.import"), action: () => handlersRef.current.onImport(), diff --git a/src/native/projectFile.ts b/src/native/projectFile.ts index fcb80bbc..633b53d2 100644 --- a/src/native/projectFile.ts +++ b/src/native/projectFile.ts @@ -124,7 +124,15 @@ export async function saveProjectFile( json: string, projectName: string, onSavedPath?: (path: string) => void, + knownPath?: string | null, ): Promise { + // „Speichern" (Cmd/Ctrl+S): bekannter Pfad → ohne Dialog atomar überschreiben. + if (knownPath && isTauriRuntime()) { + const { writeFileAtomic } = await import("./saveFile"); + await writeFileAtomic(knownPath, json); + onSavedPath?.(knownPath); + return true; + } const filename = `${projectName || "projekt"}.${PROJECT_EXT}`; return saveTextFile(json, filename, "application/json", PROJECT_DIALOG_FILTERS, onSavedPath, true); } diff --git a/src/state/keyboardShortcuts.test.ts b/src/state/keyboardShortcuts.test.ts index 9ce265e3..66f926dc 100644 --- a/src/state/keyboardShortcuts.test.ts +++ b/src/state/keyboardShortcuts.test.ts @@ -27,6 +27,15 @@ function key( } as KeyboardEvent; } +describe("Speichern-Kürzel", () => { + it("Mod+S und Mod+Shift+S sind für Speichern/Speichern unter frei (Teilen = Mod+Shift+J)", () => { + const combos = SHORTCUT_DEFS.map((d) => d.defaultCombo); + expect(combos).not.toContain("mod+s"); + expect(combos).not.toContain("mod+shift+s"); + expect(SHORTCUT_DEFS.find((d) => d.id === "split")?.defaultCombo).toBe("mod+shift+j"); + }); +}); + describe("SHORTCUT_DEFS", () => { it("hat für jede Id eine eindeutige Default-Kombination (keine eingebaute Kollision)", () => { const seen = new Map(); diff --git a/src/state/keyboardShortcuts.ts b/src/state/keyboardShortcuts.ts index 0f8fd003..3dae05fb 100644 --- a/src/state/keyboardShortcuts.ts +++ b/src/state/keyboardShortcuts.ts @@ -82,7 +82,7 @@ export const SHORTCUT_DEFS: ShortcutDef[] = [ labelKey: "shortcut.deleteSelection", defaultCombo: "Delete", }, - { id: "split", category: "edit", labelKey: "shortcut.split", defaultCombo: "mod+s" }, + { id: "split", category: "edit", labelKey: "shortcut.split", defaultCombo: "mod+shift+j" }, { id: "join", category: "edit", labelKey: "shortcut.join", defaultCombo: "mod+j" }, { id: "copyElements", category: "edit", labelKey: "shortcut.copyElements", defaultCombo: "mod+c" }, { id: "pasteElements", category: "edit", labelKey: "shortcut.pasteElements", defaultCombo: "mod+v" }, diff --git a/src/state/useKeyboardShortcuts.ts b/src/state/useKeyboardShortcuts.ts index a9fdd572..c04c1c1a 100644 --- a/src/state/useKeyboardShortcuts.ts +++ b/src/state/useKeyboardShortcuts.ts @@ -392,7 +392,7 @@ export function useSelectAllAndDeleteShortcut(opts: { } /** - * Ctrl/Cmd+S = Split, Ctrl/Cmd+J = Join der selektierten Drawing2D-Elemente. + * Ctrl/Cmd+Shift+J = Split (Ctrl/Cmd+S ist Speichern), Ctrl/Cmd+J = Join der selektierten Drawing2D-Elemente. * Join läuft über DENSELBEN Engine-Befehl wie getipptes „join" (Sofort- * Befehl, autoRun). Split bleibt die direkte Aktion (`runSplit`, in App.tsx — * bleibt dort, da es auch für einen etwaigen Menü-Eintrag geteilt wird). Beide diff --git a/src/state/useProjectFileActions.ts b/src/state/useProjectFileActions.ts index d8a376a3..9e502ffb 100644 --- a/src/state/useProjectFileActions.ts +++ b/src/state/useProjectFileActions.ts @@ -104,6 +104,8 @@ export function useProjectFileActions( // Pfad + Lock-Status der aktuell offenen .obp/.json-Datei (nur Tauri; sonst // bleibt beides null/false — Browser-Blob-Pfad hat keinen echten Pfad). const openedProjectPathRef = useRef(null); + // Zielpfad für „Speichern" (Cmd/Ctrl+S): gesetzt beim Öffnen und nach „Speichern unter". + const savePathRef = useRef(null); const projectLockOwnedRef = useRef(false); // Konflikt-Zustand: Datei ist in einer anderen Instanz gesperrt → Dialog mit // „Schreibgeschützt öffnen"/„Trotzdem erzwingen"/„Abbrechen" (kein window.confirm!). @@ -371,11 +373,14 @@ export function useProjectFileActions( // Liefert `true`, wenn wirklich gespeichert wurde (nicht bei abgebrochenem // nativem Dialog) — `guardDiscard`-Aufrufer verlassen sich darauf, um NICHT // zu verwerfen, wenn der Nutzer den Speichern-Dialog abbricht. - const onSaveProject = (): Promise => { + // Cmd/Ctrl+S „Speichern": bekannter Pfad → ohne Dialog; sonst wie „Speichern unter". + // Cmd/Ctrl+Shift+S „Speichern unter" fragt immer nach dem Ziel. + const saveProjectTo = (asNew: boolean): Promise => { const json = serializeProject(project); - return saveProjectFile(json, project.name, (path) => - addRecentProject(path, project.name || "modell"), - ).then( + return saveProjectFile(json, project.name, (path) => { + savePathRef.current = path; + addRecentProject(path, project.name || "modell"); + }, asNew ? null : savePathRef.current).then( (saved) => { if (saved) { lastSavedProjectRef.current = project; @@ -392,6 +397,8 @@ export function useProjectFileActions( }, ); }; + const onSaveProject = (): Promise => saveProjectTo(false); + const onSaveProjectAs = (): Promise => saveProjectTo(true); // „Neu" (Datei-Menü): leeres Projekt, wie am Startbildschirm — löst dabei // einen evtl. gehaltenen Datei-Lock der bisherigen Projektdatei und vergisst // deren Pfad (das leere Projekt ist noch NICHT gespeichert). Über @@ -467,6 +474,7 @@ export function useProjectFileActions( void releaseProjectLock(openedProjectPathRef.current); } openedProjectPathRef.current = null; + savePathRef.current = null; projectLockOwnedRef.current = false; }; // Übernimmt ein per Pfad geöffnetes Projekt (Tauri-Fluss): parst, prüft grob @@ -482,6 +490,7 @@ export function useProjectFileActions( releaseCurrentProjectLock(); lastSavedProjectRef.current = loaded; openedProjectPathRef.current = path; + savePathRef.current = path; projectLockOwnedRef.current = lockOwned; addRecentProject(path, loaded.name || "modell"); offerRecovery(path); @@ -670,6 +679,7 @@ export function useProjectFileActions( setImportPdfOptions, loadImportLayout, onSaveProject, + onSaveProjectAs, onNewProject, onNewProjectFromSample, onNewProjectFromComplexSample, diff --git a/src/ui/AppMenuBar.tsx b/src/ui/AppMenuBar.tsx index 3d213be1..dc6251c5 100644 --- a/src/ui/AppMenuBar.tsx +++ b/src/ui/AppMenuBar.tsx @@ -20,6 +20,7 @@ export interface AppMenuBarProps { onNewProjectFromTemplate: () => void; onOpenProject: () => void; onSaveProject: () => void; + onSaveProjectAs: () => void; onImport: () => void; /** Datei: Punktwolke importieren ([27]). */ onImportPointCloud?: () => void; @@ -65,6 +66,7 @@ export const AppMenuBar = memo(function AppMenuBar({ onNewProjectFromTemplate, onOpenProject, onSaveProject, + onSaveProjectAs, onImport, onImportPointCloud, onImportMesh, @@ -98,6 +100,7 @@ export const AppMenuBar = memo(function AppMenuBar({ { divider: true }, { label: t("file.open"), onSelect: onOpenProject }, { label: t("file.save"), onSelect: onSaveProject }, + { label: t("menu.native.saveAs"), onSelect: onSaveProjectAs }, { divider: true }, { label: t("file.import"), onSelect: onImport }, ...(onImportPointCloud ? [{ label: t("menu.native.importPointCloud"), onSelect: onImportPointCloud }] : []), diff --git a/website/content/docs/anleitung/probleme.md b/website/content/docs/anleitung/probleme.md index 7f31a9ef..82efb5d5 100644 --- a/website/content/docs/anleitung/probleme.md +++ b/website/content/docs/anleitung/probleme.md @@ -74,7 +74,6 @@ Stand 5.11.2026; die vollständige Liste führt - Zeichnungs-Reiter werden nicht im Projekt gespeichert [136]. - Ziehen von Griffen mit Fang ist im 3D noch nicht vollständig. -- Mod+S ist doppelt belegt (Speichern / Teilen bei 2D-Auswahl). **Modell und Pläne** diff --git a/website/content/docs/anleitung/tastenkuerzel.md b/website/content/docs/anleitung/tastenkuerzel.md index 0f86764f..3c581f4b 100644 --- a/website/content/docs/anleitung/tastenkuerzel.md +++ b/website/content/docs/anleitung/tastenkuerzel.md @@ -15,7 +15,8 @@ ab. Einzeltasten (ohne Mod) gelten nur, solange kein Textfeld den Fokus hat. |---|---| | Mod+N | Neues Projekt (Menü der Desktop-App) | | Mod+O | Öffnen (Menü der Desktop-App) | -| Mod+S | Speichern unter … (Menü der Desktop-App; bei gewählten 2D-Elementen: Teilen, siehe unten) | +| Mod+S | Speichern (Datei der Desktop-App ohne Dialog überschreiben; neues Projekt: Zielwahl) | +| Mod+Shift+S | Speichern unter … | | Mod+Z | Rückgängig | | Mod+Shift+Z, Strg+Y | Wiederholen | | Entf | Auswahl löschen | @@ -49,15 +50,14 @@ ab. Einzeltasten (ohne Mod) gelten nur, solange kein Textfeld den Fokus hat. | Taste | Aktion | |---|---| -| Mod+S | Teilen der gewählten 2D-Elemente | +| Mod+Shift+J | Teilen der gewählten 2D-Elemente | | Mod+J | Verbinden der gewählten 2D-Elemente | | Mod+Shift+U | Vereinigen (Boolean) | | Mod+Shift+D | Abziehen (Boolean) | | Mod+Shift+I | Schneiden (Boolean) | -Mod+S ist doppelt belegt: Sind 2D-Elemente gewählt, teilt es sie; sonst -speichert es. Wer das nicht mag, legt *Teilen* in den Einstellungen auf eine -andere Kombination. +Mod+S speichert immer; *Teilen* liegt auf Mod+Shift+J und lässt sich in den +Einstellungen umlegen. ## Maus From 26bbd9adb6c293733f9fec226d16a781121badd1 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 5 Nov 2026 13:01:42 +0000 Subject: [PATCH 3/3] =?UTF-8?q?[139]=20Fenster-=20und=20T=C3=BCrliste=20(S?= =?UTF-8?q?VG/PDF):=20lange=20Zellen=20umbrechen=20statt=20zu=20=C3=BCberl?= =?UTF-8?q?appen,=20Spaltenbreiten=20angepasst?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODO.md | 2 + src-tauri/core/src/area_report.rs | 101 ++++++++++++++++++++++++++++-- src/export/exportSchedule.test.ts | 26 ++++++++ src/export/openingSchedule.ts | 6 +- 4 files changed, 128 insertions(+), 7 deletions(-) diff --git a/TODO.md b/TODO.md index 3dd43a7b..c27f2196 100644 --- a/TODO.md +++ b/TODO.md @@ -2604,6 +2604,8 @@ Modelle · [44] Aus Datei einfügen · [45] Favoriten · [68] Gelände mit Baugr (◐, DXF-Parser, IFC-Import) · [52] Icons (◐, `CommandIcon.tsx`) · [56] Startparameter · [89] Git-freundliches Format · [90] Versionsvergleich · [91] Assistent · [92] Speckle. +- ✅ **[139] Kleine Fehler aus der Doku.** (5.11.) Beim Schreiben der Doku gefunden: (1) Befehl `wand` startete den Zauberstab statt der Wand; der Zauberstab heisst jetzt `zauberstab` (Kürzel `zs`), `wand` = Wand, Kern-Befehl `wand` unverändert. (2) Cmd/Strg+S war doppelt belegt: jetzt Speichern (bekannter Pfad ohne Dialog, sonst Dialog), Cmd/Strg+Shift+S = Speichern unter, Teilen auf Cmd/Strg+Shift+J. (3) `schedule --openings --format svg`: Zellen werden in der Blattaufteilung (`area_report.rs`, gilt auch für PDF) auf Spaltenbreite umbrochen statt zu überlappen, Spaltenbreiten der Liste angepasst. Offen: Speichern/Speichern unter nur per vitest geprüft, nicht in der Tauri-App. + - ◐ **[68] Baugrube / Geländebearbeitung.** (30.10.) Kontext-Objekt `excavation` (Rust-Modell, `ContextObject`): Sohle (`outline`, `bottom` m ±0.00), Böschung `slope` (Standard 45°, je Kante `edgeSlopes`), Schüttung `fillSlope` (33.7°), Bermen `bermWidth`/`bermHeight`. Neues Gelände = clamp(t, b − d·tan β, b + H(d)) mit d = Abstand zum diff --git a/src-tauri/core/src/area_report.rs b/src-tauri/core/src/area_report.rs index aaee8920..d406272b 100644 --- a/src-tauri/core/src/area_report.rs +++ b/src-tauri/core/src/area_report.rs @@ -239,6 +239,59 @@ fn wrap(text: &str, max_mm: f64, size_pt: f64) -> Vec { lines } +/// Geschätzte Textbreite in mm (Helvetica: Ziffern 0.556 em, Fett etwas breiter; bewusst grosszügig). +fn char_w_mm(size_pt: f64, bold: bool) -> f64 { + size_pt * 0.3528 * if bold { 0.58 } else { 0.52 } +} + +/// Bricht eine Zelle in Zeilen, die in `avail_mm` passen: an Leerzeichen, überlange Wörter hart. +fn fit_cell(text: &str, avail_mm: f64, size_pt: f64, bold: bool) -> Vec { + let max = (avail_mm / char_w_mm(size_pt, bold)).floor().max(1.0) as usize; + let mut lines: Vec = Vec::new(); + let mut cur = String::new(); + let push_word = |cur: &mut String, lines: &mut Vec, w: &str| { + let mut w: Vec = w.chars().collect(); + while utf16_len(&w.iter().collect::()) > max { + let mut n = 0; + let mut take = 0; + for (i, c) in w.iter().enumerate() { + n += c.len_utf16(); + if n > max { + break; + } + take = i + 1; + } + let take = take.max(1); + if !cur.is_empty() { + lines.push(std::mem::take(cur)); + } + lines.push(w.drain(..take).collect()); + } + let ws: String = w.iter().collect(); + if ws.is_empty() { + return; + } + if cur.is_empty() { + *cur = ws; + } else if utf16_len(cur) + 1 + utf16_len(&ws) <= max { + cur.push(' '); + cur.push_str(&ws); + } else { + lines.push(std::mem::replace(cur, ws)); + } + }; + for w in text.split_whitespace() { + push_word(&mut cur, &mut lines, w); + } + if !cur.is_empty() { + lines.push(cur); + } + if lines.is_empty() { + lines.push(String::new()); + } + lines +} + fn text(x: f64, y: f64, s: &str, size: f64, bold: bool, right: bool) -> Prim { Prim::Text { x, y, s: s.to_string(), size, bold, right } } @@ -288,7 +341,18 @@ pub fn layout(report: &Report, o: &LayoutOptions) -> Layout { let numeric: Vec = (0..s.columns.len()).map(|i| s.rows.iter().any(|r| matches!(r.cells.get(i), Some(Cell::Num { .. })))).collect(); // 0 = keine Linie, 1 = oben let draw_row = |pages: &mut Vec>, y: &mut f64, cells: &[String], bold: bool, top: bool| { - if *y + row_h > height - m { + // Zellen auf Spaltenbreite umbrechen; die Zeile wächst mit der höchsten Zelle. + let wrapped: Vec> = cells + .iter() + .enumerate() + .map(|(i, c)| { + let w = xs.get(i + 1).copied().unwrap_or(f64::NAN) - xs.get(i).copied().unwrap_or(f64::NAN); + if w.is_finite() { fit_cell(c, (w - 3.0).max(2.0), 8.5, bold) } else { vec![c.clone()] } + }) + .collect(); + let n = wrapped.iter().map(|l| l.len()).max().unwrap_or(1).max(1); + let h = if n == 1 { row_h } else { n as f64 * 3.6 + 2.4 }; + if *y + h > height - m { pages.push(Vec::new()); *y = m; } @@ -296,13 +360,15 @@ pub fn layout(report: &Report, o: &LayoutOptions) -> Layout { if top { pg.push(Prim::Line { x1: m, y1: *y, x2: m + inner, y2: *y, w: 0.35 }); } - for (i, c) in cells.iter().enumerate() { + for (i, lines) in wrapped.iter().enumerate() { let right = numeric.get(i).copied().unwrap_or(false); let xi = xs.get(i).copied().unwrap_or(f64::NAN); let xn = xs.get(i + 1).copied().unwrap_or(f64::NAN); - pg.push(text(if right { xn - 1.5 } else { xi + 1.5 }, *y + 4.2, c, 8.5, bold, right)); + for (k, l) in lines.iter().enumerate() { + pg.push(text(if right { xn - 1.5 } else { xi + 1.5 }, *y + 4.2 + k as f64 * 3.6, l, 8.5, bold, right)); + } } - *y += row_h; + *y += h; }; draw_row(&mut pages, &mut y, &s.columns, true, false); page!().push(Prim::Line { x1: m, y1: y, x2: m + inner, y2: y, w: 0.35 }); @@ -420,6 +486,33 @@ mod tests { assert_eq!(p["notes"][0], "Eine Fussnote"); } + #[test] + fn lange_zellen_ueberlappen_nicht() { + let r: Report = serde_json::from_value(json!({ + "title": "T", "projectName": "", + "sections": [{ "heading": "H", "columns": ["Nr", "Bezeichnung sehr lang", "Mass"], "widths": [1, 1, 1], + "rows": [{ "cells": ["EG.01", "Hebeschiebetür Aluminium dreifach verglast mit Oberlicht", { "n": 1234567.891, "d": 2 }] }] }], + "notes": [] + })) + .unwrap(); + let l = layout(&r, &LayoutOptions::default()); + // Text-Kästen je Grundlinie sammeln: (links, rechts) nach Ausrichtung; keine zwei überlappen. + let mut rows: std::collections::BTreeMap> = Default::default(); + for p in &l.pages[0] { + if let Prim::Text { x, y, s, size, bold, right } = p { + let w = utf16_len(s) as f64 * char_w_mm(*size, *bold) * 0.9; + let (a, b) = if *right { (x - w, *x) } else { (*x, x + w) }; + rows.entry((y * 100.0).round() as i64).or_default().push((a, b)); + } + } + for (_, mut v) in rows { + v.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap()); + for w in v.windows(2) { + assert!(w[0].1 <= w[1].0, "Überlappung {:?}", w); + } + } + } + #[test] fn seiten_und_svg() { let l = layout(&sample(), &LayoutOptions::default()); diff --git a/src/export/exportSchedule.test.ts b/src/export/exportSchedule.test.ts index aeb9d506..a111fb95 100644 --- a/src/export/exportSchedule.test.ts +++ b/src/export/exportSchedule.test.ts @@ -302,3 +302,29 @@ describe("scheduleRows — Dächer und Stützen (bisher fehlten sie in Liste/Ele expect(scheduleRows(proj).some((r) => r.id === "RM1")).toBe(false); }); }); + +describe("Fenster- und Türliste als Blatt ([139])", () => { + it("keine zwei Texte derselben Zeile überlappen (Musterhaus komplex)", async () => { + const { buildComplexSampleProject } = await import("../model/sampleProjectComplex"); + const { buildOpeningReport } = await import("./openingSchedule"); + const { layoutAreaReport } = await import("./areaReport"); + const lay = layoutAreaReport(buildOpeningReport(buildComplexSampleProject())); + let texts = 0; + for (const page of lay.pages) { + const rows = new Map(); + for (const p of page) { + if (p.k !== "text") continue; + texts++; + const w = p.s.length * p.size * 0.3528 * 0.45; // untere Schätzung der Breite + const box: [number, number] = p.align === "right" ? [p.x - w, p.x] : [p.x, p.x + w]; + const key = Math.round(p.y * 100); + rows.set(key, [...(rows.get(key) ?? []), box]); + } + for (const boxes of rows.values()) { + boxes.sort((a, b) => a[0] - b[0]); + for (let i = 1; i < boxes.length; i++) expect(boxes[i - 1]![1]).toBeLessThanOrEqual(boxes[i]![0] + 1e-6); + } + } + expect(texts).toBeGreaterThan(50); + }); +}); diff --git a/src/export/openingSchedule.ts b/src/export/openingSchedule.ts index 13fc72f4..3f587953 100644 --- a/src/export/openingSchedule.ts +++ b/src/export/openingSchedule.ts @@ -102,7 +102,7 @@ function withReveals(sec: ReportSection, rows: OpeningScheduleRow[]): ReportSect return { ...sec, columns: [...sec.columns, ...keys.map((name) => t("openings.col.reveal", { name }))], - widths: [...sec.widths, ...keys.map(() => 1.4)], + widths: [...sec.widths, ...keys.map(() => 1.9)], rows: sec.rows.map((row, i) => ({ ...row, cells: [...row.cells, ...keys.map((k) => num(revealArea(rows[i]!, k), 2))] })), }; } @@ -119,7 +119,7 @@ function windowBase(rows: OpeningScheduleRow[]): ReportSection { return { heading: t("openings.windows"), columns: [t("openings.col.mark"), t("openings.col.type"), t("openings.col.floor"), t("openings.col.rooms"), t("openings.col.width"), t("openings.col.height"), t("openings.col.sill"), t("openings.col.sound"), t("openings.col.u"), t("openings.col.rc"), t("openings.col.ext"), t("openings.col.notes")], - widths: [1.4, 2.4, 1.4, 3.2, 1.2, 1.2, 1.2, 1.6, 1.1, 1.1, 1.4, 3], + widths: [1.3, 3.4, 1.9, 3, 1.4, 1.4, 1.4, 1.5, 1.3, 1.3, 1.6, 2.6], rows: rows.map((r): ReportRow => ({ cells: [r.mark, r.typeName, r.floor, roomsText(r), num(r.width, 2), num(r.height, 2), num(r.sill, 2), r.soundClass, num(r.uValue, 2), r.burglaryClass, externalText(r.external), r.notes] })), }; } @@ -128,7 +128,7 @@ function doorBase(rows: OpeningScheduleRow[]): ReportSection { return { heading: t("openings.doors"), columns: [t("openings.col.mark"), t("openings.col.type"), t("openings.col.floor"), t("openings.col.rooms"), t("openings.col.width"), t("openings.col.height"), t("openings.col.clearWidth"), t("openings.col.clearHeight"), t("openings.col.swing"), t("openings.col.fire"), t("openings.col.sound"), t("openings.col.u"), t("openings.col.rc"), t("openings.col.ext"), t("openings.col.notes")], - widths: [1.4, 2.2, 1.3, 3, 1.1, 1.1, 1.2, 1.2, 2.6, 1.1, 1.5, 1, 1, 1.3, 2.6], + widths: [1.3, 3, 1.9, 3, 1.3, 1.3, 1.4, 1.4, 2.6, 1.1, 1.5, 1.1, 1.3, 1.6, 2.4], rows: rows.map((r): ReportRow => ({ cells: [r.mark, r.typeName, r.floor, roomsText(r), num(r.width, 2), num(r.height, 2), num(r.clearWidth, 2), num(r.clearHeight, 2), swingText(r), r.fireRating, r.soundClass, num(r.uValue, 2), r.burglaryClass, externalText(r.external), r.notes] })), }; }