diff --git a/TODO.md b/TODO.md index 4025b4ee..509e136f 100644 --- a/TODO.md +++ b/TODO.md @@ -11,7 +11,7 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `* stehen im Archiv („Bewusst nicht übernommen“). - **Grösse** (eine Person mit Agenten): S ≤ 1 Tag · M ≤ 1 Woche · L ≤ 1 Monat · XL > 1 Monat. Steht keine Grösse im Archiv, ist sie hier geschätzt. -- **IDs sind stabil.** Neue ID = nächste freie Zahl nach der höchsten im Archiv und hier (aktuell 316); +- **IDs sind stabil.** Neue ID = nächste freie Zahl nach der höchsten im Archiv und hier (aktuell 317); nie eine ID wiederverwenden oder umnummerieren. Präfix-IDs (`[K]`, `[G]`, `[T]`, `[B]`, `[C]`) bleiben. - **Pro Punkt:** was fehlt · wo im Code · Grösse. Höchstens ein bis drei Sätze je Punkt; Messwerte und Befunde gehören in den Commit. @@ -59,6 +59,7 @@ Kennwort, anonym) als PDF; Austausch mit Fachplanern über DXF/IFC. - ◐ **[307]** 3D-Dokument: Gelände als helle Fläche mit Randlinie (20.11., Bild `doc/review-307/axo.png`; `plan/axo_terrain.rs`, Netz-Quelle `excavation::terrain_model_mesh` wie 3D/Ansicht, mit Baugruben, Klasse über Sichtbarkeit/Ebene, Parameter `terrain` Vorgabe an). Verdeckt den Keller, wird vom Haus verdeckt. Zu dichte Netze (> 12 000 Dreiecke im Ausschnitt um das Gebäude) werden auf ein ~3000-Zellen-Raster umgerechnet (Baugruben-Böschung dort gröber). Offen: keine Höhenlinien (Linien im Gelände), keine Durchdringungslinie Haus/Gelände; Wettbewerb hat kein Gelände, nur Musterhaus komplex geprüft; Mac/Tauri nicht geprüft. · S - ◐ **[308]** 3D-Dokument: Gelände als Modellsockel (20.11., Bild `doc/review-308/axo.png`; `plan/axo_terrain.rs`). Zuschnitt auf Parzelle (`siteRules.parcel`, Bounding-Box ∪ Gebäude) + 2 m, ohne Parzelle Gebäude + 5 m; an allen Randkanten senkrechte Seitenflächen bis tiefster Geländepunkt (inkl. Baugrube) − 1 m, dunkler getönt, senkrechte Kanten nur an Ecken. Bildgrösse folgt Haus + Sockel. Option `terrainClip` (`parcel` Vorgabe | `building` | `none` = wie bisher ohne Sockel), CLI `--terrain-clip`. Offen: Rechteck-Hülle und Keller siehe [309]; keine UI-Einstellung für `terrainClip` (nur Doc3d-Extra/CLI); Mac/Tauri nicht geprüft. · S - ◐ **[309]** 3D-Dokument: Sockelrand gerade, Zuschnitt auf Parzellenumriss, Keller (20.11., Bild `doc/review-309/axo.png`; `plan/axo_terrain.rs`). Zuschnittfläche = Parzellenumriss + 2 m (Gehrung über `kernel2d`, Ecken ≤ 4·d, Selbstschnitte per Vereinigung geheilt, konkave Parzellen) ∪ Gebäude + 2 m, ohne Parzelle Gebäude + 5 m; Dreiecke werden an die Fläche geschnitten (i_overlay), Randkanten nur auf der Zuschnittkante und echtem Netzrand. Deckt das Netz die Fläche nicht oder ist es zu dicht, Raster über der Fläche mit am Netzrand ergänztem (konstant fortgesetztem) Gelände statt gezacktem Rand. Sockel-Unterkante ≤ tiefstes Bauteil − 0.5 m (zusätzlich zu tiefster Geländepunkt − 1 m). Offen: ergänztes Gelände ausserhalb des Netzes ist eine Annahme (nächste Höhe), im Bild nicht gekennzeichnet; keine UI-Einstellung für `terrainClip`; Mac/Tauri nicht geprüft (Haarlinien auf den Sockelseiten: [310]). · S +- ◐ **[317]** Anwählen in Schnitt und Ansicht systematisch geprüft (20.11., Hinweis Maintainer „in Schnitten Elemente nicht anwählbar“). Methode: Test-Naht `viewPickPoints` (`state/testHooks.ts`, PlanView meldet den gezeigten Plan) liefert je Pick-Id einen unüberdeckten Punkt, `e2e/sectionPick317.spec.ts` klickt ihn und prüft die Auswahl; dazu `src/plan/pickIds317.test.ts` (jede Pick-Id gehört zur richtigen Art, vier Beispielprojekte, alle Schnitte/Ansichten). **Behoben:** (a) Stütze/Träger im Schnitt trugen `ceilingId` mit der Stützen-Id → Klick wählte eine nicht vorhandene Decke (`section/primitives.rs`, `Cut::column_id`); (b) Treppe in der Ansicht trug `ceilingId` mit der Treppen-Id (`elevation/mod.rs`, jetzt `stairId`); (c) Rahmen im Schnitt/in der Ansicht nahm Stützen, Träger, Dächer, Fenster/Türen und Körper nicht mit (`MarqueeSelection.columnIds…`, nur mit `sheetBodies`, im Grundriss unverändert). **Geprüft ok** (Klick, Musterhaus komplex Schnitt A-A/B-B, Ansicht Süd/Ost; Wettbewerb/Umbau über Plan-Ids): Wand (geschnitten und dahinter), Decke/Bodenplatte, Dach, Fenster/Tür, 2D-Zeichnung/Entourage, Körper, Baum (`@tree`), Geländer in der Ansicht (`@railing`), Treppe im Schnitt, Gelände. **Offen:** Bauteile unter Geländefläche der Ansicht (UG-Wände, Baugrube, Bodenplatte in Ansicht Ost) wählen das Gelände — liegen sichtbar dahinter, nur über Klick-Zyklus ([137]); Koten/Höhenmarken, Raster, Nordpfeil, Schnittmarken in Ansicht sind abgeleitet und nicht anwählbar; Räume und Treppen in der Ansicht ohne eigene Pick-Fläche an Wand-Stellen nicht gesondert geprüft; Geländer im Schnitt nicht an einem Beispiel getroffen (keins schneidet); Wendeltreppe im Schnitt/Ansicht nur über Pick-Ids, nicht per Klick; Zoom (Rad) im e2e ohne Befund, Pan nicht; Klickpunkte liegen am weitesten vom Rand; nicht auf dem Mac/Tauri geprüft, Kern-WASM nur mit `--no-opt` im Container gebaut. · S - ◐ **[316]** Ansicht: Schlagschatten aus dem Sonnenstand, Materialfuge (Hinweis Maintainer 20.11., Bild `doc/review-316/ansicht.png`). Schatten = Projektion aller Körperflächen (Wände, Decken, Dächer samt Gauben, Stützen, Geländer ausser Glas) in Lichtrichtung auf jede sichtbare Fläche davor, von der Sonne abgewandte Flächen ganz im Eigenschatten, über Öffnungen durchscheinend, Leibungsschatten nach Lichtrichtung (`plan/elevation/sun.rs`; alte 45°-Stirnschatten `elevation_geom::shadows` entfernt). Licht: Vorgabe Zeichenregel 45° von links vorn oben relativ zur Blickrichtung (Entscheid Koordinator); Sonnenstand aus `sunStudy.when` + Geo-Anker nur mit Modelldarstellung „Schattenlicht: Sonnenstand“ (`elevation.shadowLight`). Waagrechte/senkrechte Linie an jedem Wechsel des Fassadenbaustoffs zwischen bündigen Wandflächen (`patterns.rs` `material_seams`). Offen: nicht in der Mac-App geprüft; Kontext-Netze empfangen/werfen keinen Schatten; Licht durch Fensterlöcher nicht berücksichtigt; keine eigene Schalter-Stelle an der Ansichtsebene (nur Modelldarstellung). · M - ◐ **[315]** Verbinden (Cmd/Ctrl+J) von Wänden ohne Abstandslimit (Hinweis Maintainer 20.11.): vorher nur bis max(0.5 m, 2 × Wanddicke); `cmd_wall_edit.rs` `spot`/`connect_pair` (sich schon kreuzende Paare bleiben unberührt), Hinweis `cmd.join.far` entfällt. Offen: nicht auf dem Mac geprüft. · S - ◐ **[314]** Griffe (Eckpunkte) beim Herauszoomen zu gross (Hinweis Maintainer 20.11.): `gripZoomK` (Exponent 0.35, 0.4…1.25) jetzt auch für die Quadrate, dazu `gripCrowdK` (eng liegende Griffe kleiner, bis 40 %), `planView/constants.ts`, `PlanView.tsx`. Offen: nicht auf dem Mac geprüft. · S diff --git a/e2e/sectionPick317.spec.ts b/e2e/sectionPick317.spec.ts new file mode 100644 index 00000000..351eaf57 --- /dev/null +++ b/e2e/sectionPick317.spec.ts @@ -0,0 +1,152 @@ +// [317] Anwählen in Schnitt- und Ansichts-Reitern: jedes Bauteil, das ein Primitiv mit Pick-Id trägt, lässt sich an +// einer Stelle, die kein anderes Bauteil überdeckt, per Klick anwählen (Selection enthält es danach). Die Klickpunkte +// kommen aus dem gezeigten Plan (Test-Naht `viewPickPoints`, [317]); Bildschirmpunkte über die viewBox des SVG-Overlays. +// Eigener Port: E2E_PORT=5192 npx playwright test e2e/sectionPick317.spec.ts +import { writeFileSync } from "node:fs"; +import type { Page } from "@playwright/test"; +import { blurFocus, discardIfAsked, expect, fileMenu, showSnapshot, test } from "./app"; +import type {} from "../src/state/testHooks"; + +test.use({ viewport: { width: 1600, height: 1000 } }); + +const SEL_KIND: Record = { + wallId: "walls", ceilingId: "ceilings", openingId: "openings", stairId: "stairs", roofId: "roofs", columnId: "columns", + extrudedSolidId: "solids", drawingId: "drawings", roomId: "rooms", treeId: "trees", railingId: "railings", contextObjectId: "contextObjects", +}; + +async function screenAt(page: Page, x: number, y: number): Promise<{ x: number; y: number }> { + return 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], + ); +} + +async function open(page: Page, menu: RegExp, name: string) { + await page.goto("/?dossierTest"); + await page.getByRole("button", { name: /Neues Projekt/ }).first().click(); + await expect(page.getByRole("group", { name: "Befehlszeile" })).toBeVisible(); + await fileMenu(page, menu); + await discardIfAsked(page); + await expect(page.locator(".project-name")).toContainText(name, { timeout: 30_000 }); +} + +/** Alle Klickpunkte des gezeigten Plans anklicken; liefert die Fehlschläge (`key:id`) und die Zahl der Prüfungen. */ +async function clickAll(page: Page, only?: (key: string) => boolean): Promise<{ failed: string[]; checked: number; covered: string[]; unknown: string[] }> { + await expect(page.locator("svg.plan-svg").first()).toBeVisible({ timeout: 30_000 }); + await expect.poll(() => page.evaluate(() => window.__dossierTest!.viewPickPoints().length), { timeout: 30_000 }).toBeGreaterThan(0); + await page.waitForTimeout(800); + const pts = await page.evaluate(() => window.__dossierTest!.viewPickPoints()); + const failed: string[] = []; + const covered: string[] = []; + const unknown: string[] = []; + let checked = 0; + for (const p of pts) { + if (!p.known) unknown.push(`${p.key}:${p.id}`); + if (p.covered) { covered.push(`${p.key}:${p.id}`); continue; } + if (p.key === "roomId" || (only && !only(p.key))) continue; + const kind = SEL_KIND[p.key]; + await blurFocus(page); + await page.keyboard.press("Escape"); + const s = await screenAt(page, p.x, p.y); + const box = (await page.locator("svg.plan-svg").first().boundingBox())!; + if (s.x < box.x + 2 || s.x > box.x + box.width - 2 || s.y < box.y + 2 || s.y > box.y + box.height - 2) continue; // ausserhalb des Bildausschnitts + await page.mouse.click(s.x, s.y); + // Die Auswahl kann dem Klick um einen Frame hinterherhinken: bis zu 1.5 s warten, dann gilt das Ergebnis. + let sel: Record = {}; + for (let i = 0; i < 15; i++) { + sel = await page.evaluate(() => JSON.parse(window.__dossierTest!.selected().all) as Record); + if (sel[kind]?.includes(p.id)) break; + await page.waitForTimeout(100); + } + checked++; + if (!sel[kind]?.includes(p.id)) failed.push(`${p.key}:${p.id} -> ${JSON.stringify(Object.fromEntries(Object.entries(sel).filter(([, v]) => v.length)))}`); + await page.waitForTimeout(450); // kein Doppelklick + } + return { failed, checked, covered, unknown }; +} + +test("Schnitt und Ansicht: jedes Bauteil ist per Klick anwählbar, Pick-Ids gehören zu echten Elementen", async ({ page }) => { + test.setTimeout(300_000); + await open(page, /Musterhaus \(komplex\)/, "Musterhaus komplex"); + for (const n of ["Schnitt A-A", "Schnitt B-B", "Ansicht Süd"]) { + await showSnapshot(page, n); + const r = await clickAll(page); + expect(r.checked, n).toBeGreaterThan(8); + expect(r.unknown, `${n}: Pick-Id ohne Element`).toEqual([]); + expect(r.failed, n).toEqual([]); + } + // Nach Zoom und Verschieben trifft der Klick weiter (Pick rechnet in Modellkoordinaten). + const box = (await page.locator("svg.plan-svg").first().boundingBox())!; + await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2); + await page.mouse.wheel(0, -300); + await page.waitForTimeout(500); + const r = await clickAll(page); + expect(r.checked, "nach Zoom").toBeGreaterThan(3); + expect(r.failed, "nach Zoom").toEqual([]); +}); + +test("Wettbewerb: Schnitt A-A — Treppe, Decke, Wand, Dach, Zeichnung (Entourage) anwählbar", async ({ page }) => { + test.setTimeout(300_000); + await open(page, /^Neu aus Vorlage: Wettbewerb$/, "Wettbewerb"); + await showSnapshot(page, "Schnitt A-A"); + const r = await clickAll(page); + expect(r.checked).toBeGreaterThan(8); + expect(r.unknown).toEqual([]); + expect(r.failed).toEqual([]); +}); + +test("Träger im Schnitt: Klick wählt Stütze/Träger, nicht eine Decke gleicher Id", async ({ page }) => { + test.setTimeout(300_000); + await open(page, /Musterhaus \(komplex\)/, "Musterhaus komplex"); + await showSnapshot(page, "Schnitt A-A"); + await expect.poll(() => page.evaluate(() => window.__dossierTest!.viewPickPoints().some((p) => p.key === "columnId" && p.id === "tg-eg-1")), { timeout: 30_000 }).toBe(true); + const p = (await page.evaluate(() => window.__dossierTest!.viewPickPoints())).find((q) => q.key === "columnId" && q.id === "tg-eg-1")!; + expect(p.known).toBe(true); + await blurFocus(page); + const s = await screenAt(page, p.x, p.y); + await page.mouse.click(s.x, s.y); + const sel = await page.evaluate(() => JSON.parse(window.__dossierTest!.selected().all) as Record); + expect(sel.columns).toContain("tg-eg-1"); + expect(sel.ceilings).toEqual([]); +}); + +test("Rahmen im Schnitt/in der Ansicht wählt Stützen, Dächer und Fenster mit", async ({ page }) => { + test.setTimeout(300_000); + await open(page, /Musterhaus \(komplex\)/, "Musterhaus komplex"); + await showSnapshot(page, "Ansicht Süd"); + await expect.poll(() => page.evaluate(() => window.__dossierTest!.viewPickPoints().length), { timeout: 30_000 }).toBeGreaterThan(0); + await page.waitForTimeout(800); + const box = (await page.locator("svg.plan-svg").first().boundingBox())!; + // Von rechts unten nach links oben (berührende Bauteile zählen), über die ganze Zeichenfläche. + await page.mouse.move(box.x + box.width - 4, box.y + box.height - 4); + await page.mouse.down(); + await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2, { steps: 6 }); + await page.mouse.move(box.x + 4, box.y + 4, { steps: 6 }); + await page.mouse.up(); + const sel = await page.evaluate(() => JSON.parse(window.__dossierTest!.selected().all) as Record); + expect(sel.walls.length).toBeGreaterThan(0); + expect(sel.columns.length).toBeGreaterThan(0); + expect(sel.roofs.length).toBeGreaterThan(0); + expect(sel.openings.length).toBeGreaterThan(0); +}); + +test.describe("Erkundung", () => { + test.skip(!process.env.SURVEY317, "schreibt /tmp/a317/pick.json"); + test("Anwahl je Bauteil in Schnitt und Ansicht", async ({ page }) => { + test.setTimeout(1_200_000); + const res: Record = {}; + await open(page, /Musterhaus \(komplex\)/, "Musterhaus komplex"); + for (const n of ["Schnitt A-A", "Schnitt B-B", "Ansicht Süd", "Ansicht Ost"]) { + await showSnapshot(page, n); + res[`komplex ${n}`] = await clickAll(page); + writeFileSync("/tmp/a317/pick.json", JSON.stringify(res, null, 1)); + } + }); +}); diff --git a/src-tauri/core/src/plan/elevation/mod.rs b/src-tauri/core/src/plan/elevation/mod.rs index e2b9776f..8c9c1657 100644 --- a/src-tauri/core/src/plan/elevation/mod.rs +++ b/src-tauri/core/src/plan/elevation/mod.rs @@ -526,6 +526,7 @@ pub fn elevation_primitives_ren(p: &Project, level: &LevelSpec, shadows: bool, m let nb = crate::roof_assembly::neighbors_rc(p); let assembled: std::collections::HashSet<&str> = p.roofs.as_deref().unwrap_or(&[]).iter().enumerate().filter(|(i, _)| crate::roof_assembly::is_assembled_with(p, *i, &nb)).map(|(_, r)| r.id.as_str()).collect(); + let stair_ids: std::collections::HashSet<&str> = p.stairs.as_deref().unwrap_or(&[]).iter().map(|s| s.id.as_str()).collect(); let needed = mesh_faces_needed(&faces); // [G4] Füllungen aus der exakten Sichtbarkeit: je Fläche die sichtbaren Teile (wie die Kanten), damit keine // Füllung über einer verdeckten Kante liegt (Maler-Reihenfolge nach Mitteltiefe irrte bei Gauben, die vor der @@ -557,11 +558,13 @@ pub fn elevation_primitives_ren(p: &Project, level: &LevelSpec, shadows: bool, m if let (true, Primitive::Polygon { opacity, .. }) = (f.see_through, &mut prim) { *opacity = Some(GLASS_OPACITY); } - if let Primitive::Polygon { greyed: g, wall_id, ceiling_id, roof_id, column_id, context_object_id, extruded_solid_id, .. } = &mut prim { + if let Primitive::Polygon { greyed: g, wall_id, ceiling_id, stair_id, roof_id, column_id, context_object_id, extruded_solid_id, .. } = &mut prim { *g = Some(greyed(f)); if !f.id.is_empty() { match f.role { Role::Wall => *wall_id = Some(f.id.clone()), + // [317] Treppen laufen als Platten-Flächen durch die Ansicht; ihre Pick-Id ist die Treppe, nicht eine Decke. + Role::Slab if stair_ids.contains(f.id.as_str()) => *stair_id = Some(f.id.clone()), Role::Slab => *ceiling_id = Some(f.id.clone()), Role::Roof => *roof_id = Some(f.id.clone()), Role::Column => *column_id = Some(f.id.clone()), diff --git a/src-tauri/core/src/plan/elevation/tests.rs b/src-tauri/core/src/plan/elevation/tests.rs index 0c9f96b2..7a732412 100644 --- a/src-tauri/core/src/plan/elevation/tests.rs +++ b/src-tauri/core/src/plan/elevation/tests.rs @@ -1450,3 +1450,26 @@ fn materialfuge_an_der_geschossgrenze() { let len: f64 = s.iter().map(|(a, b)| (b.x - a.x).abs()).sum(); assert!(len > 4.0, "Materialfuge fehlt: {s:?}"); } + +/// [317] Treppen in der Ansicht tragen die Pick-Id der Treppe (`stairId`), nicht die einer Decke: sonst wählt der +/// Klick eine nicht vorhandene Decke, und die Treppe bleibt unwählbar. +#[test] +fn treppe_in_der_ansicht_traegt_stair_id() { + let p = sample(); + assert!(p.stairs.as_deref().is_some_and(|s| !s.is_empty()), "Beispielprojekt ohne Treppe"); + let ceilings: HashSet = p.ceilings.as_deref().unwrap_or(&[]).iter().map(|c| c.id.clone()).collect(); + let mut stairs_seen = HashSet::new(); + for l in p.drawing_levels.iter().filter(|l| l.id.starts_with("ansicht")) { + let level = LevelSpec::from_json(&serde_json::to_value(l).unwrap()); + let Some((prims, _)) = elevation_primitives(&p, &level, true, false, &Visibility::default(), 100.0).unwrap() else { continue }; + for q in &prims { + if let Primitive::Polygon { ceiling_id: Some(c), .. } = q { + assert!(ceilings.contains(c), "{c} ist keine Decke ({})", l.id); + } + if let Primitive::Polygon { stair_id: Some(s), .. } = q { + stairs_seen.insert(s.clone()); + } + } + } + assert!(!stairs_seen.is_empty(), "keine Treppe mit stairId in den Ansichten"); +} diff --git a/src-tauri/core/src/plan/section/bands.rs b/src-tauri/core/src/plan/section/bands.rs index 80aefe0a..132abf94 100644 --- a/src-tauri/core/src/plan/section/bands.rs +++ b/src-tauri/core/src/plan/section/bands.rs @@ -699,6 +699,7 @@ pub(super) fn attach_cut_styles(cuts: Vec, p: &Project, plane: &Plane, wall _ => unreachable!(), }; cp.source_id = Some(id.clone()); + cp.column_id = Some(id.clone()); cp.category = Some(code.clone()); let comp = component_id.as_deref().filter(|s| !s.is_empty()).and_then(|id| p.component(id)); if let Some(k) = comp { @@ -876,6 +877,7 @@ pub(super) fn subtract_dominant_bands(bands: Vec) -> Vec { // Herkunft bleibt am Stück (Ebenen-Sichtbarkeit, Treppen-Pick). c.category = src.category.clone(); c.stair_id = src.stair_id.clone(); + c.column_id = src.column_id.clone(); c.layer_index = src.layer_index; c }) diff --git a/src-tauri/core/src/plan/section/mod.rs b/src-tauri/core/src/plan/section/mod.rs index 890f21b8..3e0bf793 100644 --- a/src-tauri/core/src/plan/section/mod.rs +++ b/src-tauri/core/src/plan/section/mod.rs @@ -255,6 +255,8 @@ pub struct Cut { pub stair_id: Option, /// [279] Geländer, zu dem das Band gehört (Pick `@railing:`). pub railing_id: Option, + /// [317] Stütze oder Träger, zu dem das Band gehört (Pick `columnId`; vorher fälschlich als Decke). + pub column_id: Option, /// [33] Index der Schicht im Aufbau des Bauteils (Wand-, Decken-, Dachtyp), wo bekannt. pub layer_index: Option, /// [33] Override der Schicht (nur beim Zeichnen gesetzt, [`cut_overrides`]). @@ -263,7 +265,7 @@ pub struct Cut { impl Cut { pub(crate) fn new(kind: Kind, index: usize, pts: Vec<[f64; 2]>) -> Cut { - Cut { kind, index, pts, nse: None, fill: None, hatch: None, join_priority: None, component_id: None, source_id: None, category: None, stair_id: None, railing_id: None, layer_index: None, ov: None } + Cut { kind, index, pts, nse: None, fill: None, hatch: None, join_priority: None, component_id: None, source_id: None, category: None, stair_id: None, railing_id: None, column_id: None, layer_index: None, ov: None } } } diff --git a/src-tauri/core/src/plan/section/primitives.rs b/src-tauri/core/src/plan/section/primitives.rs index e6bfd5f7..dac36624 100644 --- a/src-tauri/core/src/plan/section/primitives.rs +++ b/src-tauri/core/src/plan/section/primitives.rs @@ -552,17 +552,18 @@ pub fn section_primitives_mv(out: &Output, mono: bool, hidden_lines: bool, vis: _ if stroked && dash.is_none() => polygon(pts, &fill, SECTION_INK, SECTION_JOINT_MM, hatch), _ => polygon(pts, &fill, "none", 0.0, hatch), }; - if let Primitive::Polygon { wall_id, ceiling_id, roof_id, stair_id, extruded_solid_id, no_stroke_edges, greyed, context_object_id, .. } = &mut pr { + if let Primitive::Polygon { wall_id, ceiling_id, roof_id, stair_id, column_id, extruded_solid_id, no_stroke_edges, greyed, context_object_id, .. } = &mut pr { // [152] Importiertes Netz: Pick über die Kontext-Id. *context_object_id = if cp.kind == Kind::Mesh { src.clone() } else { None }; *wall_id = if cp.kind == Kind::Wall { src.clone() } else { None }; - *ceiling_id = if cp.kind == Kind::Slab && cp.stair_id.is_none() && cp.railing_id.is_none() { src.clone() } else { None }; + *ceiling_id = if cp.kind == Kind::Slab && cp.stair_id.is_none() && cp.railing_id.is_none() && cp.column_id.is_none() { src.clone() } else { None }; // [279] Geländer: Pick über die Kontext-Id `@railing:`. if let Some(r) = &cp.railing_id { *context_object_id = Some(crate::plan::railings::pick_id(r)); } *roof_id = if cp.kind == Kind::Roof { src.clone() } else { None }; *stair_id = cp.stair_id.clone(); + *column_id = cp.column_id.clone(); *extruded_solid_id = if cp.kind == Kind::Body { src } else { None }; *no_stroke_edges = cp.nse.clone(); *greyed = Some(cp.category.as_deref().is_some_and(|c| vis.greyed(c))); diff --git a/src-tauri/core/src/plan/section/tests.rs b/src-tauri/core/src/plan/section/tests.rs index 8db93586..7cc1c5f6 100644 --- a/src-tauri/core/src/plan/section/tests.rs +++ b/src-tauri/core/src/plan/section/tests.rs @@ -443,6 +443,22 @@ fn beispiel_schnitt_mit_pick_ids() { assert!(!serde_json::to_string(&hidden).unwrap().contains("\"roofId\"")); } +/// [317] Geschnittene Stütze trägt im Schnitt die Pick-Id `columnId` (vorher `ceilingId` mit der Stützen-Id: Klick +/// wählte eine nicht vorhandene Decke, die Stütze blieb unwählbar). +#[test] +fn geschnittene_stuetze_traegt_column_id() { + let mut p = sample(); + p.columns = Some(serde_json::from_value(serde_json::json!([ + {"id": "C1", "type": "column", "floorId": "eg", "categoryCode": "25", "position": {"x": 20.0, "y": 1.0}, "profile": {"kind": "rect", "width": 0.4, "depth": 0.4}, "rotation": 0, "height": 2.5} + ])).unwrap()); + let l = LevelSpec { kind: "section".into(), line: Some([Vec2 { x: 19.0, y: 1.0 }, Vec2 { x: 21.0, y: 1.0 }]), ..Default::default() }; + let out = compute_section(&p, &l, &[]).unwrap().unwrap(); + let (prims, _) = section_primitives(&out, false, false, &Visibility::default()); + let col: Vec<_> = prims.iter().filter(|q| matches!(q, Primitive::Polygon { column_id: Some(c), .. } if c == "C1")).collect(); + assert!(!col.is_empty(), "Stütze nicht als columnId im Schnitt"); + assert!(col.iter().all(|q| matches!(q, Primitive::Polygon { ceiling_id: None, .. }))); +} + /// [94] Sturz, Fensterbänke und Storenkasten im Sturz erscheinen im Schnitt nur, wenn gesetzt. #[test] fn sturz_baenke_und_storenkasten_im_schnitt() { diff --git a/src/plan/pickIds317.test.ts b/src/plan/pickIds317.test.ts new file mode 100644 index 00000000..f7e32b92 --- /dev/null +++ b/src/plan/pickIds317.test.ts @@ -0,0 +1,66 @@ +// [317] Pick-Ids in Schnitt und Ansicht: jede Id, die ein Plan-Primitiv trägt, muss zur Art passen — `ceilingId` eine +// Decke, `stairId` eine Treppe, `columnId` eine Stütze oder ein Träger usw. Sonst wählt der Klick ein Element, das +// es nicht gibt (Treppe in der Ansicht, Stütze/Träger im Schnitt liefen früher als `ceilingId`). +import { describe, expect, it } from "vitest"; +import { computeSection, generateElevationPlan, generateSectionPlan } from "../core"; +import type { Project } from "../model/types"; +import { sampleProject } from "../model/sampleProject"; +import { buildComplexSampleProject } from "../model/sampleProjectComplex"; +import { buildUmbauSampleProject } from "../model/sampleProjectUmbau"; +import { buildWettbewerbSampleProject } from "../model/sampleProjectWettbewerb"; + +type Lists = Record; +const LIST: Record = { + wallId: ["walls"], + ceilingId: ["ceilings"], + openingId: ["openings"], + stairId: ["stairs"], + roofId: ["roofs"], + columnId: ["columns", "beams"], + extrudedSolidId: ["extrudedSolids"], + drawingId: ["drawings2d"], + roomId: ["rooms"], +}; + +function badIds(p: Project, prims: readonly unknown[]): string[] { + const lists = p as unknown as Lists; + const bad = new Set(); + for (const pr of prims as Record[]) { + for (const [key, names] of Object.entries(LIST)) { + const id = pr[key]; + if (typeof id === "string" && !names.some((n) => (lists[n] ?? []).some((e) => e.id === id))) bad.add(`${key}=${id}`); + } + } + return [...bad]; +} + +const PROJECTS: [string, () => Project][] = [ + ["Muster", () => sampleProject], + ["komplex", buildComplexSampleProject], + ["Wettbewerb", buildWettbewerbSampleProject], + ["Umbau", buildUmbauSampleProject], +]; + +describe("Pick-Ids in Schnitt und Ansicht gehören zur richtigen Art", () => { + for (const [name, make] of PROJECTS) { + it(name, async () => { + const p = make(); + let stairIds = 0; + let columnIds = 0; + for (const l of p.drawingLevels.filter((x) => x.kind === "section" || x.kind === "elevation")) { + const plan = + l.kind === "section" + ? generateSectionPlan((await computeSection(p, l))!, false, { openings: true, scaleDenominator: 100 }) + : generateElevationPlan(p, l, { scaleDenominator: 100 })!; + expect(badIds(p, plan.primitives), `${name} ${l.id}`).toEqual([]); + for (const pr of plan.primitives as unknown as Record[]) { + if (pr.stairId) stairIds++; + if (pr.columnId) columnIds++; + } + } + // Die Beispiele zeigen Treppen bzw. Stützen/Träger tatsächlich (sonst prüft der Test nichts). + if (name === "Muster" || name === "Umbau") expect(stairIds).toBeGreaterThan(0); + if (name === "komplex") expect(columnIds).toBeGreaterThan(0); + }, 120_000); + } +}); diff --git a/src/plan/planView/planPick.ts b/src/plan/planView/planPick.ts index 83d706d2..026d67cc 100644 --- a/src/plan/planView/planPick.ts +++ b/src/plan/planView/planPick.ts @@ -191,7 +191,7 @@ export class PlanPickIndex { * Rahmen-Auswahl über Polygone mit Id im Feld `field` (CAD-Konvention): `crossing` = ein Band * berührt das Rechteck, sonst liegen alle Bänder ganz darin. Ids in Auftreten-Reihenfolge. */ - marquee(field: "wallId" | "ceilingId" | "roomId" | "stairId" | "columnId" | "roofId" | "contextObjectId", rect: ModelRect, crossing: boolean): string[] { + marquee(field: "wallId" | "ceilingId" | "roomId" | "stairId" | "columnId" | "roofId" | "openingId" | "extrudedSolidId" | "contextObjectId", rect: ModelRect, crossing: boolean): string[] { const r = Float64Array.of(rect.minX, rect.minY, rect.maxX, rect.maxY); return splitIds(core().pick_marquee_polygons(this.ix(), KIND[field], r, crossing)); } diff --git a/src/state/testHooks.ts b/src/state/testHooks.ts index c6bc6aae..a3ae6e2b 100644 --- a/src/state/testHooks.ts +++ b/src/state/testHooks.ts @@ -18,6 +18,7 @@ import { BUILTIN_PANEL_IDS } from "../panels/builtinPanels"; import { hiddenFloorIds, itemDisplay } from "../panels/displayMode"; import { renderJob } from "./renderJob"; import { CyclesCancelled } from "../core"; +import type { Plan } from "../core"; declare global { interface Window { @@ -49,6 +50,10 @@ declare global { contours: { id: string; zs: number[] }[]; excavations: { id: string; bottom: number }[]; }; + /** [317] Klickpunkte der Bauteile des gezeigten Plans (Schnitt/Ansicht): je Pick-Id ein Modellpunkt, an dem nur dieses Bauteil liegt. */ + viewPickPoints: () => { key: string; id: string; x: number; y: number; covered: boolean; /** Gibt es das Element mit dieser Id im Projekt? */ known: boolean }[]; + /** [317] Pick-Polygone des gezeigten Plans an einem Modellpunkt (Index in `primitives`, Art, Id), unterste zuerst. */ + viewPolysAt: (x: number, y: number) => string[]; /** [144] Auswahl setzen (wie ein Klick), z. B. `{ openings: ["D1"] }`. */ select: (patch: Record) => void; /** [144] Punkte einer Bemassung (Kette) — folgt sie der Öffnung? */ @@ -115,7 +120,77 @@ declare global { } } +// [317] Der Plan, den die Plan-Ansicht gerade zeigt (`PlanView` meldet ihn über `__dossierPlanProbe`). +let lastPlan: Plan | null = null; + +const PICK_KEYS = ["wallId", "ceilingId", "openingId", "stairId", "roofId", "columnId", "extrudedSolidId", "drawingId", "roomId"] as const; + +/** [317] Pro Pick-Id ein Punkt in der Fläche, den kein anderes Bauteil-Polygon (mit Id) überdeckt. */ +const KEY_LIST: Record = { wallId: "walls", ceilingId: "ceilings", openingId: "openings", stairId: "stairs", roofId: "roofs", columnId: "columns", extrudedSolidId: "extrudedSolids", drawingId: "drawings2d", roomId: "rooms", treeId: "trees", railingId: "railings", contextObjectId: "context" }; + +function pickPoints(plan: Plan): { key: string; id: string; x: number; y: number; covered: boolean; known: boolean }[] { + type Poly = { key: string; id: string; pts: { x: number; y: number }[] }; + const project = getState().project as unknown as Record; + const known = (key: string, id: string): boolean => { + const list = project[KEY_LIST[key]] ?? []; + return list.some((e) => e.id === id) || (key === "columnId" && (project.beams ?? []).some((e) => e.id === id)) || (key === "contextObjectId" && id.startsWith("@")); + }; + const polys: Poly[] = []; + for (const pr of plan.primitives) { + if (pr.kind !== "polygon" || pr.pts.length < 3) continue; + const o = pr as unknown as Record; + let key: string | null = null; + let id: string | undefined; + for (const k of PICK_KEYS) if (o[k]) { key = k; id = o[k]; break; } + const c = o.contextObjectId; + if (!key && c) { key = c.startsWith("@tree:") ? "treeId" : c.startsWith("@railing:") ? "railingId" : c.startsWith("@") ? null : "contextObjectId"; id = c.replace(/^@(tree|railing):/, ""); } + if (key && id) polys.push({ key, id, pts: pr.pts }); + } + const inside = (q: { x: number; y: number }, pts: { x: number; y: number }[]) => { + let r = false; + for (let i = 0, j = pts.length - 1; i < pts.length; j = i++) { + if (pts[i].y > q.y !== pts[j].y > q.y && q.x < ((pts[j].x - pts[i].x) * (q.y - pts[i].y)) / (pts[j].y - pts[i].y) + pts[i].x) r = !r; + } + return r; + }; + const out = new Map(); + for (const [pi, pg] of polys.entries()) { + const k = `${pg.key}:${pg.id}`; + if (out.get(k) && !out.get(k)!.covered) continue; + const xs = pg.pts.map((q) => q.x), ys = pg.pts.map((q) => q.y); + const [x0, x1, y0, y1] = [Math.min(...xs), Math.max(...xs), Math.min(...ys), Math.max(...ys)]; + let found: { x: number; y: number } | null = null; + let any: { x: number; y: number } | null = null; + let foundD = -1; + let anyD = -1; + // Rand-Abstand: der Punkt mit dem grössten Abstand zur Umrisslinie (Bildschirm-Rundung soll ihn nicht kippen). + const edgeDist = (q: { x: number; y: number }) => { + let d = Infinity; + for (let i = 0, j = pg.pts.length - 1; i < pg.pts.length; j = i++) { + const a = pg.pts[j], b = pg.pts[i]; + const dx = b.x - a.x, dy = b.y - a.y; + const l2 = dx * dx + dy * dy; + const t = l2 === 0 ? 0 : Math.max(0, Math.min(1, ((q.x - a.x) * dx + (q.y - a.y) * dy) / l2)); + d = Math.min(d, Math.hypot(q.x - (a.x + t * dx), q.y - (a.y + t * dy))); + } + return d; + }; + const N = 13; + for (let i = 1; i < N; i++) for (let j = 1; j < N; j++) { + const q = { x: x0 + ((x1 - x0) * i) / N, y: y0 + ((y1 - y0) * j) / N }; + if (!inside(q, pg.pts)) continue; + const d = edgeDist(q); + if (d > anyD) { any = q; anyD = d; } + if (d > foundD && !polys.some((o2, oi) => oi > pi && (o2.key !== pg.key || o2.id !== pg.id) && o2.key !== "contextObjectId" && inside(q, o2.pts))) { found = q; foundD = d; } + } + if (found) out.set(k, { key: pg.key, id: pg.id, ...found, covered: false, known: known(pg.key, pg.id) }); + else if (any && !out.has(k)) out.set(k, { key: pg.key, id: pg.id, ...any, covered: true, known: known(pg.key, pg.id) }); + } + return [...out.values()]; +} + export function installTestHooks(): void { + (window as unknown as { __dossierPlanProbe?: (p: Plan) => void }).__dossierPlanProbe = (p) => { lastPlan = p; }; window.__dossierTest = { corePanic: () => { try { @@ -158,6 +233,24 @@ export function installTestHooks(): void { selectionAction: (id) => runSelectionAction(id), walls: () => getState().project.walls.map((w) => ({ id: w.id, start: { ...w.start }, end: { ...w.end } })), select: (patch) => getState().setSelection(patch), + viewPickPoints: () => (lastPlan ? pickPoints(lastPlan) : []), + viewPolysAt: (x, y) => { + if (!lastPlan) return []; + const q = { x, y }; + const inside = (pts: { x: number; y: number }[]) => { + let r = false; + for (let i = 0, j = pts.length - 1; i < pts.length; j = i++) if (pts[i].y > q.y !== pts[j].y > q.y && q.x < ((pts[j].x - pts[i].x) * (q.y - pts[i].y)) / (pts[j].y - pts[i].y) + pts[i].x) r = !r; + return r; + }; + const out: string[] = []; + lastPlan.primitives.forEach((pr, i) => { + if (pr.kind !== "polygon" || !inside(pr.pts)) return; + const o = pr as unknown as Record; + const key = [...PICK_KEYS, "contextObjectId"].find((k) => o[k]); + out.push(`${i}:${key ?? "-"}:${key ? o[key] : ""}`); + }); + return out; + }, dimPts: (id) => { const g = getState().project.drawings2d.find((d) => d.id === id)?.geom; return g?.shape === "dimension" ? g.pts.map((p) => ({ x: p.x, y: p.y })) : []; diff --git a/src/state/useMouseSelectionHandlers.ts b/src/state/useMouseSelectionHandlers.ts index 9546bbd3..6ca62d52 100644 --- a/src/state/useMouseSelectionHandlers.ts +++ b/src/state/useMouseSelectionHandlers.ts @@ -331,9 +331,9 @@ export function useMouseSelectionHandlers(opts: { ceilingIds: sel.ceilingIds ?? [], roomIds: sel.roomIds ?? [], stairIds: sel.stairIds ?? [], - columnIds: [], - roofIds: [], - openingIds: [], + columnIds: sel.columnIds ?? [], + roofIds: sel.roofIds ?? [], + openingIds: sel.openingIds ?? [], treeIds: sel.treeIds ?? [], cameraIds: sel.cameraIds ?? [], railingIds: sel.railingIds ?? [], @@ -349,9 +349,9 @@ export function useMouseSelectionHandlers(opts: { ceilingIds: raw.ceilingIds.filter((id) => isInsideActiveGroup(project, "ceilingIds", id, groupPath)), roomIds: raw.roomIds.filter((id) => isInsideActiveGroup(project, "roomIds", id, groupPath)), stairIds: raw.stairIds.filter((id) => isInsideActiveGroup(project, "stairIds", id, groupPath)), - columnIds: [], - roofIds: [], - openingIds: [], + columnIds: raw.columnIds.filter((id) => isInsideActiveGroup(project, "columnIds", id, groupPath)), + roofIds: raw.roofIds.filter((id) => isInsideActiveGroup(project, "roofIds", id, groupPath)), + openingIds: raw.openingIds.filter((id) => isInsideActiveGroup(project, "openingIds", id, groupPath)), treeIds: raw.treeIds.filter((id) => isInsideActiveGroup(project, "treeIds", id, groupPath)), cameraIds: raw.cameraIds.filter((id) => isInsideActiveGroup(project, "cameraIds", id, groupPath)), railingIds: raw.railingIds.filter((id) => isInsideActiveGroup(project, "railingIds", id, groupPath)), @@ -359,12 +359,14 @@ export function useMouseSelectionHandlers(opts: { // Gruppen-Erweiterung: jedes getroffene Element, das zu einer sichtbaren // Gruppe gehört, zieht deren ganze (transitive) Mitgliedschaft nach. const { expanded, groupIds } = expandToGroups(project, filtered, groupPath); - // Öffnungen/Extrusionen/Stützen/Dächer/Kontext-Objekte sind (noch) nicht - // Teil des Marquee (Nutzer-Report betraf nur Decken/Räume/Treppen; Stütze/ - // Dach liessen sich mit derselben `marqueeHitByField`-Mechanik ergänzen, - // falls gewünscht) → beim Aufziehen abwählen. + // Stützen/Dächer/Öffnungen/Körper nur im Schnitt und in der Ansicht ([317], `sheetBodies`); im Grundriss + // (Dach deckt die ganze Traufe, Fenster hängen an ihrer Wand) bleiben sie ausserhalb des Rahmens. setSelection({ ...clearKinds(), + columns: expanded.columnIds, + roofs: expanded.roofIds, + openings: expanded.openingIds, + solids: sel.solidIds ?? [], walls: expanded.wallIds, drawings: expanded.drawingIds, ceilings: expanded.ceilingIds, diff --git a/src/views/plan/PlanView.tsx b/src/views/plan/PlanView.tsx index 5d9b91db..a5e7fe60 100644 --- a/src/views/plan/PlanView.tsx +++ b/src/views/plan/PlanView.tsx @@ -278,6 +278,10 @@ export const PlanView = forwardRef( startViewRef, // [204] Papier-Massstab folgt der Startansicht resetKey: viewKey, // Papier-Massstab folgt dem Einpassen }); + // [317] Test-Naht: der gezeigte Plan für die e2e-Prüfung der Anwahl (nur mit `?dossierTest`, sonst fehlt die Funktion). + useEffect(() => { + (window as unknown as { __dossierPlanProbe?: (p: typeof plan) => void }).__dossierPlanProbe?.(plan); + }, [plan]); // [165] Steuerhandle, Zieh-Zustände, Koordinaten-Umrechnung und Griff-Treffer. const { drag, @@ -515,6 +519,7 @@ export const PlanView = forwardRef( toolMods, marquee, onMarquee, + sheetBodies, marqueeHitAll, setMarqueeRect, drag, diff --git a/src/views/plan/planView/types.ts b/src/views/plan/planView/types.ts index c5752ab1..5c7fcad1 100644 --- a/src/views/plan/planView/types.ts +++ b/src/views/plan/planView/types.ts @@ -191,6 +191,11 @@ export interface MarqueeSelection { treeIds?: string[]; /** [279] Getroffene Geländer (Pick-Flächen um die Achse, gleiche Konvention). */ railingIds?: string[]; + /** [317] Nur im Schnitt/in der Ansicht (`sheetBodies`): Stützen/Träger, Dächer, Öffnungen, Körper (gleiche Konvention). */ + columnIds?: string[]; + roofIds?: string[]; + openingIds?: string[]; + solidIds?: string[]; /** [213] Getroffene Kameras (Pick-Flächen von Gehäuse und Sichtgrenzen, gleiche Konvention). */ cameraIds?: string[]; /** diff --git a/src/views/plan/planView/usePlanPickCycle.ts b/src/views/plan/planView/usePlanPickCycle.ts index 8a6deb29..8f2dde12 100644 --- a/src/views/plan/planView/usePlanPickCycle.ts +++ b/src/views/plan/planView/usePlanPickCycle.ts @@ -71,6 +71,8 @@ export interface UsePlanPickCycleArgs { toolMods: (e: React.PointerEvent | React.MouseEvent) => { shift: boolean; ctrl: boolean; alt: boolean; }; marquee: React.MutableRefObject<{ pointerId: number; startClientX: number; startClientY: number; startView: Vec2; moved: boolean; } | null>; onMarquee: ((selection: MarqueeSelection) => void) | undefined; + /** [317] Schnitt/Ansicht: Rahmen wählt auch Stützen, Dächer, Öffnungen und Körper. */ + sheetBodies?: boolean; marqueeHitAll: (rect: ModelRect, crossing: boolean) => string[]; setMarqueeRect: React.Dispatch>; drag: React.MutableRefObject<{ pointerId: number; startClientX: number; startClientY: number; startView: ViewBox; } | null>; @@ -127,6 +129,7 @@ export function usePlanPickCycle(inp: UsePlanPickCycleArgs) { toolMods, marquee, onMarquee, + sheetBodies, marqueeHitAll, setMarqueeRect, drag, @@ -572,6 +575,15 @@ export function usePlanPickCycle(inp: UsePlanPickCycleArgs) { .map((id) => id.slice(CAMERA_PICK.length)), ), ], + // [317] Schnitt/Ansicht: auch Stützen/Träger, Dächer, Fenster/Türen und Körper per Rahmen. + ...(sheetBodies + ? { + columnIds: getPick().marquee("columnId", rect, crossing), + roofIds: getPick().marquee("roofId", rect, crossing), + openingIds: getPick().marquee("openingId", rect, crossing), + solidIds: getPick().marquee("extrudedSolidId", rect, crossing), + } + : {}), crossing, }); }