Merge [287] UX-Prüfung durch Zeichnen

This commit is contained in:
Claude committed 2026-11-18 21:31:46 +00:00
commit 4daef2990f
18 files changed
+231 -28

No files matched your search

+13 -2
View File
@@ -36,7 +36,10 @@ import { DEFAULT_PRESETS } from "./text/richText";
import { unitsForLevel } from "./tools/displayUnits";
import type { ToolHandlers } from "./tools/types";
import { checkForUpdateOnStart } from "./update/checkForUpdate";
import { useT } from "./i18n";
import { useT, t } from "./i18n";
import type { TranslationKey } from "./i18n";
import { toolInfo } from "./tools/tools";
import { getCommand } from "./commands/registry";
// Globaler Store (Slices: project/selection/view/layout) und lokaler UI-Zustand.
import { useStore } from "./state/appStore";
@@ -580,6 +583,14 @@ export default function App() {
// Werkzeug-Hinweis und aktive Ebene der Status-Leiste → state/useStatusBarInfo.ts.
const { toolHint, activeLayerName } = useStatusBarInfo({ selection, activeCategoryCode });
// [287] Links in der Statusleiste steht bei aktivem Werkzeug/Befehl dessen Name (vorher „Auswahl“ auch beim Wandzeichnen).
const statusToolKey =
activeTool !== "select"
? toolInfo(activeTool).labelKey
: commandActive && engineView.commandName
? getCommand(engineView.commandName)?.labelKey
: null;
const statusToolLabel = statusToolKey ? t(statusToolKey as TranslationKey) : null;
// Solange keine Plan-Ansicht montiert ist, gibt es keinen Live-Massstab.
// (PlanView meldet beim Montieren/Zoomen sofort wieder einen Wert.)
@@ -1023,7 +1034,7 @@ export default function App() {
{/* Footer / Status-Leiste (unten). Werte rein aus Modell + View-State.
Cursor/Zoom nur, wenn eine Plan-Ansicht aktiv ist (sonst „—"). */}
<StatusBar
hint={toolHint}
hint={statusToolLabel ?? toolHint}
showCursor={planActive}
unit="m"
units={displayUnits}
+8 -5
View File
@@ -23,6 +23,8 @@ import type {
Vec2,
} from "../types";
import { createMutation, createPreview, createQuery, xy } from "../createCore";
import { t } from "../../i18n";
import type { TranslationKey } from "../../i18n";
/** Default-Maße (Meter). */
const DEF_WINDOW = { width: 1.2, height: 1.2, sill: 0.9 };
@@ -134,7 +136,7 @@ function posDraftAt(s: OpPos, ctx: CommandContext, pos: number | null, at: Vec2
const draft: ToolDraft = { preview: pv.shapes, vertices: [{ x: ax, y: ay }, { x: bx, y: by }] };
draft.hud = {
at: s.cursor ?? { x: mx, y: my },
text: `${from.toFixed(2)} m · ${s.kind === "door" ? "Tür" : "Fenster"} ${(
text: `${from.toFixed(2)} m · ${t(s.kind === "door" ? "cmd.opening.doorLabel" : "cmd.opening.windowLabel")} ${(
s.width * 100
).toFixed(0)}×${(s.height * 100).toFixed(0)}`,
};
@@ -163,13 +165,14 @@ export const openingCommand: Command = {
: ["point", "option"],
options: (s): CmdOption[] => {
const st = s as OpState;
const kind: CmdOption = { ...KIND, value: st.kind };
// [287] Werte übersetzt (vorher „Art=window", „Seite=left").
const kind: CmdOption = { ...KIND, value: t(st.kind === "door" ? "cmd.opening.doorLabel" : "cmd.opening.windowLabel") };
if (st.kind === "door") {
return [
kind,
{ ...HINGE, value: st.hinge },
{ ...SIDE, value: st.side },
{ ...DIR, value: st.dir },
{ ...HINGE, value: t(`objinfo.opening.hinge.${st.hinge}` as TranslationKey) },
{ ...SIDE, value: t(`objinfo.opening.swing.${st.side}` as TranslationKey) },
{ ...DIR, value: t(`objinfo.opening.dir.${st.dir}` as TranslationKey) },
];
}
return [kind];
+3 -1
View File
@@ -29,6 +29,8 @@ import type {
Vec2,
} from "../types";
import { createMutation, createPreview, xy } from "../createCore";
import { t } from "../../i18n";
import type { TranslationKey } from "../../i18n";
const EPS = 1e-6;
const DEG = Math.PI / 180;
@@ -121,7 +123,7 @@ export const roomCommand: Command = {
: ["point", "option"],
options: (s): CmdOption[] => {
const st = s as RoomCmdState;
const modeOpt: CmdOption = { ...MODE, value: st.mode };
const modeOpt: CmdOption = { ...MODE, value: t(`cmd.room.mode.${st.mode}` as TranslationKey) };
if (st.phase !== "draw") return [modeOpt];
return st.points.length >= 3 ? [modeOpt, CLOSE, UNDO] : [modeOpt, UNDO];
},
+7 -4
View File
@@ -34,6 +34,8 @@ import type {
Vec2,
} from "../types";
import { createMutation, createPreview, xy } from "../createCore";
import { t } from "../../i18n";
import type { TranslationKey } from "../../i18n";
/** Default-Laufbreite (Meter). */
const DEF_WIDTH = 1.0;
@@ -209,10 +211,11 @@ export const stairCommand: Command = {
options: (s): CmdOption[] => {
const st = s as StairCmdState;
return [
{ ...SHAPE, value: st.shape },
{ ...UPDOWN, value: st.up ? "up" : "down" },
{ ...REFERENZ, value: st.referenz },
{ ...TREAD_MODE, value: st.treadMode },
// [287] Werte übersetzt (vorher „Grundform=straight“, „Auf/Ab=up“, „Trittmass=without“).
{ ...SHAPE, value: t(`objinfo.stair.shape.${st.shape}` as TranslationKey) },
{ ...UPDOWN, value: t(st.up ? "cmd.stair.updown.up" : "cmd.stair.updown.down") },
{ ...REFERENZ, value: t(`objinfo.stair.referenz.${st.referenz}` as TranslationKey) },
{ ...TREAD_MODE, value: t(`cmd.stair.treadMode.${st.treadMode}` as TranslationKey) },
];
},
+8
View File
@@ -292,6 +292,14 @@ export const wallCommand: Command = {
return [ns, { draft: draftOf(ctx, ns) }];
}
const seg: Seg = !s.arc ? 0 : (s.pendingThrough ?? 1);
// [287] Schliesst der Klick den Zug am Startpunkt (≥ 3 Wände), ist der Ring fertig: sofort anlegen.
// Vorher blieb der Befehl offen, und das gewohnte Esc-Esc zum Beenden verwarf alle Wände.
if (s.points.length >= 3 && segLen(s.points[0], pt) < EPS) {
return [
{ phase: "start", lastPoint: null, thickOverride: to, single, ...modeOf(s) } as WallIdle,
{ draft: null, done: true, commit: appendWalls([...s.points, s.points[0]], ctx, to, [...s.segs, seg], s.ext) },
];
}
const ns: WallDrawing = {
...s,
points: [...s.points, pt],
+67
View File
@@ -0,0 +1,67 @@
/** [287] Wandzug: Klick auf den Startpunkt schliesst den Ring und beendet den Befehl. */
import { describe, it, expect } from "vitest";
import { wallCommand } from "./wall";
import type { CommandContext, CommandResult, Project, Vec2 } from "../types";
function project(): Project {
return {
id: "t",
name: "T",
lineStyles: [],
hatches: [],
components: [{ id: "c", name: "C", color: "#ccc", hatchId: "none", joinPriority: 10 }],
wallTypes: [{ id: "aw", name: "AW", layers: [{ componentId: "c", thickness: 0.2 }] }],
drawingLevels: [
{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0 },
],
layers: [{ code: "20", name: "Wände", color: "#0a0a0a", lw: 0.5, visible: true, locked: false }],
walls: [],
openings: [],
ceilings: [],
stairs: [],
rooms: [],
drawings2d: [],
context: [],
} as unknown as Project;
}
function makeCtx(): CommandContext {
const p = project();
return {
project: p,
level: p.drawingLevels[0],
defaultCategoryCode: "20",
activeWallTypeId: "aw",
lastPoint: null,
} as unknown as CommandContext;
}
const sq: Vec2[] = [
{ x: 0, y: 0 },
{ x: 4, y: 0 },
{ x: 4, y: 3 },
{ x: 0, y: 3 },
];
function feed(pts: Vec2[]) {
const ctx = makeCtx();
let s = wallCommand.init();
let last: CommandResult | null = null;
for (const pt of pts) [s, last] = wallCommand.onInput(s, { kind: "point", point: pt }, ctx);
return { s, last: last! };
}
describe("wallCommand — Ring schliessen ([287])", () => {
it("Klick auf den Startpunkt legt den Ring an und beendet den Zug", () => {
const { s, last } = feed([...sq, sq[0]]);
expect(last.done).toBe(true);
expect(last.commit).toBeDefined();
expect(wallCommand.prompt(s)).toBe("cmd.wall.start");
expect(last.commit!(project()).walls).toHaveLength(4);
});
it("zwei Wände ergeben noch keinen Ring", () => {
const { last } = feed([sq[0], sq[1], sq[0]]);
expect(last.done).toBeFalsy();
});
});
+17
View File
@@ -310,6 +310,17 @@ export const de = {
"tool.snap": "Fang",
"tool.snap.hint": "Fang an Endpunkten/Raster; Shift = Ortho, Ctrl = Fang aus",
"snap.enabled": "Fang aktiv",
"snap.tip.endpoint": "Endpunkt",
"snap.tip.midpoint": "Mitte",
"snap.tip.intersection": "Schnittpunkt",
"snap.tip.center": "Zentrum",
"snap.tip.quadrant": "Quadrant",
"snap.tip.onEdge": "Auf Kante",
"snap.tip.perpendicular": "Senkrecht",
"snap.tip.tangent": "Tangente",
"snap.tip.parallel": "Parallel",
"snap.tip.extension": "Verlängerung",
"snap.tip.divide": "Teilpunkt",
"snap.endpoint": "Endpunkt",
"snap.midpoint": "Mittelpunkt",
"snap.center": "Kreismitte/Quadranten (0/90/180/270°)",
@@ -2367,6 +2378,10 @@ export const de = {
"cmd.stair.run": "Laufrichtung / Ende ( Grundform · Auf/Ab ):",
"cmd.stair.shape": "Grundform",
"cmd.stair.updown": "Auf/Ab",
"cmd.stair.updown.up": "Auf",
"cmd.stair.updown.down": "Ab",
"cmd.stair.treadMode.with": "mit",
"cmd.stair.treadMode.without": "ohne",
"cmd.stair.stepsField": "Stufen",
"cmd.stair.riseField": "Steighöhe",
"cmd.stair.referenz": "Referenz",
@@ -3587,6 +3602,8 @@ export const de = {
// ── Raum-Befehl ─────────────────────────────────────────────────────────────
"cmd.room.label": "Raum",
"cmd.room.mode": "Modus",
"cmd.room.mode.inside": "Klick in Raum",
"cmd.room.mode.manual": "Umriss",
"cmd.room.inside": "Klick in Raum setzen:",
"cmd.room.first": "Ersten Raumpunkt setzen:",
"cmd.room.next": "Nächsten Punkt setzen ( Enter/Start schliesst ):",
+17
View File
@@ -308,6 +308,17 @@ export const en: Record<TranslationKey, string> = {
"tool.snap": "Snap",
"tool.snap.hint": "Snap to endpoints/grid; Shift = ortho, Ctrl = snap off",
"snap.enabled": "Snap on",
"snap.tip.endpoint": "Endpoint",
"snap.tip.midpoint": "Midpoint",
"snap.tip.intersection": "Intersection",
"snap.tip.center": "Centre",
"snap.tip.quadrant": "Quadrant",
"snap.tip.onEdge": "On edge",
"snap.tip.perpendicular": "Perpendicular",
"snap.tip.tangent": "Tangent",
"snap.tip.parallel": "Parallel",
"snap.tip.extension": "Extension",
"snap.tip.divide": "Division point",
"snap.endpoint": "Endpoint",
"snap.midpoint": "Midpoint",
"snap.center": "Circle center/quadrants (0/90/180/270°)",
@@ -2356,6 +2367,10 @@ export const en: Record<TranslationKey, string> = {
"cmd.stair.run": "Run direction / end ( Shape · Up/Down ):",
"cmd.stair.shape": "Shape",
"cmd.stair.updown": "Up/Down",
"cmd.stair.updown.up": "Up",
"cmd.stair.updown.down": "Down",
"cmd.stair.treadMode.with": "with",
"cmd.stair.treadMode.without": "without",
"cmd.stair.stepsField": "Steps",
"cmd.stair.riseField": "Rise",
"cmd.stair.referenz": "Reference",
@@ -3574,6 +3589,8 @@ export const en: Record<TranslationKey, string> = {
// Room command.
"cmd.room.label": "Room",
"cmd.room.mode": "Mode",
"cmd.room.mode.inside": "Click in room",
"cmd.room.mode.manual": "Outline",
"cmd.room.inside": "Click inside room:",
"cmd.room.first": "Set first room point:",
"cmd.room.next": "Set next point ( Enter/Start closes ):",
+1
View File
@@ -64,6 +64,7 @@ export function useCommandLineBinding(opts: {
? {
fields: engineView.fields.map((f) => ({
id: f.id,
labelKey: f.labelKey,
value: f.value,
locked: f.locked,
active: f.active,
+39 -10
View File
@@ -1334,17 +1334,30 @@ body {
monospace-Texteingabe rechts; das Autocomplete-Dropdown öffnet nach oben. */
.cmdline {
position: relative;
flex: 0 0 auto;
display: flex;
align-items: center;
gap: 10px;
flex: 0 0 26px;
height: 26px;
padding: 0 12px;
border-top: 1px solid var(--line);
background: var(--input);
z-index: 20;
font-size: 12px;
user-select: none;
}
/* [287] Die Zeile hängt unten an der festen 26-px-Leiste und wächst bei Bedarf NACH OBEN über die Zeichenfläche
(Treppe: 4 Optionen + 3 Felder passen bei 1280 px nicht in eine Zeile; vorher liefen Felder und Eingabe rechts aus
dem Bild). Die Zeichenfläche behält ihre Grösse, der Zoom springt nicht. */
.cmdline-row {
position: absolute;
left: 0;
right: 0;
bottom: 0;
min-height: 26px;
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 3px 10px;
padding: 2px 12px;
border-top: 1px solid var(--line);
background: var(--input);
box-sizing: border-box;
}
.cmdline-prompt {
flex: 0 0 auto;
font-weight: 600;
@@ -1353,9 +1366,15 @@ body {
}
.cmdline-options {
display: inline-flex;
flex-wrap: wrap;
align-items: center;
gap: 6px;
gap: 3px 6px;
flex: 0 1 auto;
min-width: 0;
}
.cmdline-option {
flex: 0 0 auto;
white-space: nowrap;
}
.cmdline-option {
appearance: none;
@@ -1409,9 +1428,11 @@ body {
hervorgehoben (Akzent-Rand). Wert „—" = ungelockt (folgt der Maus). */
.cmdline-fields {
display: inline-flex;
flex-wrap: wrap;
align-items: center;
gap: 6px;
flex: 0 0 auto;
gap: 3px 6px;
flex: 0 1 auto;
min-width: 0;
}
.cmdline-field {
display: inline-flex;
@@ -2735,6 +2756,14 @@ body {
stroke: #ffcc44;
stroke-width: 1.5;
}
.plan-svg .snap-tip {
fill: var(--ink);
stroke: var(--bg);
paint-order: stroke;
stroke-linejoin: round;
pointer-events: none;
user-select: none;
}
.plan-svg .snap-glyph.snap-fill {
fill: #ffcc44;
}
+15
View File
@@ -54,4 +54,19 @@ describe("hudSegments — Cursor-HUD-Formatierung (2D + 3D gemeinsam)", () => {
);
expect(segs).toEqual([{ text: "L: 2.5m", active: true, locked: false }]);
});
it("[287] beschriftet Felder ohne Länge/Winkel mit ihrer Bezeichnung statt der Feld-ID (Öffnung: Abstand/Brüstung)", () => {
const segs = hudSegments(
{ at: { x: 0, y: 0 }, text: "x" },
{
fields: [
{ id: "pos", labelKey: "cmd.field.offset", value: 2.877, locked: false, active: true },
{ id: "width", labelKey: "cmd.field.width", value: 1.2, locked: false, active: false },
{ id: "sill", labelKey: "cmd.opening.sillField", value: 0.9, locked: false, active: false },
],
typed: "",
},
);
expect(segs.map((x) => x.text)).toEqual(["Abstand: 2.877m", "Breite: 1.200m", "Brüstung: 0.900m"]);
});
});
+18 -4
View File
@@ -7,6 +7,8 @@
import type { ToolDraft } from "./types";
import { NON_LENGTH_FIELDS } from "../commands/parseInput";
import { t } from "../i18n";
import type { TranslationKey } from "../i18n";
import { MODEL_UNITS, dyToDisplay, fmtDisplay, lengthToDisplay, type DisplayUnits } from "./displayUnits";
/** Ein Segment des Cursor-HUDs (z. B. "L: 3.000m"), + Tab-Zyklus-Zustand. */
@@ -18,7 +20,7 @@ export interface HudSeg {
/** Tab-Feld-Zyklus-Zustand der Befehlszeile (s. `ui/CommandLine.tsx`). */
export interface HudFieldsState {
fields: { id: string; value: number | null; locked: boolean; active: boolean }[];
fields: { id: string; labelKey?: string; value: number | null; locked: boolean; active: boolean }[];
typed: string;
}
@@ -48,12 +50,24 @@ export function hudSegments(
: id === "height"
? (hud.dy ?? null)
: null;
const labelFor = (id: string): string =>
id === "length" ? "L" : id === "angle" ? "W" : id === "width" ? "Δx" : id === "height" ? "Δy" : id;
// [287] Länge/Winkel kurz (L/W, VW-Stil), Breite/Höhe nur mit Δx/Δy, wenn der Entwurf dx/dy liefert (Rechteck);
// alle übrigen Felder (Abstand, Brüstung, Radius, Dicke …) mit ihrer übersetzten Bezeichnung statt der Feld-ID.
const labelFor = (id: string, labelKey?: string): string =>
id === "length"
? "L"
: id === "angle"
? "W"
: (id === "width" || id === "height") && hud.dx != null
? id === "width"
? "Δx"
: "Δy"
: labelKey
? t(labelKey as TranslationKey)
: id;
const segs: HudSeg[] = [];
if (hudFields && hudFields.fields.length > 0) {
for (const f of hudFields.fields) {
const label = labelFor(f.id);
const label = labelFor(f.id, f.labelKey);
const isLength = !NON_LENGTH_FIELDS.has(f.id);
const unit = f.id === "angle" ? "°" : isLength ? u : "";
const typedHere = f.active && hudFields.typed.trim() !== "";
+2
View File
@@ -177,6 +177,7 @@ export const CommandLine = memo(forwardRef<CommandLineHandle, CommandLineProps>(
return (
<div className="cmdline" role="group" aria-label={t("cmd.aria")} data-steps={steps ?? 0}>
<div className="cmdline-row">
{suggestions.length > 0 && (
<ul className="cmdline-suggest" role="listbox">
{suggestions.map((s) => (
@@ -256,6 +257,7 @@ export const CommandLine = memo(forwardRef<CommandLineHandle, CommandLineProps>(
onChange={(e) => setText(e.target.value)}
onKeyDown={onKeyDown}
/>
</div>
</div>
);
},
+14 -1
View File
@@ -6,6 +6,8 @@ import type { Vec2 } from "../../../model/types";
import type { SnapResult, ToolDraft } from "../../../tools/types";
import { hudSegments, type HudFieldsState } from "../../../tools/hudFormat";
import { MODEL_UNITS, type DisplayUnits } from "../../../tools/displayUnits";
import { t } from "../../../i18n";
import type { TranslationKey } from "../../../i18n";
/**
* Zeichnet die Werkzeug-Vorschau: Vorschau-Formen (gestrichelte Akzentlinien /
@@ -85,7 +87,7 @@ export function DraftOverlay({
)}
{/* Snap-Marker + optionale Ortho-Hilfslinie. */}
{draft.snap && (
<SnapMarker snap={draft.snap} toScreen={toScreen} size={markSize} color={snapColor} />
<SnapMarker snap={draft.snap} toScreen={toScreen} size={markSize} color={snapColor} vbPerPx={vbPerPx} />
)}
{/* Maß-/Winkel-HUD am Cursor (VW-Stil `L: … W: …`, oder einfacher Text). */}
{draft.hud && <DraftHud hud={draft.hud} toScreen={toScreen} vbPerPx={vbPerPx} hudFields={hudFields} units={units} />}
@@ -261,14 +263,18 @@ function AngleGuide({
}
/** Marker-Glyph je Snap-Art + (bei ortho) eine gestrichelte Hilfslinie. */
const SNAP_TIP_KINDS = new Set(["endpoint", "midpoint", "intersection", "center", "quadrant", "onEdge", "perpendicular", "tangent", "parallel", "extension", "divide"]);
function SnapMarker({
snap,
toScreen,
size,
color,
vbPerPx,
}: {
snap: SnapResult;
toScreen: (v: Vec2) => Vec2;
vbPerPx: number;
size: number;
/** Farbe des Snap-Glyphs (einstellbar, Default = Akzent „Sora"). */
color: string;
@@ -281,8 +287,15 @@ function SnapMarker({
const glyphStyle = { stroke: color };
const helperStyle = { stroke: color };
const fillStyle = { stroke: color, fill: color };
// [287] Fangart als Kurztext am Marker (Archicad/VW-Art): sonst bleibt unklar, woran der Zeiger gerade hängt.
const tip = SNAP_TIP_KINDS.has(snap.kind) ? t(`snap.tip.${snap.kind}` as TranslationKey) : null;
return (
<g className="snap-marker" data-snap-kind={snap.kind}>
{tip && (
<text className="snap-tip" x={s.x + 9 * vbPerPx} y={s.y - 7 * vbPerPx} fontSize={11 * vbPerPx} strokeWidth={3 * vbPerPx}>
{tip}
</text>
)}
{(snap.kind === "ortho" || snap.kind === "extension") && snap.refA && (
<line
className="snap-helper-line"