[190] Verbinden schliesst Wandecken und T-Stösse; Kürzel Duplizieren, Sperren, Einpassen, Ebenen ein-/ausblenden

Cmd/Ctrl+J: gewählte nicht parallele Wände werden bis zum Achsschnittpunkt verlängert/gekürzt
(L-Ecke, T-Stoss, Toleranz 0.5 m bzw. 2 x Wanddicke), Öffnungen bleiben im Plan stehen, ein
Undo-Schritt, Hinweis wenn nichts zu verbinden war. Neue umbelegbare Kürzel Cmd+D, Cmd+L,
Cmd+0, Cmd+Shift+F/H/A, auch im nativen Menü.
This commit is contained in:
Claude committed 2026-11-11 21:02:31 +00:00
1 parent 6fb80570d0
commit 37e501d6b2
17 files changed
+485 -8

No files matched your search

+1
View File
@@ -67,6 +67,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 |
+19
View File
@@ -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);
+14 -1
View File
@@ -52,7 +52,13 @@ export type ShortcutId =
| "floorDown"
| "floorUp"
| "showSelection3d"
| "hideSelection3d";
| "hideSelection3d"
| "duplicate"
| "toggleLock"
| "hideSelectionLayers"
| "showAllLayers"
| "fitAll"
| "fitSelection";
export type ShortcutCategory =
| "general"
@@ -214,6 +220,13 @@ export const SHORTCUT_DEFS: ShortcutDef[] = [
{ id: "floorUp", category: "navigation", labelKey: "shortcut.floorUp", defaultCombo: "mod+6" },
{ id: "showSelection3d", category: "navigation", labelKey: "shortcut.showSelection3d", defaultCombo: "mod+3" },
{ id: "hideSelection3d", category: "navigation", labelKey: "shortcut.hideSelection3d", defaultCombo: "mod+4" },
// [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]));
+25
View File
@@ -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]?.();
}
+57 -2
View File
@@ -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]);
}
/**
@@ -672,3 +674,56 @@ export function useViewNavigationShortcuts(overrides: ShortcutOverrides): void {
return () => window.removeEventListener("keydown", onKey);
}, [overrides]);
}
/**
* [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]);
}
+2
View File
@@ -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";
@@ -160,6 +161,7 @@ export function useNativeMenu(opts: {
onFloorStep: stepActiveFloor,
onShowSelection3d: showSelectionIn3d,
onHideSelection3d: hideSelectionIn3d,
onSelectionAction: runSelectionAction,
onToggleResources: () => toggleResources(),
onOpenSettings: () => openSettings(),
onOpenPanel: (panelId) => setLayout((l) => revealPanel(l, panelId)),
+38 -2
View File
@@ -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/