[100] Deckenspiegel: Leuchten (Symbol Deckenleuchte, Kategorie 65), Deckenspiegel im Layout-Viewport geprüft
This commit is contained in:
8 files changed
+117
-3
No files matched your search
@@ -369,6 +369,27 @@ pub(crate) mod tests {
|
||||
assert!((x - 95.0).abs() < 1e-9 && (y - 70.0).abs() < 1e-9);
|
||||
}
|
||||
|
||||
/// [100] Deckenspiegel-Viewport: derselbe Inhalt wie die Deckenspiegel-Ebene (Wände, Untersicht).
|
||||
#[test]
|
||||
fn deckenspiegel_viewport() {
|
||||
let mut v = json();
|
||||
v["drawingLevels"].as_array_mut().unwrap().push(serde_json::json!({"id": "ds", "name": "DS", "kind": "ceiling", "visible": true, "locked": false, "ceilingOfId": "eg"}));
|
||||
v["layers"].as_array_mut().unwrap().push(serde_json::json!({"code": "30", "name": "D", "color": "#000", "lw": 0.35, "visible": true, "locked": false}));
|
||||
v["walls"] = serde_json::json!([{"id": "W", "type": "wall", "floorId": "eg", "categoryCode": "20", "start": {"x": 0, "y": 0}, "end": {"x": 10, "y": 0}, "height": 2.6}]);
|
||||
v["ceilings"] = serde_json::json!([{"id": "C", "type": "ceiling", "floorId": "eg", "categoryCode": "30", "thickness": 0.2, "outline": [{"x": 0, "y": 0}, {"x": 10, "y": 0}, {"x": 10, "y": 6}, {"x": 0, "y": 6}]}]);
|
||||
v["viewSnapshots"].as_array_mut().unwrap().push(serde_json::json!({"id": "sd", "name": "DS", "viewType": "grundriss", "view3d": "iso", "scaleDenominator": 50, "detail": "mittel", "activeLevelId": "ds", "layerVisibility": {"20": true, "30": true}, "drawingVisibility": {}}));
|
||||
v["layouts"][0]["viewports"] = serde_json::json!([{"id": "vd", "snapshotId": "sd", "xMm": 20, "yMm": 20, "widthMm": 300, "heightMm": 200}]);
|
||||
let p: Project = serde_json::from_value(v).unwrap();
|
||||
let maps = viewport_maps(&p, layout_of_level(&p, "sh").unwrap());
|
||||
assert_eq!(maps.len(), 1);
|
||||
assert_eq!(maps[0].scale, 50.0);
|
||||
let snap = &p.view_snapshots.as_ref().unwrap()[1];
|
||||
let direct = crate::plan::domains::plan_domains(&p, &viewport_args(snap, 50.0)).unwrap();
|
||||
assert!(!direct.walls.is_empty() && !direct.ceilings.is_empty(), "Wände und Untersicht im Viewport");
|
||||
let b = crate::plan::buf::View::parse(&maps[0].buf).unwrap().bounds().unwrap();
|
||||
assert!(b[2] - b[0] > 9.9 && b[3] - b[1] > 5.9, "Ausmass der Decke: {b:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn klippen() {
|
||||
let r = [0.0, 0.0, 1.0, 1.0];
|
||||
|
||||
@@ -281,6 +281,34 @@ pub fn view_templates() -> Vec<Value> {
|
||||
]
|
||||
}
|
||||
|
||||
/// [100] Symbole (2D-Blöcke): Deckenleuchte als Kreis mit Diagonalkreuz (Elektro-Sinnbild), Ø 30 cm,
|
||||
/// für den Deckenspiegel (Kategorie „Leuchten“, [`light_category`]).
|
||||
pub fn block_defs() -> Vec<Value> {
|
||||
let k = 0.15 * std::f64::consts::FRAC_1_SQRT_2;
|
||||
let p = |x: f64, y: f64| json!({"x": x, "y": y});
|
||||
vec![json!({"id": "std-blk-deckenleuchte", "name": "Deckenleuchte", "geom2d": [
|
||||
{"shape": "circle", "center": p(0.0, 0.0), "r": 0.15},
|
||||
{"shape": "line", "a": p(-k, -k), "b": p(k, k)},
|
||||
{"shape": "line", "a": p(-k, k), "b": p(k, -k)},
|
||||
]})]
|
||||
}
|
||||
|
||||
/// [100] Grafik-Kategorie „Leuchten“ (Code 65) für Leuchten-Symbole im Deckenspiegel.
|
||||
pub const LIGHT_CATEGORY_CODE: &str = "65";
|
||||
|
||||
pub fn light_category() -> Value {
|
||||
json!({"code": LIGHT_CATEGORY_CODE, "name": "Leuchten", "color": "#b08020", "lw": 0.18, "visible": true, "locked": false})
|
||||
}
|
||||
|
||||
/// Gibt es im Kategorie-Baum schon den Code oder den Namen der Leuchten-Kategorie?
|
||||
fn has_light_category(layers: &[Value]) -> bool {
|
||||
layers.iter().any(|l| {
|
||||
l["code"].as_str() == Some(LIGHT_CATEGORY_CODE)
|
||||
|| name_key(l).as_deref() == Some("leuchten")
|
||||
|| l["children"].as_array().is_some_and(|c| has_light_category(c))
|
||||
})
|
||||
}
|
||||
|
||||
pub fn library() -> Vec<(&'static str, Vec<Value>)> {
|
||||
vec![
|
||||
("lineStyles", line_styles()),
|
||||
@@ -290,6 +318,7 @@ pub fn library() -> Vec<(&'static str, Vec<Value>)> {
|
||||
("ceilingTypes", ceiling_types()),
|
||||
("roofTypes", roof_types()),
|
||||
("viewTemplates", view_templates()),
|
||||
("blockDefs", block_defs()),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -348,6 +377,13 @@ fn merge_plan(root: &Map<String, Value>) -> (Vec<Value>, HashMap<String, String>
|
||||
ops.push(json!({"kind": "setField", "key": key, "value": add}));
|
||||
}
|
||||
}
|
||||
// Kategorie „Leuchten“ (Kategorien haben keine id: ganze Liste setzen, ein Undo-Schritt).
|
||||
let layers = root.get("layers").and_then(Value::as_array).cloned().unwrap_or_default();
|
||||
if !has_light_category(&layers) {
|
||||
let mut all = layers;
|
||||
all.push(light_category());
|
||||
ops.push(json!({"kind": "setField", "key": "layers", "value": all}));
|
||||
}
|
||||
(ops, ids)
|
||||
}
|
||||
|
||||
@@ -378,6 +414,7 @@ fn managed(key: &str) -> &'static [&'static str] {
|
||||
"color", "background", "hatchId", "viewHatchId", "joinPriority", "fireClass", "elevationColor", "standardId", "lambda", "density", "material", "surfacePattern",
|
||||
"abbrev",
|
||||
],
|
||||
"blockDefs" => &["geom2d"],
|
||||
_ => &["layers"],
|
||||
}
|
||||
}
|
||||
@@ -553,6 +590,26 @@ mod tests {
|
||||
r
|
||||
}
|
||||
|
||||
/// [100] Leuchten: Symbol Deckenleuchte (Kreis mit Kreuz) und Kategorie „Leuchten“, nur einmal.
|
||||
#[test]
|
||||
fn leuchten_symbol_und_kategorie() {
|
||||
let r = apply(&empty_root(), &merge_ops(&empty_root()));
|
||||
let p: Project = serde_json::from_value(Value::Object(r.clone())).unwrap();
|
||||
let b = p.block_defs.as_ref().unwrap().iter().find(|b| b.id == "std-blk-deckenleuchte").expect("Deckenleuchte");
|
||||
assert_eq!(b.geom2d.len(), 3);
|
||||
assert!(p.layers.iter().any(|l| l.code == "65" && l.name == "Leuchten"));
|
||||
assert!(merge_ops(&r).is_empty(), "zweites Laden ergänzt nichts");
|
||||
// Vorhandene Kategorie gleichen Namens (anderer Code, als Kind): keine zweite.
|
||||
let mut own = empty_root();
|
||||
own.insert("layers".into(), json!([{"code": "20", "name": "Wände", "color": "#000", "lw": 0.35, "visible": true, "locked": false,
|
||||
"children": [{"code": "28", "name": "Leuchten", "color": "#000", "lw": 0.13, "visible": true, "locked": false}]}]));
|
||||
assert!(!merge_ops(&own).iter().any(|o| o["key"] == "layers"));
|
||||
// Andere Kategorien bleiben, die neue kommt ans Ende.
|
||||
own.insert("layers".into(), json!([{"code": "20", "name": "Wände", "color": "#000", "lw": 0.35, "visible": true, "locked": false}]));
|
||||
let op = merge_ops(&own).into_iter().find(|o| o["key"] == "layers").unwrap();
|
||||
assert_eq!(op["value"].as_array().unwrap().iter().map(|l| l["code"].as_str().unwrap()).collect::<Vec<_>>(), ["20", "65"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bibliothek_ist_vollstaendig_und_gueltig() {
|
||||
let r = apply(&empty_root(), &merge_ops(&empty_root()));
|
||||
|
||||
@@ -1425,6 +1425,7 @@ export const de = {
|
||||
"resources.loadStandards.n.viewTemplates": "{n} Ansichtsvorlagen",
|
||||
"resources.loadStandards.n.hatches": "{n} Schraffuren",
|
||||
"resources.loadStandards.n.lineStyles": "{n} Linientypen",
|
||||
"resources.loadStandards.n.blockDefs": "{n} Symbole",
|
||||
"resources.col.lambda": "Wärmeleitfähigkeit λ [W/mK]",
|
||||
"resources.col.density": "Rohdichte [kg/m³]",
|
||||
"resources.col.fireClass": "Brandverhalten (VKF)",
|
||||
|
||||
@@ -1418,6 +1418,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"resources.loadStandards.n.viewTemplates": "{n} view templates",
|
||||
"resources.loadStandards.n.hatches": "{n} hatches",
|
||||
"resources.loadStandards.n.lineStyles": "{n} line types",
|
||||
"resources.loadStandards.n.blockDefs": "{n} symbols",
|
||||
"resources.col.lambda": "Thermal conductivity λ [W/mK]",
|
||||
"resources.col.density": "Density [kg/m³]",
|
||||
"resources.col.fireClass": "Reaction to fire (VKF)",
|
||||
|
||||
@@ -35,7 +35,7 @@ describe("Standard-Bibliothek ([100]–[102])", () => {
|
||||
expect(c.components).toBe(35);
|
||||
expect(c.lineStyles).toBeGreaterThan(5);
|
||||
expect(c.wallTypes + c.ceilingTypes + c.roofTypes).toBe(5);
|
||||
expect(standardsMergeCounts(standardsMergeOps(withStandards(empty)))).toEqual({ lineStyles: 0, hatches: 0, components: 0, wallTypes: 0, ceilingTypes: 0, roofTypes: 0, viewTemplates: 0 });
|
||||
expect(standardsMergeCounts(standardsMergeOps(withStandards(empty)))).toEqual({ lineStyles: 0, hatches: 0, components: 0, wallTypes: 0, ceilingTypes: 0, roofTypes: 0, viewTemplates: 0, blockDefs: 0 });
|
||||
});
|
||||
|
||||
it("Sinnbilder nach SIA 400 Fig. 34: Putz leer, Dämmung quer, Beton gekreuzt", () => {
|
||||
|
||||
@@ -27,10 +27,12 @@ export interface StandardsMergeCounts {
|
||||
ceilingTypes: number;
|
||||
roofTypes: number;
|
||||
viewTemplates: number;
|
||||
/** Symbole (2D-Blöcke, z. B. Deckenleuchte [100]). */
|
||||
blockDefs: number;
|
||||
}
|
||||
|
||||
export function standardsMergeCounts(ops: readonly CoreOp[]): StandardsMergeCounts {
|
||||
const out: StandardsMergeCounts = { lineStyles: 0, hatches: 0, components: 0, wallTypes: 0, ceilingTypes: 0, roofTypes: 0, viewTemplates: 0 };
|
||||
const out: StandardsMergeCounts = { lineStyles: 0, hatches: 0, components: 0, wallTypes: 0, ceilingTypes: 0, roofTypes: 0, viewTemplates: 0, blockDefs: 0 };
|
||||
for (const op of ops) {
|
||||
const key = op.kind === "add" ? op.collection : op.kind === "setField" ? op.key : null;
|
||||
const n = op.kind === "add" ? op.items.length : op.kind === "setField" && Array.isArray(op.value) ? op.value.length : 0;
|
||||
|
||||
@@ -31,3 +31,35 @@ describe("viewportLevelPlan", () => {
|
||||
expect(plan.primitives.length).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
// [100] Deckenspiegel auf dem Blatt: derselbe Plan wie die Deckenspiegel-Ebene (Blattansicht und PDF rufen
|
||||
// beide `viewportLevelPlan`), Strichstärken der geschnittenen Wände wie im Grundriss.
|
||||
describe("viewportLevelPlan: Deckenspiegel ([100])", () => {
|
||||
const q = structuredClone(p);
|
||||
q.drawingLevels.push({ id: "ds-og", name: "Deckenspiegel OG", kind: "ceiling", visible: true, locked: false, ceilingOfId: "og" });
|
||||
type Prim = { kind: string; wallId?: string; ceilingId?: string; cls?: string; weightMm?: number; a?: { x: number; y: number }; b?: { x: number; y: number } };
|
||||
|
||||
it("gleicher Inhalt wie die Ebene, auch im Druck", async () => {
|
||||
for (const forPrint of [false, true]) {
|
||||
const vp = await viewportLevelPlan(q, "ds-og", codes, "mittel", 50, forPrint);
|
||||
const own = generatePlan(q, "ds-og", codes, undefined, "mittel", false, false, true, 50, forPrint);
|
||||
expect(vp.primitives.length).toBe(own.primitives.length);
|
||||
expect(vp.bounds).toEqual(own.bounds);
|
||||
const prims = vp.primitives as Prim[];
|
||||
expect(prims.some((x) => x.wallId)).toBe(true);
|
||||
expect(prims.some((x) => x.ceilingId || x.cls === "roof-eaves")).toBe(true);
|
||||
expect(prims.some((x) => x.cls === "door-swing" || x.cls === "door-leaf")).toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
it("Wand-Strichstärken wie im Grundriss (gleicher Massstab)", async () => {
|
||||
const ds = (await viewportLevelPlan(q, "ds-og", codes, "mittel", 50, true)).primitives as Prim[];
|
||||
const gr = (await viewportLevelPlan(q, "og", codes, "mittel", 50, true)).primitives as Prim[];
|
||||
const wallLine = (x: Prim) => x.kind === "line" && (x.cls === "wall-outline" || x.cls === "layer-joint");
|
||||
const key = (x: Prim) => `${x.cls}|${x.a?.x.toFixed(4)}|${x.a?.y.toFixed(4)}|${x.b?.x.toFixed(4)}|${x.b?.y.toFixed(4)}`;
|
||||
const widths = new Map(gr.filter(wallLine).map((x) => [key(x), x.weightMm]));
|
||||
const shared = ds.filter((x) => wallLine(x) && widths.has(key(x)));
|
||||
expect(shared.length).toBeGreaterThan(100);
|
||||
for (const x of shared) expect(x.weightMm, key(x)).toBe(widths.get(key(x)));
|
||||
});
|
||||
});
|
||||
@@ -1055,7 +1055,7 @@ export function createProjectSlice(
|
||||
// Rückmeldung, was hinzukam ([101]); ein Undo-Schritt.
|
||||
const ops = standardsMergeOps(get().project);
|
||||
const c = standardsMergeCounts(ops);
|
||||
const parts = (["components", "wallTypes", "ceilingTypes", "roofTypes", "hatches", "lineStyles", "viewTemplates"] as const)
|
||||
const parts = (["components", "wallTypes", "ceilingTypes", "roofTypes", "hatches", "lineStyles", "viewTemplates", "blockDefs"] as const)
|
||||
.filter((k) => c[k] > 0)
|
||||
.map((k) => t(`resources.loadStandards.n.${k}`, { n: c[k] }));
|
||||
if (ops.length) applyChange(ops);
|
||||
|
||||
Reference in new issue
Block a user