[93] Layout-Blatt: Papier-mm in Linealen/Objekt-Info/HUD, Symbole in Papiergrösse, Fang auf Viewport-Inhalt, DXF-Papierbereich mit Blatt-Zeichnung, PDF-Raumfüllung
- Anzeige-Einheiten (tools/displayUnits.ts): auf der Blatt-Ebene Papier-mm mit y nach unten in Linealen, Statusleiste, Objekt-Info, Attribute-Massen, Cursor-HUD und Befehlszeile; getippte Koordinaten/Längen in mm - Kote, Detailverweis, Punktmarke: feste Grössen auf dem Blatt mit Faktor 1/100 (Papiermass wie bei 1:100) - Kern-Fang (sheet_viewports.rs, snap_model.rs): Kanten der Viewport-Pläne, abgebildet und geklippt, je Dokument-Stand - DXF/DWG --layout: je Projekt-Layout ein Papierbereich mit Blatt-Zeichnung (Block) und Ansichtsfenstern (CLI + App) - Druck-SVG: #rrggbbaa als fill-opacity (svg2pdf füllte Räume deckend dunkel); Geo-Verschieben lässt Blatt-Zeichnungen; Objekt-Info: Enter committete doppelt - Tests: Rust (Kern, fileio), vitest, e2e (mm-Anzeige, Fang auf Viewport-Inhalt)
This commit is contained in:
31 files changed
+1098
-124
No files matched your search
+25
-3
@@ -16,6 +16,8 @@
|
||||
// fünf DOSSIER-Modi): das Zeichnungsebenen-Panel steuert das 3D, das
|
||||
// Ebenen-Panel die Kategorie-Darstellung in Grundriss UND 3D.
|
||||
|
||||
import { lengthFromDisplay, unitsForLevel } from "./tools/displayUnits";
|
||||
import { NON_LENGTH_FIELDS } from "./commands/parseInput";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import {
|
||||
collectVisibleCodes,
|
||||
@@ -600,6 +602,8 @@ export default function App() {
|
||||
project.drawingLevels[0];
|
||||
// Massstab der Arbeitsebene: auf einem Blatt Papier 1:1, sonst der gewählte Plan-Massstab.
|
||||
const planScale = isSheetLevel(activeLevel) ? SHEET_SCALE_DENOMINATOR : scaleDenominator;
|
||||
// Anzeige-Einheiten (Lineale, Statusleiste, HUD, Befehlszeile): auf einem Blatt Papier-mm ([93]).
|
||||
const displayUnits = unitsForLevel(activeLevel);
|
||||
|
||||
// Sichtbare Kategorie-Codes — Basisfilter für Grundriss & 3D.
|
||||
const visibleCodes = useMemo(
|
||||
@@ -938,6 +942,8 @@ export default function App() {
|
||||
cmdLatest.current.setProject(group && mutate.coreReq ? cmdMutation({ ...mutate.coreReq, group }) : mutate);
|
||||
},
|
||||
isFloor: () => cmdLatest.current.activeLevel.kind === "floor",
|
||||
// Getippte Werte auf einem Layout-Blatt in Papier-mm, y nach unten ([93]).
|
||||
inputUnits: () => unitsForLevel(cmdLatest.current.activeLevel),
|
||||
// Frisch über `text`/`textbox` erzeugtes Element sofort inline editieren
|
||||
// (kein Lookup nötig — der Commit hat es bereits angehängt, s. engine.ts
|
||||
// applyResult-Reihenfolge commit→focusDrawing). Auswahl-Löschen wie
|
||||
@@ -3611,6 +3617,7 @@ export default function App() {
|
||||
Prompt + klickbare Inline-Optionen + Texteingabe + Autocomplete. */}
|
||||
<CommandLine
|
||||
ref={commandLineRef}
|
||||
units={displayUnits}
|
||||
// (c) Während eines Vertex- ODER Kanten-Griff-Drags belegt der Feld-
|
||||
// Controller das Befehlsfeld (Länge/Winkel bzw. Abstand). Läuft eine
|
||||
// Auswahl-Transformation (Drehen etc.), belegt sie Prompt + U/I/O/P +
|
||||
@@ -3660,8 +3667,22 @@ export default function App() {
|
||||
: engineView.fields
|
||||
}
|
||||
onSubmit={(text) => {
|
||||
// Feld-Controller (Griff, Kante, Transformation): getippte Länge in Anzeige-Einheiten
|
||||
// (Blatt: Papier-mm) → Meter; Winkel/Anzahl bleiben.
|
||||
const ctlFields = gripEdit
|
||||
? gripEditFields()
|
||||
: edgeEdit
|
||||
? edgeEditFields()
|
||||
: activeTransform
|
||||
? transformFields()
|
||||
: [];
|
||||
const ctlActive = ctlFields.find((f) => f.active)?.id;
|
||||
const typed = (raw: string): number => {
|
||||
const n = parseFloat(raw.replace(",", "."));
|
||||
return ctlActive && !NON_LENGTH_FIELDS.has(ctlActive) ? lengthFromDisplay(displayUnits, n) : n;
|
||||
};
|
||||
if (gripEdit) {
|
||||
const v = parseFloat(text.replace(",", "."));
|
||||
const v = typed(text);
|
||||
if (isFinite(v)) submitGripEditValue(v);
|
||||
// Leere Eingabe: kein neuer Wert zu locken — Enter bestätigt
|
||||
// stattdessen die aktuelle Position (Maus- oder bereits
|
||||
@@ -3671,7 +3692,7 @@ export default function App() {
|
||||
return;
|
||||
}
|
||||
if (edgeEdit) {
|
||||
const v = parseFloat(text.replace(",", "."));
|
||||
const v = typed(text);
|
||||
if (isFinite(v)) submitEdgeEditValue(v);
|
||||
else planViewRef.current?.confirmEdgeEdit();
|
||||
return;
|
||||
@@ -3686,7 +3707,7 @@ export default function App() {
|
||||
return;
|
||||
}
|
||||
if (activeTransform) {
|
||||
const v = parseFloat(text.replace(",", "."));
|
||||
const v = typed(text);
|
||||
if (isFinite(v)) submitTransformValue(v);
|
||||
return;
|
||||
}
|
||||
@@ -3804,6 +3825,7 @@ export default function App() {
|
||||
hint={toolHint}
|
||||
showCursor={planActive}
|
||||
unit="m"
|
||||
units={displayUnits}
|
||||
referenceLines={referenceLines}
|
||||
onReferenceLines={setReferenceLines}
|
||||
referenceLinesEnabled={planActive}
|
||||
|
||||
+1
-1
@@ -594,7 +594,7 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
await loadFileio();
|
||||
// --scale N (Massstabsnenner, Default 100): Bemassungsstil, Linientypen, Raumstempel, Ansichtsfenster.
|
||||
// --dim-unit cm: Masszahlen in Zentimetern; --layout: zusätzlich Papierbereich mit Ansichtsfenster.
|
||||
const cad = { scaleDenominator: scale, dimUnit: args.flags.get("dim-unit") === "cm" ? ("cm" as const) : ("m" as const), paperLayout: args.flags.has("layout") };
|
||||
const cad = { scaleDenominator: scale, dimUnit: args.flags.get("dim-unit") === "cm" ? ("cm" as const) : ("m" as const), paperLayout: args.flags.has("layout"), levelId: lvl.id };
|
||||
if (command === "dxf" && args.flags.has("binary")) out(args, buildPlanDxfBinary(plan, world, cad), `${lvl.name}.dxf`);
|
||||
else if (command === "dxf") out(args, buildPlanDxf(plan, world, cad), `${lvl.name}.dxf`);
|
||||
else out(args, buildPlanDwg(plan, world, cad), `${lvl.name}.dwg`);
|
||||
|
||||
@@ -28,7 +28,7 @@ function ctxReq(ctx: CommandContext): object {
|
||||
floorHeight: ctx.level.floorHeight ?? null,
|
||||
cat: ctx.defaultCategoryCode,
|
||||
wallType: ctx.activeWallTypeId,
|
||||
...(ctx.level.layoutId ? { textHeight: SHEET_TEXT_HEIGHT_M } : {}),
|
||||
...(ctx.level.layoutId ? { textHeight: SHEET_TEXT_HEIGHT_M, sheet: true } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+20
-2
@@ -16,7 +16,8 @@
|
||||
import type { Vec2 } from "../model/types";
|
||||
import type { SnapResult, ToolDraft } from "../tools/types";
|
||||
import type { ProjectMutation } from "../core";
|
||||
import { parseInput, resolvePoint } from "./parseInput";
|
||||
import { NON_LENGTH_FIELDS, parseInput, resolvePoint, toModelInput } from "./parseInput";
|
||||
import { MODEL_UNITS, type DisplayUnits } from "../tools/displayUnits";
|
||||
import { getCommand, resolveCommand, autocomplete } from "./registry";
|
||||
import type {
|
||||
Command,
|
||||
@@ -59,6 +60,11 @@ export interface EngineHost {
|
||||
* Inline-Text-Editor zu öffnen). Fehlt der Host-Handler, ist das ein No-op.
|
||||
*/
|
||||
focusDrawing?(drawingId: string, minHeightM?: number): void;
|
||||
/**
|
||||
* Optional: Einheiten getippter Werte ([93]): auf einem Layout-Blatt Papier-mm mit y nach unten
|
||||
* (s. `tools/displayUnits.ts`). Fehlt der Handler, gelten Meter.
|
||||
*/
|
||||
inputUnits?(): DisplayUnits;
|
||||
}
|
||||
|
||||
/** Öffentlicher Schnappschuss für die Command-Line-UI (rein lesend). */
|
||||
@@ -228,6 +234,12 @@ export class CommandEngine {
|
||||
* sofort den daraus gebildeten Punkt — so commitet ein Ein-Feld-Befehl (Kreis:
|
||||
* Radius) direkt und ein Zwei-Feld-Befehl (Linie) nach dem zweiten Wert.
|
||||
*/
|
||||
/** Art des aktiven Tab-Felds für getippte Werte: Länge, Δy („height“) oder ohne Umrechnung. */
|
||||
private activeFieldUnit(): "length" | "dy" | "none" {
|
||||
const f = this.currentFields()[this.activeFieldIndex];
|
||||
return !f || NON_LENGTH_FIELDS.has(f.id) ? "none" : f.id === "height" ? "dy" : "length";
|
||||
}
|
||||
|
||||
private lockActiveField(value: number): void {
|
||||
this.syncFields();
|
||||
const defs = this.currentFields();
|
||||
@@ -361,7 +373,13 @@ export class CommandEngine {
|
||||
return;
|
||||
}
|
||||
|
||||
const parsed = parseInput(text);
|
||||
const parsed = toModelInput(
|
||||
parseInput(text),
|
||||
this.host.inputUnits?.() ?? MODEL_UNITS,
|
||||
// Nackte Zahl: Länge im Längen-Feld bzw. als Distanz-Lock eines Punkt-Schritts; reine Zahl-Schritte
|
||||
// (Anzahl, Faktor, Winkel …) bleiben ohne Umrechnung.
|
||||
this.hasFields() ? this.activeFieldUnit() : accepts.includes("point") ? "length" : "none",
|
||||
);
|
||||
|
||||
// Tab-Feld-Modus (§2.7): eine nackte Zahl LOCKT das aktive Feld (statt als
|
||||
// distance/number durchzureichen) und rückt aufs nächste Feld vor. Absolute/
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
// (passend zur Y-flip-freien Modellkonvention: +Y ist „oben").
|
||||
|
||||
import type { Vec2 } from "../model/types";
|
||||
import { lengthFromDisplay, pointFromDisplay, yFromDisplay, type DisplayUnits } from "../tools/displayUnits";
|
||||
|
||||
/** Geparste, noch nicht aufgelöste Eingabe. */
|
||||
export type ParsedInput =
|
||||
@@ -106,6 +107,31 @@ export function parseInput(raw: string): ParsedInput {
|
||||
return { kind: "text", text: s };
|
||||
}
|
||||
|
||||
/** Tab-Felder ohne Länge (keine Einheiten-Umrechnung getippter Werte). */
|
||||
export const NON_LENGTH_FIELDS: ReadonlySet<string> = new Set(["angle", "count", "steps", "segments", "sides", "bends"]);
|
||||
|
||||
/**
|
||||
* Getippte Eingabe in Anzeige-Einheiten → Modell ([93], Layout-Blatt: Papier-mm, y nach unten).
|
||||
* `distance`: eine nackte Zahl ist eine Länge (Längen-Feld, Distanz-Lock), ein Δy (Feld „height“: auf
|
||||
* dem Papier nach unten) oder bleibt, wie sie ist (Winkel, Anzahl, Faktor).
|
||||
*/
|
||||
export function toModelInput(p: ParsedInput, u: DisplayUnits, distance: "length" | "dy" | "none"): ParsedInput {
|
||||
if (u.perMeter === 1 && !u.flipY) return p;
|
||||
switch (p.kind) {
|
||||
case "absolute":
|
||||
return { kind: "absolute", point: pointFromDisplay(u, p.point) };
|
||||
case "relative":
|
||||
return { kind: "relative", delta: { x: lengthFromDisplay(u, p.delta.x), y: yFromDisplay(u, p.delta.y) } };
|
||||
case "polar":
|
||||
return { kind: "polar", dist: lengthFromDisplay(u, p.dist), angleDeg: p.angleDeg };
|
||||
case "distance":
|
||||
if (distance === "none") return p;
|
||||
return { kind: "distance", value: distance === "dy" ? yFromDisplay(u, p.value) : lengthFromDisplay(u, p.value) };
|
||||
default:
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
/** Punkt aus polarer Form (Distanz/Winkel) relativ zu einem Basispunkt. */
|
||||
export function polarPoint(base: Vec2, dist: number, angleDeg: number): Vec2 {
|
||||
const a = angleDeg * DEG;
|
||||
|
||||
@@ -50,8 +50,13 @@ export interface ExportDxfOptions {
|
||||
scaleDenominator?: number;
|
||||
/** Einheit der Masszahl: Meter (Default, wie im Plan „3.25") oder Zentimeter („325"). */
|
||||
dimUnit?: "m" | "cm";
|
||||
/** Zusätzlich ein Layout (Papierbereich) mit Ansichtsfenster im Planmassstab anlegen. */
|
||||
/**
|
||||
* Zusätzlich ein Layout (Papierbereich) mit Ansichtsfenster im Planmassstab anlegen — und je
|
||||
* Projekt-Layout einen Papierbereich mit der Blatt-Zeichnung und den Ansichtsfenstern auf `levelId`.
|
||||
*/
|
||||
paperLayout?: boolean;
|
||||
/** Exportierte Ebene (für die Ansichtsfenster der Projekt-Layouts im Papierbereich). */
|
||||
levelId?: string;
|
||||
}
|
||||
|
||||
/** Ausgabeformat des Modell-Space-Exports. */
|
||||
@@ -133,7 +138,7 @@ export function collectPlanDrawing(
|
||||
const o = Float64Array.of(scale, (opts.includeHatches ?? true) ? 1 : 0, opts.dimUnit === "cm" ? 1 : 0, opts.paperLayout ? 1 : 0, b.minX, b.minY, b.maxX, b.maxY);
|
||||
const doc = documentFor(project).id;
|
||||
// Eigener Puffer mit Schraffur-JSON (Verlauf-Schraffuren brauchen ihre Farben).
|
||||
const bytes = withPlanParts(planParts(plan, true), (segs) => core().plan_dxf_flat(doc, segs, o));
|
||||
const bytes = withPlanParts(planParts(plan, true), (segs) => core().plan_dxf_flat(doc, segs, o, opts.levelId ?? ""));
|
||||
return decodeFlat(bytes);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import { Fragment } from "react";
|
||||
import type { ReactNode } from "react";
|
||||
import { t } from "../i18n";
|
||||
import { formatM, wallTypeLabel } from "../model/types";
|
||||
import { fmtLength, unitsForLevel } from "../tools/displayUnits";
|
||||
import { PEN_WEIGHTS } from "../model/types";
|
||||
import type { AttributeSource } from "../model/types";
|
||||
import { usePanelHost } from "./host";
|
||||
@@ -124,6 +125,8 @@ export function AttributesPanel() {
|
||||
}
|
||||
|
||||
const isDrawing = sel.kind === "drawing2d";
|
||||
const sheetUnits = unitsForLevel(host.project.drawingLevels.find((z) => z.id === sel.floorId));
|
||||
const sizeText = (m: number): string => (sheetUnits.perMeter === 1 ? formatM(m) : `${fmtLength(sheetUnits, m).replace(/mm$/, "")} mm`);
|
||||
// Strichstärke: Wand/Decke/Stütze/Drawing2D tragen einen eigenen Override
|
||||
// (`strokeWeight`/`weightMm`) + Quellen-Dropdown; andere Elementarten erben
|
||||
// stets aus der Kategorie (kein Setter im Kontrakt → nicht editierbar).
|
||||
@@ -760,9 +763,7 @@ 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. */}
|
||||
{/* ── Masse (informativ, aus der bbox) — auf einem Layout-Blatt in Papier-mm ([93]). */}
|
||||
{/* 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
|
||||
@@ -771,9 +772,9 @@ export function AttributesPanel() {
|
||||
<>
|
||||
<div className="attr-section-label">{t("attr.size")}</div>
|
||||
<span className="attr-key">{t(isModelElement ? "attr.extentX" : "attr.width")}</span>
|
||||
<span className="attr-val attr-readonly">{formatM(bboxW)}</span>
|
||||
<span className="attr-val attr-readonly">{sizeText(bboxW)}</span>
|
||||
<span className="attr-key">{t(isModelElement ? "attr.extentY" : "attr.height")}</span>
|
||||
<span className="attr-val attr-readonly">{formatM(bboxH)}</span>
|
||||
<span className="attr-val attr-readonly">{sizeText(bboxH)}</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -14,9 +14,10 @@
|
||||
// Bezeichner englisch, UI-Text/Kommentare deutsch (CONVENTIONS.md). Alle sichtbaren
|
||||
// Texte über t(...).
|
||||
|
||||
import { lengthFromDisplay, lengthToDisplay, unitsForLevel, xToDisplay, yFromDisplay, yToDisplay } from "../tools/displayUnits";
|
||||
import { solidProps } from "../engine/truckSolid";
|
||||
import type { SolidProps, SolidSpec } from "../engine/truckSolid";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
// Anzeige-Fallbacks für die Öffnungs-Linien-Übersteuerung (LineStyleRow) —
|
||||
// dieselben Werte wie POCHE_STROKE/SYMBOL_HAIRLINE_MM im Grundriss (Kern: plan/style.rs)
|
||||
// (reine UI-Default-Anzeige, kein Re-Export nötig).
|
||||
@@ -106,6 +107,11 @@ export function ObjectInfoPanel() {
|
||||
// Wert (wie bei Breite/Höhe oben).
|
||||
const px = bbox.minX + anchor.fx * width;
|
||||
const py = bbox.minY + anchor.fy * height;
|
||||
// Auf einem Layout-Blatt zeigt und liest das Panel Papier-mm mit y nach unten ([93]).
|
||||
const u = unitsForLevel(host.project.drawingLevels.find((z) => z.id === sel.floorId));
|
||||
const len = (m: number): number => lengthToDisplay(u, m);
|
||||
const unlen = (v: number): number => lengthFromDisplay(u, v);
|
||||
const lenProps = { unit: u.suffix, digits: u.digits };
|
||||
|
||||
// Rohe Drawing2D-Geometrie der Selektion (nur bei kind==="drawing2d") — für
|
||||
// die Linien-Länge/Kreis-Radius-Felder unten; die Selection-Sicht trägt
|
||||
@@ -199,15 +205,17 @@ export function ObjectInfoPanel() {
|
||||
<div className="objinfo-xyzcol">
|
||||
<DimensionField
|
||||
label={t("objinfo.x")}
|
||||
value={px}
|
||||
value={xToDisplay(u, px)}
|
||||
min={-Infinity}
|
||||
onCommit={(nx) => host.onMoveSelectionBy(nx - px, 0)}
|
||||
{...lenProps}
|
||||
onCommit={(nx) => host.onMoveSelectionBy(unlen(nx) - px, 0)}
|
||||
/>
|
||||
<DimensionField
|
||||
label={t("objinfo.y")}
|
||||
value={py}
|
||||
value={yToDisplay(u, py)}
|
||||
min={-Infinity}
|
||||
onCommit={(ny) => host.onMoveSelectionBy(0, ny - py)}
|
||||
{...lenProps}
|
||||
onCommit={(ny) => host.onMoveSelectionBy(0, yFromDisplay(u, ny) - py)}
|
||||
/>
|
||||
{/* Z ehrlich: Das Modell ist 2D pro Ebene; es gibt keine Z am Element.
|
||||
Daher „—" statt einer gefakten 0, mit kurzem Hinweis im Titel. */}
|
||||
@@ -229,13 +237,15 @@ export function ObjectInfoPanel() {
|
||||
<div className="objinfo-section-label">{t("objinfo.dimensions")}</div>
|
||||
<DimensionField
|
||||
label={t("objinfo.width")}
|
||||
value={width}
|
||||
onCommit={(w) => commitSize(w, height)}
|
||||
value={len(width)}
|
||||
{...lenProps}
|
||||
onCommit={(w) => commitSize(unlen(w), height)}
|
||||
/>
|
||||
<DimensionField
|
||||
label={t("objinfo.height")}
|
||||
value={height}
|
||||
onCommit={(h) => commitSize(width, h)}
|
||||
value={len(height)}
|
||||
{...lenProps}
|
||||
onCommit={(h) => commitSize(width, unlen(h))}
|
||||
/>
|
||||
{/* Formspezifische Zusatzfelder (nur wenn das Modell den Wert direkt
|
||||
hergibt — andere Formen bleiben ohne Zusatzfeld, s. Dateikopf). */}
|
||||
@@ -243,8 +253,9 @@ export function ObjectInfoPanel() {
|
||||
<>
|
||||
<DimensionField
|
||||
label={t("objinfo.drawing.length")}
|
||||
value={Math.hypot(width, height)}
|
||||
onCommit={(v) => host.onSetDrawingLineLength(v)}
|
||||
value={len(Math.hypot(width, height))}
|
||||
{...lenProps}
|
||||
onCommit={(v) => host.onSetDrawingLineLength(unlen(v))}
|
||||
/>
|
||||
<DimensionField
|
||||
label={t("objinfo.drawing.angle")}
|
||||
@@ -264,16 +275,18 @@ export function ObjectInfoPanel() {
|
||||
{drawingShape === "circle" && (
|
||||
<DimensionField
|
||||
label={t("objinfo.drawing.radius")}
|
||||
value={width / 2}
|
||||
onCommit={(v) => host.onSetDrawingCircleRadius(v)}
|
||||
value={len(width / 2)}
|
||||
{...lenProps}
|
||||
onCommit={(v) => host.onSetDrawingCircleRadius(unlen(v))}
|
||||
/>
|
||||
)}
|
||||
{drawingShape === "arc" && rawDrawing?.geom.shape === "arc" && (
|
||||
<>
|
||||
<DimensionField
|
||||
label={t("objinfo.drawing.radius")}
|
||||
value={rawDrawing.geom.r}
|
||||
onCommit={(v) => host.onSetDrawingArcRadius(v)}
|
||||
value={len(rawDrawing.geom.r)}
|
||||
{...lenProps}
|
||||
onCommit={(v) => host.onSetDrawingArcRadius(unlen(v))}
|
||||
/>
|
||||
<DimensionField
|
||||
label={t("objinfo.drawing.startAngle")}
|
||||
@@ -2036,6 +2049,7 @@ function DimensionField({
|
||||
min = 0,
|
||||
unit = "m",
|
||||
step = 0.01,
|
||||
digits = 3,
|
||||
}: {
|
||||
label: string;
|
||||
value: number;
|
||||
@@ -2043,16 +2057,24 @@ function DimensionField({
|
||||
min?: number;
|
||||
unit?: string;
|
||||
step?: number;
|
||||
/** Nachkommastellen der Anzeige (Papier-mm: 1). */
|
||||
digits?: number;
|
||||
}) {
|
||||
// Entwurf als String, damit Zwischenzustände (leer, „1.") tippbar sind.
|
||||
// `null` = kein aktiver Entwurf → zeige den Host-Wert.
|
||||
const [draft, setDraft] = useState<string | null>(null);
|
||||
// Enter committet und nimmt danach den Fokus — das `blur` im selben Handler sieht noch den alten
|
||||
// Entwurf (State noch nicht neu gerendert) und committete ein zweites Mal (X/Y: doppelte Verschiebung).
|
||||
const pending = useRef<string | null>(null);
|
||||
pending.current = draft;
|
||||
|
||||
const shown = draft ?? value.toFixed(3);
|
||||
const shown = draft ?? (Object.is(Number(value.toFixed(digits)), -0) ? 0 : value).toFixed(digits);
|
||||
|
||||
function commit() {
|
||||
if (draft === null) return;
|
||||
const v = Number(draft);
|
||||
const d = pending.current;
|
||||
if (d === null) return;
|
||||
pending.current = null;
|
||||
const v = Number(d);
|
||||
setDraft(null);
|
||||
if (isFinite(v) && v >= min) onCommit(v);
|
||||
}
|
||||
|
||||
@@ -136,6 +136,7 @@ export function useExportHandlers(opts: {
|
||||
scaleDenominator: decision.scaleDenominator,
|
||||
dimUnit: decision.dimUnit,
|
||||
paperLayout: decision.paperLayout,
|
||||
levelId: activeLevelId,
|
||||
fileName: `${project.name}-${activeLevelName}`,
|
||||
});
|
||||
} catch (err) {
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { MODEL_UNITS, PAPER_UNITS, fmtLength, rulerLabel, unitsForLevel, xToDisplay, yFromDisplay, yToDisplay } from "./displayUnits";
|
||||
import { parseInput, toModelInput } from "../commands/parseInput";
|
||||
import { hudSegments } from "./hudFormat";
|
||||
|
||||
describe("[93] Anzeige-Einheiten auf dem Layout-Blatt", () => {
|
||||
it("Blatt-Ebene = Papier-mm mit y nach unten, sonst Meter", () => {
|
||||
expect(unitsForLevel({ layoutId: "L" })).toBe(PAPER_UNITS);
|
||||
expect(unitsForLevel({})).toBe(MODEL_UNITS);
|
||||
// Blatt-Punkt (0.42, −0.297) = Papier (420, 297) mm.
|
||||
expect(xToDisplay(PAPER_UNITS, 0.42)).toBeCloseTo(420, 9);
|
||||
expect(yToDisplay(PAPER_UNITS, -0.297)).toBeCloseTo(297, 9);
|
||||
expect(yFromDisplay(PAPER_UNITS, 297)).toBeCloseTo(-0.297, 12);
|
||||
expect(fmtLength(PAPER_UNITS, 0.0125)).toBe("12.5mm");
|
||||
expect(fmtLength(MODEL_UNITS, 3)).toBe("3.000m");
|
||||
});
|
||||
|
||||
it("Lineal: mm ohne Einheit, y positiv nach unten; Modell unverändert", () => {
|
||||
expect(rulerLabel(PAPER_UNITS, "x", 0.05)).toBe("50");
|
||||
expect(rulerLabel(PAPER_UNITS, "y", -0.1)).toBe("100");
|
||||
expect(rulerLabel(PAPER_UNITS, "y", 0)).toBe("0");
|
||||
expect(rulerLabel(MODEL_UNITS, "y", -1)).toBe("-1.000m");
|
||||
});
|
||||
|
||||
it("getippte Koordinaten/Längen in Papier-mm → Blatt-Meter", () => {
|
||||
expect(toModelInput(parseInput("100,50"), PAPER_UNITS, "length")).toEqual({ kind: "absolute", point: { x: 0.1, y: -0.05 } });
|
||||
expect(toModelInput(parseInput("r10,20"), PAPER_UNITS, "length")).toEqual({ kind: "relative", delta: { x: 0.01, y: -0.02 } });
|
||||
expect(toModelInput(parseInput("50<30"), PAPER_UNITS, "length")).toEqual({ kind: "polar", dist: 0.05, angleDeg: 30 });
|
||||
expect(toModelInput(parseInput("25"), PAPER_UNITS, "length")).toEqual({ kind: "distance", value: 0.025 });
|
||||
expect(toModelInput(parseInput("25"), PAPER_UNITS, "dy")).toEqual({ kind: "distance", value: -0.025 });
|
||||
// Anzahl/Winkel/Faktor bleiben; im Modell bleibt alles.
|
||||
expect(toModelInput(parseInput("5"), PAPER_UNITS, "none")).toEqual({ kind: "distance", value: 5 });
|
||||
expect(toModelInput(parseInput("100,50"), MODEL_UNITS, "length")).toEqual({ kind: "absolute", point: { x: 100, y: 50 } });
|
||||
});
|
||||
|
||||
it("Cursor-HUD in mm, Δy nach unten", () => {
|
||||
const segs = hudSegments({ at: { x: 0, y: 0 }, dx: 0.03, dy: -0.02 }, null, PAPER_UNITS).map((s) => s.text);
|
||||
expect(segs).toEqual(["Δx: 30.0mm", "Δy: 20.0mm"]);
|
||||
const l = hudSegments({ at: { x: 0, y: 0 }, length: 0.05, angleDeg: 90 }, null, PAPER_UNITS).map((s) => s.text);
|
||||
expect(l).toEqual(["L: 50.0mm", "W: 90.000°"]);
|
||||
const f = hudSegments({ at: { x: 0, y: 0 }, length: 0.05, angleDeg: 0 }, {
|
||||
fields: [
|
||||
{ id: "length", value: null, locked: false, active: true },
|
||||
{ id: "angle", value: 45, locked: true, active: false },
|
||||
],
|
||||
typed: "",
|
||||
}, PAPER_UNITS).map((s) => s.text);
|
||||
expect(f).toEqual(["L: 50.0mm", "W: 45.000°"]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,65 @@
|
||||
// Anzeige-Einheiten der 2D-Ansicht ([93]): im Modell Meter (y nach oben), auf einem offenen Layout-Blatt
|
||||
// Papier-mm mit y nach unten wie auf dem Papier (die Blatt-Ebene rechnet in Papier-Metern mit
|
||||
// Ursprung oben links und Papier-y = −y, s. `sheetMmToModel`). Lineale, Statusleiste, Objekt-Info,
|
||||
// Cursor-HUD und Befehlszeile zeigen Werte über diese Umrechnung und lesen getippte Werte zurück.
|
||||
|
||||
import type { Vec2 } from "../model/types";
|
||||
|
||||
export interface DisplayUnits {
|
||||
/** Anzeige-Einheiten je Meter (1 bzw. 1000). */
|
||||
perMeter: number;
|
||||
/** Einheit hinter der Zahl. */
|
||||
suffix: "m" | "mm";
|
||||
/** Nachkommastellen fester Anzeigen. */
|
||||
digits: number;
|
||||
/** Papier-y nach unten (Anzeige-y = −Modell-y). */
|
||||
flipY: boolean;
|
||||
}
|
||||
|
||||
export const MODEL_UNITS: DisplayUnits = { perMeter: 1, suffix: "m", digits: 3, flipY: false };
|
||||
export const PAPER_UNITS: DisplayUnits = { perMeter: 1000, suffix: "mm", digits: 1, flipY: true };
|
||||
|
||||
/** Einheiten der Ebene: Papier-mm auf einer Blatt-Ebene (`layoutId`), sonst Meter. */
|
||||
export function unitsForLevel(level: { layoutId?: string | null } | null | undefined): DisplayUnits {
|
||||
return level?.layoutId ? PAPER_UNITS : MODEL_UNITS;
|
||||
}
|
||||
|
||||
/** Länge (Meter) → Anzeige-Zahl. */
|
||||
export const lengthToDisplay = (u: DisplayUnits, m: number): number => m * u.perMeter;
|
||||
/** Anzeige-Zahl → Länge (Meter). */
|
||||
export const lengthFromDisplay = (u: DisplayUnits, v: number): number => v / u.perMeter;
|
||||
/** Modell-x → Anzeige-x. */
|
||||
export const xToDisplay = (u: DisplayUnits, x: number): number => x * u.perMeter;
|
||||
/** Modell-y → Anzeige-y (auf dem Papier nach unten). */
|
||||
export const yToDisplay = (u: DisplayUnits, y: number): number => (u.flipY ? -y : y) * u.perMeter;
|
||||
/** Anzeige-y → Modell-y. */
|
||||
export const yFromDisplay = (u: DisplayUnits, v: number): number => (u.flipY ? -v : v) / u.perMeter;
|
||||
/** Modell-Δy → Anzeige-Δy. */
|
||||
export const dyToDisplay = yToDisplay;
|
||||
|
||||
/** Zahl ohne „−0" und mit den festen Nachkommastellen der Einheit. */
|
||||
export function fmtDisplay(u: DisplayUnits, v: number, digits = u.digits): string {
|
||||
const r = Number(v.toFixed(digits));
|
||||
return (Object.is(r, -0) || Math.abs(r) < 10 ** -(digits + 1) ? 0 : r).toFixed(digits);
|
||||
}
|
||||
|
||||
/** Länge (Meter) als Text mit Einheit, z. B. „3.000m" bzw. „12.5mm". */
|
||||
export const fmtLength = (u: DisplayUnits, m: number): string => `${fmtDisplay(u, lengthToDisplay(u, m))}${u.suffix}`;
|
||||
|
||||
/** Lineal-Beschriftung einer x- bzw. y-Marke (Modell-Meter). */
|
||||
export function rulerLabel(u: DisplayUnits, axis: "x" | "y", v: number): string {
|
||||
const d = axis === "x" ? xToDisplay(u, v) : yToDisplay(u, v);
|
||||
if (u === MODEL_UNITS || u.perMeter === 1) return `${fmtDisplay(u, d, 3)}m`;
|
||||
// Papier: ganze mm, wo es aufgeht (Schritte ≥ 1 mm), sonst eine Stelle.
|
||||
const whole = Math.abs(d - Math.round(d)) < 1e-6;
|
||||
return `${fmtDisplay(u, d, whole ? 0 : 1)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getippte Koordinaten-/Längeneingabe (`parseInput`) in Modellwerte: Punkte und Längen aus Anzeige-
|
||||
* Einheiten in Meter, Papier-y zurück nach Modell-y. Winkel bleiben (gegen den Uhrzeigersinn auf dem
|
||||
* Bildschirm, wie im Modell).
|
||||
*/
|
||||
export function pointFromDisplay(u: DisplayUnits, p: Vec2): Vec2 {
|
||||
return { x: lengthFromDisplay(u, p.x), y: yFromDisplay(u, p.y) };
|
||||
}
|
||||
+14
-9
@@ -6,6 +6,8 @@
|
||||
// Abhängigkeit — reine Werte rein, Segmente raus.
|
||||
|
||||
import type { ToolDraft } from "./types";
|
||||
import { NON_LENGTH_FIELDS } from "../commands/parseInput";
|
||||
import { MODEL_UNITS, dyToDisplay, fmtDisplay, lengthToDisplay, type DisplayUnits } from "./displayUnits";
|
||||
|
||||
/** Ein Segment des Cursor-HUDs (z. B. "L: 3.000m"), + Tab-Zyklus-Zustand. */
|
||||
export interface HudSeg {
|
||||
@@ -31,7 +33,11 @@ export interface HudFieldsState {
|
||||
export function hudSegments(
|
||||
hud: NonNullable<ToolDraft["hud"]>,
|
||||
hudFields: HudFieldsState | null,
|
||||
/** Anzeige-Einheiten der Längen (Layout-Blatt: Papier-mm, Δy nach unten, [93]). */
|
||||
units: DisplayUnits = MODEL_UNITS,
|
||||
): HudSeg[] {
|
||||
const len = (m: number): string => fmtDisplay(units, lengthToDisplay(units, m));
|
||||
const u = units.suffix;
|
||||
const liveFor = (id: string): number | null =>
|
||||
id === "length"
|
||||
? (hud.length ?? null)
|
||||
@@ -48,22 +54,21 @@ export function hudSegments(
|
||||
if (hudFields && hudFields.fields.length > 0) {
|
||||
for (const f of hudFields.fields) {
|
||||
const label = labelFor(f.id);
|
||||
const unit = f.id === "angle" ? "°" : "m";
|
||||
const isLength = !NON_LENGTH_FIELDS.has(f.id);
|
||||
const unit = f.id === "angle" ? "°" : isLength ? u : "";
|
||||
const typedHere = f.active && hudFields.typed.trim() !== "";
|
||||
const value = typedHere
|
||||
? hudFields.typed
|
||||
: f.value != null
|
||||
? f.value.toFixed(3)
|
||||
: (liveFor(f.id)?.toFixed(3) ?? "—");
|
||||
const fmt = (v: number): string => (f.id === "height" ? fmtDisplay(units, dyToDisplay(units, v)) : isLength ? len(v) : v.toFixed(3));
|
||||
const live = liveFor(f.id);
|
||||
const value = typedHere ? hudFields.typed : f.value != null ? fmt(f.value) : live != null ? fmt(live) : "—";
|
||||
segs.push({ text: `${label}: ${value}${unit}`, active: f.active, locked: f.locked });
|
||||
}
|
||||
return segs;
|
||||
}
|
||||
if (hud.dx != null && hud.dy != null) {
|
||||
segs.push({ text: `Δx: ${hud.dx.toFixed(3)}m`, active: false, locked: false });
|
||||
segs.push({ text: `Δy: ${hud.dy.toFixed(3)}m`, active: false, locked: false });
|
||||
segs.push({ text: `Δx: ${len(hud.dx)}${u}`, active: false, locked: false });
|
||||
segs.push({ text: `Δy: ${fmtDisplay(units, dyToDisplay(units, hud.dy))}${u}`, active: false, locked: false });
|
||||
} else if (hud.length != null && hud.angleDeg != null) {
|
||||
segs.push({ text: `L: ${hud.length.toFixed(3)}m`, active: false, locked: false });
|
||||
segs.push({ text: `L: ${len(hud.length)}${u}`, active: false, locked: false });
|
||||
segs.push({ text: `W: ${hud.angleDeg.toFixed(3)}°`, active: false, locked: false });
|
||||
} else if (hud.text) {
|
||||
segs.push({ text: hud.text, active: false, locked: false });
|
||||
|
||||
+12
-7
@@ -8,6 +8,8 @@
|
||||
import { forwardRef, useImperativeHandle, useRef, useState } from "react";
|
||||
import { t } from "../i18n";
|
||||
import type { TranslationKey } from "../i18n";
|
||||
import { NON_LENGTH_FIELDS } from "../commands/parseInput";
|
||||
import { MODEL_UNITS, dyToDisplay, lengthToDisplay, type DisplayUnits } from "../tools/displayUnits";
|
||||
|
||||
export interface CommandLineOption {
|
||||
id: string;
|
||||
@@ -56,6 +58,8 @@ export interface CommandLineProps {
|
||||
onTextChange?: (text: string) => void;
|
||||
/** Autocomplete-Kandidaten für ein Präfix (nur im Ruhezustand sinnvoll). */
|
||||
suggest: (prefix: string) => string[];
|
||||
/** Anzeige-Einheiten der Längenfelder (Layout-Blatt: Papier-mm, [93]); Standard Meter. */
|
||||
units?: DisplayUnits;
|
||||
}
|
||||
|
||||
export interface CommandLineHandle {
|
||||
@@ -77,7 +81,7 @@ export interface CommandLineHandle {
|
||||
|
||||
export const CommandLine = forwardRef<CommandLineHandle, CommandLineProps>(
|
||||
function CommandLine(
|
||||
{ active, promptKey, options, fields, onSubmit, onOption, onCycleField, onCancel, suggest, onTextChange },
|
||||
{ active, promptKey, options, fields, onSubmit, onOption, onCycleField, onCancel, suggest, onTextChange, units = MODEL_UNITS },
|
||||
ref,
|
||||
) {
|
||||
const [text, setTextRaw] = useState("");
|
||||
@@ -202,12 +206,13 @@ export const CommandLine = forwardRef<CommandLineHandle, CommandLineProps>(
|
||||
// Winkelfeld in Grad, sonst Längen in Metern. Gelockte Werte fest
|
||||
// (mehr Nachkommastellen), live (maus-folgende) Werte gerundet.
|
||||
const isAngle = f.id === "angle";
|
||||
const digits = isAngle ? (f.locked ? 1 : 0) : f.locked ? 3 : 2;
|
||||
const unit = isAngle ? "°" : " m";
|
||||
const text =
|
||||
f.value == null
|
||||
? "—"
|
||||
: `${Number(f.value.toFixed(digits)).toString()}${unit}`;
|
||||
const isLength = !NON_LENGTH_FIELDS.has(f.id);
|
||||
const paper = isLength && units.perMeter !== 1;
|
||||
const digits = isAngle ? (f.locked ? 1 : 0) : paper ? (f.locked ? 2 : 1) : f.locked ? 3 : 2;
|
||||
const unit = isAngle ? "°" : ` ${units.suffix}`;
|
||||
const shown =
|
||||
f.value == null ? null : f.id === "height" ? dyToDisplay(units, f.value) : isLength ? lengthToDisplay(units, f.value) : f.value;
|
||||
const text = shown == null ? "—" : `${Number(shown.toFixed(digits)).toString()}${unit}`;
|
||||
return (
|
||||
<span
|
||||
key={f.id}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
// Rein gesteuert (controlled): alle Werte kommen aus App (Modell + View-State),
|
||||
// keine eigene Logik. Bezeichner englisch, UI-Text/Kommentare deutsch.
|
||||
|
||||
import { MODEL_UNITS, fmtDisplay, xToDisplay, yToDisplay, type DisplayUnits } from "../tools/displayUnits";
|
||||
import { useCursor } from "../state/cursorStore";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import type { SnapSettings } from "../tools/types";
|
||||
@@ -21,6 +22,8 @@ export interface StatusBarProps {
|
||||
showCursor: boolean;
|
||||
/** Einheit aus dem Projekt (vorerst fix „m"). */
|
||||
unit: string;
|
||||
/** Anzeige-Einheiten der Cursor-Koordinaten (Layout-Blatt: Papier-mm, y nach unten, [93]). */
|
||||
units?: DisplayUnits;
|
||||
/** Referenzlinien (Wandachsen) an/aus — sitzt jetzt in der Statusleiste. */
|
||||
referenceLines: boolean;
|
||||
/** Referenzlinien umschalten. */
|
||||
@@ -358,6 +361,7 @@ export function StatusBar({
|
||||
hint,
|
||||
showCursor,
|
||||
unit,
|
||||
units = MODEL_UNITS,
|
||||
referenceLines,
|
||||
onReferenceLines,
|
||||
referenceLinesEnabled,
|
||||
@@ -372,7 +376,9 @@ export function StatusBar({
|
||||
const liveCursor = useCursor();
|
||||
const cursor = showCursor ? liveCursor : null;
|
||||
const coords = cursor
|
||||
? `${fmt(cursor.x)}, ${fmt(cursor.y)}`
|
||||
? units === MODEL_UNITS
|
||||
? `${fmt(cursor.x)}, ${fmt(cursor.y)}`
|
||||
: `${fmtDisplay(units, xToDisplay(units, cursor.x))}, ${fmtDisplay(units, yToDisplay(units, cursor.y))}`
|
||||
: "—";
|
||||
|
||||
return (
|
||||
@@ -409,7 +415,7 @@ export function StatusBar({
|
||||
<Sep />
|
||||
<Field label={t("status.xy")} value={coords} />
|
||||
<Sep />
|
||||
<Field label={t("status.unit")} value={unit} />
|
||||
<Field label={t("status.unit")} value={units === MODEL_UNITS ? unit : units.suffix} />
|
||||
<Sep />
|
||||
<Field label={t("status.floor")} value={activeFloor} />
|
||||
<Sep />
|
||||
|
||||
@@ -43,6 +43,7 @@ import {
|
||||
import { DraftOverlay } from "./planView/overlays";
|
||||
import { visibleGripIndices } from "./planView/gripCull";
|
||||
import { localViewBoxAttr, makeToLocal, pickOverlayOrigin } from "./planView/overlayOrigin";
|
||||
import type { DisplayUnits } from "../../tools/displayUnits";
|
||||
import { PlanRulers } from "./planView/PlanRulers";
|
||||
import { PlanGrid } from "./planView/PlanGrid";
|
||||
import { expandRegion, indexedInRegion, regionContains, type Bounds } from "../../core";
|
||||
@@ -587,6 +588,8 @@ export interface PlanViewProps {
|
||||
* (wie bei Luftbildern), damit er sichtbar bleibt.
|
||||
*/
|
||||
backdrop?: (origin: Vec2, pxPerMeter: number) => ReactNode;
|
||||
/** Anzeige-Einheiten von Linealen und HUD (Layout-Blatt: Papier-mm, y nach unten, [93]). */
|
||||
units?: DisplayUnits;
|
||||
/** Einpass-Bereich (Modell-Meter) statt der Plan-Grenzen — z. B. das Blatt. */
|
||||
fitBounds?: { minX: number; minY: number; maxX: number; maxY: number };
|
||||
}
|
||||
@@ -715,6 +718,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
hoverDivideDelayMs = 300,
|
||||
hoverDivideCount = 2,
|
||||
backdrop,
|
||||
units,
|
||||
fitBounds,
|
||||
},
|
||||
ref,
|
||||
@@ -3535,6 +3539,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
vbPerPx={1 / meet}
|
||||
snapColor={snapColor}
|
||||
hudFields={hudFields ?? null}
|
||||
units={units}
|
||||
/>
|
||||
)}
|
||||
</LiveMeet>
|
||||
@@ -3698,6 +3703,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
vbPerPx={1 / scale}
|
||||
pxPerMeter={scale * PX_PER_M}
|
||||
store={rulerCursor}
|
||||
units={units}
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import type { Vec2 } from "../../../model/types";
|
||||
import { PX_PER_M } from "../../../core";
|
||||
import { MODEL_UNITS, rulerLabel, type DisplayUnits } from "../../../tools/displayUnits";
|
||||
|
||||
/**
|
||||
* Schrittweite (Meter) fürs Lineal: 1/2/5·10^n, sodass Major-Ticks ≥ ~64 px
|
||||
@@ -30,6 +31,7 @@ export function PlanRulers({
|
||||
vbPerPx,
|
||||
pxPerMeter,
|
||||
cursor,
|
||||
units = MODEL_UNITS,
|
||||
}: {
|
||||
/** Sichtbarer Ausschnitt in (absoluten) viewBox-Einheiten. */
|
||||
vb: { x0: number; y0: number; w: number; h: number };
|
||||
@@ -41,13 +43,15 @@ export function PlanRulers({
|
||||
vbPerPx: number;
|
||||
pxPerMeter: number;
|
||||
cursor: Vec2 | null;
|
||||
/** Beschriftung: Meter (Modell) oder Papier-mm mit y nach unten (Layout-Blatt, [93]). */
|
||||
units?: DisplayUnits;
|
||||
}) {
|
||||
const TH = 20 * vbPerPx; // Leisten-Dicke (screen-px → viewBox)
|
||||
const step = rulerStep(pxPerMeter);
|
||||
const minor = step / 5;
|
||||
const font = 9 * vbPerPx;
|
||||
// Negative Null vermeiden („−0.000m" bei Startwerten knapp unter 0).
|
||||
const label = (v: number): string => `${(Math.abs(v) < 1e-9 ? 0 : v).toFixed(3)}m`;
|
||||
const label = (axis: "x" | "y", v: number): string => rulerLabel(units, axis, v);
|
||||
|
||||
// Sichtbarer Modellbereich (Plan-Y nach oben: vbY = −y·PX_PER_M).
|
||||
const mx0 = vb.x0 / PX_PER_M;
|
||||
@@ -91,7 +95,7 @@ export function PlanRulers({
|
||||
/>
|
||||
{t.major && (
|
||||
<text className="plan-ruler-text" x={t.vbX + 3 * vbPerPx} y={y0 + TH * 0.42} fontSize={font}>
|
||||
{label(t.model)}
|
||||
{label("x", t.model)}
|
||||
</text>
|
||||
)}
|
||||
</g>
|
||||
@@ -116,7 +120,7 @@ export function PlanRulers({
|
||||
fontSize={font}
|
||||
transform={`rotate(-90 ${x0 + TH * 0.42} ${t.vbY - 3 * vbPerPx})`}
|
||||
>
|
||||
{label(t.model)}
|
||||
{label("y", t.model)}
|
||||
</text>
|
||||
)}
|
||||
</g>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
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";
|
||||
|
||||
/**
|
||||
* Zeichnet die Werkzeug-Vorschau: Vorschau-Formen (gestrichelte Akzentlinien /
|
||||
@@ -22,12 +23,15 @@ export function DraftOverlay({
|
||||
vbPerPx,
|
||||
snapColor,
|
||||
hudFields = null,
|
||||
units = MODEL_UNITS,
|
||||
}: {
|
||||
draft: ToolDraft;
|
||||
toScreen: (v: Vec2) => Vec2;
|
||||
vbPerPx: number;
|
||||
snapColor: string;
|
||||
hudFields?: HudFieldsState | null;
|
||||
/** Anzeige-Einheiten des HUDs (Layout-Blatt: Papier-mm). */
|
||||
units?: DisplayUnits;
|
||||
}) {
|
||||
const vertSize = 4.5 * vbPerPx; // halbe Kantenlänge eines Stützpunkt-Quadrats (klein + einheitlich)
|
||||
const markSize = 4.75 * vbPerPx; // halbe Kantenlänge des Snap-Markers (klein + fein)
|
||||
@@ -84,7 +88,7 @@ export function DraftOverlay({
|
||||
<SnapMarker snap={draft.snap} toScreen={toScreen} size={markSize} color={snapColor} />
|
||||
)}
|
||||
{/* Maß-/Winkel-HUD am Cursor (VW-Stil `L: … W: …`, oder einfacher Text). */}
|
||||
{draft.hud && <DraftHud hud={draft.hud} toScreen={toScreen} vbPerPx={vbPerPx} hudFields={hudFields} />}
|
||||
{draft.hud && <DraftHud hud={draft.hud} toScreen={toScreen} vbPerPx={vbPerPx} hudFields={hudFields} units={units} />}
|
||||
</g>
|
||||
);
|
||||
}
|
||||
@@ -101,15 +105,17 @@ function DraftHud({
|
||||
toScreen,
|
||||
vbPerPx,
|
||||
hudFields = null,
|
||||
units,
|
||||
}: {
|
||||
hud: NonNullable<ToolDraft["hud"]>;
|
||||
toScreen: (v: Vec2) => Vec2;
|
||||
vbPerPx: number;
|
||||
hudFields?: HudFieldsState | null;
|
||||
units: DisplayUnits;
|
||||
}) {
|
||||
// Segmente: gemeinsame Formatierung mit dem 3D-Pendant (Wasm3DViewport.tsx),
|
||||
// s. `tools/hudFormat.ts`.
|
||||
const segs = hudSegments(hud, hudFields);
|
||||
const segs = hudSegments(hud, hudFields, units);
|
||||
if (segs.length === 0) return null;
|
||||
|
||||
const p = toScreen(hud.at);
|
||||
@@ -276,7 +282,7 @@ function SnapMarker({
|
||||
const helperStyle = { stroke: color };
|
||||
const fillStyle = { stroke: color, fill: color };
|
||||
return (
|
||||
<g className="snap-marker">
|
||||
<g className="snap-marker" data-snap-kind={snap.kind}>
|
||||
{(snap.kind === "ortho" || snap.kind === "extension") && snap.refA && (
|
||||
<line
|
||||
className="snap-helper-line"
|
||||
|
||||
@@ -33,6 +33,7 @@ import type { SectionOutput } from "../core";
|
||||
import { generateElevationPlan } from "../core";
|
||||
import { crossKindOverlayAllowed, planUnderlayPrimitives } from "../core";
|
||||
import { levelMarkerPrimitives, levelMarksEnabled } from "../core";
|
||||
import { unitsForLevel } from "../tools/displayUnits";
|
||||
import { setSheetOwnerOutlines, setSheetSnapSegments, snapSegmentsFromPrimitives } from "../tools/sheetSnapGeometry";
|
||||
import { pushNativeScene, pushNativeWalls } from "./plan/nativeSync";
|
||||
import { selectionHighlightLines } from "../core";
|
||||
@@ -952,6 +953,7 @@ function LevelPlanView({
|
||||
selectedDrawingIds={selectedDrawingIds}
|
||||
gripHandlers={gripHandlers}
|
||||
backdrop={backdrop}
|
||||
units={unitsForLevel(level)}
|
||||
fitBounds={fitBounds}
|
||||
/>
|
||||
{/* NACH PlanView gerendert (nicht als box-shadow auf .pane), damit der
|
||||
|
||||
Reference in new issue
Block a user