From 76bae648ba4c9f13c643834dbf132183a4cb8136 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 12:07:58 +0000 Subject: [PATCH] =?UTF-8?q?[131]=20Geschoss-Editor:=20OK=20fertig=20Boden?= =?UTF-8?q?=20direkt=20eintippen=20(Geschossh=C3=B6he=20darunter=20bzw.=20?= =?UTF-8?q?eigene=20passt=20sich=20an)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67 --- TODO.md | 2 +- e2e/levelZero.spec.ts | 12 +++++- src/i18n/de.ts | 1 + src/i18n/en.ts | 1 + src/menus/InlineEditors.elevation.test.ts | 22 +++++++++++ src/menus/InlineEditors.tsx | 46 ++++++++++++++++++++++- 6 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 src/menus/InlineEditors.elevation.test.ts diff --git a/TODO.md b/TODO.md index 068a8cd3..8ebdb01d 100644 --- a/TODO.md +++ b/TODO.md @@ -2199,7 +2199,7 @@ Reihenfolge = Abhängigkeiten. Neue Geometrie entsteht in Rust ([K]). Dach-Triangulierung; Grundrisse: Schatten/Baurecht jetzt im EG als Geschoss nächst ±0.00). Tests: cargo (`levels`, Format 5, Koten), vitest `layers.test.ts`, `sampleProjectComplex.test.ts`, e2e `levelZero.spec.ts` (Bezug wählen → EG −2.60, Höhe ändern, Undo), `sectionViews.spec.ts`. Geprüft: Screenshot Schnitt A-A im Browser - (Linux). Offen: Höhe eines Geschosses direkt eintippen (heute nur über Bezug + Geschosshöhen), Umordnen der Ebenen + (Linux). 4.11.: Höhe direkt eintippen (Geschoss-Editor; über ±0.00 passt sich die Geschosshöhe darunter an, darunter die eigene; `elevationFix`, vitest + e2e). Umordnen der Ebenen ändert die Höhen nicht mehr (Stapel nach bisheriger Höhe, 4.11.), nicht in der Tauri-App geprüft. · S - ◐ **[132] Ansichten/Schnitte aus [114].** (4.11.) Flachdächer zeigen in Ansicht und Schnitt ihre Stirn als Band (`elevation::fascia_quads`, Aufbaudicke); Stützen erscheinen in Ansichten als Prismen (`collect_column_faces`, runde diff --git a/e2e/levelZero.spec.ts b/e2e/levelZero.spec.ts index 069f118e..de17fae3 100644 --- a/e2e/levelZero.spec.ts +++ b/e2e/levelZero.spec.ts @@ -25,15 +25,23 @@ test("Geschoss als ±0.00 wählen: Erdgeschoss liegt danach negativ", async ({ p await page.keyboard.press("Escape"); await page.locator(".nav-row", { hasText: "Erdgeschoss" }).first().click({ button: "right" }); await page.getByText("Einstellungen…", { exact: true }).click(); - const h = page.locator(".editor-num input[type=number]").first(); + const h = page.locator(".editor-num input[type=number]:not([data-testid])").first(); await h.fill("2.8"); await expect(egElev).toHaveText("−2.80"); await expect(ogElev).toHaveText("±0.00"); + // Höhe direkt eintippen: unter ±0.00 passt sich die eigene Geschosshöhe an. + const z = page.getByTestId("level-elevation-input"); + await z.fill("-3"); + await z.press("Enter"); + await expect(egElev).toHaveText("−3.00"); + await expect(ogElev).toHaveText("±0.00"); await page.keyboard.press("Escape"); - // Undo: Höhe zurück, dann Bezug zurück (ein Schritt) → EG wieder ±0.00. + // Undo: eingetippte Höhe zurück, Geschosshöhe zurück, dann Bezug zurück (ein Schritt) → EG wieder ±0.00. await blurFocus(page); await page.keyboard.press("ControlOrMeta+z"); + await expect(egElev).toHaveText("−2.80"); + await page.keyboard.press("ControlOrMeta+z"); await expect(egElev).toHaveText("−2.60"); await page.keyboard.press("ControlOrMeta+z"); await expect(egElev).toHaveText("±0.00"); diff --git a/src/i18n/de.ts b/src/i18n/de.ts index d236588b..70093f31 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -1014,6 +1014,7 @@ export const de = { "editor.floorHeight": "Geschosshöhe", "editor.cutHeight": "Schnitthöhe", "editor.levelElevation": "OK fertig Boden", + "editor.levelElevation.hint": "Höhe relativ zu ±0.00 eintippen; die Geschosshöhe darunter (unter ±0.00: die eigene) passt sich an", "editor.zeroLevel": "Bezug ±0.00", "editor.zeroLevel.hint": "Dieses Geschoss liegt auf ±0.00; Geschosse darunter erhalten negative Höhen.", "editor.viewTop": "Oberkante Sicht", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 1b3f9f06..965fdb56 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -1008,6 +1008,7 @@ export const en: Record = { "editor.floorHeight": "Floor height", "editor.cutHeight": "Cut height", "editor.levelElevation": "Finished floor level", + "editor.levelElevation.hint": "Type the level relative to ±0.00; the storey height below (below ±0.00: its own) adapts", "editor.zeroLevel": "Datum ±0.00", "editor.zeroLevel.hint": "This storey is at ±0.00; storeys below get negative elevations.", "editor.viewTop": "View top", diff --git a/src/menus/InlineEditors.elevation.test.ts b/src/menus/InlineEditors.elevation.test.ts new file mode 100644 index 00000000..d4d7e04c --- /dev/null +++ b/src/menus/InlineEditors.elevation.test.ts @@ -0,0 +1,22 @@ +import { describe, expect, it } from "vitest"; +import type { DrawingLevel } from "../model/types"; +import { elevationFix } from "./InlineEditors"; + +const lv = (id: string, base: number, h: number, zero = false) => + ({ id, name: id, kind: "floor", visible: true, locked: false, baseElevation: base, floorHeight: h, ...(zero ? { zeroLevel: true } : {}) }) as unknown as DrawingLevel; +const levels = [lv("ug", -2.7, 2.7), lv("eg", 0, 2.9, true), lv("og", 2.9, 2.8)]; + +describe("[131] Geschosshöhe direkt setzen", () => { + it("über ±0.00: Geschosshöhe darunter passt sich an", () => { + expect(elevationFix(levels, "og", 3.1)).toEqual({ id: "eg", floorHeight: 3.1 }); + }); + it("unter ±0.00: eigene Geschosshöhe passt sich an", () => { + expect(elevationFix(levels, "ug", -3)).toEqual({ id: "ug", floorHeight: 3 }); + }); + it("Bezugsgeschoss, gleiche Höhe und Unsinn: nichts", () => { + expect(elevationFix(levels, "eg", 1)).toBeNull(); + expect(elevationFix(levels, "og", 2.9)).toBeNull(); + expect(elevationFix(levels, "og", -1)).toBeNull(); + expect(elevationFix(levels, "og", Number.NaN)).toBeNull(); + }); +}); diff --git a/src/menus/InlineEditors.tsx b/src/menus/InlineEditors.tsx index 8d4ee621..ab43e90b 100644 --- a/src/menus/InlineEditors.tsx +++ b/src/menus/InlineEditors.tsx @@ -116,6 +116,29 @@ function isZeroLevel(levels: readonly DrawingLevel[], id: string): boolean { return (floors.find((z) => z.zeroLevel) ?? floors[0])?.id === id; } +/** + * [131] Höhe eines Geschosses direkt setzen: Über ±0.00 wird die Geschosshöhe des Geschosses darunter angepasst, + * unter ±0.00 die eigene (Abstand zum Geschoss darüber). Liefert die Änderung oder `null` bei Unsinn + * (gleiche Höhe, nicht positiv, Bezugsgeschoss). + */ +export function elevationFix(levels: readonly DrawingLevel[], id: string, z: number): { id: string; floorHeight: number } | null { + if (!Number.isFinite(z)) return null; + const floors = levels.filter((l) => l.kind === "floor").slice().sort((a, b) => (a.baseElevation ?? 0) - (b.baseElevation ?? 0)); + const i = floors.findIndex((l) => l.id === id); + if (i < 0 || isZeroLevel(levels, id)) return null; + const cur = floors[i].baseElevation ?? 0; + if (Math.abs(z - cur) < 1e-9) return null; + const round = (v: number) => Math.round(v * 1e6) / 1e6; + if (cur > 0) { + const below = floors[i - 1]; + const h = round(z - (below?.baseElevation ?? 0)); + return below && h > 0 ? { id: below.id, floorHeight: h } : null; + } + const above = floors[i + 1]; + const h = round((above?.baseElevation ?? 0) - z); + return above && h > 0 ? { id, floorHeight: h } : null; +} + export function LevelInlineEditor({ editor, onClose, @@ -149,7 +172,28 @@ export function LevelInlineEditor({ {/* [131] OK fertig Boden relativ zu ±0.00 (aus dem Stapel); ein Geschoss ist der Bezug. */} - {formatElevation(level.baseElevation ?? 0)} + {isZeroLevel(project.drawingLevels, level.id) ? ( + {formatElevation(level.baseElevation ?? 0)} + ) : ( + { + if (e.key !== "Enter") return; + e.stopPropagation(); + const fix = elevationFix(project.drawingLevels, level.id, Number((e.target as HTMLInputElement).value)); + if (fix) patchLevel(fix.id, { floorHeight: fix.floorHeight }); + }} + onBlur={(e) => { + const fix = elevationFix(project.drawingLevels, level.id, Number(e.target.value)); + if (fix) patchLevel(fix.id, { floorHeight: fix.floorHeight }); + }} + /> + )} {t("editor.unit.m")}