From 39fe982057048bd2895c53d8302f42a4e8661528 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 12 Nov 2026 04:50:35 +0000 Subject: [PATCH] =?UTF-8?q?[193]=20Gel=C3=A4nde:=20H=C3=B6henlinien-Punkt?= =?UTF-8?q?=20l=C3=B6schen=20(Kontextmen=C3=BC)=20und=20Aufr=C3=A4umen=20b?= =?UTF-8?q?eim=20Zur=C3=BCckziehen;=20Netzpunkte=20als=20Griffe,=20Punkt-H?= =?UTF-8?q?=C3=B6he,=20Netz=20auf=20Parzelle=20zuschneiden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODO.md | 2 +- e2e/contextDrag.spec.ts | 20 ++++++ src-tauri/core/src/cmd_context.rs | 102 +++++++++++++++++++++++++++--- src-tauri/core/src/grips.rs | 91 +++++++++++++++++++++++++- src/geometry/grips.ts | 2 + src/i18n/de.ts | 7 ++ src/i18n/en.ts | 7 ++ src/menus/AppContextMenu.tsx | 5 ++ src/menus/contextMenu.tsx | 8 +-- src/panels/ContextObjectProps.tsx | 46 ++++++++++++++ src/state/contextEdit.test.ts | 22 +++++++ src/state/projectSlice.ts | 5 +- src/state/siteSlice.ts | 15 +++++ src/state/useGripEditing.ts | 32 +++++++++- 14 files changed, 347 insertions(+), 17 deletions(-) diff --git a/TODO.md b/TODO.md index 825fc7a6..8f2bd49f 100644 --- a/TODO.md +++ b/TODO.md @@ -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; 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`. **Update 11.11. (Rest):** Höhen-Helfer nach Rust (`cmd_context.rs`: `contextOffset`/`contourZ`, TS-Fassung `contextHeight.ts` gelöscht; Store `offsetContextHeight`/`setContourHeight`); Maus-Ziehen im Plan für gewählte Kontext-Elemente (Baugrube, Höhenlinien, Netze, Bild: Vorschau und Ops aus dem Kern-Transform, Fang auf den ersten Punkt, ein Undo-Schritt, `moveContextBy`); Höhenlinien-Punkte als Griffe (`contourGrip`/`contourInsert` in `grips.rs`, Einfüge-Rauten wie [26], ein Undo-Schritt je Zug; ab 600 Punkten keine Griffe, ab 100 keine Rauten); Entf und Cmd+A auf den Ansichts-Schlagschatten (`viewShadows`) blenden `shadows` der Ansicht aus. e2e `contextDrag.spec.ts`. **Offen:** Gelände-Netz zuschneiden/Punkte editieren; Höhenlinien-Punkt löschen (Kontextmenü); Aufräumen eingefügter Punkte beim Zurückziehen. · 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`. **Update 11.11. (Rest):** Höhen-Helfer nach Rust (`cmd_context.rs`: `contextOffset`/`contourZ`, TS-Fassung `contextHeight.ts` gelöscht; Store `offsetContextHeight`/`setContourHeight`); Maus-Ziehen im Plan für gewählte Kontext-Elemente (Baugrube, Höhenlinien, Netze, Bild: Vorschau und Ops aus dem Kern-Transform, Fang auf den ersten Punkt, ein Undo-Schritt, `moveContextBy`); Höhenlinien-Punkte als Griffe (`contourGrip`/`contourInsert` in `grips.rs`, Einfüge-Rauten wie [26], ein Undo-Schritt je Zug; ab 600 Punkten keine Griffe, ab 100 keine Rauten); Entf und Cmd+A auf den Ansichts-Schlagschatten (`viewShadows`) blenden `shadows` der Ansicht aus. e2e `contextDrag.spec.ts`. **Update 12.11. (Rest):** Höhenlinien-Punkt löschen im Rechtsklick-Menü („Ecke löschen", gleiche Mechanik wie [26]: `ringDelete`/`ringTidy` mit `kind: "contours"`, Kern `grips.rs::contour_ring_edit`, Minimum offen 2 / geschlossen 3); eingefügte oder gezogene Punkte, die auf einem Nachbarn oder der Nachbargeraden landen, entfallen beim Setzen im selben Undo-Schritt. Gelände-Netz (`terrainMesh`/`importedMesh`): Netzpunkte als Griffe im Grundriss (`meshGrip`, bis 600 Punkte, grössere Netze ohne Griffe), Höhe je Netzpunkt in der Objekt-Info (Nummer + Höhe, Befehl `meshPointZ`), Zuschneiden auf die Parzelle (Befehl `meshCrop`, Schwerpunkt-Test, Punkte und `vertexColors` werden bereinigt; Knopf in der Objekt-Info). **Offen:** Netzpunkt-Höhe direkt am Griff wählen (statt Nummer in der Objekt-Info); Zuschneiden auf frei gezeichnetes Rechteck/Polygon (Kern kann Polygon, UI nur Parzelle); Griffe nur im Ausschnitt für grosse Netze; Aufräumen/Löschen einzelner Netzpunkte (Dreiecke neu vernetzen). Nicht in der Tauri-App getestet. · M - ◐ **[198]** T-Stoss: gleiche Schichten verschmelzen (12.11.). Ursache: jede Wand zeichnete ihre Umriss-/Fugenlinie einzeln, am T-Stoss blieb ein Stück Wandumriss der Durchgangswand unter dem Innenputz des Abzweigs (Putz an Putz). Jetzt streicht `plan/seams.rs` nach dem Zeichnen alle Linien/Polygonkanten, die zwei Flächen gleichen Stils (Füllung + Schraffur ohne Ursprung) VERSCHIEDENER Bauteile trennen (Probe beidseits, Linie muss auf dem Rand beider Flächen liegen); Teilstücke werden zu Linien `wall-outline`/`section-joint`. Grundriss (`walls.rs`, Bänder + schwarze Sammelfläche ab 1:100), Schnitt (`section/primitives.rs`, feine Fugen; schwere Schnittkante unberührt) — Bildschirm, Druck, SVG gleich (gleiche Primitive). Materialwechsel und Fugen eigener Schichten einer Wand bleiben. Tests `plan/wall_merge_tests.rs` (T, Ecke, Kreuzung, Gegenprobe, Materialwechsel), `section/tests.rs`; Goldens nachgeführt. Offen: Flächen werden nicht per Boolean vereinigt (Schraffur-Phase je Wand; verschieden orientierte Schraffur gilt als anderer Stil, Linie bleibt); durchlaufende, nicht verbundene Wand durch Wand (Überlappung) unberührt; Ansicht nicht angesehen; nicht in der Tauri-App/auf dem Mac. · M - ◐ **[195b]** Objekteinstellungen als ECHTES Nebenfenster (Wunsch Maintainer, 12.11.). **Stand 12.11.:** Unter Tauri öffnet T (bzw. Menü) das native Fenster `object-settings` (`native/objectSettingsWindow.ts`, Fensterseite `ObjectSettingsWindowApp.tsx`, Protokoll `objectSettingsSync.ts`); Browser/Electron behalten das schwebende Panel. Architektur (schlankste ohne Doppelspur): das Fenster lädt denselben Store als SPIEGEL (Projekt-Leseansicht als Feld-Differenz `projectDelta` + Laden ins eigene Kern-Dokument, Auswahl, aktive Ebene, Wert-Felder des Panel-Hosts, Fokus-Abschnitt von T) und rendert unverändert `ObjectSettingsPanel`; Store-Änderungen dort rechnen ihre Ops auf dem Spiegel und gehen über `state/changeSink.ts` ans Hauptfenster (`applyChange`, Undo je Änderung, `coalesceKey` bleibt), Host-Handler per Proxy (`remoteHost`) ebenso; Cmd+Z/Shift+Cmd+Z im Fenster wirken auf den Verlauf des Hauptfensters, Meldungen erscheinen dort. Auswahlwechsel und Undo im Hauptfenster kommen als Sync (30 ms gebündelt, nur bei offenem Fenster, ohne React-Abo in `App`). Mehrfachwerte: Schraffur (Attribute) und Wandtyp/Dicke („gemischt“), Wandtyp gilt für alle gewählten Wände (ein Schritt). **Stand 12.11. (2):** „gemischt“ auch für Decke (Typ/Dicke/UK/OK), Dach (Typ/Neigung), Öffnung (Typ/Breite/Höhe/Brüstung) und Wand-UK/OK (`mixedValues.ts`, Marke `MixedMark`); die Setter dafür (`elementAttributesHost`, `patchAll`) ändern alle gewählten Elemente gleicher Art in EINEM Undo-Schritt (Dicken per `groupChanges`; Dach nur Typ/Neigung), ein nicht angefasstes gemischtes Feld bleibt unverändert; `deriveSelection` führt bei mehreren Decken/Öffnungen/Dächern mit dem ersten Element (vorher: keine Info, also kein Abschnitt). `OpeningEditorDialog` ist weg: der Editor ist der Abschnitt „Fenster-/Türeditor“ im Bereich „Objekt“ (`panels/objectInfo/OpeningEditor.tsx`, ⚙ klappt ihn auf; Host-Handler `onPatchWindowType/DoorType/onSaveOpeningStyle`; „Als Stil speichern“ mit Eingabezeile statt `window.prompt`); `setOpeningEditorId`/Dialog-State entfernt. **12.11. Ops-Strom:** das Hauptfenster schickt die vom Kern-Dokument angenommenen Ops (Commit/Griff/Befehl/Import/Undo/Redo, `ProjectDocument.onChange`) mit laufender Nummer `seq`; das Fenster führt sie ohne Verlauf nach (`applyRemote` = `doc_apply` + `applyOps`, kein Rust nötig). Rückfall Feld-Differenz + Vollabgleich bei Laden/Neu, grossem Verlaufsschritt ohne Ops; Lücke in `seq` oder abgelehnte Ops → Fenster fordert den ganzen Stand an. Messung Grossgebäude (1832 Wände, Linux-Container): Sync einer Wandänderung 0.4 ms statt 56 ms. Tests `native/objectSettingsSync.test.ts`, `objectSettingsWindow.render.test.ts`, `state/mixedValues.test.ts`, `panelHost/elementAttributesHost.test.ts`. **Stand 12.11. (3):** Mehrfachauswahl setzt jetzt auch Referenzlinie/Fugen-Versatz/Terminierung/Dachanschluss/Aussen+tragend (Wand, Decke), alle Öffnungs-Felder (nur Öffnungen GLEICHER Art Fenster/Tür; Position und Dach-/Deckenfenster-Lage bewusst nur das erste), den Fenster-/Türeditor (`onPatchOpening`, Typ-Zuweisung; ein Undo-Schritt), Treppe, Raum (SIA, Nutzung, Oberflächen; der Name bleibt je Raum eigen, Feld gesperrt), Stütze und Körper (`patchAll`/`mapAll`, `targetIds` im `elementAttributesHost`); `deriveSelection` führt auch bei mehreren Treppen/Räumen/Körpern/Stützen mit dem ersten Element; „gemischt“ für Referenzlinie, Treppe (Typ/Form/Breite/Stufen/Steighöhe), Öffnungs-Anschlag/Aufschlag/Richtung/Flügel, Raum-SIA, Höhe von Stütze/Körper. Dach-Kanten, Gauben und Innenhöfe sind dachspezifisch: nur bei EINEM Dach angeboten. Tests `native/objectSettingsSync.test.ts`, `objectSettingsWindow.render.test.ts`, `state/mixedValues.test.ts`, `panelHost/elementAttributesHost.test.ts`, `objectInfo/OpeningEditor.render.test.ts`. **Offen:** NICHT auf macOS gebaut/getestet (nur vitest/tsc im Linux-Container; Capability `object-settings` ergänzt, kein Rust); kein Messwert (Live-Mass) im Fenster; Gelände/Baugrube haben keinen Setter im Objekt-Info (nichts umgestellt); Dach-Felder ausser Typ/Neigung (Dicke, Traufhöhe …) setzen bei Mehrfachauswahl weiter nur das erste Dach. · L - ◐ **[194]** Texte exakt synchron beim Zoomen (12.11., Maintainer Mac: Texte immer leicht verzögert; Nachfolger [145]). diff --git a/e2e/contextDrag.spec.ts b/e2e/contextDrag.spec.ts index b6b37151..79a46f04 100644 --- a/e2e/contextDrag.spec.ts +++ b/e2e/contextDrag.spec.ts @@ -89,3 +89,23 @@ test("Musterhaus komplex: Höhenlinien-Punkt per Griff ziehen, ein Undo-Schritt" expect(await firstOf(page, "contourSet")).toEqual(p0); expect(p1).not.toEqual(p0); }); + +test("Musterhaus komplex: Höhenlinien-Punkt per Rechtsklick löschen, ein Undo-Schritt [193]", async ({ page }) => { + test.setTimeout(120_000); + await openComplex(page); + await showSnapshot(page, "Situation 1:500"); + await openTab(page, "Elemente"); + await elementRows(page).filter({ hasText: "Höhenlinien (Vermessung)" }).first().click(); + const grips = page.locator(".plan-grip:not(.plan-grip-insert)"); + await expect.poll(() => grips.count(), { timeout: 30_000 }).toBeGreaterThan(20); + + const p0 = await firstOf(page, "contourSet"); + const g = await modelToClient(page, p0.x, p0.y); + await page.mouse.click(g.x, g.y, { button: "right" }); + await page.getByRole("menuitem", { name: /Ecke löschen/ }).click(); + await expect.poll(async () => JSON.stringify(await firstOf(page, "contourSet"))).not.toBe(JSON.stringify(p0)); + + await blurFocus(page); + await page.keyboard.press("ControlOrMeta+z"); + expect(await firstOf(page, "contourSet")).toEqual(p0); +}); diff --git a/src-tauri/core/src/cmd_context.rs b/src-tauri/core/src/cmd_context.rs index a69cbd04..d163fd21 100644 --- a/src-tauri/core/src/cmd_context.rs +++ b/src-tauri/core/src/cmd_context.rs @@ -53,19 +53,82 @@ pub fn contour_height(e: &Value, index: usize, z: f64) -> Option { Some(with(e, "contours", Value::Array(out))) } -/// Ops der Höhen-Befehle (`None` = fremder Befehl). +/// Höhe des Netzpunkts `index` (Vertex-Nummer) eines Geländes/Netzes auf `z` setzen. +pub fn mesh_point_height(e: &Value, index: usize, z: f64) -> Option { + if !matches!(kind(e), "terrainMesh" | "importedMesh") || !z.is_finite() { + return None; + } + let pos = arr(field(e, "positions")); + let k = index.checked_mul(3)?.checked_add(2)?; + if k >= pos.len() || num_of(Some(&pos[k])) == z { + return None; + } + let mut out = pos.to_vec(); + out[k] = js_num(z); + Some(with(e, "positions", Value::Array(out))) +} + +/// Netz auf ein Polygon (`poly` = flach x,y,…) zuschneiden: Dreiecke bleiben, deren Schwerpunkt im Polygon liegt; nicht +/// mehr genutzte Punkte (samt `vertexColors`) fallen weg. Nichts übrig oder nichts abgeschnitten = keine Änderung. +pub fn mesh_crop(e: &Value, poly: &[f64]) -> Option { + if !matches!(kind(e), "terrainMesh" | "importedMesh") || poly.len() < 6 || poly.len() % 2 != 0 || poly.iter().any(|v| !v.is_finite()) { + return None; + } + let pos: Vec = arr(field(e, "positions")).iter().map(|v| num_of(Some(v))).collect(); + let idx: Vec = arr(field(e, "indices")).iter().map(|v| num_of(Some(v))).map(|f| if f >= 0.0 && f.fract() == 0.0 { f as usize } else { usize::MAX }).collect(); + let nv = pos.len() / 3; + if idx.len() < 3 || idx.iter().any(|&i| i >= nv) { + return None; + } + let keep: Vec<&[usize]> = idx + .chunks_exact(3) + .filter(|t| { + let (cx, cy) = t.iter().fold((0.0, 0.0), |a, &i| (a.0 + pos[3 * i] / 3.0, a.1 + pos[3 * i + 1] / 3.0)); + crate::plan::pick::point_in_polygon(cx, cy, poly) + }) + .collect(); + if keep.is_empty() || keep.len() == idx.len() / 3 { + return None; + } + let mut map = vec![usize::MAX; nv]; + let mut order: Vec = Vec::new(); + let mut new_idx: Vec = Vec::with_capacity(keep.len() * 3); + for t in keep { + for &i in t { + if map[i] == usize::MAX { + map[i] = order.len(); + order.push(i); + } + new_idx.push(js_num(map[i] as f64)); + } + } + let new_pos: Vec = order.iter().flat_map(|&i| (0..3).map(move |c| (i, c))).map(|(i, c)| js_num(pos[3 * i + c])).collect(); + let mut out = with(&with(e, "positions", Value::Array(new_pos)), "indices", Value::Array(new_idx)); + if let Some(vc) = field(e, "vertexColors").and_then(Value::as_array).filter(|c| c.len() == nv * 3) { + let nc: Vec = order.iter().flat_map(|&i| vc[3 * i..3 * i + 3].iter().cloned()).collect(); + out = with(&out, "vertexColors", Value::Array(nc)); + } + Some(out) +} + +/// Ops der Höhen-/Netz-Befehle (`None` = fremder Befehl). pub fn ops(root: &Map, v: &Value) -> Option> { let cmd = v.get("cmd").and_then(Value::as_str)?; - if cmd != "contextOffset" && cmd != "contourZ" { + if !matches!(cmd, "contextOffset" | "contourZ" | "meshPointZ" | "meshCrop") { return None; } let num = |k: &str| v.get(k).and_then(Value::as_f64).unwrap_or(f64::NAN); - let patched = v.get("id").and_then(Value::as_str).and_then(|id| element(root, id)).and_then(|e| { - if cmd == "contextOffset" { - height_offset(e, num("dz")) - } else { - let i = num("index"); - if i.is_finite() && i >= 0.0 { contour_height(e, i as usize, num("z")) } else { None } + let index = || { + let i = num("index"); + (i.is_finite() && i >= 0.0).then_some(i as usize) + }; + let patched = v.get("id").and_then(Value::as_str).and_then(|id| element(root, id)).and_then(|e| match cmd { + "contextOffset" => height_offset(e, num("dz")), + "contourZ" => contour_height(e, index()?, num("z")), + "meshPointZ" => mesh_point_height(e, index()?, num("z")), + _ => { + let poly: Vec = v.get("poly").and_then(Value::as_array)?.iter().map(|x| x.as_f64().unwrap_or(f64::NAN)).collect(); + mesh_crop(e, &poly) } }); Some(patched.map(|entity| vec![Op::Replace { collection: "context".into(), entity }]).unwrap_or_default()) @@ -112,6 +175,29 @@ mod tests { assert!(run(json!({"cmd":"contextOffset","id":"hl"})).is_empty()); } + #[test] + fn netzpunkt_hoehe_und_zuschnitt() { + let o = run(json!({"cmd":"meshPointZ","id":"tm","index":1,"z":9})); + assert_eq!(o[0]["entity"]["positions"], json!([0, 0, 5, 1, 0, 9, 0, 1, 7])); + assert!(run(json!({"cmd":"meshPointZ","id":"tm","index":1,"z":6})).is_empty()); + assert!(run(json!({"cmd":"meshPointZ","id":"tm","index":3,"z":6})).is_empty()); + assert!(run(json!({"cmd":"meshPointZ","id":"hl","index":0,"z":6})).is_empty()); + // Zwei Dreiecke (Quadrat 0..2); Zuschnitt auf die linke Hälfte behält eines, verwirft Punkte und Farben. + let mut r = root(); + r.insert("context".into(), json!([{"id":"q","type":"terrainMesh","positions":[0,0,1, 2,0,2, 2,2,3, 0,2,4],"indices":[0,1,2, 0,2,3],"vertexColors":[0,0,0, 1,1,1, 2,2,2, 3,3,3]}])); + let cut = |poly: Value| ops(&r, &json!({"cmd":"meshCrop","id":"q","poly":poly})).unwrap().iter().map(|o| o.to_json()).collect::>(); + let o = cut(json!([-1.0, -1.0, 1.5, -1.0, 1.5, 3.0, -1.0, 3.0])); + // Schwerpunkte: (4/3, 2/3) und (2/3, 4/3) -> beide liegen links von 1.5: nichts abgeschnitten. + assert!(o.is_empty()); + let o = cut(json!([-1.0, -1.0, 1.0, -1.0, 1.0, 3.0, -1.0, 3.0])); + assert_eq!(o[0]["entity"]["indices"], json!([0, 1, 2])); + assert_eq!(o[0]["entity"]["positions"], json!([0, 0, 1, 2, 2, 3, 0, 2, 4])); + assert_eq!(o[0]["entity"]["vertexColors"], json!([0, 0, 0, 2, 2, 2, 3, 3, 3])); + // ausserhalb von allem / kaputtes Polygon + assert!(cut(json!([10, 10, 11, 10, 11, 11])).is_empty()); + assert!(cut(json!([0, 0, 1])).is_empty()); + } + #[test] fn hoehe_einer_linie() { let o = run(json!({"cmd":"contourZ","id":"hl","index":1,"z":510})); diff --git a/src-tauri/core/src/grips.rs b/src-tauri/core/src/grips.rs index 19c0318c..76cdc59d 100644 --- a/src-tauri/core/src/grips.rs +++ b/src-tauri/core/src/grips.rs @@ -317,6 +317,11 @@ pub fn run(lk: &Lookup, req: &Request) -> Result { let (seg, (x, y)) = (r.n("seg"), r.p("pt")); patch("context", r.s("id"), &|e| contour_edit(e, seg, Some((x, y)), true)).into() } + // [193] Gelände-Netz: Netzpunkt `index` (Vertex-Nummer) im Grundriss verschieben, die Höhe bleibt (Höhe: Befehl `meshPointZ`). + "meshGrip" => { + let (index, (x, y)) = (r.n("index"), r.p("pt")); + patch("context", r.s("id"), &|e| mesh_grip(e, index, x, y)).into() + } "excavationEdge" => { let (a, b, (dx, dy)) = (r.n("a"), r.n("b"), r.p("delta")); patch("context", r.s("id"), &|e| Some(with(e, "outline", move_polygon_edge(field(e, "outline")?.as_array()?, a, b, dx, dy, true)?))).into() @@ -375,7 +380,7 @@ pub fn run(lk: &Lookup, req: &Request) -> Result { Some("roof") => "roofs", Some("ceiling") => "ceilings", Some("room") => "rooms", - Some("excavation") => "context", + Some("excavation") | Some("contours") => "context", Some("polyline") => "drawings2d", _ => return Ok(GripResult::default()), }; @@ -1475,6 +1480,58 @@ fn contour_edit(e: &Value, flat: f64, at: Option<(f64, f64)>, insert: bool) -> O None } +/// [193] Netzpunkt `index` eines `terrainMesh`/`importedMesh` auf `(x, y)` setzen (z unverändert). +fn mesh_grip(e: &Value, index: f64, x: f64, y: f64) -> Option { + if !(x.is_finite() && y.is_finite()) || !matches!(field(e, "type").and_then(Value::as_str), Some("terrainMesh" | "importedMesh")) { + return None; + } + let pos = arr(field(e, "positions")); + let i = index_in(index, pos.len() / 3)?; + let mut v = pos.to_vec(); + v[3 * i] = js_num(x); + v[3 * i + 1] = js_num(y); + Some(with(e, "positions", Value::Array(v))) +} + +/// [193] Höhenlinien-Punkt löschen bzw. aufräumen (flacher Index über alle Linien des Satzes). Mindestens 2 Punkte +/// (offen) bzw. 3 (geschlossen) bleiben. Aufräumen entfernt den Punkt nur, wenn er auf dem Nachbarpunkt oder (innen) auf +/// der Geraden zwischen den Nachbarn liegt. Eine wahre Kurve (`curve`) fällt weg. Einfügen läuft über `contourInsert`. +fn contour_ring_edit(e: &Value, flat: f64, edit: &RingEdit) -> Option { + if field(e, "type").and_then(Value::as_str) != Some("contourSet") || matches!(edit, RingEdit::Insert(..)) { + return None; + } + let cs = arr(field(e, "contours")); + let mut off = 0usize; + for (ci, c) in cs.iter().enumerate() { + let pts = arr(field(c, "pts")); + let (closed, n) = (truthy(field(c, "closed")), pts.len()); + if let Some(i) = index_in(flat - off as f64, n) { + if n <= if closed { 3 } else { 2 } { + return None; + } + if let RingEdit::Tidy(tol) = *edit { + let near = |a: usize, b: usize| { + let (p, q) = (xy(&pts[a]), xy(&pts[b])); + hypot2(p.0 - q.0, p.1 - q.1) < tol + }; + let end = !closed && (i == 0 || i == n - 1); + let hit = if end { near(i, if i == 0 { 1 } else { n - 2 }) } else { near(i, (i + n - 1) % n) || near(i, (i + 1) % n) || point_near_neighbors(pts, i, tol) }; + if !hit { + return None; + } + } + let mut v = pts.to_vec(); + v.remove(i); + let nc = with_opt(&with(c, "pts", Value::Array(v)), vec![("curve", None)]); + let mut out = cs.to_vec(); + out[ci] = nc; + return Some(with(e, "contours", Value::Array(out))); + } + off += n; + } + None +} + /// [26] Ecke einfügen/löschen/aufräumen an einem Umriss-Element (s. `ringInsert`). fn ring_edit(e: &Value, kind: &str, flat: f64, edit: &RingEdit) -> Option { if truthy(field(e, "locked")) { @@ -1496,6 +1553,7 @@ fn ring_edit(e: &Value, kind: &str, flat: f64, edit: &RingEdit) -> Option "excavation" => simple("outline", "outlineBulge"), "room" => simple("boundary", "boundaryBulge"), "polyline" => polyline_ring_edit(e, flat, edit), + "contours" => contour_ring_edit(e, flat, edit), "roof" => { let outline = field(e, "outline")?.as_array()?; let holes: Vec<&Vec> = arr(field(e, "holes")).iter().filter_map(|h| h.as_array()).collect(); @@ -2132,6 +2190,37 @@ mod tests { assert!(ent(json!({"op": "contourInsert", "id": "hl", "seg": 6, "pt": [1, 2]})).is_none()); } + /// [193] Netzpunkt im Grundriss verschieben (z bleibt). + #[test] + fn netzpunkt_griff() { + let r = root(json!({"context": [{"id": "tm", "type": "terrainMesh", "positions": [0, 0, 5, 1, 0, 6, 0, 1, 7], "indices": [0, 1, 2]}]})); + let ent = |v: Value| run(&Lookup::plain(&r), &rq(v)).unwrap().ops.first().map(|o| o.to_json()["entity"].clone()); + let e = ent(json!({"op": "meshGrip", "id": "tm", "index": 1, "pt": [3, 4]})).unwrap(); + assert_eq!(e["positions"], json!([0, 0, 5, 3, 4, 6, 0, 1, 7])); + assert!(ent(json!({"op": "meshGrip", "id": "tm", "index": 3, "pt": [3, 4]})).is_none()); + } + + /// [193] Höhenlinien-Punkt löschen / aufräumen (Mindestpunktzahl offen 2, geschlossen 3). + #[test] + fn hoehenlinien_punkt_loeschen() { + let r = root(json!({"context": [{"id": "hl", "type": "contourSet", "contours": [ + {"z": 1, "closed": false, "pts": [{"x": 0, "y": 0}, {"x": 2, "y": 0}, {"x": 4, "y": 0}]}, + {"z": 2, "closed": true, "curve": {"cx": 0, "cy": 0}, "pts": [{"x": 0, "y": 1}, {"x": 2, "y": 1}, {"x": 2, "y": 3}]}, + {"z": 3, "closed": false, "pts": [{"x": 0, "y": 5}, {"x": 5, "y": 5}]}]}]})); + let ent = |v: Value| run(&Lookup::plain(&r), &rq(v)).unwrap().ops.first().map(|o| o.to_json()["entity"].clone()); + let e = ent(json!({"op": "ringDelete", "kind": "contours", "id": "hl", "index": 1})).unwrap(); + assert_eq!(e["contours"][0]["pts"].as_array().unwrap().len(), 2); + assert_eq!(e["contours"][0]["pts"][1], json!({"x": 4, "y": 0})); + // geschlossen mit 3 Punkten und offen mit 2: nicht löschbar + assert!(ent(json!({"op": "ringDelete", "kind": "contours", "id": "hl", "index": 4})).is_none()); + assert!(ent(json!({"op": "ringDelete", "kind": "contours", "id": "hl", "index": 6})).is_none()); + assert!(ent(json!({"op": "ringDelete", "kind": "contours", "id": "hl", "index": 9})).is_none()); + // Aufräumen: Punkt 1 liegt auf der Geraden -> weg; ein Punkt abseits bliebe. + let e = ent(json!({"op": "ringTidy", "kind": "contours", "id": "hl", "index": 1, "tol": 0.01})).unwrap(); + assert_eq!(e["contours"][0]["pts"].as_array().unwrap().len(), 2); + assert!(ent(json!({"op": "ringTidy", "kind": "contours", "id": "hl", "index": 4, "tol": 0.01})).is_none()); + } + /// [26] Dach: Ecken und Kanten von Umriss und Hof über den flachen Index; schiefer Umriss bleibt schief. #[test] fn dach_griffe_umriss_und_hof() { diff --git a/src/geometry/grips.ts b/src/geometry/grips.ts index 1e69d20b..3f702c01 100644 --- a/src/geometry/grips.ts +++ b/src/geometry/grips.ts @@ -36,6 +36,8 @@ export type GripRequest = // [193] Höhenlinien-Satz: Punkt (flacher Index über alle Linien) ziehen bzw. hinter Punkt `seg` einfügen (Kern `contour_edit`). | { op: "contourGrip"; id: string; index: number; pt: P } | { op: "contourInsert"; id: string; seg: number; pt: P } + // [193] Gelände-Netz: Netzpunkt (Vertex-Nummer) im Grundriss verschieben (Kern `mesh_grip`). + | { op: "meshGrip"; id: string; index: number; pt: P } // [26] Dach: Ecke bzw. Kante von Umriss/Hof, flacher Index (erst `outline`, dann `holes` Ring für Ring). | { op: "roofVertex"; id: string; index: number; pt: P } | { op: "roofEdge"; id: string; a: number; b: number; delta: P } diff --git a/src/i18n/de.ts b/src/i18n/de.ts index cd5dd110..9e3285d1 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -2440,6 +2440,13 @@ export const de = { "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.meshPoint": "Netzpunkt Nr.", + "site.meshPoint.hint": "Nummer des Netzpunkts (1 bis {n}); seine Lage ziehst du im Grundriss am Griff", + "site.meshPoint.z": "Höhe des Punkts (m)", + "site.meshCrop": "Auf Grundstück zuschneiden", + "site.meshCrop.hint": "Entfernt alle Dreiecke, deren Schwerpunkt ausserhalb der Parzelle liegt", + "site.meshCrop.noParcel": "Zuerst die Parzelle im Baurecht erfassen", + "site.meshCrop.nothing": "Nichts zuzuschneiden: Das Netz liegt ganz innerhalb der Parzelle bzw. ausserhalb davon.", "site.excavation.bottom": "Sohle [m]", "site.excavation.slope": "Böschung [°]", "site.excavation.fillSlope": "Schüttung [°]", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index fdfd09ce..6b44eddb 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -2428,6 +2428,13 @@ export const en: Record = { "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.meshPoint": "Mesh point no.", + "site.meshPoint.hint": "Number of the mesh point (1 to {n}); drag its position in the plan by its grip", + "site.meshPoint.z": "Point height (m)", + "site.meshCrop": "Crop to parcel", + "site.meshCrop.hint": "Removes all triangles whose centroid lies outside the parcel", + "site.meshCrop.noParcel": "Enter the parcel under building regulations first", + "site.meshCrop.nothing": "Nothing to crop: the mesh lies entirely inside the parcel or entirely outside it.", "site.excavation.bottom": "Bottom [m]", "site.excavation.slope": "Slope [°]", "site.excavation.fillSlope": "Fill slope [°]", diff --git a/src/menus/AppContextMenu.tsx b/src/menus/AppContextMenu.tsx index 763ed916..660f44af 100644 --- a/src/menus/AppContextMenu.tsx +++ b/src/menus/AppContextMenu.tsx @@ -171,6 +171,11 @@ export function AppContextMenu(props: { if (room && !room.locked) return { kind: "room" as const, id: room.id, rings: [{ pts: room.boundary, off: 0 }] }; const ctx = selection.contextObjects.length === 1 ? (project.context ?? []).find((x) => x.id === selection.contextObjects[0]) : undefined; if (ctx && ctx.type === "excavation") return { kind: "excavation" as const, id: ctx.id, rings: [{ pts: ctx.outline, off: 0 }] }; + // [193] Höhenlinien-Satz: je Linie ein Ring (flacher Index über alle Linien); offene Linien haben kein Schlusssegment. + if (ctx && ctx.type === "contourSet") { + return { kind: "contours" as const, id: ctx.id, rings: ctx.contours.reduce<{ pts: Vec2[]; off: number; closed: boolean }[]>( + (acc, c) => (c.pts.length >= 2 ? [...acc, { pts: c.pts, off: ctx.contours.slice(0, ctx.contours.indexOf(c)).reduce((n, x) => n + x.pts.length, 0), closed: !!c.closed }] : acc), []) }; + } return null; })(), insertRingVertex, diff --git a/src/menus/contextMenu.tsx b/src/menus/contextMenu.tsx index 07302fd7..fb5558f9 100644 --- a/src/menus/contextMenu.tsx +++ b/src/menus/contextMenu.tsx @@ -90,7 +90,7 @@ export interface MenuActions { selectedSectionLine?: { id: string; pts: Vec2[] } | null; insertSectionBend?: (id: string, seg: number, pt: Vec2) => void; /** [26] Einzeln gewähltes Element mit Umriss (Dach samt Höfen, Decke, Raum, Baugrube): Ringe mit Start-Index im flachen Ecken-Index. */ - selectedRing?: { kind: RingKind; id: string; rings: { pts: Vec2[]; off: number }[] } | null; + selectedRing?: { kind: RingKind; id: string; rings: { pts: Vec2[]; off: number; closed?: boolean }[] } | null; insertRingVertex?: (kind: RingKind, id: string, seg: number, pt: Vec2) => void; deleteRingVertex?: (kind: RingKind, id: string, index: number) => void; deleteSectionBend?: (id: string, index: number) => void; @@ -364,8 +364,8 @@ function planMenuItems( // [26] Umriss-Element: Ecke am Klick einfügen bzw. die getroffene Ecke löschen (mindestens drei bleiben). const ring = a.selectedRing; if (ring) { - for (const { pts, off } of ring.rings) { - const geom = { pts, closed: true }; + for (const { pts, off, closed = true } of ring.rings) { + const geom = { pts, closed }; const hit = nearestPolylineTarget(geom, model, toleranceFor(geom)); if (!hit) continue; if (hit.kind === "segment" && a.insertRingVertex) { @@ -376,7 +376,7 @@ function planMenuItems( }); } if (hit.kind === "vertex" && a.deleteRingVertex) { - const enabled = pts.length > 3; + const enabled = pts.length > (closed ? 3 : 2); pointItems.push({ label: t("ctx.deleteCorner"), icon: , diff --git a/src/panels/ContextObjectProps.tsx b/src/panels/ContextObjectProps.tsx index 8cd2f3f0..5623091b 100644 --- a/src/panels/ContextObjectProps.tsx +++ b/src/panels/ContextObjectProps.tsx @@ -65,6 +65,51 @@ const SMOOTH_LEVELS = [0, 1, 2, 3] as const; const RESMOOTH_PASSES = [1, 2, 4] as const; +/** [193] Netzpunkt wählen (Nummer ab 1) und seine Höhe setzen; Zuschneiden des Netzes auf die Parzelle. */ +function MeshPointFields({ obj }: { obj: Extract }) { + const setMeshPointHeight = useStore((s) => s.setMeshPointHeight); + const cropMesh = useStore((s) => s.cropMesh); + const notify = useStore((s) => s.notify); + const parcel = useStore((s) => s.project.siteRules?.parcel); + const [nr, setNr] = useState("1"); + const n = Math.floor(obj.positions.length / 3); + const i = Math.round(Number(nr)) - 1; + const valid = Number.isFinite(i) && i >= 0 && i < n; + return ( + <> + + + + + ); +} + /** [193] Höhenversatz (alle Höhen um dz) und, bei Höhenlinien, die Höhe je Linie. */ function HeightFields({ obj }: { obj: ContextObject }) { const offsetContextHeight = useStore((s) => s.offsetContextHeight); @@ -90,6 +135,7 @@ function HeightFields({ obj }: { obj: ContextObject }) { onBlur={apply} /> + {(obj.type === "terrainMesh" || obj.type === "importedMesh") && } {obj.type === "contourSet" && (
{t("site.contours", { n: obj.contours.length })} diff --git a/src/state/contextEdit.test.ts b/src/state/contextEdit.test.ts index 941707c5..2b807067 100644 --- a/src/state/contextEdit.test.ts +++ b/src/state/contextEdit.test.ts @@ -46,6 +46,11 @@ describe("Höhenlinien: Punkte per Griff", () => { expect(ins.contours[0].pts).toHaveLength(4); expect(ins.contours[0].pts[2]).toEqual({ x: 3, y: 1 }); }); + it("Punkt löschen und Aufräumen laufen über ringDelete/ringTidy", () => { + const p = project(); + expect(commit(p, { op: "ringDelete", kind: "contours", id: "hl", index: 1 }, "hl").contours[0].pts).toHaveLength(2); + expect(commit(p, { op: "ringTidy", kind: "contours", id: "hl", index: 1, tol: 0.01 }, "hl").contours[0].pts).toHaveLength(2); + }); }); describe("Kontext verschieben (Maus-Ziehen im Plan)", () => { @@ -58,3 +63,20 @@ describe("Kontext verschieben (Maus-Ziehen im Plan)", () => { expect(contextAnchor(p, "nix")).toBeNull(); }); }); + +describe("Gelände-Netz: Punkte und Zuschnitt [193]", () => { + const mesh = { + id: "tm", type: "terrainMesh", categoryCode: "02", name: "Gelände", + positions: [0, 0, 1, 2, 0, 2, 2, 2, 3, 0, 2, 4], indices: [0, 1, 2, 0, 2, 3], + } as unknown as ContextObject; + const proj = (): Project => ({ ...sampleProject, context: [mesh] }); + it("Netzpunkt per Griff verschieben, Höhe setzen, auf Polygon zuschneiden", () => { + const p = proj(); + const m = commit(p, { op: "meshGrip", id: "tm", index: 1, pt: [5, 6] }, "tm"); + expect(m.positions.slice(3, 6)).toEqual([5, 6, 2]); + const z = documentFor(p).cmdOps({ cmd: "meshPointZ", id: "tm", index: 2, z: 9 }); + expect(JSON.stringify(z)).toContain("9"); + const crop = documentFor(p).cmdOps({ cmd: "meshCrop", id: "tm", poly: [-1, -1, 1, -1, 1, 3, -1, 3] }); + expect(JSON.stringify(crop)).toContain('"indices":[0,1,2]'); + }); +}); diff --git a/src/state/projectSlice.ts b/src/state/projectSlice.ts index 882eafb6..3ac2c7dd 100644 --- a/src/state/projectSlice.ts +++ b/src/state/projectSlice.ts @@ -402,6 +402,8 @@ export interface ProjectSlice { insertRingVertex: (kind: RingKind, id: string, seg: number, pt: Vec2, coalesceKey?: string) => void; /** [26] Ecke löschen (mind. 3 bleiben); ein Undo-Schritt. */ deleteRingVertex: (kind: RingKind, id: string, index: number) => void; + /** [193] Netzpunkt eines Geländes/Netzes im Grundriss verschieben (Höhe bleibt). */ + moveMeshPoint: (id: string, index: number, pt: Vec2) => void; /** [191] Bogen-Scheitel der Kante `seg` (Dach: flacher Index) ziehen: setzt den Bulge über die Pfeilhöhe. */ setRingArc: (kind: "roof" | "ceiling" | "room", id: string, seg: number, pt: Vec2, coalesceKey?: string) => void; /** [26] Nach dem Ziehen: Ecke auf Nachbar bzw. Gerade zwischen den Nachbarn entfällt. */ @@ -1309,8 +1311,9 @@ export function createProjectSlice( }, insertRingVertex: (kind, id, seg, pt, coalesceKey) => applyGrip(kind === "contours" ? { op: "contourInsert", id, seg, pt: gripPt(pt) } : kind === "polyline" ? { op: "insertPoint", id, seg, pt: gripPt(pt) } : { op: "ringInsert", kind, id, seg, pt: gripPt(pt) }, coalesceKey), + moveMeshPoint: (id, index, pt) => applyGrip({ op: "meshGrip", id, index, pt: gripPt(pt) }), deleteRingVertex: (kind, id, index) => - kind === "contours" ? undefined : applyGrip(kind === "polyline" ? { op: "deletePoint", id, index } : { op: "ringDelete", kind, id, index }), + applyGrip(kind === "polyline" ? { op: "deletePoint", id, index } : { op: "ringDelete", kind, id, index }), setRingArc: (kind, id, seg, pt, coalesceKey) => applyGrip({ op: "ringArc", kind, id, seg, pt: gripPt(pt) }, coalesceKey ?? `ringArc:${kind}:${id}:${seg}`), tidyRingVertex: (kind, id, index, coalesceKey, tol) => applyGrip({ op: "ringTidy", kind, id, index, ...(tol != null ? { tol } : {}) }, coalesceKey), diff --git a/src/state/siteSlice.ts b/src/state/siteSlice.ts index 43100742..95623a79 100644 --- a/src/state/siteSlice.ts +++ b/src/state/siteSlice.ts @@ -38,6 +38,10 @@ export interface SiteSlice { offsetContextHeight: (id: string, dz: number) => void; /** [193] Höhe der Höhenlinie `index` eines Höhenlinien-Satzes setzen (Kern `cmd_context.rs`); `coalesceKey` für Tippen. */ setContourHeight: (id: string, index: number, z: number, coalesceKey?: string) => void; + /** [193] Höhe eines Netzpunkts (Vertex-Nummer ab 0) setzen. */ + setMeshPointHeight: (id: string, index: number, z: number, coalesceKey?: string) => void; + /** [193] Netz auf ein Polygon (Modell-Meter) zuschneiden; false = nichts geändert. */ + cropMesh: (id: string, poly: Vec2[]) => boolean; /** [193] Kontext-Elemente um `delta` verschieben (Maus-Ziehen im Plan; Kern `cmd_transform.rs`), ein Undo-Schritt. */ moveContextBy: (ids: string[], delta: Vec2) => void; /** [T6]/[68] Ändert Felder eines Kontext-Objekts (Gelände, Baugrube) in einem Schritt; `coalesceKey` für Tippen. */ @@ -111,6 +115,17 @@ export function createSiteSlice( if (ops.length) get().applyChange(ops, coalesceKey); }, + setMeshPointHeight: (id, index, z, coalesceKey) => { + const ops = documentFor(get().project).cmdOps({ cmd: "meshPointZ", id, index, z }); + if (ops.length) get().applyChange(ops, coalesceKey); + }, + + cropMesh: (id, poly) => { + const ops = documentFor(get().project).cmdOps({ cmd: "meshCrop", id, poly: poly.flatMap((q) => [q.x, q.y]) }); + if (ops.length) get().applyChange(ops); + return ops.length > 0; + }, + moveContextBy: (ids, delta) => { if (ids.length === 0 || (delta.x === 0 && delta.y === 0)) return; const ops = transformOps(get().project, { wallIds: [], drawingId: null, contextIds: ids }, "move", [{ x: 0, y: 0 }, delta], "move", 1); diff --git a/src/state/useGripEditing.ts b/src/state/useGripEditing.ts index 57bb9449..008b3561 100644 --- a/src/state/useGripEditing.ts +++ b/src/state/useGripEditing.ts @@ -195,6 +195,13 @@ export function useGripEditing(opts: { return o && o.type === "contourSet" ? o : null; })() : null; + // [193] Einzeln gewähltes Gelände-/Netz-Element: Netzpunkte als Griffe (Kern `grips.rs::mesh_grip`). + const selectedMesh = selectedContourSetId + ? (() => { + const o = (project.context ?? []).find((c) => c.id === selectedContourSetId); + return o && (o.type === "terrainMesh" || o.type === "importedMesh") ? o : null; + })() + : null; const selectedTreeId = single(selection, "trees"); const selectedTree = selectedTreeId ? (project.trees ?? []).find((x) => x.id === selectedTreeId) : undefined; // [176] Schnitt-/Ansichtslinie im Grundriss: Griffe an Anfang, Knickpunkten (`bendPoints`) und Ende. @@ -541,6 +548,19 @@ export function useGripEditing(opts: { } return pts; } + // [193] Gelände-Netz: jeder Netzpunkt ein Griff (xy; die Höhe steht in der Objekt-Info). Grosse Netze (swissALTI3D + // mit tausenden Punkten) bekommen keine Griffe — dort hilft Zuschneiden auf das Grundstück. + if (selectedMesh && !selectedCeiling && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0) { + const n = Math.floor(selectedMesh.positions.length / 3); + if (n > MAX_CONTOUR_GRIPS) return []; + const pts: Vec2[] = []; + for (let i = 0; i < n; i++) { + pts.push({ x: selectedMesh.positions[3 * i], y: selectedMesh.positions[3 * i + 1] }); + gripOwners.push({ localIndex: i }); + gripOwnerRange.push([0, n - 1]); + } + return pts; + } // [68] Baugrube: Umriss-Ecken + Sohlen-Griff (Lage: Schwerpunkt, y um die Sohlenhöhe versetzt). if (modelEditable && selectedExcavation && !selectedCeiling && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0) { const pts = excavationGripPoints(selectedExcavation); @@ -822,7 +842,7 @@ export function useGripEditing(opts: { /** [193] Aufgeschobenes Ziehen von Gelände-/Umgebungs-Elementen: ungefangenes und gefangenes Gesamt-Delta. */ const pendingContextMoveRef = useRef<{ ids: string[]; raw: Vec2; total: Vec2; anchor: Vec2 | null } | null>(null); /** [193] Zug an einem Höhenlinien-Punkt (bzw. einer Einfüge-Raute: `insertSeg`): Vorschau bis zum Setzen, dann EIN Undo-Schritt. */ - const pendingContourRef = useRef<{ id: string; index: number; pt: Vec2; insertSeg?: number } | null>(null); + const pendingContourRef = useRef<{ id: string; index: number; pt: Vec2; insertSeg?: number; mesh?: boolean } | null>(null); /** Aufgeschobene Öffnungs-Verschiebung im Schnitt/in der Ansicht (neue `position`). */ const pendingOpeningMoveRef = useRef<{ id: string; position: number } | null>(null); /** Aufgeschobene Höhen-Änderung im Schnitt (Kante `kind` auf die Höhe `y`, Kern `sheetHeight`). */ @@ -1149,6 +1169,10 @@ export function useGripEditing(opts: { // auf die Wand/2D-Aktionen. So teilen Plan- UND 3D-Griffe denselben Pfad. const applyGrip = (index: number, pt: Vec2, arcLength?: number) => { // [193] Höhenlinien-Punkt bzw. Einfüge-Raute: nur Vorschau, das Projekt ändert sich beim Setzen (ein Undo-Schritt). + if (selectedMesh) { + pendingContourRef.current = { id: selectedMesh.id, index, pt, mesh: true }; + return; + } if (selectedContourSet) { const ins = gripOwners[index]; pendingContourRef.current = ins?.insertSeg != null @@ -1285,6 +1309,7 @@ export function useGripEditing(opts: { /** Vorschau-Form des ausstehenden Eckpunkt-Zugs (leer, wenn keiner läuft). */ const gripPreviewShapes = (): DraftShape[] => { const pc = pendingContourRef.current; + if (pc?.mesh) return []; if (pc && selectedContourSet?.id === pc.id) { // Die betroffene Höhenlinie mit dem gezogenen (bzw. eingefügten) Punkt als Linienzug. let off = 0; @@ -1360,9 +1385,12 @@ export function useGripEditing(opts: { if (ph) sheetHeightGrip(ph.kind, ph.id, ph.y, ph.free, ph.from, ph.index); const pc = pendingContourRef.current; pendingContourRef.current = null; - if (pc) { + if (pc?.mesh) storeState().moveMeshPoint(pc.id, pc.index, pc.pt); + else if (pc) { if (pc.insertSeg != null) storeState().insertRingVertex("contours", pc.id, pc.insertSeg, pc.pt); else storeState().moveRingVertex("contours", pc.id, pc.index, pc.pt); + // [193] Punkt, der auf einem Nachbarn bzw. auf der Geraden zwischen den Nachbarn landet, entfällt (derselbe Undo-Schritt). + storeState().tidyRingVertex("contours", pc.id, pc.index, undefined, ringTidyTol()); } const pa = pendingAreaGripRef.current; pendingAreaGripRef.current = null;