From e4641357fd2bdfa05249f1791a4cfad24144a193 Mon Sep 17 00:00:00 2001 From: karim Date: Wed, 21 Oct 2026 21:15:22 +0200 Subject: [PATCH] Schnitt/Ansicht: Fenster/Tueren waagrecht ziehen (Position entlang der Wirtswand), Decken im Blatt greifbar; Objekt-Info: Bauteil-Masse als Ausdehnung X/Y statt Breite/Hoehe, bei Oeffnungen keine bbox --- src/i18n/de.ts | 2 ++ src/i18n/en.ts | 2 ++ src/panels/AttributesPanel.tsx | 11 ++++++--- src/plan/PlanView.tsx | 35 ++++++++++++++++++++++++--- src/state/useGripEditing.ts | 44 +++++++++++++++++++++++++++++++--- src/tools/sheetSnapGeometry.ts | 5 ++-- src/views/viewportContent.tsx | 1 + 7 files changed, 89 insertions(+), 11 deletions(-) diff --git a/src/i18n/de.ts b/src/i18n/de.ts index b970eca5..738706e7 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -406,6 +406,8 @@ export const de = { "attr.size": "Maße", "attr.width": "Breite", "attr.height": "Höhe", + "attr.extentX": "Ausdehnung X", + "attr.extentY": "Ausdehnung Y", // Objekt-Info-Palette (ObjectInfoPanel) "objinfo.title": "Objekt-Info", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 9d7393b0..db5b57dc 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -404,6 +404,8 @@ export const en: Record = { "attr.size": "Size", "attr.width": "Width", "attr.height": "Height", + "attr.extentX": "Extent X", + "attr.extentY": "Extent Y", // Objekt-Info-Palette (ObjectInfoPanel) "objinfo.title": "Object Info", diff --git a/src/panels/AttributesPanel.tsx b/src/panels/AttributesPanel.tsx index aa273a33..292ae626 100644 --- a/src/panels/AttributesPanel.tsx +++ b/src/panels/AttributesPanel.tsx @@ -269,6 +269,7 @@ export function AttributesPanel() { const bboxW = sel.bbox.maxX - sel.bbox.minX; const bboxH = sel.bbox.maxY - sel.bbox.minY; + const isModelElement = !!(sel.wall || sel.ceiling || sel.roof || sel.stair || sel.room); return (
@@ -793,12 +794,16 @@ export function AttributesPanel() { {/* ── Masse (informativ, aus der bbox) — bei einer Layout-Annotation in Papier-mm statt Modell-Metern geführt (`formatM` passt nicht), daher hier weggelassen; Grösse steht bereits im Blatt-HUD. */} - {!isAnnotation && ( + {/* Bauteile: die bbox ist der GRUNDRISS-Umriss (X/Y), keine Höhe — als + „Ausdehnung X/Y" beschriften (Nutzer-Report: Fenster zeigte „Höhe + 0.34 m" = Wanddicke). Öffnungen tragen Breite/Höhe im eigenen + Abschnitt, dort entfällt die bbox ganz. */} + {!isAnnotation && !sel.opening && ( <>
{t("attr.size")}
- {t("attr.width")} + {t(isModelElement ? "attr.extentX" : "attr.width")} {formatM(bboxW)} - {t("attr.height")} + {t(isModelElement ? "attr.extentY" : "attr.height")} {formatM(bboxH)} )} diff --git a/src/plan/PlanView.tsx b/src/plan/PlanView.tsx index a7e9a4b1..513a3c55 100644 --- a/src/plan/PlanView.tsx +++ b/src/plan/PlanView.tsx @@ -572,6 +572,12 @@ export interface PlanViewProps { selectedDrawingIds?: string[]; /** Griff-Zieh-Treiber: Live-Bewegung (gesnappt) + Abschluss. */ gripHandlers?: GripHandlers; + /** + * Schnitt-/Ansichts-Blatt: zusätzlich gewählte Öffnungen und Decken per + * Körper-Zug greifbar (die App überträgt das Blatt-Delta entlang der + * Schnittlinie, s. useGripEditing `sheet`). Im Grundriss aus. + */ + sheetBodies?: boolean; /** * Farbe des Auswahlrahmens (Marquee-Ziehauswahl). Einstellbar im * Einstellungs-Fenster (State in ViewSlice); Default = Akzent „Yuyake". @@ -598,6 +604,16 @@ export interface PlanViewProps { } /** Treiber für das Ziehen von Editier-Griffen (von App bereitgestellt). */ +/** Gegriffener Körper beim Parallel-Verschieben. */ +export interface BodyTarget { + wallId?: string; + drawingId?: string; + /** Nur im Schnitt/in der Ansicht (`sheetBodies`). */ + openingId?: string; + /** Nur im Schnitt/in der Ansicht (`sheetBodies`). */ + ceilingId?: string; +} + export interface GripHandlers { onGripMove(index: number, raw: Vec2, pxPerMeter: number, mods: ToolMods): void; /** @@ -609,7 +625,7 @@ export interface GripHandlers { */ onMoveBody( delta: Vec2, - target?: { wallId?: string; drawingId?: string }, + target?: BodyTarget, mods?: ToolMods, ): void; /** @@ -672,6 +688,7 @@ export const PlanView = forwardRef( selectedWallIds, selectedCeilingIds, selectedOpeningIds, + sheetBodies = false, selectedStairIds, selectedRoomIds, selectedRoofIds, @@ -1251,7 +1268,7 @@ export const PlanView = forwardRef( const moveDrag = useRef<{ pointerId: number; last: Vec2; - target: { wallId?: string; drawingId?: string }; + target: BodyTarget; } | null>(null); // Transiente Stempel-Griff-Zieh-Daten: letzter Modellpunkt, gegen den das // inkrementelle Delta gebildet wird (verschiebt NUR den Raum-Stempel-Anker). @@ -1748,7 +1765,19 @@ export const PlanView = forwardRef( const grabbedBody = ( clientX: number, clientY: number, - ): { wallId?: string; drawingId?: string } | null => { + ): BodyTarget | null => { + // Schnitt/Ansicht: gewählte Öffnung bzw. Decke unter dem Cursor (Vorrang vor + // der Wirtswand, die im Blatt dahinter liegt). + if (sheetBodies) { + const hi = hitTest(clientX, clientY); + const p = hi !== null ? plan.primitives[hi] : null; + if (p && "openingId" in p && p.openingId && selectedOpeningIds?.includes(p.openingId)) { + return { openingId: p.openingId }; + } + if (p && p.kind === "polygon" && p.ceilingId && selectedCeilingIds?.includes(p.ceilingId)) { + return { ceilingId: p.ceilingId }; + } + } const selWalls = new Set(selectedWallIds ?? []); if (selWalls.size) { const hi = hitTest(clientX, clientY); diff --git a/src/state/useGripEditing.ts b/src/state/useGripEditing.ts index 02045454..0dc8472d 100644 --- a/src/state/useGripEditing.ts +++ b/src/state/useGripEditing.ts @@ -16,6 +16,7 @@ import type { DraftShape, SnapResult, SnapSettings, ToolDraft, ToolMods } from " import { applyAngleConstraint, computeSnap } from "../tools/snapping"; import { useCommandTabShortcut } from "./useKeyboardShortcuts"; import { sheetOwnerOutlines } from "../tools/sheetSnapGeometry"; +import type { BodyTarget } from "../plan/PlanView"; import type { CommandLineHandle } from "../ui/CommandLine"; import type { CommandEngine } from "../commands/engine"; @@ -497,6 +498,8 @@ export function useGripEditing(opts: { const pendingAreaGripRef = useRef<{ kind: "room" | "ceiling"; id: string; index: number; flat: number; pt: Vec2 } | null>(null); const pendingAreaMoveRef = useRef<{ kind: "ceiling" | "room" | "stair"; id: string; total: Vec2 } | null>(null); const pendingWallMoveRef = useRef<{ wallId: string; total: Vec2 } | null>(null); + /** Aufgeschobene Öffnungs-Verschiebung im Schnitt/in der Ansicht (neue `position`). */ + const pendingOpeningMoveRef = useRef<{ id: string; position: number } | null>(null); /** Laufendes Blatt-Delta (u, Meter) eines Zugs im Schnitt (s. moveInSheet). */ const sheetDuRef = useRef<{ id: string; du: number } | null>(null); const pendingBodyRef = useRef<{ drawingId: string; total: Vec2 } | null>(null); @@ -992,6 +995,9 @@ export function useGripEditing(opts: { moveGripOf(c.drawingId, c.wallId, c.index, { x: c.pos.x + pwm.total.x, y: c.pos.y + pwm.total.y }, scaleDenominator); } } + const pom = pendingOpeningMoveRef.current; + pendingOpeningMoveRef.current = null; + if (pom) updateOpening(pom.id, { position: pom.position }); const pa = pendingAreaMoveRef.current; pendingAreaMoveRef.current = null; if (pa && (pa.total.x !== 0 || pa.total.y !== 0)) { @@ -1082,6 +1088,7 @@ export function useGripEditing(opts: { pendingAreaGripRef.current = null; pendingAreaMoveRef.current = null; pendingWallMoveRef.current = null; + pendingOpeningMoveRef.current = null; sheetDuRef.current = null; pendingBodyRef.current = null; pendingEdgeRef.current = null; @@ -1098,7 +1105,7 @@ export function useGripEditing(opts: { const moveInSheet = ( sh: { levelId: string; uAxis: Vec2 }, delta: Vec2, - target?: { wallId?: string; drawingId?: string }, + target?: BodyTarget, ) => { if (target?.drawingId) { // 2D-Element der Ebene selbst: normales Körper-Verschieben im Blatt-Raum. @@ -1111,8 +1118,12 @@ export function useGripEditing(opts: { setDraft({ preview: bodyPreviewShapes(), vertices: [], snap: null }); return; } + if (target?.openingId) { + moveOpeningInSheet(sh, delta, target.openingId); + return; + } const wallId = target ? target.wallId ?? null : selectedWallId; - const ceilingId = !target && !wallId ? selectedCeilingId : null; + const ceilingId = target ? target.ceilingId ?? null : !wallId ? selectedCeilingId : null; const kind = wallId ? "wall" : ceilingId ? "ceiling" : null; const id = wallId ?? ceilingId; if (!kind || !id) return; @@ -1135,6 +1146,33 @@ export function useGripEditing(opts: { setDraft({ preview, vertices: [], snap: null }); }; + // Öffnung im Blatt waagrecht ziehen: Blatt-Delta (u) → Verschiebung entlang + // der Wirtswand (Δposition = du · (u-Achse · Wandrichtung)); bei einer quer + // geschnittenen Wand (Achse ⟂ Schnittlinie) bewegt sie sich darum kaum — + // richtig so, sie läuft ja in die Tiefe. Projekt erst beim Loslassen. + const moveOpeningInSheet = (sh: { levelId: string; uAxis: Vec2 }, delta: Vec2, openingId: string) => { + const op = (project.openings ?? []).find((o) => o.id === openingId); + const w = op && project.walls.find((x) => x.id === op.hostWallId); + if (!op || !w || op.locked) return; + const axis = normalize(sub(w.end, w.start)); + const factor = dot(sh.uAxis, axis); + if (Math.abs(factor) < 0.15) return; + const prevDu = sheetDuRef.current && sheetDuRef.current.id === openingId ? sheetDuRef.current.du : 0; + const len = Math.hypot(w.end.x - w.start.x, w.end.y - w.start.y); + // Auf die Wand klemmen (Öffnung bleibt drin) — auch die Vorschau. + const rawPos = op.position + (prevDu + delta.x) * factor; + const pos = Math.max(0, Math.min(len - op.width, rawPos)); + const du = (pos - op.position) / factor; + sheetDuRef.current = { id: openingId, du }; + pendingOpeningMoveRef.current = { id: openingId, position: pos }; + const preview: DraftShape[] = sheetOwnerOutlines(sh.levelId, "opening", openingId).map((pts) => ({ + kind: "poly", + pts: pts.map((q) => ({ x: q.x + du, y: q.y })), + closed: true, + })); + setDraft({ preview, vertices: [], snap: null }); + }; + const gripHandlers = { onGripMove: (index: number, raw: Vec2, pxPerMeter: number, mods: ToolMods) => { // Erster Move-Event nach dem Grab (gripDragInfoRef noch leer): die @@ -1217,7 +1255,7 @@ export function useGripEditing(opts: { }, onMoveBody: ( delta: Vec2, - target?: { wallId?: string; drawingId?: string }, + target?: BodyTarget, mods?: ToolMods, ) => { // Shift = Ortho: das Delta auf die dominante Achse (H/V) zwingen — diff --git a/src/tools/sheetSnapGeometry.ts b/src/tools/sheetSnapGeometry.ts index f91987de..fc58b535 100644 --- a/src/tools/sheetSnapGeometry.ts +++ b/src/tools/sheetSnapGeometry.ts @@ -60,7 +60,7 @@ export function snapSegmentsFromPrimitives(prims: readonly Primitive[]): SnapSeg } /** Bauteil-Art, deren Schnittflächen im Blatt gezogen werden können. */ -export type SheetOwnerKind = "wall" | "ceiling"; +export type SheetOwnerKind = "wall" | "ceiling" | "opening"; /** * Schnittflächen der Ebene `levelId` je Quell-Bauteil ablegen (aus den Plan- @@ -79,7 +79,8 @@ export function setSheetOwnerOutlines(levelId: string, prims: readonly Primitive }; for (const p of prims) { if (p.kind !== "polygon") continue; - if (p.wallId) add(`wall:${p.wallId}`, p.pts); + if (p.openingId) add(`opening:${p.openingId}`, p.pts); + else if (p.wallId) add(`wall:${p.wallId}`, p.pts); else if (p.ceilingId) add(`ceiling:${p.ceilingId}`, p.pts); } outlinesByLevel.set(levelId, map); diff --git a/src/views/viewportContent.tsx b/src/views/viewportContent.tsx index 0c81ad03..355bde8b 100644 --- a/src/views/viewportContent.tsx +++ b/src/views/viewportContent.tsx @@ -1331,6 +1331,7 @@ function SectionPlanView({ selectedDrawingId={selectedDrawingId} selectedDrawingIds={selectedDrawingIds} gripHandlers={gripHandlers} + sheetBodies /> {/* NACH PlanView gerendert (nicht als box-shadow auf .pane), damit der Isolations-Rahmen über der PlanView-SVG sichtbar bleibt. */}