[109][101] Merge: neue SIA-Muster auch im 3D-Live-Schnitt und SVG (Schraffur-Crate hatchgen), „Standards aktualisieren", Putz/Keramik/Faserzement
Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
39 files changed
+1022
-78
No files matched your search
@@ -1624,10 +1624,24 @@ Reihenfolge = Abhängigkeiten. Neue Geometrie entsteht in Rust ([K]).
|
||||
Musterlinien 0.10/0.13 mm). Schnitt: Dachschichten-Muster folgen der Dachneigung, Deckenschichten liegen
|
||||
(Achse 0°, vorher 90°), einschalige Wände wie Schicht-Bänder (vorher Grundriss-Winkel). DXF: Kurven-Muster
|
||||
als Polylinien; Ressourcen-Vorschau zeichnet Vektor-Schraffuren mit dem Kern-Generator. Geprüft: Rust-
|
||||
Tests, CLI-Grundriss 1:50/1:100 und Schnitte (Wand, Decke, Dach) aller Standard-Baustoffe angesehen
|
||||
(Linux). Offen: 3D-Live-Schnitt (render3d) zeigt neue Muster vereinfacht (Zickzack/Kreuz/Diagonal);
|
||||
Projekte mit Standards vom 29.10. behalten die alten Schraffur-Definitionen (Standards laden ergänzt nur);
|
||||
Alt-Pfade `planToPrintSvg`/SVG-PlanView zeichnen neue Muster als Diagonale; nicht in der Tauri-App geprüft. · M
|
||||
Tests, CLI-Grundriss 1:50/1:100 und Schnitte (Wand, Decke, Dach) aller Standard-Baustoffe angesehen (Linux).
|
||||
Nachtrag 30.10. (Offene Punkte erledigt): Schraffur-Generator (`hatch.rs`, `jsnum`, `jsmath`) in eigenem Crate
|
||||
`src-tauri/hatchgen` (`dossier-hatch`; Kern re-exportiert unter `crate::hatch` …, im `exclude` des Workspace,
|
||||
Teil von `npm run check`). render3d-Live-Schnitt zeichnet Schicht-/Streumuster (Muster-Ids ab 4 = Generator-Codes)
|
||||
mit demselben Generator als Ribbons in den Schnittlinien (`section_fill::push_generated_hatch`), der Cap-Shader
|
||||
füllt dort Papier (Zickzack-Zweig entfernt). Druck-SVG (`plan_print_svg.rs`) und SVG-PlanView-Rückfall
|
||||
(`isGeneratedPattern`, `buildHatchRuns`) nutzen den Generator, die `<pattern>`-Kachel „insulation" entfällt.
|
||||
Neues Muster `dots` (Punktfeld, Schichtmuster, Teilung 5 cm · scale) für Putz innen/aussen (`std-h-putz`),
|
||||
Keramik (`std-h-keramik`, Kreuzraster 45°), Faserzement (`std-h-faserzement`, Diagonale 135°). Keine
|
||||
Massstabsgrenze für Schraffuren: Putz ist auch in 1:100 ein feiner Grauton; leer = „SIA Ohne Schraffur" wählen.
|
||||
„Standards aktualisieren" ([101]) im Ressourcen-Manager-Kopf: Overlay (kein window.confirm) listet je Eintrag
|
||||
mit Standard-id die abweichenden Felder; Regel: nur vom Standard geführte Felder (Name/Zusatzfelder bleiben),
|
||||
Selbstanpassung ist nicht erkennbar (alte Fassungen nicht gespeichert) → umbenannte Einträge abgewählt, alle
|
||||
anderen vorgewählt, „Alle überschreiben"/„Keine"; fehlende Standards werden mit ergänzt; ein Undo-Schritt
|
||||
(`standards.rs::update_plan/update_ops`, Abfragen `standardsUpdatePlan/-Ops`). Geprüft: Rust-/vitest-Tests,
|
||||
Druck-SVG-Schnitte 1:50 aller Standard-Baustoffe angesehen (Linux). Offen: render3d-Ribbons nicht visuell
|
||||
geprüft (Metal nur macOS, WebGPU nicht im Browser); Ribbon-Breite konstant in der Welt wie die Trennlinien;
|
||||
SVG-PlanView-Rückfall ohne Strichmuster der Musterlinien; nicht in der Tauri-App geprüft. · M
|
||||
- ◐ **[105] Fenster/Türen: Rahmen-Detail, Anschlag je Seite, Türzargen-Arten.** (29.10., Wunsch Maintainer „so tief wie
|
||||
ArchiCAD“) Neue optionale Modellfelder (nur Rust-Modell): `frameDetail` am Fenster-/Türtyp und feldweise an der Öffnung
|
||||
(`Opening.frameDetail`): Blendrahmen-Breite je Seite, Tiefe/Lage, Flügelrahmen (Breite, Tiefe, Überschlag), Pfosten/
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
|
||||
const fast = process.argv.includes("--fast");
|
||||
const crates = ["core", "render2d", "render3d", "kernel2d", "trucksolid", "fileio"];
|
||||
const crates = ["core", "render2d", "render3d", "kernel2d", "trucksolid", "fileio", "hatchgen"];
|
||||
const steps = [
|
||||
{ name: "tsc", cmd: "npx", args: ["tsc", "--noEmit", "-p", "."] },
|
||||
{ name: "vitest", cmd: "npx", args: ["vitest", "run"] },
|
||||
|
||||
Generated
+8
@@ -1107,6 +1107,13 @@ dependencies = [
|
||||
"tendril",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dossier-hatch"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "downcast-rs"
|
||||
version = "1.2.1"
|
||||
@@ -4013,6 +4020,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"console_error_panic_hook",
|
||||
"dossier-hatch",
|
||||
"env_logger",
|
||||
"js-sys",
|
||||
"naga",
|
||||
|
||||
@@ -7,7 +7,7 @@ members = ["."]
|
||||
# nutzen kann. kernel2d: analog — eigenstaendiger 2D-Geometrie-Kern, als
|
||||
# Pfad-Abhaengigkeit von dossier-core (src-tauri/core) eingebunden, ausserhalb
|
||||
# des cad-tauri-Workspace.
|
||||
exclude = ["render2d", "render3d", "kernel2d", "dwgimport", "trucksolid"]
|
||||
exclude = ["render2d", "render3d", "kernel2d", "dwgimport", "trucksolid", "hatchgen"]
|
||||
|
||||
[package]
|
||||
name = "cad-tauri"
|
||||
|
||||
Generated
+9
@@ -29,6 +29,7 @@ name = "dossier-core"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"console_error_panic_hook",
|
||||
"dossier-hatch",
|
||||
"i_overlay",
|
||||
"kernel2d",
|
||||
"render3d",
|
||||
@@ -39,6 +40,13 @@ dependencies = [
|
||||
"zmij",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dossier-hatch"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.3"
|
||||
@@ -162,6 +170,7 @@ dependencies = [
|
||||
name = "render3d"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dossier-hatch",
|
||||
"serde",
|
||||
]
|
||||
|
||||
|
||||
@@ -15,13 +15,15 @@ crate-type = ["cdylib", "rlib"]
|
||||
[features]
|
||||
default = []
|
||||
# Browser-/Node-Bindings (wasm-bindgen); nur fuer wasm32-unknown-unknown.
|
||||
web = ["dep:wasm-bindgen", "dep:console_error_panic_hook"]
|
||||
web = ["dep:wasm-bindgen", "dep:console_error_panic_hook", "dossier-hatch/web"]
|
||||
|
||||
[dependencies]
|
||||
i_overlay = { version = "9.1", default-features = false }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = { version = "1", features = ["preserve_order", "float_roundtrip"] }
|
||||
kernel2d = { path = "../kernel2d" }
|
||||
# Schraffur-Generator + JS-Zahlsemantik (auch von render3d genutzt), s. hatchgen/src/lib.rs.
|
||||
dossier-hatch = { path = "../hatchgen" }
|
||||
# Analytischer Schnitt-Extraktor (`section::cut_section`, GPU-frei, nur serde) für Schnitt/Ansicht im Kern ([K3c]).
|
||||
render3d = { path = "../render3d", default-features = false }
|
||||
# Kürzeste Dezimaldarstellung wie serde_json (Zahlen, die früher über JSON reisten, bitgleich nachbilden).
|
||||
|
||||
@@ -30,7 +30,7 @@ pub mod room_area;
|
||||
pub mod room_boundary;
|
||||
pub mod polygon_holes;
|
||||
pub mod js_fmt;
|
||||
pub mod jsmath;
|
||||
pub use dossier_hatch::jsmath;
|
||||
pub mod stairs3d;
|
||||
pub mod mesh3d;
|
||||
pub mod ceilings3d;
|
||||
@@ -38,8 +38,8 @@ pub mod columns3d;
|
||||
pub mod drawing2d_3d;
|
||||
pub mod openings3d;
|
||||
pub mod wall_mesh_cut;
|
||||
pub mod jsnum;
|
||||
pub mod hatch;
|
||||
pub use dossier_hatch::jsnum;
|
||||
pub use dossier_hatch::hatch;
|
||||
pub mod hatch_flat;
|
||||
pub mod plan;
|
||||
pub mod plan_buf;
|
||||
|
||||
@@ -250,6 +250,9 @@ pub enum HatchPattern {
|
||||
/// Naturstein ([109]): Diagonale in Doppellinien.
|
||||
#[serde(rename = "stone")]
|
||||
Stone,
|
||||
/// Punktfeld ([109], Putz): feine Punkte im versetzten Raster.
|
||||
#[serde(rename = "dots")]
|
||||
Dots,
|
||||
#[serde(other)]
|
||||
#[ts(skip)]
|
||||
Unknown,
|
||||
|
||||
@@ -2051,6 +2051,7 @@ fn write_hatch_words(out: &mut Vec<f64>, h: &HatchRender, color: f64) {
|
||||
HatchPattern::Earth => 9.0,
|
||||
HatchPattern::Gravel => 10.0,
|
||||
HatchPattern::Stone => 11.0,
|
||||
HatchPattern::Dots => 12.0,
|
||||
_ => 2.0,
|
||||
};
|
||||
let kind = match h.kind {
|
||||
|
||||
@@ -527,7 +527,7 @@ fn dash_seg(a: V2, b: V2, cycle: &[f64]) -> Vec<(V2, V2)> {
|
||||
fn is_curve_pattern(p: Pattern) -> bool {
|
||||
matches!(
|
||||
p,
|
||||
Pattern::Insulation | Pattern::InsulationHard | Pattern::InsulationWave | Pattern::Timber | Pattern::Earth | Pattern::Gravel | Pattern::Stone
|
||||
Pattern::Insulation | Pattern::InsulationHard | Pattern::InsulationWave | Pattern::Timber | Pattern::Earth | Pattern::Gravel | Pattern::Stone | Pattern::Dots
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -245,10 +245,18 @@ fn fill_parallel(poly: &[V2], angle: f64, spacing: f64, out: &mut Vec<(V2, V2)>)
|
||||
}
|
||||
}
|
||||
|
||||
/// Muster, die der Kern-Generator als Linien/Polylinien erzeugt (Schichtmuster, Streu-/Punktmuster, Doppellinien).
|
||||
fn is_generated(p: Pattern) -> bool {
|
||||
matches!(
|
||||
p,
|
||||
Pattern::Insulation | Pattern::InsulationHard | Pattern::InsulationWave | Pattern::Timber | Pattern::Earth | Pattern::Gravel | Pattern::Stone | Pattern::Dots
|
||||
)
|
||||
}
|
||||
|
||||
/// Schraffurlinien in Papier-mm (`hatchLines`).
|
||||
fn hatch_lines(poly_mm: &[V2], h: &Hatch, mm_per_m: f64) -> Vec<(V2, V2)> {
|
||||
let unit_mm = (1.0 / 90.0) * mm_per_m;
|
||||
let tile_mm = (if h.pattern == Pattern::Insulation { 10.0 } else { 8.0 }) * h.scale * unit_mm;
|
||||
let tile_mm = 8.0 * h.scale * unit_mm;
|
||||
let spacing = jsnum::max(0.5, tile_mm);
|
||||
let angle = (h.angle * PI) / 180.0;
|
||||
let mut segs = Vec::new();
|
||||
@@ -256,9 +264,6 @@ fn hatch_lines(poly_mm: &[V2], h: &Hatch, mm_per_m: f64) -> Vec<(V2, V2)> {
|
||||
if h.pattern == Pattern::Crosshatch {
|
||||
fill_parallel(poly_mm, angle + PI / 2.0, spacing, &mut segs);
|
||||
}
|
||||
if h.pattern == Pattern::Insulation {
|
||||
fill_parallel(poly_mm, angle - PI / 4.0, spacing, &mut segs);
|
||||
}
|
||||
segs
|
||||
}
|
||||
|
||||
@@ -351,6 +356,16 @@ fn entry(out: &mut Out, view: &View, i: usize, hatches: &[(i32, Hatch, i32)], m:
|
||||
let (a, b) = (run[0], run[run.len() - 1]);
|
||||
out.el(1, "line", &line_attrs(m.at(a.x, a.y), m.at(b.x, b.y), &hatch_color, pen, Some(&hdash)));
|
||||
}
|
||||
} else if is_generated(h.pattern) {
|
||||
// Schicht-/Streumuster ([109]): dieselben Linien wie Szene und Chunk-Pfad (Kern-Generator).
|
||||
for run in hatch::build_hatch_runs(&pts, &h) {
|
||||
let p: Vec<V2> = run.iter().map(|q| m.at(q.x, q.y)).collect();
|
||||
match p.len() {
|
||||
0 | 1 => {}
|
||||
2 => out.el(1, "line", &line_attrs(p[0], p[1], &hatch_color, pen, Some(&hdash))),
|
||||
_ => out.el(1, "polyline", &polyline_attrs(&p, &hatch_color, pen, Some(&hdash))),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Strichmuster der Schraffur (null und [] gleich: keins).
|
||||
for (a, b) in hatch_lines(&pts_mm, &h, k) {
|
||||
|
||||
@@ -85,6 +85,12 @@ pub fn run_root(lk: &crate::document::Lookup, name: &str, text: &str) -> Result<
|
||||
"penDeleteOps" => json(&crate::pens::delete_pen_ops(root, text)),
|
||||
// Standard-Bibliothek ([100]–[102], `standards.rs`): fehlende Standard-Ressourcen als Ops.
|
||||
"standardsMergeOps" => json(&crate::standards::merge_ops(root)),
|
||||
// „Standards aktualisieren" ([109]): Abweichungen vom heutigen Standard / Ops für die gewählten (`text` = JSON-Liste `"<Liste>:<id>"`).
|
||||
"standardsUpdatePlan" => json(&crate::standards::update_plan(root)),
|
||||
"standardsUpdateOps" => {
|
||||
let sel: Vec<String> = serde_json::from_str(text).map_err(|e| format!("standardsUpdateOps: {e}"))?;
|
||||
json(&crate::standards::update_ops(root, &sel))
|
||||
}
|
||||
"penSeedOps" => {
|
||||
let a: serde_json::Value = serde_json::from_str(text).map_err(|e| format!("penSeedOps: {e}"))?;
|
||||
json(&crate::pens::seed_standard_ops(root, a["id"].as_str().unwrap_or(""), a["name"].as_str().unwrap_or("")))
|
||||
|
||||
@@ -104,6 +104,14 @@ pub fn hatches() -> Vec<Value> {
|
||||
// Holzfaser: Welle über die Dicke.
|
||||
layer("std-h-holzfaser", "SIA Dämmung Holzfaser", "insulationWave", 1.0),
|
||||
solid("std-h-gips", "SIA Gips", "#cfcfcf"),
|
||||
// Putz (innen/aussen): feines, ruhiges Punktfeld entlang der Schicht (Teilung 2 cm). Eine Schraffur
|
||||
// ohne Massstabsgrenze: in 1:100 und gröber wird sie ein feiner Grauton, wer Putz dort leer will,
|
||||
// wählt „SIA Ohne Schraffur".
|
||||
json!({"id": "std-h-putz", "name": "SIA Putz", "pattern": "dots", "scale": 0.4, "angle": 0, "relativeToWall": true, "color": INK, "lineWeight": 0.1}),
|
||||
// Keramik (Fliesen, Platten): feines Kreuzraster 45°.
|
||||
lines("std-h-keramik", "SIA Keramik", "crosshatch", 0.015, 45.0, false, 0.1, ""),
|
||||
// Faserzement: dichte Diagonale 135° (Plattenwerkstoff, gegenläufig zu Backstein/Beton).
|
||||
lines("std-h-faserzement", "SIA Faserzement", "diagonal", 0.02, 135.0, false, 0.1, ""),
|
||||
// Estrich/Überzug: feines Punktfeld (punktierte Diagonale).
|
||||
lines("std-h-estrich", "SIA Estrich", "diagonal", 0.025, 45.0, false, 0.1, "std-ls-schraffur-punkt"),
|
||||
solid("std-h-stahl", "SIA Stahl", INK),
|
||||
@@ -166,12 +174,12 @@ pub fn components() -> Vec<Value> {
|
||||
Mat { id: "std-c-holzfaser", name: "Holzfaser", abbrev: "HF", fill: "#ffffff", elev: "#b08a5a", hatch: "std-h-holzfaser", lambda: Some(0.04), density: Some(140.0), rf: "RF3", tex: None, prio: 24.0, pattern: None },
|
||||
Mat { id: "std-c-trittschall", name: "Trittschalldämmung", abbrev: "TSD", fill: "#ffffff", elev: "#efe6a8", hatch: "std-h-daemmung-weich", lambda: Some(0.035), density: Some(100.0), rf: "RF1", tex: None, prio: 19.0, pattern: None },
|
||||
Mat { id: "std-c-gipskarton", name: "Gipskarton", abbrev: "GK", fill: "#cfcfcf", elev: "#f4f4f2", hatch: "std-h-gips", lambda: Some(0.25), density: Some(800.0), rf: "RF1", tex: Some(("Plaster001", 1.0)), prio: 12.0, pattern: None },
|
||||
Mat { id: "std-c-innenputz", name: "Innenputz", abbrev: "IP", fill: "#ffffff", elev: "#f5f3ee", hatch: "std-h-ohne", lambda: Some(0.7), density: Some(1400.0), rf: "RF1", tex: Some(("Plaster001", 1.0)), prio: 10.0, pattern: None },
|
||||
Mat { id: "std-c-aussenputz", name: "Aussenputz", abbrev: "AP", fill: "#ffffff", elev: "#e9e3d6", hatch: "std-h-ohne", lambda: Some(0.87), density: Some(1800.0), rf: "RF1", tex: Some(("Plaster001", 1.0)), prio: 10.0, pattern: None },
|
||||
Mat { id: "std-c-innenputz", name: "Innenputz", abbrev: "IP", fill: "#ffffff", elev: "#f5f3ee", hatch: "std-h-putz", lambda: Some(0.7), density: Some(1400.0), rf: "RF1", tex: Some(("Plaster001", 1.0)), prio: 10.0, pattern: None },
|
||||
Mat { id: "std-c-aussenputz", name: "Aussenputz", abbrev: "AP", fill: "#ffffff", elev: "#e9e3d6", hatch: "std-h-putz", lambda: Some(0.87), density: Some(1800.0), rf: "RF1", tex: Some(("Plaster001", 1.0)), prio: 10.0, pattern: None },
|
||||
Mat { id: "std-c-zementestrich", name: "Zementestrich", abbrev: "ZE", fill: "#ffffff", elev: "#cfcac0", hatch: "std-h-estrich", lambda: Some(1.4), density: Some(2000.0), rf: "RF1", tex: Some(("Concrete048", 2.0)), prio: 30.0, pattern: None },
|
||||
// Bodenbeläge ([100]): Muster im Grundriss (Oberseite der Decke) und im 3D.
|
||||
Mat { id: "std-c-parkett", name: "Parkett", abbrev: "PA", fill: "#ffffff", elev: "#c9a06b", hatch: "std-h-holz", lambda: Some(0.13), density: Some(650.0), rf: "RF3", tex: Some(("Wood095", 1.0)), prio: 8.0, pattern: sp("runningBond", None, 0.6, Some(0.1), None) },
|
||||
Mat { id: "std-c-keramik", name: "Keramikplatten", abbrev: "KP", fill: "#ffffff", elev: "#d8d4cc", hatch: "std-h-ohne", lambda: Some(1.3), density: Some(2300.0), rf: "RF1", tex: None, prio: 9.0, pattern: sp("grid", None, 0.3, Some(0.3), None) },
|
||||
Mat { id: "std-c-keramik", name: "Keramikplatten", abbrev: "KP", fill: "#ffffff", elev: "#d8d4cc", hatch: "std-h-keramik", lambda: Some(1.3), density: Some(2300.0), rf: "RF1", tex: None, prio: 9.0, pattern: sp("grid", None, 0.3, Some(0.3), None) },
|
||||
Mat { id: "std-c-glas", name: "Glas", abbrev: "GL", fill: "#d6ecf3", elev: "#a9c8d4", hatch: "std-h-ohne", lambda: Some(1.0), density: Some(2500.0), rf: "RF1", tex: None, prio: 70.0, pattern: None },
|
||||
Mat { id: "std-c-stahl", name: "Stahl", abbrev: "ST", fill: INK, elev: "#7d8287", hatch: "std-h-stahl", lambda: Some(50.0), density: Some(7850.0), rf: "RF1", tex: Some(("Metal063", 1.0)), prio: 110.0, pattern: None },
|
||||
Mat { id: "std-c-aluminium", name: "Aluminium", abbrev: "AL", fill: "#8c8c8c", elev: "#b9bcbf", hatch: "std-h-alu", lambda: Some(160.0), density: Some(2700.0), rf: "RF1", tex: Some(("Metal063", 1.0)), prio: 105.0, pattern: None },
|
||||
@@ -185,7 +193,7 @@ pub fn components() -> Vec<Value> {
|
||||
Mat { id: "std-c-boden-deckel", name: "Holzschalung Boden-Deckel", abbrev: "BD", fill: "#ffffff", elev: "#a9824f", hatch: "std-h-holz", lambda: Some(0.13), density: Some(450.0), rf: "RF3", tex: Some(("WoodSiding008", 1.0)), prio: 41.0, pattern: sp("boardBatten", Some("vertical"), 0.2, None, Some(0.06)) },
|
||||
Mat { id: "std-c-schindeln", name: "Holzschindeln", abbrev: "SCH", fill: "#ffffff", elev: "#9c8566", hatch: "std-h-holz", lambda: Some(0.13), density: Some(450.0), rf: "RF3", tex: Some(("Wood095", 0.5)), prio: 41.0, pattern: sp("shingles", None, 0.1, Some(0.12), None) },
|
||||
Mat { id: "std-c-trapezblech", name: "Trapezblech", abbrev: "TB", fill: INK, elev: "#9aa1a6", hatch: "std-h-stahl", lambda: Some(50.0), density: Some(7850.0), rf: "RF1", tex: Some(("CorrugatedSteel005", 1.0)), prio: 108.0, pattern: sp("trapezoid", Some("vertical"), 0.2, None, Some(0.06)) },
|
||||
Mat { id: "std-c-faserzement", name: "Faserzementplatten", abbrev: "FZ", fill: "#ffffff", elev: "#a6a8a6", hatch: "std-h-ohne", lambda: Some(0.6), density: Some(1800.0), rf: "RF1", tex: None, prio: 42.0, pattern: sp("grid", None, 1.25, Some(0.625), None) },
|
||||
Mat { id: "std-c-faserzement", name: "Faserzementplatten", abbrev: "FZ", fill: "#ffffff", elev: "#a6a8a6", hatch: "std-h-faserzement", lambda: Some(0.6), density: Some(1800.0), rf: "RF1", tex: None, prio: 42.0, pattern: sp("grid", None, 1.25, Some(0.625), None) },
|
||||
Mat { id: "std-c-tonziegel", name: "Tonziegel", abbrev: "ZI", fill: "#ffffff", elev: "#b3583c", hatch: "std-h-backstein", lambda: Some(1.0), density: Some(1900.0), rf: "RF1", tex: Some(("RoofingTiles013A", 1.0)), prio: 15.0, pattern: sp("grid", Some("horizontal"), 0.21, Some(0.34), None) },
|
||||
];
|
||||
list.iter()
|
||||
@@ -263,6 +271,11 @@ fn remap(v: &mut Value, key: &str, ids: &HashMap<String, String>) {
|
||||
/// gleichem Namen (Gross-/Kleinschreibung egal); Verweise neuer Einträge (Schraffur → Linienstil, Bauteil →
|
||||
/// Schraffur, Aufbau → Bauteil/Fugen-Linienstil) zeigen dann auf den vorhandenen Eintrag.
|
||||
pub fn merge_ops(root: &Map<String, Value>) -> Vec<Value> {
|
||||
merge_plan(root).0
|
||||
}
|
||||
|
||||
/// Wie [`merge_ops`], dazu die Umleitung Standard-id → vorhandene id (gleichnamige Einträge).
|
||||
fn merge_plan(root: &Map<String, Value>) -> (Vec<Value>, HashMap<String, String>) {
|
||||
let mut ids: HashMap<String, String> = HashMap::new();
|
||||
let mut ops = Vec::new();
|
||||
for (key, items) in library() {
|
||||
@@ -299,6 +312,175 @@ pub fn merge_ops(root: &Map<String, Value>) -> Vec<Value> {
|
||||
ops.push(json!({"kind": "setField", "key": key, "value": add}));
|
||||
}
|
||||
}
|
||||
(ops, ids)
|
||||
}
|
||||
|
||||
// ── „Standards aktualisieren" ([109]) ────────────────────────────────────────
|
||||
//
|
||||
// Projekte, die mit älteren Standards angelegt wurden, behalten deren Definitionen („Standards laden"
|
||||
// ergänzt nur). „Aktualisieren" gleicht Standard-Einträge (gleiche id wie ein Eintrag der Bibliothek) mit
|
||||
// der heutigen Definition ab. Regel:
|
||||
// - Verglichen werden nur die vom Standard geführten Felder (`managed`); Name und eigene Zusatzfelder
|
||||
// bleiben unangetastet. Ein vom Standard geführtes Feld, das die neue Definition nicht mehr hat, wird
|
||||
// entfernt (z. B. ein früherer `lineStyleId`).
|
||||
// - Ob jemand einen Standard-Eintrag selbst geändert hat, lässt sich nicht erkennen (frühere Fassungen sind
|
||||
// nicht gespeichert). Darum nennt der Plan jede Abweichung einzeln; vorgewählt sind alle Einträge,
|
||||
// deren Name noch dem Standard entspricht, umbenannte (`renamed`) sind abgewählt. Gewählt wird im Dialog.
|
||||
// - Verweise (Schraffur, Linienstil, Bauteil) werden nur gesetzt, wenn das Ziel im Projekt existiert bzw.
|
||||
// gleichzeitig ergänzt wird; fehlende Standard-Einträge werden wie bei „Standards laden" angehängt.
|
||||
|
||||
type Valid<'a> = HashMap<&'a str, std::collections::HashSet<String>>;
|
||||
|
||||
/// Felder, die der Standard je Liste führt.
|
||||
fn managed(key: &str) -> &'static [&'static str] {
|
||||
match key {
|
||||
"lineStyles" => &["color", "dash", "kind", "zigzag"],
|
||||
"hatches" => &[
|
||||
"pattern", "scale", "angle", "color", "lineWeight", "relativeToWall", "lineStyleId", "kind", "lines", "density", "lengthMin", "lengthMax", "seed",
|
||||
],
|
||||
"components" => &[
|
||||
"color", "background", "hatchId", "viewHatchId", "joinPriority", "fireClass", "elevationColor", "standardId", "lambda", "density", "material", "surfacePattern",
|
||||
"abbrev",
|
||||
],
|
||||
_ => &["layers"],
|
||||
}
|
||||
}
|
||||
|
||||
/// Zahlen gleich nach Wert (1 == 1.0), sonst strukturell.
|
||||
fn same(a: &Value, b: &Value) -> bool {
|
||||
match (a, b) {
|
||||
(Value::Number(x), Value::Number(y)) => x.as_f64() == y.as_f64(),
|
||||
(Value::Array(x), Value::Array(y)) => x.len() == y.len() && x.iter().zip(y).all(|(p, q)| same(p, q)),
|
||||
(Value::Object(x), Value::Object(y)) => x.len() == y.len() && x.iter().all(|(k, v)| y.get(k).is_some_and(|w| same(v, w))),
|
||||
_ => a == b,
|
||||
}
|
||||
}
|
||||
|
||||
/// Ziel eines Verweises im Projekt (nach Umleitung gleichnamiger Einträge), sonst `None`.
|
||||
fn ref_target(ref_key: &str, id: &str, valid: &Valid, ids: &HashMap<String, String>) -> Option<String> {
|
||||
let list = match ref_key {
|
||||
"lineStyleId" | "jointLineStyleId" => "lineStyles",
|
||||
"hatchId" | "viewHatchId" => "hatches",
|
||||
_ => "components",
|
||||
};
|
||||
let id = ids.get(id).map(String::as_str).unwrap_or(id);
|
||||
valid.get(list).is_some_and(|v| v.contains(id)).then(|| id.to_string())
|
||||
}
|
||||
|
||||
/// Neue Fassung eines vorhandenen Standard-Eintrags (nur geführte Felder; Verweise auf fehlende Ziele
|
||||
/// bleiben wie sie sind) und die Namen der geänderten Felder.
|
||||
fn updated(key: &str, old: &Value, std: &Value, valid: &Valid, ids: &HashMap<String, String>) -> (Value, Vec<String>) {
|
||||
let mut new = old.clone();
|
||||
let mut fields = Vec::new();
|
||||
for f in managed(key) {
|
||||
let mut want = std.get(*f).cloned();
|
||||
if let Some(Value::String(id)) = &want {
|
||||
if matches!(*f, "lineStyleId" | "hatchId" | "viewHatchId") {
|
||||
match ref_target(f, id, valid, ids) {
|
||||
Some(ok) => want = Some(json!(ok)),
|
||||
None => continue, // Ziel fehlt: Verweis bleibt
|
||||
}
|
||||
}
|
||||
}
|
||||
if *f == "layers" {
|
||||
if let Some(Value::Array(ls)) = &mut want {
|
||||
for l in ls {
|
||||
for rk in ["componentId", "jointLineStyleId"] {
|
||||
if let Some(id) = l[rk].as_str().map(String::from) {
|
||||
match ref_target(rk, &id, valid, ids) {
|
||||
Some(ok) => l[rk] = json!(ok),
|
||||
None => return (old.clone(), Vec::new()),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let have = old.get(*f);
|
||||
let differs = match (&want, have) {
|
||||
(Some(w), Some(h)) => !same(w, h),
|
||||
(None, None) => false,
|
||||
(None, Some(h)) => !h.is_null(),
|
||||
(Some(w), None) => !w.is_null(),
|
||||
};
|
||||
if differs {
|
||||
fields.push((*f).to_string());
|
||||
match want {
|
||||
Some(w) => new[*f] = w,
|
||||
None => {
|
||||
if let Some(o) = new.as_object_mut() {
|
||||
o.remove(*f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
(new, fields)
|
||||
}
|
||||
|
||||
/// Eine Abweichung: (Liste, id, Name, geänderte Felder, umbenannt, neue Fassung).
|
||||
type Change = (String, String, String, Vec<String>, bool, Value);
|
||||
|
||||
fn update_changes(root: &Map<String, Value>) -> (Vec<Change>, usize) {
|
||||
let (merge, ids) = merge_plan(root);
|
||||
let mut valid: Valid = HashMap::new();
|
||||
let mut added = 0;
|
||||
for (key, _) in library() {
|
||||
let set = valid.entry(key).or_default();
|
||||
if let Some(a) = root.get(key).and_then(Value::as_array) {
|
||||
set.extend(a.iter().filter_map(|e| e["id"].as_str().map(String::from)));
|
||||
}
|
||||
for op in &merge {
|
||||
let list = match op["kind"].as_str() {
|
||||
Some("add") if op["collection"] == key => op["items"].as_array(),
|
||||
Some("setField") if op["key"] == key => op["value"].as_array(),
|
||||
_ => None,
|
||||
};
|
||||
for it in list.into_iter().flatten() {
|
||||
added += 1;
|
||||
if let Some(i) = it["id"].as_str() {
|
||||
set.insert(i.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut out = Vec::new();
|
||||
for (key, items) in library() {
|
||||
let Some(existing) = root.get(key).and_then(Value::as_array) else { continue };
|
||||
for std in &items {
|
||||
let Some(id) = std["id"].as_str() else { continue };
|
||||
let Some(old) = existing.iter().find(|e| e["id"] == id) else { continue };
|
||||
let (new, fields) = updated(key, old, std, &valid, &ids);
|
||||
if fields.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let name = old["name"].as_str().unwrap_or(id).to_string();
|
||||
let renamed = name_key(old) != name_key(std);
|
||||
out.push((key.to_string(), id.to_string(), name, fields, renamed, new));
|
||||
}
|
||||
}
|
||||
(out, added)
|
||||
}
|
||||
|
||||
/// Abweichungen der Standard-Einträge im Projekt von der heutigen Bibliothek: je Eintrag
|
||||
/// `{collection, id, name, fields, renamed}`; dazu `added` = Anzahl fehlender Standard-Einträge.
|
||||
pub fn update_plan(root: &Map<String, Value>) -> Value {
|
||||
let (changes, added) = update_changes(root);
|
||||
json!({
|
||||
"added": added,
|
||||
"changes": changes.iter().map(|c| json!({"collection": c.0, "id": c.1, "name": c.2, "fields": c.3, "renamed": c.4})).collect::<Vec<_>>(),
|
||||
})
|
||||
}
|
||||
|
||||
/// Ops für „Standards aktualisieren": fehlende Standards anhängen und die gewählten Einträge (`selected` =
|
||||
/// `"<Liste>:<id>"`) ersetzen — ein Undo-Schritt. Unbekannte Auswahl wird ignoriert.
|
||||
pub fn update_ops(root: &Map<String, Value>, selected: &[String]) -> Vec<Value> {
|
||||
let mut ops = merge_ops(root);
|
||||
for (key, id, _, _, _, new) in update_changes(root).0 {
|
||||
if selected.contains(&format!("{key}:{id}")) {
|
||||
ops.push(json!({"kind": "replace", "collection": key, "entity": new}));
|
||||
}
|
||||
}
|
||||
ops
|
||||
}
|
||||
|
||||
@@ -361,6 +543,104 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn putz_keramik_faserzement_haben_schraffur() {
|
||||
let r = apply(&empty_root(), &merge_ops(&empty_root()));
|
||||
let p: Project = serde_json::from_value(Value::Object(r)).unwrap();
|
||||
for (comp, hatch) in [("std-c-innenputz", "std-h-putz"), ("std-c-aussenputz", "std-h-putz"), ("std-c-keramik", "std-h-keramik"), ("std-c-faserzement", "std-h-faserzement")] {
|
||||
assert_eq!(p.components.iter().find(|c| c.id == comp).unwrap().hatch_id, hatch);
|
||||
}
|
||||
assert_eq!(p.hatches.iter().find(|h| h.id == "std-h-putz").unwrap().pattern, crate::model::HatchPattern::Dots);
|
||||
}
|
||||
|
||||
fn alt_projekt() -> Map<String, Value> {
|
||||
// Projekt mit Standards vom 29.10.: alte EPS-Schraffur, Putz ohne Schraffur, eine umbenannte und
|
||||
// eine eigene Schraffur.
|
||||
let mut root = apply(&empty_root(), &merge_ops(&empty_root()));
|
||||
let hs = root.get_mut("hatches").unwrap().as_array_mut().unwrap();
|
||||
hs.retain(|h| h["id"] != "std-h-putz");
|
||||
for h in hs.iter_mut() {
|
||||
if h["id"] == "std-h-eps" {
|
||||
h["pattern"] = json!("insulation");
|
||||
}
|
||||
if h["id"] == "std-h-xps" {
|
||||
h["name"] = json!("Meine XPS");
|
||||
h["pattern"] = json!("diagonal");
|
||||
}
|
||||
}
|
||||
hs.push(json!({"id": "mine", "name": "Eigene", "pattern": "diagonal", "scale": 1, "angle": 0, "color": "#000"}));
|
||||
for c in root.get_mut("components").unwrap().as_array_mut().unwrap() {
|
||||
if c["id"] == "std-c-innenputz" {
|
||||
c["hatchId"] = json!("std-h-ohne");
|
||||
}
|
||||
}
|
||||
root
|
||||
}
|
||||
|
||||
fn apply_all(root: &Map<String, Value>, ops: &[Value]) -> Map<String, Value> {
|
||||
let mut r = root.clone();
|
||||
for op in ops {
|
||||
match op["kind"].as_str().unwrap() {
|
||||
"add" => r.get_mut(op["collection"].as_str().unwrap()).unwrap().as_array_mut().unwrap().extend(op["items"].as_array().unwrap().iter().cloned()),
|
||||
"setField" => {
|
||||
r.insert(op["key"].as_str().unwrap().into(), op["value"].clone());
|
||||
}
|
||||
"replace" => {
|
||||
let list = r.get_mut(op["collection"].as_str().unwrap()).unwrap().as_array_mut().unwrap();
|
||||
let i = list.iter().position(|e| e["id"] == op["entity"]["id"]).unwrap();
|
||||
list[i] = op["entity"].clone();
|
||||
}
|
||||
k => panic!("{k}"),
|
||||
}
|
||||
}
|
||||
r
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn aktualisieren_listet_abweichungen_und_ersetzt_gewaehlte() {
|
||||
let root = alt_projekt();
|
||||
let plan = update_plan(&root);
|
||||
assert_eq!(plan["added"], 1, "Putz-Schraffur fehlt");
|
||||
let ch = plan["changes"].as_array().unwrap();
|
||||
let find = |id: &str| ch.iter().find(|c| c["id"] == id);
|
||||
assert_eq!(find("std-h-eps").unwrap()["fields"], json!(["pattern"]));
|
||||
assert_eq!(find("std-h-eps").unwrap()["renamed"], false);
|
||||
assert_eq!(find("std-h-xps").unwrap()["renamed"], true, "umbenannt: abgewählt");
|
||||
assert!(find("std-h-xps").unwrap()["fields"].as_array().unwrap().iter().any(|f| f == "pattern"));
|
||||
assert_eq!(find("std-c-innenputz").unwrap()["fields"], json!(["hatchId"]), "Verweis zeigt künftig auf die ergänzte Putz-Schraffur");
|
||||
assert!(find("mine").is_none() && find("std-h-beton").is_none(), "Eigenes und Unverändertes nicht");
|
||||
let ops = update_ops(&root, &["hatches:std-h-eps".to_string(), "components:std-c-innenputz".to_string()]);
|
||||
let after = apply_all(&root, &ops);
|
||||
let get = |k: &str, id: &str| after[k].as_array().unwrap().iter().find(|e| e["id"] == id).unwrap().clone();
|
||||
assert_eq!(get("hatches", "std-h-eps")["pattern"], "insulationHard");
|
||||
assert_eq!(get("hatches", "std-h-xps")["pattern"], "diagonal", "nicht gewählt: bleibt");
|
||||
assert_eq!(get("components", "std-c-innenputz")["hatchId"], "std-h-putz");
|
||||
assert!(after["hatches"].as_array().unwrap().iter().any(|h| h["id"] == "std-h-putz"));
|
||||
let left = update_plan(&after);
|
||||
assert_eq!(left["added"], 0);
|
||||
assert!(left["changes"].as_array().unwrap().iter().all(|c| c["id"] == "std-h-xps"));
|
||||
let all: Vec<String> = left["changes"].as_array().unwrap().iter().map(|c| format!("{}:{}", c["collection"].as_str().unwrap(), c["id"].as_str().unwrap())).collect();
|
||||
let done = apply_all(&after, &update_ops(&after, &all));
|
||||
assert!(update_plan(&done)["changes"].as_array().unwrap().is_empty());
|
||||
let p: Project = serde_json::from_value(Value::Object(done)).unwrap();
|
||||
assert!(crate::project_refs::dangling_refs(&p).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn aktualisieren_entfernt_nicht_mehr_gefuehrte_felder_und_laesst_zusatzfelder() {
|
||||
let mut root = apply(&empty_root(), &merge_ops(&empty_root()));
|
||||
for h in root.get_mut("hatches").unwrap().as_array_mut().unwrap() {
|
||||
if h["id"] == "std-h-eps" {
|
||||
h["lineStyleId"] = json!("std-ls-voll");
|
||||
h["myNote"] = json!("bleibt");
|
||||
}
|
||||
}
|
||||
let after = apply_all(&root, &update_ops(&root, &["hatches:std-h-eps".to_string()]));
|
||||
let eps = after["hatches"].as_array().unwrap().iter().find(|h| h["id"] == "std-h-eps").unwrap();
|
||||
assert!(eps.get("lineStyleId").is_none());
|
||||
assert_eq!(eps["myNote"], "bleibt");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zweites_laden_verdoppelt_nichts() {
|
||||
let once = apply(&empty_root(), &merge_ops(&empty_root()));
|
||||
|
||||
@@ -42,10 +42,15 @@ fn pattern_id(p: HatchPattern) -> f64 {
|
||||
HatchPattern::Solid => 1.0,
|
||||
HatchPattern::Diagonal => 2.0,
|
||||
HatchPattern::Crosshatch => 3.0,
|
||||
HatchPattern::Insulation | HatchPattern::InsulationHard | HatchPattern::InsulationWave => 4.0,
|
||||
// 3D-Schnittflächen (render3d) kennen nur die Grundmuster: nächstliegendes ([109]).
|
||||
HatchPattern::Timber | HatchPattern::Earth => 3.0,
|
||||
HatchPattern::Gravel | HatchPattern::Stone => 2.0,
|
||||
// Ab 4: Muster-Code des Kern-Generators (render3d zeichnet die Linien selbst, [109]).
|
||||
HatchPattern::Insulation => 4.0,
|
||||
HatchPattern::InsulationHard => 6.0,
|
||||
HatchPattern::InsulationWave => 7.0,
|
||||
HatchPattern::Timber => 8.0,
|
||||
HatchPattern::Earth => 9.0,
|
||||
HatchPattern::Gravel => 10.0,
|
||||
HatchPattern::Stone => 11.0,
|
||||
HatchPattern::Dots => 12.0,
|
||||
_ => 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+114
@@ -0,0 +1,114 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.20.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
||||
|
||||
[[package]]
|
||||
name = "dossier-hatch"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.47"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "3.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.129"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
"rustversion",
|
||||
"wasm-bindgen-macro",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.129"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.129"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.129"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
@@ -0,0 +1,20 @@
|
||||
# Kein eigener [workspace]-Block (wie render3d): der Parent `src-tauri/Cargo.toml` schliesst das Crate per
|
||||
# `exclude` aus; es baut standalone (`cd hatchgen && cargo test`) und als Pfad-Abhaengigkeit von core/render3d.
|
||||
|
||||
[package]
|
||||
name = "dossier-hatch"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
description = "Schraffur-Generator (Linien, Schichtmuster) als eigenes Crate: dossier-core (Plan/Schnitt/Ansicht) und render3d (Live-Schnitt) zeichnen damit dieselben Linien. Nur JS-Zahlsemantik (jsnum, jsmath), keine weiteren Abhaengigkeiten."
|
||||
license = "AGPL-3.0-or-later"
|
||||
|
||||
[lib]
|
||||
name = "dossier_hatch"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
# Math-Aufrufe der JS-Engine (bitgleich zu TS), nur wasm32; vom Kern (Feature "web") durchgereicht.
|
||||
web = ["dep:wasm-bindgen"]
|
||||
|
||||
[dependencies]
|
||||
wasm-bindgen = { version = "0.2", optional = true }
|
||||
@@ -50,6 +50,7 @@ pub enum Pattern {
|
||||
Earth = 9,
|
||||
Gravel = 10,
|
||||
Stone = 11,
|
||||
Dots = 12,
|
||||
}
|
||||
|
||||
impl Pattern {
|
||||
@@ -66,6 +67,7 @@ impl Pattern {
|
||||
9 => Pattern::Earth,
|
||||
10 => Pattern::Gravel,
|
||||
11 => Pattern::Stone,
|
||||
12 => Pattern::Dots,
|
||||
_ => Pattern::Diagonal,
|
||||
}
|
||||
}
|
||||
@@ -417,6 +419,7 @@ pub fn build_hatch_runs(poly: &[V2], hatch: &Hatch) -> Vec<Run> {
|
||||
Pattern::Timber => return timber_band_runs(poly, hatch, scale),
|
||||
Pattern::Earth => return earth_runs(poly, hatch, scale),
|
||||
Pattern::Gravel => return gravel_runs(poly, hatch, scale),
|
||||
Pattern::Dots => return dots_runs(poly, hatch, scale),
|
||||
_ => {}
|
||||
}
|
||||
let spacing_m = 8.0 * scale * PX_TO_M;
|
||||
@@ -659,6 +662,45 @@ fn gravel_runs(poly: &[V2], hatch: &Hatch, scale: f64) -> Vec<Run> {
|
||||
runs
|
||||
}
|
||||
|
||||
/// Punktfeld (Putz, SIA 400): feine, ruhige Punkte im versetzten Raster, entlang der Schicht ausgerichtet
|
||||
/// (Schichtmuster: Laufrichtung = Schraffurwinkel, Bänder wie bei der Dämmung). Teilung entlang u = 0.05 m ·
|
||||
/// scale; die Reihen füllen die Schichtdicke gleichmässig (Reihenabstand ≈ 0.87 · Teilung, mindestens eine
|
||||
/// Reihe in der Schichtmitte, damit auch dünne Putzschichten Punkte bekommen). Jeder Punkt ein winziger
|
||||
/// Strich (30 % der Teilung); nur Punkte, die ganz in der Fläche liegen (ruhiger Rand).
|
||||
fn dots_runs(poly: &[V2], hatch: &Hatch, scale: f64) -> Vec<Run> {
|
||||
let Some(b) = band_frame(poly, hatch, scale) else { return Vec::new() };
|
||||
let pitch = (0.05 * scale).max(0.004);
|
||||
let half_dot = 0.15 * pitch;
|
||||
if (b.u1 - b.u0) / pitch > BAND_MAX_POINTS {
|
||||
return Vec::new();
|
||||
}
|
||||
let mut runs = Vec::new();
|
||||
for &(vc, half) in &b.rows {
|
||||
let k = (2.0 * half / (0.87 * pitch)).round().max(1.0);
|
||||
if k > 5_000.0 {
|
||||
continue;
|
||||
}
|
||||
let step = 2.0 * half / k;
|
||||
let mut r = 0.0;
|
||||
while r < k {
|
||||
let v = vc - half + (r + 0.5) * step;
|
||||
let shift = if r.rem_euclid(2.0) == 0.0 { 0.0 } else { 0.5 };
|
||||
let mut i = ((b.u0 - b.ua) / pitch).floor() - 1.0;
|
||||
while b.ua + (i + shift) * pitch <= b.u1 + pitch {
|
||||
let cu = b.ua + (i + shift) * pitch;
|
||||
let (a, e) = (b.at(cu - half_dot, v), b.at(cu + half_dot, v));
|
||||
let kept = clip_segment_to_polygon(a, e, poly);
|
||||
if kept.len() == 1 && hypot2(kept[0].1.x - kept[0].0.x, kept[0].1.y - kept[0].0.y) > 1.9 * half_dot {
|
||||
runs.push(vec![a, e]);
|
||||
}
|
||||
i += 1.0;
|
||||
}
|
||||
r += 1.0;
|
||||
}
|
||||
}
|
||||
runs
|
||||
}
|
||||
|
||||
// ── Random-Schraffur ────────────────────────────────────────────────────────
|
||||
|
||||
/// mulberry32 (deterministischer 32-bit-PRNG).
|
||||
@@ -1006,10 +1048,38 @@ mod tests {
|
||||
assert!((st / d - 2.0).abs() < 0.1, "{st} / {d}");
|
||||
}
|
||||
|
||||
/// Putz: ruhiges Punktfeld entlang der Schicht, nur ganze Punkte, stabil, versetzte Reihen; auch eine
|
||||
/// dünne Putzschicht (1.5 cm) bekommt mindestens eine Reihe.
|
||||
#[test]
|
||||
fn putz_punktfeld() {
|
||||
let mut h = hatch(Pattern::Dots);
|
||||
h.angle = 0.0;
|
||||
h.scale = 0.4; // Teilung 2 cm
|
||||
let sq = band(1.0, 0.1);
|
||||
let runs = build_hatch_runs(&sq, &h);
|
||||
// 10 cm: 5 Reihen à ~50 Punkte
|
||||
assert!((200..300).contains(&runs.len()), "{}", runs.len());
|
||||
assert!(runs.iter().all(|r| r.len() == 2 && (r[1].x - r[0].x - 0.006).abs() < 1e-9 && r[0].y == r[1].y), "Punkte sind winzige Striche");
|
||||
let (lo, hi) = extent(&runs, |p| p.x);
|
||||
assert!(lo >= 0.0 && hi <= 1.0);
|
||||
assert_eq!(runs, build_hatch_runs(&sq, &h));
|
||||
let (ylo, yhi) = extent(&runs, |p| p.y);
|
||||
assert!(ylo > 0.0 && yhi < 0.1);
|
||||
// dünne Schicht
|
||||
let thin = build_hatch_runs(&band(1.0, 0.015), &h);
|
||||
assert!(thin.len() > 30, "{}", thin.len());
|
||||
assert!(thin.iter().all(|r| r[0].y >= 0.0 && r[0].y <= 0.015));
|
||||
// versetzte Reihen: mindestens zwei Phasen in x
|
||||
let mut phases: Vec<i64> = runs.iter().map(|r| ((r[0].x / 0.02).rem_euclid(1.0) * 100.0).round() as i64 % 100).collect();
|
||||
phases.sort();
|
||||
phases.dedup();
|
||||
assert!(phases.len() >= 2, "{phases:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn schichtmuster_entartet_leer() {
|
||||
let p = vec![v2(0.0, 0.0), v2(f64::INFINITY, 0.0), v2(1.0, 1.0)];
|
||||
for pat in [Pattern::InsulationHard, Pattern::InsulationWave, Pattern::Timber, Pattern::Earth, Pattern::Gravel, Pattern::Stone] {
|
||||
for pat in [Pattern::InsulationHard, Pattern::InsulationWave, Pattern::Timber, Pattern::Earth, Pattern::Gravel, Pattern::Stone, Pattern::Dots] {
|
||||
assert!(build_hatch_runs(&p, &hatch(pat)).is_empty(), "{pat:?}");
|
||||
}
|
||||
// Linie ohne Dicke
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,6 @@
|
||||
//! Schraffur-Generator ([109]): `hatch` (Linien-, Schicht-, Streumuster), `jsnum`/`jsmath` (JS-Zahlsemantik).
|
||||
//! Gemeinsam genutzt von `dossier-core` (Re-Export unter `crate::hatch` usw.) und `render3d` (Live-Schnitt).
|
||||
|
||||
pub mod hatch;
|
||||
pub mod jsmath;
|
||||
pub mod jsnum;
|
||||
@@ -57,6 +57,8 @@ web = [
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
# Schraffur-Generator des Kerns (Live-Schnitt zeichnet dieselben Musterlinien wie Plan/Schnitt, [109]).
|
||||
dossier-hatch = { path = "../hatchgen" }
|
||||
# JSON-Modell (dieselbe Ableitung wie der native Push): im Web-Pfad zur Laufzeit
|
||||
# geparst; optional, nur mit Feature "web".
|
||||
serde_json = { version = "1", optional = true }
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
//! Rechteck (4 Ecken, siehe `section.rs`) — Fan-Triangulierung genuegt.
|
||||
|
||||
use crate::section::{cut_section, CutPolygon, SectionPlane};
|
||||
use dossier_hatch::hatch::{build_hatch_runs, v2, Hatch as GenHatch, HatchKind, Pattern};
|
||||
use crate::section_boolean::subtract_dominant_bands;
|
||||
use crate::types::{RoofLayerInput, SlabInput, WallInput};
|
||||
|
||||
@@ -78,6 +79,12 @@ const CUT_LINE_MM_TO_WORLD: f32 = 0.01;
|
||||
/// sichtbar VOR den Cut-Caps liegen (die exakt auf der Ebene sitzen).
|
||||
const CUT_LINE_LIFT: f32 = 0.002;
|
||||
|
||||
/// Ab dieser Muster-Id zeichnet NICHT der Cap-Shader, sondern der Kern-Generator (`dossier_hatch`, derselbe
|
||||
/// wie in Plan/Schnitt — Dämmschlange, Zickzack, Welle, Holzkreuz, Naturstein, Erdreich, Kies, Punktfeld):
|
||||
/// die Ids sind die Muster-Codes des Generators (`Pattern::from_code`). Der Shader füllt solche Flächen leer
|
||||
/// (Papier); die Linien kommen als Ribbons (`build_cut_cap_lines`).
|
||||
pub const GENERATED_PATTERN_MIN: u32 = 4;
|
||||
|
||||
/// Fallback-Muster-Id, wenn ein Cut-Polygon keine `hatch` traegt: 2 = diagonal
|
||||
/// (45°) — reproduziert mit `angle_rad = 0`, `scale = 1` exakt das fruehere fest
|
||||
/// verdrahtete 45°-Muster (Rueckwaertskompatibilitaet fuer Waende/Decken ohne
|
||||
@@ -138,7 +145,8 @@ pub fn build_cut_caps(
|
||||
// cos/sin rechnen kann.
|
||||
let (pattern, angle_rad, scale, line_weight) = match poly.hatch {
|
||||
Some(h) => (
|
||||
h.pattern as f32,
|
||||
// Generator-Muster: Shader zeichnet nichts (Id 0), die Linien kommen als Ribbons.
|
||||
if h.pattern >= GENERATED_PATTERN_MIN { 0.0 } else { h.pattern as f32 },
|
||||
h.angle.to_radians(),
|
||||
h.scale.max(0.05),
|
||||
h.line_weight.max(0.0),
|
||||
@@ -229,10 +237,53 @@ pub fn build_cut_cap_lines(
|
||||
let b = to_world(poly.pts[(k + 1) % n]);
|
||||
push_line_ribbon(&mut verts, a, b, normal, half_w, color);
|
||||
}
|
||||
push_generated_hatch(&mut verts, poly, &to_world, normal);
|
||||
}
|
||||
verts
|
||||
}
|
||||
|
||||
/// Muster-Tinte der Generator-Schraffur (wie `ink` im Cap-Shader).
|
||||
const HATCH_INK: [f32; 3] = [0.06, 0.06, 0.06];
|
||||
|
||||
/// Musterlinien eines Cut-Polygons mit Generator-Muster (`GENERATED_PATTERN_MIN`) als Ribbons: dieselben
|
||||
/// Linien wie im 2D-Schnitt (`dossier_hatch::hatch::build_hatch_runs`, Polygon (u,v) in Metern, Winkel und
|
||||
/// Skala der Bauteil-Schraffur). Breite wie die Shader-Linien (mm-Papier -> Welt über `CUT_LINE_MM_TO_WORLD`).
|
||||
fn push_generated_hatch(
|
||||
out: &mut Vec<f32>,
|
||||
poly: &CutPolygon,
|
||||
to_world: &dyn Fn([f32; 2]) -> [f32; 3],
|
||||
normal: [f32; 3],
|
||||
) {
|
||||
let Some(h) = poly.hatch else { return };
|
||||
if h.pattern < GENERATED_PATTERN_MIN || poly.pts.len() < 3 {
|
||||
return;
|
||||
}
|
||||
let gen = GenHatch {
|
||||
pattern: Pattern::from_code(h.pattern as f64),
|
||||
kind: HatchKind::Vector,
|
||||
random: false,
|
||||
scale: h.scale.max(0.05) as f64,
|
||||
angle: h.angle as f64,
|
||||
line_weight: h.line_weight as f64,
|
||||
origin: None,
|
||||
seed: None,
|
||||
density: None,
|
||||
length_min: None,
|
||||
length_max: None,
|
||||
dash: Vec::new(),
|
||||
motif: None,
|
||||
};
|
||||
let pts: Vec<_> = poly.pts.iter().map(|p| v2(p[0] as f64, p[1] as f64)).collect();
|
||||
let half_w = (h.line_weight.max(0.0) * CUT_LINE_MM_TO_WORLD * 0.5).max(1e-4);
|
||||
for run in build_hatch_runs(&pts, &gen) {
|
||||
for w in run.windows(2) {
|
||||
let a = to_world([w[0].x as f32, w[0].y as f32]);
|
||||
let b = to_world([w[1].x as f32, w[1].y as f32]);
|
||||
push_line_ribbon(out, a, b, normal, half_w, HATCH_INK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Legt ein flaches Ribbon-Quad (2 Dreiecke) der halben Breite `half_w` um die
|
||||
/// Kante `a`->`b`, verbreitert IN der Schnittebene (senkrecht zur Kante ueber
|
||||
/// `cross(normal, dir)`), und schreibt es als 6 Vertices `[pos, color]` in `out`.
|
||||
@@ -333,6 +384,43 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// Generator-Muster (Id >= 4, hier 4 Daemmschlange): der Shader bekommt Id 0 (Papier), die Linien kommen als
|
||||
/// Ribbons aus dem Kern-Generator in den Cut-Linien — mehr Dreiecke als ohne Muster, alle in der Schnittebene.
|
||||
#[test]
|
||||
fn generator_muster_kommt_als_ribbons() {
|
||||
let mk = |pattern: u32| WallInput {
|
||||
top_drop: [0.0, 0.0],
|
||||
start: [0.0, 0.0],
|
||||
end: [3.0, 0.0],
|
||||
thickness: 0.3,
|
||||
height: 2.5,
|
||||
base_elevation: 0.0,
|
||||
color: [0.8, 0.8, 0.8],
|
||||
openings: vec![],
|
||||
layers: None,
|
||||
holes: vec![],
|
||||
material_index: None,
|
||||
hatch: Some(Hatch { pattern, angle: -90.0, scale: 1.0, line_weight: 0.13, top_angle: None }),
|
||||
cut: None,
|
||||
start_cut: None,
|
||||
end_cut: None,
|
||||
};
|
||||
let plane = SectionPlane::looking_plus_x(1.5);
|
||||
let caps = build_cut_caps(&plane, &[mk(4)], &[], &[]);
|
||||
assert!(!caps.is_empty());
|
||||
for i in 0..caps.len() / CAP_FLOATS_PER_VERTEX {
|
||||
assert_eq!(caps[i * CAP_FLOATS_PER_VERTEX + 5], 0.0, "Shader zeichnet kein Muster");
|
||||
}
|
||||
let plain = build_cut_cap_lines(&plane, &[mk(0)], &[], &[]);
|
||||
for pat in [4u32, 6, 7, 8, 9, 10, 11, 12] {
|
||||
let lines = build_cut_cap_lines(&plane, &[mk(pat)], &[], &[]);
|
||||
assert!(lines.len() > plain.len() + 6 * CUT_LINE_FLOATS_PER_VERTEX * 10, "Muster {pat}: Musterlinien fehlen");
|
||||
assert_eq!(lines.len() % CUT_LINE_FLOATS_PER_VERTEX, 0);
|
||||
}
|
||||
// Diagonale/Kreuz bleiben im Shader (keine Ribbons)
|
||||
assert_eq!(build_cut_cap_lines(&plane, &[mk(2)], &[], &[]).len(), plain.len());
|
||||
}
|
||||
|
||||
/// Ohne `hatch` faellt jedes Cap-Polygon auf das Diagonalmuster (Id 2,
|
||||
/// angle 0, scale 1) zurueck — das reproduziert das fruehere fixe 45°-Muster.
|
||||
#[test]
|
||||
|
||||
@@ -374,7 +374,8 @@ fn fs_main(in : VsOut) -> @location(0) vec4<f32> {
|
||||
/// passend zur 2D-Schnittkonvention `HATCH_INK`): es variiert das MUSTER, nicht die
|
||||
/// Farbe. Muster-Ids: 0 = none (leer/weiss), 1 = solid (Vollton),
|
||||
/// 2 = diagonal (Linienschar, `angle` steuert die Neigung — 0° = horizontal, wie
|
||||
/// im 2D), 3 = crosshatch (Kreuz), 4 = insulation (Zickzack/Daemmung).
|
||||
/// im 2D), 3 = crosshatch (Kreuz); ab 4 (Daemmung, Holz, Naturstein, Erdreich, Kies, Putz) kommen die Musterlinien
|
||||
/// aus dem Kern-Generator (`dossier_hatch`, Ribbons in `section_fill`), der Shader zeichnet dort Papier.
|
||||
pub const CAP_WGSL: &str = r#"
|
||||
struct Globals {
|
||||
view_proj : mat4x4<f32>,
|
||||
@@ -459,10 +460,6 @@ fn fs_main(in : VsOut) -> @location(0) vec4<f32> {
|
||||
let sv = dv / spacing;
|
||||
let fw_u = fwidth(su);
|
||||
let fw_v = fwidth(sv);
|
||||
let cell = spacing * 2.0;
|
||||
let tri = abs(fract(du / cell) - 0.5) * 2.0; // 0..1 Dreieckswelle (Daemmung)
|
||||
let fb = fract(dv / cell);
|
||||
let fw_zig = fwidth(fb) + fwidth(tri);
|
||||
|
||||
// none (0): leere (weisse) Schnittflaeche — wie „keine Schraffur" im 2D.
|
||||
if (pattern == 0) {
|
||||
@@ -485,14 +482,9 @@ fn fs_main(in : VsOut) -> @location(0) vec4<f32> {
|
||||
line_band(sv, half_s, fw_v),
|
||||
line_band(su, half_s, fw_u)
|
||||
);
|
||||
} else {
|
||||
// insulation (4, Daemmung): Zickzack. Die Quer-Position (dv) folgt einer
|
||||
// Dreieckswelle entlang der Lauf-Achse (du) — ein durchgehender Zickzack.
|
||||
let d = min(abs(fb - tri), min(abs(fb - tri + 1.0), abs(fb - tri - 1.0)));
|
||||
let aa = max(fw_zig, 1e-5);
|
||||
let hw = half / cell;
|
||||
line = 1.0 - smoothstep(hw, hw + aa, d);
|
||||
}
|
||||
// Ids ab 4 (Daemmung, Holz, Naturstein, Erdreich, Kies, Putz ...) zeichnet der Kern-Generator als
|
||||
// Ribbons (section_fill::push_generated_hatch); der Shader laesst die Flaeche leer (Papier).
|
||||
|
||||
let color = mix(paper, ink, clamp(line, 0.0, 1.0));
|
||||
return vec4<f32>(color, 1.0);
|
||||
|
||||
@@ -27,7 +27,7 @@ pub type Rgb = [f32; 3];
|
||||
/// siehe 2D-Direktive `HATCH_INK`) und wandert deshalb bewusst NICHT mit.
|
||||
///
|
||||
/// `pattern`: 0 = none (leer/weiss), 1 = solid (Vollton), 2 = diagonal (45°),
|
||||
/// 3 = crosshatch (Kreuz), 4 = insulation (Zickzack/Daemmung). Die Zuordnung ist
|
||||
/// 3 = crosshatch (Kreuz), ab 4 = Muster-Code des Kern-Generators (`dossier_hatch::Pattern`: 4 Daemmschlange, 6-7 Hartschaum/Welle, 8 Holz, 9 Erdreich, 10 Kies, 11 Naturstein, 12 Punktfeld). Die Zuordnung ist
|
||||
/// mit der TS-Seite (`toWalls3d::hatchPatternId`) und dem Shader synchron zu halten.
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||
pub struct Hatch {
|
||||
|
||||
@@ -1594,6 +1594,7 @@ export default function App() {
|
||||
patchPenSetWeight,
|
||||
seedStandardPenSet,
|
||||
loadStandards,
|
||||
updateStandards,
|
||||
addCustomPalette,
|
||||
renameCustomPalette,
|
||||
deleteCustomPalette,
|
||||
@@ -2549,6 +2550,7 @@ export default function App() {
|
||||
onPatchPenSetWeight: patchPenSetWeight,
|
||||
onSeedStandardPenSet: seedStandardPenSet,
|
||||
onLoadStandards: loadStandards,
|
||||
onUpdateStandards: updateStandards,
|
||||
onAddCustomPalette: addCustomPalette,
|
||||
onRenameCustomPalette: renameCustomPalette,
|
||||
onDeleteCustomPalette: deleteCustomPalette,
|
||||
|
||||
@@ -57,7 +57,7 @@ export type LoadFileResult =
|
||||
| { ok: false; error: string };
|
||||
|
||||
/** Wurzel-Abfragen des Kerns (`queries.rs::run_root`). */
|
||||
export type RootQueryName = "penRebakeOps" | "penDeleteOps" | "penSeedOps" | "standardsMergeOps" | "folderPdfPages" | "layoutTitleBlock" | "translatePatch" | "translateOps" | "selectionFilterPatch";
|
||||
export type RootQueryName = "penRebakeOps" | "penDeleteOps" | "penSeedOps" | "standardsMergeOps" | "standardsUpdatePlan" | "standardsUpdateOps" | "folderPdfPages" | "layoutTitleBlock" | "translatePatch" | "translateOps" | "selectionFilterPatch";
|
||||
|
||||
/** Abfragen des Kerns (`queries.rs`). */
|
||||
export type QueryName =
|
||||
|
||||
@@ -1253,6 +1253,49 @@ export const de = {
|
||||
"material.fetchAmbient": "Textur laden",
|
||||
"material.fetchAmbient.hint": "Lädt die Texturkarten dieses ambientCG-Materials (CC0) herunter.",
|
||||
"resources.loadStandards": "Standards laden",
|
||||
"resources.updateStandards": "Standards aktualisieren",
|
||||
"resources.updateStandards.hint": "Bringt Standard-Einträge (Schraffuren, Baustoffe, Linientypen, Aufbauten mit Standard-id) auf die heutige Definition. Du siehst vorher, was sich ändert, und wählst aus; ein Undo-Schritt.",
|
||||
"resources.updateStandards.intro": "Diese Standard-Einträge weichen von der heutigen Bibliothek ab. Ob du einen Eintrag selbst angepasst hast, kann Dossier nicht erkennen: umbenannte Einträge sind abgewählt, alle anderen vorgewählt. Name und eigene Zusatzfelder bleiben unverändert.",
|
||||
"resources.updateStandards.added": "Außerdem werden {n} fehlende Standard-Einträge hinzugefügt.",
|
||||
"resources.updateStandards.none": "Alle Standard-Einträge sind auf dem heutigen Stand.",
|
||||
"resources.updateStandards.renamed": "umbenannt",
|
||||
"resources.updateStandards.all": "Alle überschreiben",
|
||||
"resources.updateStandards.noneSelected": "Keine",
|
||||
"resources.updateStandards.apply": "{n} aktualisieren",
|
||||
"resources.updateStandards.done": "Standards: {n} Einträge aktualisiert",
|
||||
"resources.updateStandards.col.components": "Baustoffe",
|
||||
"resources.updateStandards.col.hatches": "Schraffuren",
|
||||
"resources.updateStandards.col.lineStyles": "Linientypen",
|
||||
"resources.updateStandards.col.wallTypes": "Wandaufbauten",
|
||||
"resources.updateStandards.col.ceilingTypes": "Deckenaufbauten",
|
||||
"resources.updateStandards.col.roofTypes": "Dachaufbauten",
|
||||
"resources.updateStandards.field.pattern": "Muster",
|
||||
"resources.updateStandards.field.scale": "Massstab",
|
||||
"resources.updateStandards.field.angle": "Winkel",
|
||||
"resources.updateStandards.field.color": "Farbe",
|
||||
"resources.updateStandards.field.lineWeight": "Strichstärke",
|
||||
"resources.updateStandards.field.relativeToWall": "Bezug zur Wand",
|
||||
"resources.updateStandards.field.lineStyleId": "Linientyp",
|
||||
"resources.updateStandards.field.kind": "Art",
|
||||
"resources.updateStandards.field.lines": "Linienart",
|
||||
"resources.updateStandards.field.density": "Dichte",
|
||||
"resources.updateStandards.field.lengthMin": "Mindestlänge",
|
||||
"resources.updateStandards.field.lengthMax": "Maximallänge",
|
||||
"resources.updateStandards.field.seed": "Streuung",
|
||||
"resources.updateStandards.field.background": "Hintergrund",
|
||||
"resources.updateStandards.field.hatchId": "Schraffur",
|
||||
"resources.updateStandards.field.viewHatchId": "Ansichtsschraffur",
|
||||
"resources.updateStandards.field.joinPriority": "Anschlussvorrang",
|
||||
"resources.updateStandards.field.fireClass": "Brandklasse",
|
||||
"resources.updateStandards.field.elevationColor": "Ansichtsfarbe",
|
||||
"resources.updateStandards.field.standardId": "Standard-id",
|
||||
"resources.updateStandards.field.lambda": "Lambda",
|
||||
"resources.updateStandards.field.material": "Textur",
|
||||
"resources.updateStandards.field.surfacePattern": "Ansichtsmuster",
|
||||
"resources.updateStandards.field.abbrev": "Kürzel",
|
||||
"resources.updateStandards.field.dash": "Strichmuster",
|
||||
"resources.updateStandards.field.zigzag": "Zickzack",
|
||||
"resources.updateStandards.field.layers": "Schichten",
|
||||
"resources.loadStandards.hint": "Ergänzt die SIA-400-Standards (Baustoffe mit Schraffur, Ansichtsschraffur, Textur und Kennwerten, Linientypen, Wand-/Decken-/Dachaufbauten). Vorhandene Einträge (gleiche id oder gleicher Name) bleiben unverändert.",
|
||||
"resources.loadStandards.added": "{list} hinzugefügt",
|
||||
"resources.loadStandards.none": "Standards: alles schon vorhanden",
|
||||
@@ -1424,6 +1467,7 @@ export const de = {
|
||||
"pattern.stone": "Naturstein",
|
||||
"pattern.earth": "Erdreich",
|
||||
"pattern.gravel": "Kies",
|
||||
"pattern.dots": "Punktfeld (Putz)",
|
||||
"pattern.diagonal": "Diagonal",
|
||||
"pattern.crosshatch": "Kreuzschraffur",
|
||||
"pattern.custom": "Eigenes Motiv",
|
||||
|
||||
@@ -1246,6 +1246,49 @@ export const en: Record<TranslationKey, string> = {
|
||||
"material.fetchAmbient": "Load texture",
|
||||
"material.fetchAmbient.hint": "Downloads the texture maps of this ambientCG material (CC0).",
|
||||
"resources.loadStandards": "Load standards",
|
||||
"resources.updateStandards": "Update standards",
|
||||
"resources.updateStandards.hint": "Brings standard entries (hatches, materials, line types, assemblies with a standard id) up to today's definition. You see what changes first and choose; one undo step.",
|
||||
"resources.updateStandards.intro": "These standard entries differ from today's library. Dossier cannot tell whether you adjusted an entry yourself: renamed entries are unchecked, all others are checked. Names and your own extra fields stay as they are.",
|
||||
"resources.updateStandards.added": "{n} missing standard entries will also be added.",
|
||||
"resources.updateStandards.none": "All standard entries are up to date.",
|
||||
"resources.updateStandards.renamed": "renamed",
|
||||
"resources.updateStandards.all": "Overwrite all",
|
||||
"resources.updateStandards.noneSelected": "None",
|
||||
"resources.updateStandards.apply": "Update {n}",
|
||||
"resources.updateStandards.done": "Standards: {n} entries updated",
|
||||
"resources.updateStandards.col.components": "Materials",
|
||||
"resources.updateStandards.col.hatches": "Hatches",
|
||||
"resources.updateStandards.col.lineStyles": "Line types",
|
||||
"resources.updateStandards.col.wallTypes": "Wall assemblies",
|
||||
"resources.updateStandards.col.ceilingTypes": "Ceiling assemblies",
|
||||
"resources.updateStandards.col.roofTypes": "Roof assemblies",
|
||||
"resources.updateStandards.field.pattern": "Pattern",
|
||||
"resources.updateStandards.field.scale": "Scale",
|
||||
"resources.updateStandards.field.angle": "Angle",
|
||||
"resources.updateStandards.field.color": "Color",
|
||||
"resources.updateStandards.field.lineWeight": "Line weight",
|
||||
"resources.updateStandards.field.relativeToWall": "Relative to wall",
|
||||
"resources.updateStandards.field.lineStyleId": "Line type",
|
||||
"resources.updateStandards.field.kind": "Kind",
|
||||
"resources.updateStandards.field.lines": "Line mode",
|
||||
"resources.updateStandards.field.density": "Density",
|
||||
"resources.updateStandards.field.lengthMin": "Min length",
|
||||
"resources.updateStandards.field.lengthMax": "Max length",
|
||||
"resources.updateStandards.field.seed": "Seed",
|
||||
"resources.updateStandards.field.background": "Background",
|
||||
"resources.updateStandards.field.hatchId": "Hatch",
|
||||
"resources.updateStandards.field.viewHatchId": "View hatch",
|
||||
"resources.updateStandards.field.joinPriority": "Join priority",
|
||||
"resources.updateStandards.field.fireClass": "Fire class",
|
||||
"resources.updateStandards.field.elevationColor": "Elevation color",
|
||||
"resources.updateStandards.field.standardId": "Standard id",
|
||||
"resources.updateStandards.field.lambda": "Lambda",
|
||||
"resources.updateStandards.field.material": "Texture",
|
||||
"resources.updateStandards.field.surfacePattern": "Surface pattern",
|
||||
"resources.updateStandards.field.abbrev": "Abbreviation",
|
||||
"resources.updateStandards.field.dash": "Dash",
|
||||
"resources.updateStandards.field.zigzag": "Zigzag",
|
||||
"resources.updateStandards.field.layers": "Layers",
|
||||
"resources.loadStandards.hint": "Adds the SIA 400 standards (materials with hatch, surface pattern, texture and physical values, line types, wall/ceiling/roof build-ups). Existing entries (same id or same name) stay unchanged.",
|
||||
"resources.loadStandards.added": "Added {list}",
|
||||
"resources.loadStandards.none": "Standards: everything already present",
|
||||
@@ -1415,6 +1458,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"pattern.stone": "Natural stone",
|
||||
"pattern.earth": "Earth",
|
||||
"pattern.gravel": "Gravel",
|
||||
"pattern.dots": "Dot field (plaster)",
|
||||
"pattern.diagonal": "Diagonal",
|
||||
"pattern.crosshatch": "Crosshatch",
|
||||
"pattern.custom": "Custom motif",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { emptyProject, sampleProject } from "./sampleProject";
|
||||
import { standardsMergeCounts, standardsMergeOps, withStandards } from "./standards";
|
||||
import { standardsChangeKey, standardsMergeCounts, standardsMergeOps, standardsUpdateOps, standardsUpdatePlan, withStandards } from "./standards";
|
||||
import { applyOps } from "../core/ops";
|
||||
|
||||
describe("Standard-Bibliothek ([100]–[102])", () => {
|
||||
it("bringt Baustoffe, Linientypen und Aufbauten in ein neues Projekt", () => {
|
||||
@@ -36,4 +37,34 @@ describe("Standard-Bibliothek ([100]–[102])", () => {
|
||||
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 });
|
||||
});
|
||||
|
||||
it("Putz, Keramik und Faserzement haben eine Schraffur", () => {
|
||||
const p = withStandards({ ...emptyProject, components: [], hatches: [], lineStyles: [], wallTypes: [], ceilingTypes: [], roofTypes: [] });
|
||||
const hatchOf = (name: string) => p.hatches.find((h) => h.id === p.components.find((c) => c.name === name)!.hatchId)!;
|
||||
expect(hatchOf("Innenputz").pattern).toBe("dots");
|
||||
expect(hatchOf("Aussenputz").pattern).toBe("dots");
|
||||
expect(hatchOf("Keramikplatten").pattern).toBe("crosshatch");
|
||||
expect(hatchOf("Faserzementplatten").pattern).toBe("diagonal");
|
||||
});
|
||||
|
||||
it("„Standards aktualisieren“: alte Definitionen auf heutigen Stand, Auswahl, ein Op-Satz", () => {
|
||||
const full = withStandards({ ...emptyProject, components: [], hatches: [], lineStyles: [], wallTypes: [], ceilingTypes: [], roofTypes: [] });
|
||||
expect(standardsUpdatePlan(full).changes).toEqual([]);
|
||||
// Stand 29.10.: EPS mit alter Schraffur, Putz ohne Schraffur, XPS umbenannt
|
||||
const old = {
|
||||
...full,
|
||||
hatches: full.hatches.filter((h) => h.id !== "std-h-putz").map((h) => (h.id === "std-h-eps" ? { ...h, pattern: "insulation" as const } : h.id === "std-h-xps" ? { ...h, name: "Meine XPS", pattern: "diagonal" as const } : h)),
|
||||
components: full.components.map((c) => (c.id === "std-c-innenputz" ? { ...c, hatchId: "std-h-ohne" } : c)),
|
||||
};
|
||||
const plan = standardsUpdatePlan(old);
|
||||
expect(plan.added).toBe(1);
|
||||
expect(plan.changes.map((c) => c.id).sort()).toEqual(["std-c-innenputz", "std-h-eps", "std-h-xps"]);
|
||||
expect(plan.changes.find((c) => c.id === "std-h-xps")!.renamed).toBe(true);
|
||||
const selected = plan.changes.filter((c) => !c.renamed).map(standardsChangeKey);
|
||||
const after = applyOps(old, standardsUpdateOps(old, selected));
|
||||
expect(after.hatches.find((h) => h.id === "std-h-eps")!.pattern).toBe("insulationHard");
|
||||
expect(after.hatches.find((h) => h.id === "std-h-xps")!.pattern).toBe("diagonal");
|
||||
expect(after.components.find((c) => c.id === "std-c-innenputz")!.hatchId).toBe("std-h-putz");
|
||||
expect(standardsUpdatePlan(after).changes.map((c) => c.id)).toEqual(["std-h-xps"]);
|
||||
});
|
||||
});
|
||||
@@ -37,3 +37,34 @@ export function standardsMergeCounts(ops: readonly CoreOp[]): StandardsMergeCoun
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Ein Standard-Eintrag des Projekts, der von der heutigen Bibliothek abweicht („Standards aktualisieren"). */
|
||||
export interface StandardsChange {
|
||||
/** Projekt-Liste (`hatches`, `components`, `wallTypes` …). */
|
||||
collection: string;
|
||||
id: string;
|
||||
name: string;
|
||||
/** Namen der Felder, die sich ändern würden. */
|
||||
fields: string[];
|
||||
/** Name weicht vom Standard ab: vermutlich selbst angepasst (im Dialog abgewählt). */
|
||||
renamed: boolean;
|
||||
}
|
||||
|
||||
export interface StandardsUpdatePlan {
|
||||
/** Anzahl fehlender Standard-Einträge, die mit angehängt werden. */
|
||||
added: number;
|
||||
changes: StandardsChange[];
|
||||
}
|
||||
|
||||
/** Schlüssel eines Eintrags in der Auswahl von {@link standardsUpdateOps}. */
|
||||
export const standardsChangeKey = (c: Pick<StandardsChange, "collection" | "id">): string => `${c.collection}:${c.id}`;
|
||||
|
||||
/** Abweichungen der Standard-Einträge vom heutigen Standard (Regel s. `standards.rs`, „Standards aktualisieren"). */
|
||||
export function standardsUpdatePlan(project: Project): StandardsUpdatePlan {
|
||||
return documentFor(project).queryRoot<StandardsUpdatePlan>("standardsUpdatePlan");
|
||||
}
|
||||
|
||||
/** Ops: fehlende Standards anhängen und die gewählten Einträge (`standardsChangeKey`) auf den heutigen Stand bringen. */
|
||||
export function standardsUpdateOps(project: Project, selected: readonly string[]): CoreOp[] {
|
||||
return documentFor(project).queryRoot<CoreOp[]>("standardsUpdateOps", JSON.stringify(selected));
|
||||
}
|
||||
@@ -1202,7 +1202,8 @@ export type HatchPattern =
|
||||
| "timber"
|
||||
| "earth"
|
||||
| "gravel"
|
||||
| "stone";
|
||||
| "stone"
|
||||
| "dots";
|
||||
|
||||
/** Eine wiederverwendbare Schraffur (Hatch Manager). */
|
||||
export type HatchStyle = {
|
||||
|
||||
@@ -117,6 +117,7 @@ const PATTERN_CODE: Record<string, number> = {
|
||||
earth: 9,
|
||||
gravel: 10,
|
||||
stone: 11,
|
||||
dots: 12,
|
||||
};
|
||||
|
||||
/** Ein Hatch-Datensatz (auch Eingabe der Einzel-Bindungen in `glPlanHatch.ts`). */
|
||||
|
||||
@@ -57,7 +57,7 @@ import {
|
||||
PEN_FALLBACK_COLOR,
|
||||
PEN_FALLBACK_WEIGHT,
|
||||
} from "../model/penSets";
|
||||
import { standardsMergeCounts, standardsMergeOps } from "../model/standards";
|
||||
import { standardsMergeCounts, standardsMergeOps, standardsUpdateOps } from "../model/standards";
|
||||
import { reorderByIds } from "../model/reorder";
|
||||
import { transformMutation } from "../tools/transform";
|
||||
import type { CopyMode, TransformOp, TransformSelection } from "../tools/transform";
|
||||
@@ -185,6 +185,8 @@ export interface ProjectSlice {
|
||||
seedStandardPenSet: () => void;
|
||||
/** Ergänzt die fehlenden SIA-400-Standards (Baustoffe, Schraffuren, Linientypen, Aufbauten; [100]–[102]). */
|
||||
loadStandards: () => void;
|
||||
/** „Standards aktualisieren" ([109]): ergänzt Fehlendes und bringt die gewählten Standard-Einträge (`"<Liste>:<id>"`) auf den heutigen Stand; ein Undo-Schritt. */
|
||||
updateStandards: (selected: string[]) => void;
|
||||
|
||||
// ── Benutzerdefinierte Farbpaletten (s. model/types.ts::CustomPalette) ────
|
||||
addCustomPalette: () => void;
|
||||
@@ -1036,6 +1038,12 @@ export function createProjectSlice(
|
||||
get().notify(parts.length ? t("resources.loadStandards.added", { list: parts.join(", ") }) : t("resources.loadStandards.none"), "info");
|
||||
},
|
||||
|
||||
updateStandards: (selected) => {
|
||||
const ops = standardsUpdateOps(get().project, selected);
|
||||
if (ops.length) applyChange(ops);
|
||||
get().notify(t("resources.updateStandards.done", { n: selected.length }), "info");
|
||||
},
|
||||
|
||||
addCustomPalette: () =>
|
||||
applyChange(
|
||||
addItems("customPalettes", [{ id: `palette-${Date.now()}`, name: t("default.customPaletteName"), colors: [] }]),
|
||||
|
||||
@@ -114,6 +114,7 @@ export function useProjectActions(
|
||||
const patchPenSetWeight = useStore((s) => s.patchPenSetWeight);
|
||||
const seedStandardPenSet = useStore((s) => s.seedStandardPenSet);
|
||||
const loadStandards = useStore((s) => s.loadStandards);
|
||||
const updateStandards = useStore((s) => s.updateStandards);
|
||||
const addCustomPalette = useStore((s) => s.addCustomPalette);
|
||||
const renameCustomPalette = useStore((s) => s.renameCustomPalette);
|
||||
const deleteCustomPalette = useStore((s) => s.deleteCustomPalette);
|
||||
@@ -425,6 +426,7 @@ export function useProjectActions(
|
||||
patchPenSetWeight,
|
||||
seedStandardPenSet,
|
||||
loadStandards,
|
||||
updateStandards,
|
||||
addCustomPalette,
|
||||
renameCustomPalette,
|
||||
deleteCustomPalette,
|
||||
|
||||
@@ -34,6 +34,7 @@ import { EyeIcon } from "./EyeIcon";
|
||||
import { t } from "../i18n";
|
||||
import { ComponentsTab } from "./resourceManager/ComponentsTab";
|
||||
import { HatchesTab } from "./resourceManager/HatchesTab";
|
||||
import { StandardsUpdateDialog } from "./resourceManager/StandardsUpdateDialog";
|
||||
import { LinesTab } from "./resourceManager/LinesTab";
|
||||
import { CeilingStylesTab, RoofStylesTab, WallStylesTab } from "./resourceManager/LayeredStylesTab";
|
||||
import { DoorStylesTab } from "./resourceManager/DoorStylesTab";
|
||||
@@ -153,6 +154,8 @@ export interface ResourceManagerHandlers {
|
||||
onSeedStandardPenSet?: () => void;
|
||||
/** Ergänzt die fehlenden SIA-400-Standards ([100]–[102], „Standards laden"). */
|
||||
onLoadStandards?: () => void;
|
||||
/** „Standards aktualisieren" ([109]): bringt die gewählten Standard-Einträge (`"<Liste>:<id>"`) auf den heutigen Stand. */
|
||||
onUpdateStandards?: (selected: string[]) => void;
|
||||
/**
|
||||
* Farbpaletten (Tab „Paletten"): eigene Paletten verwalten + Sichtbarkeit
|
||||
* der Bänke im Farbwahl-Popover. Optional wie die Stift-Handler.
|
||||
@@ -234,6 +237,7 @@ export function ResourceManager({
|
||||
if (initialTab) setTab(initialTab);
|
||||
}, [initialTab]);
|
||||
const [rect, setRect] = useState<WindowRect>(initialRect);
|
||||
const [updateStandardsOpen, setUpdateStandardsOpen] = useState(false);
|
||||
|
||||
// Verschieben über die Kopfzeile: Cursor − linke/obere Kante festhalten und die
|
||||
// Kante der Cursorbewegung folgen lassen (Pointer-Capture hält die Geste).
|
||||
@@ -330,6 +334,16 @@ export function ResourceManager({
|
||||
{t("resources.loadStandards")}
|
||||
</button>
|
||||
)}
|
||||
{handlers.onUpdateStandards && (
|
||||
<button
|
||||
className="res-add res-update-standards"
|
||||
title={t("resources.updateStandards.hint")}
|
||||
onPointerDown={(e) => e.stopPropagation()}
|
||||
onClick={() => setUpdateStandardsOpen(true)}
|
||||
>
|
||||
{t("resources.updateStandards")}
|
||||
</button>
|
||||
)}
|
||||
{!windowed && (
|
||||
<button
|
||||
className="res-close"
|
||||
@@ -475,6 +489,14 @@ export function ResourceManager({
|
||||
)}
|
||||
</div>
|
||||
|
||||
{updateStandardsOpen && handlers.onUpdateStandards && (
|
||||
<StandardsUpdateDialog
|
||||
project={project}
|
||||
onApply={(sel) => handlers.onUpdateStandards?.(sel)}
|
||||
onClose={() => setUpdateStandardsOpen(false)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Greifer unten rechts (Größe ändern) — im eigenen OS-Fenster übernimmt
|
||||
das Betriebssystem das Grössenändern, daher windowed ohne Greifer. */}
|
||||
{!windowed && (
|
||||
|
||||
@@ -32,6 +32,7 @@ const PATTERN_OPTIONS: { value: HatchPattern; labelKey: string }[] = [
|
||||
{ value: "stone", labelKey: "pattern.stone" },
|
||||
{ value: "earth", labelKey: "pattern.earth" },
|
||||
{ value: "gravel", labelKey: "pattern.gravel" },
|
||||
{ value: "dots", labelKey: "pattern.dots" },
|
||||
{ value: "custom", labelKey: "pattern.custom" },
|
||||
];
|
||||
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
// „Standards aktualisieren" ([109]): Bestätigungs-Overlay (kein window.confirm — im Tauri-WKWebView stumm).
|
||||
// Listet die Standard-Einträge des Projekts, die von der heutigen Bibliothek abweichen, mit den betroffenen
|
||||
// Feldern. Ob ein Eintrag selbst angepasst wurde, lässt sich nicht erkennen: umbenannte Einträge sind
|
||||
// abgewählt, alle anderen vorgewählt; „Alle überschreiben" wählt alles. Regel: `core/src/standards.rs`.
|
||||
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import type { Project } from "../../model/types";
|
||||
import { standardsChangeKey, standardsUpdatePlan } from "../../model/standards";
|
||||
import { t } from "../../i18n";
|
||||
|
||||
const COLLECTION_ORDER = ["components", "hatches", "lineStyles", "wallTypes", "ceilingTypes", "roofTypes"];
|
||||
|
||||
export function StandardsUpdateDialog({
|
||||
project,
|
||||
onApply,
|
||||
onClose,
|
||||
}: {
|
||||
project: Project;
|
||||
onApply: (selected: string[]) => void;
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const plan = useMemo(() => standardsUpdatePlan(project), [project]);
|
||||
const [selected, setSelected] = useState<Set<string>>(
|
||||
() => new Set(plan.changes.filter((c) => !c.renamed).map(standardsChangeKey)),
|
||||
);
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.key === "Escape") onClose();
|
||||
};
|
||||
window.addEventListener("keydown", onKey);
|
||||
return () => window.removeEventListener("keydown", onKey);
|
||||
}, [onClose]);
|
||||
|
||||
const toggle = (key: string) =>
|
||||
setSelected((s) => {
|
||||
const n = new Set(s);
|
||||
if (n.has(key)) n.delete(key);
|
||||
else n.add(key);
|
||||
return n;
|
||||
});
|
||||
const groups = COLLECTION_ORDER.map((col) => ({ col, items: plan.changes.filter((c) => c.collection === col) })).filter((g) => g.items.length > 0);
|
||||
const nothing = plan.changes.length === 0 && plan.added === 0;
|
||||
const canApply = selected.size > 0 || plan.added > 0;
|
||||
|
||||
return createPortal(
|
||||
<div className="imp-overlay" onClick={onClose}>
|
||||
<div className="imp-dialog" role="dialog" aria-modal="true" aria-label={t("resources.updateStandards")} style={{ maxWidth: 560 }} onClick={(e) => e.stopPropagation()}>
|
||||
<header className="imp-head">
|
||||
<span className="imp-head-title">{t("resources.updateStandards")}</span>
|
||||
<button className="imp-close" onClick={onClose} aria-label={t("export.close")}>
|
||||
×
|
||||
</button>
|
||||
</header>
|
||||
<div className="imp-body" style={{ maxHeight: "60vh", overflow: "auto" }}>
|
||||
{nothing ? (
|
||||
<section className="imp-section">
|
||||
<div className="imp-section-title">{t("resources.updateStandards.none")}</div>
|
||||
</section>
|
||||
) : (
|
||||
<>
|
||||
<section className="imp-section">
|
||||
<div className="imp-section-title" style={{ fontWeight: 400 }}>
|
||||
{t("resources.updateStandards.intro")}
|
||||
</div>
|
||||
{plan.added > 0 && (
|
||||
<div className="imp-section-title" style={{ fontWeight: 400, opacity: 0.8 }}>
|
||||
{t("resources.updateStandards.added", { n: plan.added })}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
{groups.map((g) => (
|
||||
<section className="imp-section" key={g.col}>
|
||||
<div className="imp-section-title">{t(`resources.updateStandards.col.${g.col}`)}</div>
|
||||
{g.items.map((c) => {
|
||||
const key = standardsChangeKey(c);
|
||||
return (
|
||||
<label key={key} style={{ display: "flex", gap: 8, alignItems: "baseline", padding: "2px 0", cursor: "pointer" }}>
|
||||
<input type="checkbox" checked={selected.has(key)} onChange={() => toggle(key)} />
|
||||
<span>
|
||||
{c.name}
|
||||
{c.renamed && <em style={{ opacity: 0.7 }}> ({t("resources.updateStandards.renamed")})</em>}
|
||||
<span style={{ opacity: 0.6, fontSize: 11 }}> — {c.fields.map((f) => t(`resources.updateStandards.field.${f}`)).join(", ")}</span>
|
||||
</span>
|
||||
</label>
|
||||
);
|
||||
})}
|
||||
</section>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<footer className="imp-foot">
|
||||
{!nothing && plan.changes.length > 0 && (
|
||||
<>
|
||||
<button className="imp-btn" onClick={() => setSelected(new Set(plan.changes.map(standardsChangeKey)))}>
|
||||
{t("resources.updateStandards.all")}
|
||||
</button>
|
||||
<button className="imp-btn" onClick={() => setSelected(new Set())}>
|
||||
{t("resources.updateStandards.noneSelected")}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
<button className="imp-btn" onClick={onClose}>
|
||||
{t("export.cancel")}
|
||||
</button>
|
||||
{!nothing && (
|
||||
<button
|
||||
className="imp-btn primary"
|
||||
disabled={!canApply}
|
||||
onClick={() => {
|
||||
onApply([...selected]);
|
||||
onClose();
|
||||
}}
|
||||
>
|
||||
{t("resources.updateStandards.apply", { n: selected.size })}
|
||||
</button>
|
||||
)}
|
||||
</footer>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
);
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { polyUsesPattern } from "./primitives";
|
||||
import { isGeneratedPattern, polyUsesPattern } from "./primitives";
|
||||
import type { HatchRender } from "../../../plan/generatePlan/shared";
|
||||
|
||||
function hatch(over: Partial<HatchRender> = {}): HatchRender {
|
||||
@@ -43,3 +43,14 @@ describe("polyUsesPattern — gradient", () => {
|
||||
expect(polyUsesPattern(hatch({ pattern: "none" }))).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("polyUsesPattern — Kern-Generator-Muster ([109])", () => {
|
||||
it("Schicht-/Streumuster laufen über buildHatchRuns, nicht über <pattern>-Kacheln", () => {
|
||||
for (const pattern of ["insulation", "insulationHard", "insulationWave", "timber", "earth", "gravel", "stone", "dots"] as const) {
|
||||
expect(isGeneratedPattern(pattern)).toBe(true);
|
||||
expect(polyUsesPattern(hatch({ pattern }))).toBe(false);
|
||||
}
|
||||
expect(polyUsesPattern(hatch({ pattern: "diagonal" }))).toBe(true);
|
||||
expect(polyUsesPattern(hatch({ pattern: "crosshatch" }))).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -8,7 +8,7 @@ import { NO_HATCH } from "../../../core";
|
||||
import { layoutText, stampBlockLines, wrapPlainText } from "../../../text/renderHtml";
|
||||
import type { Vec2 } from "../../../model/types";
|
||||
import { quantizePen } from "../../../export/sceneToPrintSvg";
|
||||
import { buildRandomHatchRuns, zigzagPoints, motifPoints, DASH_MM_TO_M } from "../../../core";
|
||||
import { buildHatchRuns, buildRandomHatchRuns, zigzagPoints, motifPoints, DASH_MM_TO_M } from "../../../core";
|
||||
import { dashHasDot } from "../../../core";
|
||||
import { HAIRLINE_PX, PX_PER_M, mmToPx, printStrokeVb, visibleEdgeRuns } from "../../../core";
|
||||
import { dashArrayCss, fitDashToPeriod, hatchDashVb, lineDashVb } from "../../../core";
|
||||
@@ -19,13 +19,30 @@ const IMG_TILE_VB = 40;
|
||||
/** Lineare/Kreuz-Muster brauchen ein <pattern>; solid/none nicht. */
|
||||
export function needsPattern(pattern: HatchRender["pattern"]): boolean {
|
||||
return (
|
||||
pattern === "insulation" ||
|
||||
pattern === "diagonal" ||
|
||||
pattern === "crosshatch" ||
|
||||
pattern === "custom"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Muster, die der Kern-Generator als Linien/Polylinien erzeugt ([109]: Dämmschlange, Zickzack, Welle, Holzkreuz,
|
||||
* Naturstein, Erdreich, Kies, Punktfeld) — der SVG-Rückfall zeichnet sie wie GL/Druck-SVG aus
|
||||
* `buildHatchRuns` (eine Implementierung) statt als `<pattern>`-Kachel.
|
||||
*/
|
||||
export function isGeneratedPattern(pattern: HatchRender["pattern"]): boolean {
|
||||
return (
|
||||
pattern === "insulation" ||
|
||||
pattern === "insulationHard" ||
|
||||
pattern === "insulationWave" ||
|
||||
pattern === "timber" ||
|
||||
pattern === "earth" ||
|
||||
pattern === "gravel" ||
|
||||
pattern === "stone" ||
|
||||
pattern === "dots"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ob ein Polygon einen SVG-Fill-Server aus `<defs>` braucht (`<pattern>` ODER
|
||||
* `<linearGradient>`/`<radialGradient>` — beide lassen sich identisch per
|
||||
@@ -40,6 +57,7 @@ export function polyUsesPattern(h: HatchRender): boolean {
|
||||
if (h.kind === "image") return !!h.image;
|
||||
if (h.kind === "gradient") return !!h.gradient;
|
||||
if (h.lines === "random") return false;
|
||||
if (isGeneratedPattern(h.pattern)) return false;
|
||||
return needsPattern(h.pattern);
|
||||
}
|
||||
|
||||
@@ -122,37 +140,6 @@ export function HatchPattern({
|
||||
);
|
||||
}
|
||||
|
||||
if (hatch.pattern === "insulation") {
|
||||
// Weiche Zickzack-/Wellenlinie (SIA-nah). Kachel 14×10 × Maßstab.
|
||||
const w = 14 * hatch.scale;
|
||||
const h = 10 * hatch.scale;
|
||||
const my = 5 * hatch.scale;
|
||||
const qy1 = -1 * hatch.scale;
|
||||
const qy2 = 11 * hatch.scale;
|
||||
const qx1 = 3.5 * hatch.scale;
|
||||
const qx2 = 7 * hatch.scale;
|
||||
const qx3 = 10.5 * hatch.scale;
|
||||
return (
|
||||
<pattern
|
||||
id={id}
|
||||
patternUnits="userSpaceOnUse"
|
||||
width={w}
|
||||
height={h}
|
||||
patternTransform={`rotate(${hatch.angle})`}
|
||||
>
|
||||
<path
|
||||
d={`M0 ${my} Q ${qx1} ${qy1} ${qx2} ${my} Q ${qx3} ${qy2} ${w} ${my}`}
|
||||
fill="none"
|
||||
stroke={hatch.color}
|
||||
strokeWidth={sw}
|
||||
style={dashStyle(w)}
|
||||
strokeLinecap={dashCap}
|
||||
vectorEffect={vfx}
|
||||
/>
|
||||
</pattern>
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
hatch.pattern === "custom" &&
|
||||
hatch.motif &&
|
||||
@@ -570,9 +557,9 @@ export function renderPrimitive(
|
||||
// Random-Vektor-Schraffur (Kies/Splitt): Grundfüllung + deterministische
|
||||
// Streu-Striche (im MODELL-Raum erzeugt → toScreen; identischer Seed wie
|
||||
// GL/PDF) + Umriss. KEIN <pattern> (die Striche werden direkt gezeichnet).
|
||||
if (p.hatch.kind !== "image" && p.hatch.lines === "random") {
|
||||
if (p.hatch.kind !== "image" && (p.hatch.lines === "random" || isGeneratedPattern(p.hatch.pattern))) {
|
||||
const hsw = weight(p.hatch.lineWeight > 0 ? p.hatch.lineWeight : 0.13);
|
||||
const runs = buildRandomHatchRuns(p.pts, p.hatch);
|
||||
const runs = p.hatch.lines === "random" ? buildRandomHatchRuns(p.pts, p.hatch) : buildHatchRuns(p.pts, p.hatch);
|
||||
return (
|
||||
<g>
|
||||
<polygon points={pts} fill={p.fill} stroke="none" />
|
||||
|
||||
Reference in new issue
Block a user