[110] Linientyp ohne Strichstärke: Stärke an Schraffur, Schichtfuge, Element; Migration Format 4

This commit is contained in:
Claude committed 2026-10-30 01:27:35 +00:00
1 parent ae52efae58
commit 765a93e562
27 files changed
+350 -153

No files matched your search

+11
View File
@@ -1504,6 +1504,17 @@ Reihenfolge = Abhängigkeiten. Neue Geometrie entsteht in Rust ([K]).
Offen: Verschieben/Griffe und Objekt-Info für Dach-Öffnungen (Info zeigt Wand-Felder), Fenster-/Türliste
(Geschoss aus der Wand), Löschen des Dachs löscht die Fenster nicht mit (Prüfung meldet den fehlenden Wirt),
Eindeckrahmen nur als flacher Ring, Lukarnen, nicht in der Tauri-App geprüft. · M
- ◐ **[110] Linientyp ohne Strichstärke.** (30.10., Wunsch Maintainer: „Volllinie 0.5/0.35 soll es nicht
geben") Ein Linienstil ist nur Muster (Volllinie, Strich, Punkt, Zickzack, Motiv) + Farbe; die Stärke trägt
das Element (`Drawing2D.weightMm`, sonst Ebene), die Schraffur (neu `HatchStyle.lineWeight`, Default 0.13),
die Schichtfuge (neu `Layer.jointWeightMm`) bzw. Override (`lineweight`). `LineStyle.weight` nur noch für
die Migration gelesen (Format 4, `migrate_line_weights`): Stärke an die Verwender, Stile, die sich nur in
der Stärke unterscheiden, zusammengeführt („Volllinie 0.02/0.13/0.25/0.5" → „Volllinie"). Musterhaus,
Standards (keine „Schraffurlinie 0.10" mehr; „Strichlinie", „Strichlinie lang", „Strichlinie kurz"),
PDF-Import (Strichlinien als 0.02-Element), Ressourcen-Manager (Linien ohne Stärke; Schraffur: Strichstärke;
Aufbau: Fugen-Strichstärke). Geprüft: Rust-/vitest-Tests; CLI-Szenen (Grundriss 1:50/1:100, Schnitte) und
DXF von Musterhaus und einem Format-3-Projekt mit allen Standards vor/nach der Migration bytegleich (Linux).
Offen: nicht in der Tauri-App geprüft. · S
## Priorität 4 — später
+1 -1
View File
@@ -819,7 +819,7 @@ mod tests {
assert_eq!(d.project().unwrap().walls.len(), 0);
assert_eq!(d.field("openings").unwrap()[0]["kind"], "door");
assert!(d.undo().is_none());
assert!(d.serialize().starts_with("{\n \"formatVersion\": 3,\n \"id\": \"q\""));
assert!(d.serialize().starts_with("{\n \"formatVersion\": 4,\n \"id\": \"q\""));
}
#[test]
+3 -1
View File
@@ -745,7 +745,7 @@ fn plan_dash_styles(dashes: &[(String, Vec<f64>)], existing: &[Value], name_temp
}
used.insert(id.clone());
let name = name_template.replace("{pattern}", &label);
created.push(json!({"id": id, "name": name, "weight": 0.02, "color": "#1a1a1a", "dash": dash.iter().map(|&d| js_num(d)).collect::<Vec<_>>()}));
created.push(json!({"id": id, "name": name, "color": "#1a1a1a", "dash": dash.iter().map(|&d| js_num(d)).collect::<Vec<_>>()}));
by_layer.insert(layer.clone(), id);
}
(created, by_layer)
@@ -897,6 +897,8 @@ pub fn import_ops(root: &Map<String, Value>, d: &DrawingImport, dec: &Decision,
o.insert("geom".into(), geom);
if let Some(s) = style_by_layer.get(&c.layer).filter(|s| !s.is_empty()) {
o.insert("lineStyleId".into(), s.clone().into());
// Strichlinien aus dem PDF als Haarlinie (die Stärke trägt das Element, nicht der Linienstil, [110]).
o.insert("weightMm".into(), json!(0.02));
}
if c.filled && is_polyline {
let fill = d.layer_fill_colors.get(&c.layer).and_then(Value::as_str).unwrap_or(DXF_HATCH_FILL);
+4 -4
View File
@@ -136,7 +136,7 @@ fn pdf_mit_strichmuster() {
let dec = decision(json!({"target": {"kind": "existing", "levelId": "eg"}, "categoryMode": "byLayer", "activeCategoryCode": "20", "dashStyleTemplate": "PDF-Strich {pattern}"}));
let r = import_ops(&project(), &d, &dec, 0.0);
let ops: Vec<Value> = r.ops.iter().map(Op::to_json).collect();
assert_eq!(ops[0]["items"][0], json!({"id": "pdf-dash-1_05_0_7", "name": "PDF-Strich 1.05/0.7", "weight": 0.02, "color": "#1a1a1a", "dash": [1.05, 0.7]}));
assert_eq!(ops[0]["items"][0], json!({"id": "pdf-dash-1_05_0_7", "name": "PDF-Strich 1.05/0.7", "color": "#1a1a1a", "dash": [1.05, 0.7]}));
assert_eq!(ops[1]["items"][0]["lineStyleId"], json!("pdf-dash-1_05_0_7"));
let info = pdf_page_info(&page);
assert_eq!(info["layers"], json!({"PDF 0.18 #ff0000 (Strich 1.05/0.7)": 1, "PDF Fläche #ffffff": 1}));
@@ -147,15 +147,15 @@ fn strichmuster_zu_linienstilen() {
assert!(same_dash(&[1.05, 0.7], &[1.0, 0.7]));
assert!(!same_dash(&[3.0, 1.0], &[1.0, 3.0]));
assert!(!same_dash(&[1.0, 1.0], &[1.0, 1.0, 1.0, 1.0]));
let solid = json!({"id": "thin", "name": "Volllinie", "weight": 0.13, "color": "#111", "dash": null});
let dashed = json!({"id": "d", "name": "Strich", "weight": 0.02, "color": "#111", "dash": [1, 0.7]});
let solid = json!({"id": "thin", "name": "Volllinie", "color": "#111", "dash": null});
let dashed = json!({"id": "d", "name": "Strich", "color": "#111", "dash": [1, 0.7]});
let dashes: Vec<(String, Vec<f64>)> =
vec![("a".into(), vec![1.05, 0.7]), ("b".into(), vec![2.8, 1.4]), ("c".into(), vec![2.8, 1.4]), ("d".into(), vec![0.05, 0.7, 2.8, 0.7])];
let (created, by_layer) = plan_dash_styles(&dashes, &[solid.clone(), dashed], "S {pattern}");
assert_eq!(by_layer["a"], "d");
assert_eq!(created.len(), 2);
assert_eq!(by_layer["b"], by_layer["c"]);
assert_eq!(created[0], json!({"id": "pdf-dash-2_8_1_4", "name": "S 2.8/1.4", "weight": 0.02, "color": "#1a1a1a", "dash": [2.8, 1.4]}));
assert_eq!(created[0], json!({"id": "pdf-dash-2_8_1_4", "name": "S 2.8/1.4", "color": "#1a1a1a", "dash": [2.8, 1.4]}));
assert_eq!(created[1]["dash"], json!([0.05, 0.7, 2.8, 0.7]));
// Gleiche id schon vergeben → Zähler.
let taken = json!({"id": "pdf-dash-2_8_1_4", "kind": "dot", "dash": [2.8, 1.4]});
+20 -13
View File
@@ -46,15 +46,14 @@ pub struct LineStyleMotif {
pub struct LineStyle {
pub id: String,
pub name: String,
/// @deprecated Die Strichstärke gehört NICHT mehr in den Linienstil — es gibt nur
/// „Vollinie/Strich", die tatsächliche Dicke wird per Element-Attribut (bzw.
/// Ebene/Default) aufgelöst. Das Feld bleibt für die Backward-Compat-Auflösung
/// erhalten und dient den Renderern noch als Fallback für die Muster-/Fugen-Stärke
/// (siehe `resolveHatch` → `HatchRender.lineWeight`). Der Linien-Detail-Editor
/// zeigt es nicht mehr an; neue Linienstile bekommen einen Haarlinien-Default.
/// Die echte per-Element-Strichstärken-Auflösung (Attribut → Ebene → Default)
/// folgt separat mit dem By-Layer/By-Object-Refactor — NICHT hier.
pub weight: f64,
/// @deprecated Nur noch für die Migration alter Dateien gelesen ([110], Format 4): Ein Linienstil
/// legt nur das Muster (Volllinie, Strich, Punkt, Zickzack …) und die Farbe fest — die Strichstärke
/// kommt vom Element (`Drawing2D.weightMm`), der Schraffur (`HatchStyle.lineWeight`), der
/// Schichtfuge (`Layer.jointWeightMm`) bzw. Ebene/Stift. Die Migration trägt das alte Gewicht dort
/// ein und entfernt es hier; die Renderer werten es nicht mehr aus.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub weight: Option<f64>,
/// Farbe (hex).
pub color: String,
/// Strichmuster in Millimetern, alternierend AN/AUS (`[on, off, on, off, …]`),
@@ -315,10 +314,14 @@ pub struct HatchStyle {
/// `plan/generatePlan.ts` → `resolveHatch`). Bei `pattern==="solid"` ist es die
/// Vollfüllfarbe, bei `pattern==="none"` ungenutzt.
pub color: String,
/// Optionaler Linienstil für die Musterlinien (Line Manager).
/// Optionaler Linienstil für die Musterlinien (Line Manager): nur Muster/Farbe.
#[serde(rename = "lineStyleId", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub line_style_id: Option<String>,
/// Strichstärke der Musterlinien in Papier-mm ([110]); fehlt sie, gilt 0.13.
#[serde(rename = "lineWeight", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub line_weight: Option<f64>,
/// Steuer-Parameter der Random-Vektor-Schraffur (`kind`/"vector" + `lines`===
/// "random", z. B. Kies/Splitt). ALLE additiv & optional — fehlen sie, gilt das
/// bestehende deterministische Streu-Verhalten (Seed aus der Flächen-Bounding-Box,
@@ -604,6 +607,10 @@ pub struct Layer {
#[serde(rename = "jointLineStyleId", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub joint_line_style_id: Option<String>,
/// Strichstärke der Schichtfuge in Papier-mm ([110]); fehlt sie, gilt die Standard-Fuge.
#[serde(rename = "jointWeightMm", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub joint_weight_mm: Option<f64>,
#[serde(flatten)]
#[ts(skip)]
pub extra: Extra,
@@ -3009,7 +3016,7 @@ pub struct Drawing2D {
#[ts(optional)]
pub fill_color: Option<String>,
/// Optionale direkte Strichstärke-Übersteuerung in Millimetern; hat Vorrang
/// vor dem LineStyle-Gewicht und der Kategorie-Strichstärke.
/// vor der Kategorie-Strichstärke (Linienstile tragen keine Stärke, [110]).
#[serde(rename = "weightMm", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub weight_mm: Option<f64>,
@@ -3025,8 +3032,8 @@ pub struct Drawing2D {
#[ts(optional)]
pub background_source: Option<AttributeSource>,
/// Quelle der Strichstärke, wenn kein explizites `weightMm` gesetzt ist:
/// "layer" erzwingt `LayerCategory.lw` (unter Umgehung des LineStyle-Gewichts),
/// "object"/`undefined` (Default) = heutige Kette (LineStyle.weight ?? Kategorie).
/// "layer" erzwingt `LayerCategory.lw`,
/// "object"/`undefined` (Default) = Kategorie-Strichstärke.
#[serde(rename = "strokeWeightSource", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub stroke_weight_source: Option<AttributeSource>,
+8 -8
View File
@@ -136,14 +136,14 @@ pub fn emit_slabs(p: &Project) -> Vec<RSlab> {
let l = &layers[layer_idx as usize];
let (color, cut) = match p.component(&l.component_id) {
Some(comp) => {
let line = resolve_cut_line_style(p, l.joint_line_style_id.as_deref());
let line = resolve_cut_line_style(p, l);
(
hex_to_rgb(&comp.color, style::WALL_RGB),
Some(RCutMeta {
join_priority: Some(comp.join_priority),
component_id: Some(comp.id.clone()),
line_color: line.map(|x| x.0),
line_weight: line.map(|x| x.1),
line_color: line.0,
line_weight: line.1,
}),
)
}
@@ -356,7 +356,7 @@ fn resolve_wall_bands(p: &Project, maps: &[String], wall: &Wall, layered: bool)
let mut bands = Vec::with_capacity(wt.layers.len());
for l in &wt.layers {
let Some(comp) = p.component(&l.component_id) else { return fallback() };
let line = resolve_cut_line_style(p, l.joint_line_style_id.as_deref());
let line = resolve_cut_line_style(p, l);
bands.push(WallBand {
thickness: l.thickness,
color: hex_to_rgb(&comp.color, WALL_RGB),
@@ -364,8 +364,8 @@ fn resolve_wall_bands(p: &Project, maps: &[String], wall: &Wall, layered: bool)
material_index: material_layer(p, maps, &l.component_id),
priority: Some(comp.join_priority),
component_id: Some(comp.id.clone()),
cut_line_color: line.map(|x| x.0),
cut_line_weight: line.map(|x| x.1),
cut_line_color: line.0,
cut_line_weight: line.1,
});
}
(bands, true)
@@ -1462,8 +1462,8 @@ pub fn emit_roof_cut_layers(p: &Project) -> Result<Vec<RRoofLayer>, String> {
continue;
}
let color = roof_color(p, override_color, &layer.component_id)?;
let line = resolve_cut_line_style(p, layer.joint_line_style_id.as_deref());
let cut = line.map(|(c, w)| RCutMeta { line_color: Some(c), line_weight: Some(w), ..Default::default() });
let line = resolve_cut_line_style(p, &layer);
let cut = (line.0.is_some() || line.1.is_some()).then(|| RCutMeta { line_color: line.0, line_weight: line.1, ..Default::default() });
for (i, plane) in g.planes.iter().enumerate() {
let nrm = plane_normal_up(plane);
let polygon: Vec<V3> = plane.iter().map(|q| [q[0] - nrm[0] * offset_above, q[1] - nrm[1] * offset_above, q[2] - nrm[2] * offset_above]).collect();
+1 -1
View File
@@ -575,7 +575,7 @@ fn emit_inner(c: &Ctx, d: &Drawing2D, attrs: Attrs, geom: &Drawing2DGeom, greyed
let ls_idx = attrs.line_style_id.filter(|s| !s.is_empty()).and_then(|id| p.line_styles.iter().position(|l| l.id == id));
let ls = ls_idx.map(|i| &p.line_styles[i]);
let color = attrs.color.or(ls.map(|l| l.color.as_str())).or(category.map(|k| k.color.as_str())).unwrap_or(MONO_INK);
let weight = resolve_stroke_weight(attrs.weight, d.stroke_weight_source, category, ls.map(|l| l.weight).or(category.map(|k| k.lw)).unwrap_or(WALL_FALLBACK_MM));
let weight = resolve_stroke_weight(attrs.weight, d.stroke_weight_source, category, category.map(|k| k.lw).unwrap_or(WALL_FALLBACK_MM));
let dash_scale = match d.dash_scale {
Some(s) if s > 0.0 => s,
_ => 1.0,
+1 -1
View File
@@ -101,7 +101,7 @@ pub fn resolve_hatch(p: &Project, hatch_id: &str, wall_angle_deg: Option<f64>, f
angle,
origin: p_origin,
color: foreground.unwrap_or(HATCH_INK).to_string(),
line_weight: ls.map_or(0.13, |l| l.weight),
line_weight: h.line_weight.unwrap_or(0.13),
dash: ls.and_then(|l| l.dash.clone()),
kind: h.kind,
lines: h.lines,
+1 -1
View File
@@ -221,7 +221,7 @@ fn wall_poche(c: &Ctx, out: &mut Vec<Primitive>, e: &EffWall, gaps: &[(f64, f64)
a,
b,
"layer-joint",
jls.map_or(layer_mm, |s| s.weight * detail.layer_factor()),
wt.layers.get(li).and_then(|l| l.joint_weight_mm).filter(|w| w.is_finite() && *w > 0.0).map_or(layer_mm, |w| w * detail.layer_factor()),
Some(jls.and_then(|s| s.dash.clone())),
Some(jls.map_or(stroke, |s| s.color.as_str())),
greyed,
+182 -3
View File
@@ -9,7 +9,7 @@
use serde_json::{Map, Value};
/// Aktuelle Version des Dateiformats. Bei jeder Formatänderung erhöhen + Migration anhängen.
pub const PROJECT_FORMAT_VERSION: u64 = 3;
pub const PROJECT_FORMAT_VERSION: u64 = 4;
const REQUIRED_ARRAYS: [&str; 3] = ["walls", "layers", "drawingLevels"];
const DEFAULT_ARRAYS: [&str; 5] = ["lineStyles", "hatches", "components", "wallTypes", "drawings2d"];
@@ -236,6 +236,128 @@ pub fn parse_project_file(text: &str, now_ms: f64) -> Parsed {
}
}
/// Name ohne angehängte Strichstärke („Volllinie 0.13" → „Volllinie", „Schraffurlinie 0.10 mm" →
/// „Schraffurlinie"); sonst unverändert.
fn strip_weight_suffix(name: &str) -> String {
let t = name.trim_end();
let t = t.strip_suffix("mm").map_or(t, str::trim_end);
let Some(pos) = t.rfind(' ') else { return name.to_string() };
let tail = &t[pos + 1..];
if !tail.is_empty() && tail.chars().all(|c| c.is_ascii_digit() || c == '.' || c == ',') && tail.chars().any(|c| c.is_ascii_digit()) {
t[..pos].trim_end().to_string()
} else {
name.to_string()
}
}
/// 3 → 4 ([110]): Linienstile tragen keine Strichstärke mehr. Das alte `LineStyle.weight` wandert an
/// die Verwender — Schraffur (`lineWeight`), Schichtfuge der Aufbauten (`jointWeightMm`), 2D-Element
/// (`weightMm`, nur wo es vorher galt: kein eigenes `weightMm`, Quelle nicht „layer") und Override-
/// Aktion (`lineweight`) —, damit Pläne gleich aussehen. Danach werden Stile, die sich nur in der
/// Stärke unterschieden, zu einem zusammengeführt (erster gewinnt, Name ohne Stärke-Anhang).
fn migrate_line_weights(mut raw: Map<String, Value>) -> Map<String, Value> {
let Some(Value::Array(styles)) = raw.get("lineStyles").cloned() else { return raw };
let mut weight: std::collections::HashMap<String, f64> = std::collections::HashMap::new();
// Gruppen gleicher Stile ohne id/Name/Stärke → kanonische id.
let mut canon: std::collections::HashMap<String, String> = std::collections::HashMap::new();
let mut by_key: Vec<(String, String)> = Vec::new();
let mut kept: Vec<Value> = Vec::new();
for st in styles {
let Value::Object(mut o) = st else {
kept.push(st);
continue;
};
let id = o.get("id").and_then(Value::as_str).unwrap_or("").to_string();
if let Some(w) = o.get("weight").and_then(Value::as_f64).filter(|w| w.is_finite()) {
weight.insert(id.clone(), w);
}
o.shift_remove("weight");
let mut key_obj = o.clone();
key_obj.shift_remove("id");
key_obj.shift_remove("name");
if key_obj.get("dash").is_some_and(Value::is_null) {
key_obj.shift_remove("dash");
}
let key = Value::Object(key_obj).to_string();
if let Some((_, first)) = by_key.iter().find(|(k, _)| *k == key) {
if !id.is_empty() {
canon.insert(id, first.clone());
}
continue;
}
if let Some(n) = o.get("name").and_then(Value::as_str) {
// Ohne Stärke-Anhang, solange der Name dadurch nicht doppelt wird.
let stripped = strip_weight_suffix(n);
if !kept.iter().any(|k| k.get("name").and_then(Value::as_str) == Some(stripped.as_str())) {
o.insert("name".into(), stripped.into());
}
}
by_key.push((key, id));
kept.push(Value::Object(o));
}
raw.insert("lineStyles".into(), Value::Array(kept));
let canon_of = |id: &str| canon.get(id).cloned().unwrap_or_else(|| id.to_string());
let weight_of = |v: Option<&Value>| v.and_then(Value::as_str).filter(|s| !s.is_empty()).and_then(|id| weight.get(id).copied());
let num = |w: f64| serde_json::Number::from_f64(w).map(Value::Number);
let redirect = |o: &mut Map<String, Value>, key: &str| {
if let Some(Value::String(id)) = o.get(key) {
let c = canon_of(id);
o.insert(key.into(), c.into());
}
};
// Schraffuren.
if let Some(Value::Array(hs)) = raw.get_mut("hatches") {
for h in hs.iter_mut().filter_map(Value::as_object_mut) {
if !h.contains_key("lineWeight") {
if let Some(w) = weight_of(h.get("lineStyleId")).and_then(num) {
h.insert("lineWeight".into(), w);
}
}
redirect(h, "lineStyleId");
}
}
// Schichtfugen der Aufbauten.
for key in ["wallTypes", "ceilingTypes", "roofTypes"] {
let Some(Value::Array(ts)) = raw.get_mut(key) else { continue };
for t in ts.iter_mut().filter_map(Value::as_object_mut) {
let Some(Value::Array(ls)) = t.get_mut("layers") else { continue };
for l in ls.iter_mut().filter_map(Value::as_object_mut) {
if !l.contains_key("jointWeightMm") {
if let Some(w) = weight_of(l.get("jointLineStyleId")).and_then(num) {
l.insert("jointWeightMm".into(), w);
}
}
redirect(l, "jointLineStyleId");
}
}
}
// 2D-Elemente.
if let Some(Value::Array(ds)) = raw.get_mut("drawings2d") {
for d in ds.iter_mut().filter_map(Value::as_object_mut) {
let layer_src = d.get("strokeWeightSource").and_then(Value::as_str) == Some("layer");
if !layer_src && !d.get("weightMm").is_some_and(Value::is_number) {
if let Some(w) = weight_of(d.get("lineStyleId")).and_then(num) {
d.insert("weightMm".into(), w);
}
}
redirect(d, "lineStyleId");
}
}
// Override-Regeln.
if let Some(Value::Array(rs)) = raw.get_mut("overrideRules") {
for r in rs.iter_mut().filter_map(Value::as_object_mut) {
let Some(Value::Object(a)) = r.get_mut("actions") else { continue };
if !a.get("lineweight").is_some_and(Value::is_number) {
if let Some(w) = weight_of(a.get("linetypeId")).and_then(num) {
a.insert("lineweight".into(), w);
}
}
redirect(a, "linetypeId");
}
}
raw
}
/// Wie [`parse_project_file`], für ein bereits geparstes Objekt.
pub fn parse_project_object(raw: Value, now_ms: f64) -> Parsed {
let Value::Object(mut obj) = raw else { return Parsed::Err("Die Datei enthält kein Dossier-Projekt.".into()) };
@@ -267,6 +389,7 @@ pub fn parse_project_object(raw: Value, now_ms: f64) -> Parsed {
obj = match i {
1 => migrate_doors(obj),
2 => migrate_layout_annotations(obj),
3 => migrate_line_weights(obj),
_ => obj, // 0 → 1: Einführung von `formatVersion`; Inhalt unverändert.
};
}
@@ -456,11 +579,67 @@ mod tests {
json!({"id":"p","name":"N","walls":[],"layers":[],"drawingLevels":[]})
}
/// [110]: Stärke wandert vom Linienstil an Schraffur, Fuge, Element und Override; Stile, die sich
/// nur in der Stärke unterscheiden, werden eins.
#[test]
fn linienstaerke_wandert_an_die_verwender() {
let v = json!({"formatVersion": 3, "id":"p","name":"N","walls":[],"layers":[],"drawingLevels":[],
"lineStyles": [
{"id":"hair","name":"Volllinie 0.02","weight":0.02,"color":"#1a1a1a","dash":null},
{"id":"thin","name":"Volllinie 0.13","weight":0.13,"color":"#1a1a1a","dash":null},
{"id":"thick","name":"Volllinie 0.5 mm","weight":0.5,"color":"#1a1a1a"},
{"id":"dash","name":"Strich","weight":0.02,"color":"#1a1a1a","dash":[1,0.7]},
{"id":"dark","name":"Volllinie 0.5","weight":0.5,"color":"#0a0a0a","dash":null}
],
"hatches": [
{"id":"h1","name":"A","pattern":"diagonal","scale":1,"angle":45,"color":"#000","lineStyleId":"hair"},
{"id":"h2","name":"B","pattern":"diagonal","scale":1,"angle":45,"color":"#000","lineStyleId":"thick","lineWeight":0.18},
{"id":"h3","name":"C","pattern":"diagonal","scale":1,"angle":45,"color":"#000"}
],
"wallTypes": [{"id":"w","name":"W","layers":[{"componentId":"c","thickness":0.1,"jointLineStyleId":"thin"},{"componentId":"c","thickness":0.1}]}],
"roofTypes": [{"id":"r","name":"R","layers":[{"componentId":"c","thickness":0.1,"jointLineStyleId":"dash"}]}],
"drawings2d": [
{"id":"d1","lineStyleId":"thick"},
{"id":"d2","lineStyleId":"thick","weightMm":0.7},
{"id":"d3","lineStyleId":"thick","strokeWeightSource":"layer"}
],
"overrideRules": [{"id":"o","actions":{"linetypeId":"thin"}}]
});
let Parsed::Ok { project: p, migrated_from, .. } = parse_project_object(v, 0.0) else { panic!() };
assert_eq!(migrated_from, Some(3));
assert_eq!(p["lineStyles"], json!([
{"id":"hair","name":"Volllinie","color":"#1a1a1a","dash":null},
{"id":"dash","name":"Strich","color":"#1a1a1a","dash":[1,0.7]},
{"id":"dark","name":"Volllinie 0.5","color":"#0a0a0a","dash":null}
]));
assert_eq!(p["hatches"][0]["lineWeight"], json!(0.02));
assert_eq!(p["hatches"][1]["lineWeight"], json!(0.18));
assert_eq!(p["hatches"][1]["lineStyleId"], json!("hair"));
assert!(p["hatches"][2].get("lineWeight").is_none());
let wl = &p["wallTypes"][0]["layers"];
assert_eq!((wl[0]["jointWeightMm"].clone(), wl[0]["jointLineStyleId"].clone()), (json!(0.13), json!("hair")));
assert!(wl[1].get("jointWeightMm").is_none());
assert_eq!(p["roofTypes"][0]["layers"][0]["jointWeightMm"], json!(0.02));
let d = &p["drawings2d"];
assert_eq!((d[0]["weightMm"].clone(), d[0]["lineStyleId"].clone()), (json!(0.5), json!("hair")));
assert_eq!(d[1]["weightMm"], json!(0.7));
assert!(d[2].get("weightMm").is_none());
assert_eq!(p["overrideRules"][0]["actions"], json!({"linetypeId":"hair","lineweight":0.13}));
}
#[test]
fn staerke_anhang_im_namen() {
assert_eq!(strip_weight_suffix("Volllinie 0.13"), "Volllinie");
assert_eq!(strip_weight_suffix("Schraffurlinie 0.10 mm"), "Schraffurlinie");
assert_eq!(strip_weight_suffix("Strichlinie fein"), "Strichlinie fein");
assert_eq!(strip_weight_suffix("PDF-Strich 1.05/0.7"), "PDF-Strich 1.05/0.7");
}
#[test]
fn alte_datei_wird_migriert_und_ergaenzt() {
let Parsed::Ok { project, warnings, migrated_from } = parse_project_object(minimal(), 0.0) else { panic!() };
assert_eq!(migrated_from, Some(0));
assert_eq!(project["formatVersion"], 3);
assert_eq!(project["formatVersion"], 4);
assert_eq!(project["lineStyles"], json!([]));
assert!(warnings.is_empty());
}
@@ -604,6 +783,6 @@ mod tests {
fn serialisierung_setzt_version_nach_vorn() {
let Value::Object(m) = minimal() else { panic!() };
let s = serialize_project(&m);
assert!(s.starts_with("{\n \"formatVersion\": 3,\n \"id\": \"p\""));
assert!(s.starts_with("{\n \"formatVersion\": 4,\n \"id\": \"p\""));
}
}
-1
View File
@@ -1145,7 +1145,6 @@ fn drawing_selection(root: &Map<String, Value>, d: &Value) -> J {
let cat_lw = cat.and_then(|c| nn(field(c, "lw")));
let weight = nn(field(d, "weightMm"))
.or_else(|| if str_of(field(d, "strokeWeightSource")) != Some("object") { cat_lw } else { None })
.or_else(|| ls.and_then(|l| nn(field(l, "weight"))))
.or(cat_lw)
.cloned()
.unwrap_or_else(|| js_num(WALL_FALLBACK_MM));
+26 -20
View File
@@ -34,22 +34,23 @@ fn material(id: &str, size_m: f64) -> Value {
const INK: &str = "#1a1a1a";
/// Linientypen (SIA 400 / ISO 128). Strichmuster in Papier-mm (AN/AUS, 0 = Punkt), unabhängig vom Massstab.
/// Linientypen (SIA 400 / ISO 128): nur Muster und Farbe — die Strichstärke kommt vom Element, der
/// Schraffur, der Schichtfuge bzw. Ebene/Stift ([110]). Strichmuster in Papier-mm (AN/AUS, 0 = Punkt),
/// unabhängig vom Massstab.
pub fn line_styles() -> Vec<Value> {
let dash = |id: &str, name: &str, w: f64, d: Value| json!({"id": id, "name": name, "weight": w, "color": INK, "dash": d});
let dash = |id: &str, name: &str, d: Value| json!({"id": id, "name": name, "color": INK, "dash": d});
vec![
dash("std-ls-voll", "Volllinie", 0.25, Value::Null),
dash("std-ls-strich-fein", "Strichlinie fein", 0.18, json!([3, 1.5])),
dash("std-ls-strich-grob", "Strichlinie grob", 0.5, json!([6, 2])),
dash("std-ls-punkt", "Punktlinie", 0.25, json!([0, 1])),
dash("std-ls-strichpunkt", "Strichpunktlinie (Achse)", 0.18, json!([12, 1.5, 0, 1.5])),
dash("std-ls-strichzweipunkt", "Strich-Zweipunktlinie", 0.18, json!([12, 1.5, 0, 1.5, 0, 1.5])),
dash("std-ls-grundstueck", "Grundstücksgrenze", 0.5, json!([8, 1.5, 0, 1.5, 0, 1.5])),
dash("std-ls-bauteilgrenze", "Baulinie / Bauteilgrenze", 0.35, json!([8, 1.5, 0, 1.5])),
json!({"id": "std-ls-bruch", "name": "Bruchlinie (Zickzack)", "weight": 0.18, "color": INK, "dash": null,
dash("std-ls-voll", "Volllinie", Value::Null),
dash("std-ls-strich-fein", "Strichlinie", json!([3, 1.5])),
dash("std-ls-strich-grob", "Strichlinie lang", json!([6, 2])),
dash("std-ls-punkt", "Punktlinie", json!([0, 1])),
dash("std-ls-strichpunkt", "Strichpunktlinie (Achse)", json!([12, 1.5, 0, 1.5])),
dash("std-ls-strichzweipunkt", "Strich-Zweipunktlinie", json!([12, 1.5, 0, 1.5, 0, 1.5])),
dash("std-ls-grundstueck", "Grundstücksgrenze", json!([8, 1.5, 0, 1.5, 0, 1.5])),
dash("std-ls-bauteilgrenze", "Baulinie / Bauteilgrenze", json!([8, 1.5, 0, 1.5])),
json!({"id": "std-ls-bruch", "name": "Bruchlinie (Zickzack)", "color": INK, "dash": null,
"kind": "zigzag", "zigzag": {"amplitude": 1.5, "wavelength": 4}}),
dash("std-ls-schraffur", "Schraffurlinie 0.10", 0.1, Value::Null),
dash("std-ls-schraffur-strich", "Schraffurlinie gestrichelt", 0.1, json!([1, 0.7])),
dash("std-ls-schraffur-strich", "Strichlinie kurz", json!([1, 0.7])),
]
}
@@ -61,14 +62,19 @@ pub fn hatches() -> Vec<Value> {
v["relativeToWall"] = json!(true);
}
if !ls.is_empty() {
v["lineStyleId"] = json!(ls);
v["lineWeight"] = json!(if ls == "std-ls-voll-025" { 0.25 } else { 0.1 });
if ls == "std-ls-voll-025" {
v["lineStyleId"] = json!("std-ls-voll");
} else if ls != "std-ls-schraffur" {
v["lineStyleId"] = json!(ls);
}
}
v
};
let solid = |id: &str, name: &str, color: &str| json!({"id": id, "name": name, "pattern": "solid", "scale": 1, "angle": 0, "color": color});
let random = |id: &str, name: &str, angle: f64, density: f64, lmin: f64, lmax: f64, seed: f64| {
json!({"id": id, "name": name, "kind": "vector", "lines": "random", "pattern": "diagonal", "scale": 1, "angle": angle,
"color": INK, "lineStyleId": "std-ls-schraffur", "density": density, "lengthMin": lmin, "lengthMax": lmax, "seed": seed})
"color": INK, "lineWeight": 0.1, "density": density, "lengthMin": lmin, "lengthMax": lmax, "seed": seed})
};
vec![
h("std-h-ohne", "SIA Ohne Schraffur", "none", 1.0, 0.0, false, ""),
@@ -88,7 +94,7 @@ pub fn hatches() -> Vec<Value> {
h("std-h-estrich", "SIA Estrich", "diagonal", 0.35, 45.0, false, "std-ls-schraffur-strich"),
solid("std-h-stahl", "SIA Stahl", INK),
solid("std-h-alu", "SIA Aluminium", "#8c8c8c"),
h("std-h-naturstein", "SIA Naturstein", "diagonal", 0.8, 45.0, false, "std-ls-voll"),
h("std-h-naturstein", "SIA Naturstein", "diagonal", 0.8, 45.0, false, "std-ls-voll-025"),
random("std-h-erdreich", "SIA Erdreich", 45.0, 0.8, 1.5, 4.0, 11.0),
random("std-h-kies", "SIA Kies / Sauberkeitsschicht", 60.0, 1.8, 0.4, 0.9, 13.0),
]
@@ -330,7 +336,7 @@ mod tests {
let tb = p.components.iter().find(|c| c.id == "std-c-trapezblech").unwrap().material.as_ref().unwrap();
assert!(tb.color.is_none() && tb.library_id.as_deref() == Some("CorrugatedSteel005"));
// Linientypen
for name in ["Volllinie", "Strichlinie fein", "Strichlinie grob", "Punktlinie", "Strichpunktlinie (Achse)", "Strich-Zweipunktlinie", "Grundstücksgrenze", "Bruchlinie (Zickzack)"] {
for name in ["Volllinie", "Strichlinie", "Strichlinie lang", "Punktlinie", "Strichpunktlinie (Achse)", "Strich-Zweipunktlinie", "Grundstücksgrenze", "Bruchlinie (Zickzack)"] {
assert!(p.line_styles.iter().any(|l| l.name == name), "{name}");
}
}
@@ -345,14 +351,14 @@ mod tests {
fn gleichnamige_bleiben_und_verweise_zeigen_darauf() {
let mut root = empty_root();
root.insert("components".into(), json!([{"id": "brick", "name": "backstein ", "color": "#8c5544", "hatchId": "x", "joinPriority": 50}]));
root.insert("lineStyles".into(), json!([{"id": "thin", "name": "Schraffurlinie 0.10", "weight": 0.1, "color": "#000", "dash": null}]));
root.insert("lineStyles".into(), json!([{"id": "thin", "name": "Strichlinie kurz", "color": "#000", "dash": [1, 0.7]}]));
let r = apply(&root, &merge_ops(&root));
let comps = r["components"].as_array().unwrap();
assert_eq!(comps.iter().filter(|c| c["name"].as_str().unwrap().trim().eq_ignore_ascii_case("backstein")).count(), 1);
assert_eq!(comps[0]["color"], "#8c5544", "vorhandenes Bauteil unverändert");
let iw = r["wallTypes"].as_array().unwrap().iter().find(|t| t["id"] == "std-wt-iw-backstein").unwrap();
assert_eq!(iw["layers"][1]["componentId"], "brick");
let bs = r["hatches"].as_array().unwrap().iter().find(|h| h["id"] == "std-h-backstein").unwrap();
assert_eq!(bs["lineStyleId"], "thin");
let pb = r["hatches"].as_array().unwrap().iter().find(|h| h["id"] == "std-h-porenbeton").unwrap();
assert_eq!(pb["lineStyleId"], "thin");
}
}
+7 -6
View File
@@ -58,13 +58,12 @@ pub struct HatchCore {
pub fn resolve_hatch_core(p: &Project, hatch_id: &str, wall_angle_deg: Option<f64>) -> Option<HatchCore> {
let h = p.hatch(hatch_id)?;
let ls = h.line_style_id.as_deref().filter(|s| !s.is_empty()).and_then(|id| p.line_style(id));
let base = h.angle;
let angle = match wall_angle_deg {
Some(w) if h.relative_to_wall == Some(true) => base - w,
_ => base,
};
Some(HatchCore { pattern: h.pattern, scale: h.scale * 1.0, angle, line_weight: ls.map_or(0.13, |l| l.weight) })
Some(HatchCore { pattern: h.pattern, scale: h.scale * 1.0, angle, line_weight: h.line_weight.unwrap_or(0.13) })
}
/// Schnitt-Schraffur eines Bauteils (`resolveComponentHatch`); `axis_angle_deg` 90 für Wand-Bänder,
@@ -113,8 +112,10 @@ pub fn dominant_layer_color(p: &Project, layers: &[crate::model::Layer], fallbac
}
}
/// Stil der Schnitt-Umrisslinie einer Schicht (`resolveCutLineStyle`).
pub fn resolve_cut_line_style(p: &Project, joint_line_style_id: Option<&str>) -> Option<(Rgb, f64)> {
let ls = p.line_styles.iter().find(|l| Some(l.id.as_str()) == joint_line_style_id.filter(|s| !s.is_empty()))?;
Some((hex_to_rgb(&ls.color, DRAWING_LINE_FALLBACK_RGB), ls.weight))
/// Stil der Schnitt-Umrisslinie einer Schicht (`resolveCutLineStyle`): Farbe aus dem Linienstil der
/// Fuge, Stärke aus der Schicht (`jointWeightMm`, [110]) — beide unabhängig optional.
pub fn resolve_cut_line_style(p: &Project, layer: &crate::model::Layer) -> (Option<Rgb>, Option<f64>) {
let id = layer.joint_line_style_id.as_deref().filter(|s| !s.is_empty());
let ls = id.and_then(|id| p.line_styles.iter().find(|l| l.id == id));
(ls.map(|ls| hex_to_rgb(&ls.color, DRAWING_LINE_FALLBACK_RGB)), layer.joint_weight_mm.filter(|w| w.is_finite() && *w > 0.0))
}
+14 -34
View File
@@ -2,38 +2,15 @@
"id": "demo",
"name": "Demo-Haus",
"lineStyles": [
{
"id": "hatch-hair",
"name": "Volllinie 0.02",
"weight": 0.02,
"color": "#1a1a1a",
"dash": null
},
{
"id": "thin",
"name": "Volllinie 0.13",
"weight": 0.13,
"name": "Volllinie",
"color": "#1a1a1a",
"dash": null
},
{
"id": "medium",
"name": "Volllinie 0.25",
"weight": 0.25,
"color": "#1a1a1a",
"dash": null
},
{
"id": "thick",
"name": "Volllinie 0.5",
"weight": 0.5,
"color": "#0a0a0a",
"dash": null
},
{
"id": "hatch-dash",
"name": "Dämmungsstrich",
"weight": 0.02,
"color": "#1a1a1a",
"dash": [
0.35,
@@ -57,7 +34,7 @@
"scale": 1,
"angle": 0,
"color": "#1a1a1a",
"lineStyleId": "thin"
"lineWeight": 0.13
},
{
"id": "diagonal",
@@ -66,7 +43,7 @@
"scale": 1,
"angle": 45,
"color": "#1a1a1a",
"lineStyleId": "thin"
"lineWeight": 0.13
},
{
"id": "crosshatch",
@@ -75,7 +52,7 @@
"scale": 1,
"angle": 0,
"color": "#1a1a1a",
"lineStyleId": "thin"
"lineWeight": 0.13
},
{
"id": "solid-concrete",
@@ -84,7 +61,7 @@
"scale": 1,
"angle": 0,
"color": "#9aa0a6",
"lineStyleId": "thin"
"lineWeight": 0.13
},
{
"id": "sia-concrete",
@@ -93,7 +70,7 @@
"scale": 0.5,
"angle": 45,
"color": "#1a1a1a",
"lineStyleId": "hatch-hair"
"lineWeight": 0.02
},
{
"id": "sia-brick",
@@ -103,7 +80,7 @@
"angle": 45,
"relativeToWall": true,
"color": "#1a1a1a",
"lineStyleId": "hatch-hair"
"lineWeight": 0.02
},
{
"id": "sia-insulation",
@@ -113,7 +90,7 @@
"angle": 0,
"relativeToWall": true,
"color": "#1a1a1a",
"lineStyleId": "hatch-hair"
"lineWeight": 0.02
}
],
"components": [
@@ -222,7 +199,8 @@
{
"componentId": "insulation",
"thickness": 0.16,
"jointLineStyleId": "thin"
"jointLineStyleId": "thin",
"jointWeightMm": 0.13
},
{
"componentId": "brick",
@@ -265,7 +243,8 @@
{
"componentId": "insulation",
"thickness": 0.04,
"jointLineStyleId": "thin"
"jointLineStyleId": "thin",
"jointWeightMm": 0.13
},
{
"componentId": "concrete",
@@ -286,7 +265,8 @@
{
"componentId": "insulation",
"thickness": 0.22,
"jointLineStyleId": "thin"
"jointLineStyleId": "thin",
"jointWeightMm": 0.13
},
{
"componentId": "render-int",
+4 -1
View File
@@ -1121,6 +1121,9 @@ export const de = {
"resources.col.component": "Bauteil",
"resources.col.thickness": "Dicke (mm)",
"resources.col.joint": "Fuge",
"resources.col.jointWeight": "Fugen-Strichstärke (mm, 0 = Standard)",
"resources.col.hatchLineWeight": "Strichstärke (mm)",
"resources.col.hatchLineWeight.hint": "Stärke der Musterlinien auf dem Papier; der Linienstil legt nur das Muster fest.",
"resources.joint.default": "— (Haarlinie)",
"resources.layer.add": "Schicht hinzufügen",
"resources.layer.remove": "Schicht entfernen",
@@ -1320,7 +1323,7 @@ export const de = {
"pattern.custom": "Eigenes Motiv",
// Linien.
"resources.lines.hint": "Strichstärke in Millimetern (Paper-Space). Strichmuster: durchgezogen, gestrichelt oder gepunktet.",
"resources.lines.hint": "Linientyp = Muster (durchgezogen, gestrichelt, gepunktet, Zickzack …) und Farbe. Die Strichstärke legt das Element, die Schraffur, die Schichtfuge oder die Ebene fest.",
"resources.lines.empty": "Noch keine Linienstile.",
"resources.lines.placeholder": "Linienstil",
"resources.col.weight": "Stärke (mm)",
+4 -1
View File
@@ -1115,6 +1115,9 @@ export const en: Record<TranslationKey, string> = {
"resources.col.component": "Component",
"resources.col.thickness": "Thickness (mm)",
"resources.col.joint": "Joint",
"resources.col.jointWeight": "Joint line weight (mm, 0 = default)",
"resources.col.hatchLineWeight": "Line weight (mm)",
"resources.col.hatchLineWeight.hint": "Weight of the pattern lines on paper; the line style only sets the pattern.",
"resources.joint.default": "— (hairline)",
"resources.layer.add": "Add layer",
"resources.layer.remove": "Remove layer",
@@ -1310,7 +1313,7 @@ export const en: Record<TranslationKey, string> = {
"pattern.crosshatch": "Crosshatch",
"pattern.custom": "Custom motif",
"resources.lines.hint": "Line weight in millimetres (paper space). Stroke: solid, dashed or dotted.",
"resources.lines.hint": "Line type = pattern (solid, dashed, dotted, zigzag …) and colour. The line weight is set by the element, the hatch, the layer joint or the layer.",
"resources.lines.empty": "No line styles yet.",
"resources.lines.placeholder": "Line style",
"resources.col.weight": "Weight (mm)",
+1 -1
View File
@@ -21,7 +21,7 @@ import { documentFor, sharedDocument } from "../core/document";
import type { LoadFileResult } from "../core/document";
/** Aktuelle Version des Dateiformats (muss `PROJECT_FORMAT_VERSION` im Kern entsprechen — Test). */
export const PROJECT_FORMAT_VERSION = 3;
export const PROJECT_FORMAT_VERSION = 4;
export type ParseProjectResult = LoadFileResult;
+1 -1
View File
@@ -52,7 +52,7 @@ export function richProject(): Project {
const lvl = sampleProject.drawingLevels[0].id;
return {
...sampleProject,
formatVersion: 3,
formatVersion: 4,
// Blatt-Ebene des Layouts „lay1" (2D-Zeichnung auf dem Blatt).
drawingLevels: [...sampleProject.drawingLevels, { id: "sheet-lay1", name: "Blatt 1", kind: "drawing", visible: true, locked: false, layoutId: "lay1" }],
textStyles: [{ id: "ts1", label: "Titel", marks: { bold: true, font: "Helvetica", sizePt: 14 } }],
+16 -21
View File
@@ -26,18 +26,13 @@ export const sampleProject: Project = {
id: "demo",
name: "Demo-Haus",
// ── Ressourcen-Bibliotheken (zentral verwiesen per id) ──────────────────
// Linienstile: aufgeräumt auf kanonische VOLLLINIEN je Strichstärke (dash=null)
// + eine gestrichelte Linie. Früher gab es drei funktional identische 0.13-
// Volllinien ("thin"/"hatch-line"/"joint-massive") — zusammengeführt auf "thin"
// ("Volllinie 0.13"); Schraffur-/Schichtfugen-Referenzen zeigen jetzt darauf.
// (Die ids bleiben stabil, damit geladene Projekte + interne Referenzen halten.)
// Linienstile: nur Muster + Farbe ([110]) — die Strichstärke tragen Schraffur (`lineWeight`),
// Schichtfuge (`jointWeightMm`) bzw. Element/Ebene. Früher gab es „Volllinie 0.02/0.13/0.25/0.5";
// zusammengeführt auf „thin" (Volllinie). Die ids bleiben stabil.
lineStyles: [
{ id: "hatch-hair", name: "Volllinie 0.02", weight: 0.02, color: "#1a1a1a", dash: null },
{ id: "thin", name: "Volllinie 0.13", weight: 0.13, color: "#1a1a1a", dash: null },
{ id: "medium", name: "Volllinie 0.25", weight: 0.25, color: "#1a1a1a", dash: null },
{ id: "thick", name: "Volllinie 0.5", weight: 0.5, color: "#0a0a0a", dash: null },
// Gestrichelte Haarlinie für die Dämmung (Striche quer durch die Wanddicke).
{ id: "hatch-dash", name: "Dämmungsstrich", weight: 0.02, color: "#1a1a1a", dash: [0.35, 0.3] },
{ id: "thin", name: "Volllinie", color: "#1a1a1a", dash: null },
// Gestrichelte Linie (z. B. Dämmung, Striche quer durch die Wanddicke).
{ id: "hatch-dash", name: "Dämmungsstrich", color: "#1a1a1a", dash: [0.35, 0.3] },
],
// Schraffuren: color = Linien-/Vollfüllfarbe des Musters; angle in Grad.
// "none" = keine Schraffur (nur Component-Füllung).
@@ -52,7 +47,7 @@ export const sampleProject: Project = {
scale: 1,
angle: 0,
color: "#1a1a1a",
lineStyleId: "thin",
lineWeight: 0.13,
},
{
id: "diagonal",
@@ -61,7 +56,7 @@ export const sampleProject: Project = {
scale: 1,
angle: 45,
color: "#1a1a1a",
lineStyleId: "thin",
lineWeight: 0.13,
},
{
id: "crosshatch",
@@ -70,7 +65,7 @@ export const sampleProject: Project = {
scale: 1,
angle: 0,
color: "#1a1a1a",
lineStyleId: "thin",
lineWeight: 0.13,
},
{
id: "solid-concrete",
@@ -79,7 +74,7 @@ export const sampleProject: Project = {
scale: 1,
angle: 0,
color: "#9aa0a6",
lineStyleId: "thin",
lineWeight: 0.13,
},
// ── SIA-Schnittschraffuren (Haarlinie) ──────────────────────────────────
// Dichte Teilung (scale < 1; Muster-Kachel = 8·scale) für den SIA-Look.
@@ -91,7 +86,7 @@ export const sampleProject: Project = {
scale: 0.5,
angle: 45,
color: "#1a1a1a",
lineStyleId: "hatch-hair",
lineWeight: 0.02,
},
// Backstein: Diagonale, 45° RELATIV zur Wandachse (dreht mit der Wand mit).
{
@@ -102,7 +97,7 @@ export const sampleProject: Project = {
angle: 45,
relativeToWall: true,
color: "#1a1a1a",
lineStyleId: "hatch-hair",
lineWeight: 0.02,
},
// Dämmung: DURCHGEZOGENE (nicht gestrichelte) Linien QUER durch die Wanddicke
// (senkrecht zur Wandachse), wandbezogen. Basiswinkel 0 = Musterlinie steht
@@ -115,7 +110,7 @@ export const sampleProject: Project = {
angle: 0,
relativeToWall: true,
color: "#1a1a1a",
lineStyleId: "hatch-hair",
lineWeight: 0.02,
},
],
// Bauteil-Materialien: color = Poché-Füllung im Grundriss UND 3D-Diffusfarbe;
@@ -182,7 +177,7 @@ export const sampleProject: Project = {
layers: [
{ componentId: "render-ext", thickness: 0.02 },
// Innere Fuge der Dämmung trifft auf den Backstein (massiv↔massiv) → 0.13 mm.
{ componentId: "insulation", thickness: 0.16, jointLineStyleId: "thin" },
{ componentId: "insulation", thickness: 0.16, jointLineStyleId: "thin", jointWeightMm: 0.13 },
{ componentId: "brick", thickness: 0.15 },
{ componentId: "render-int", thickness: 0.015 },
],
@@ -209,7 +204,7 @@ export const sampleProject: Project = {
// Estrich (schwimmend) → Trittschalldämmung.
{ componentId: "screed", thickness: 0.06 },
// Innere Fuge der Dämmung trifft auf die Betondecke (massiv) → 0.13 mm.
{ componentId: "insulation", thickness: 0.04, jointLineStyleId: "thin" },
{ componentId: "insulation", thickness: 0.04, jointLineStyleId: "thin", jointWeightMm: 0.13 },
// Betondecke (Rohdecke, tragend) — innerste/unterste Schicht.
{ componentId: "concrete", thickness: 0.2 },
],
@@ -222,7 +217,7 @@ export const sampleProject: Project = {
// Aussen (Eindeckung) → innen (Verkleidung); Bauteile aus der Bibliothek.
layers: [
{ componentId: "roof-tiles", thickness: 0.04 }, // Eindeckung (Tonziegel)
{ componentId: "insulation", thickness: 0.22, jointLineStyleId: "thin" }, // Sparren/Dämmung
{ componentId: "insulation", thickness: 0.22, jointLineStyleId: "thin", jointWeightMm: 0.13 }, // Sparren/Dämmung
{ componentId: "render-int", thickness: 0.0125 }, // Innenverkleidung (GK)
],
},
+14 -13
View File
@@ -693,7 +693,7 @@ export type Drawing2D = {
fillColor?: string;
/**
* Optionale direkte Strichstärke-Übersteuerung in Millimetern; hat Vorrang
* vor dem LineStyle-Gewicht und der Kategorie-Strichstärke.
* vor der Kategorie-Strichstärke (Linienstile tragen keine Stärke, [110]).
*/
weightMm?: number;
/**
@@ -707,8 +707,8 @@ export type Drawing2D = {
backgroundSource?: AttributeSource;
/**
* Quelle der Strichstärke, wenn kein explizites `weightMm` gesetzt ist:
* "layer" erzwingt `LayerCategory.lw` (unter Umgehung des LineStyle-Gewichts),
* "object"/`undefined` (Default) = heutige Kette (LineStyle.weight ?? Kategorie).
* "layer" erzwingt `LayerCategory.lw`,
* "object"/`undefined` (Default) = Kategorie-Strichstärke.
*/
strokeWeightSource?: AttributeSource;
/**
@@ -1185,8 +1185,10 @@ export type HatchStyle = {
* Vollfüllfarbe, bei `pattern==="none"` ungenutzt.
*/
color: string;
/** Optionaler Linienstil für die Musterlinien (Line Manager). */
/** Optionaler Linienstil für die Musterlinien (Line Manager): nur Muster/Farbe. */
lineStyleId?: string;
/** Strichstärke der Musterlinien in Papier-mm ([110]); fehlt sie, gilt 0.13. */
lineWeight?: number;
/**
* Steuer-Parameter der Random-Vektor-Schraffur (`kind`/"vector" + `lines`===
* "random", z. B. Kies/Splitt). ALLE additiv & optional — fehlen sie, gilt das
@@ -1261,6 +1263,8 @@ export type Layer = {
* Fehlt das Feld, wird die Standard-Haarlinie (0.02 mm) gezeichnet.
*/
jointLineStyleId?: string;
/** Strichstärke der Schichtfuge in Papier-mm ([110]); fehlt sie, gilt die Standard-Fuge. */
jointWeightMm?: number;
};
/**
@@ -1401,16 +1405,13 @@ export type LineStyle = {
id: string;
name: string;
/**
* @deprecated Die Strichstärke gehört NICHT mehr in den Linienstil — es gibt nur
* „Vollinie/Strich", die tatsächliche Dicke wird per Element-Attribut (bzw.
* Ebene/Default) aufgelöst. Das Feld bleibt für die Backward-Compat-Auflösung
* erhalten und dient den Renderern noch als Fallback für die Muster-/Fugen-Stärke
* (siehe `resolveHatch` → `HatchRender.lineWeight`). Der Linien-Detail-Editor
* zeigt es nicht mehr an; neue Linienstile bekommen einen Haarlinien-Default.
* Die echte per-Element-Strichstärken-Auflösung (Attribut → Ebene → Default)
* folgt separat mit dem By-Layer/By-Object-Refactor — NICHT hier.
* @deprecated Nur noch für die Migration alter Dateien gelesen ([110], Format 4): Ein Linienstil
* legt nur das Muster (Volllinie, Strich, Punkt, Zickzack …) und die Farbe fest — die Strichstärke
* kommt vom Element (`Drawing2D.weightMm`), der Schraffur (`HatchStyle.lineWeight`), der
* Schichtfuge (`Layer.jointWeightMm`) bzw. Ebene/Stift. Die Migration trägt das alte Gewicht dort
* ein und entfernt es hier; die Renderer werten es nicht mehr aus.
*/
weight: number;
weight?: number;
/** Farbe (hex). */
color: string;
/**
+5 -5
View File
@@ -12,7 +12,7 @@ import { selectionHighlightLines, projectToWalls3d, projectToModel3d, pickGeomet
import { hexToRgb } from "./toWalls3d/shared";
import type { ToolDraft } from "../tools/types";
import { generatePlan } from "./generatePlan";
import { getHatch, getLineStyle } from "../model/types";
import { getHatch } from "../model/types";
import { roofGeometry, roofBaseElevation } from "../geometry/roof";
const RGB: [number, number, number] = [1, 0.5, 0.1];
@@ -1805,7 +1805,7 @@ describe("Schnitt-Schraffur-Orientierung: relativeToWall dreht bei Wand, nicht b
const h = getHatch(p, id);
return {
angle: h.relativeToWall && wallAngleDeg != null ? h.angle - wallAngleDeg : h.angle,
lineWeight: (h.lineStyleId ? getLineStyle(p, h.lineStyleId) : null)?.weight ?? 0.13,
lineWeight: h.lineWeight ?? 0.13,
};
};
// 2D-Referenz (verbindlich): splitWallLayers ruft resolveHatch(…, 90, …) (Wand
@@ -1844,9 +1844,9 @@ describe("Schnitt-Schraffur-Orientierung: relativeToWall dreht bei Wand, nicht b
expect(brick.hatch?.angle).toBeCloseTo(resolveHatch(sampleProject, "sia-brick", 90).angle, 6);
});
it("Musterlinien-Stärke kommt aus dem LineStyle des Hatch durch (2D-Parität)", () => {
// sia-insulation nutzt lineStyleId "hatch-hair" (0.02 mm). Der 3D-Hatch muss die
// resolveHatch-lineWeight (aus dem LineStyle) tragen — für Wand UND Decke gleich.
it("Musterlinien-Stärke kommt aus der Schraffur durch (2D-Parität)", () => {
// sia-insulation trägt lineWeight 0.02 mm ([110]). Der 3D-Hatch muss die
// resolveHatch-lineWeight (aus der Schraffur) tragen — für Wand UND Decke gleich.
const expected = resolveHatch(sampleProject, "sia-insulation", 90).lineWeight;
expect(wallInsul().hatch?.lineWeight).toBeCloseTo(expected, 6);
expect(slabInsul().hatch?.lineWeight).toBeCloseTo(expected, 6);
-1
View File
@@ -894,7 +894,6 @@ export function createProjectSlice(
const lineStyle: LineStyle = {
id: `line-${Date.now()}`,
name: t("default.lineStyleName"),
weight: 0.18,
color: "#2b3039",
dash: null,
};
+3 -3
View File
@@ -52,7 +52,7 @@ describe("Projekt laden ([K4] S4)", () => {
st().undo();
expect(st().project).toBe(next);
// Kern-Dokument = Leseansicht (Speichern aus dem Kern).
expect(JSON.parse(serializeProject(st().project))).toEqual({ ...next, formatVersion: 3 });
expect(JSON.parse(serializeProject(st().project))).toEqual({ ...next, formatVersion: 4 });
});
it("openProjectFile: Kern liest, migriert und lädt direkt; Verlauf leer; kaputte Datei ändert nichts", () => {
@@ -70,7 +70,7 @@ describe("Projekt laden ([K4] S4)", () => {
expect(r.ok && r.migratedFrom).toBe(1);
expect(st().undoDepth).toBe(0);
expect(st().redoDepth).toBe(0);
expect(st().project.formatVersion).toBe(3);
expect(st().project.formatVersion).toBe(4);
expect(st().project.openings?.some((o) => o.id === "TX" && o.kind === "door")).toBe(true);
expect("doors" in st().project).toBe(false);
// Danach normal weiterarbeiten: ein Schritt, Undo zurück auf den geladenen Stand.
@@ -78,6 +78,6 @@ describe("Projekt laden ([K4] S4)", () => {
st().setProject(opsMutation((p) => patchItem(p, "walls", p.walls[0].id, { height: 7 })));
st().undo();
expect(st().project).toEqual(loaded);
expect(serializeProject(st().project)).toBe(JSON.stringify({ formatVersion: 3, ...loaded }, null, 2));
expect(serializeProject(st().project)).toBe(JSON.stringify({ formatVersion: 4, ...loaded }, null, 2));
});
});
+2 -1
View File
@@ -471,7 +471,8 @@ export function LineSwatch({
width?: number;
height?: number;
}) {
const px = Math.max(1, Math.min(6, style.weight * 6));
// Linienstile tragen keine Stärke mehr ([110]): Vorschau mit einheitlicher Linie.
const px = 1.5;
const midY = height / 2;
const x0 = 4;
const x1 = width - 4;
+10 -2
View File
@@ -212,6 +212,14 @@ function HatchDetail({
options={lineOptions}
/>
</FieldRow>
<FieldRow label={t("resources.col.hatchLineWeight")} hint={t("resources.col.hatchLineWeight.hint")}>
<NumberField
value={hatch.lineWeight ?? 0.13}
onChange={(w) => onPatch({ lineWeight: Math.max(0.01, w) })}
step={0.01}
min={0.01}
/>
</FieldRow>
{lines === "random" && (
<>
<FieldRow label={t("resources.field.density")}>
@@ -327,8 +335,8 @@ function patToHatches(text: string): Omit<HatchStyle, "id">[] {
scale: 1,
angle: p.families[0]?.angle ?? 45,
color: "#1a1a1a",
// Kanonische Volllinie 0.13 (früher "hatch-line", zusammengeführt auf "thin").
lineStyleId: "thin",
// Volllinie (Muster); die Stärke trägt die Schraffur ([110]).
lineWeight: 0.13,
}));
}
@@ -166,6 +166,16 @@ function LayeredStyleDetail({
/>
)}
</FieldRow>
{!isInner && (
<FieldRow label={t("resources.col.jointWeight")}>
<NumberField
value={layer.jointWeightMm ?? 0}
onChange={(w) => patchLayer(i, { jointWeightMm: w > 0 ? w : undefined })}
step={0.01}
min={0}
/>
</FieldRow>
)}
</div>
<DeleteButton
onClick={() => removeLayer(i)}
+1 -9
View File
@@ -4,7 +4,6 @@
import { useState } from "react";
import type { LineStyle, Project } from "../../model/types";
import { PEN_WEIGHTS } from "../../model/types";
import { parseLin } from "../../io/linParser";
import { LineSwatch } from "../hatchPreview";
import { segmentsToDash, dashToSegments, presetOfDash, LINE_PRESETS, type LineSegment, type LineSegmentType, type LinePresetKey } from "../../core";
@@ -249,11 +248,10 @@ function LineStyleDetail({
);
}
/** .lin-Text → id-lose Linienstile (schwarze Haarlinie 0.18 als Default). */
/** .lin-Text → id-lose Linienstile (nur Muster; die Stärke trägt das Element, [110]). */
function linToStyles(text: string): Omit<LineStyle, "id">[] {
return parseLin(text).map((p) => ({
name: p.name,
weight: 0.18,
color: "#1a1a1a",
dash: p.dash,
}));
@@ -278,12 +276,6 @@ export function LinesTab({
return (
<div className="res-tab">
{/* Vorschlagswerte für die Strichstärke (Standard-Stiftbreiten in mm). */}
<datalist id="pen-weights">
{PEN_WEIGHTS.map((w) => (
<option key={w} value={w} />
))}
</datalist>
<div className="res-hint">{t("resources.lines.hint")}</div>
<div className="res-md">
<div className="res-md-list">