[38][112] Achsraster (rechtwinklig/radial, Blasen, Fang, Schnitt/Ansicht, DXF, Griffe), Bemassung an Rasterachsen, Bogenwänden, Treppen; Radius-/Durchmesser-/Bogenlängen-Mass; Autodim für nicht mittige Wände
This commit is contained in:
41 files changed
+2351
-72
No files matched your search
@@ -292,6 +292,7 @@ const TOOL_COMMAND: Partial<Record<ToolId, string>> = {
|
||||
scalebar: "scalebar",
|
||||
revcloud: "revcloud",
|
||||
pointmarker: "pointmarker",
|
||||
grid: "grid",
|
||||
wipeout: "wipeout",
|
||||
text: "text",
|
||||
leader: "leader",
|
||||
|
||||
+1
-1
@@ -603,7 +603,7 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
const o = await computeSection(project, lvl);
|
||||
if (!o) fail("keine gültige Schnittlinie");
|
||||
// Wie die App: verdeckte Kanten nach der Ebene, geschnittene Fenster/Türen.
|
||||
plan = generateSectionPlan(o, false, { visibleCodes: allCodes, hiddenLines: lvl.hiddenLines, openings: true });
|
||||
plan = generateSectionPlan(o, false, { visibleCodes: allCodes, hiddenLines: lvl.hiddenLines, openings: true, scaleDenominator: scale });
|
||||
} else {
|
||||
plan = generateElevationPlan(project, lvl, { scaleDenominator: scale });
|
||||
if (!plan) fail("keine gültige Ansichtslinie");
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// Radius-, Durchmesser- und Bogenlängen-Bemassung ([38]): Klick auf den Rand eines Kreises, Bogens oder
|
||||
// einer Bogenwand (Fläche oder Achse). Der Kern (`cmd_draw.rs`, `dim_assoc::round_dimension`) findet den
|
||||
// Kreis, setzt Mittelpunkt und Randpunkte und hängt sie daran (Bezug `center`/`rim`): Verschieben oder
|
||||
// Vergrössern des Kreises, Strecken der Bogenwand führt das Mass nach. Radius und Durchmesser: ein Klick;
|
||||
// Bogenlänge: Anfang, Ende (gegen den Uhrzeigersinn), dann Lage der Masslinie.
|
||||
|
||||
import type { Command, CommandContext, CommandResult, CommandState, ToolDraft, Vec2 } from "../types";
|
||||
import { createMutation, createPreview, xy } from "../createCore";
|
||||
|
||||
export type RoundKind = "radius" | "diameter" | "arc";
|
||||
|
||||
interface RoundState extends CommandState {
|
||||
phase: "first" | "second" | "offset";
|
||||
pts: Vec2[];
|
||||
}
|
||||
|
||||
const fresh = (): RoundState => ({ phase: "first", lastPoint: null, pts: [] });
|
||||
const idle = (): [CommandState, CommandResult] => [fresh(), { draft: null, done: true }];
|
||||
|
||||
/** Fangtoleranz auf dem Rand (Modell-Meter). */
|
||||
const TOL = 0.2;
|
||||
|
||||
function draft(ctx: CommandContext, kind: RoundKind, pts: Vec2[], cursor: Vec2 | null): ToolDraft | null {
|
||||
const all = cursor ? [...pts, cursor] : pts;
|
||||
if (all.length === 0) return null;
|
||||
const pv = createPreview(ctx, { cmd: "dimround", kind, tol: TOL }, all);
|
||||
return { preview: pv.shapes, vertices: pts };
|
||||
}
|
||||
|
||||
function make(kind: RoundKind, name: string): Command {
|
||||
const keyOf = (s: RoundState) => (s.phase === "first" ? `cmd.${name}.first` : s.phase === "second" ? `cmd.${name}.second` : `cmd.${name}.offset`);
|
||||
return {
|
||||
name,
|
||||
labelKey: `cmd.${name}.label` as never,
|
||||
prompt: (s) => keyOf(s as RoundState) as never,
|
||||
accepts: () => ["point"],
|
||||
options: () => [],
|
||||
init: fresh,
|
||||
|
||||
onInput: (state, input, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as RoundState;
|
||||
if (input.kind !== "point") return [s, { draft: null }];
|
||||
const pts = [...s.pts, input.point];
|
||||
if (kind !== "arc" || s.phase === "offset") {
|
||||
const commit = createMutation(ctx, { cmd: "dimround", kind, tol: TOL, pts: pts.slice(0, kind === "arc" ? 2 : 1).map(xy), side: kind === "arc" ? xy(input.point) : null });
|
||||
return [fresh(), { draft: null, done: true, commit }];
|
||||
}
|
||||
const ns: RoundState = { phase: pts.length >= 2 ? "offset" : "second", pts, lastPoint: input.point };
|
||||
return [ns, { draft: draft(ctx, kind, pts, null) }];
|
||||
},
|
||||
|
||||
onMove: (state, point, _snap, ctx): [CommandState, CommandResult] => [state, { draft: draft(ctx, kind, (state as RoundState).pts, point) }],
|
||||
onConfirm: () => idle(),
|
||||
onCancel: () => idle(),
|
||||
};
|
||||
}
|
||||
|
||||
export const radiusDimCommand = make("radius", "dimradius");
|
||||
export const diameterDimCommand = make("diameter", "dimdiameter");
|
||||
export const arcDimCommand = make("arc", "dimarc");
|
||||
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* `gridCommand` ([112]) und die Rundmass-Befehle ([38]): Eingabe → Zeichnung im Kern. Die Nachführung der
|
||||
* Bezüge im Store prüft `src/state/gridAssoc.test.ts`.
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { gridCommand } from "./grid";
|
||||
import { arcDimCommand, diameterDimCommand, radiusDimCommand } from "./dimround";
|
||||
import type { CommandContext, Project } from "../types";
|
||||
import type { Drawing2D } from "../../model/types";
|
||||
|
||||
function project(extra: Drawing2D[] = []): Project {
|
||||
return {
|
||||
id: "t",
|
||||
name: "T",
|
||||
lineStyles: [],
|
||||
hatches: [],
|
||||
components: [],
|
||||
wallTypes: [],
|
||||
drawingLevels: [{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0 }],
|
||||
layers: [{ code: "20", name: "Zeichnung", color: "#0a0a0a", lw: 0.5, visible: true, locked: false }],
|
||||
walls: [],
|
||||
openings: [],
|
||||
ceilings: [],
|
||||
stairs: [],
|
||||
rooms: [],
|
||||
drawings2d: extra,
|
||||
context: [],
|
||||
};
|
||||
}
|
||||
|
||||
function ctxOf(p: Project): CommandContext {
|
||||
return { project: p, level: p.drawingLevels[0], defaultCategoryCode: "20", activeLineStyleId: "solid", activeWallTypeId: "aw", lastPoint: null, selection: { wallIds: [], drawingId: null } };
|
||||
}
|
||||
|
||||
describe("gridCommand", () => {
|
||||
it("Ursprung + Feldweiten → Achsraster mit Beschriftung 1, 2, 3 / A, B", () => {
|
||||
const p = project();
|
||||
const ctx = ctxOf(p);
|
||||
let [s] = gridCommand.onInput(gridCommand.init(), { kind: "point", point: { x: 2, y: 1 } }, ctx);
|
||||
[s] = gridCommand.onInput(s, { kind: "text", text: "6 4.5 3x5" }, ctx);
|
||||
const [, r] = gridCommand.onInput(s, { kind: "text", text: "5 5" }, ctx);
|
||||
expect(r.done).toBe(true);
|
||||
const g = r.commit!(p).drawings2d[0].geom;
|
||||
expect(g.shape).toBe("grid");
|
||||
if (g.shape !== "grid") return;
|
||||
expect(g.origin).toEqual({ x: 2, y: 1 });
|
||||
expect(g.a.map((x) => [x.label, x.pos])).toEqual([["1", 0], ["2", 6], ["3", 10.5], ["4", 15.5], ["5", 20.5], ["6", 25.5]]);
|
||||
expect(g.b.map((x) => [x.label, x.pos])).toEqual([["A", 0], ["B", 5], ["C", 10]]);
|
||||
});
|
||||
|
||||
it("radial: Option umschalten, Strahlen und Ringe; Enter übernimmt die Vorgaben", () => {
|
||||
const p = project();
|
||||
const ctx = ctxOf(p);
|
||||
let [s] = gridCommand.onInput(gridCommand.init(), { kind: "option", id: "radial" }, ctx);
|
||||
[s] = gridCommand.onInput(s, { kind: "point", point: { x: 0, y: 0 } }, ctx);
|
||||
[s] = gridCommand.onInput(s, { kind: "text", text: "2x45" }, ctx);
|
||||
const [, r] = gridCommand.onInput(s, { kind: "text", text: "3 3" }, ctx);
|
||||
const g = r.commit!(p).drawings2d[0].geom;
|
||||
expect(g.shape === "grid" && g.radial).toBe(true);
|
||||
if (g.shape === "grid") {
|
||||
expect(g.a.map((x) => x.pos)).toEqual([0, 45, 90]);
|
||||
expect(g.b.map((x) => x.pos)).toEqual([3, 6]);
|
||||
}
|
||||
// Vorgaben (Enter, Enter) im rechtwinkligen Raster: 6 6 6 / 6 6.
|
||||
let [t] = gridCommand.onInput(gridCommand.init(), { kind: "point", point: { x: 0, y: 0 } }, ctx);
|
||||
[t] = gridCommand.onConfirm(t, ctx);
|
||||
const [, e] = gridCommand.onConfirm(t, ctx);
|
||||
const d = e.commit!(p).drawings2d[0].geom;
|
||||
expect(d.shape === "grid" && [d.a.length, d.b.length]).toEqual([4, 3]);
|
||||
});
|
||||
|
||||
it("unlesbare Feldweiten legen nichts an; Vorschau am Cursor liefert Achsen", () => {
|
||||
const p = project();
|
||||
const ctx = ctxOf(p);
|
||||
let [s] = gridCommand.onInput(gridCommand.init(), { kind: "point", point: { x: 0, y: 0 } }, ctx);
|
||||
[s] = gridCommand.onInput(s, { kind: "text", text: "abc" }, ctx);
|
||||
const [, r] = gridCommand.onInput(s, { kind: "text", text: "5" }, ctx);
|
||||
expect(r.commit!(p).drawings2d.length).toBe(0);
|
||||
const [, mv] = gridCommand.onMove(gridCommand.init(), { x: 1, y: 1 }, null, ctx);
|
||||
expect(mv.draft?.preview.length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Rundmass-Befehle", () => {
|
||||
const circle = { id: "K", type: "drawing2d", levelId: "eg", categoryCode: "20", geom: { shape: "circle", center: { x: 5, y: 5 }, r: 2 } } as Drawing2D;
|
||||
|
||||
it("Radius/Durchmesser: ein Klick auf den Rand → Mass mit Bezug", () => {
|
||||
for (const [cmd, kind] of [[radiusDimCommand, "radius"], [diameterDimCommand, "diameter"]] as const) {
|
||||
const p = project([circle]);
|
||||
const [, r] = cmd.onInput(cmd.init(), { kind: "point", point: { x: 7, y: 5.02 } }, ctxOf(p));
|
||||
const g = r.commit!(p).drawings2d[1].geom;
|
||||
expect(g.shape === "dimension" && g.kind).toBe(kind);
|
||||
expect(g.shape === "dimension" && g.refs?.map((x) => x?.feature)).toEqual(["center", "rim"]);
|
||||
}
|
||||
});
|
||||
|
||||
it("Bogenlänge: Anfang, Ende, Lage → drei Punkte; Klick ins Leere legt nichts an", () => {
|
||||
const p = project([circle]);
|
||||
const ctx = ctxOf(p);
|
||||
let [s] = arcDimCommand.onInput(arcDimCommand.init(), { kind: "point", point: { x: 7, y: 5 } }, ctx);
|
||||
[s] = arcDimCommand.onInput(s, { kind: "point", point: { x: 5, y: 7 } }, ctx);
|
||||
const [, r] = arcDimCommand.onInput(s, { kind: "point", point: { x: 5, y: 8 } }, ctx);
|
||||
const dim = r.commit!(p).drawings2d[1];
|
||||
expect(dim.geom.shape === "dimension" && dim.geom.pts.length).toBe(3);
|
||||
expect(dim.geom.shape === "dimension" && dim.geom.offset).toBeCloseTo(1, 6);
|
||||
const [, none] = radiusDimCommand.onInput(radiusDimCommand.init(), { kind: "point", point: { x: 50, y: 50 } }, ctx);
|
||||
expect(none.commit!(p).drawings2d.length).toBe(1);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,95 @@
|
||||
// Achsraster ([112]): Ursprung klicken, dann die Feldweiten als Text (`6 4.5 3x5`: Zahlen, `N x W` =
|
||||
// N Felder zu W). Rechtwinklig: erst die Richtung 1, 2, 3 …, dann A, B, C …; radial: Strahlwinkel in
|
||||
// Grad und Ringabstände. Das Raster ist eine 2D-Zeichnung (Kern, `grid.rs`): Achsen mit Blasen in
|
||||
// allen Plänen, Schnitten und Ansichten, Fang auf Achsen und Schnittpunkte, Griffe je Achse.
|
||||
|
||||
import type { Command, CommandContext, CommandResult, CommandState, CmdOption, ToolDraft, Vec2 } from "../types";
|
||||
import { createMutation, createPreview, xy } from "../createCore";
|
||||
|
||||
type Phase = "origin" | "xs" | "ys";
|
||||
|
||||
interface GridState extends CommandState {
|
||||
phase: Phase;
|
||||
origin: Vec2 | null;
|
||||
radial: boolean;
|
||||
xs: string;
|
||||
ys: string;
|
||||
}
|
||||
|
||||
const DEFAULTS = {
|
||||
ortho: { xs: "6 6 6", ys: "6 6" },
|
||||
radial: { xs: "4x45", ys: "3 3 3" },
|
||||
};
|
||||
|
||||
const RADIAL: CmdOption = { id: "radial", labelKey: "cmd.grid.radial" };
|
||||
|
||||
const start = (radial = false): GridState => ({
|
||||
phase: "origin",
|
||||
lastPoint: null,
|
||||
origin: null,
|
||||
radial,
|
||||
xs: radial ? DEFAULTS.radial.xs : DEFAULTS.ortho.xs,
|
||||
ys: radial ? DEFAULTS.radial.ys : DEFAULTS.ortho.ys,
|
||||
});
|
||||
|
||||
const idle = (): [CommandState, CommandResult] => [start(), { draft: null, done: true }];
|
||||
|
||||
/** Vorschau (Kern): die Achsen des Rasters am Cursor. */
|
||||
function draft(ctx: CommandContext, s: GridState, at: Vec2): ToolDraft {
|
||||
const pv = createPreview(ctx, { cmd: "grid", xs: s.xs, ys: s.ys, radial: s.radial, angle: 0 }, [at]);
|
||||
return { preview: pv.shapes, vertices: [at] };
|
||||
}
|
||||
|
||||
const commit = (ctx: CommandContext, s: GridState, ys: string) =>
|
||||
createMutation(ctx, { cmd: "grid", at: xy(s.origin as Vec2), xs: s.xs, ys, radial: s.radial, angle: 0 });
|
||||
|
||||
export const gridCommand: Command = {
|
||||
name: "grid",
|
||||
labelKey: "cmd.grid.label",
|
||||
prompt: (state) => {
|
||||
const s = state as GridState;
|
||||
if (s.phase === "origin") return "cmd.grid.origin";
|
||||
if (s.phase === "xs") return s.radial ? "cmd.grid.xsRadial" : "cmd.grid.xs";
|
||||
return s.radial ? "cmd.grid.ysRadial" : "cmd.grid.ys";
|
||||
},
|
||||
accepts: (state) => ((state as GridState).phase === "origin" ? ["point", "option"] : ["text"]),
|
||||
options: (state): CmdOption[] => ((state as GridState).phase === "origin" ? [{ ...RADIAL, value: (state as GridState).radial ? "ja" : "nein" }] : []),
|
||||
floorOnly: false,
|
||||
init: () => start(),
|
||||
|
||||
onInput: (state, input, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as GridState;
|
||||
if (s.phase === "origin") {
|
||||
if (input.kind === "option" && input.id === "radial") return [start(!s.radial), { draft: null }];
|
||||
if (input.kind !== "point") return [s, { draft: null }];
|
||||
const ns: GridState = { ...s, phase: "xs", origin: input.point, lastPoint: input.point };
|
||||
return [ns, { draft: draft(ctx, ns, input.point) }];
|
||||
}
|
||||
if (input.kind !== "text") return [s, { draft: null }];
|
||||
const text = input.text.trim();
|
||||
if (s.phase === "xs") {
|
||||
const ns: GridState = { ...s, phase: "ys", xs: text === "" ? s.xs : text };
|
||||
return [ns, { draft: s.origin ? draft(ctx, ns, s.origin) : null }];
|
||||
}
|
||||
const ys = text === "" && !s.radial ? s.ys : text;
|
||||
return [start(), { draft: null, done: true, commit: commit(ctx, s, ys) }];
|
||||
},
|
||||
|
||||
onMove: (state, point, _snap, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as GridState;
|
||||
if (s.phase !== "origin") return [s, { draft: s.origin ? draft(ctx, s, s.origin) : null }];
|
||||
return [s, { draft: draft(ctx, s, point) }];
|
||||
},
|
||||
|
||||
// Enter: Vorgabe-Feldweiten übernehmen.
|
||||
onConfirm: (state, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as GridState;
|
||||
if (s.phase === "origin") return idle();
|
||||
if (s.phase === "xs") {
|
||||
const ns: GridState = { ...s, phase: "ys" };
|
||||
return [ns, { draft: s.origin ? draft(ctx, ns, s.origin) : null }];
|
||||
}
|
||||
return [start(), { draft: null, done: true, commit: commit(ctx, s, s.ys) }];
|
||||
},
|
||||
onCancel: () => idle(),
|
||||
};
|
||||
@@ -47,6 +47,8 @@ import { scaleCommand } from "./cmds/scale";
|
||||
import { explodeCommand } from "./cmds/explode";
|
||||
import { dimdetachCommand } from "./cmds/dimdetach";
|
||||
import { autodimCommand } from "./cmds/autodim";
|
||||
import { gridCommand } from "./cmds/grid";
|
||||
import { arcDimCommand, diameterDimCommand, radiusDimCommand } from "./cmds/dimround";
|
||||
import { alignCommand } from "./cmds/align";
|
||||
import { joinCommand } from "./cmds/join";
|
||||
import { copyCommand } from "./cmds/copy";
|
||||
@@ -115,6 +117,10 @@ export const COMMANDS: Record<string, Command> = {
|
||||
explode: explodeCommand,
|
||||
dimdetach: dimdetachCommand,
|
||||
autodim: autodimCommand,
|
||||
grid: gridCommand,
|
||||
dimradius: radiusDimCommand,
|
||||
dimdiameter: diameterDimCommand,
|
||||
dimarc: arcDimCommand,
|
||||
align: alignCommand,
|
||||
join: joinCommand,
|
||||
copy: copyCommand,
|
||||
@@ -236,6 +242,15 @@ export const ALIASES: Record<string, string> = {
|
||||
bml: "dimdetach",
|
||||
bemassungloesen: "dimdetach",
|
||||
ab: "autodim",
|
||||
axes: "grid",
|
||||
achsraster: "grid",
|
||||
achsen: "grid",
|
||||
rad: "dimradius",
|
||||
radiusmass: "dimradius",
|
||||
dm: "dimdiameter",
|
||||
durchmessermass: "dimdiameter",
|
||||
bogenl: "dimarc",
|
||||
bogenlaenge: "dimarc",
|
||||
aussenbemassung: "autodim",
|
||||
al: "align",
|
||||
ausrichten: "align",
|
||||
|
||||
@@ -208,6 +208,8 @@ export const de = {
|
||||
"tool.revcloud.hint": "Revisionswolke: Punkte wie Polylinie klicken, Enter beendet offen, Klick nahe Start oder \"Schliessen\" schliesst",
|
||||
"tool.pointmarker": "Punktmarker",
|
||||
"tool.pointmarker.hint": "Punktmarker: Punkt setzen — Kreuz-in-Kreis-Symbol markiert einen Referenzpunkt",
|
||||
"tool.grid": "Achsraster",
|
||||
"tool.grid.hint": "Achsraster: Ursprung setzen, dann Feldweiten eingeben — Achsen mit Blasen in allen Plänen, Schnitten und Ansichten",
|
||||
"tool.wipeout": "Maskenregion",
|
||||
"tool.wipeout.hint": "Maskenregion: Punkte wie Polylinie klicken, Klick nahe Start oder Enter (ab 3 Punkten) schliesst und deckt darunterliegende Zeichnung ab",
|
||||
"tool.text": "Text",
|
||||
@@ -384,6 +386,17 @@ export const de = {
|
||||
"attr.ends.tick": "Schrägstrich",
|
||||
"attr.ends.square": "Quadrat",
|
||||
"attr.dim.section": "Bemassung",
|
||||
"attr.grid.section": "Achsraster",
|
||||
"attr.grid.bubbles": "Achsblasen",
|
||||
"attr.grid.bubbles.both": "Beide Enden",
|
||||
"attr.grid.bubbles.start": "Nur Anfang",
|
||||
"attr.grid.bubbles.end": "Nur Ende",
|
||||
"attr.grid.extend": "Überstand (m)",
|
||||
"attr.grid.bubbleMm": "Blase Ø (mm)",
|
||||
"attr.grid.levels": "Sichtbar in",
|
||||
"attr.grid.show3d": "Im 3D-Modell zeigen",
|
||||
"attr.grid.levels.all": "Allen Geschossen",
|
||||
"attr.grid.levels.here": "Nur diesem Geschoss",
|
||||
"attr.dim.gap": "Abstand Hilfslinie (mm)",
|
||||
"attr.dim.overshoot": "Überstand (mm)",
|
||||
"attr.dim.tick": "Massstrich-Länge (mm)",
|
||||
@@ -1766,6 +1779,23 @@ export const de = {
|
||||
"cmd.revcloud.arcSize": "Beulengrösse",
|
||||
"cmd.pointmarker.label": "Punktmarker",
|
||||
"cmd.pointmarker.point": "Punkt:",
|
||||
"cmd.grid.label": "Achsraster",
|
||||
"cmd.grid.origin": "Ursprung des Achsrasters ( Radial ):",
|
||||
"cmd.grid.radial": "Radial",
|
||||
"cmd.grid.xs": "Feldweiten Achsen 1, 2, 3 … (z. B. 6 4.5 3x5, Enter = 6 6 6):",
|
||||
"cmd.grid.ys": "Feldweiten Achsen A, B, C … (z. B. 5 5, Enter = 6 6):",
|
||||
"cmd.grid.xsRadial": "Strahlwinkel in Grad (z. B. 8x45, Enter = 4x45):",
|
||||
"cmd.grid.ysRadial": "Ringabstände ab der Mitte (z. B. 3 3 4):",
|
||||
"cmd.dimradius.label": "Radiusmass",
|
||||
"cmd.dimradius.first": "Kreis, Bogen oder Bogenwand anklicken:",
|
||||
"cmd.dimdiameter.label": "Durchmessermass",
|
||||
"cmd.dimdiameter.first": "Kreis, Bogen oder Bogenwand anklicken:",
|
||||
"cmd.dimarc.label": "Bogenlänge",
|
||||
"cmd.dimarc.first": "Bogenanfang auf Kreis, Bogen oder Bogenwand:",
|
||||
"cmd.dimarc.second": "Bogenende:",
|
||||
"cmd.dimarc.offset": "Lage der Masslinie:",
|
||||
"history.cmd.grid": "Achsraster",
|
||||
"history.cmd.dimround": "Radius-/Bogenmass",
|
||||
"cmd.wipeout.label": "Maskenregion",
|
||||
"cmd.wipeout.start": "Startpunkt:",
|
||||
"cmd.wipeout.next": "Nächster Punkt:",
|
||||
|
||||
@@ -206,6 +206,8 @@ export const en: Record<TranslationKey, string> = {
|
||||
"tool.revcloud.hint": "Revision cloud: click points like a polyline, Enter finishes open, clicking near start or \"Close\" closes it",
|
||||
"tool.pointmarker": "Point marker",
|
||||
"tool.pointmarker.hint": "Point marker: set a point — a cross-in-circle symbol marks a reference point",
|
||||
"tool.grid": "Structural grid",
|
||||
"tool.grid.hint": "Structural grid: set the origin, then enter bay widths — axes with bubbles in all plans, sections and elevations",
|
||||
"tool.wipeout": "Mask region",
|
||||
"tool.wipeout.hint": "Mask region: click points like a polyline, clicking near start or Enter (3+ points) closes and covers the drawing underneath",
|
||||
"tool.text": "Text",
|
||||
@@ -382,6 +384,17 @@ export const en: Record<TranslationKey, string> = {
|
||||
"attr.ends.tick": "Tick",
|
||||
"attr.ends.square": "Square",
|
||||
"attr.dim.section": "Dimension",
|
||||
"attr.grid.section": "Structural grid",
|
||||
"attr.grid.bubbles": "Axis bubbles",
|
||||
"attr.grid.bubbles.both": "Both ends",
|
||||
"attr.grid.bubbles.start": "Start only",
|
||||
"attr.grid.bubbles.end": "End only",
|
||||
"attr.grid.extend": "Extension (m)",
|
||||
"attr.grid.bubbleMm": "Bubble Ø (mm)",
|
||||
"attr.grid.levels": "Visible on",
|
||||
"attr.grid.show3d": "Show in 3D model",
|
||||
"attr.grid.levels.all": "All levels",
|
||||
"attr.grid.levels.here": "This level only",
|
||||
"attr.dim.gap": "Extension gap (mm)",
|
||||
"attr.dim.overshoot": "Overshoot (mm)",
|
||||
"attr.dim.tick": "Tick length (mm)",
|
||||
@@ -1755,6 +1768,23 @@ export const en: Record<TranslationKey, string> = {
|
||||
"cmd.revcloud.arcSize": "Arc size",
|
||||
"cmd.pointmarker.label": "Point marker",
|
||||
"cmd.pointmarker.point": "Point:",
|
||||
"cmd.grid.label": "Structural grid",
|
||||
"cmd.grid.origin": "Grid origin ( Radial ):",
|
||||
"cmd.grid.radial": "Radial",
|
||||
"cmd.grid.xs": "Bay widths for axes 1, 2, 3 … (e.g. 6 4.5 3x5, Enter = 6 6 6):",
|
||||
"cmd.grid.ys": "Bay widths for axes A, B, C … (e.g. 5 5, Enter = 6 6):",
|
||||
"cmd.grid.xsRadial": "Ray angles in degrees (e.g. 8x45, Enter = 4x45):",
|
||||
"cmd.grid.ysRadial": "Ring spacings from the centre (e.g. 3 3 4):",
|
||||
"cmd.dimradius.label": "Radius dimension",
|
||||
"cmd.dimradius.first": "Pick a circle, arc or arc wall:",
|
||||
"cmd.dimdiameter.label": "Diameter dimension",
|
||||
"cmd.dimdiameter.first": "Pick a circle, arc or arc wall:",
|
||||
"cmd.dimarc.label": "Arc length",
|
||||
"cmd.dimarc.first": "Arc start on a circle, arc or arc wall:",
|
||||
"cmd.dimarc.second": "Arc end:",
|
||||
"cmd.dimarc.offset": "Position of the dimension line:",
|
||||
"history.cmd.grid": "Structural grid",
|
||||
"history.cmd.dimround": "Radius/arc dimension",
|
||||
"cmd.wipeout.label": "Mask region",
|
||||
"cmd.wipeout.start": "Start point:",
|
||||
"cmd.wipeout.next": "Next point:",
|
||||
|
||||
@@ -521,7 +521,16 @@ 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";
|
||||
export type DimFeature =
|
||||
| "wall"
|
||||
| "opening"
|
||||
| "vertex"
|
||||
| "edge"
|
||||
| "center"
|
||||
| "intersection"
|
||||
| "axis"
|
||||
| "axiscross"
|
||||
| "rim";
|
||||
|
||||
/** Bezug eines Bemassungspunkts auf ein Element ([38]). */
|
||||
export type DimRef = {
|
||||
@@ -887,6 +896,11 @@ export type Drawing2DGeom =
|
||||
* wenn ein Bezug ungültig wird. Fehlt das Feld, ist die Bemassung frei wie bisher.
|
||||
*/
|
||||
refs?: Array<DimRef | null>;
|
||||
/**
|
||||
* Art der Bemassung (fehlt = linear): Radius/Durchmesser (`pts` = Mittelpunkt, Punkt auf dem
|
||||
* Kreis) und Bogenlänge (`pts` = Mittelpunkt, Bogenanfang, Bogenende).
|
||||
*/
|
||||
kind?: "radius" | "diameter" | "arc";
|
||||
}
|
||||
| {
|
||||
shape: "kote";
|
||||
@@ -921,6 +935,24 @@ export type Drawing2DGeom =
|
||||
segments: number;
|
||||
}
|
||||
| { shape: "pointmarker"; at: Vec2 }
|
||||
| {
|
||||
shape: "grid";
|
||||
origin: Vec2;
|
||||
angle: number;
|
||||
radial?: boolean;
|
||||
a: Array<GridAxis>;
|
||||
b: Array<GridAxis>;
|
||||
/** Überstand der Achsen über die äusserste Querachse (Meter, Standard 1.5). */
|
||||
extend?: number;
|
||||
/** Enden mit Achsblase (Standard Anfang und Ende). */
|
||||
bubbles?: "start" | "end" | "both";
|
||||
/** Blasen-Durchmesser in Papier-mm (Standard 8). */
|
||||
bubbleMm?: number;
|
||||
/** Geschosse, in denen das Raster gezeigt wird; fehlt oder leer = in allen. */
|
||||
levels?: Array<string>;
|
||||
/** Im 3D-Modell als dünne Linien zeigen. */
|
||||
show3d?: boolean;
|
||||
}
|
||||
| {
|
||||
shape: "text";
|
||||
at: Vec2;
|
||||
@@ -1240,6 +1272,9 @@ export type FrameDetail = {
|
||||
rebates?: OpeningSides;
|
||||
};
|
||||
|
||||
/** Eine Achse des Achsrasters: Beschriftung und Lage (Abstand bzw. Winkel/Radius, s. `Grid`). */
|
||||
export type GridAxis = { label: string; pos: number };
|
||||
|
||||
/**
|
||||
* Raster-Regel: generiert Wände entlang gleichmäßiger X-/Y-Achsen.
|
||||
* Typischer Anwendungsfall: Tragwerks-Achsraster (z. B. 3 m Abstand).
|
||||
|
||||
@@ -501,6 +501,45 @@ export function AttributesPanel() {
|
||||
(Modellmass, s. `model/dimension.ts`); leer/0 fällt auf den
|
||||
Standard zurück. Die Masszahl selbst wird direkt im Plan am
|
||||
eigenen Griff verschoben (rastet nahe der Standardlage ein). */}
|
||||
{drawing?.geom.shape === "grid" && (() => {
|
||||
const geom = drawing.geom as Extract<typeof drawing.geom, { shape: "grid" }>;
|
||||
const here = geom.levels?.includes(drawing.levelId) && geom.levels.length === 1;
|
||||
return (
|
||||
<>
|
||||
<div className="attr-section-label">{t("attr.grid.section")}</div>
|
||||
<span className="attr-key">{t("attr.grid.bubbles")}</span>
|
||||
<span className="attr-val">
|
||||
<select value={geom.bubbles ?? "both"} onChange={(e) => host.onSetGridProps(drawing.id, { bubbles: e.target.value as "start" | "end" | "both" })}>
|
||||
<option value="both">{t("attr.grid.bubbles.both")}</option>
|
||||
<option value="start">{t("attr.grid.bubbles.start")}</option>
|
||||
<option value="end">{t("attr.grid.bubbles.end")}</option>
|
||||
</select>
|
||||
</span>
|
||||
<span className="attr-key">{t("attr.grid.extend")}</span>
|
||||
<span className="attr-val">
|
||||
<input className="attr-num" style={{ width: 72 }} type="number" step={0.1} min={0} value={geom.extend ?? 1.5}
|
||||
onChange={(e) => { const v = Number(e.target.value); if (Number.isFinite(v) && v >= 0) host.onSetGridProps(drawing.id, { extend: v }); }} />
|
||||
</span>
|
||||
<span className="attr-key">{t("attr.grid.bubbleMm")}</span>
|
||||
<span className="attr-val">
|
||||
<input className="attr-num" style={{ width: 72 }} type="number" step={0.5} min={2} value={geom.bubbleMm ?? 8}
|
||||
onChange={(e) => { const v = Number(e.target.value); if (Number.isFinite(v) && v >= 2) host.onSetGridProps(drawing.id, { bubbleMm: v }); }} />
|
||||
</span>
|
||||
<span className="attr-key">{t("attr.grid.show3d")}</span>
|
||||
<span className="attr-val">
|
||||
<input type="checkbox" checked={geom.show3d === true} onChange={(e) => host.onSetGridProps(drawing.id, { show3d: e.target.checked })} />
|
||||
</span>
|
||||
<span className="attr-key">{t("attr.grid.levels")}</span>
|
||||
<span className="attr-val">
|
||||
<select value={here ? "here" : "all"} onChange={(e) => host.onSetGridProps(drawing.id, { levels: e.target.value === "here" ? [drawing.levelId] : undefined })}>
|
||||
<option value="all">{t("attr.grid.levels.all")}</option>
|
||||
<option value="here">{t("attr.grid.levels.here")}</option>
|
||||
</select>
|
||||
</span>
|
||||
</>
|
||||
);
|
||||
})()}
|
||||
|
||||
{drawing?.geom.shape === "dimension" && (
|
||||
<>
|
||||
<div className="attr-section-label">{t("attr.dim.section")}</div>
|
||||
|
||||
@@ -253,6 +253,17 @@ export function ToolIcon({ id }: { id: ToolId }) {
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
case "grid":
|
||||
// Achsraster: zwei Achsen mit Blasen.
|
||||
return (
|
||||
<svg {...common}>
|
||||
<line x1="5" y1="5" x2="5" y2="15" strokeDasharray="2 1" />
|
||||
<line x1="11" y1="5" x2="11" y2="15" strokeDasharray="2 1" />
|
||||
<line x1="1" y1="10" x2="15" y2="10" strokeDasharray="2 1" />
|
||||
<circle cx="5" cy="3" r="2" fill="none" />
|
||||
<circle cx="11" cy="3" r="2" fill="none" />
|
||||
</svg>
|
||||
);
|
||||
case "pointmarker":
|
||||
// Kreuz-in-Kreis (Punkt-/Knotenmarker).
|
||||
return (
|
||||
@@ -347,6 +358,7 @@ const TOOLS_2D: ToolId[] = [
|
||||
"scalebar",
|
||||
"revcloud",
|
||||
"pointmarker",
|
||||
"grid",
|
||||
"wipeout",
|
||||
"text",
|
||||
"leader",
|
||||
|
||||
@@ -297,6 +297,11 @@ export interface PanelHostValue {
|
||||
drawingId: string,
|
||||
patch: { start?: EndMark; end?: EndMark; sizeMm?: number },
|
||||
) => void;
|
||||
/** Achsraster ([112]): Blasenseite, Überstand (m), Blasen-Ø (Papier-mm), Geschosse (leer = alle). */
|
||||
onSetGridProps: (
|
||||
drawingId: string,
|
||||
patch: { bubbles?: "start" | "end" | "both"; extend?: number; bubbleMm?: number; levels?: string[] | undefined; show3d?: boolean },
|
||||
) => void;
|
||||
onSetDimensionStyle: (
|
||||
drawingId: string,
|
||||
patch: {
|
||||
|
||||
@@ -118,12 +118,14 @@ export function levelArg(level: DrawingLevel) {
|
||||
export function generateSectionPlan(
|
||||
output: SectionOutput,
|
||||
mono = false,
|
||||
opts: { hiddenLines?: boolean; visibleCodes?: Set<string>; categoryDisplay?: CategoryDisplayResolver; openings?: boolean } = {},
|
||||
opts: { hiddenLines?: boolean; visibleCodes?: Set<string>; categoryDisplay?: CategoryDisplayResolver; openings?: boolean; scaleDenominator?: number } = {},
|
||||
): Plan {
|
||||
const { project, level } = output;
|
||||
const text = JSON.stringify({
|
||||
level: levelArg(level),
|
||||
hiddenLines: !!opts.hiddenLines,
|
||||
// Massstabsnenner für die Achsblasen des Rasters ([112]); Default 100.
|
||||
scale: opts.scaleDenominator ?? 100,
|
||||
...visibilityArgs(project, opts.visibleCodes, opts.categoryDisplay),
|
||||
});
|
||||
const args = output.bodies.slice();
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
// [112]/[38] Achsraster und Bemassung im Store: eine Bemassung zwischen zwei Achsen folgt der verschobenen
|
||||
// Achse (Kern führt `pts` im selben Undo-Schritt nach); Rundmass folgt dem Kreis; Achsfang im Kern.
|
||||
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 } from "../model/types";
|
||||
|
||||
const dims = (): Drawing2D[] => getState().project.drawings2d.filter((d) => d.geom.shape === "dimension");
|
||||
const xs = (d: Drawing2D): number[] => (d.geom.shape === "dimension" ? d.geom.pts.map((q) => q.x) : []);
|
||||
|
||||
beforeEach(() => {
|
||||
setState({ project: emptyProject, undoDepth: 0, redoDepth: 0, canUndo: false, canRedo: false });
|
||||
getState().clearHistory();
|
||||
getState().setProject(cmdMutation({ cmd: "grid", at: [2, 1], xs: "6 6", ys: "5", ctx: { level: "eg", cat: "20" }, stamp: "g" }));
|
||||
});
|
||||
|
||||
describe("Achsraster im Store", () => {
|
||||
it("Bemassung zwischen zwei Achsen: Achse verschieben → Mass folgt, ein Undo-Schritt", () => {
|
||||
const grid = getState().project.drawings2d.find((d) => d.geom.shape === "grid")!;
|
||||
expect(grid).toBeDefined();
|
||||
// Achse 1 bei x = 2, Achse 2 bei x = 8, Kette auf y = 3 zwischen den gefangenen Achspunkten.
|
||||
getState().setProject(cmdMutation({ cmd: "dimension", pts: [[2, 3], [8, 3]], snaps: [[2, 3], [8, 3]], offset: 1, ctx: { level: "eg" }, stamp: "t" }));
|
||||
const d0 = dims()[0];
|
||||
expect(d0.geom.shape === "dimension" && d0.geom.refs?.map((r) => r?.feature)).toEqual(["axis", "axis"]);
|
||||
expect(xs(d0)).toEqual([2, 8]);
|
||||
|
||||
getState().applyChange((p) =>
|
||||
patchItem(p, "drawings2d", grid.id, (d) => (d.geom.shape === "grid" ? { ...d, geom: { ...d.geom, a: d.geom.a.map((x) => (x.label === "2" ? { ...x, pos: 7.5 } : x)) } } : d)),
|
||||
);
|
||||
expect(xs(dims()[0])).toEqual([2, 9.5]);
|
||||
getState().undo();
|
||||
expect(xs(dims()[0])).toEqual([2, 8]);
|
||||
getState().redo();
|
||||
expect(xs(dims()[0])).toEqual([2, 9.5]);
|
||||
});
|
||||
|
||||
it("Raster verschieben mit der Bemassung bleibt verbunden; Achsschnittpunkt hängt als axiscross an", () => {
|
||||
getState().setProject(cmdMutation({ cmd: "dimension", pts: [[2, 1], [8, 1]], snaps: [[2, 1], [8, 1]], offset: 1, ctx: { level: "eg" }, stamp: "t" }));
|
||||
const d = dims()[0];
|
||||
expect(d.geom.shape === "dimension" && d.geom.refs?.map((r) => r?.feature)).toEqual(["axiscross", "axiscross"]);
|
||||
// Ursprung des Rasters um (1, 0) verschieben → Punkte folgen.
|
||||
const grid = getState().project.drawings2d.find((x) => x.geom.shape === "grid")!;
|
||||
getState().applyChange((p) => patchItem(p, "drawings2d", grid.id, (x) => (x.geom.shape === "grid" ? { ...x, geom: { ...x.geom, origin: { x: 3, y: 1 } } } : x)));
|
||||
expect(xs(dims()[0])).toEqual([3, 9]);
|
||||
});
|
||||
|
||||
it("Radiusmass folgt dem Kreis", () => {
|
||||
getState().applyChange(
|
||||
addItems("drawings2d", [{ id: "K", type: "drawing2d", levelId: "eg", categoryCode: "20", geom: { shape: "circle", center: { x: 20, y: 20 }, r: 2 } } as Drawing2D]),
|
||||
);
|
||||
getState().setProject(cmdMutation({ cmd: "dimround", kind: "radius", pts: [[22, 20]], ctx: { level: "eg" }, stamp: "r" }));
|
||||
getState().applyChange((p) => patchItem(p, "drawings2d", "K", (x) => (x.geom.shape === "circle" ? { ...x, geom: { ...x.geom, center: { x: 30, y: 20 }, r: 3 } } : x)));
|
||||
const d = dims()[0];
|
||||
expect(d.geom.shape === "dimension" && d.geom.pts).toEqual([{ x: 30, y: 20 }, { x: 33, y: 20 }]);
|
||||
});
|
||||
});
|
||||
@@ -602,6 +602,17 @@ export function usePanelHostBase(opts: {
|
||||
patchItem(p, "drawings2d", drawingId, (d) => ({ ...d, endMarks: { ...d.endMarks, ...patch } })),
|
||||
),
|
||||
),
|
||||
onSetGridProps: (drawingId, patch) =>
|
||||
setProject(
|
||||
opsMutation((p) =>
|
||||
patchItem(p, "drawings2d", drawingId, (d) => {
|
||||
if (d.geom.shape !== "grid") return d;
|
||||
const geom = { ...d.geom, ...patch };
|
||||
if (patch.levels === undefined && "levels" in patch) delete geom.levels;
|
||||
return { ...d, geom };
|
||||
}),
|
||||
),
|
||||
),
|
||||
onSetDimensionStyle: (drawingId, patch) =>
|
||||
setProject(
|
||||
opsMutation((p) =>
|
||||
|
||||
@@ -346,6 +346,18 @@ const pointmarkerTool: Tool = {
|
||||
onCancel: (s) => [s, { draft: null, done: true }],
|
||||
};
|
||||
|
||||
// Achsraster ([112]): Platzhalter-Werkzeug, gekoppelt an den `grid`-Befehl (Ursprung + Feldweiten).
|
||||
const gridTool: Tool = {
|
||||
id: "grid",
|
||||
labelKey: "tool.grid",
|
||||
hintKey: () => "tool.grid.hint",
|
||||
init: () => ({ phase: "idle" }),
|
||||
onClick: (s) => [s, { draft: null }],
|
||||
onMove: (s) => [s, { draft: null }],
|
||||
onCommitGesture: (s) => [s, { draft: null, done: true }],
|
||||
onCancel: (s) => [s, { draft: null, done: true }],
|
||||
};
|
||||
|
||||
// Wipeout/Maskenregion: Platzhalter-Werkzeug, gekoppelt an den
|
||||
// `wipeout`-Befehl (Punktfolge, schliesst automatisch → weisse Maskenfläche).
|
||||
// Freies 2D-Element (nicht floorOnly).
|
||||
@@ -456,6 +468,7 @@ const TOOLS: Record<ToolId, Tool> = {
|
||||
scalebar: scalebarTool,
|
||||
revcloud: revcloudTool,
|
||||
pointmarker: pointmarkerTool,
|
||||
grid: gridTool,
|
||||
wipeout: wipeoutTool,
|
||||
text: textTool,
|
||||
leader: leaderTool,
|
||||
|
||||
@@ -35,6 +35,7 @@ export type ToolId =
|
||||
| "scalebar"
|
||||
| "revcloud"
|
||||
| "pointmarker"
|
||||
| "grid"
|
||||
| "wipeout"
|
||||
| "text"
|
||||
| "leader"
|
||||
|
||||
@@ -47,5 +47,6 @@ export function drawingMoveAnchor(d: Drawing2D, verts: Vec2[]): Vec2 | null {
|
||||
const g = d.geom;
|
||||
if (g.shape === "circle" || g.shape === "arc" || g.shape === "ellipse") return g.center;
|
||||
if (g.shape === "text" || g.shape === "kote" || g.shape === "detailref" || g.shape === "scalebar" || g.shape === "pointmarker") return g.at;
|
||||
if (g.shape === "grid") return g.origin;
|
||||
return null;
|
||||
}
|
||||
@@ -669,7 +669,7 @@ function useCrossKindOverlay(
|
||||
} else if (l.kind === "section") {
|
||||
const sOut = sectionOutputs[l.id];
|
||||
prims = sOut
|
||||
? generateSectionPlan(sOut, mono, { hiddenLines: l.hiddenLines, visibleCodes, categoryDisplay })
|
||||
? generateSectionPlan(sOut, mono, { hiddenLines: l.hiddenLines, visibleCodes, categoryDisplay, scaleDenominator })
|
||||
.primitives
|
||||
: [];
|
||||
} else {
|
||||
@@ -1155,9 +1155,10 @@ function SectionPlanView({
|
||||
visibleCodes,
|
||||
categoryDisplay,
|
||||
openings: true,
|
||||
scaleDenominator,
|
||||
})
|
||||
: null,
|
||||
[isElevation, output, mono, level.hiddenLines, visibleCodes, categoryDisplay, inputs],
|
||||
[isElevation, output, mono, level.hiddenLines, visibleCodes, categoryDisplay, inputs, scaleDenominator],
|
||||
);
|
||||
const rawPlan = isElevation ? elevationPlan : sectionPlan;
|
||||
// Grundriss-Unterlage (Nutzer-Wunsch: "in der Ansicht auch mal einen
|
||||
|
||||
Reference in new issue
Block a user