[285] Bedienung: Decke-Lage, Wandtyp/Aussenbauteil, λ der Standard-Baustoffe, Fenster-Abstand, Rampen-Hinweis, Bäume in der Axo, Baurecht ohne Gebäude
This commit is contained in:
17 files changed
+573
-72
No files matched your search
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* [285] `ceilingCommand` — Option „Lage": Geschossdecke (oben, wie bisher), Bodenplatte unter dem Geschoss, frei (Oberkante getippt).
|
||||
*/
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { ceilingCommand } from "./ceiling";
|
||||
import type { CommandContext, CmdInput, CommandState, Project, Vec2 } from "../types";
|
||||
|
||||
function project(): Project {
|
||||
return {
|
||||
id: "t",
|
||||
name: "T",
|
||||
lineStyles: [],
|
||||
hatches: [],
|
||||
components: [{ id: "beton", name: "Beton", color: "#999999", joinPriority: 100 }],
|
||||
wallTypes: [{ id: "aw", name: "AW", layers: [{ componentId: "beton", thickness: 0.2 }] }],
|
||||
ceilingTypes: [{ id: "ct", name: "Platte", layers: [{ componentId: "beton", thickness: 0.25 }] }],
|
||||
drawingLevels: [{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0 }],
|
||||
layers: [{ code: "30", name: "Decken", color: "#000000", lw: 0.35, visible: true, locked: false }],
|
||||
walls: [],
|
||||
openings: [],
|
||||
ceilings: [],
|
||||
stairs: [],
|
||||
rooms: [],
|
||||
drawings2d: [],
|
||||
context: [],
|
||||
} as unknown as Project;
|
||||
}
|
||||
|
||||
const ctxOf = (p: Project): CommandContext => ({
|
||||
project: p,
|
||||
level: p.drawingLevels[0],
|
||||
defaultCategoryCode: "30",
|
||||
activeLineStyleId: "solid",
|
||||
activeWallTypeId: "aw",
|
||||
lastPoint: null,
|
||||
selection: { wallIds: [], drawingId: null },
|
||||
});
|
||||
|
||||
const outline: Vec2[] = [
|
||||
{ x: 0, y: 0 },
|
||||
{ x: 4, y: 0 },
|
||||
{ x: 4, y: 3 },
|
||||
{ x: 0, y: 3 },
|
||||
];
|
||||
|
||||
/** Eingaben nacheinander; liefert das Projekt nach dem Commit. */
|
||||
function run(inputs: CmdInput[]): Project {
|
||||
const p = project();
|
||||
const ctx = ctxOf(p);
|
||||
let state: CommandState = ceilingCommand.init();
|
||||
let commit: ((q: Project) => Project) | undefined;
|
||||
for (const input of inputs) {
|
||||
const [ns, res] = ceilingCommand.onInput(state, input, ctx);
|
||||
state = ns;
|
||||
commit = res.commit ?? commit;
|
||||
}
|
||||
return commit ? commit(p) : p;
|
||||
}
|
||||
|
||||
const pts = (): CmdInput[] => outline.map((point) => ({ kind: "point", point }));
|
||||
const close: CmdInput = { kind: "option", id: "close" };
|
||||
const pos: CmdInput = { kind: "option", id: "pos" };
|
||||
|
||||
describe("ceilingCommand Lage [285]", () => {
|
||||
it("Vorgabe „oben“: Oberkante am Geschoss (kein top)", () => {
|
||||
const q = run([...pts(), close]);
|
||||
expect(q.ceilings).toHaveLength(1);
|
||||
expect(q.ceilings![0].top).toBeUndefined();
|
||||
});
|
||||
|
||||
it("„unter dem Geschoss“ (Bodenplatte): Oberkante auf dem Geschossboden", () => {
|
||||
const q = run([pos, ...pts(), close]);
|
||||
expect(q.ceilings![0].top).toEqual({ mode: "floor", floorId: "eg", offset: 0 });
|
||||
});
|
||||
|
||||
it("„frei“: nach dem Umriss die Oberkante tippen (−0.02 = abgesenkte Balkonplatte)", () => {
|
||||
const q = run([pos, pos, ...pts(), close, { kind: "number", value: -0.02 }]);
|
||||
expect(q.ceilings).toHaveLength(1);
|
||||
expect(q.ceilings![0].top).toEqual({ mode: "floor", floorId: "eg", offset: -0.02 });
|
||||
});
|
||||
|
||||
it("„frei“ ohne Eingabe: nichts angelegt; Enter nimmt 0", () => {
|
||||
expect(run([pos, pos, ...pts(), close]).ceilings ?? []).toHaveLength(0);
|
||||
const p = project();
|
||||
const ctx = ctxOf(p);
|
||||
let state: CommandState = ceilingCommand.init();
|
||||
for (const input of [pos, pos, ...pts(), close]) state = ceilingCommand.onInput(state, input, ctx)[0];
|
||||
const [, res] = ceilingCommand.onConfirm(state, ctx);
|
||||
expect(res.commit!(p).ceilings![0].top).toEqual({ mode: "floor", floorId: "eg", offset: 0 });
|
||||
});
|
||||
});
|
||||
@@ -4,6 +4,12 @@
|
||||
// 1) „Erster Umrisspunkt der Decke:" → Punkt
|
||||
// 2) „Nächster Punkt ( Schliessen Zurück ):" → Punkt … Der Umriss schließt per
|
||||
// Klick auf den Startpunkt, Option „Schliessen" (C) oder Enter (≥3 Punkte).
|
||||
// 3) nur bei Lage „Frei": „Oberkante in m über Geschossboden <0>:" → Zahl, Enter = 0.
|
||||
//
|
||||
// Option „Lage" ([285], sticky über den Befehl): „Oben" = Oberkante am Geschoss (Geschossdecke, wie bisher) ·
|
||||
// „Unter" = Bodenplatte, Oberkante auf dem Geschossboden (UK = OK − Dicke, also unter dem Geschoss) ·
|
||||
// „Frei" = Oberkante getippt (z. B. −0.02 für eine abgesenkte Balkonplatte). Vorher ging das nur über OK/UK
|
||||
// „Eigene" in der Objekt-Info (6 Schritte).
|
||||
//
|
||||
// Akzeptiert je Punkt Maus-Picks UND getippte Koordinaten (0,0 · r3,0 · 5<45) —
|
||||
// derselbe Eingabepfad wie Polylinie/Wand. Die fertige Decke rendert über die
|
||||
@@ -27,6 +33,7 @@ import type {
|
||||
Vec2,
|
||||
} from "../types";
|
||||
import { createMutation, xy } from "../createCore";
|
||||
import { t } from "../../i18n";
|
||||
|
||||
const EPS = 1e-6;
|
||||
const DEG = Math.PI / 180;
|
||||
@@ -55,18 +62,31 @@ function nextFromFields(
|
||||
return { x: last.x + Math.cos(ang) * length, y: last.y + Math.sin(ang) * length };
|
||||
}
|
||||
|
||||
/** Lage der Decke ([285]): am Geschoss oben, unter dem Geschoss (Bodenplatte) oder frei (OK getippt). */
|
||||
export type CeilPos = "top" | "below" | "free";
|
||||
const POS_NEXT: Record<CeilPos, CeilPos> = { top: "below", below: "free", free: "top" };
|
||||
|
||||
interface CeilIdle extends CommandState {
|
||||
phase: "start";
|
||||
pos: CeilPos;
|
||||
}
|
||||
interface CeilDrawing extends CommandState {
|
||||
phase: "next";
|
||||
points: Vec2[];
|
||||
cursor: Vec2 | null;
|
||||
pos: CeilPos;
|
||||
}
|
||||
type CeilState = CeilIdle | CeilDrawing;
|
||||
/** Lage „Frei": Umriss steht, die Oberkante fehlt noch. */
|
||||
interface CeilZ extends CommandState {
|
||||
phase: "z";
|
||||
points: Vec2[];
|
||||
pos: CeilPos;
|
||||
}
|
||||
type CeilState = CeilIdle | CeilDrawing | CeilZ;
|
||||
|
||||
const CLOSE: CmdOption = { id: "close", labelKey: "cmd.polyline.close" };
|
||||
const UNDO: CmdOption = { id: "undo", labelKey: "cmd.polyline.undo" };
|
||||
const posOption = (pos: CeilPos): CmdOption => ({ id: "pos", labelKey: "cmd.ceiling.pos", value: t(`cmd.ceiling.pos.${pos}`), key: "L" });
|
||||
|
||||
/** Vorschau: geschlossener Umriss-Ring (ab 3 Punkten) + Gummiband + HUD. */
|
||||
function ceilingDraft(points: Vec2[], cursor: Vec2 | null): ToolDraft {
|
||||
@@ -90,56 +110,81 @@ function ceilingDraft(points: Vec2[], cursor: Vec2 | null): ToolDraft {
|
||||
* Commit: Decke aus dem Umriss (normalisiert, CCW; entartet → nichts), Typ = aktiver Aufbau, Ebene
|
||||
* „30“ falls vorhanden — im Kern (`cmd_create.rs`).
|
||||
*/
|
||||
const appendCeiling = (pts: Vec2[], ctx: CommandContext) => createMutation(ctx, { cmd: "ceiling", pts: pts.map(xy) });
|
||||
const appendCeiling = (pts: Vec2[], ctx: CommandContext, top: number | null = null) =>
|
||||
createMutation(ctx, { cmd: "ceiling", pts: pts.map(xy), top });
|
||||
|
||||
const idle = (): [CommandState, CommandResult] => [
|
||||
{ phase: "start", lastPoint: null } as CeilIdle,
|
||||
{ draft: null, done: true },
|
||||
];
|
||||
const idleOf = (pos: CeilPos): CeilIdle => ({ phase: "start", lastPoint: null, pos });
|
||||
const idle = (pos: CeilPos = "top"): [CommandState, CommandResult] => [idleOf(pos), { draft: null, done: true }];
|
||||
|
||||
/** Umriss steht: „Frei" fragt nach der Oberkante, sonst gleich anlegen („Unter" = OK auf dem Geschossboden). */
|
||||
function finish(s: CeilDrawing, ctx: CommandContext): [CommandState, CommandResult] {
|
||||
if (s.pos === "free") {
|
||||
const ns: CeilZ = { phase: "z", points: s.points, pos: s.pos, lastPoint: null };
|
||||
return [ns, { draft: ceilingDraft(s.points, null) }];
|
||||
}
|
||||
return [idleOf(s.pos), { draft: null, done: true, commit: appendCeiling(s.points, ctx, s.pos === "below" ? 0 : null) }];
|
||||
}
|
||||
|
||||
export const ceilingCommand: Command = {
|
||||
name: "ceiling",
|
||||
labelKey: "cmd.ceiling.label",
|
||||
// Decken leben auf Geschossen — wie die Wand nur dort aktiv.
|
||||
floorOnly: true,
|
||||
prompt: (s) =>
|
||||
(s as CeilState).phase === "next" ? "cmd.ceiling.next" : "cmd.ceiling.start",
|
||||
accepts: (s) =>
|
||||
(s as CeilState).phase === "next"
|
||||
? ["point", "number", "option"]
|
||||
: ["point", "number"],
|
||||
prompt: (s) => {
|
||||
const ph = (s as CeilState).phase;
|
||||
return ph === "z" ? "cmd.ceiling.z" : ph === "next" ? "cmd.ceiling.next" : "cmd.ceiling.start";
|
||||
},
|
||||
accepts: (s) => {
|
||||
const ph = (s as CeilState).phase;
|
||||
return ph === "z" ? ["number", "option"] : ph === "next" ? ["point", "number", "option"] : ["point", "number", "option"];
|
||||
},
|
||||
options: (s) => {
|
||||
const ps = s as CeilState;
|
||||
if (ps.phase !== "next") return [];
|
||||
return ps.points.length >= 3 ? [CLOSE, UNDO] : [UNDO];
|
||||
const pos = posOption(ps.pos);
|
||||
if (ps.phase === "z") return [pos];
|
||||
if (ps.phase !== "next") return [pos];
|
||||
return ps.points.length >= 3 ? [CLOSE, UNDO, pos] : [UNDO, pos];
|
||||
},
|
||||
init: (): CeilIdle => ({ phase: "start", lastPoint: null }),
|
||||
init: (): CeilIdle => idleOf("top"),
|
||||
|
||||
onInput: (state, input, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as CeilState;
|
||||
|
||||
// Lage umschalten (jederzeit); steht der Umriss schon und fehlt nur die Oberkante, entscheidet die neue Lage.
|
||||
if (input.kind === "option" && input.id === "pos") {
|
||||
const pos = POS_NEXT[s.pos];
|
||||
if (s.phase === "z") {
|
||||
if (pos === "free") return [{ ...s, pos } as CeilZ, { draft: ceilingDraft(s.points, null) }];
|
||||
return [idleOf(pos), { draft: null, done: true, commit: appendCeiling(s.points, ctx, pos === "below" ? 0 : null) }];
|
||||
}
|
||||
const ns = { ...s, pos } as CeilState;
|
||||
return [ns, { draft: ns.phase === "next" ? ceilingDraft(ns.points, ns.cursor) : null }];
|
||||
}
|
||||
|
||||
// Oberkante getippt (Lage „Frei"), m über dem Geschossboden; Unsinn bleibt im Schritt.
|
||||
if (s.phase === "z") {
|
||||
if (input.kind === "number" && Number.isFinite(input.value)) {
|
||||
return [idleOf(s.pos), { draft: null, done: true, commit: appendCeiling(s.points, ctx, input.value) }];
|
||||
}
|
||||
return [s, { draft: ceilingDraft(s.points, null) }];
|
||||
}
|
||||
|
||||
if (input.kind === "option") {
|
||||
if (s.phase !== "next") return [s, { draft: null }];
|
||||
if (input.id === "undo") {
|
||||
const pts = s.points.slice(0, -1);
|
||||
if (pts.length === 0)
|
||||
return [{ phase: "start", lastPoint: null } as CeilIdle, { draft: null }];
|
||||
if (pts.length === 0) return [idleOf(s.pos), { draft: null }];
|
||||
const ns: CeilDrawing = {
|
||||
phase: "next",
|
||||
points: pts,
|
||||
cursor: s.cursor,
|
||||
lastPoint: pts[pts.length - 1],
|
||||
pos: s.pos,
|
||||
};
|
||||
return [ns, { draft: ceilingDraft(pts, s.cursor) }];
|
||||
}
|
||||
// Sofort schließen: committet die Decke (unabhängig, ≥3 Punkte).
|
||||
if (input.id === "close" && s.points.length >= 3) {
|
||||
const pts = s.points;
|
||||
return [
|
||||
{ phase: "start", lastPoint: null } as CeilIdle,
|
||||
{ draft: null, done: true, commit: appendCeiling(pts, ctx) },
|
||||
];
|
||||
}
|
||||
// Sofort schließen (≥3 Punkte).
|
||||
if (input.id === "close" && s.points.length >= 3) return finish(s, ctx);
|
||||
return [s, { draft: ceilingDraft(s.points, s.cursor) }];
|
||||
}
|
||||
|
||||
@@ -151,30 +196,24 @@ export const ceilingCommand: Command = {
|
||||
}
|
||||
const pt = input.point;
|
||||
if (s.phase !== "next") {
|
||||
const ns: CeilDrawing = { phase: "next", points: [pt], cursor: pt, lastPoint: pt };
|
||||
const ns: CeilDrawing = { phase: "next", points: [pt], cursor: pt, lastPoint: pt, pos: s.pos };
|
||||
return [ns, { draft: ceilingDraft([pt], pt) }];
|
||||
}
|
||||
// Klick nahe Startpunkt → schließen (committet die Decke).
|
||||
if (s.points.length >= 3 && segLen(s.points[0], pt) < CLOSE_HIT) {
|
||||
const pts = s.points;
|
||||
return [
|
||||
{ phase: "start", lastPoint: null } as CeilIdle,
|
||||
{ draft: null, done: true, commit: appendCeiling(pts, ctx) },
|
||||
];
|
||||
}
|
||||
if (s.points.length >= 3 && segLen(s.points[0], pt) < CLOSE_HIT) return finish(s, ctx);
|
||||
// Null-Strecke (Klick auf denselben Punkt) ignorieren.
|
||||
const last = s.points[s.points.length - 1];
|
||||
if (segLen(last, pt) < EPS) {
|
||||
return [s, { draft: ceilingDraft(s.points, s.cursor) }];
|
||||
}
|
||||
const points = [...s.points, pt];
|
||||
const ns: CeilDrawing = { phase: "next", points, cursor: pt, lastPoint: pt };
|
||||
const ns: CeilDrawing = { phase: "next", points, cursor: pt, lastPoint: pt, pos: s.pos };
|
||||
return [ns, { draft: ceilingDraft(points, pt) }];
|
||||
},
|
||||
|
||||
onMove: (state, point): [CommandState, CommandResult] => {
|
||||
const s = state as CeilState;
|
||||
if (s.phase !== "next") return [s, { draft: null }];
|
||||
if (s.phase !== "next") return [s, { draft: s.phase === "z" ? ceilingDraft(s.points, null) : null }];
|
||||
const ns: CeilDrawing = { ...s, cursor: point };
|
||||
return [ns, { draft: ceilingDraft(s.points, point) }];
|
||||
},
|
||||
@@ -182,16 +221,12 @@ export const ceilingCommand: Command = {
|
||||
// Enter/Space/Rechtsklick: Umriss schließen + committen (≥3 Punkte).
|
||||
onConfirm: (state, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as CeilState;
|
||||
if (s.phase === "next" && s.points.length >= 3) {
|
||||
const pts = s.points;
|
||||
return [
|
||||
{ phase: "start", lastPoint: null } as CeilIdle,
|
||||
{ draft: null, done: true, commit: appendCeiling(pts, ctx) },
|
||||
];
|
||||
}
|
||||
return idle();
|
||||
if (s.phase === "next" && s.points.length >= 3) return finish(s, ctx);
|
||||
// Lage „Frei": Enter = Oberkante 0 (Geschossboden).
|
||||
if (s.phase === "z") return [idleOf(s.pos), { draft: null, done: true, commit: appendCeiling(s.points, ctx, 0) }];
|
||||
return idle(s.pos);
|
||||
},
|
||||
onCancel: (): [CommandState, CommandResult] => idle(),
|
||||
onCancel: (state): [CommandState, CommandResult] => idle((state as CeilState).pos),
|
||||
|
||||
// Tab-Feld-Zyklus nur im „next"-Schritt: Länge + Winkel relativ zum letzten Punkt.
|
||||
fields: (state) => ((state as CeilState).phase === "next" ? CEIL_FIELDS : []),
|
||||
|
||||
@@ -40,8 +40,12 @@ function pickWall(ctx: CommandContext, p: Vec2): { id: string; start: Vec2; end:
|
||||
return { id, start: { x: start[0], y: start[1] }, end: { x: end[0], y: end[1] }, t, bulge };
|
||||
}
|
||||
|
||||
/** Tab-Felder im Positionsschritt: Breite/Höhe/Brüstung (+ Winkel bei Tür). */
|
||||
/**
|
||||
* Tab-Felder im Positionsschritt: Abstand entlang der Wand (erstes, aktives Feld — eine getippte Zahl ist der
|
||||
* Abstand, nicht die Breite, [285]), dann Breite/Höhe/Brüstung (+ Winkel bei Tür).
|
||||
*/
|
||||
const BASE_FIELDS: CommandField[] = [
|
||||
{ id: "pos", labelKey: "cmd.field.offset" },
|
||||
{ id: "width", labelKey: "cmd.field.width" },
|
||||
{ id: "height", labelKey: "cmd.field.height" },
|
||||
{ id: "sill", labelKey: "cmd.opening.sillField" },
|
||||
@@ -73,6 +77,8 @@ interface OpPos extends CommandState {
|
||||
bulge?: number;
|
||||
cursor: Vec2 | null;
|
||||
posAlong: number; // Abstand vom Wandanfang (Meter)
|
||||
/** [285] Getippter Abstand (Feld „Abstand“): hat Vorrang vor Maus und Klick. */
|
||||
posLock?: number;
|
||||
kind: "window" | "door";
|
||||
hinge: "start" | "end";
|
||||
side: "left" | "right";
|
||||
@@ -230,8 +236,8 @@ export const openingCommand: Command = {
|
||||
return [ns, { draft: posDraft(ns, ctx) }];
|
||||
}
|
||||
|
||||
// Positionsschritt: Klick projiziert auf die Achse → committen.
|
||||
const ns: OpPos = { ...s, posAlong: posDraftAt(s, ctx, null, pt).pos, cursor: pt };
|
||||
// Positionsschritt: Klick projiziert auf die Achse (ein getippter Abstand gilt vor dem Klick) → committen.
|
||||
const ns: OpPos = { ...s, posAlong: s.posLock ?? posDraftAt(s, ctx, null, pt).pos, cursor: pt };
|
||||
return [
|
||||
idle(s)[0],
|
||||
{ draft: null, done: true, commit: appendOpening(ns, ctx) },
|
||||
@@ -241,7 +247,7 @@ export const openingCommand: Command = {
|
||||
onMove: (state, point, _snap, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as OpState;
|
||||
if (s.phase !== "pos") return [s, { draft: null }];
|
||||
const at = posDraftAt({ ...s, cursor: point }, ctx, null, point);
|
||||
const at = s.posLock !== undefined ? posDraftAt({ ...s, cursor: point }, ctx, s.posLock, null) : posDraftAt({ ...s, cursor: point }, ctx, null, point);
|
||||
const ns: OpPos = { ...s, posAlong: at.pos, cursor: point };
|
||||
return [ns, { draft: at.draft }];
|
||||
},
|
||||
@@ -249,7 +255,7 @@ export const openingCommand: Command = {
|
||||
onConfirm: (state, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as OpState;
|
||||
if (s.phase === "pos") {
|
||||
const ns = s;
|
||||
const ns: OpPos = s.posLock !== undefined ? { ...s, posAlong: s.posLock } : s;
|
||||
return [
|
||||
idle(s)[0],
|
||||
{ draft: null, done: true, commit: appendOpening(ns, ctx) },
|
||||
@@ -267,6 +273,7 @@ export const openingCommand: Command = {
|
||||
// Getippte Tab-Felder sticky in den State übernehmen; kein Koordinatenpunkt.
|
||||
pointFromFields: (state, locks) => {
|
||||
const s = state as OpState;
|
||||
if (s.phase === "pos") s.posLock = "pos" in locks && Number.isFinite(locks.pos) ? locks.pos : undefined;
|
||||
if ("width" in locks && locks.width > 0) s.width = locks.width;
|
||||
if ("height" in locks && locks.height > 0) s.height = locks.height;
|
||||
if ("sill" in locks && locks.sill >= 0) s.sill = locks.sill;
|
||||
@@ -276,6 +283,7 @@ export const openingCommand: Command = {
|
||||
fieldValues: (state): Record<string, number> => {
|
||||
const s = state as OpState;
|
||||
const out: Record<string, number> = {
|
||||
...(s.phase === "pos" ? { pos: s.posLock ?? s.posAlong } : {}),
|
||||
width: s.width,
|
||||
height: s.height,
|
||||
sill: s.sill,
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
// [285] Fenster-Befehl: eine getippte Zahl beim Schritt „Position entlang der Wand (Abstand tippen)“ ist der
|
||||
// ABSTAND vom Wandanfang, nicht die Breite (vorher setzte sie still die Breite: „3“ = 3 m breites Fenster).
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { CommandEngine, type EngineHost } from "../engine";
|
||||
import type { CommandContext } from "../types";
|
||||
import type { ProjectMutation } from "../../core";
|
||||
import { sampleProject } from "../../model/sampleProject";
|
||||
|
||||
// Beispielhaus ohne die vorhandenen Öffnungen (sonst weicht das Fenster ihnen aus).
|
||||
const project = { ...sampleProject, openings: [] };
|
||||
const level = sampleProject.drawingLevels.find((l) => l.kind === "floor")!;
|
||||
const ctx: CommandContext = {
|
||||
project,
|
||||
level,
|
||||
defaultCategoryCode: "20",
|
||||
activeLineStyleId: "",
|
||||
activeWallTypeId: sampleProject.wallTypes[0]?.id ?? "",
|
||||
lastPoint: null,
|
||||
selection: { wallIds: [], drawingId: null, drawingIds: [] } as unknown as CommandContext["selection"],
|
||||
};
|
||||
|
||||
function run(type: (e: CommandEngine) => void) {
|
||||
const commits: ProjectMutation[] = [];
|
||||
const host: EngineHost = {
|
||||
context: (lastPoint) => ({ ...ctx, lastPoint }),
|
||||
snap: () => null,
|
||||
pxPerMeter: () => 50,
|
||||
setDraft: () => {},
|
||||
commit: (m) => void commits.push(m),
|
||||
isFloor: () => true,
|
||||
};
|
||||
const engine = new CommandEngine(host);
|
||||
engine.start("fenster");
|
||||
type(engine);
|
||||
return commits;
|
||||
}
|
||||
|
||||
describe("Fenster: getippter Abstand", () => {
|
||||
it("„3.5“ + Enter setzt das Fenster 3.5 m vom Wandanfang (Breite bleibt 1.2 m)", () => {
|
||||
// W1 läuft von (0,0) nach (5,0).
|
||||
const commits = run((e) => {
|
||||
e.pick({ x: 1, y: 0 });
|
||||
e.submitText("3.5");
|
||||
e.confirm();
|
||||
});
|
||||
expect(commits).toHaveLength(1);
|
||||
const q = commits[0](project);
|
||||
const o = (q.openings ?? []).find((x) => !(project.openings ?? []).some((y) => y.id === x.id))!;
|
||||
expect(o.hostWallId).toBe("W1");
|
||||
expect(o.position).toBeCloseTo(3.5, 6);
|
||||
expect(o.width).toBeCloseTo(1.2, 6);
|
||||
});
|
||||
});
|
||||
@@ -3,7 +3,7 @@
|
||||
* Geschossboden; Enter beim Gefälle übernimmt 6 %.
|
||||
*/
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { rampCommand, RAMP_DEFAULT_PERCENT } from "./ramp";
|
||||
import { rampCommand, rampNotice, RAMP_DEFAULT_PERCENT } from "./ramp";
|
||||
import type { CommandContext, CommandState, Project, Vec2 } from "../types";
|
||||
|
||||
function project(): Project {
|
||||
@@ -79,4 +79,26 @@ describe("rampCommand", () => {
|
||||
const q = run([...outline, { x: 0, y: 1.5 }, { x: 5, y: 1.5 }], 0);
|
||||
expect(q.ceilings ?? []).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("[285] Hinweis, wenn die Rampe über die Geschosshöhe steigt oder tiefer als eine Geschosshöhe fällt", () => {
|
||||
const a = { x: 0, y: 0 };
|
||||
// 6 % auf 10 m = 0.6 m: in Ordnung.
|
||||
expect(rampNotice(a, { x: 10, y: 0 }, 6, 2.6)?.key).toBe("cmd.ramp.done");
|
||||
// 6 % auf 50 m = 3 m > 2.6 m: steigt über die Geschosshöhe.
|
||||
const hi = rampNotice(a, { x: 50, y: 0 }, 6, 2.6);
|
||||
expect(hi?.key).toBe("cmd.ramp.tooHigh");
|
||||
expect(hi?.kind).toBe("warning");
|
||||
// −6 % auf 50 m = −3 m: fällt unter den Boden.
|
||||
expect(rampNotice(a, { x: 50, y: 0 }, -6, 2.6)?.key).toBe("cmd.ramp.tooLow");
|
||||
// Ohne Geschosshöhe gilt die Vorgabe 2.6 m.
|
||||
expect(rampNotice(a, { x: 50, y: 0 }, 6, undefined)?.key).toBe("cmd.ramp.tooHigh");
|
||||
});
|
||||
it("[285] Der Befehl meldet den Hinweis beim Commit", () => {
|
||||
const p = project();
|
||||
const ctx = ctxOf(p);
|
||||
let state: CommandState = rampCommand.init();
|
||||
for (const point of [...outline, { x: 0, y: 1.5 }, { x: 10, y: 1.5 }]) state = rampCommand.onInput(state, { kind: "point", point }, ctx)[0];
|
||||
const [, res] = rampCommand.onInput(state, { kind: "number", value: 50 }, ctx);
|
||||
expect(res.notice?.key).toBe("cmd.ramp.tooHigh");
|
||||
});
|
||||
});
|
||||
@@ -44,9 +44,25 @@ function draft(s: RampState): ToolDraft {
|
||||
|
||||
const idle = (): RampState => ({ phase: "start", points: [], cursor: null, lastPoint: null });
|
||||
|
||||
/** Vorgabe-Geschosshöhe, wenn das Geschoss keine hat (wie der Kern, `cmd_create.rs`). */
|
||||
const DEF_FLOOR_HEIGHT = 2.6;
|
||||
|
||||
/**
|
||||
* [285] Hinweis nach dem Anlegen: steigt die Rampe über die Geschosshöhe bzw. fällt sie tiefer als eine Geschosshöhe unter den
|
||||
* Boden, stimmt meist die Richtung nicht (Anfang = Geschossboden, positives Gefälle = steigt zum Ende).
|
||||
*/
|
||||
export function rampNotice(from: Vec2, to: Vec2, percent: number, floorHeight: number | undefined): CommandResult["notice"] {
|
||||
const h = floorHeight && floorHeight > 0 ? floorHeight : DEF_FLOOR_HEIGHT;
|
||||
const rise = (percent / 100) * dist(from, to);
|
||||
if (rise > h + EPS) return { key: "cmd.ramp.tooHigh", params: { rise: rise.toFixed(2), height: h.toFixed(2) }, kind: "warning" };
|
||||
if (rise < -h - EPS) return { key: "cmd.ramp.tooLow", params: { drop: (-rise).toFixed(2), height: h.toFixed(2) }, kind: "warning" };
|
||||
return { key: "cmd.ramp.done", kind: "info" };
|
||||
}
|
||||
|
||||
function commit(s: RampState, percent: number, ctx: CommandContext): [CommandState, CommandResult] {
|
||||
const req = { cmd: "ramp", pts: s.points.map(xy), from: xy(s.from!), to: xy(s.to!), percent };
|
||||
return [idle(), { draft: null, done: true, commit: createMutation(ctx, req), notice: { key: "cmd.ramp.done", kind: "info" } }];
|
||||
const notice = rampNotice(s.from!, s.to!, percent, ctx.level.floorHeight);
|
||||
return [idle(), { draft: null, done: true, commit: createMutation(ctx, req), notice }];
|
||||
}
|
||||
|
||||
const closeOutline = (s: RampState): [CommandState, CommandResult] => {
|
||||
|
||||
+51
-12
@@ -32,6 +32,7 @@ import type {
|
||||
Vec2,
|
||||
} from "../types";
|
||||
import { createMutation, createPreview, xy } from "../createCore";
|
||||
import { t } from "../../i18n";
|
||||
|
||||
const EPS = 1e-6;
|
||||
const DEG = Math.PI / 180;
|
||||
@@ -74,6 +75,20 @@ interface ArcMode {
|
||||
arc: boolean;
|
||||
/** Im Bogen-Modus: tangential an den Vorgänger statt Drei-Punkt-Bogen. */
|
||||
tangent: boolean;
|
||||
/** [285] Wandtyp dieses Befehls (Option „Wandtyp“, bleibt erhalten); null = aktiver Wandtyp des Projekts. */
|
||||
typeId: string | null;
|
||||
/** [285] Name zum Wandtyp (nur für die Anzeige der Option). */
|
||||
typeName: string | null;
|
||||
/** [285] Aussenbauteil (IFC `IsExternal`): „auto“ = nach dem Wandtyp („Aussenwand“ ⇒ aussen), „yes“/„no“ ausdrücklich. */
|
||||
ext: "auto" | "yes" | "no";
|
||||
}
|
||||
const NO_MODE: ArcMode = { arc: false, tangent: false, typeId: null, typeName: null, ext: "auto" };
|
||||
const EXT_NEXT = { auto: "yes", yes: "no", no: "auto" } as const;
|
||||
|
||||
/** Kontext mit dem gewählten Wandtyp des Befehls (Option „Wandtyp“); ein inzwischen gelöschter Typ fällt auf den aktiven zurück. */
|
||||
function effCtx(ctx: CommandContext, s: ArcMode): CommandContext {
|
||||
if (!s.typeId || s.typeId === ctx.activeWallTypeId) return ctx;
|
||||
return ctx.project.wallTypes.some((w) => w.id === s.typeId) ? { ...ctx, activeWallTypeId: s.typeId } : ctx;
|
||||
}
|
||||
|
||||
interface WallIdle extends CommandState, ArcMode {
|
||||
@@ -101,6 +116,8 @@ type WallCmdState = WallIdle | WallDrawing;
|
||||
const UNDO: CmdOption = { id: "undo", labelKey: "cmd.polyline.undo" };
|
||||
const arcOption = (on: boolean): CmdOption => ({ id: "arc", labelKey: "cmd.polyline.arcOpt", value: on ? "on" : "off" });
|
||||
const tangentOption = (on: boolean): CmdOption => ({ id: "tangent", labelKey: "cmd.polyline.tangentOpt", value: on ? "on" : "off" });
|
||||
const typeOption = (s: ArcMode): CmdOption => ({ id: "wtype", labelKey: "cmd.wall.typeOpt", value: s.typeName ?? t("cmd.wall.typeActive"), key: "T" });
|
||||
const extOption = (s: ArcMode): CmdOption => ({ id: "ext", labelKey: "cmd.wall.extOpt", value: t(`cmd.wall.ext.${s.ext}`), key: "A" });
|
||||
|
||||
/**
|
||||
* Bänder der schon gesetzten Segmente: sie ändern sich je Mausschritt nicht und werden nur neu gerechnet,
|
||||
@@ -150,22 +167,26 @@ function wallDraft(
|
||||
* Commit: je Achssegment eine Wand des aktiven Typs (Höhe aus dem Geschoss); eine gelockte Dicke
|
||||
* (einschichtig) wählt/erzeugt den passenden Wandtyp — beides im Kern (`cmd_create.rs`).
|
||||
*/
|
||||
const appendWalls = (pts: Vec2[], ctx: CommandContext, thick: number | null, segs: Seg[] = []) =>
|
||||
createMutation(
|
||||
const appendWalls = (pts: Vec2[], ctx: CommandContext, thick: number | null, segs: Seg[] = [], ext: ArcMode["ext"] = "auto") => {
|
||||
const external = ext === "auto" ? null : ext === "yes";
|
||||
return createMutation(
|
||||
ctx,
|
||||
segs.some((g) => g !== 0) ? { cmd: "wall", pts: pts.map(xy), thick, segs } : { cmd: "wall", pts: pts.map(xy), thick },
|
||||
segs.some((g) => g !== 0)
|
||||
? { cmd: "wall", pts: pts.map(xy), thick, segs, external }
|
||||
: { cmd: "wall", pts: pts.map(xy), thick, external },
|
||||
);
|
||||
};
|
||||
|
||||
const idle = (
|
||||
thickOverride: number | null = null,
|
||||
single = false,
|
||||
mode: ArcMode = { arc: false, tangent: false },
|
||||
mode: ArcMode = NO_MODE,
|
||||
): [CommandState, CommandResult] => [
|
||||
{ phase: "start", lastPoint: null, thickOverride, single, arc: mode.arc, tangent: mode.tangent } as WallIdle,
|
||||
{ phase: "start", lastPoint: null, thickOverride, single, ...modeOf(mode) } as WallIdle,
|
||||
{ draft: null, done: true },
|
||||
];
|
||||
|
||||
const modeOf = (s: ArcMode): ArcMode => ({ arc: s.arc, tangent: s.tangent });
|
||||
const modeOf = (s: ArcMode): ArcMode => ({ arc: s.arc, tangent: s.tangent, typeId: s.typeId, typeName: s.typeName, ext: s.ext });
|
||||
const draftOf = (ctx: CommandContext, s: WallDrawing): ToolDraft => wallDraft(ctx, s.points, s.cursor, s.thickOverride, s);
|
||||
|
||||
export const wallCommand: Command = {
|
||||
@@ -181,14 +202,30 @@ export const wallCommand: Command = {
|
||||
accepts: () => ["point", "number", "option"],
|
||||
options: (s) => {
|
||||
const ps = s as WallCmdState;
|
||||
const arc = [arcOption(!!ps.arc), ...(ps.arc ? [tangentOption(!!ps.tangent)] : [])];
|
||||
const arc = [arcOption(!!ps.arc), ...(ps.arc ? [tangentOption(!!ps.tangent)] : []), typeOption(ps), extOption(ps)];
|
||||
return ps.phase === "next" ? [...arc, UNDO] : arc;
|
||||
},
|
||||
init: (): WallIdle => ({ phase: "start", lastPoint: null, thickOverride: null, single: false, arc: false, tangent: false }),
|
||||
init: (): WallIdle => ({ phase: "start", lastPoint: null, thickOverride: null, single: false, ...NO_MODE }),
|
||||
|
||||
onInput: (state, input, ctx): [CommandState, CommandResult] => {
|
||||
onInput: (state, input, ctx0): [CommandState, CommandResult] => {
|
||||
const s = state as WallCmdState;
|
||||
const to = s.thickOverride;
|
||||
|
||||
// [285] Wandtyp wählen (reihum durch die Typen des Projekts) bzw. Aussenbauteil umschalten.
|
||||
if (input.kind === "option" && (input.id === "wtype" || input.id === "ext")) {
|
||||
let flip: Partial<ArcMode>;
|
||||
if (input.id === "ext") flip = { ext: EXT_NEXT[s.ext] };
|
||||
else {
|
||||
const list = ctx0.project.wallTypes;
|
||||
if (list.length === 0) return [s, { draft: null }];
|
||||
const cur = list.findIndex((w) => w.id === (s.typeId ?? ctx0.activeWallTypeId));
|
||||
const next = list[(cur + 1) % list.length];
|
||||
flip = { typeId: next.id, typeName: next.name };
|
||||
}
|
||||
const ns = { ...s, ...flip } as WallCmdState;
|
||||
return [ns, { draft: ns.phase === "next" ? draftOf(effCtx(ctx0, ns), ns) : null }];
|
||||
}
|
||||
const ctx = effCtx(ctx0, s);
|
||||
const single = isSingleLayer(ctx);
|
||||
|
||||
if (input.kind === "option") {
|
||||
@@ -268,22 +305,24 @@ export const wallCommand: Command = {
|
||||
return [ns, { draft: draftOf(ctx, ns) }];
|
||||
},
|
||||
|
||||
onMove: (state, point, _snap, ctx): [CommandState, CommandResult] => {
|
||||
onMove: (state, point, _snap, ctx0): [CommandState, CommandResult] => {
|
||||
const s = state as WallCmdState;
|
||||
if (s.phase !== "next") return [s, { draft: null }];
|
||||
const ctx = effCtx(ctx0, s);
|
||||
const ns: WallDrawing = { ...s, cursor: point, single: isSingleLayer(ctx) };
|
||||
return [ns, { draft: draftOf(ctx, ns) }];
|
||||
},
|
||||
|
||||
// Enter/Space/Rechtsklick: offenen Zug beenden (≥2 Punkte) und committen.
|
||||
onConfirm: (state, ctx): [CommandState, CommandResult] => {
|
||||
onConfirm: (state, ctx0): [CommandState, CommandResult] => {
|
||||
const s = state as WallCmdState;
|
||||
const ctx = effCtx(ctx0, s);
|
||||
if (s.phase === "next" && s.points.length >= 2) {
|
||||
const pts = s.points;
|
||||
const to = s.thickOverride;
|
||||
return [
|
||||
{ phase: "start", lastPoint: null, thickOverride: to, single: s.single, ...modeOf(s) } as WallIdle,
|
||||
{ draft: null, done: true, commit: appendWalls(pts, ctx, to, s.segs) },
|
||||
{ draft: null, done: true, commit: appendWalls(pts, ctx, to, s.segs, s.ext) },
|
||||
];
|
||||
}
|
||||
return idle(s.thickOverride, s.single, modeOf(s));
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* [285] `wallCommand` — Option „Wandtyp“ (reihum durch die Typen des Projekts) und „Aussenbauteil“ (IFC `IsExternal`):
|
||||
* Vorgabe nach dem Namen des Wandtyps („Aussenwand“ ⇒ aussen, „Innenwand“ ⇒ innen), ausdrücklich umschaltbar.
|
||||
*/
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { wallCommand } from "./wall";
|
||||
import type { CommandContext, CmdInput, CommandState, Project } 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: "Aussenwand 36", layers: [{ componentId: "c", thickness: 0.36 }] },
|
||||
{ id: "iw", name: "Innenwand 12", layers: [{ componentId: "c", thickness: 0.12 }] },
|
||||
{ id: "bt", name: "Beton", 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;
|
||||
}
|
||||
|
||||
const ctxOf = (p: Project): CommandContext => ({
|
||||
project: p,
|
||||
level: p.drawingLevels[0],
|
||||
defaultCategoryCode: "20",
|
||||
activeLineStyleId: "solid",
|
||||
activeWallTypeId: "aw",
|
||||
lastPoint: null,
|
||||
selection: { wallIds: [], drawingId: null },
|
||||
});
|
||||
|
||||
const A = { x: 0, y: 0 };
|
||||
const B = { x: 4, y: 0 };
|
||||
|
||||
function draw(options: string[]): Project["walls"][number] {
|
||||
const p = project();
|
||||
const ctx = ctxOf(p);
|
||||
let state: CommandState = wallCommand.init();
|
||||
for (const id of options) state = wallCommand.onInput(state, { kind: "option", id }, ctx)[0];
|
||||
for (const point of [A, B]) state = wallCommand.onInput(state, { kind: "point", point } as CmdInput, ctx)[0];
|
||||
const [, res] = wallCommand.onConfirm(state, ctx);
|
||||
return res.commit!(p).walls[0];
|
||||
}
|
||||
|
||||
describe("wallCommand Wandtyp und Aussenbauteil [285]", () => {
|
||||
it("Vorgabe: aktiver Wandtyp „Aussenwand“ ⇒ Aussenbauteil", () => {
|
||||
const w = draw([]);
|
||||
expect(w.wallTypeId).toBe("aw");
|
||||
expect(w.isExternal).toBe(true);
|
||||
});
|
||||
|
||||
it("Option Wandtyp wählt den nächsten Typ des Projekts; „Innenwand“ ⇒ innen", () => {
|
||||
const w = draw(["wtype"]);
|
||||
expect(w.wallTypeId).toBe("iw");
|
||||
expect(w.isExternal).toBe(false);
|
||||
});
|
||||
|
||||
it("Typ ohne Hinweis im Namen: keine Angabe; Option Aussenbauteil schaltet auto → ja → nein", () => {
|
||||
expect(draw(["wtype", "wtype"]).isExternal).toBeUndefined();
|
||||
expect(draw(["wtype", "wtype", "ext"]).isExternal).toBe(true);
|
||||
expect(draw(["ext", "ext"]).isExternal).toBe(false);
|
||||
});
|
||||
|
||||
it("Die Optionen zeigen den gewählten Typ", () => {
|
||||
const p = project();
|
||||
const ctx = ctxOf(p);
|
||||
const [s] = wallCommand.onInput(wallCommand.init(), { kind: "option", id: "wtype" }, ctx);
|
||||
const o = wallCommand.options(s).find((x) => x.id === "wtype");
|
||||
expect(o?.value).toBe("Innenwand 12");
|
||||
});
|
||||
});
|
||||
@@ -2057,9 +2057,20 @@ export const de = {
|
||||
"cmd.wall.label": "Wand",
|
||||
"cmd.wall.start": "Startpunkt der Wand:",
|
||||
"cmd.wall.next": "Nächster Punkt:",
|
||||
"cmd.wall.typeOpt": "Wandtyp",
|
||||
"cmd.wall.typeActive": "aktiv",
|
||||
"cmd.wall.extOpt": "Aussenbauteil",
|
||||
"cmd.wall.ext.auto": "nach Typ",
|
||||
"cmd.wall.ext.yes": "ja",
|
||||
"cmd.wall.ext.no": "nein",
|
||||
"cmd.ceiling.label": "Decke",
|
||||
"cmd.ceiling.start": "Erster Umrisspunkt der Decke:",
|
||||
"cmd.ceiling.next": "Nächster Punkt ( Schliessen ):",
|
||||
"cmd.ceiling.pos": "Lage",
|
||||
"cmd.ceiling.pos.top": "oben",
|
||||
"cmd.ceiling.pos.below": "unter dem Geschoss",
|
||||
"cmd.ceiling.pos.free": "frei",
|
||||
"cmd.ceiling.z": "Oberkante in m über dem Geschossboden <0>:",
|
||||
"cmd.ramp.label": "Rampe",
|
||||
"cmd.ramp.start": "Erster Umrisspunkt der Rampe:",
|
||||
"cmd.ramp.next": "Nächster Punkt ( Schliessen ):",
|
||||
@@ -2067,6 +2078,8 @@ export const de = {
|
||||
"cmd.ramp.to": "Ende der Gefällelinie:",
|
||||
"cmd.ramp.percent": "Gefälle in % (negativ = abwärts) <6>:",
|
||||
"cmd.ramp.done": "Rampe angelegt.",
|
||||
"cmd.ramp.tooHigh": "Rampe steigt {rise} m, mehr als die Geschosshöhe ({height} m): Anfang und Ende der Gefällelinie vertauscht?",
|
||||
"cmd.ramp.tooLow": "Rampe fällt {drop} m, tiefer als eine Geschosshöhe ({height} m) unter den Boden: Richtung prüfen.",
|
||||
"cmd.beam.done": "Träger angelegt.",
|
||||
"cmd.railing.done": "Geländer angelegt.",
|
||||
"cmd.solidbool.label": "Körper verschneiden",
|
||||
@@ -3320,6 +3333,7 @@ export const de = {
|
||||
"siteRules.areas": "Parzelle {parcel} m² · zulässig {allowed} m²",
|
||||
"siteRules.violation": "Gebäude {area} m² ausserhalb der zulässigen Fläche",
|
||||
"siteRules.inside": "Gebäude innerhalb der zulässigen Fläche",
|
||||
"siteRules.noBuilding": "Noch kein Gebäude gezeichnet",
|
||||
"siteRules.heightOk": "Höhe {top} m ≤ {max} m",
|
||||
"siteRules.heightOver": "Höhe {top} m über {max} m",
|
||||
"siteRules.terrainAtFacade": "Massgebendes Terrain an der Fassade: {z} m (Höhe darüber gemessen)",
|
||||
|
||||
@@ -2046,9 +2046,20 @@ export const en: Record<TranslationKey, string> = {
|
||||
"cmd.wall.label": "Wall",
|
||||
"cmd.wall.start": "Start of wall:",
|
||||
"cmd.wall.next": "Next point:",
|
||||
"cmd.wall.typeOpt": "Wall type",
|
||||
"cmd.wall.typeActive": "active",
|
||||
"cmd.wall.extOpt": "External",
|
||||
"cmd.wall.ext.auto": "by type",
|
||||
"cmd.wall.ext.yes": "yes",
|
||||
"cmd.wall.ext.no": "no",
|
||||
"cmd.ceiling.label": "Ceiling",
|
||||
"cmd.ceiling.start": "First outline point of ceiling:",
|
||||
"cmd.ceiling.next": "Next point ( Close ):",
|
||||
"cmd.ceiling.pos": "Position",
|
||||
"cmd.ceiling.pos.top": "top",
|
||||
"cmd.ceiling.pos.below": "below storey",
|
||||
"cmd.ceiling.pos.free": "free",
|
||||
"cmd.ceiling.z": "Top level in m above storey floor <0>:",
|
||||
"cmd.ramp.label": "Ramp",
|
||||
"cmd.ramp.start": "First outline point of the ramp:",
|
||||
"cmd.ramp.next": "Next point ( Close ):",
|
||||
@@ -2056,6 +2067,8 @@ export const en: Record<TranslationKey, string> = {
|
||||
"cmd.ramp.to": "End of the slope line:",
|
||||
"cmd.ramp.percent": "Gradient in % (negative = downward) <6>:",
|
||||
"cmd.ramp.done": "Ramp created.",
|
||||
"cmd.ramp.tooHigh": "Ramp rises {rise} m, more than the storey height ({height} m): start and end of the slope line swapped?",
|
||||
"cmd.ramp.tooLow": "Ramp drops {drop} m, more than one storey height ({height} m) below the floor: check the direction.",
|
||||
"cmd.beam.done": "Beam created.",
|
||||
"cmd.railing.done": "Railing created.",
|
||||
"cmd.solidbool.label": "Boolean solids",
|
||||
@@ -3268,6 +3281,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"siteRules.areas": "Parcel {parcel} m² · buildable {allowed} m²",
|
||||
"siteRules.violation": "Building {area} m² outside the buildable area",
|
||||
"siteRules.inside": "Building inside the buildable area",
|
||||
"siteRules.noBuilding": "No building drawn yet",
|
||||
"siteRules.heightOk": "Height {top} m ≤ {max} m",
|
||||
"siteRules.heightOver": "Height {top} m exceeds {max} m",
|
||||
"siteRules.terrainAtFacade": "Reference terrain at the façade: {z} m (height measured from it)",
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// [285] Standardaufbauten neuer Projekte haben für jede Schicht eine Wärmeleitfähigkeit (sonst „U-Wert unvollständig“).
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { emptyProject } from "./sampleProject";
|
||||
|
||||
describe("Wärmeleitfähigkeit der Standard-Baustoffe [285]", () => {
|
||||
it("jede Schicht aller Wand-/Decken-/Dachtypen hat λ > 0", () => {
|
||||
const types = [...emptyProject.wallTypes, ...(emptyProject.ceilingTypes ?? []), ...(emptyProject.roofTypes ?? [])];
|
||||
for (const t of types) {
|
||||
for (const l of t.layers) {
|
||||
const c = emptyProject.components.find((x) => x.id === l.componentId);
|
||||
expect(c?.lambda, `${t.name}: ${l.componentId}`).toBeGreaterThan(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -117,10 +117,13 @@ export const sampleProject: Project = {
|
||||
],
|
||||
// Bauteil-Materialien: color = Poché-Füllung im Grundriss UND 3D-Diffusfarbe;
|
||||
// joinPriority höher = läuft am Stoß durch (für spätere T-Stöße).
|
||||
// [285] lambda = Bemessungswert der Wärmeleitfähigkeit W/(m·K), SIA-übliche Richtwerte (SIA 279/180, Merkblatt SIA 2001;
|
||||
// dieselben Werte wie die Standard-Bibliothek `core/standards.rs`) — sonst meldet der U-Wert „unvollständig“.
|
||||
components: [
|
||||
{
|
||||
id: "render-ext",
|
||||
name: "Aussenputz",
|
||||
lambda: 0.87,
|
||||
color: "#d8d2c7",
|
||||
hatchId: "none",
|
||||
joinPriority: 10,
|
||||
@@ -128,10 +131,11 @@ export const sampleProject: Project = {
|
||||
},
|
||||
// Weißer Grund unter den durchgezogenen Dämmungs-Haarlinien (quer zur Wand).
|
||||
// Kein passendes Bibliotheks-Asset (Dämmung) → bewusst ohne `material`.
|
||||
{ id: "insulation", name: "Wärmedämmung", color: "#ffffff", hatchId: "sia-insulation", joinPriority: 20 },
|
||||
{ id: "insulation", name: "Wärmedämmung", color: "#ffffff", hatchId: "sia-insulation", lambda: 0.035, joinPriority: 20 },
|
||||
{
|
||||
id: "brick",
|
||||
name: "Backstein",
|
||||
lambda: 0.44,
|
||||
color: "#8c5544",
|
||||
hatchId: "sia-brick",
|
||||
joinPriority: 50,
|
||||
@@ -140,6 +144,7 @@ export const sampleProject: Project = {
|
||||
{
|
||||
id: "render-int",
|
||||
name: "Innenputz",
|
||||
lambda: 0.7,
|
||||
color: "#efece6",
|
||||
hatchId: "none",
|
||||
joinPriority: 10,
|
||||
@@ -153,6 +158,7 @@ export const sampleProject: Project = {
|
||||
{
|
||||
id: "roof-tiles",
|
||||
name: "Dachziegel",
|
||||
lambda: 1.0,
|
||||
color: "#b8735c",
|
||||
hatchId: "sia-brick",
|
||||
joinPriority: 15,
|
||||
@@ -162,6 +168,7 @@ export const sampleProject: Project = {
|
||||
{
|
||||
id: "concrete",
|
||||
name: "Beton",
|
||||
lambda: 2.0,
|
||||
color: "#9aa0a6",
|
||||
hatchId: "sia-concrete",
|
||||
joinPriority: 100,
|
||||
@@ -169,7 +176,7 @@ export const sampleProject: Project = {
|
||||
},
|
||||
// Zementestrich — oberste Schicht des mehrschichtigen Deckenaufbaus (Decken-Stile).
|
||||
// Kein passendes Bibliotheks-Asset (Estrich) → bewusst ohne `material`.
|
||||
{ id: "screed", name: "Zementestrich", color: "#c9c2b3", hatchId: "diagonal", joinPriority: 30 },
|
||||
{ id: "screed", name: "Zementestrich", color: "#c9c2b3", hatchId: "diagonal", lambda: 1.4, joinPriority: 30 },
|
||||
],
|
||||
wallTypes: [
|
||||
{
|
||||
|
||||
@@ -96,7 +96,7 @@ export function SiteRulesSection() {
|
||||
|
||||
const check = checkSiteRules(project);
|
||||
const n = rules.parcel.length;
|
||||
const ok = check !== null && check.violationArea < 0.01 && !check.heightExceeded && !check.profileExceeded;
|
||||
const ok = check !== null && check.maxTop !== null && check.violationArea < 0.01 && !check.heightExceeded && !check.profileExceeded;
|
||||
|
||||
return (
|
||||
<div className="site-rules">
|
||||
@@ -121,12 +121,14 @@ export function SiteRulesSection() {
|
||||
</div>
|
||||
|
||||
{check && (
|
||||
<div className={"site-rules-result" + (ok ? " ok" : " bad")}>
|
||||
<div className={"site-rules-result" + (check.maxTop === null ? "" : ok ? " ok" : " bad")}>
|
||||
<div>{t("siteRules.areas", { parcel: fmt(check.parcelArea), allowed: fmt(check.allowedArea) })}</div>
|
||||
<div>
|
||||
{check.violationArea >= 0.01
|
||||
? t("siteRules.violation", { area: fmt(check.violationArea, 2) })
|
||||
: t("siteRules.inside")}
|
||||
: check.maxTop === null
|
||||
? t("siteRules.noBuilding")
|
||||
: t("siteRules.inside")}
|
||||
</div>
|
||||
{rules.maxHeight !== undefined && check.maxTop !== null && (
|
||||
<div>
|
||||
|
||||
Reference in new issue
Block a user