[144] Öffnungen verschieben: gewählte Tür/Fenster gleiten beim Verschieben entlang der Wand; Objekt-Info Abstand ab Wandende; Griff-Länge entlang der Wand

This commit is contained in:
Claude committed 2026-11-06 00:50:33 +00:00
1 parent 92a5cdbef7
commit d4f93ca3f3
19 files changed
+393 -12

No files matched your search

+3 -1
View File
@@ -137,6 +137,7 @@ export function toCommandSelection(sel: Selection): CommandSelection {
roofIds: sel.roofs,
stairIds: sel.stairs,
roomIds: sel.rooms,
openingIds: sel.openings,
};
}
@@ -155,7 +156,8 @@ export function hasTransformable(sel: Selection): boolean {
sel.ceilings.length > 0 ||
sel.roofs.length > 0 ||
sel.stairs.length > 0 ||
sel.rooms.length > 0
sel.rooms.length > 0 ||
sel.openings.length > 0
);
}
+2
View File
@@ -211,6 +211,8 @@ export interface OpeningInfo {
hostWallName: string;
/** Abstand vom Wand-Startpunkt (Meter). */
position: number;
/** Achslänge der geraden Wirtswand (fehlt bei Bogenwand) — „Abstand ab Wandende“ ([144]). */
wallLength?: number;
width: number;
height: number;
/** Brüstungshöhe (Meter); 0 bei Türen. */
+6
View File
@@ -22,6 +22,10 @@ declare global {
polylines: (prefix: string) => { id: string; pts: { x: number; y: number }[] }[];
/** [137] Gewählte 2D-Elemente und Gruppen. */
selected: () => { drawings: string[]; groups: string[]; all: string };
/** [144] Öffnungen (id, Wirtswand, Lage ab Wandanfang). */
openings: () => { id: string; hostWallId: string; position: number }[];
/** [144] Auswahl setzen (wie ein Klick), z. B. `{ openings: ["D1"] }`. */
select: (patch: Record<string, string[]>) => void;
};
}
}
@@ -46,6 +50,8 @@ export function installTestHooks(): void {
getState().project.drawings2d.flatMap((d) => (d.geom.shape === "line" ? [{ a: d.geom.a, b: d.geom.b }] : [])),
polylines: (prefix) =>
getState().project.drawings2d.flatMap((d) => (d.id.startsWith(prefix) && d.geom.shape === "polyline" ? [{ id: d.id, pts: d.geom.pts }] : [])),
openings: () => (getState().project.openings ?? []).map((o) => ({ id: o.id, hostWallId: o.hostWallId, position: o.position })),
select: (patch) => getState().setSelection(patch),
selected: () => ({ drawings: [...getState().selection.drawings], groups: [...getState().selection.groups], all: JSON.stringify(getState().selection) }),
};
}
+1
View File
@@ -44,6 +44,7 @@ function sheetOnlySelection(level: DrawingLevel, sel: TransformSelection): Trans
roofIds: [],
stairIds: [],
roomIds: [],
openingIds: [],
};
}
+25
View File
@@ -380,6 +380,18 @@ export function useGripEditing(opts: {
return out;
})();
// Einheitsrichtung der Wirtswand, wenn eine Wandöffnung gewählt ist (sonst null).
const openingWallDir = (): Vec2 | null => {
if (!selectedOpeningId) return null;
const op = (project.openings ?? []).find((o) => o.id === selectedOpeningId);
const w = op && !op.hostRoofId && !op.hostCeilingId ? project.walls.find((x) => x.id === op.hostWallId) : undefined;
if (!w) return null;
const dx = w.end.x - w.start.x;
const dy = w.end.y - w.start.y;
const len = Math.hypot(dx, dy);
return len > 1e-9 ? { x: dx / len, y: dy / len } : null;
};
// Nachbar-Griff-Index INNERHALB desselben Elements (für Anker-Auflösung).
// null = kein Nachbar möglich (Einzelgriff-Element wie Kreis/Öffnung/Treppe).
const neighborGripIndex = (index: number): number | null => {
@@ -564,6 +576,10 @@ export function useGripEditing(opts: {
// Gemeinsam genutzt vom Tab-Feld-Controller UND dem Shift-Ortho-Bezug UND
// dem Cursor-HUD (Länge/Winkel-Anzeige neben der Maus).
const resolveGripAnchor = (index: number): Vec2 | null => {
// Wandöffnung ([144]): einziger Griff (Mitte) — Bezug ist seine Lage beim Greifen, die getippte
// Länge ist also die Verschiebung entlang der Wand.
const wallOpening = openingWallDir();
if (wallOpening) return gripOriginRef.current ?? grips[index] ?? null;
// Bei Mehrfachauswahl gehört der gezogene Griff evtl. NICHT dem einzeln
// selektierten `selectedDrawing`, sondern einem anderen Element der
// Auswahl — das eigentliche Element über `gripOwners` auflösen.
@@ -626,7 +642,16 @@ export function useGripEditing(opts: {
if (!info) return;
const anchor = resolveGripAnchor(info.index);
if (!anchor) return; // ohne Anker keine polare Eingabe möglich
const wallDir = openingWallDir();
setGripEdit((prev) => {
if (!prev && wallDir) {
// Öffnung ([144]): Richtung = Wandrichtung (bzw. Gegenrichtung, je nach bisherigem Zug), damit
// die getippte Länge genau die Strecke entlang der Wand ist.
const g = grips[info.index];
const along = (g.x - anchor.x) * wallDir.x + (g.y - anchor.y) * wallDir.y;
const deg = (Math.atan2(wallDir.y, wallDir.x) * 180) / Math.PI + (along < 0 ? 180 : 0);
return { anchor, active: "length", locks: { length: Math.abs(along), angle: ((deg % 360) + 360) % 360 } };
}
if (!prev) {
const { length, angleDeg: angle } = gripPolar(anchor, grips[info.index]);
return { anchor, active: "length", locks: { length, angle } };
+2 -2
View File
@@ -582,8 +582,8 @@ export function useTransformShortcuts(
return;
}
// Transformierbar sind Wände, 2D-Zeichnungen, extrudierte Körper, Stützen,
// Decken/Dächer/Treppen/Räume. Öffnungen laufen bewusst NICHT hierüber, sondern über ihre
// eigenen Bewegpunkte (Grips) — sie sind wandgebunden. Ohne Auswahl: still.
// Decken/Dächer/Treppen/Räume und ([144]) Öffnungen — die gleiten beim Verschieben entlang ihrer
// Wand; Drehen/Spiegeln lehnt die Engine für sie allein mit Hinweis ab. Ohne Auswahl: still.
if (!hasTransformSelection) return;
const op = matchesShortcut(e, "transformMove", overrides)
? "move"
+5 -2
View File
@@ -949,8 +949,11 @@ export function usePanelHostBase(opts: {
updateOpening(selection.id, { sillHeight });
},
onSetOpeningPosition: (position) => {
if (selection?.kind === "opening" && position >= 0)
updateOpening(selection.id, { position });
if (selection?.kind !== "opening" || !Number.isFinite(position)) return;
// [144] In der Wand halten: auf [0, Wandlänge − Breite] klemmen (Bogenwand: nur ≥ 0).
const o = selection.opening;
const max = o?.wallLength != null ? Math.max(0, o.wallLength - o.width) : Infinity;
updateOpening(selection.id, { position: Math.min(max, Math.max(0, position)) });
},
onSetOpeningSwingAngle: (swingAngle) => {
if (selection?.kind === "opening" && swingAngle > 0)