[36][34][38] Merge: View Range je Geschoss, Ansichtsvorlagen, assoziative Bemassung

Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
Claude committed 2026-10-30 06:16:00 +00:00
commit 31caeea299
29 files changed
+1281 -40

No files matched your search

+11
View File
@@ -1435,6 +1435,15 @@ export default function App() {
applyChange((p) => patchItems(p, "drawings2d", selectedDrawingIds, (d) => ({ ...d, noPrint: next })));
};
// „Bemassung lösen" ([38]): gewählte Bemassungen mit Bezügen auf Modell-Elemente.
const attachedDimensionIds = selectedDrawingIds.filter((id) => {
const g = project.drawings2d.find((d) => d.id === id)?.geom;
return g?.shape === "dimension" && !!g.refs?.some(Boolean);
});
const detachDimensions = () => {
if (attachedDimensionIds.length) applyChange((p) => cmdMutation({ cmd: "dimdetach", ids: attachedDimensionIds }).toOps(p));
};
// Ctrl/Cmd+G / Ctrl/Cmd+Shift+G = Gruppieren/Auflösen (Vectorworks-artig,
// s. state/groupActions.ts). `applyGroupSelection` setzt nach dem Gruppieren/
// Auflösen alle betroffenen Auswahl-Kanäle auf einen Schlag.
@@ -4164,6 +4173,8 @@ export default function App() {
isolateSelectionLayers,
selectionAllNoPrint: !!selectionAllNoPrint,
toggleSelectionNoPrint,
attachedDimensionCount: attachedDimensionIds.length,
detachDimensions,
bringToFront: () => reorderDrawings(selectedDrawingIds, "front"),
bringForward: () => reorderDrawings(selectedDrawingIds, "forward"),
sendBackward: () => reorderDrawings(selectedDrawingIds, "backward"),
+32
View File
@@ -0,0 +1,32 @@
// Bemassung lösen ([38]) — entfernt die Bezüge der gewählten Bemassungen auf Modell-Elemente
// (assoziative Bemassung, `dim_assoc.rs`): die Punkte bleiben, wo sie sind, folgen aber nicht mehr.
// Sofort-Befehl ohne Punkt-Eingabe (wie Auflösen): wirkt auf die bestehende Auswahl.
import { cmdMutation } from "../../core";
import type { Command, CommandContext, CommandResult, CommandState } from "../types";
const done = (): [CommandState, CommandResult] => [
{ phase: "idle", lastPoint: null },
{ draft: null, done: true },
];
export const dimdetachCommand: Command = {
name: "dimdetach",
labelKey: "cmd.dimdetach.label",
prompt: () => "cmd.dimdetach.label",
accepts: () => [],
options: () => [],
init: (): CommandState => ({ phase: "idle", lastPoint: null }),
autoRun: (ctx: CommandContext): CommandResult => {
const sel = ctx.selection;
const ids = sel.drawingIds?.length ? sel.drawingIds : sel.drawingId ? [sel.drawingId] : [];
if (ids.length === 0) return { draft: null, done: true };
return { draft: null, done: true, commit: cmdMutation({ cmd: "dimdetach", ids }) };
},
onInput: (): [CommandState, CommandResult] => done(),
onMove: (state): [CommandState, CommandResult] => [state, { draft: null }],
onConfirm: (): [CommandState, CommandResult] => done(),
onCancel: (): [CommandState, CommandResult] => done(),
};
+17 -9
View File
@@ -24,6 +24,7 @@
import { segmentHud } from "../../tools/types";
import type {
CmdInput,
Command,
CommandContext,
CommandField,
@@ -76,6 +77,8 @@ interface DimStart extends CommandState {
interface DimNext extends CommandState {
phase: "next";
pts: Vec2[];
/** Gefangene Klickpunkte (roh, vor der Projektion) — daran hängt die Kette assoziativ ([38]). */
snaps?: Vec2[];
cursor: Vec2 | null;
/** ID der bearbeiteten Kette (Ergänzen-Modus) — null = neue Kette. */
editId: string | null;
@@ -83,6 +86,7 @@ interface DimNext extends CommandState {
interface DimOffset extends CommandState {
phase: "offset";
pts: Vec2[];
snaps?: Vec2[];
cursor: Vec2 | null;
editId: string | null;
}
@@ -117,8 +121,12 @@ function offsetDraft(ctx: CommandContext, pts: Vec2[], at: Vec2 | null): ToolDra
}
/** Commit (Kern): Kette (Nullstrecken entfernt) mit Abstand bzw. Seite eines Punkts; `editId` ändert eine bestehende. */
const commitChain = (ctx: CommandContext, pts: Vec2[], offset: number | null, side: Vec2 | null, editId: string | null) =>
createMutation(ctx, { cmd: "dimension", pts, offset, side, editId });
const commitChain = (ctx: CommandContext, pts: Vec2[], offset: number | null, side: Vec2 | null, editId: string | null, snaps: Vec2[] = []) =>
createMutation(ctx, { cmd: "dimension", pts, offset, side, editId, snaps });
/** Gefangene Punkte samt neuem Klick (nur wenn er gefangen wurde). */
const withSnap = (snaps: Vec2[] | undefined, input: CmdInput): Vec2[] =>
input.kind === "point" && input.snap ? [...(snaps ?? []), input.point] : (snaps ?? []);
const idle = (): [CommandState, CommandResult] => [
{ phase: "start", lastPoint: null },
@@ -147,11 +155,11 @@ export const dimensionCommand: Command = {
if (input.id === "undo") {
const pts = s.pts.slice(0, -1);
if (pts.length === 0) return [{ phase: "start", lastPoint: null }, { draft: null }];
const ns: DimNext = { phase: "next", pts, cursor: s.cursor, editId: s.editId, lastPoint: pts[pts.length - 1] };
const ns: DimNext = { phase: "next", pts, cursor: s.cursor, editId: s.editId, lastPoint: pts[pts.length - 1], snaps: s.snaps };
return [ns, { draft: chainDraft(pts, s.cursor) }];
}
if (input.id === "finish" && s.pts.length >= 2) {
const ns: DimOffset = { phase: "offset", pts: s.pts, cursor: s.cursor, editId: s.editId, lastPoint: s.lastPoint };
const ns: DimOffset = { phase: "offset", pts: s.pts, cursor: s.cursor, editId: s.editId, lastPoint: s.lastPoint, snaps: s.snaps };
return [ns, { draft: offsetDraft(ctx, s.pts, null) }];
}
return [s, { draft: chainDraft(s.pts, s.cursor) }];
@@ -166,13 +174,13 @@ export const dimensionCommand: Command = {
const existing = selectedChain(ctx);
const pts = existing ? insertIntoChain(ctx, existing.pts, pt) : [pt];
const editId = existing ? existing.id : null;
const ns: DimNext = { phase: "next", pts, cursor: pt, editId, lastPoint: pt };
const ns: DimNext = { phase: "next", pts, cursor: pt, editId, lastPoint: pt, snaps: withSnap([], input) };
return [ns, { draft: chainDraft(pts, pt) }];
}
// Ab dem dritten Punkt (bzw. jedem weiteren Klick im Ergänzen-Modus):
// auf die durch Punkt 1/2 festgelegte Gerade projizieren/einsortieren.
const pts = s.pts.length >= 2 ? insertIntoChain(ctx, s.pts, pt) : [...s.pts, pt];
const ns: DimNext = { phase: "next", pts, cursor: pt, editId: s.editId, lastPoint: pt };
const ns: DimNext = { phase: "next", pts, cursor: pt, editId: s.editId, lastPoint: pt, snaps: withSnap(s.snaps, input) };
return [ns, { draft: chainDraft(pts, pt) }];
}
@@ -180,8 +188,8 @@ export const dimensionCommand: Command = {
if (input.kind !== "number" && input.kind !== "point") return [s, { draft: offsetDraft(ctx, s.pts, null) }];
const commit =
input.kind === "number"
? commitChain(ctx, s.pts, input.value, null, s.editId)
: commitChain(ctx, s.pts, null, input.point, s.editId);
? commitChain(ctx, s.pts, input.value, null, s.editId, s.snaps)
: commitChain(ctx, s.pts, null, input.point, s.editId, s.snaps);
return [{ phase: "start", lastPoint: null }, { draft: null, done: true, commit }];
},
@@ -210,7 +218,7 @@ export const dimensionCommand: Command = {
onConfirm: (state, ctx): [CommandState, CommandResult] => {
const s = state as DimState;
if (s.phase === "next" && s.pts.length >= 2) {
const ns: DimOffset = { phase: "offset", pts: s.pts, cursor: s.cursor, editId: s.editId, lastPoint: s.lastPoint };
const ns: DimOffset = { phase: "offset", pts: s.pts, cursor: s.cursor, editId: s.editId, lastPoint: s.lastPoint, snaps: s.snaps };
return [ns, { draft: offsetDraft(ctx, s.pts, null) }];
}
return idle();
+4
View File
@@ -45,6 +45,7 @@ import { mirrorCommand } from "./cmds/mirror";
import { rotateCommand } from "./cmds/rotate";
import { scaleCommand } from "./cmds/scale";
import { explodeCommand } from "./cmds/explode";
import { dimdetachCommand } from "./cmds/dimdetach";
import { autodimCommand } from "./cmds/autodim";
import { alignCommand } from "./cmds/align";
import { joinCommand } from "./cmds/join";
@@ -111,6 +112,7 @@ export const COMMANDS: Record<string, Command> = {
rotate: rotateCommand,
scale: scaleCommand,
explode: explodeCommand,
dimdetach: dimdetachCommand,
autodim: autodimCommand,
align: alignCommand,
join: joinCommand,
@@ -229,6 +231,8 @@ export const ALIASES: Record<string, string> = {
skalieren: "scale",
x: "explode",
aufloesen: "explode",
bml: "dimdetach",
bemassungloesen: "dimdetach",
ab: "autodim",
aussenbemassung: "autodim",
al: "align",
+27 -9
View File
@@ -286,9 +286,10 @@ export class ProjectDocument {
}
return { problems };
}
const project = applyOps(base, ops, core().doc_last_hits(this.handle));
const extra = this.lastExtra();
const project = this.withExtra(applyOps(base, ops, core().doc_last_hits(this.handle)), extra);
this.mirror = project;
this.rememberCommit(base, project, ops);
this.rememberCommit(base, project, extra.length ? [...ops, ...extra] : ops);
return { project };
}
@@ -306,9 +307,10 @@ export class ProjectDocument {
const r = fromMarkedJson<{ ops: CoreOp[]; notice?: string } | { problems: string[] }>(out);
if ("problems" in r) return r;
if (r.ops.length === 0) return { project: base, ops: r.ops, notice: r.notice };
const project = applyOps(base, r.ops, core().doc_last_hits(this.handle));
const extra = this.lastExtra();
const project = this.withExtra(applyOps(base, r.ops, core().doc_last_hits(this.handle)), extra);
this.mirror = project;
return { project, ops: r.ops, notice: r.notice };
return { project, ops: extra.length ? [...r.ops, ...extra] : r.ops, notice: r.notice };
}
/**
@@ -354,9 +356,10 @@ export class ProjectDocument {
const r = fromMarkedJson<{ ops: CoreOp[] } | { problems: string[] }>(out);
if ("problems" in r) return r;
if (r.ops.length === 0) return { project: base, ops: r.ops };
const project = applyOps(base, r.ops);
const extra = this.lastExtra();
const project = this.withExtra(applyOps(base, r.ops), extra);
this.mirror = project;
return { project, ops: r.ops };
return { project, ops: extra.length ? [...r.ops, ...extra] : r.ops };
}
/**
@@ -371,10 +374,12 @@ export class ProjectDocument {
if (out.startsWith("\u0001")) throw new Error(out.slice(1));
const r = fromMarkedJson<({ ops: CoreOp[] } & R) | { problems: string[] }>(out);
if ("problems" in r) return r;
const project = r.ops.length ? applyOps(base, r.ops) : base;
const extra = r.ops.length ? this.lastExtra() : [];
const project = r.ops.length ? this.withExtra(applyOps(base, r.ops), extra) : base;
this.mirror = project;
this.rememberCommit(base, project, r.ops);
return { ...r, project };
const ops = extra.length ? [...r.ops, ...extra] : r.ops;
this.rememberCommit(base, project, ops);
return { ...r, ops, project };
}
/**
@@ -504,6 +509,19 @@ export class ProjectDocument {
}
/** Nach einer angenommenen Änderung: grossen, eigenen (nicht verschmolzenen) Schritt merken. */
/**
* Nachführ-Ops des letzten Commits ([38], assoziative Bemassung): der Kern hat sie im selben
* Undo-Schritt angewendet, die Leseansicht übernimmt sie hinter den eigenen Ops.
*/
private lastExtra(): CoreOp[] {
const json = this.handle ? core().doc_last_extra(this.handle) : "";
return json ? (JSON.parse(json) as CoreOp[]) : [];
}
private withExtra(project: Project, extra: readonly CoreOp[]): Project {
return extra.length ? applyOps(project, extra) : project;
}
private rememberCommit(base: Project, project: Project, ops: readonly CoreOp[]): void {
const [seq, , merged] = this.historySeqs();
if (!merged) this.steps.remember(seq, base, project, ops);
+13
View File
@@ -826,6 +826,17 @@ export const de = {
// ── Extrusions-Attribute (truck-Integration, Object-Info-Panel) ─────────
"objinfo.sectionLine.section": "Schnittlinie",
"objinfo.detailRef.section": "Detail-/Schnitt-Verweis",
"objinfo.dimRefs.section": "Assoziative Bemassung",
"objinfo.dimRefs.point": "Punkt {n}",
"objinfo.dimRefs.free": "frei",
"objinfo.dimRefs.lost": "Bezug verloren ({id})",
"objinfo.dimRefs.lostHint": "Rot markierte Punkte haben ihren Bezug verloren und bleiben an der letzten Lage.",
"objinfo.dimRefs.feature.wall": "Wand",
"objinfo.dimRefs.feature.opening": "Öffnung",
"objinfo.dimRefs.feature.vertex": "Eckpunkt",
"objinfo.dimRefs.feature.edge": "Kante",
"objinfo.dimRefs.feature.center": "Mittelpunkt",
"objinfo.dimRefs.feature.intersection": "Wandecke",
"objinfo.detailRef.label": "Bezeichner",
"objinfo.detailRef.sheet": "Blatt",
"objinfo.detailRef.sheet.none": "Kein Verweis",
@@ -1797,6 +1808,7 @@ export const de = {
"cmd.align.distX": "waagrecht verteilen",
"cmd.align.distY": "senkrecht verteilen",
"cmd.explode.label": "Auflösen",
"cmd.dimdetach.label": "Bemassung lösen",
"cmd.autodim.label": "Aussenbemassung",
"cmd.scale.label": "Skalieren",
"cmd.scale.base": "Basispunkt:",
@@ -2851,6 +2863,7 @@ export const de = {
"history.cmd.dimension": "Bemassung",
"history.cmd.ellipse": "Ellipse zeichnen",
"history.cmd.explode": "Auflösen",
"history.cmd.dimdetach": "Bemassung lösen",
"history.cmd.extend": "Verlängern",
"history.cmd.extrude": "Extrusion",
"history.cmd.fillet": "Verrundung",
+13
View File
@@ -822,6 +822,17 @@ export const en: Record<TranslationKey, string> = {
// ── Extruded solid attributes (truck integration, object info panel) ────
"objinfo.sectionLine.section": "Section line",
"objinfo.detailRef.section": "Detail/section reference",
"objinfo.dimRefs.section": "Associative dimension",
"objinfo.dimRefs.point": "Point {n}",
"objinfo.dimRefs.free": "free",
"objinfo.dimRefs.lost": "Reference lost ({id})",
"objinfo.dimRefs.lostHint": "Points marked red lost their reference and stay at their last position.",
"objinfo.dimRefs.feature.wall": "Wall",
"objinfo.dimRefs.feature.opening": "Opening",
"objinfo.dimRefs.feature.vertex": "Vertex",
"objinfo.dimRefs.feature.edge": "Edge",
"objinfo.dimRefs.feature.center": "Centre",
"objinfo.dimRefs.feature.intersection": "Wall corner",
"objinfo.detailRef.label": "Label",
"objinfo.detailRef.sheet": "Sheet",
"objinfo.detailRef.sheet.none": "No link",
@@ -1785,6 +1796,7 @@ export const en: Record<TranslationKey, string> = {
"cmd.align.distX": "Distribute horizontally",
"cmd.align.distY": "Distribute vertically",
"cmd.explode.label": "Explode",
"cmd.dimdetach.label": "Detach dimension",
"cmd.autodim.label": "Exterior dimensions",
"cmd.scale.label": "Scale",
"cmd.scale.base": "Base point:",
@@ -2837,6 +2849,7 @@ export const en: Record<TranslationKey, string> = {
"history.cmd.dimension": "Dimension",
"history.cmd.ellipse": "Draw ellipse",
"history.cmd.explode": "Explode",
"history.cmd.dimdetach": "Detach dimension",
"history.cmd.extend": "Extend",
"history.cmd.extrude": "Extrude",
"history.cmd.fillet": "Fillet",
+11
View File
@@ -117,6 +117,9 @@ export interface MenuActions {
selectionAllNoPrint: boolean;
/** Setzt/löscht `noPrint` für die gesamte aktuelle 2D-Auswahl in einem Zug. */
toggleSelectionNoPrint: () => void;
/** Gewählte Bemassungen mit Bezügen ([38]); ab 1 erscheint „Bemassung lösen". */
attachedDimensionCount?: number;
detachDimensions?: () => void;
}
/**
@@ -377,6 +380,12 @@ function planMenuItems(
]
: [];
// „Bemassung lösen" ([38]) — nur wenn gewählte Bemassungen an Elementen hängen.
const dimDetachItems: ContextMenuItem[] =
a.attachedDimensionCount && a.detachDimensions
? [{ label: t("cmd.dimdetach.label"), icon: <MenuIcon name="link_off" />, onClick: a.detachDimensions }]
: [];
// Boolean-Einträge (Vereinigen/Subtrahieren/Schneiden) auf die 2D-Auswahl.
// Aktiv ab 2 geschlossenen Flächen; sonst deaktiviert mit erklärendem Tooltip.
const boolEnabled = a.closedSelectionCount >= 2;
@@ -452,6 +461,7 @@ function planMenuItems(
...layerItems,
...(layerItems.length ? [{ divider: true } as ContextMenuItem] : []),
...noPrintItems,
...dimDetachItems,
...(noPrintItems.length ? [{ divider: true } as ContextMenuItem] : []),
{
label: t("ctx.fitSelection"),
@@ -485,6 +495,7 @@ function planMenuItems(
...layerItems,
...(layerItems.length ? [{ divider: true } as ContextMenuItem] : []),
...noPrintItems,
...dimDetachItems,
...(noPrintItems.length ? [{ divider: true } as ContextMenuItem] : []),
...booleanItems,
{ divider: true },
+25
View File
@@ -520,6 +520,24 @@ export type CustomPalette = {
*/
export type DetailLevel = "grob" | "mittel" | "fein";
/** Merkmal, an dem ein Bemassungspunkt hängt ([38], `dim_assoc.rs`). */
export type DimFeature = "wall" | "opening" | "vertex" | "edge" | "center" | "intersection";
/** Bezug eines Bemassungspunkts auf ein Element ([38]). */
export type DimRef = {
/** Element-id (Wand, Öffnung, Stütze, Decke, Dach, Raum oder 2D-Zeichnung). */
id: string;
feature: DimFeature;
index?: number;
t?: number;
id2?: string;
index2?: number;
/** Normalabstand Merkmal → Masslinie (Modell-Meter, links der Masslinie positiv); fehlt = 0. */
d?: number;
/** Bezug ungültig (Element/Punkt weg): der Punkt bleibt an der zuletzt gespeicherten Lage. */
lost?: boolean;
};
/** Masse einer Türzarge/eines Türrahmens ([105]); Bedeutung je `frameKind`. Fehlt ⇒ Vorgabe. */
export type DoorFrameDetail = {
/** Falzbreite (parallel zur Wandfläche: Überdeckung Blatt/Rahmen), Vorgabe 0.015. */
@@ -862,6 +880,13 @@ export type Drawing2DGeom =
* Index = Segmentnummer.
*/
textOffsetsMm?: Array<{ along: number; perp: number }>;
/**
* Assoziative Bemassung ([38]): je Punkt (Index wie `pts`) der Bezug auf ein Merkmal eines
* Elements (`null` = freier Punkt). Der Kern führt `pts` nach jeder Änderung nach
* (`dim_assoc.rs`); `pts` ist damit immer die zuletzt aufgelöste Lage und der Rückfall,
* wenn ein Bezug ungültig wird. Fehlt das Feld, ist die Bemassung frei wie bisher.
*/
refs?: Array<DimRef | null>;
}
| {
shape: "kote";
+2
View File
@@ -52,6 +52,7 @@ import {
ColumnSection,
SectionLineSection,
DetailRefSection,
DimRefsSection,
} from "./ObjectInfoPanel";
import { SurfacePatternPlacement } from "./SurfacePatternPlacement";
@@ -793,6 +794,7 @@ export function AttributesPanel() {
{sel.extrudedSolid && <ExtrudedSolidSection solid={sel.extrudedSolid} host={host} />}
{sel.column && <ColumnSection column={sel.column} host={host} />}
{sel.detailRef && <DetailRefSection detailRef={sel.detailRef} drawingId={sel.id} host={host} />}
{sel.dimRefs && <DimRefsSection refs={sel.dimRefs} drawingId={sel.id} host={host} />}
</div>
);
}
+39
View File
@@ -27,6 +27,7 @@ import { t } from "../i18n";
import type { TranslationKey } from "../i18n";
import { flattenCategories, formatM } from "../model/types";
import type {
DimRef,
Dormer,
DormerKind,
DrawingLevel,
@@ -586,6 +587,44 @@ export function SectionLineSection({
);
}
// ── Assoziative Bemassung ([38]) ────────────────────────────────────────────
// Je Punkt: frei, angehängt (Merkmal + Element) oder Bezug verloren; „Bemassung lösen" entfernt alle.
export function DimRefsSection({
refs,
drawingId,
host,
}: {
refs: (DimRef | null)[];
drawingId: string;
host: ReturnType<typeof usePanelHost>;
}) {
const lost = refs.some((r) => r?.lost);
return (
<>
<div className="objinfo-sep" />
<div className="objinfo-section-label">{t("objinfo.dimRefs.section")}</div>
{refs.map((r, i) => (
<div className="objinfo-field" key={i} data-testid="dim-ref">
<span className="objinfo-flabel">{t("objinfo.dimRefs.point", { n: i + 1 })}</span>
<span className="objinfo-fval">
{!r
? t("objinfo.dimRefs.free")
: r.lost
? t("objinfo.dimRefs.lost", { id: r.id })
: `${t(`objinfo.dimRefs.feature.${r.feature}` as TranslationKey)} · ${r.id}${r.id2 ? ` / ${r.id2}` : ""}`}
</span>
</div>
))}
{lost && <div className="objinfo-measure-hint">{t("objinfo.dimRefs.lostHint")}</div>}
<div className="objinfo-field">
<button type="button" className="objinfo-btn" onClick={() => host.onDetachDimension(drawingId)}>
{t("cmd.dimdetach.label")}
</button>
</div>
</>
);
}
// ── Detail-/Schnitt-Verweis-Attribut-Abschnitt ──────────────────────────────
// Bezeichner (obere Zeile) + Blattverknüpfung (Dropdown der Project.layouts,
// „kein Verweis" löst sie); ohne Verknüpfung zusätzlich ein manueller
+2
View File
@@ -285,6 +285,8 @@ export interface PanelHostValue {
onSetDetailRefSheetLayout: (drawingId: string, sheetLayoutId: string | undefined) => void;
/** Manueller Blattname-Platzhalter, nur relevant OHNE Blattverknüpfung. */
onSetDetailRefSheetLabel: (drawingId: string, sheetLabel: string) => void;
/** „Bemassung lösen" ([38]): Bezüge der Bemassung entfernen, Punkte bleiben. */
onDetachDimension: (drawingId: string) => void;
onSetHatchPlacement: (
drawingId: string,
patch: { angleDeg?: number | null; scale?: number | null; origin?: Vec2 | null },
+63
View File
@@ -0,0 +1,63 @@
// [38] Assoziative Bemassung im Store: eine an Wandenden gefangene Bemassung folgt der Wand (Kern
// führt `pts` im selben Undo-Schritt nach), „Bemassung lösen" macht sie wieder frei.
import { describe, it, expect, beforeEach } from "vitest";
import { getState, setState } from "./appStore";
import { emptyProject } from "../model/sampleProject";
import { addItems, cmdMutation, patchItem } from "../core";
import type { Drawing2D, Wall } from "../model/types";
const wall: Wall = {
id: "W1",
type: "wall",
floorId: "eg",
categoryCode: "21",
start: { x: 0, y: 0 },
end: { x: 5, y: 0 },
wallTypeId: "aw",
height: 2.6,
} as Wall;
const dim = (): Drawing2D | undefined => getState().project.drawings2d.find((d) => d.geom.shape === "dimension");
const len = (d: Drawing2D | undefined): number => {
if (d?.geom.shape !== "dimension") return NaN;
const [a, b] = d.geom.pts;
return Math.hypot(b.x - a.x, b.y - a.y);
};
beforeEach(() => {
setState({ project: emptyProject, undoDepth: 0, redoDepth: 0, canUndo: false, canRedo: false });
getState().clearHistory();
getState().applyChange(addItems("walls", [wall]));
});
describe("assoziative Bemassung [38]", () => {
it("Wand strecken → Masszahl folgt, ein Undo-Schritt", () => {
getState().setProject(
cmdMutation({ cmd: "dimension", pts: [[0, 0], [5, 0]], snaps: [[0, 0], [5, 0]], offset: 1, ctx: { level: "eg" }, stamp: "t" }),
);
const d0 = dim();
expect(d0?.geom.shape === "dimension" && d0.geom.refs?.map((r) => r?.feature)).toEqual(["wall", "wall"]);
expect(len(d0)).toBeCloseTo(5, 9);
getState().applyChange((p) => patchItem(p, "walls", "W1", { end: { x: 7.25, y: 0 } }));
expect(len(dim())).toBeCloseTo(7.25, 9);
getState().undo();
expect(len(dim())).toBeCloseTo(5, 9);
expect(getState().project.walls[0].end.x).toBe(5);
getState().redo();
expect(len(dim())).toBeCloseTo(7.25, 9);
});
it("freie Punkte bleiben frei; Lösen entfernt die Bezüge", () => {
getState().setProject(cmdMutation({ cmd: "dimension", pts: [[0, 0], [3, 3]], offset: 1, ctx: { level: "eg" }, stamp: "t" }));
const free = dim();
// Punkt (0, 0) deckt sich mit dem Wandanfang, (3, 3) ist frei.
expect(free?.geom.shape === "dimension" && free.geom.refs?.map((r) => r?.feature ?? null)).toEqual(["wall", null]);
getState().setProject(cmdMutation({ cmd: "dimdetach", ids: [free!.id] }));
const d = dim();
expect(d?.geom.shape === "dimension" && d.geom.refs).toBeUndefined();
getState().applyChange((p) => patchItem(p, "walls", "W1", { start: { x: -1, y: 0 } }));
expect(dim()?.geom).toEqual(d?.geom);
});
});
+6
View File
@@ -19,6 +19,7 @@ import type { SolidSpec } from "../engine/truckSolid";
import { documentFor } from "../core/document";
import type {
AttributeSource,
DimRef,
ColumnProfile,
ContextImage,
ContextObject,
@@ -486,6 +487,11 @@ export interface Selection {
* `geom.shape === "detailref"`).
*/
detailRef?: DetailRefInfo;
/**
* Assoziative Bemassung ([38]): Bezug je Punkt der Kette (`null` = freier Punkt), nur bei
* `geom.shape === "dimension"` mit Bezügen.
*/
dimRefs?: (DimRef | null)[];
}
/**
+2 -1
View File
@@ -8,7 +8,7 @@
// Extrahiert aus App.tsx. Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
import { applyFillMode } from "./fillMode";
import { addItems, fieldOps, opsMutation, patchItem, patchItems, removeItems, removeRoofHole, setFieldIfChanged, setRoofEdge } from "../core";
import { addItems, cmdMutation, fieldOps, opsMutation, patchItem, patchItems, removeItems, removeRoofHole, setFieldIfChanged, setRoofEdge } from "../core";
import type { CoreOp, ProjectMutation } from "../core";
import { useMemo, type RefObject } from "react";
import type { DrawingLevel, Project } from "../model/types";
@@ -548,6 +548,7 @@ export function usePanelHostBase(opts: {
onAddColorToCustomPalette: (paletteId, hex) => addColorToCustomPalette(paletteId, hex),
onSetDashScale: (drawingId, scale) =>
setProject(opsMutation((p) => patchItem(p, "drawings2d", drawingId, { dashScale: scale }))),
onDetachDimension: (drawingId) => setProject(cmdMutation({ cmd: "dimdetach", ids: [drawingId] })),
onSetDetailRefLabel: (drawingId, label) =>
setProject(
opsMutation((p) =>