Merge branch 'worktree-agent-a8fc6e473cca76d27' into claude/practical-noether-1hb2s1
# Conflicts: # TODO.md # src/App.tsx # src/state/keyboardShortcuts.ts # src/state/useKeyboardShortcuts.ts
This commit is contained in:
17 files changed
+486
-8
No files matched your search
@@ -88,6 +88,21 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `*
|
||||
- ○ **[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
|
||||
- ○ **[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
|
||||
gewählten Wänden auch Ecken: nicht parallele gerade Wände eines Geschosses, deren Enden bis 0.5 m (bzw. 2 × Wanddicke)
|
||||
vom Achsschnittpunkt liegen (Lücke oder Überstand), werden dort verlängert/gekürzt (L-Ecke, beide Enden); Ende nahe einer
|
||||
anderen Wand, deren Achse im Innern getroffen wird, ergibt einen T-Stoss (nur dieses Ende rückt). Mehr als zwei Wände: alle
|
||||
Paare, nahe Paare zuerst, jedes Ende höchstens einmal; kollinear wie bisher zusammengefasst (dann nicht noch einmal
|
||||
angefasst). Gehrung/Anschluss aus `joins.rs`; Öffnungen und Bemassung führt `cmd_wall_edit::commit` nach (wie Trim/Extend:
|
||||
Öffnungen bleiben im Plan stehen, [188]), ein Undo-Schritt; ohne Wirkung Hinweis `cmd.join.nothing`. Kern
|
||||
`cmd_wall_edit.rs::connect_ops`; Tests `verbinden_*`; e2e `wallJoin190.spec.ts`. Das Tastenkürzel reagiert jetzt auch bei
|
||||
reiner Wandauswahl. Neue umbelegbare Kürzel (Einstellungen): Cmd+D Duplizieren (Kopie 0.5 m versetzt, danach gewählt),
|
||||
Cmd+L Sperren/Entsperren, Cmd+Shift+H Ebenen der Auswahl ausblenden, Cmd+Shift+A alle Ebenen einblenden, Cmd+0 alles
|
||||
einpassen, Cmd+Shift+F auf Auswahl einpassen (ohne Plan: 3D-Kamera); alle im nativen Menü (`state/selectionActions.ts`).
|
||||
Offen: Bogenwände werden nicht verbunden; T-Stoss nur bis zur Achse (nicht Fläche); „Auswahl ausblenden" im Grundriss
|
||||
schaltet Ebenen (persistent, undo-bar), nicht einzelne Elemente temporär; kein Cmd+E/F2 (keine Funktion dahinter);
|
||||
nicht in der Tauri-App geprüft. · S
|
||||
- ○ **[189]** Panels neu ordnen + Einstellungsdialog (12.11., Maintainer): Attribute-Panel unten links nur Gestaltung (Stift, Füllung, Linienstil, Schraffur); BIM-/Bauteil-Infos (Typ, Schichten, Masse, Kennwerte, IFC/Psets, Material …) in die Objekt-Info. Taste T bei Auswahl öffnet direkt den Einstellungsdialog des Objekts (wie Archicad Cmd+T), v. a. für Fenster/Türen, deren Einstellungen heute nur über das Attribute-Panel erreichbar sind. · M
|
||||
- ○ **[187]** Griffe im Schnitt/in der Ansicht (12.11., Maintainer): angewählte Elemente haben dort kaum Fasspunkte (Decken, Gelände, Dächer …). Wie Archicad: Decke OK/UK (Höhe/Dicke), Wand OK (Höhe), Öffnung Brüstung/Sturz, Dach Traufe/First bzw. Neigung, Treppe An-/Austritt, Gelände-Profilpunkte (falls Modell es erlaubt); ein Undo-Schritt je Zug, Fang + Tab-Eingabe wie im Grundriss. · L
|
||||
(Navigator, Kürzel, Ebenen-Panel) behält Zoom und Ausschnitt exakt — Geschosse teilen sich den Einpass-Schlüssel
|
||||
(`viewTabs.ts::planFitKey`, `PlanView` `fitKey`; Schnitt/Ansicht/Zeichnung/neues Projekt passen weiter ein).
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// [190] Cmd/Ctrl+J verbindet gewählte Wände an Ecken: zwei Wände mit 0.3 m Lücke, beide wählen, Ctrl+J →
|
||||
// die Achsen treffen sich im Schnittpunkt (ein Undo-Schritt). Geprüft am gespeicherten Projekt.
|
||||
import { readFile } from "node:fs/promises";
|
||||
import type { Page } from "@playwright/test";
|
||||
import { blurFocus, commandInput, expect, fileMenu, finishCommand, openTab, startNewProject, test, typeCommand } from "./app";
|
||||
|
||||
type W = { start: { x: number; y: number }; end: { x: number; y: number } };
|
||||
|
||||
async function savedWalls(page: Page): Promise<W[]> {
|
||||
await blurFocus(page);
|
||||
const pending = page.waitForEvent("download");
|
||||
await fileMenu(page, "Projekt speichern");
|
||||
const dl = await pending;
|
||||
return JSON.parse((await readFile(await dl.path())).toString("utf8")).walls as W[];
|
||||
}
|
||||
|
||||
async function drawWalls(page: Page, walls: [string, string][]): Promise<void> {
|
||||
for (const [a, b] of walls) {
|
||||
await page.getByRole("button", { name: "Wand", exact: true }).click();
|
||||
if (!(await page.locator(".cmdline-prompt").textContent())?.includes("Startpunkt")) {
|
||||
await page.getByRole("button", { name: "Wand", exact: true }).click();
|
||||
}
|
||||
await expect(page.locator(".cmdline-prompt")).toHaveText("Startpunkt der Wand:");
|
||||
await commandInput(page).focus();
|
||||
await typeCommand(page, a);
|
||||
await typeCommand(page, b);
|
||||
await finishCommand(page);
|
||||
}
|
||||
}
|
||||
|
||||
test("Wände mit Lücke an der Ecke per Ctrl+J verbinden, rückgängig", async ({ page }) => {
|
||||
await startNewProject(page);
|
||||
await openTab(page, "Elemente");
|
||||
await drawWalls(page, [
|
||||
["0,0", "5.7,0"],
|
||||
["6,0.3", "6,4"],
|
||||
]);
|
||||
await blurFocus(page);
|
||||
// Zurück ins Auswahl-Werkzeug, alles wählen.
|
||||
await page.keyboard.press("Escape");
|
||||
await page.keyboard.press("ControlOrMeta+a");
|
||||
await page.keyboard.press("ControlOrMeta+j");
|
||||
const meets = (ws: W[]) =>
|
||||
ws.some((w) => Math.abs(w.end.x - 6) < 1e-6 && Math.abs(w.end.y) < 1e-6) &&
|
||||
ws.some((w) => Math.abs(w.start.x - 6) < 1e-6 && Math.abs(w.start.y) < 1e-6);
|
||||
await expect.poll(async () => meets(await savedWalls(page))).toBe(true);
|
||||
|
||||
// Ein Undo-Schritt stellt die Lücke wieder her.
|
||||
await blurFocus(page);
|
||||
await page.keyboard.press("ControlOrMeta+z");
|
||||
await expect.poll(async () => (await savedWalls(page)).some((w) => Math.abs(w.end.x - 5.7) < 1e-6)).toBe(true);
|
||||
});
|
||||
@@ -990,7 +990,19 @@ pub fn ops(root: &Map<String, Value>, p: &Project, v: &Value) -> Option<Vec<Op>>
|
||||
"offset" => offset_ops(root, s_arg(v, "id"), n_arg(v, "d"), &mut ids),
|
||||
"join" => {
|
||||
let mut ops = join_ops(root, &list("ids"), &mut ids);
|
||||
ops.extend(wall_edit::join_ops(root, p, &list("ids")));
|
||||
let walls = wall_edit::join_ops(root, p, &list("ids"));
|
||||
// Schon kollinear verkettete Wände nicht noch einmal anfassen.
|
||||
let touched: Vec<String> = walls
|
||||
.iter()
|
||||
.flat_map(|o| match o {
|
||||
Op::Replace { collection, entity } if collection == "walls" => id_of(entity).map(String::from).into_iter().collect(),
|
||||
Op::Remove { collection, ids } if collection == "walls" => ids.clone(),
|
||||
_ => vec![],
|
||||
})
|
||||
.collect();
|
||||
ops.extend(walls);
|
||||
// [190] Ecken und T-Stösse: Enden bis zum Achsschnittpunkt verlängern/kürzen.
|
||||
ops.extend(wall_edit::connect_ops(root, p, &list("ids"), &touched));
|
||||
ops
|
||||
}
|
||||
"splitAt" => break_ops(root, s_arg(v, "id"), p_arg(v, "pt"), p_arg(v, "pt"), &mut ids),
|
||||
|
||||
@@ -1013,6 +1013,110 @@ pub fn join_ops(root: &Map<String, Value>, pr: &Project, ids_sel: &[String]) ->
|
||||
ops
|
||||
}
|
||||
|
||||
/// Ein Wandende, das beim Verbinden auf einen Achsschnittpunkt `x` rückt.
|
||||
struct Move {
|
||||
i: usize,
|
||||
at_end: bool,
|
||||
x: P,
|
||||
}
|
||||
|
||||
/// Lage des Achsschnittpunkts zu einer Wand: nahe einem Ende (Abstand, Ende?) oder im Innern.
|
||||
enum Spot {
|
||||
End(f64, bool),
|
||||
Inner,
|
||||
}
|
||||
|
||||
fn spot(ax: &Axis, x: P, tol: f64) -> Option<Spot> {
|
||||
let s = ax.local(x).0;
|
||||
let (d0, d1) = (s.abs(), (s - ax.len).abs());
|
||||
if d0.min(d1) <= tol {
|
||||
Some(Spot::End(d0.min(d1), d1 < d0))
|
||||
} else if s > 0.0 && s < ax.len {
|
||||
Some(Spot::Inner)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Verbinden von Ecken ([190], Archicad-Art): gewählte gerade Wände eines Geschosses, deren Achsen sich
|
||||
/// nicht sauber treffen, werden bis zum Achsschnittpunkt verlängert bzw. gekürzt. Zwei Enden nahe am
|
||||
/// Schnittpunkt ergeben eine L-Ecke (beide rücken), ein Ende nahe am Schnittpunkt, der im Innern der
|
||||
/// anderen Wand liegt, einen T-Stoss (nur das Ende rückt). Toleranz je Paar: grösser von 0.5 m und der
|
||||
/// doppelten Wanddicke. Jedes Ende rückt höchstens einmal (nahe Paare zuerst). Die Gehrung bzw. der
|
||||
/// Anschluss folgt aus den Enden (`joins.rs`); Öffnungen und Bemassung führt [`commit`] nach (wie
|
||||
/// Trim/Extend — Öffnungen bleiben im Plan stehen). Wände in `skip` (schon kollinear verkettet) und
|
||||
/// Bogenwände bleiben aussen vor. Parallele Wände (auch versetzte) werden nicht angefasst.
|
||||
pub fn connect_ops(root: &Map<String, Value>, pr: &Project, ids_sel: &[String], skip: &[String]) -> Vec<Op> {
|
||||
let sel: Vec<(&Wall, Axis)> = walls(pr)
|
||||
.iter()
|
||||
.filter(|w| editable(w) && ids_sel.contains(&w.id) && !skip.contains(&w.id))
|
||||
.filter_map(|w| Axis::of(w).filter(|a| a.arc.is_none()).map(|a| (w, a)))
|
||||
.collect();
|
||||
// Kandidaten: (Kosten, Bewegungen)
|
||||
let mut cands: Vec<(f64, Vec<Move>)> = Vec::new();
|
||||
for i in 0..sel.len() {
|
||||
for j in i + 1..sel.len() {
|
||||
let ((wi, ai), (wj, aj)) = (&sel[i], &sel[j]);
|
||||
if wi.floor_id != wj.floor_id {
|
||||
continue;
|
||||
}
|
||||
let den = cross(ai.u, aj.u);
|
||||
if den.abs() < 0.02 {
|
||||
continue;
|
||||
}
|
||||
let t = cross(P::new(aj.a.x - ai.a.x, aj.a.y - ai.a.y), aj.u) / den;
|
||||
let x = P::new(ai.a.x + ai.u.x * t, ai.a.y + ai.u.y * t);
|
||||
if !fin(x) {
|
||||
continue;
|
||||
}
|
||||
let thick = |w: &Wall| {
|
||||
let (lo, hi) = faces(pr, w);
|
||||
(hi - lo).abs()
|
||||
};
|
||||
let tol = 0.5_f64.max(2.0 * thick(wi).max(thick(wj)));
|
||||
match (spot(ai, x, tol), spot(aj, x, tol)) {
|
||||
(Some(Spot::End(da, ea)), Some(Spot::End(db, eb))) => cands.push((da + db, vec![Move { i, at_end: ea, x }, Move { i: j, at_end: eb, x }])),
|
||||
(Some(Spot::End(da, ea)), Some(Spot::Inner)) => cands.push((da, vec![Move { i, at_end: ea, x }])),
|
||||
(Some(Spot::Inner), Some(Spot::End(db, eb))) => cands.push((db, vec![Move { i: j, at_end: eb, x }])),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
cands.sort_by(|a, b| a.0.total_cmp(&b.0));
|
||||
let mut span: Vec<(f64, f64)> = sel.iter().map(|(_, a)| (0.0, a.len)).collect();
|
||||
let mut used: Vec<(usize, bool)> = Vec::new();
|
||||
for (_, moves) in &cands {
|
||||
if moves.iter().any(|m| used.contains(&(m.i, m.at_end))) {
|
||||
continue;
|
||||
}
|
||||
// Keine Wand darf dabei (fast) verschwinden.
|
||||
let next: Vec<(usize, (f64, f64))> = moves
|
||||
.iter()
|
||||
.map(|m| {
|
||||
let s = sel[m.i].1.local(m.x).0;
|
||||
(m.i, if m.at_end { (span[m.i].0, s) } else { (s, span[m.i].1) })
|
||||
})
|
||||
.collect();
|
||||
if next.iter().any(|(_, (a, b))| !(b - a >= 0.05)) {
|
||||
continue;
|
||||
}
|
||||
for (m, (i, sp)) in moves.iter().zip(next) {
|
||||
span[i] = sp;
|
||||
used.push((m.i, m.at_end));
|
||||
}
|
||||
}
|
||||
let plans: Vec<Plan> = sel
|
||||
.iter()
|
||||
.zip(&span)
|
||||
.filter(|((_, a), (s0, s1))| s0.abs() > EPS_S || (s1 - a.len).abs() > EPS_S)
|
||||
.map(|((w, a), sp)| Plan { src: w, ax: a.clone(), pieces: vec![*sp], follow_ends: true })
|
||||
.collect();
|
||||
if plans.is_empty() {
|
||||
return vec![];
|
||||
}
|
||||
commit(root, pr, &Edit { plans, extra: vec![] }, &mut IdGen::new("join"))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -1395,4 +1499,63 @@ mod tests {
|
||||
assert!(close(xy_of(&a["end"]), (5.0, 0.0)));
|
||||
assert!((a["bulge"].as_f64().unwrap() + 1.0).abs() < 1e-9);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn verbinden_l_ecke_mit_luecke_und_ueberstand() {
|
||||
// a endet 0.3 vor der Ecke, b beginnt 0.3 daneben; Fenster in a bei 1..2 und in b (ab Start).
|
||||
let r = project(
|
||||
vec![wall("a", (0.0, 0.0), (5.7, 0.0), None), wall("b", (6.0, 0.3), (6.0, 4.4), None)],
|
||||
vec![opening("o1", "a", 1.0, 1.0), opening("o2", "b", 1.0, 1.0)],
|
||||
vec![],
|
||||
);
|
||||
let n = apply(&r, connect_ops(&r, &typed(&r), &["a".into(), "b".into()], &[]));
|
||||
assert!(close(xy_of(&w_of(&n, "a")["end"]), (6.0, 0.0)));
|
||||
assert!(close(xy_of(&w_of(&n, "b")["start"]), (6.0, 0.0)));
|
||||
assert!(close(xy_of(&w_of(&n, "a")["start"]), (0.0, 0.0)));
|
||||
assert!(close(xy_of(&w_of(&n, "b")["end"]), (6.0, 4.4)));
|
||||
// Öffnungen bleiben im Plan stehen: o2 lag bei y = 1.3, jetzt Position 1.3 ab neuem Start.
|
||||
let o2 = arr(n.get("openings")).iter().find(|o| o["id"] == "o2").unwrap();
|
||||
assert!((o2["position"].as_f64().unwrap() - 1.3).abs() < 1e-9);
|
||||
let o1 = arr(n.get("openings")).iter().find(|o| o["id"] == "o1").unwrap();
|
||||
assert!((o1["position"].as_f64().unwrap() - 1.0).abs() < 1e-9);
|
||||
// Überstand: a ragt über b hinaus → gekürzt.
|
||||
let r = project(vec![wall("a", (0.0, 0.0), (6.4, 0.0), None), wall("b", (6.0, 0.0), (6.0, 4.0), None)], vec![], vec![]);
|
||||
let n = apply(&r, connect_ops(&r, &typed(&r), &["a".into(), "b".into()], &[]));
|
||||
assert!(close(xy_of(&w_of(&n, "a")["end"]), (6.0, 0.0)));
|
||||
// Schon sauber oder zu weit weg: nichts.
|
||||
let r = project(vec![wall("a", (0.0, 0.0), (6.0, 0.0), None), wall("b", (6.0, 0.0), (6.0, 4.0), None)], vec![], vec![]);
|
||||
assert!(connect_ops(&r, &typed(&r), &["a".into(), "b".into()], &[]).is_empty());
|
||||
let r = project(vec![wall("a", (0.0, 0.0), (4.0, 0.0), None), wall("b", (6.0, 0.0), (6.0, 4.0), None)], vec![], vec![]);
|
||||
assert!(connect_ops(&r, &typed(&r), &["a".into(), "b".into()], &[]).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn verbinden_t_stoss_und_kollinear_unberuehrt() {
|
||||
// a endet 0.3 vor der Querwand b (die weiter durchläuft): nur a rückt, b bleibt.
|
||||
let r = project(vec![wall("a", (0.0, 0.0), (5.7, 0.0), None), wall("b", (6.0, -3.0), (6.0, 3.0), None)], vec![opening("o", "a", 1.0, 1.0)], vec![]);
|
||||
let n = apply(&r, connect_ops(&r, &typed(&r), &["a".into(), "b".into()], &[]));
|
||||
assert!(close(xy_of(&w_of(&n, "a")["end"]), (6.0, 0.0)));
|
||||
assert!(close(xy_of(&w_of(&n, "b")["start"]), (6.0, -3.0)));
|
||||
assert!(close(xy_of(&w_of(&n, "b")["end"]), (6.0, 3.0)));
|
||||
assert_eq!(arr(n.get("openings")).len(), 1);
|
||||
// Kollinear und parallel versetzt: connect_ops fasst nichts an.
|
||||
let r = project(vec![wall("a", (0.0, 0.0), (4.0, 0.0), None), wall("b", (4.2, 0.0), (8.0, 0.0), None), wall("c", (4.0, 0.5), (8.0, 0.5), None)], vec![], vec![]);
|
||||
assert!(connect_ops(&r, &typed(&r), &["a".into(), "b".into(), "c".into()], &[]).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn verbinden_mehr_als_zwei_waende_und_ein_undo_schritt() {
|
||||
// U-Form mit Lücken: a–b und b–c.
|
||||
let r = project(
|
||||
vec![wall("a", (0.0, 0.0), (5.8, 0.0), None), wall("b", (6.0, 0.2), (6.0, 3.8), None), wall("c", (6.0, 4.0), (0.2, 4.0), None)],
|
||||
vec![],
|
||||
vec![],
|
||||
);
|
||||
let ops = connect_ops(&r, &typed(&r), &["a".into(), "b".into(), "c".into()], &[]);
|
||||
let n = apply(&r, ops);
|
||||
assert!(close(xy_of(&w_of(&n, "a")["end"]), (6.0, 0.0)));
|
||||
assert!(close(xy_of(&w_of(&n, "b")["start"]), (6.0, 0.0)));
|
||||
assert!(close(xy_of(&w_of(&n, "b")["end"]), (6.0, 4.0)));
|
||||
assert!(close(xy_of(&w_of(&n, "c")["start"]), (6.0, 4.0)));
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,10 @@ pub fn result(root: &Map<String, Value>, p: &Project, text: &str) -> Result<Grip
|
||||
if v.get("group").is_none() && v.get("cmd").and_then(Value::as_str) == Some("transform") {
|
||||
return Ok(crate::cmd_transform::transform_result(root, p, &parse(&v, "transform")?));
|
||||
}
|
||||
Ok(GripResult { ops: ops(root, p, text)?, notice: None })
|
||||
let ops = ops(root, p, text)?;
|
||||
// [190] Verbinden ohne Wirkung: Hinweis statt stillem Nichts.
|
||||
let notice = (ops.is_empty() && v.get("cmd").and_then(Value::as_str) == Some("join")).then_some("cmd.join.nothing");
|
||||
Ok(GripResult { ops, notice })
|
||||
}
|
||||
|
||||
/// Wie [`result`], als Antwort-JSON `{"ops": […], "notice": …}` (Zahlen mit Nicht-endlich-Marken).
|
||||
|
||||
@@ -64,8 +64,11 @@ import {
|
||||
useActiveToolKeys,
|
||||
useElementClipboardShortcut,
|
||||
useObjectSettingsShortcut,
|
||||
useFitShortcuts,
|
||||
useUndoRedoShortcut,
|
||||
} from "./state/useKeyboardShortcuts";
|
||||
import { registerSelectionActions } from "./state/selectionActions";
|
||||
import { fitView as fitView3d } from "./viewport/cameraBridge";
|
||||
import { useProjectFileActions } from "./state/useProjectFileActions";
|
||||
import { useModelImport } from "./state/useModelImport";
|
||||
import { useTextTarget } from "./state/useTextTarget";
|
||||
@@ -555,6 +558,11 @@ export default function App() {
|
||||
// Zoom-Buttons der Oberleiste an die montierte Plan-Ansicht weiterreichen.
|
||||
const fitPlan = () => planViewRef.current?.fit();
|
||||
const fitSelection = () => planViewRef.current?.fitSelection();
|
||||
// [190] Cmd/Ctrl+0 alles einpassen, Cmd/Ctrl+Shift+F auf Auswahl (ohne Plan-Ansicht: 3D-Kamera).
|
||||
const fitAllKey = () => (planViewRef.current ? planViewRef.current.fit() : fitView3d());
|
||||
const fitSelectionKey = () => (planViewRef.current ? planViewRef.current.fitSelection() : fitView3d());
|
||||
registerSelectionActions({ fitAll: fitAllKey, fitSelection: fitSelectionKey });
|
||||
useFitShortcuts(fitAllKey, fitSelectionKey, shortcutOverrides);
|
||||
// Papier-Massstab anwenden: gewählten Nenner merken UND den Plan-Zoom exakt
|
||||
// auf 1:N setzen (PlanView rechnet die viewBox aus N + Canvas + dpi).
|
||||
const applyScale = (n: number) => {
|
||||
|
||||
@@ -186,6 +186,11 @@ export function pasteElementClipboard(
|
||||
activeLevelId: string,
|
||||
): { ops: CoreOp[]; pastedIds: PastedIds } {
|
||||
const ops = documentFor(project).cmdOps({ cmd: "paste", clip, levelId: activeLevelId, stamp: uniqueStamp() });
|
||||
return { ops, pastedIds: addedIds(ops) };
|
||||
}
|
||||
|
||||
/** Neue ids je Bauteil-Art aus den `add`-Ops (Einfügen, Duplizieren). */
|
||||
export function addedIds(ops: readonly CoreOp[]): PastedIds {
|
||||
const pastedIds: PastedIds = {
|
||||
wallIds: [],
|
||||
drawingIds: [],
|
||||
@@ -202,7 +207,7 @@ export function pasteElementClipboard(
|
||||
const key = op.kind === "add" ? PASTED_KEY[op.collection] : undefined;
|
||||
if (op.kind === "add" && key) for (const e of op.items) pastedIds[key].push((e as { id: string }).id);
|
||||
}
|
||||
return { ops, pastedIds };
|
||||
return pastedIds;
|
||||
}
|
||||
|
||||
export { EMPTY_CLIPBOARD };
|
||||
@@ -121,6 +121,13 @@ export const de = {
|
||||
"menu.view.floorUp": "Geschoss höher",
|
||||
"menu.view.showSelection3d": "Auswahl in 3D zeigen",
|
||||
"menu.view.hideSelection3d": "Auswahl im 3D ausblenden",
|
||||
"menu.view.fitAll": "Alles einpassen",
|
||||
"menu.view.fitSelection": "Auf Auswahl einpassen",
|
||||
"menu.view.hideSelectionLayers": "Ebenen der Auswahl ausblenden",
|
||||
"menu.view.showAllLayers": "Alle Ebenen einblenden",
|
||||
"menu.edit.duplicate": "Duplizieren",
|
||||
"menu.edit.join": "Verbinden",
|
||||
"menu.edit.toggleLock": "Sperren / Entsperren",
|
||||
"menu.window": "Fenster",
|
||||
"menu.window.resources": "Ressourcen",
|
||||
"menu.window.settings": "Einstellungen",
|
||||
@@ -2306,6 +2313,7 @@ export const de = {
|
||||
// Alt+Klick). Labels für Befehlsleiste/Menüs.
|
||||
"edit.split.label": "Teilen",
|
||||
"edit.join.label": "Verbinden",
|
||||
"cmd.join.nothing": "Nichts zu verbinden: Wände treffen sich bereits oder liegen zu weit auseinander.",
|
||||
"edit.cutSegment.label": "Segment löschen",
|
||||
// Tab-Feld-Zyklus (Präzisionseingabe): geordnete Zahlenfelder je Schritt.
|
||||
"cmd.field.length": "Länge",
|
||||
@@ -3073,6 +3081,12 @@ export const de = {
|
||||
"shortcut.showSelection3d": "Auswahl in 3D zeigen (ohne Auswahl: alles)",
|
||||
"shortcut.objectSettings": "Einstellungen des gewählten Objekts öffnen (ohne Auswahl: Werkzeug-Voreinstellung)",
|
||||
"shortcut.hideSelection3d": "Auswahl im 3D ausblenden",
|
||||
"shortcut.duplicate": "Duplizieren (Kopie mit Versatz)",
|
||||
"shortcut.toggleLock": "Auswahl sperren / entsperren",
|
||||
"shortcut.hideSelectionLayers": "Ebenen der Auswahl ausblenden",
|
||||
"shortcut.showAllLayers": "Alle Ebenen einblenden",
|
||||
"shortcut.fitAll": "Alles einpassen",
|
||||
"shortcut.fitSelection": "Auf Auswahl einpassen",
|
||||
|
||||
"settings.section.update": "Update",
|
||||
"settings.update.autoCheck": "Automatisch nach Updates suchen",
|
||||
|
||||
@@ -120,6 +120,13 @@ export const en: Record<TranslationKey, string> = {
|
||||
"menu.view.floorUp": "Story up",
|
||||
"menu.view.showSelection3d": "Show selection in 3D",
|
||||
"menu.view.hideSelection3d": "Hide selection in 3D",
|
||||
"menu.view.fitAll": "Fit all",
|
||||
"menu.view.fitSelection": "Fit to selection",
|
||||
"menu.view.hideSelectionLayers": "Hide layers of selection",
|
||||
"menu.view.showAllLayers": "Show all layers",
|
||||
"menu.edit.duplicate": "Duplicate",
|
||||
"menu.edit.join": "Join",
|
||||
"menu.edit.toggleLock": "Lock / unlock",
|
||||
"menu.window": "Window",
|
||||
"menu.window.resources": "Resources",
|
||||
"menu.window.settings": "Settings",
|
||||
@@ -2294,6 +2301,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
// Alt+Click). Labels for the command line / menus.
|
||||
"edit.split.label": "Split",
|
||||
"edit.join.label": "Join",
|
||||
"cmd.join.nothing": "Nothing to join: walls already meet or are too far apart.",
|
||||
"edit.cutSegment.label": "Delete segment",
|
||||
// Tab field cycle (precision input): ordered numeric fields per step.
|
||||
"cmd.field.length": "Length",
|
||||
@@ -3060,6 +3068,12 @@ export const en: Record<TranslationKey, string> = {
|
||||
"shortcut.showSelection3d": "Show selection in 3D (no selection: everything)",
|
||||
"shortcut.objectSettings": "Open settings of the selected object (no selection: tool defaults)",
|
||||
"shortcut.hideSelection3d": "Hide selection in 3D",
|
||||
"shortcut.duplicate": "Duplicate (offset copy)",
|
||||
"shortcut.toggleLock": "Lock / unlock selection",
|
||||
"shortcut.hideSelectionLayers": "Hide layers of selection",
|
||||
"shortcut.showAllLayers": "Show all layers",
|
||||
"shortcut.fitAll": "Fit all",
|
||||
"shortcut.fitSelection": "Fit to selection",
|
||||
|
||||
"settings.section.update": "Update",
|
||||
"settings.update.autoCheck": "Check for updates automatically",
|
||||
|
||||
@@ -17,6 +17,7 @@ import { isTauriRuntime } from "./projectFile";
|
||||
import { t } from "../i18n";
|
||||
import { APP_VERSION } from "../ui/TopBar";
|
||||
import type { View3d, ViewType } from "../model/viewTypes";
|
||||
import type { SelectionActionId } from "../state/selectionActions";
|
||||
|
||||
/** Alle Aktionen, die die native Menüleiste auslösen kann. */
|
||||
export interface NativeAppMenuHandlers {
|
||||
@@ -63,6 +64,8 @@ export interface NativeAppMenuHandlers {
|
||||
onShowSelection3d?: () => void;
|
||||
/** [185] Auswahl im 3D ausblenden (Cmd+4). */
|
||||
onHideSelection3d?: () => void;
|
||||
/** [190] Auswahl-Aktionen mit Kürzel (Cmd+D/J/L, Cmd+0, Cmd+Shift+F/H/A), s. `state/selectionActions.ts`. */
|
||||
onSelectionAction?: (id: SelectionActionId) => void;
|
||||
|
||||
onToggleResources: () => void;
|
||||
onOpenSettings: () => void;
|
||||
@@ -276,6 +279,22 @@ export function useNativeAppMenu(
|
||||
redoItem,
|
||||
await PredefinedMenuItem.new({ item: "Separator" }),
|
||||
deleteItem,
|
||||
// [190] Archicad-Kürzel (dieselben laufen im Browser über `useSelectionActionShortcuts`).
|
||||
await MenuItem.new({
|
||||
text: t("menu.edit.duplicate"),
|
||||
accelerator: "CmdOrCtrl+D",
|
||||
action: () => handlersRef.current.onSelectionAction?.("duplicate"),
|
||||
}),
|
||||
await MenuItem.new({
|
||||
text: t("menu.edit.join"),
|
||||
accelerator: "CmdOrCtrl+J",
|
||||
action: () => handlersRef.current.onSelectionAction?.("join"),
|
||||
}),
|
||||
await MenuItem.new({
|
||||
text: t("menu.edit.toggleLock"),
|
||||
accelerator: "CmdOrCtrl+L",
|
||||
action: () => handlersRef.current.onSelectionAction?.("toggleLock"),
|
||||
}),
|
||||
await PredefinedMenuItem.new({ item: "Separator" }),
|
||||
await MenuItem.new({
|
||||
text: t("menu.native.move"),
|
||||
@@ -375,6 +394,28 @@ export function useNativeAppMenu(
|
||||
accelerator: "CmdOrCtrl+4",
|
||||
action: () => handlersRef.current.onHideSelection3d?.(),
|
||||
}),
|
||||
// [190] Einpassen und Ebenen ein-/ausblenden.
|
||||
await PredefinedMenuItem.new({ item: "Separator" }),
|
||||
await MenuItem.new({
|
||||
text: t("menu.view.fitAll"),
|
||||
accelerator: "CmdOrCtrl+0",
|
||||
action: () => handlersRef.current.onSelectionAction?.("fitAll"),
|
||||
}),
|
||||
await MenuItem.new({
|
||||
text: t("menu.view.fitSelection"),
|
||||
accelerator: "CmdOrCtrl+Shift+F",
|
||||
action: () => handlersRef.current.onSelectionAction?.("fitSelection"),
|
||||
}),
|
||||
await MenuItem.new({
|
||||
text: t("menu.view.hideSelectionLayers"),
|
||||
accelerator: "CmdOrCtrl+Shift+H",
|
||||
action: () => handlersRef.current.onSelectionAction?.("hideLayers"),
|
||||
}),
|
||||
await MenuItem.new({
|
||||
text: t("menu.view.showAllLayers"),
|
||||
accelerator: "CmdOrCtrl+Shift+A",
|
||||
action: () => handlersRef.current.onSelectionAction?.("showAllLayers"),
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ in `ProjectSync`.
|
||||
| `viewSnapshots.ts`, `viewSnapshotFolders.ts`, `viewTabs.ts` | Ausschnitte, ihre Ordner, Zeichnungs-Reiter (mit dem Projekt als `uiState.viewTabs` gesichert, [136]); Reiter-Arten und Navigations-Regeln ([182]) |
|
||||
| `tabNavigation.ts` | Navigator/Grundriss-/3D-Knöpfe/Layouts wählen den passenden Reiter (`openLevel`, `switchViewType`, `openLayoutTab`, [182]) |
|
||||
| `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 |
|
||||
| `autosave.ts`, `projectStore.ts`, `recentProjects.ts`, `startupGuard.ts` | Autosave und Wiederherstellen, IndexedDB, zuletzt geöffnet, Start-Protokoll |
|
||||
|
||||
@@ -47,6 +47,25 @@ describe("SHORTCUT_DEFS", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("[190] Archicad-Kürzel", () => {
|
||||
const combo = (id: string) => SHORTCUT_DEFS.find((d) => d.id === id)?.defaultCombo;
|
||||
it("belegt die neuen Kürzel ohne Kollision mit Werkzeug-Ziffern und Buchstaben", () => {
|
||||
expect(combo("duplicate")).toBe("mod+d");
|
||||
expect(combo("toggleLock")).toBe("mod+l");
|
||||
expect(combo("fitAll")).toBe("mod+0");
|
||||
expect(combo("fitSelection")).toBe("mod+shift+f");
|
||||
expect(combo("hideSelectionLayers")).toBe("mod+shift+h");
|
||||
expect(combo("showAllLayers")).toBe("mod+shift+a");
|
||||
// Kein Kürzel doppelt (auch nicht gegen m/s/d/q und 1–0).
|
||||
const all = SHORTCUT_DEFS.map((d) => d.defaultCombo);
|
||||
expect(new Set(all).size).toBe(all.length);
|
||||
// Cmd+D (Duplizieren) und d (Drehen) sind verschiedene Kombinationen.
|
||||
expect(matchesShortcut(key("d"), "duplicate", {})).toBe(false);
|
||||
expect(matchesShortcut(key("d", { metaKey: true }), "duplicate", {})).toBe(true);
|
||||
expect(matchesShortcut(key("d", { metaKey: true }), "transformRotate", {})).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("comboMatches", () => {
|
||||
it("erkennt Ctrl/Cmd+Z (mod+z)", () => {
|
||||
expect(comboMatches(key("z", { ctrlKey: true }), "mod+z")).toBe(true);
|
||||
|
||||
@@ -53,7 +53,13 @@ export type ShortcutId =
|
||||
| "floorUp"
|
||||
| "showSelection3d"
|
||||
| "hideSelection3d"
|
||||
| "objectSettings";
|
||||
| "objectSettings"
|
||||
| "duplicate"
|
||||
| "toggleLock"
|
||||
| "hideSelectionLayers"
|
||||
| "showAllLayers"
|
||||
| "fitAll"
|
||||
| "fitSelection";
|
||||
|
||||
export type ShortcutCategory =
|
||||
| "general"
|
||||
@@ -217,6 +223,13 @@ export const SHORTCUT_DEFS: ShortcutDef[] = [
|
||||
{ id: "hideSelection3d", category: "navigation", labelKey: "shortcut.hideSelection3d", defaultCombo: "mod+4" },
|
||||
// [189] Einstellungsdialog des gewählten Objekts (Archicad Cmd+T), hier schlicht „t".
|
||||
{ id: "objectSettings", category: "edit", labelKey: "shortcut.objectSettings", defaultCombo: "t", bareKeyOnly: true },
|
||||
// [190] Weitere Archicad-Kürzel (Esc = Auswahl leeren / Befehl abbrechen ist fest verdrahtet, s. oben).
|
||||
{ id: "duplicate", category: "edit", labelKey: "shortcut.duplicate", defaultCombo: "mod+d" },
|
||||
{ id: "toggleLock", category: "edit", labelKey: "shortcut.toggleLock", defaultCombo: "mod+l" },
|
||||
{ id: "hideSelectionLayers", category: "navigation", labelKey: "shortcut.hideSelectionLayers", defaultCombo: "mod+shift+h" },
|
||||
{ id: "showAllLayers", category: "navigation", labelKey: "shortcut.showAllLayers", defaultCombo: "mod+shift+a" },
|
||||
{ id: "fitAll", category: "navigation", labelKey: "shortcut.fitAll", defaultCombo: "mod+0" },
|
||||
{ id: "fitSelection", category: "navigation", labelKey: "shortcut.fitSelection", defaultCombo: "mod+shift+f" },
|
||||
];
|
||||
|
||||
const DEFS_BY_ID = new Map<ShortcutId, ShortcutDef>(SHORTCUT_DEFS.map((d) => [d.id, d]));
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// [190] Kleine Ablage für Aktionen, die mehrere Eingänge haben (Tastenkürzel im Fenster, natives Menü):
|
||||
// Duplizieren, Sperren, Verbinden, Ebenen aus-/einblenden, Einpassen. Die Aktionen leben dort, wo ihr Zustand
|
||||
// ist (`useSelectionCommands`, `App`) und tragen sich bei jedem Render ein; das native Menü (`useNativeMenu`)
|
||||
// ruft sie über `runSelectionAction`, ohne dass der Zustand durch die Menü-Verdrahtung gereicht werden muss.
|
||||
|
||||
export type SelectionActionId =
|
||||
| "duplicate"
|
||||
| "toggleLock"
|
||||
| "join"
|
||||
| "hideLayers"
|
||||
| "showAllLayers"
|
||||
| "fitAll"
|
||||
| "fitSelection";
|
||||
|
||||
const actions: Partial<Record<SelectionActionId, () => void>> = {};
|
||||
|
||||
/** Trägt (oder ersetzt) Aktionen ein; spätere Aufrufe gewinnen. */
|
||||
export function registerSelectionActions(a: Partial<Record<SelectionActionId, () => void>>): void {
|
||||
Object.assign(actions, a);
|
||||
}
|
||||
|
||||
/** Führt die Aktion aus, falls eingetragen (sonst nichts). */
|
||||
export function runSelectionAction(id: SelectionActionId): void {
|
||||
actions[id]?.();
|
||||
}
|
||||
@@ -397,6 +397,7 @@ export function useSplitJoinShortcut(
|
||||
runSplit: (ids: string[]) => void,
|
||||
setSelection: (patch: Partial<Selection>) => void,
|
||||
overrides: ShortcutOverrides,
|
||||
selectedWallIds: string[] = [],
|
||||
): void {
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
@@ -405,7 +406,8 @@ export function useSplitJoinShortcut(
|
||||
const isJoin = !isSplit && matchesShortcut(e, "join", overrides);
|
||||
if (!isSplit && !isJoin) return;
|
||||
const ids = selectedDrawingIds;
|
||||
if (ids.length === 0) return; // nur 2D-Auswahl bedient; Wände → no-op
|
||||
// Teilen: nur 2D-Auswahl. Verbinden ([190]): auch gewählte Wände (Ecken/T-Stösse schliessen).
|
||||
if (isSplit ? ids.length === 0 : ids.length + selectedWallIds.length === 0) return;
|
||||
e.preventDefault();
|
||||
|
||||
if (isSplit) {
|
||||
@@ -420,7 +422,7 @@ export function useSplitJoinShortcut(
|
||||
window.addEventListener("keydown", onKey);
|
||||
return () => window.removeEventListener("keydown", onKey);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [selectedDrawingIds, engine, overrides]);
|
||||
}, [selectedDrawingIds, selectedWallIds, engine, overrides]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -699,3 +701,56 @@ export function useObjectSettingsShortcut(
|
||||
return () => window.removeEventListener("keydown", onKey);
|
||||
}, [overrides, engineRef]);
|
||||
}
|
||||
|
||||
/**
|
||||
* [190] Auswahl-Aktionen mit Archicad-Kürzeln: Cmd/Ctrl+D = Duplizieren (Kopie mit Versatz), Cmd/Ctrl+L =
|
||||
* Sperren/Entsperren, Cmd/Ctrl+Shift+H = Ebenen der Auswahl ausblenden, Cmd/Ctrl+Shift+A = alle Ebenen
|
||||
* einblenden. Die Aktionen selbst liegen in `useSelectionCommands` (auch vom Kontextmenü gebraucht).
|
||||
*/
|
||||
export function useSelectionActionShortcuts(
|
||||
actions: { duplicate: () => void; toggleLock: () => void; hideLayers: () => void; showAllLayers: () => void },
|
||||
overrides: ShortcutOverrides,
|
||||
): void {
|
||||
const ref = useRef(actions);
|
||||
ref.current = actions;
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (isEditableTarget(e)) return;
|
||||
const fn = matchesShortcut(e, "duplicate", overrides)
|
||||
? ref.current.duplicate
|
||||
: matchesShortcut(e, "toggleLock", overrides)
|
||||
? ref.current.toggleLock
|
||||
: matchesShortcut(e, "hideSelectionLayers", overrides)
|
||||
? ref.current.hideLayers
|
||||
: matchesShortcut(e, "showAllLayers", overrides)
|
||||
? ref.current.showAllLayers
|
||||
: null;
|
||||
if (!fn) return;
|
||||
e.preventDefault();
|
||||
fn();
|
||||
};
|
||||
window.addEventListener("keydown", onKey);
|
||||
return () => window.removeEventListener("keydown", onKey);
|
||||
}, [overrides]);
|
||||
}
|
||||
|
||||
/** [190] Cmd/Ctrl+0 = alles einpassen, Cmd/Ctrl+Shift+F = auf Auswahl einpassen (Plan; im 3D-Reiter die Kamera). */
|
||||
export function useFitShortcuts(fitAll: () => void, fitSelection: () => void, overrides: ShortcutOverrides): void {
|
||||
const ref = useRef({ fitAll, fitSelection });
|
||||
ref.current = { fitAll, fitSelection };
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (isEditableTarget(e) && !(e.target as HTMLElement).classList.contains("cmdline-input")) return;
|
||||
const fn = matchesShortcut(e, "fitAll", overrides)
|
||||
? ref.current.fitAll
|
||||
: matchesShortcut(e, "fitSelection", overrides)
|
||||
? ref.current.fitSelection
|
||||
: null;
|
||||
if (!fn) return;
|
||||
e.preventDefault();
|
||||
fn();
|
||||
};
|
||||
window.addEventListener("keydown", onKey);
|
||||
return () => window.removeEventListener("keydown", onKey);
|
||||
}, [overrides]);
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import { t } from "../i18n";
|
||||
import { getState, type RootState } from "./appStore";
|
||||
import { openMeshFileDialog } from "./meshImportStore";
|
||||
import { openPointCloudFileDialog } from "./pointCloudStore";
|
||||
import { runSelectionAction } from "./selectionActions";
|
||||
import { hideSelectionIn3d, showSelectionIn3d, stepActiveFloor } from "./tabNavigation";
|
||||
import type { useDialogState } from "./useDialogState";
|
||||
import type { useProjectFileActions } from "./useProjectFileActions";
|
||||
@@ -163,6 +164,7 @@ export function useNativeMenu(opts: {
|
||||
onFloorStep: stepActiveFloor,
|
||||
onShowSelection3d: showSelectionIn3d,
|
||||
onHideSelection3d: hideSelectionIn3d,
|
||||
onSelectionAction: runSelectionAction,
|
||||
onToggleResources: () => toggleResources(),
|
||||
onOpenSettings: () => openSettings(),
|
||||
onOpenPanel: (panelId) => setLayout((l) => revealPanel(l, panelId)),
|
||||
|
||||
@@ -18,7 +18,10 @@ import { applyDrawingStyleOps, readDrawingStyle } from "../editors/matchProps";
|
||||
import { cutSegmentOps, splitOps } from "../editors/splitJoin";
|
||||
import type { BooleanResult } from "../editors/booleanOps";
|
||||
import type { EngineView } from "../commands/engine";
|
||||
import { clearKinds, fromIdLists, hasTransformable, isEmpty, toMembership } from "./selection";
|
||||
import { clearKinds, fromIdLists, hasTransformable, isEmpty, toMembership, toTransformSelection } from "./selection";
|
||||
import { registerSelectionActions } from "./selectionActions";
|
||||
import { transformOps } from "../tools/transform";
|
||||
import { addedIds, type PastedIds } from "../editors/elementClipboard";
|
||||
import { containingGroupId, EMPTY_MEMBERSHIP } from "./groupActions";
|
||||
import type { GroupMembership, MemberKind } from "./groupActions";
|
||||
import { isLocked, lockMembersOps } from "./objectLock";
|
||||
@@ -28,6 +31,7 @@ import {
|
||||
useBooleanOpsShortcut,
|
||||
useGroupShortcut,
|
||||
useSelectAllAndDeleteShortcut,
|
||||
useSelectionActionShortcuts,
|
||||
useSplitJoinShortcut,
|
||||
useTransformShortcuts,
|
||||
useViewNavigationShortcuts,
|
||||
@@ -192,7 +196,7 @@ export function useSelectionCommands(opts: {
|
||||
|
||||
// Ctrl/Cmd+S = Split, Ctrl/Cmd+J = Join der selektierten Drawing2D-Elemente —
|
||||
// siehe state/useKeyboardShortcuts.ts.
|
||||
useSplitJoinShortcut(selection.drawings, engine, runSplit, setSelection, shortcutOverrides);
|
||||
useSplitJoinShortcut(selection.drawings, engine, runSplit, setSelection, shortcutOverrides, selection.walls);
|
||||
|
||||
// Ctrl/Cmd+Shift+U/D/I = Boolean Vereinigung/Subtraktion/Schnitt — siehe
|
||||
// state/useKeyboardShortcuts.ts. (Ctrl/Cmd+C/V-Kopieren/Einfügen folgt weiter
|
||||
@@ -258,6 +262,20 @@ export function useSelectionCommands(opts: {
|
||||
const codes = new Set(selectionLayerCodes);
|
||||
applyChange((p) => fieldOps(p, "layers", setCategoriesVisible(p.layers, codes, false)));
|
||||
};
|
||||
// [190] Alle Ebenen wieder einblenden (Cmd/Ctrl+Shift+A, Gegenstück zu „Ebenen der Auswahl ausblenden").
|
||||
const showAllLayers = () =>
|
||||
applyChange((p) => fieldOps(p, "layers", setCategoriesVisible(p.layers, new Set(p.layers.map((l) => l.code)), true)));
|
||||
// [190] Cmd/Ctrl+D: gewählte Elemente duplizieren — Kopie mit Versatz (0.5 m rechts/unten), die Kopie ist danach gewählt.
|
||||
const duplicateSelection = () => {
|
||||
if (!hasTransformable(selection)) return;
|
||||
const out: { ids?: PastedIds } = {};
|
||||
applyChange((p) => {
|
||||
const ops = transformOps(p, toTransformSelection(selection), "move", [{ x: 0, y: 0 }, { x: 0.5, y: -0.5 }], "copy", 1);
|
||||
out.ids = addedIds(ops);
|
||||
return ops;
|
||||
});
|
||||
if (out.ids) setSelection(fromIdLists(out.ids));
|
||||
};
|
||||
const isolateSelectionLayers = () => {
|
||||
const { selectionLayerCodes } = menuState(true);
|
||||
if (selectionLayerCodes.length === 0) return;
|
||||
@@ -307,6 +325,24 @@ export function useSelectionCommands(opts: {
|
||||
);
|
||||
// [185] Cmd/Ctrl+3/4/5/6: Auswahl in 3D zeigen/ausblenden, Geschoss tiefer/höher.
|
||||
useViewNavigationShortcuts(shortcutOverrides);
|
||||
// [190] Verbinden (Cmd/Ctrl+J) auch aus dem nativen Menü: dieselbe Aktion wie das Tastenkürzel.
|
||||
const joinSelection = () => {
|
||||
if (selection.drawings.length + selection.walls.length === 0) return;
|
||||
engine.start("join");
|
||||
setSelection({ drawings: [], walls: [] });
|
||||
};
|
||||
registerSelectionActions({
|
||||
duplicate: duplicateSelection,
|
||||
toggleLock: toggleSelectionLock,
|
||||
join: joinSelection,
|
||||
hideLayers: hideSelectionLayers,
|
||||
showAllLayers,
|
||||
});
|
||||
// [190] Cmd/Ctrl+D/L, Cmd/Ctrl+Shift+H/A.
|
||||
useSelectionActionShortcuts(
|
||||
{ duplicate: duplicateSelection, toggleLock: toggleSelectionLock, hideLayers: hideSelectionLayers, showAllLayers },
|
||||
shortcutOverrides,
|
||||
);
|
||||
|
||||
// Doppelklick auf ein gruppiertes Element → Gruppe betreten (Isolation):
|
||||
// alles ausserhalb wird gedimmt/gesperrt gerendert (s. viewportContent.tsx/
|
||||
|
||||
Reference in new issue
Block a user