[140] Raumstempel ab 1:200 kleiner und ohne SIA-Zeile; Tests an neue Defaults angepasst
This commit is contained in:
7 files changed
+45
-25
No files matched your search
@@ -23,6 +23,9 @@ const COLUMN_FALLBACK_FILL: &str = "#3a3f47";
|
||||
const ROOM_FILL_ALPHA: &str = "00";
|
||||
/// Basis-Schriftgrösse des Raumstempels (pt).
|
||||
const ROOM_STAMP_PT: f64 = 10.0;
|
||||
/// [140] Raumstempel ab 1:200 (2.5 mm statt 3.5 mm, ohne SIA-Zeile): kleine Räume überlappen sonst.
|
||||
const ROOM_STAMP_SMALL_PT: f64 = 7.0;
|
||||
const ROOM_STAMP_SMALL_FROM: f64 = 200.0;
|
||||
const NAME_PT: f64 = 12.0;
|
||||
const NUMBER_PT: f64 = 9.0;
|
||||
const LINE2_PT: f64 = 9.0;
|
||||
@@ -605,17 +608,18 @@ fn rooms(c: &Ctx, out: &mut Vec<Primitive>, bounds: &mut Bounds) {
|
||||
continue;
|
||||
}
|
||||
let at = room.stamp_anchor.unwrap_or(pv(res.centroid));
|
||||
let small = c.a.scale >= ROOM_STAMP_SMALL_FROM;
|
||||
let (doc, extra_lines) = match &room.stamp {
|
||||
Some(s) => (room_stamp_to_doc(s), room_stamp_extra_lines(s, res.net, room.sia_category)),
|
||||
None => (
|
||||
room.stamp_doc.clone().unwrap_or_else(|| doc_from_text(&room.name)),
|
||||
vec![
|
||||
StampLine { text: format!("{} m²", to_fixed(res.net, 2)), align: Align::Center },
|
||||
StampLine { text: format!("{} · {}", sia_key(room.sia_category), sia_label(room.sia_category)), align: Align::Center },
|
||||
],
|
||||
),
|
||||
None => {
|
||||
let mut lines = vec![StampLine { text: format!("{} m²", to_fixed(res.net, 2)), align: Align::Center }];
|
||||
if !small {
|
||||
lines.push(StampLine { text: format!("{} · {}", sia_key(room.sia_category), sia_label(room.sia_category)), align: Align::Center });
|
||||
}
|
||||
(room.stamp_doc.clone().unwrap_or_else(|| doc_from_text(&room.name)), lines)
|
||||
}
|
||||
};
|
||||
out.push(Primitive::Text { at, doc, extra_lines, base_pt: ROOM_STAMP_PT, color: color.into(), room_id: Some(room.id.clone()), greyed, opacity: None });
|
||||
out.push(Primitive::Text { at, doc, extra_lines, base_pt: if small { ROOM_STAMP_SMALL_PT } else { ROOM_STAMP_PT }, color: color.into(), room_id: Some(room.id.clone()), greyed, opacity: None });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -985,6 +989,19 @@ mod tests {
|
||||
PlanArgs::parse(detail, &t).unwrap()
|
||||
}
|
||||
|
||||
/// [140] Raumstempel ab 1:200 kleiner (7 pt) und ohne SIA-Zeile; bis 1:100 10 pt mit zwei Zusatzzeilen.
|
||||
#[test]
|
||||
fn raumstempel_je_massstab() {
|
||||
let p = sample();
|
||||
let stamp = |scale: f64| {
|
||||
let t = serde_json::json!({ "floor": "eg", "show": ["20", "60"], "grey": [], "scale": scale }).to_string();
|
||||
let r = plan_domains(&p, &PlanArgs::parse(1.0, &t).unwrap()).unwrap();
|
||||
r.rooms.iter().find_map(|q| match q { Primitive::Text { base_pt, extra_lines, .. } => Some((*base_pt, extra_lines.len())), _ => None }).unwrap()
|
||||
};
|
||||
assert_eq!(stamp(100.0), (ROOM_STAMP_PT, 2));
|
||||
assert_eq!(stamp(200.0), (ROOM_STAMP_SMALL_PT, 1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn beispiel_eg_decke_raum() {
|
||||
let p = sample();
|
||||
|
||||
@@ -124,8 +124,8 @@ describe.skipIf(!hasEzdxf)("Fachplaner-Export gegen ezdxf", { timeout: 60_000 },
|
||||
}
|
||||
const st = r.dimstyles["DOSSIER_1-100"];
|
||||
expect(st).toMatchObject({ dimscale: 100, dimtad: 1, dimdec: 2, dimlfac: 1, dimtxsty: "DOSSIER" });
|
||||
expect(st.dimtxt as number).toBeCloseTo(0.004, 9); // 4 mm Papier
|
||||
expect(st.dimtsz as number).toBeCloseTo(0.0015, 9); // Architekturstrich 3 mm
|
||||
expect(st.dimtxt as number).toBeCloseTo(0.0025, 9); // 2.5 mm Papier ([140])
|
||||
expect(st.dimtsz as number).toBeCloseTo(0.001, 9); // Architekturstrich 2 mm ([140])
|
||||
});
|
||||
|
||||
it("Bemassungsstil im Massstab 1:50 und in cm", () => {
|
||||
|
||||
@@ -131,10 +131,10 @@ describe("Druck-SVG: Textgrössen in Papier-mm", () => {
|
||||
expect(t.xs[0] - t.xs[1]).toBeCloseTo((4 * K) / 2, 3);
|
||||
});
|
||||
|
||||
it("Masszahl in der Papier-Schrifthöhe (4 mm), Höhenkote lesbar gross", () => {
|
||||
it("Masszahl in der Papier-Schrifthöhe (2.5 mm, [140]), Höhenkote lesbar gross", () => {
|
||||
const all = print();
|
||||
const dim = all.find((x) => x.text === "5.00")!;
|
||||
expect(dim.sizes[0]).toBeCloseTo(4, 3);
|
||||
expect(dim.sizes[0]).toBeCloseTo(2.5, 3);
|
||||
const kote = all.find((x) => /0[.,]00/.test(x.text) && x !== dim);
|
||||
expect(kote).toBeDefined();
|
||||
expect(kote!.sizes[0]).toBeGreaterThan(1);
|
||||
|
||||
@@ -633,8 +633,8 @@ describe("2D-Zeichnung — Bemassung: Papier-mm statt Modellmass", () => {
|
||||
const lens = out
|
||||
.filter((p) => p.kind === "line")
|
||||
.map((p) => (p.kind === "line" ? Math.hypot(p.b.x - p.a.x, p.b.y - p.a.y) : 0));
|
||||
// Default 3 mm bei 1:50 = 0.15 m (der frühere feste Modellwert).
|
||||
expect(Math.min(...lens)).toBeCloseTo(0.15, 9);
|
||||
// Default 2 mm bei 1:50 = 0.1 m ([140], vorher 3 mm).
|
||||
expect(Math.min(...lens)).toBeCloseTo(0.1, 9);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -134,11 +134,11 @@ describe("generatePlan — Schichtfugen als stilisierbare Linien", () => {
|
||||
expect(joints[0].dash ?? null).toBeNull();
|
||||
});
|
||||
|
||||
it("fällt ohne Zuweisung auf die Haarlinie (0.02 mm) in Wandfarbe zurück", () => {
|
||||
it("fällt ohne Zuweisung auf die feine Fuge (0.09 mm, [140]) in Wandfarbe zurück", () => {
|
||||
const proj = cornerProject();
|
||||
proj.walls = [proj.walls[0]];
|
||||
const joints = jointLines(proj);
|
||||
expect(joints.length).toBe(1);
|
||||
expect(joints[0].weightMm).toBeCloseTo(0.02, 6);
|
||||
expect(joints[0].weightMm).toBeCloseTo(0.09, 6);
|
||||
});
|
||||
});
|
||||
@@ -12,6 +12,9 @@ import type { Primitive } from "./generatePlan/shared";
|
||||
|
||||
const ALL = new Set(flattenCategories(sampleProject.layers).map((c) => c.code));
|
||||
const on: Project = { ...sampleProject, scaleLineWeights: true };
|
||||
const off: Project = { ...sampleProject, scaleLineWeights: false };
|
||||
// [140] Kern `scale_weight`: nur der Anteil über 0.09 mm skaliert (1:200: Faktor √½).
|
||||
const scaledWeight = (w: number, f: number) => (w > 0.09 ? 0.09 + (w - 0.09) * f : w);
|
||||
const weights = (ps: Primitive[]) =>
|
||||
ps.flatMap((p) => (p.kind === "polygon" ? [p.strokeWidthMm] : "weightMm" in p && typeof p.weightMm === "number" ? [p.weightMm] : []));
|
||||
const plan = (p: Project, n: number, compact = false) =>
|
||||
@@ -19,18 +22,18 @@ const plan = (p: Project, n: number, compact = false) =>
|
||||
|
||||
describe("Strichstärken nach Massstab", () => {
|
||||
// Der Faktor selbst (Grenzen, ungültiger Massstab) ist im Kern geprüft (`plan/extras.rs`).
|
||||
it("Grundriss 1:200: jede Stärke × Faktor, aus → unverändert", () => {
|
||||
const base = weights(plan(sampleProject, 200).primitives);
|
||||
it("Grundriss 1:200: jede Stärke über dem Sockel × Faktor, aus → unverändert", () => {
|
||||
const base = weights(plan(off, 200).primitives);
|
||||
const scaled = weights(plan(on, 200).primitives);
|
||||
expect(scaled.length).toBe(base.length);
|
||||
const f = 0.5 ** 0.25;
|
||||
scaled.forEach((w, i) => expect(w).toBeCloseTo(base[i] * f, 9));
|
||||
expect(scaled).not.toEqual(base);
|
||||
scaled.forEach((w, i) => expect(w).toBeCloseTo(scaledWeight(base[i], Math.SQRT1_2), 9));
|
||||
});
|
||||
it("auch die kompakte Linien-Unterlage (GPU-Ansicht) wird skaliert", () => {
|
||||
const base = weights(plan(sampleProject, 200, true).primitives);
|
||||
const base = weights(plan(off, 200, true).primitives);
|
||||
const scaled = weights(plan(on, 200, true).primitives);
|
||||
expect(scaled.length).toBe(base.length);
|
||||
scaled.forEach((w, i) => expect(w).toBeCloseTo(base[i] * 0.5 ** 0.25, 9));
|
||||
scaled.forEach((w, i) => expect(w).toBeCloseTo(scaledWeight(base[i], Math.SQRT1_2), 9));
|
||||
});
|
||||
it("gleiche Eingabe → gleiche Inhalts-Hashes der Kern-Abschnitte (GPU-Cache), auch mit Massstab", () => {
|
||||
const line = {
|
||||
@@ -41,7 +44,7 @@ describe("Strichstärken nach Massstab", () => {
|
||||
const pl = generatePlan(p, "eg", ALL, undefined, "mittel", false, false, true, 200);
|
||||
return (pl.bufRuns ?? []).flatMap((r) => Array.from(r.buf.hashes!.subarray(r.from, r.to)));
|
||||
};
|
||||
const base = { ...sampleProject, drawings2d: [...sampleProject.drawings2d, line] };
|
||||
const base = { ...off, drawings2d: [...sampleProject.drawings2d, line] };
|
||||
const a = hashes(base);
|
||||
expect(a.length).toBeGreaterThan(0);
|
||||
expect(hashes(base)).toEqual(a);
|
||||
|
||||
@@ -340,11 +340,11 @@ describe("generatePlan — Linien-Übersteuerung je Kategorie (Opening.frameLine
|
||||
sillLine: { faces: "aussen", view: "auf" },
|
||||
};
|
||||
|
||||
it("ohne Übersteuerung: Stulp-/Sash-/Sims-Linien nutzen den Default (Opening.color bzw. Haarlinie)", () => {
|
||||
it("ohne Übersteuerung: Stulp-/Sash-/Sims-Linien nutzen den Default (Opening.color bzw. feine Linie 0.13, [140])", () => {
|
||||
const p = project({ ...baseWindow, typeId: "wt1" }, [twoSashType]);
|
||||
const stulp = linesOfClass(p, "window-stulp", "mittel");
|
||||
expect(stulp.length).toBeGreaterThan(0);
|
||||
for (const l of stulp) expect(l.kind === "line" && l.weightMm).toBeCloseTo(0.02, 6);
|
||||
for (const l of stulp) expect(l.kind === "line" && l.weightMm).toBeCloseTo(0.13, 6);
|
||||
});
|
||||
|
||||
it("frameLine übersteuert Farbe+Stärke der Laibungs-Blöcke (window-stulp, einflügliges Fenster ohne Flügelstoss)", () => {
|
||||
|
||||
Reference in new issue
Block a user