Merge branch 'worktree-agent-a9472965c2e002097' into claude/practical-noether-1hb2s1

This commit is contained in:
Claude committed 2026-11-11 21:38:37 +00:00
commit c6dd5ce91d
19 files changed
+513 -78

No files matched your search

+1 -1
View File
@@ -85,7 +85,7 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `*
gedämpft (render3d hat nur `set_ghost` für die Hülle); natives Mac-3D-Fenster bekommt nur den Ebenen-Baum, nicht
den Darstellungsmodus; Datei-Exporte (OBJ/glTF/IFC/STEP) bleiben vollständig; kein e2e (3D-Pick headless unzuverlässig);
nicht in der Tauri-App/auf dem Mac geprüft. · M
- ○ **[193]** Anwählen/Bearbeiten von Gelände & Co. (12.11., Maintainer, PRIO): Cmd+A lässt Kontext-Elemente (Gelände, Höhenlinien, Baugrube, Kontext) bewusst aus (`useKeyboardShortcuts.ts`) — seit [181] normale Elemente → mit auswählen (gesperrte nicht). Nach Löschen bleibt eine Belag-Schraffur, die weder anwählbar noch löschbar ist (vermutlich Decke/Raum anderes Geschoss) → klären: sichtbar ⇒ anwählbar. Baugrube im Grundriss nicht anwähl-/verschiebbar → Pick, Verschieben, Eckgriffe. Gelände nicht anpassbar → Anwählen, Verschieben, Höhe versetzen; Höhenlinien: Höhe je Linie, Punkte ziehen; Netz: verschieben/versetzen/zuschneiden. e2e für alles. · M
- ◐ **[193]** Anwählen/Bearbeiten von Gelände & Co. (12.11., Maintainer, PRIO; Stand 11.11.): **erledigt** — Cmd+A nimmt Gelände, Höhenlinien, Baugrube, Netze, Bilder mit (sichtbare, nicht gesperrte Klasse; reine Funktion `state/selectAll.ts`) und die Schattenfläche der Sonnenstudie (`site: sunStudy`); Entf löscht sie in einem Undo-Schritt (Schatten: blendet `sunStudy.show` aus). Die „nicht lösch-/anwählbare Schraffur" war der Schatten der Sonnenstudie (abgeleitet aus den Geschossen, die Cmd+A nicht erfasst, Loch = Treppenöffnung); er war schon anwählbar ([137]), aber Entf tat nichts. Verschieben/Kopieren/Drehen/Spiegeln für Kontext-Elemente (Kern `cmd_transform.rs`, `contextIds`; Baugrube, Höhenlinien, Netze, Bild); Objekt-Info: Höhenversatz für Gelände/Netz/Höhenlinien/Baugrube und Höhe je Höhenlinie (`state/contextHeight.ts`, TS-Hilfe, später in den Kern). Baugrube war im Grundriss schon anwählbar (Kern-Pick) und hat Eckgriffe (`useGripEditing`); e2e `selectAllContext.spec.ts`. **Offen:** Punkte einer Höhenlinie per Griff ziehen; Gelände-Netz zuschneiden/Punkte editieren; Ziehen im Plan ohne Befehl (Drag-Move) für Kontext; Höhen-Helfer nach Rust; „Entf" auf Baurechtslinie/Ansichtsschatten blendet noch nichts aus. · M
- ○ **[192]** Ebenen/Klassen schnell schalten (12.11., Maintainer): Rechtsklick im Ebenen-Panel „Nur diese Ebene anzeigen“, „Diese ausblenden“, „Alle einblenden“; Rechtsklick auf Objekt (Plan/Schnitt/3D) „Ebene des Objekts isolieren/ausblenden“, „Alle Ebenen einblenden“ (stellt Zustand vor dem Isolieren wieder her); optional Kürzel. Sonnet. · S
- ○ **[191]** Runde Decken/Dächer (12.11., Maintainer-Screenshot Erker 3D): Decken-/Dachumrisse sind Polygone (Beispiel: `arcPts(…, 14)`) → facettierte Kanten; Bogenwände ohne Deckenauflager [178] → Decke ragt durch die runde Wand (Flackern/Linien). Umsetzen: Bögen im Umriss (Bulge je Kante wie Wände) für Decken/Dächer/Räume oder Ableitung aus angrenzenden Bogenwänden, feine Tessellierung + weiche Normalen im 3D, echte Bögen in Plan/Schnitt/Export; [178] auch an Bogenwänden; Beispielprojekt auf echte Bögen umstellen. Opus. · L
- ◐ **[190]** Verbinden wie Archicad + Kürzel (12.11., Wunsch Maintainer). Umgesetzt (12.11.): Cmd/Ctrl+J („join") schliesst bei
+113
View File
@@ -0,0 +1,113 @@
// [193] Mac-Befund (Musterhaus komplex): Cmd+A nahm Gelände/Höhenlinien/Baugrube nicht mit, nach Cmd+A + Entf blieb eine
// Fläche im Grundriss stehen, die Baugrube liess sich nicht anwählen/verschieben, das Gelände nicht anpassen.
// Geprüft wie ein Nutzer: Cmd+A → Entf (ein Undo-Schritt, im Grundriss bleibt keine gefüllte Fläche), Baugrube anklicken
// (Objekt-Info), Baugrube mit „Verschieben" versetzen und rückgängig machen, Gelände-Höhenversatz.
import type { Page } from "@playwright/test";
import { blurFocus, discardIfAsked, expect, fileMenu, openTab, showSnapshot, test, typeCommand } from "./app";
import type {} from "../src/state/testHooks"; // Typ von window.__dossierTest
async function clickModel(page: Page, x: number, y: number): Promise<void> {
const p = await page.locator("svg.plan-svg").first().evaluate(
(el, [x, y]) => {
const [vx, vy, vw, vh] = el.getAttribute("viewBox")!.split(/\s+/).map(Number);
const ox = Number(el.getAttribute("data-origin-x") ?? 0);
const oy = Number(el.getAttribute("data-origin-y") ?? 0);
const r = el.getBoundingClientRect();
const s = Math.min(r.width / vw, r.height / vh);
return { x: r.left + (r.width - vw * s) / 2 + (x * 90 - ox - vx) * s, y: r.top + (r.height - vh * s) / 2 + (-y * 90 - oy - vy) * s };
},
[x, y],
);
await page.mouse.click(p.x, p.y);
}
const ctx = (page: Page) => page.evaluate(() => window.__dossierTest!.context());
const fills = (page: Page) => page.evaluate(() => window.__dossierTest!.planFills());
const objInfo = (page: Page) => page.locator(".objinfo-panel").first();
async function openComplex(page: Page): Promise<void> {
await page.goto("/?dossierTest");
await page.getByRole("button", { name: /Neues Projekt/ }).first().click();
await expect(page.getByRole("group", { name: "Befehlszeile" })).toBeVisible();
await fileMenu(page, /Musterhaus \(komplex\)/);
await discardIfAsked(page);
await expect(page.locator(".project-name")).toHaveText("Musterhaus komplex", { timeout: 30_000 });
await expect(page.locator("svg.plan-svg").first()).toBeVisible({ timeout: 30_000 });
}
test("Musterhaus komplex: Cmd+A + Entf nimmt Gelände und Baugrube mit, nichts Gefülltes bleibt, ein Undo-Schritt", async ({ page }) => {
test.setTimeout(120_000);
await openComplex(page);
await showSnapshot(page, "EG 1:100");
// Die Klasse „02 Gelände" ist in diesem Ausschnitt ausgeblendet: Cmd+A nimmt nur Sichtbares mit — erst einblenden.
await openTab(page, "Ebenen");
await page.getByRole("button", { name: /^Gelände sichtbar$/ }).click();
await openTab(page, "Objekt-Info");
const before = await ctx(page);
expect(before.map((c) => c.type)).toEqual(expect.arrayContaining(["terrainMesh", "contourSet", "excavation"]));
expect(await fills(page)).toBeGreaterThan(0);
await blurFocus(page);
await page.keyboard.press("ControlOrMeta+a");
await page.keyboard.press("Delete");
// Gelände, Baugrube weg; die Höhenlinien (Klasse „14", im Ausschnitt ausgeblendet) bleiben — Cmd+A nimmt nur Sichtbares mit.
expect((await ctx(page)).map((c) => c.type)).toEqual(["contourSet"]);
await expect.poll(() => fills(page)).toBe(0);
// Ein Undo-Schritt bringt alles zurück.
await blurFocus(page);
await page.keyboard.press("ControlOrMeta+z");
expect((await ctx(page)).length).toBe(before.length);
await expect.poll(() => fills(page)).toBeGreaterThan(0);
});
test("Musterhaus komplex: Baugrube anklicken, mit Verschieben versetzen, Rückgängig; Höhenversatz am Gelände", async ({ page }) => {
test.setTimeout(120_000);
await openComplex(page);
await showSnapshot(page, "EG 1:100");
await openTab(page, "Objekt-Info");
// Klick in die Südwest-Böschung der Baugrube (ausserhalb der Sohle, weg von Wänden).
await expect(async () => {
await page.keyboard.press("Escape");
await clickModel(page, -1.6, 4);
await expect(objInfo(page)).toContainText("Baugrube", { timeout: 1000 });
}).toPass({ timeout: 30_000 });
const first = async () => (await ctx(page)).find((c) => c.type === "excavation")!.first!;
const p0 = await first();
await blurFocus(page);
await page.keyboard.press("m");
await expect(page.locator(".cmdline-prompt")).toHaveText("Basispunkt klicken");
await typeCommand(page, "0,0");
await typeCommand(page, "2,3");
await expect(page.locator(".cmdline-prompt")).toHaveText("Befehl:");
const p1 = await first();
expect(Math.round((p1.x - p0.x) * 1000) / 1000).toBe(2);
expect(Math.round((p1.y - p0.y) * 1000) / 1000).toBe(3);
await blurFocus(page);
await page.keyboard.press("ControlOrMeta+z");
expect(await first()).toEqual(p0);
});
test("Musterhaus komplex: Gelände anwählen und Höhenversatz mit Undo", async ({ page }) => {
test.setTimeout(120_000);
await openComplex(page);
await showSnapshot(page, "Situation 1:500");
await openTab(page, "Objekt-Info");
const offset = objInfo(page).getByTestId("context-height-offset");
await expect(async () => {
await page.keyboard.press("Escape");
await clickModel(page, -12, -10);
await expect(offset).toBeVisible({ timeout: 1000 });
}).toPass({ timeout: 30_000 });
const zOf = () => page.evaluate(() => window.__dossierTest!.terrainZ());
const z0 = await zOf();
await offset.fill("0.5");
await offset.press("Enter");
await expect.poll(async () => Math.round(((await zOf()) - z0) * 1000) / 1000).toBe(0.5);
await blurFocus(page);
await page.keyboard.press("ControlOrMeta+z");
await expect.poll(async () => Math.round(((await zOf()) - z0) * 1000) / 1000).toBe(0);
});
+111 -2
View File
@@ -287,6 +287,58 @@ fn mv_tree(t: &Value, xf: &Xf) -> Value {
with(t, "position", pt(n.0, n.1))
}
/// [193] Gelände-/Umgebungs-Element (`Project.context`): alle x/y abbilden, z bleibt. Netze (`importedMesh`,
/// `terrainMesh`): Positionen (x,y,z flach), bei Spiegelung Dreiecks-Umlauf umkehren; Höhenlinien: Punkte
/// (eine wahre Kurve `curve` fällt weg, ausser bei reiner Verschiebung); Baugrube: Umriss; Luftbild: Rahmen.
fn mv_context(e: &Value, xf: &Xf) -> Value {
let kind = field(e, "type").and_then(Value::as_str).unwrap_or("");
match kind {
"importedMesh" | "terrainMesh" => {
let src = arr(field(e, "positions"));
let mut out = Vec::with_capacity(src.len());
for c in src.chunks(3) {
if c.len() < 3 {
out.extend(c.iter().cloned());
continue;
}
let (x, y) = xf.apply(num_of(Some(&c[0])), num_of(Some(&c[1])));
out.extend([js_num(x), js_num(y), c[2].clone()]);
}
let mut f = vec![("positions", Value::Array(out))];
if xf.reverses() {
let idx: Vec<Value> = arr(field(e, "indices")).chunks(3).flat_map(|t| if t.len() == 3 { vec![t[0].clone(), t[2].clone(), t[1].clone()] } else { t.to_vec() }).collect();
f.push(("indices", Value::Array(idx)));
}
with_all(e, f)
}
"contourSet" => {
let translate = matches!(xf, Xf::Move { .. });
let cs: Vec<Value> = arr(field(e, "contours"))
.iter()
.map(|c| {
let c = with(c, "pts", xf.pts(field(c, "pts")));
match field(&c, "curve") {
Some(cv) if translate => {
let n = xf.apply(num_of(field(cv, "cx")), num_of(field(cv, "cy")));
with(&c, "curve", with_all(cv, vec![("cx", js_num(n.0)), ("cy", js_num(n.1))]))
}
Some(_) => with_opt(&c, vec![("curve", None)]),
None => c,
}
})
.collect();
with(e, "contours", Value::Array(cs))
}
"excavation" => with(e, "outline", xf.pts(field(e, "outline"))),
"image" => {
let (a, b) = (xy(field(e, "min").unwrap_or(&Value::Null)), xy(field(e, "max").unwrap_or(&Value::Null)));
let (p, q) = (xf.apply(a.0, a.1), xf.apply(b.0, b.1));
with_all(e, vec![("min", pt(jsnum::min(p.0, q.0), jsnum::min(p.1, q.1))), ("max", pt(jsnum::max(p.0, q.0), jsnum::max(p.1, q.1)))])
}
_ => e.clone(),
}
}
fn mv_ceiling(c: &Value, xf: &Xf) -> Value {
let mut f = vec![("outline", xf.pts(field(c, "outline")))];
if truthy(field(c, "openings")) {
@@ -567,6 +619,8 @@ pub struct Sel {
pub opening_ids: Option<Vec<String>>,
/// [149] Gewählte Bäume.
pub tree_ids: Option<Vec<String>>,
/// [193] Gewählte Gelände-/Umgebungs-Elemente (`Project.context`).
pub context_ids: Option<Vec<String>>,
}
fn nonempty(s: &Option<String>) -> Option<&str> {
@@ -622,6 +676,7 @@ enum Kind {
Stair,
Room,
Tree,
Context,
}
/// Dächer nur bei Verschieben/Skalieren (der Umriss ist an die Weltachsen gebunden, der First folgt
@@ -657,6 +712,7 @@ fn gather<'a>(root: &'a Map<String, Value>, sel: &Sel, op: &str, ignore_lock: bo
each("stairs", Ids::opt(&sel.stair_ids), Kind::Stair);
each("rooms", Ids::opt(&sel.room_ids), Kind::Room);
each("trees", Ids::opt(&sel.tree_ids), Kind::Tree);
each("context", Ids::opt(&sel.context_ids), Kind::Context);
out
}
@@ -835,6 +891,10 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
if !trees.is_empty() {
patch("trees", &|t| trees.has(t) && !locked(t), &|t| mv_tree(t, &xf));
}
let ctx = Ids::opt(&sel.context_ids);
if !ctx.is_empty() {
patch("context", &|c| ctx.has(c), &|c| mv_context(c, &xf));
}
// Öffnungen in bewegten Dächern/Decken ([103]) folgen ihrem Wirt.
let hosts: std::collections::HashSet<&str> =
items.iter().filter(|(k, _)| matches!(k, Kind::Roof | Kind::Ceiling)).filter_map(|(_, e)| id_of(e)).collect();
@@ -850,7 +910,7 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
// Kopien (Kopie/Reihe/Verteilen bzw. gespiegelte Kopie).
let mut ids = IdGen::new(&req.stamp);
let mut new: [Vec<Value>; 9] = Default::default();
let mut new: [Vec<Value>; 10] = Default::default();
let mut new_openings = Vec::new();
for t in copy_ts(op, &req.mode, req.count.0) {
let xf = Xf::of(op, &pts, t);
@@ -866,6 +926,7 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
Kind::Stair => "ST",
Kind::Room => "RM",
Kind::Tree => "tree",
Kind::Context => "ctx",
})
.collect();
let new_ids: Vec<String> = prefixes.iter().map(|p| ids.next(p)).collect();
@@ -891,6 +952,7 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
Kind::Stair => (6, mv_stair(e, &xf, k_at(t))),
Kind::Room => (7, mv_room(e, &xf)),
Kind::Tree => (8, mv_tree(e, &xf)),
Kind::Context => (9, mv_context(e, &xf)),
};
new[slot].push(with(&v, "id", Value::String(new_id.clone())));
}
@@ -912,7 +974,7 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
}
}
}
let keys = ["walls", "drawings2d", "extrudedSolids", "columns", "ceilings", "roofs", "stairs", "rooms", "trees"];
let keys = ["walls", "drawings2d", "extrudedSolids", "columns", "ceilings", "roofs", "stairs", "rooms", "trees", "context"];
for (key, items) in keys.iter().zip(new) {
ops.extend(add(key, items));
}
@@ -1228,6 +1290,27 @@ fn item_preview(p: &Project, kind: Kind, e: &Value, xf: &Xf, out: &mut Pending)
let ring: Vec<(f64, f64)> = crate::tree::circle([c.0, c.1], d / 2.0, 24).into_iter().map(|q| (q[0], q[1])).collect();
s.poly(&ring);
}
Kind::Context => {
// [193] Baugrube: Umriss; Netze, Höhenlinien, Bild: Rahmen der abgebildeten Punkte.
let pts: Vec<(f64, f64)> = match field(e, "type").and_then(Value::as_str) {
Some("excavation") => pts_of(field(e, "outline")),
Some("importedMesh" | "terrainMesh") => arr(field(e, "positions")).chunks(3).filter(|c| c.len() == 3).map(|c| (num_of(Some(&c[0])), num_of(Some(&c[1])))).collect(),
Some("contourSet") => arr(field(e, "contours")).iter().flat_map(|c| pts_of(field(c, "pts"))).collect(),
Some("image") => {
let (a, b) = (xy(field(e, "min").unwrap_or(&Value::Null)), xy(field(e, "max").unwrap_or(&Value::Null)));
vec![a, (b.0, a.1), b, (a.0, b.1)]
}
_ => vec![],
};
let mapped_pts = mapped(&pts, xf);
if field(e, "type").and_then(Value::as_str) == Some("excavation") {
s.poly(&mapped_pts);
} else if !mapped_pts.is_empty() {
let (x0, x1) = mapped_pts.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |a, p| (a.0.min(p.0), a.1.max(p.0)));
let (y0, y1) = mapped_pts.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |a, p| (a.0.min(p.1), a.1.max(p.1)));
s.poly(&[(x0, y0), (x1, y0), (x1, y1), (x0, y1)]);
}
}
Kind::Drawing => {
let at = s.buf.len();
out.drawings.push((at, with_geom(e, mv_geom(field(e, "geom").unwrap_or(&Value::Null), xf))));
@@ -1407,6 +1490,32 @@ mod tests {
assert_eq!(ops[0]["items"][0]["position"], json!({"x":4,"y":3}));
}
/// [193] Gelände-/Umgebungs-Elemente verschieben: Baugrube (Umriss), Höhenlinien, Gelände-Netz (z bleibt), Spiegeln kehrt den Netz-Umlauf um.
#[test]
fn kontext_verschieben() {
let r = root(json!({"context":[
{"id":"bg","type":"excavation","bottom":-2,"outline":[{"x":0,"y":0},{"x":4,"y":0},{"x":4,"y":4}]},
{"id":"hl","type":"contourSet","contours":[{"z":5,"pts":[{"x":1,"y":1},{"x":2,"y":1}],"closed":false}]},
{"id":"tm","type":"terrainMesh","positions":[0,0,7, 1,0,8, 0,1,9],"indices":[0,1,2]},
{"id":"x","type":"excavation","outline":[{"x":0,"y":0}]}]}));
let run = |op: &str, pts: Value| {
let req: TransformReq = serde_json::from_value(json!({"sel":{"wallIds":[],"contextIds":["bg","hl","tm"]},"op":op,"pts":pts,"mode":"move","count":1,"stamp":"s"})).unwrap();
transform_ops(&r, &Project::default(), &req).iter().map(|o| o.to_json()).collect::<Vec<_>>()
};
let ops = run("move", json!([[0, 0], [3, 1]]));
assert_eq!(ops.len(), 3, "{ops:?}");
assert!(ops.iter().all(|o| o["collection"] == "context"));
assert_eq!(ops[0]["entity"]["outline"][1], json!({"x":7,"y":1}));
assert_eq!(ops[0]["entity"]["bottom"], json!(-2));
assert_eq!(ops[1]["entity"]["contours"][0]["pts"][0], json!({"x":4,"y":2}));
assert_eq!(ops[2]["entity"]["positions"], json!([3, 1, 7, 4, 1, 8, 3, 2, 9]));
assert_eq!(ops[2]["entity"]["indices"], json!([0, 1, 2]));
// Spiegeln an der x-Achse: y wechselt das Vorzeichen, Dreiecke laufen rückwärts.
let ops = run("mirror", json!([[0, 0], [1, 0]]));
assert_eq!(ops[2]["entity"]["positions"], json!([0, 0, 7, 1, 0, 8, 0, -1, 9]));
assert_eq!(ops[2]["entity"]["indices"], json!([0, 2, 1]));
}
/// [T2] Bogenwand: Verschieben/Drehen behalten den Bulge, Spiegeln kehrt ihn um.
#[test]
fn bogenwand_spiegeln_kehrt_bulge() {
+2
View File
@@ -88,6 +88,8 @@ export interface CommandSelection {
openingIds?: string[];
/** [149] Gewählte Bäume (Verschieben/Kopieren/Spiegeln/Drehen: Stammmitte). */
treeIds?: string[];
/** [193] Gewählte Gelände-/Umgebungs-Elemente (`Project.context`: Gelände, Höhenlinien, Baugrube, Netze, Bilder). */
contextIds?: string[];
}
/** Live-Kontext, den ein Befehl bei jedem Schritt erhält (analog ToolContext). */
+4
View File
@@ -2415,6 +2415,10 @@ export const de = {
"site.contourIndexEvery": "Zähllinie jede",
"site.smoothShading": "Glatt schattieren",
"site.creaseAngle": "Knickwinkel °",
"site.heightOffset": "Höhenversatz [m]",
"site.heightOffset.hint": "Alle Höhen des Elements um diesen Wert verschieben (Eingabe mit Enter bestätigen; negativ = tiefer).",
"site.contours": "Höhenlinien ({n}) — Höhe [m]",
"site.contour.points": "{n} Punkte",
"site.excavation.bottom": "Sohle [m]",
"site.excavation.slope": "Böschung [°]",
"site.excavation.fillSlope": "Schüttung [°]",
+4
View File
@@ -2403,6 +2403,10 @@ export const en: Record<TranslationKey, string> = {
"site.contourIndexEvery": "Index contour every",
"site.smoothShading": "Smooth shading",
"site.creaseAngle": "Crease angle °",
"site.heightOffset": "Height offset [m]",
"site.heightOffset.hint": "Shift all heights of this element by this value (confirm with Enter; negative = lower).",
"site.contours": "Contours ({n}) — height [m]",
"site.contour.points": "{n} points",
"site.excavation.bottom": "Bottom [m]",
"site.excavation.slope": "Slope [°]",
"site.excavation.fillSlope": "Fill slope [°]",
+64 -1
View File
@@ -11,7 +11,8 @@ import { useStore } from "../state/appStore";
import type { ContextObject } from "../model/types";
import { flattenCategories } from "../model/types";
import { resmoothGridTerrain } from "../model/terrain";
import { useMemo } from "react";
import { useMemo, useState } from "react";
import { contourHeightPatch, heightOffsetPatch } from "../state/contextHeight";
import type { ExcavationQuantity } from "../core";
/** Zahl-Eingabe für ein Feld eines Kontext-Objekts (leer = Standard, ungültig = keine Änderung). */
@@ -64,8 +65,70 @@ const SMOOTH_LEVELS = [0, 1, 2, 3] as const;
/** [137] Zusätzliche Glättungs-Durchgänge für Raster-Gelände. */
const RESMOOTH_PASSES = [1, 2, 4] as const;
/** [193] Höhenversatz (alle Höhen um dz) und, bei Höhenlinien, die Höhe je Linie. */
function HeightFields({ obj }: { obj: ContextObject }) {
const host = usePanelHost();
const [dz, setDz] = useState("");
if (obj.type === "image") return null;
const apply = () => {
const patch = dz.trim() === "" ? null : heightOffsetPatch(obj, Number(dz.replace(",", ".")));
if (patch) host.onPatchContextObject(obj.id, patch);
setDz("");
};
return (
<>
<label className="site-prop" title={t("site.heightOffset.hint")}>
<span>{t("site.heightOffset")}</span>
<input
type="text"
inputMode="decimal"
data-testid="context-height-offset"
placeholder="0.00"
value={dz}
onChange={(e) => setDz(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && apply()}
onBlur={apply}
/>
</label>
{obj.type === "contourSet" && (
<div className="site-prop" data-testid="contour-heights" style={{ display: "block", maxHeight: 180, overflowY: "auto" }}>
<span>{t("site.contours", { n: obj.contours.length })}</span>
{obj.contours.map((c, i) => (
<label key={i} style={{ display: "flex", gap: 6, alignItems: "center" }}>
<span style={{ flex: 1 }}>{`${i + 1} · ${t("site.contour.points", { n: c.pts.length })}`}</span>
<input
type="number"
step={0.5}
style={{ width: 90 }}
data-testid={`contour-z-${i}`}
value={c.z}
onChange={(e) => {
const patch = e.target.value.trim() === "" ? null : contourHeightPatch(obj, i, Number(e.target.value));
if (patch) host.onPatchContextObject(obj.id, patch, `site-${obj.id}-contourZ-${i}`);
}}
/>
</label>
))}
</div>
)}
</>
);
}
/** Felder eines Kontext-Objekts; `null` für Arten ohne eigene Einstellungen (Höhenlinien, Luftbild). */
export function ContextObjectProps({ obj, quantities }: { obj: ContextObject; quantities: readonly ExcavationQuantity[] }) {
return (
<>
<KindFields obj={obj} quantities={quantities} />
<div className="site-props">
<HeightFields obj={obj} />
</div>
</>
);
}
function KindFields({ obj, quantities }: { obj: ContextObject; quantities: readonly ExcavationQuantity[] }) {
const host = usePanelHost();
const project = useStore((s) => s.project);
const notify = useStore((s) => s.notify);
+1 -1
View File
@@ -70,7 +70,7 @@ in `ProjectSync`.
| `view3dFilter.ts` | 3D-Element-Filter ([185], rein UI): „Auswahl in 3D zeigen" (Cmd/Ctrl+3) und temporär ausgeblendete Elemente (Cmd/Ctrl+4); Geschoss-Kürzel Cmd/Ctrl+5/6 in `tabNavigation.ts` |
| `selectionActions.ts` | Ablage für Aktionen mit mehreren Eingängen ([190]): Duplizieren, Sperren, Verbinden, Ebenen aus-/einblenden, Einpassen — Tastenkürzel und natives Menü rufen dieselben Funktionen (`runSelectionAction`) |
| `groupActions.ts` | Gruppen erzeugen, auflösen, betreten |
| `exportScope.ts`, `objectLock.ts` | Export „nur Auswahl"; Objekt-Sperre |
| `exportScope.ts`, `objectLock.ts`, `selectAll.ts`, `contextHeight.ts` | Export „nur Auswahl"; Objekt-Sperre; Cmd+A-Auswahl (reine Funktion); Höhenversatz von Gelände-Elementen |
| `autosave.ts`, `projectStore.ts`, `recentProjects.ts`, `startupGuard.ts` | Autosave und Wiederherstellen, IndexedDB, zuletzt geöffnet, Start-Protokoll |
| `aiAccess.ts` | KI-Zugriff auf das offene Projekt (`[9]`) |
+24
View File
@@ -0,0 +1,24 @@
import { describe, expect, it } from "vitest";
import { contourHeightPatch, heightOffsetPatch } from "./contextHeight";
import type { ContextObject } from "../model/types";
const base = { id: "a", name: "A", categoryCode: "02" };
const set = { ...base, type: "contourSet", contours: [{ z: 500, pts: [], closed: false }, { z: 501, pts: [], closed: false }] } as ContextObject;
describe("Höhe von Gelände-Elementen", () => {
it("Netz: nur z wird versetzt", () => {
const o = { ...base, type: "terrainMesh", positions: [0, 0, 5, 1, 0, 6, 0, 1, 7], indices: [0, 1, 2] } as ContextObject;
expect(heightOffsetPatch(o, -1.5)).toEqual({ positions: [0, 0, 3.5, 1, 0, 4.5, 0, 1, 5.5] });
});
it("Höhenlinien und Baugrube", () => {
expect(heightOffsetPatch(set, 2)).toEqual({ contours: [{ z: 502, pts: [], closed: false }, { z: 503, pts: [], closed: false }] });
expect(heightOffsetPatch({ ...base, type: "excavation", outline: [], bottom: -3 } as ContextObject, 0.5)).toEqual({ bottom: -2.5 });
});
it("keine Änderung bei 0/NaN; Höhe einer Linie", () => {
expect(heightOffsetPatch(set, 0)).toBeNull();
expect(heightOffsetPatch(set, NaN)).toBeNull();
expect(contourHeightPatch(set, 1, 510)).toEqual({ contours: [{ z: 500, pts: [], closed: false }, { z: 510, pts: [], closed: false }] });
expect(contourHeightPatch(set, 1, 501)).toBeNull();
expect(contourHeightPatch(set, 7, 1)).toBeNull();
});
});
+29
View File
@@ -0,0 +1,29 @@
// [193] Höhe von Gelände-/Umgebungs-Elementen ändern: Höhenversatz (alle z um dz) und die Höhe einer einzelnen
// Höhenlinie. Liefert Feld-Patches für `patchContextObject`; `null` = Art ohne Höhe (Luftbild) oder keine Änderung.
import type { ContextObject, Contour } from "../model/types";
/** Alle Höhen des Elements um `dz` Meter versetzen: Netz-z, Höhenlinien-z, Baugruben-Sohle. */
export function heightOffsetPatch(obj: ContextObject, dz: number): Record<string, unknown> | null {
if (!Number.isFinite(dz) || dz === 0) return null;
switch (obj.type) {
case "terrainMesh":
case "importedMesh": {
const pos = obj.positions.slice();
for (let i = 2; i < pos.length; i += 3) pos[i] += dz;
return { positions: pos };
}
case "contourSet":
return { contours: obj.contours.map((c): Contour => ({ ...c, z: c.z + dz })) };
case "excavation":
return { bottom: obj.bottom + dz };
default:
return null;
}
}
/** Höhe der Höhenlinie `index` eines Höhenlinien-Satzes setzen. */
export function contourHeightPatch(obj: ContextObject, index: number, z: number): Record<string, unknown> | null {
if (obj.type !== "contourSet" || !Number.isFinite(z) || !obj.contours[index] || obj.contours[index].z === z) return null;
return { contours: obj.contours.map((c, i): Contour => (i === index ? { ...c, z } : c)) };
}
+52
View File
@@ -0,0 +1,52 @@
// [193] Cmd+A: Kontext-Elemente (Gelände, Höhenlinien, Baugrube, Netze, Bilder) gehören dazu — sichtbare, nicht gesperrte Klasse.
import { beforeAll, describe, expect, it } from "vitest";
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
import { setCategoriesVisible, patchCategoryByCode } from "../model/layers";
import { selectAllIds, selectAllHasAny } from "./selectAll";
import type { Project } from "../model/types";
let p: Project;
beforeAll(() => {
p = buildComplexSampleProject();
});
describe("selectAllIds", () => {
it("nimmt Gelände, Höhenlinien und Baugrube mit", () => {
const ids = selectAllIds(p, "eg");
const all = new Set(ids.contextObjects);
for (const type of ["terrainMesh", "contourSet", "excavation"] as const) {
const c = (p.context ?? []).filter((o) => o.type === type);
expect(c.length, type).toBeGreaterThan(0);
for (const o of c) expect(all.has(o.id), `${type} ${o.id}`).toBe(true);
}
expect(ids.walls!.length).toBeGreaterThan(0);
expect(selectAllHasAny(ids)).toBe(true);
});
it("wählt die Schattenfläche der Sonnenstudie (Entf blendet sie aus), nur im Geschoss-Grundriss", () => {
expect(p.sunStudy?.show).toBe(true);
expect(selectAllIds(p, "eg").site).toEqual(["sunStudy"]);
expect(selectAllIds(p, "schnitt-a").site).toEqual([]);
const q = { ...p, sunStudy: { ...p.sunStudy!, show: false } };
expect(selectAllIds(q, "eg").site).toEqual([]);
});
it("lässt Kontext mit ausgeblendeter Klasse aus", () => {
const ctx = p.context![0];
const q = { ...p, layers: setCategoriesVisible(p.layers, new Set([ctx.categoryCode]), false) };
expect(selectAllIds(q, "eg").contextObjects).not.toContain(ctx.id);
expect(selectAllIds(q, "eg").contextObjects!.length).toBeLessThan(selectAllIds(p, "eg").contextObjects!.length);
});
it("lässt Kontext mit gesperrter Klasse aus", () => {
const ctx = p.context![0];
const q = { ...p, layers: patchCategoryByCode(p.layers, ctx.categoryCode, { locked: true }) };
expect(selectAllIds(q, "eg").contextObjects).not.toContain(ctx.id);
});
it("andere Geschosse bleiben aussen vor", () => {
const ids = selectAllIds(p, "eg");
const ogWall = p.walls.find((w) => w.floorId === "og")!;
expect(ids.walls).not.toContain(ogWall.id);
});
});
+59
View File
@@ -0,0 +1,59 @@
// „Alles auswählen" (Cmd/Ctrl+A) als reine Funktion: Id-Listen des Projekts für das aktive Geschoss.
// Geschossbezogene Elemente nach floorId/levelId; Schnittlinien-Symbole und Kontext-Elemente
// (Gelände, Höhenlinien, Baugrube, Netze, Bilder) sind projektweit — Kontext nur, wenn seine Klasse
// sichtbar und nicht gesperrt ist ([193], seit [181] normale Elemente mit Klasse).
import type { Project } from "../model/types";
import { collectVisibleCodes, flattenCategories } from "../model/layers";
import type { Selection } from "./selection";
export function selectAllIds(project: Project, levelId: string): Partial<Selection> {
const wallIds = project.walls.filter((w) => w.floorId === levelId).map((w) => w.id);
const wallIdSet = new Set(wallIds);
const drawingIds = project.drawings2d.filter((d) => d.levelId === levelId).map((d) => d.id);
const ceilingIds = (project.ceilings ?? []).filter((c) => c.floorId === levelId).map((c) => c.id);
const ceilingIdSet = new Set(ceilingIds);
const roofIds = (project.roofs ?? []).filter((r) => r.floorId === levelId).map((r) => r.id);
const roofIdSet = new Set(roofIds);
// Öffnungen haben kein eigenes floorId (Geschoss über die Wirtswand); Dachfenster/Deckenöffnungen
// ([103]) über das Dach bzw. die Decke des Geschosses.
const openingIds = (project.openings ?? [])
.filter((o) => wallIdSet.has(o.hostWallId) || (!!o.hostRoofId && roofIdSet.has(o.hostRoofId)) || (!!o.hostCeilingId && ceilingIdSet.has(o.hostCeilingId)))
.map((o) => o.id);
const stairIds = (project.stairs ?? []).filter((s) => s.floorId === levelId).map((s) => s.id);
const roomIds = (project.rooms ?? []).filter((r) => r.floorId === levelId).map((r) => r.id);
const solids = (project.extrudedSolids ?? []).filter((s) => s.levelId === levelId).map((s) => s.id);
const columnIds = (project.columns ?? []).filter((c) => c.floorId === levelId).map((c) => c.id);
// Schnittführungs-Symbole sind projektweit (kein floorId; plan/context.rs, plan_section_lines).
const sectionLines = project.drawingLevels
.filter((l) => (l.kind === "section" || l.kind === "elevation") && l.linePoints)
.map((l) => l.id);
// Kontext-Elemente: projektweit, nur sichtbare und nicht gesperrte Klasse.
const ctx = project.context ?? [];
let contextObjects: string[] = [];
if (ctx.length) {
const visible = collectVisibleCodes(project.layers);
const locked = new Set(flattenCategories(project.layers).filter((c) => c.locked).map((c) => c.code));
contextObjects = ctx.filter((c) => visible.has(c.categoryCode) && !locked.has(c.categoryCode)).map((c) => c.id);
}
// Schattenfläche der Sonnenstudie: abgeleitet, aber angeklickt wählbar ([137]) — also auch hier; Entf blendet sie aus.
const level = project.drawingLevels.find((l) => l.id === levelId);
const site = project.sunStudy?.show && level?.kind === "floor" ? ["sunStudy"] : [];
return {
site,
walls: wallIds,
drawings: drawingIds,
ceilings: ceilingIds,
openings: openingIds,
stairs: stairIds,
rooms: roomIds,
solids,
columns: columnIds,
roofs: roofIds,
contextObjects,
sectionLines,
};
}
/** Hat „Alles auswählen" überhaupt etwas gewählt? */
export const selectAllHasAny = (sel: Partial<Selection>): boolean => Object.values(sel).some((l) => (l?.length ?? 0) > 0);
+1
View File
@@ -86,6 +86,7 @@ describe("Selection", () => {
roomIds: [],
openingIds: [],
treeIds: [],
contextIds: [],
});
expect(toTransformSelection(s)).toEqual(c);
});
+3 -1
View File
@@ -142,6 +142,7 @@ export function toCommandSelection(sel: Selection): CommandSelection {
roomIds: sel.rooms,
openingIds: sel.openings,
treeIds: sel.trees,
contextIds: sel.contextObjects,
};
}
@@ -162,7 +163,8 @@ export function hasTransformable(sel: Selection): boolean {
sel.stairs.length > 0 ||
sel.rooms.length > 0 ||
sel.openings.length > 0 ||
sel.trees.length > 0
sel.trees.length > 0 ||
sel.contextObjects.length > 0
);
}
+24
View File
@@ -39,6 +39,12 @@ declare global {
modelView: () => string | undefined;
/** [173] Schnitt der aktiven Ebene (1:50, Detailgrad der Anzeige): Zahl der Wand-Schnittflächen und ihre Fläche (m²). */
sectionWalls: () => Promise<{ n: number; area: number }>;
/** [193] Gelände-/Umgebungs-Elemente (Art, Id, bei der Baugrube die erste Umrissecke). */
context: () => { id: string; type: string; first?: { x: number; y: number } }[];
/** [193] Gefüllte Flächen (Füllfarbe gesetzt) im Grundriss der aktiven Ebene (alle Kategorien, 1:100); bei 0 ist nichts Gefülltes mehr zu sehen. */
planFills: () => number;
/** [193] Höhe (z) des ersten Gelände-Netz-Punkts. */
terrainZ: () => number;
/** [185] Darstellungszustand der Plan-Ansicht: aktive Ebene, Bildmitte (Modell-m), Zoom (px/m), Massstab. */
viewCamera: () => { levelId: string; center: { x: number; y: number } | null; pxPerMeter: number | null; scale: number };
/** [192] Sichtbare Ebenen-Codes und Zahl der Plan-Primitive (gesamt / mit Wand-Bezug) der aktiven Ebene. */
@@ -88,6 +94,24 @@ export function installTestHooks(): void {
walk(s.project.layers);
return generatePlan(s.project, s.activeLevelId, codes, undefined, s.detail, false, false, true, 50).primitives.filter((q) => q.kind === "line" && q.cls === cls).length;
},
context: () =>
(getState().project.context ?? []).map((c) => ({ id: c.id, type: c.type, first: c.type === "excavation" ? c.outline[0] : undefined })),
planFills: () => {
const s = getState();
const codes = new Set<string>();
const walk = (cs: { code: string; children?: unknown[] }[]): void => {
for (const c of cs) {
codes.add(c.code);
walk((c.children ?? []) as { code: string; children?: unknown[] }[]);
}
};
walk(s.project.layers);
return generatePlan(s.project, s.activeLevelId, codes, undefined, s.detail, false, false, true, 100).primitives.filter((q) => q.kind === "polygon" && q.fill && q.fill !== "none").length;
},
terrainZ: () => {
const t = (getState().project.context ?? []).find((c) => c.type === "terrainMesh");
return t && t.type === "terrainMesh" ? t.positions[2] : NaN;
},
modelView: () => getState().project.drawingLevels.find((l) => l.id === getState().activeLevelId)?.modelViewOptionId,
sectionWalls: async () => {
const s = getState();
+4 -68
View File
@@ -10,6 +10,7 @@
//
// Extrahiert aus App.tsx. Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
import { selectAllIds, selectAllHasAny } from "./selectAll";
import { useEffect, useRef } from "react";
import type { RefObject } from "react";
import type { ToolId } from "../tools/types";
@@ -289,74 +290,9 @@ export function useSelectAllAndDeleteShortcut(opts: {
if (matchesShortcut(e, "selectAll", shortcutOverrides)) {
// Projekt beim Tastendruck aus dem Store ([121]: App abonniert es nicht mehr).
const project = getState().project;
const wallIds = project.walls
.filter((w) => w.floorId === activeLevelId)
.map((w) => w.id);
const wallIdSet = new Set(wallIds);
const drawingIds = project.drawings2d
.filter((d) => d.levelId === activeLevelId)
.map((d) => d.id);
const ceilingIds = (project.ceilings ?? [])
.filter((c) => c.floorId === activeLevelId)
.map((c) => c.id);
// Öffnungen haben kein eigenes floorId (das Geschoss ergibt sich aus
// der Wirtswand) — über die bereits geschossgefilterten Wand-Ids.
// Dachfenster/Deckenöffnungen ([103]): über das Dach bzw. die Decke des Geschosses.
const roofIdSet = new Set((project.roofs ?? []).filter((r) => r.floorId === activeLevelId).map((r) => r.id));
const ceilingIdSet = new Set(ceilingIds);
const openingIds = (project.openings ?? [])
.filter((o) => wallIdSet.has(o.hostWallId) || (!!o.hostRoofId && roofIdSet.has(o.hostRoofId)) || (!!o.hostCeilingId && ceilingIdSet.has(o.hostCeilingId)))
.map((o) => o.id);
const stairIds = (project.stairs ?? [])
.filter((s) => s.floorId === activeLevelId)
.map((s) => s.id);
const roomIds = (project.rooms ?? [])
.filter((r) => r.floorId === activeLevelId)
.map((r) => r.id);
const extrudedSolidIds = (project.extrudedSolids ?? [])
.filter((s) => s.levelId === activeLevelId)
.map((s) => s.id);
const columnIds = (project.columns ?? [])
.filter((c) => c.floorId === activeLevelId)
.map((c) => c.id);
const roofIds = (project.roofs ?? [])
.filter((r) => r.floorId === activeLevelId)
.map((r) => r.id);
// Schnittführungs-Symbole sind projektweit (kein floorId-Bezug — sie
// werden auf JEDEM Grundriss gezeichnet, s. plan/context.rs im Kern,
// plan_section_lines), anders als die übrigen, geschossgefilterten Kanäle.
const sectionLineIds = project.drawingLevels
.filter((l) => (l.kind === "section" || l.kind === "elevation") && l.linePoints)
.map((l) => l.id);
// Kontext-Objekte (importierte Gebäude/Terrain) sind ebenfalls
// projektweit, aber bewusst NICHT Teil von „Alles auswählen" — anders
// als Schnittlinien sind sie Hintergrund-/Referenzgeometrie, kein
// Geschossinhalt; ein versehentliches Löschen wäre riskanter als
// hilfreich. Bleibt daher unverändert (kein Clear, kein Select).
if (
wallIds.length ||
drawingIds.length ||
ceilingIds.length ||
openingIds.length ||
stairIds.length ||
roomIds.length ||
extrudedSolidIds.length ||
columnIds.length ||
roofIds.length ||
sectionLineIds.length
) {
setSelection({
walls: wallIds,
drawings: drawingIds,
ceilings: ceilingIds,
openings: openingIds,
stairs: stairIds,
rooms: roomIds,
solids: extrudedSolidIds,
columns: columnIds,
roofs: roofIds,
sectionLines: sectionLineIds,
});
const ids = selectAllIds(project, activeLevelId);
if (selectAllHasAny(ids)) {
setSelection(ids);
e.preventDefault();
}
return;
+6
View File
@@ -150,8 +150,14 @@ export function useSelectionCommands(opts: {
const ctxids = new Set(selection.contextObjects);
// [149] Bäume (gesperrte bleiben).
const treeids = new Set(selection.trees.filter((id) => !(project.trees ?? []).find((t) => t.id === id)?.locked));
// [193] Abgeleitete Lage-Darstellung (Schatten, Baurecht) ist kein Element: Entf blendet sie aus
// (`show: false`; über die Lage-Panels wieder einschaltbar).
const siteHide: ReturnType<typeof fieldOps> = [];
if (selection.site.includes("sunStudy") && project.sunStudy?.show) siteHide.push(...fieldOps(project, "sunStudy", { ...project.sunStudy, show: false }));
if (selection.site.includes("siteRules") && project.siteRules && project.siteRules.show !== false) siteHide.push(...fieldOps(project, "siteRules", { ...project.siteRules, show: false }));
setProject(
opsMutation((p) => [
...siteHide,
...removeItems(p, "drawings2d", dids),
...removeItems(p, "walls", wids),
...removeItems(p, "ceilings", cids),
+5 -1
View File
@@ -55,6 +55,8 @@ export interface TransformSelection {
openingIds?: string[];
/** [149] Gewählte Bäume (Stammmitte wird transformiert). */
treeIds?: string[];
/** [193] Gewählte Gelände-/Umgebungs-Elemente (alle Punkte x/y werden abgebildet). */
contextIds?: string[];
}
/** Auswahl (Befehlskontext) → TransformSelection (gleiche Form, alle Elementarten). */
@@ -71,6 +73,7 @@ export function toTransformSel(sel: CommandSelection): TransformSelection {
roomIds: sel.roomIds,
openingIds: sel.openingIds,
treeIds: sel.treeIds,
contextIds: sel.contextIds,
};
}
@@ -91,7 +94,8 @@ export function hasTransformSelection(sel: CommandSelection, op?: string): boole
(sel.roofIds?.length ?? 0) > 0 ||
(sel.stairIds?.length ?? 0) > 0 ||
(sel.roomIds?.length ?? 0) > 0 ||
(sel.treeIds?.length ?? 0) > 0
(sel.treeIds?.length ?? 0) > 0 ||
(sel.contextIds?.length ?? 0) > 0
);
}
+6 -3
View File
@@ -255,9 +255,12 @@ export function usePlanPicking(inp: UsePlanPickingArgs) {
// [137] Getroffene Lage-Darstellung: Quelle `"sunStudy"`/`"siteRules"` (Baurechtslinie vor Schatten) oder null.
const pickSiteAt = (clientX: number, clientY: number): string | null => {
const ids = contextIdsAt(clientX, clientY).filter((id) => id.startsWith("@") && !id.startsWith(TREE_PICK));
const id = ids.find((x) => x === "@siteRules") ?? ids[0];
return id ? id.slice(1) : null;
const all = contextIdsAt(clientX, clientY).filter((id) => !id.startsWith(TREE_PICK));
// [193] Liegt ein Kontext-Element (Baugrube, Netz) über der Schattenfläche, gehört der Klick ihm — sonst wäre
// die Baugrube unter dem Schatten des Hauses nicht anzuwählen. Die Baurechtslinie (unsichtbares Band) gewinnt immer.
if (all.includes("@siteRules")) return "siteRules";
const top = all[0];
return top && top.startsWith("@") ? top.slice(1) : null;
};
// [149] Getroffener Baum (oberste Kronenfläche) oder null.