Merge branch 'worktree-agent-a733d7bc917c3ae8e' into claude/practical-noether-1hb2s1

This commit is contained in:
Claude committed 2026-11-06 10:24:25 +00:00
commit 6d41a84511
14 files changed
+178 -49

No files matched your search

+31 -17
View File
@@ -73,26 +73,32 @@ pub fn free_color_palette() -> Vec<String> {
out
}
/// 255 Stifte + Stile der Standardpalette (`generateStandardPenPalette`): `(pens, styles)`.
/// [140] Strichstärken-Rangfolge der Plandarstellung bei 1:100 (mm): Schnittkante Wände 0.25, Decken/Öffnungen
/// 0.18, Symbole/Ansicht 0.13, Schraffur/Bemassung 0.1, Haarlinie 0.02.
pub const PEN_WEIGHT_STEPS: [f64; 5] = [0.25, 0.18, 0.13, 0.1, 0.02];
/// 255 Stifte + Stile der Standardpalette (`generateStandardPenPalette`): `(pens, styles)`. Strichstärken nach
/// [`PEN_WEIGHT_STEPS`]: je Farbton die dunkelste Stufe am stärksten (wie die Plan-Rangfolge), Schwarz 0.25.
pub fn standard_pen_palette() -> (Vec<Value>, Map<String, Value>) {
let mut pens = Vec::with_capacity(255);
let mut styles = Map::new();
let mut add = |id: u32, name: String, color: String| {
let mut add = |id: u32, name: String, color: String, weight: f64| {
pens.push(json!({"id": id.to_string(), "name": name}));
styles.insert(id.to_string(), json!({"color": color, "weight": PEN_FALLBACK_WEIGHT}));
styles.insert(id.to_string(), json!({"color": color, "weight": weight}));
};
for (id, name, color) in [
(1, "Rot", "#ff0000"),
(2, "Gelb", "#ffff00"),
(3, "Grün", "#00ff00"),
(4, "Cyan", "#00ffff"),
(5, "Blau", "#0000ff"),
(6, "Magenta", "#ff00ff"),
(7, "Schwarz", "#000000"),
(8, "Dunkelgrau", "#414141"),
(9, "Grau", "#808080"),
let [w25, w18, w13, w10, w02] = PEN_WEIGHT_STEPS;
for (id, name, color, w) in [
(1, "Rot", "#ff0000", w18),
(2, "Gelb", "#ffff00", w18),
(3, "Grün", "#00ff00", w18),
(4, "Cyan", "#00ffff", w18),
(5, "Blau", "#0000ff", w18),
(6, "Magenta", "#ff00ff", w18),
(7, "Schwarz", "#000000", w25),
(8, "Dunkelgrau", "#414141", w13),
(9, "Grau", "#808080", w10),
] {
add(id, name.to_string(), color.to_string());
add(id, name.to_string(), color.to_string(), w);
}
let mut id = 10;
for hue in 0..24 {
@@ -102,12 +108,13 @@ pub fn standard_pen_palette() -> (Vec<Value>, Map<String, Value>) {
let level = (step % 5) as f64;
let l = 0.75 - level * 0.14;
let s = if saturated { 0.85 } else { 0.4 };
add(id, format!("Stift {id}"), hsl_to_hex(h, s, l));
// Stufe 0 (hell) … 4 (dunkel): dunkler = stärker.
add(id, format!("Stift {id}"), hsl_to_hex(h, s, l), PEN_WEIGHT_STEPS[4 - (step % 5)]);
id += 1;
}
}
for (gid, color) in [(250, "#333333"), (251, "#5b5b5b"), (252, "#848484"), (253, "#adadad"), (254, "#d6d6d6"), (255, "#ffffff")] {
add(gid, format!("Grau {gid}"), color.to_string());
for (gid, color, w) in [(250, "#333333", w25), (251, "#5b5b5b", w18), (252, "#848484", w13), (253, "#adadad", w10), (254, "#d6d6d6", w02), (255, "#ffffff", w18)] {
add(gid, format!("Grau {gid}"), color.to_string(), w);
}
(pens, styles)
}
@@ -342,6 +349,13 @@ mod tests {
assert_eq!(styles.len(), 255);
assert_eq!(styles["7"]["color"], "#000000");
assert_eq!(pens[9]["name"], "Stift 10");
// [140] Stärken nach der Plan-Rangfolge, alle fünf Stufen vertreten.
assert_eq!(styles["7"]["weight"], 0.25);
assert_eq!((styles["10"]["weight"].as_f64(), styles["14"]["weight"].as_f64()), (Some(0.02), Some(0.25)));
for w in PEN_WEIGHT_STEPS {
assert!(styles.values().filter(|s| s["weight"].as_f64() == Some(w)).count() >= 10, "{w}");
}
assert!(styles.values().all(|s| PEN_WEIGHT_STEPS.contains(&s["weight"].as_f64().unwrap())));
}
#[test]
+42 -1
View File
@@ -2286,6 +2286,30 @@ fn ring_bbox(r: &[[f64; 2]]) -> [f64; 4] {
r.iter().fold([f64::INFINITY, f64::INFINITY, f64::NEG_INFINITY, f64::NEG_INFINITY], |b, q| [b[0].min(q[0]), b[1].min(q[1]), b[2].max(q[0]), b[3].max(q[1])])
}
/// [140] Dämmschichten (Dämmschlange, Zickzack, Welle) unter [`THIN_INSULATION_PAPER_MM`] Papierdicke ab 1:75
/// ohne Muster (nur Füllung und feine Fuge): die Schlange einer 3–4 cm Trittschalldämmung wäre in 1:100 ein
/// dichter Zickzack-Balken. 1:50 (und `scale` 0) zeichnet sie immer.
pub fn plain_thin_insulation(mut cuts: Vec<Cut>, scale: f64) -> Vec<Cut> {
if !(scale >= THIN_MERGE_FROM) || !scale.is_finite() {
return cuts;
}
for c in &mut cuts {
let Some(h) = c.hatch.as_mut() else { continue };
if !matches!(h.pattern, HatchPattern::Insulation | HatchPattern::InsulationHard | HatchPattern::InsulationWave) || h.kind.is_some() {
continue;
}
let half = ring_len(&c.pts) / 2.0;
let thick = if half > 0.0 { ring_area(&c.pts) / half } else { 0.0 };
if thick * 1000.0 / scale < THIN_INSULATION_PAPER_MM {
h.pattern = HatchPattern::None;
}
}
cuts
}
/// [140] Papierdicke (mm), unter der Dämmschichten ab 1:75 ohne Muster gezeichnet werden.
pub const THIN_INSULATION_PAPER_MM: f64 = 0.5;
/// [140] Dünne Schnitt-Schichten (Putz, Parkett, Trittschall, Folien) bei 1:`scale` zusammenfassen: eine Schicht
/// unter [`walls::THIN_LAYER_PAPER_MM`] Papierdicke (Dicke ≈ Fläche / halber Umfang) übernimmt Füllung und
/// Schraffur der dickeren Nachbarschicht desselben Bauteils, mit der sie die längste Kante teilt, und wird mit
@@ -2377,7 +2401,7 @@ pub fn section_primitives(out: &Output, mono: bool, hidden_lines: bool, vis: &Vi
/// [`section_primitives`] beim Massstab 1:`scale` (dünne Schichten zusammengefasst, [`merge_thin_cuts`]).
pub fn section_primitives_at(out: &Output, mono: bool, hidden_lines: bool, vis: &Visibility, scale: f64) -> (Vec<Primitive>, [f64; 4]) {
let merged = merge_thin_cuts(&out.cuts, scale);
let merged = plain_thin_insulation(merge_thin_cuts(&out.cuts, scale), scale);
let mut prims = Vec::new();
let mut acc = Acc::new();
let shown = |code: &str| vis.visible(code) && vis.render(code);
@@ -3137,6 +3161,23 @@ mod tests {
assert!(merge_thin_cuts(&other, 100.0).iter().any(|c| c.fill.as_deref() == Some("#a")));
}
/// [140] Trittschall 4 cm: 1:100 (0.4 mm Papier) ohne Zickzack, 1:50 mit; dicke Dämmung bleibt.
#[test]
fn duenne_daemmung_ohne_muster_ab_1_100() {
let rect = |v0: f64, v1: f64| vec![[0.0, v1], [5.0, v1], [5.0, v0], [0.0, v0]];
let mk = |v0: f64, v1: f64, pattern: HatchPattern| {
let mut c = Cut::new(Kind::Slab, 0, rect(v0, v1));
c.hatch = Some(HatchRender { pattern, ..section_hatch() });
c
};
let cuts = vec![mk(0.0, 0.04, HatchPattern::Insulation), mk(0.1, 0.26, HatchPattern::Insulation), mk(0.3, 0.33, HatchPattern::InsulationHard), mk(0.4, 0.43, HatchPattern::Diagonal)];
let pat = |cs: &[Cut]| cs.iter().map(|c| c.hatch.as_ref().unwrap().pattern).collect::<Vec<_>>();
use HatchPattern as P;
assert_eq!(pat(&plain_thin_insulation(cuts.clone(), 50.0)), [P::Insulation, P::Insulation, P::InsulationHard, P::Diagonal], "1:50 alle Muster");
assert_eq!(pat(&plain_thin_insulation(cuts.clone(), 100.0)), [P::None, P::Insulation, P::None, P::Diagonal], "1:100");
assert_eq!(pat(&plain_thin_insulation(cuts, 0.0)), [P::Insulation, P::Insulation, P::InsulationHard, P::Diagonal]);
}
#[test]
fn beispiel_schnitt_mit_pick_ids() {
let p = sample();
+32 -7
View File
@@ -62,8 +62,16 @@ fn detail_of(d: DetailLevel) -> Detail {
}
}
/// [140] Tusche (Schwarz-Weiss) im Viewport: Standard wie in der App; Farbe nur, wenn die Ansichtsvorlage
/// des Ausschnitts ausdrücklich `mono: false` setzt (z. B. „Präsentation" farbig gewählt).
pub fn snapshot_mono(p: &Project, snap: &ViewSnapshot) -> bool {
let Some(id) = snap.template_id.as_deref() else { return true };
let t = p.view_templates.iter().flatten().find(|t| t.id == id);
t.and_then(|t| t.mono) != Some(false)
}
/// Plan-Argumente eines Viewports (wie `ViewportPlanSvg`: projektglobal, nicht für den Druck).
pub fn viewport_args(snap: &ViewSnapshot, scale: f64) -> PlanArgs {
pub fn viewport_args(snap: &ViewSnapshot, scale: f64, mono: bool) -> PlanArgs {
let (detail, auto_coarse) = crate::plan::domains::effective_detail(detail_of(snap.detail), scale);
PlanArgs {
floor: snap.active_level_id.clone(),
@@ -75,7 +83,7 @@ pub fn viewport_args(snap: &ViewSnapshot, scale: f64) -> PlanArgs {
scale,
for_print: false,
compact: false,
mono: false,
mono,
sun_when: None,
auto_coarse,
}
@@ -126,7 +134,7 @@ pub fn snapshot_buf(p: &Project, snap: &ViewSnapshot, scale: f64, shadows: Optio
Some(s) => section_view_buf(p, &DrawingLevel { shadows: Some(s), ..l.clone() }, snap, scale),
None => section_view_buf(p, l, snap, scale),
},
_ => plan_domains_buf(p, &viewport_args(snap, scale)).ok(),
_ => plan_domains_buf(p, &viewport_args(snap, scale, snapshot_mono(p, snap))).ok(),
}
}
@@ -159,7 +167,8 @@ fn candidate_codes(p: &Project) -> HashSet<String> {
/// TS) fehlen im Schnitt — der Kern hat sie hier nicht.
fn section_view_buf(p: &Project, level: &DrawingLevel, snap: &ViewSnapshot, scale: f64) -> Option<Vec<u8>> {
use crate::plan::prim::Primitive;
let args = viewport_args(snap, scale);
let mono = snapshot_mono(p, snap);
let args = viewport_args(snap, scale, mono);
let invisible: Vec<String> = candidate_codes(p).into_iter().filter(|c| !args.show.contains(c)).collect();
let text = serde_json::json!({
"level": serde_json::to_value(level).ok()?,
@@ -170,9 +179,9 @@ fn section_view_buf(p: &Project, level: &DrawingLevel, snap: &ViewSnapshot, scal
})
.to_string();
let raw = if level.kind == DrawingLevelKind::Section {
crate::plan::section::section_plan_buf(p, &[0.0, 1.0, 0.0], &text)
crate::plan::section::section_plan_buf(p, &[f64::from(u8::from(mono)), 1.0, 0.0], &text)
} else {
crate::plan::elevation::elevation_plan_buf(p, &[0.0, if level.shadows.unwrap_or(false) { 1.0 } else { 0.0 }, scale], &text)
crate::plan::elevation::elevation_plan_buf(p, &[f64::from(u8::from(mono)), if level.shadows.unwrap_or(false) { 1.0 } else { 0.0 }, scale], &text)
}
.ok()?;
let rv = crate::plan::buf::View::parse(&raw)?;
@@ -385,6 +394,22 @@ pub(crate) mod tests {
assert!((x - 95.0).abs() < 1e-9 && (y - 70.0).abs() < 1e-9);
}
/// [140] Viewports zeichnen in Tusche wie die App; Farbe nur über die Vorlage (`mono: false`).
#[test]
fn viewport_tusche_ausser_vorlage_farbig() {
let mut v = json();
v["viewTemplates"] = serde_json::json!([{"id": "farbig", "name": "F", "mono": false}, {"id": "tusche", "name": "T", "mono": true}, {"id": "offen", "name": "O"}]);
let mut p: Project = serde_json::from_value(v).unwrap();
let mut snap = p.view_snapshots.as_ref().unwrap()[0].clone();
assert!(snapshot_mono(&p, &snap), "ohne Vorlage: Tusche");
for (id, mono) in [("farbig", false), ("tusche", true), ("offen", true), ("fehlt", true)] {
snap.template_id = Some(id.into());
assert_eq!(snapshot_mono(&p, &snap), mono, "{id}");
}
p.view_templates = None;
assert!(snapshot_mono(&p, &snap));
}
/// [100] Deckenspiegel-Viewport: derselbe Inhalt wie die Deckenspiegel-Ebene (Wände, Untersicht).
#[test]
fn deckenspiegel_viewport() {
@@ -400,7 +425,7 @@ pub(crate) mod tests {
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();
let direct = crate::plan::domains::plan_domains(&p, &viewport_args(snap, 50.0, snapshot_mono(&p, snap))).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:?}");
+3 -2
View File
@@ -268,11 +268,12 @@ pub fn roof_types() -> Vec<Value> {
/// Alle Standard-Ressourcen je Projekt-Liste, in Abhängigkeitsreihenfolge.
/// [66] Ansichtsvorlagen für Pläne „mit einem Klick" (an Geschoss/Schnitt/Ansicht binden oder anwenden):
/// Präsentation (farbig, Schatten, ohne Referenz- und Konstruktionslinien), Eingabe 1:100 und Ausführung 1:50
/// Präsentation (Tusche wie alle Pläne [140], Farbe über `mono: false` wählbar; Schatten, ohne Referenz- und
/// Konstruktionslinien), Eingabe 1:100 und Ausführung 1:50
/// (schwarz-weiss nach SIA 400).
pub fn view_templates() -> Vec<Value> {
vec![
json!({"id": "std-vt-praesentation", "name": "Präsentation", "detail": "mittel", "mono": false, "shadows": true, "hiddenLines": false,
json!({"id": "std-vt-praesentation", "name": "Präsentation", "detail": "mittel", "mono": true, "shadows": true, "hiddenLines": false,
"layerVisibility": {"90": false, "99": false}}),
json!({"id": "std-vt-eingabe-100", "name": "Eingabeplan 1:100", "detail": "mittel", "scaleDenominator": 100, "mono": true, "shadows": false,
"layerVisibility": {"99": false}}),