Schnitt: geschnittene Wand/Decke waagrecht ziehen (Grundriss-Verschiebung entlang der Schnittlinie, Vorschau im Blatt); automatische Hoehenkoten in Schnitt und Ansicht

This commit is contained in:
karim committed 2026-10-21 18:57:57 +02:00
1 parent f44ba9ed85
commit 50bff03b51
11 files changed
+276 -38

No files matched your search

+46 -29
View File
@@ -156,6 +156,51 @@ const XLINE_DASH: number[] = [0.3, 0.1, 0.03, 0.1]; // Strich-Punkt (CAD-Mittell
// ── Leader (Vorführungspfeil) ────────────────────────────────────────────────
/**
* Höhenkote (SIA 400 B.5.4/Figur 18) als Primitive: OK = Spitze nach unten,
* UK = Spitze nach oben; fertig = Kontur (hohl), roh = voll gefüllt. `at` ist
* die Spitze. Geteilt vom 2D-Element `kote` und den automatischen Koten im
* Schnitt/in der Ansicht (`plan/levelMarkers.ts`).
*/
export function pushKote(
out: Primitive[],
at: Vec2,
value: number,
kind: "okFertig" | "ukFertig" | "okRoh" | "ukRoh",
color: string,
weightMm: number,
greyed: boolean,
drawingId?: string,
): void {
const up = kind === "okFertig" || kind === "okRoh" ? 1 : -1;
const filled = kind === "okRoh" || kind === "ukRoh";
const pts: Vec2[] = [
at,
{ x: at.x - KOTE_TRI_HALF_W_M, y: at.y + up * KOTE_TRI_SIZE_M },
{ x: at.x + KOTE_TRI_HALF_W_M, y: at.y + up * KOTE_TRI_SIZE_M },
];
out.push({
kind: "polygon",
pts,
fill: filled ? color : "none",
stroke: color,
strokeWidthMm: weightMm,
hatch: NO_HATCH,
greyed,
drawingId,
});
out.push({
kind: "drawingText",
at: { x: at.x + KOTE_TRI_HALF_W_M + KOTE_TEXT_GAP_M, y: at.y + up * KOTE_TRI_SIZE_M * 0.5 },
text: formatKoteLabel(value),
heightM: KOTE_TEXT_HEIGHT_M,
angle: 0,
color,
greyed,
drawingId,
});
}
/**
* Erzeugt die Plan-Primitive EINES 2D-Elements. Hülle um
* {@link addDrawing2DInner}: sie stempelt am Ende die Objekt-Transparenz
@@ -691,35 +736,7 @@ function addDrawing2DInner(
break;
}
case "kote": {
// SIA 400 B.5.4/Figur 18: OK = Spitze nach unten, UK = Spitze nach oben;
// fertig = Kontur (hohl), roh = voll gefüllt. `at` ist die Spitze.
const up = g.kind === "okFertig" || g.kind === "okRoh" ? 1 : -1;
const filled = g.kind === "okRoh" || g.kind === "ukRoh";
const pts: Vec2[] = [
g.at,
{ x: g.at.x - KOTE_TRI_HALF_W_M, y: g.at.y + up * KOTE_TRI_SIZE_M },
{ x: g.at.x + KOTE_TRI_HALF_W_M, y: g.at.y + up * KOTE_TRI_SIZE_M },
];
out.push({
kind: "polygon",
pts,
fill: filled ? color : "none",
stroke: color,
strokeWidthMm: weightMm,
hatch: NO_HATCH,
greyed,
drawingId: d.id,
});
out.push({
kind: "drawingText",
at: { x: g.at.x + KOTE_TRI_HALF_W_M + KOTE_TEXT_GAP_M, y: g.at.y + up * KOTE_TRI_SIZE_M * 0.5 },
text: formatKoteLabel(g.value),
heightM: KOTE_TEXT_HEIGHT_M,
angle: 0,
color,
greyed,
drawingId: d.id,
});
pushKote(out, g.at, g.value, g.kind, color, weightMm, greyed, d.id);
break;
}
case "detailref": {
+28
View File
@@ -0,0 +1,28 @@
import { describe, expect, it } from "vitest";
import { sampleProject } from "../model/sampleProject";
import type { Primitive } from "./generatePlan";
import { levelMarkerPrimitives, levelMarksEnabled } from "./levelMarkers";
const texts = (prims: Primitive[]) =>
prims.filter((p): p is Extract<Primitive, { kind: "drawingText" }> => p.kind === "drawingText").map((p) => p.text);
describe("levelMarkerPrimitives", () => {
it("Kote je Geschoss (OK fertig Boden) + oberste Kante, links der Zeichnung", () => {
const prims = levelMarkerPrimitives(sampleProject, { minX: 0, minY: -0.3, maxX: 5, maxY: 6.2 });
expect(texts(prims)).toEqual(["±0.00", "+2.60", "+6.20"]);
for (const p of prims) {
if (p.kind === "line") expect(Math.max(p.a.x, p.b.x)).toBeLessThan(0);
}
});
it("Geschosse ausserhalb der Zeichnung entfallen", () => {
const prims = levelMarkerPrimitives(sampleProject, { minX: 0, minY: 2, maxX: 5, maxY: 6 });
expect(texts(prims)).toEqual(["+2.60", "+6.00"]);
});
it("standardmässig an, abschaltbar", () => {
const lv = sampleProject.drawingLevels.find((l) => l.kind === "section")!;
expect(levelMarksEnabled(lv)).toBe(true);
expect(levelMarksEnabled({ ...lv, levelMarks: false })).toBe(false);
});
});
+55
View File
@@ -0,0 +1,55 @@
// Automatische Höhenkoten im Schnitt/in der Ansicht: je Geschoss die Kote
// OK fertig Boden (`baseElevation`, ±0.00 = Bezug) plus die oberste Kante des
// Gebäudes (First/OK Dach), links neben der Zeichnung mit einer kurzen
// Bezugslinie zur Geometrie. Symbol = dieselbe SIA-400-Kote wie das 2D-Element
// `kote` (`pushKote`). Abschaltbar je Ebene (`DrawingLevel.levelMarks`).
import type { DrawingLevel, Project } from "../model/types";
import { pushKote } from "./generatePlan/drawing2d";
import type { Primitive } from "./generatePlan";
const INK = "#1f242c";
/** Abstand der Kote links von der Zeichnung (Meter). */
const MARK_OFFSET_M = 1.2;
/** Länge der Bezugslinie (Meter, endet knapp vor der Zeichnung). */
const LEADER_GAP_M = 0.15;
/** Ob eine Ebene automatische Koten trägt (Default an). */
export function levelMarksEnabled(level: DrawingLevel): boolean {
return level.levelMarks !== false;
}
/**
* Kote-Primitive für eine Zeichnung mit den Grenzen `bounds` (u, Höhe). Höhen
* ausserhalb der Zeichnung (Geschosse, die der Schnitt nicht zeigt) entfallen.
*/
export function levelMarkerPrimitives(
project: Project,
bounds: { minX: number; minY: number; maxX: number; maxY: number },
): Primitive[] {
if (!(bounds.maxX > bounds.minX) || !(bounds.maxY > bounds.minY)) return [];
const x = bounds.minX - MARK_OFFSET_M;
const heights: number[] = [];
const pushH = (z: number) => {
if (z < bounds.minY - 1e-6 || z > bounds.maxY + 1e-6) return;
if (heights.some((h) => Math.abs(h - z) < 0.05)) return;
heights.push(z);
};
for (const l of project.drawingLevels) {
if (l.kind === "floor" && l.baseElevation !== undefined) pushH(l.baseElevation);
}
pushH(bounds.maxY);
const out: Primitive[] = [];
for (const z of heights) {
out.push({
kind: "line",
a: { x: x - 0.3, y: z },
b: { x: bounds.minX - LEADER_GAP_M, y: z },
cls: "section-level-leader",
weightMm: 0.13,
color: INK,
});
pushKote(out, { x, y: z }, Math.round(z * 100) / 100, "okFertig", INK, 0.18, false);
}
return out;
}