Zusammenführung [291] Geländer

This commit is contained in:
Claude committed 2026-11-19 09:34:02 +00:00
commit eced0fa722
29 files changed
+1444 -209

No files matched your search

+6 -1
View File
@@ -12,12 +12,17 @@ export interface RailingInfo {
baseZ: number;
topZ: number;
height: number;
/** Stäbe und Pfosten (nur Art „Stäbe"). */
/** Stäbe und (sichtbare) Pfosten. */
bars: number;
posts: number;
/** Ansichtsfläche Länge × Höhe (m²). */
area: number;
closed: boolean;
/** [291] Zahl der Felder (zwischen zwei Pfosten) und Bindung der Achse. */
fields: number;
bound: "stair" | "edge" | null;
/** [291] Aufgelöste Achse (gebunden: aus Treppe bzw. Decke abgeleitet). */
axis: [number, number][];
}
/** Kennzahlen eines Geländers; `null` bei unbekannter Id oder unsinnigen Massen. */
+18 -4
View File
@@ -4,7 +4,9 @@
// 2) „Nächster Punkt ( Schliessen Zurück Art ):" → Punkt … Enter beendet (offen, ≥ 2 Punkte), „Schliessen" (C) oder
// ein Klick auf den Startpunkt schliesst den Zug (≥ 3 Punkte, Treppenauge/Galerie ringsum).
// Eine getippte Zahl setzt die Höhe (Vorgabe 1.00 m, SIA 358); sie bleibt über Aufrufe. Optionen (Klick wechselt): Art
// Stäbe/Glas/Brüstung/Lochblech. Fusshöhe, Handlauf, Stababstand, Dicke danach in der Objekt-Info.
// Stäbe/Glas/Brüstung/Lochblech; [291] „an Treppe/Kante“: der nächste Klick auf eine Treppe (nächste Wange) oder eine
// Deckenkante legt ein gebundenes Geländer an, das seinem Träger folgt (Auflösung im Kern, `railing::path`). Fusshöhe,
// Handlauf, Pfosten, Zwischenholme, Stababstand, Dicke danach in der Objekt-Info.
//
// Die Ops baut der Kern (`cmd_create.rs`, Befehl „railing"): Ebene „41" (Geländer), falls vorhanden, sonst die aktive.
//
@@ -23,7 +25,7 @@ const CLOSE_HIT = 0.08;
const KINDS: RailingKind[] = ["bars", "glass", "solid", "perforated"];
/** Vorgaben des Werkzeugs (modulweit, leben über Befehls-Instanzen hinweg). */
export const railingDefaults: { kind: RailingKind; height: number } = { kind: "bars", height: 1.0 };
export const railingDefaults: { kind: RailingKind; height: number; bind: boolean } = { kind: "bars", height: 1.0, bind: false };
const next = <T>(list: readonly T[], v: T): T => list[(list.indexOf(v) + 1) % list.length];
@@ -53,6 +55,9 @@ export const railingReq = (pts: Vec2[], closed: boolean) => ({
pts: pts.map(xy),
});
/** [291] Anfrage „an Treppe/Kante“: der Kern sucht die nächste Treppenwange bzw. Deckenkante zum Klick. */
export const railingBindReq = (pt: Vec2) => ({ cmd: "railing", kind: railingDefaults.kind, height: railingDefaults.height, bind: true, pts: [xy(pt)] });
const RAILING_DONE = { key: "cmd.railing.done", kind: "info" } as const;
const appendRailing = (pts: Vec2[], closed: boolean, ctx: CommandContext) => createMutation(ctx, railingReq(pts, closed));
@@ -91,12 +96,13 @@ export const railingCommand: Command = {
labelKey: "cmd.gelaender.label",
// Geländer stehen auf Geschossen — wie die Wand nur dort aktiv.
floorOnly: true,
prompt: (s) => ((s as RailState).phase === "next" ? "cmd.gelaender.next" : "cmd.gelaender.start"),
prompt: (s) => ((s as RailState).phase === "next" ? "cmd.gelaender.next" : railingDefaults.bind ? "cmd.gelaender.pickTarget" : "cmd.gelaender.start"),
accepts: (s) => ((s as RailState).phase === "next" ? ["point", "number", "option"] : ["point", "number", "option"]),
options: (s): CmdOption[] => {
const ps = s as RailState;
const kind: CmdOption = { id: "kind", labelKey: "cmd.gelaender.kind", value: t(`objinfo.railing.kind.${railingDefaults.kind}` as TranslationKey) };
if (ps.phase !== "next") return [kind];
const bind: CmdOption = { id: "bind", labelKey: "cmd.gelaender.bind", value: t(railingDefaults.bind ? "cmd.gelaender.bindOn" : "cmd.gelaender.bindOff") };
if (ps.phase !== "next") return [kind, bind];
return ps.points.length >= 3 ? [CLOSE, UNDO, kind] : [UNDO, kind];
},
init: (): RailIdle => ({ phase: "start", lastPoint: null }),
@@ -116,6 +122,10 @@ export const railingCommand: Command = {
railingDefaults.kind = next(KINDS, railingDefaults.kind);
return [s, { draft: draft() }];
}
if (input.id === "bind" && s.phase !== "next") {
railingDefaults.bind = !railingDefaults.bind;
return [s, { draft: null }];
}
if (s.phase !== "next") return [s, { draft: null }];
if (input.id === "undo") {
const pts = s.points.slice(0, -1);
@@ -132,6 +142,10 @@ export const railingCommand: Command = {
if (input.kind !== "point") return [s, { draft: draft() }];
const pt = input.point;
// [291] An Treppe/Kante: ein Klick genügt, der Kern bindet an die nächste Wange bzw. Deckenkante.
if (s.phase !== "next" && railingDefaults.bind) {
return [{ phase: "start", lastPoint: null } as RailIdle, { draft: null, done: true, commit: createMutation(ctx, railingBindReq(pt)), notice: RAILING_DONE }];
}
if (s.phase !== "next") {
const ns: RailDrawing = { phase: "next", points: [pt], cursor: pt, lastPoint: pt };
return [ns, { draft: railingDraft([pt], pt) }];
+28
View File
@@ -2233,6 +2233,10 @@ export const de = {
"cmd.gelaender.start": "Erster Punkt des Geländers (Zahl = Höhe in m):",
"cmd.gelaender.next": "Nächster Punkt (Enter beendet, Zahl = Höhe):",
"cmd.gelaender.kind": "Art",
"cmd.gelaender.bind": "an Treppe/Kante",
"cmd.gelaender.bindOn": "ja",
"cmd.gelaender.bindOff": "nein",
"cmd.gelaender.pickTarget": "Treppe (Wange) oder Deckenkante anklicken:",
"objinfo.kind.railing": "Geländer",
"objinfo.kind.beam": "Träger",
"objinfo.railing.many": "{n} Geländer",
@@ -2258,6 +2262,30 @@ export const de = {
"objinfo.railing.counts": "Stäbe / Pfosten",
"objinfo.railing.points": "Punkte",
"objinfo.railing.locked": "Gesperrt — Werte nicht änderbar.",
"objinfo.railing.handrailProfile": "Handlauf-Profil",
"objinfo.railing.profile.rect": "rechteckig",
"objinfo.railing.profile.round": "rund",
"objinfo.railing.handrailHeight": "Handlaufhöhe",
"objinfo.railing.posts": "Pfosten",
"objinfo.railing.postSpacing": "Pfostenabstand (max.)",
"objinfo.railing.postSize": "Pfostenquerschnitt",
"objinfo.railing.midRails": "Zwischenholme",
"objinfo.railing.fieldNo": "Feld Nr.",
"objinfo.railing.fieldKind": "Füllung des Feldes",
"objinfo.railing.fieldKindDefault": "wie Geländer",
"objinfo.railing.fields": "Felder",
"objinfo.railing.bound": "Gebunden",
"objinfo.railing.bound.stair": "Treppe",
"objinfo.railing.bound.edge": "Deckenkante",
"objinfo.railing.boundMissing": "fehlt (Punkte gelten)",
"objinfo.railing.stairSide": "Treppenseite",
"objinfo.railing.side.left": "links",
"objinfo.railing.side.right": "rechts",
"objinfo.railing.edgeIndex": "Kante Nr.",
"objinfo.railing.edgeCount": "Anzahl Kanten",
"objinfo.railing.edgeInset": "Abstand zur Kante",
"objinfo.railing.unbind": "Lösen",
"objinfo.railing.unbindHint": "Geländer vom Träger lösen: die Punkte bleiben als freie Achse",
"newProject.layer.41": "Geländer",
"objinfo.kind.tree": "Baum",
"objinfo.tree.many": "{n} Bäume",
+28
View File
@@ -2221,6 +2221,10 @@ export const en: Record<TranslationKey, string> = {
"cmd.gelaender.start": "First railing point (number = height in m):",
"cmd.gelaender.next": "Next point (Enter finishes, number = height):",
"cmd.gelaender.kind": "Type",
"cmd.gelaender.bind": "to stair/edge",
"cmd.gelaender.bindOn": "on",
"cmd.gelaender.bindOff": "off",
"cmd.gelaender.pickTarget": "Click a stair (side) or slab edge:",
"objinfo.kind.railing": "Railing",
"objinfo.kind.beam": "Beam",
"objinfo.railing.many": "{n} railings",
@@ -2246,6 +2250,30 @@ export const en: Record<TranslationKey, string> = {
"objinfo.railing.counts": "Bars / posts",
"objinfo.railing.points": "Points",
"objinfo.railing.locked": "Locked — values cannot be changed.",
"objinfo.railing.handrailProfile": "Handrail profile",
"objinfo.railing.profile.rect": "rectangular",
"objinfo.railing.profile.round": "round",
"objinfo.railing.handrailHeight": "Handrail height",
"objinfo.railing.posts": "Posts",
"objinfo.railing.postSpacing": "Post spacing (max.)",
"objinfo.railing.postSize": "Post size",
"objinfo.railing.midRails": "Intermediate rails",
"objinfo.railing.fieldNo": "Panel no.",
"objinfo.railing.fieldKind": "Panel infill",
"objinfo.railing.fieldKindDefault": "as railing",
"objinfo.railing.fields": "Panels",
"objinfo.railing.bound": "Attached",
"objinfo.railing.bound.stair": "Stair",
"objinfo.railing.bound.edge": "Slab edge",
"objinfo.railing.boundMissing": "missing (points apply)",
"objinfo.railing.stairSide": "Stair side",
"objinfo.railing.side.left": "left",
"objinfo.railing.side.right": "right",
"objinfo.railing.edgeIndex": "Edge no.",
"objinfo.railing.edgeCount": "Number of edges",
"objinfo.railing.edgeInset": "Distance from edge",
"objinfo.railing.unbind": "Detach",
"objinfo.railing.unbindHint": "Detach the railing from its host: the points stay as a free axis",
"newProject.layer.41": "Railings",
"cmd.circlestotrees.label": "Convert circles to trees",
"objinfo.kind.tree": "Tree",
+54
View File
@@ -3608,6 +3608,46 @@ export type Railing = {
handrail?: boolean;
/** Handlauf: Durchmesser (m, Vorgabe 0.04). */
handrailSize?: number;
/** [291] Handlauf: Profil (rechteckig = Vorgabe, rund). */
handrailProfile?: RailingProfile;
/** [291] Handlauf: Höhe der Oberkante über dem Fuss (m); fehlt = `height` (Handlauf obenauf). */
handrailHeight?: number;
/**
* [291] Pfosten setzen (an Ecken und Enden automatisch, dazwischen höchstens `postSpacing`); fehlt = bei Stäben ja, sonst nein.
*/
posts?: boolean;
/**
* [291] Pfosten: grösster Achsabstand (m, Vorgabe 1.20); die Felder einer Strecke werden gleich lang.
*/
postSpacing?: number;
/** [291] Pfosten: Querschnitt (Kantenlänge, m, Vorgabe 0.03). */
postSize?: number;
/**
* [291] Anzahl Zwischenholme (waagrechte Stäbe zwischen Fuss und Handlauf, gleich verteilt; Vorgabe 0).
*/
midRails?: number;
/**
* [291] Füllung je Feld (Feld = Abschnitt zwischen zwei Pfosten, längs der Achse ab 0 gezählt); fehlt ein Feld, gilt `kind`.
*/
fields?: Array<RailingField>;
/**
* [291] Gebunden an eine Treppe: die Achse folgt der Treppenwange `stairSide` und steigt mit dem Lauf (Höhe
* lotrecht über der Stufenkante); `points` dient dann nur als Ersatz, falls die Treppe fehlt.
*/
stairId?: string;
/** [291] Seite der Treppe in Laufrichtung (Vorgabe links). */
stairSide?: RailingSide;
/**
* [291] Gebunden an eine Deckenkante: die Achse folgt den Kanten `edgeIndex` … `edgeIndex + edgeCount − 1` des
* Deckenumrisses, um `edgeInset` nach innen versetzt; der Fuss steht auf der Deckenoberkante (+ `baseOffset`).
*/
ceilingId?: string;
/** [291] Erste Kante (Kante i läuft von outline[i] zu outline[i+1]). */
edgeIndex?: number;
/** [291] Anzahl aufeinanderfolgender Kanten (Vorgabe 1; alle Kanten = geschlossen ringsum). */
edgeCount?: number;
/** [291] Abstand der Achse von der Deckenkante nach innen (m, Vorgabe 0.05). */
edgeInset?: number;
/** Optionales Bauteil (Component) für Füllung/Farbe, v. a. der massiven Brüstung. */
componentId?: string;
/** Optionale Übersteuerung der Strichfarbe; sonst gilt die Kategorie-Farbe. */
@@ -3618,12 +3658,26 @@ export type Railing = {
designOption?: DesignOptionRef;
};
/** [291] Füllung eines Feldes (zwischen zwei Pfosten) abweichend von `Railing.kind`. */
export type RailingField = {
/** Feld-Nummer längs der Achse (ab 0). */
index: number;
/** Füllung dieses Feldes. */
kind: RailingKind;
};
/**
* Art der Füllung eines Geländers ([279]): Stäbe (Rundstahl/Flachstahl, lotrecht), Glas (Ganzglas-Brüstung),
* massive Brüstung (Mauer/Beton) oder Lochblech.
*/
export type RailingKind = "bars" | "glass" | "solid" | "perforated";
/** [291] Profil des Handlaufs. */
export type RailingProfile = "rect" | "round";
/** [291] Seite einer Treppe in Laufrichtung (gebundenes Geländer). */
export type RailingSide = "left" | "right";
/**
* Referenzlinien-Regel: setzt die `referenceLine`-Eigenschaft bei passenden
* Wänden einheitlich (Vectorworks-Stil).
+102 -6
View File
@@ -1,12 +1,15 @@
// Abschnitt „Geländer" der Objekt-Info ([279]): Art (Stäbe, Glas, Brüstung, Lochblech), Höhe (Vorgabe 1.00 m nach
// SIA 358), Fusshöhe über dem Geschoss (z. B. auf einer Balkonplatte), Handlauf, Stababstand/-querschnitt, Dicke und
// Bauteil der Brüstung. Kennzahlen (Länge, Stäbe, Pfosten) rechnet der Kern (`analysis/railingInfo.ts`). Jede Änderung
// ist ein Undo-Schritt (der Kern prüft die Op); bei mehreren gewählten Geländern wirken die Felder auf alle.
// Bauteil der Brüstung. [291] Aufbau je Feld: Pfosten (an/aus, grösster Abstand, Querschnitt), Handlauf (Profil, Höhe),
// Zwischenholme, Füllung je Feld; Bindung an Treppe (Seite) oder Deckenkante (Kante, Anzahl, Abstand) und „Lösen“ (die
// aufgelöste Achse wird zur freien Polylinie). Kennzahlen (Länge, Felder, Stäbe, Pfosten) rechnet der Kern
// (`analysis/railingInfo.ts`). Jede Änderung ist ein Undo-Schritt (der Kern prüft die Op); bei mehreren gewählten
// Geländern wirken die Felder auf alle.
//
// Gerufen von `ObjectInfoPanel`.
import { useMemo } from "react";
import type { Railing, RailingKind } from "../../model/types";
import { useMemo, useState } from "react";
import type { Railing, RailingField, RailingKind, RailingProfile, RailingSide } from "../../model/types";
import { useStore } from "../../state/appStore";
import { t, type TranslationKey } from "../../i18n";
import { patchItem } from "../../core";
@@ -17,6 +20,10 @@ import { DimensionField } from "./fields";
const KINDS: RailingKind[] = ["bars", "glass", "solid", "perforated"];
/** Vorgabe des Handlaufs je Art, wenn nichts angegeben ist (Kern `railing::has_handrail`). */
const handrailDefault = (kind: RailingKind): boolean => kind === "bars" || kind === "glass";
/** [291] Vorgabe der Pfosten je Art (Kern `railing::has_posts`). */
const postsDefault = (kind: RailingKind): boolean => kind === "bars";
const PROFILES: RailingProfile[] = ["rect", "round"];
const SIDES: RailingSide[] = ["left", "right"];
export function RailingSection({ ids }: { ids: readonly string[] }) {
const project = useStore((st) => st.project);
@@ -24,6 +31,7 @@ export function RailingSection({ ids }: { ids: readonly string[] }) {
const list = (project.railings ?? []).filter((x) => ids.includes(x.id));
const rail = list[0];
const info = useMemo(() => (rail ? railingInfo(project, rail.id) : null), [project, rail]);
const [fieldNo, setFieldNo] = useState(0);
if (!rail) return <div className="objinfo-panel"><div className="objinfo-empty">{t("objinfo.empty")}</div></div>;
const locked = !!rail.locked;
const set = (patch: Partial<Railing>, all = false) =>
@@ -33,6 +41,24 @@ export function RailingSection({ ids }: { ids: readonly string[] }) {
const bars = rail.kind === "bars";
const panel = rail.kind === "glass" || rail.kind === "solid" || rail.kind === "perforated";
const dflt = rail.kind === "glass" ? 0.02 : rail.kind === "solid" ? 0.15 : 0.004;
const posts = rail.posts ?? postsDefault(rail.kind);
const stair = rail.stairId ? (project.stairs ?? []).find((x) => x.id === rail.stairId) : undefined;
const ceiling = rail.ceilingId ? (project.ceilings ?? []).find((x) => x.id === rail.ceilingId) : undefined;
const fieldKind = (rail.fields ?? []).find((f) => f.index === fieldNo)?.kind ?? "";
const setFieldKind = (k: string) => {
const rest: RailingField[] = (rail.fields ?? []).filter((f) => f.index !== fieldNo);
const next = k ? [...rest, { index: fieldNo, kind: k as RailingKind }].sort((a, b) => a.index - b.index) : rest;
set({ fields: next.length ? next : undefined });
};
// Lösen: die aufgelöste Achse (Kern) bleibt als freie Polylinie; ohne Kern-Achse die gespeicherten Punkte.
const unbind = () => {
const axis = info?.axis.map(([x, y]) => ({ x, y }));
const closed = axis && axis.length >= 4 && Math.hypot(axis[0].x - axis[axis.length - 1].x, axis[0].y - axis[axis.length - 1].y) < 1e-6;
set({
stairId: undefined, stairSide: undefined, ceilingId: undefined, edgeIndex: undefined, edgeCount: undefined, edgeInset: undefined,
...(axis && axis.length >= 2 ? { points: closed ? axis.slice(0, -1) : axis, closed: closed || undefined } : {}),
});
};
return (
<div className="objinfo-panel objinfo-railing">
<div className="objinfo-head">
@@ -60,6 +86,37 @@ export function RailingSection({ ids }: { ids: readonly string[] }) {
<input type="checkbox" checked={handrail} disabled={locked} onChange={(e) => set({ handrail: e.target.checked }, true)} data-testid="railing-handrail" />
</div>
{handrail && <DimensionField label={t("objinfo.railing.handrailSize")} value={rail.handrailSize ?? 0.04} min={0.02} onCommit={(v) => set({ handrailSize: v })} />}
{handrail && (
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.railing.handrailProfile")}</span>
<Dropdown
value={rail.handrailProfile ?? "rect"}
onChange={(v) => set({ handrailProfile: v === "rect" ? undefined : (v as RailingProfile) }, true)}
options={PROFILES.map((v) => ({ value: v, label: t(`objinfo.railing.profile.${v}` as TranslationKey) }))}
title={t("objinfo.railing.handrailProfile")}
width={150}
/>
</div>
)}
{handrail && <DimensionField label={t("objinfo.railing.handrailHeight")} value={rail.handrailHeight ?? rail.height} min={0.1} onCommit={(v) => set({ handrailHeight: Math.abs(v - rail.height) < 1e-9 ? undefined : v }, true)} />}
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.railing.posts")}</span>
<input type="checkbox" checked={posts} disabled={locked} onChange={(e) => set({ posts: e.target.checked }, true)} data-testid="railing-posts" />
</div>
{posts && <DimensionField label={t("objinfo.railing.postSpacing")} value={rail.postSpacing ?? 1.2} min={0.2} onCommit={(v) => set({ postSpacing: v }, true)} />}
{posts && <DimensionField label={t("objinfo.railing.postSize")} value={rail.postSize ?? 0.03} min={0.01} onCommit={(v) => set({ postSize: v }, true)} />}
<DimensionField label={t("objinfo.railing.midRails")} value={rail.midRails ?? 0} min={0} unit="" step={1} digits={0} onCommit={(v) => set({ midRails: Math.round(v) > 0 ? Math.min(20, Math.round(v)) : undefined }, true)} />
<DimensionField label={t("objinfo.railing.fieldNo")} value={fieldNo} min={0} unit="" step={1} digits={0} onCommit={(v) => setFieldNo(Math.max(0, Math.round(v)))} />
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.railing.fieldKind")}</span>
<Dropdown
value={fieldKind}
onChange={setFieldKind}
options={[{ value: "", label: t("objinfo.railing.fieldKindDefault") }, ...KINDS.map((v) => ({ value: v, label: t(`objinfo.railing.kind.${v}` as TranslationKey) }))]}
title={t("objinfo.railing.fieldKind")}
width={150}
/>
</div>
{bars && <DimensionField label={t("objinfo.railing.barSpacing")} value={rail.barSpacing ?? 0.12} min={0.03} onCommit={(v) => set({ barSpacing: v })} />}
{bars && <DimensionField label={t("objinfo.railing.barSize")} value={rail.barSize ?? 0.014} min={0.004} onCommit={(v) => set({ barSize: v })} />}
{panel && <DimensionField label={t("objinfo.railing.thickness")} value={rail.thickness ?? dflt} min={0.002} onCommit={(v) => set({ thickness: v })} />}
@@ -75,9 +132,44 @@ export function RailingSection({ ids }: { ids: readonly string[] }) {
/>
</div>
)}
{(rail.stairId || rail.ceilingId) && <div className="objinfo-section-label">{t("objinfo.railing.bound")}</div>}
{rail.stairId && (
<>
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.railing.bound.stair")}</span>
<span className="objinfo-fval" data-testid="railing-bound">{stair ? stair.id : t("objinfo.railing.boundMissing")}</span>
</div>
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.railing.stairSide")}</span>
<Dropdown
value={rail.stairSide ?? "left"}
onChange={(v) => set({ stairSide: v as RailingSide })}
options={SIDES.map((v) => ({ value: v, label: t(`objinfo.railing.side.${v}` as TranslationKey) }))}
title={t("objinfo.railing.stairSide")}
width={150}
/>
</div>
</>
)}
{rail.ceilingId && (
<>
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.railing.bound.edge")}</span>
<span className="objinfo-fval" data-testid="railing-bound">{ceiling ? ceiling.id : t("objinfo.railing.boundMissing")}</span>
</div>
<DimensionField label={t("objinfo.railing.edgeIndex")} value={rail.edgeIndex ?? 0} min={0} unit="" step={1} digits={0} onCommit={(v) => set({ edgeIndex: Math.max(0, Math.round(v)) })} />
<DimensionField label={t("objinfo.railing.edgeCount")} value={rail.edgeCount ?? 1} min={1} unit="" step={1} digits={0} onCommit={(v) => set({ edgeCount: Math.round(v) > 1 ? Math.round(v) : undefined })} />
<DimensionField label={t("objinfo.railing.edgeInset")} value={rail.edgeInset ?? 0.05} min={-1} onCommit={(v) => set({ edgeInset: v })} />
</>
)}
{(rail.stairId || rail.ceilingId) && (
<button type="button" className="objinfo-btn" disabled={locked} onClick={unbind} title={t("objinfo.railing.unbindHint")} data-testid="railing-unbind">
{t("objinfo.railing.unbind")}
</button>
)}
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.railing.closed")}</span>
<input type="checkbox" checked={rail.closed === true} disabled={locked || rail.points.length < 3} onChange={(e) => set({ closed: e.target.checked || undefined })} data-testid="railing-closed" />
<input type="checkbox" checked={rail.closed === true} disabled={locked || rail.points.length < 3 || !!rail.stairId || !!rail.ceilingId} onChange={(e) => set({ closed: e.target.checked || undefined })} data-testid="railing-closed" />
</div>
{info && (
<>
@@ -85,12 +177,16 @@ export function RailingSection({ ids }: { ids: readonly string[] }) {
<span className="objinfo-flabel">{t("objinfo.railing.length")}</span>
<span className="objinfo-fval" data-testid="railing-length">{info.length.toFixed(2)} m</span>
</div>
{bars && (
{(bars || posts) && (
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.railing.counts")}</span>
<span className="objinfo-fval">{info.bars} / {info.posts}</span>
</div>
)}
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.railing.fields")}</span>
<span className="objinfo-fval" data-testid="railing-fields">{info.fields}</span>
</div>
</>
)}
<div className="objinfo-field">
+6
View File
@@ -23,4 +23,10 @@ describe("[279] Geländer-Griffe", () => {
expect(railingGripPatch(base, -1, { x: 4, y: 1 })).toEqual({});
expect(railingGripPatch(base, 0, { x: NaN, y: 1 })).toEqual({});
});
it("[291] gebunden an Treppe oder Deckenkante: keine Griffe", () => {
expect(railingGripPoints({ ...base, stairId: "t1" })).toEqual([]);
expect(railingGripPoints({ ...base, ceilingId: "d1", edgeIndex: 0 })).toEqual([]);
expect(railingGripPatch({ ...base, stairId: "t1" }, 1, { x: 4, y: 1 })).toEqual({});
});
});
+8 -3
View File
@@ -1,17 +1,22 @@
// [279] Griffe eines Geländers im Grundriss: jeder Punkt der Achse (verschieben). Die Punkte folgen dem Modell
// (`Railing.points`); ein Ziehen ersetzt genau diesen Punkt, Höhe, Art und Teilung bleiben.
// (`Railing.points`); ein Ziehen ersetzt genau diesen Punkt, Höhe, Art und Teilung bleiben. [291] An Treppe oder
// Deckenkante gebundene Geländer haben keine Griffe (die Achse folgt dem Träger; lösen in der Objekt-Info).
//
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
import type { Railing, Vec2 } from "../model/types";
/** Griff-Punkte: alle Punkte der Achse in Reihenfolge. */
/** An Treppe oder Deckenkante gebunden ([291]): die Achse leitet der Kern ab, Griffe gäbe es nur zum Schein. */
const isBound = (r: Railing): boolean => !!r.stairId || !!r.ceilingId;
/** Griff-Punkte: alle Punkte der Achse in Reihenfolge; gebundene Geländer haben keine ([291], die Achse folgt dem Träger). */
export function railingGripPoints(r: Railing): Vec2[] {
if (isBound(r)) return [];
return r.points.map((p) => ({ x: p.x, y: p.y }));
}
/** Änderung beim Ziehen des Griffs `index` an `pt`; unbekannter Index ändert nichts. */
export function railingGripPatch(r: Railing, index: number, pt: Vec2): Partial<Railing> {
if (!Number.isFinite(pt.x) || !Number.isFinite(pt.y) || index < 0 || index >= r.points.length) return {};
if (isBound(r) || !Number.isFinite(pt.x) || !Number.isFinite(pt.y) || index < 0 || index >= r.points.length) return {};
return { points: r.points.map((p, i) => (i === index ? { x: pt.x, y: pt.y } : p)) };
}