Merge branch 'worktree-agent-a733d7bc917c3ae8e' into claude/practical-noether-1hb2s1
This commit is contained in:
14 files changed
+178
-49
No files matched your search
@@ -2778,11 +2778,23 @@ Format · [90] Versionsvergleich · [91] Assistent · [92] Speckle.
|
||||
Detailgrad-Übersteuerung, Fenster grob) angepasst. Goldens neu (Grundrisse: Blasen, Stempelzeilen; Schnitte:
|
||||
zusammengefasste Schichten; CLI-Schnitt in Tusche). Geprüft: cargo test Kern, vitest, tsc, CLI-SVG (EG
|
||||
1:100/200/500, Schnitt A-A 1:100/1:50, Ansicht Süd) in Chromium angesehen.
|
||||
Offen: Layout-Viewports (`sheet_viewports.rs`, `viewportPlan.ts`) und Präsentationsblatt zeichnen weiter „Farbig"
|
||||
(Ansicht mit Ziegelrot auf dem Blatt); Ansichtsvorlage „Präsentation" setzt `mono: false`; dünne
|
||||
Trittschalldämmung (2–3 cm) bleibt in 1:100 als dichter Zickzack-Balken; Stempel-Breite nur geschätzt (keine
|
||||
Schriftmetrik), L-förmige Räume über die Bounding-Box; Stifte (`penSets`) nicht angepasst; Fenster grob ohne
|
||||
Brüstungs-/Sturzlinie. Nur Linux/CLI-SVG + Chromium geprüft, nicht in der Tauri-App (Bildschirm nicht angesehen). · M
|
||||
(6.11., Teil 4) **Blätter in Tusche:** Layout-Viewports (Blatt, PDF/Druck, Präsentationsblatt; Kern
|
||||
`sheet_viewports::snapshot_mono` für Fang/DXF, TS `snapshotMono` → `viewportLevelPlan(…, mono)`) zeichnen Grundriss,
|
||||
Schnitt und Ansicht in Tusche; Farbe nur, wenn die Ansichtsvorlage des Ausschnitts `mono: false` setzt. Vorlage
|
||||
„Präsentation" jetzt `mono: true` (Feld „Tusche" in der Vorlage abwählen = farbig; bestehende Projekte mit der
|
||||
alten Vorlage `mono: false` bleiben farbig). Eigene Blatt-Zeichnung (Planrahmen, Logos) unverändert. **Anzeige**
|
||||
heisst in Kopfleiste und Vorlagen „Tusche" / „Ink" (Wert `mono` unverändert). **Dünne Dämmung:** Dämmschichten
|
||||
(Schlange/Zickzack/Welle) unter 0.5 mm Papierdicke ab 1:75 ohne Muster, nur Füllung + Fuge
|
||||
(`section::plain_thin_insulation`; 4 cm Trittschall in 1:100), 1:50 mit Muster. **Stifte:** Standardpalette mit
|
||||
Stärken der Rangfolge 0.25/0.18/0.13/0.1/0.02 (`pens::PEN_WEIGHT_STEPS`; je Farbton dunkel = stark, Schwarz 0.25)
|
||||
statt überall 0.18 — nur neu angelegte Stiftsätze, bestehende behalten ihre Stärken. Fenster grob bleibt bei zwei
|
||||
Strichen (Wunsch Maintainer). Tests: `viewport_tusche_ausser_vorlage_farbig`, `duenne_daemmung_ohne_muster_ab_1_100`,
|
||||
Palette (Rust + `penSets.test.ts`), `viewportPlan.test.ts` (keine bunten Farben, Farbe auf Wunsch). Goldens
|
||||
unverändert. Geprüft: cargo test Kern, vitest, tsc, e2e presentationSheet/layoutSheet/publish/viewTemplates,
|
||||
Präsentationsblatt (Browser) und CLI-Schnitt 1:100 vorher/nachher angesehen.
|
||||
Offen: Stempel-Breite nur geschätzt (keine Schriftmetrik), L-förmige Räume über die Bounding-Box; Präsentations-
|
||||
Dialog ohne eigenen Farb-Schalter (nur über die Vorlage); dünne Dämmung im Grundriss nicht behandelt (Wände selten
|
||||
< 5 cm). Nur Linux/CLI-SVG + Chromium geprüft, nicht in der Tauri-App. · M
|
||||
Höhenlinien). Offen: dünne Schichten (Putz, Parkett) laufen in 1:100 zu einem Balken zusammen (Detailgrad sollte
|
||||
sie zusammenfassen); Achsen laufen in Ansicht/Grundriss durch das Gebäude; Raumstempel farbig statt schwarz im
|
||||
Druck ohne Schwarz-Weiss; Schatten im EG-Grundriss überdeckt Bemassung; eigene Stempel (`Room.stamp`) behalten in
|
||||
|
||||
+31
-17
@@ -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]
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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:?}");
|
||||
|
||||
@@ -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}}),
|
||||
|
||||
@@ -246,6 +246,7 @@ export {
|
||||
sectionUAxisModel,
|
||||
} from "../plan/toSection";
|
||||
export { viewportLevelPlan } from "../plan/viewportPlan";
|
||||
export { snapshotMono } from "../plan/viewportPlan";
|
||||
|
||||
export {
|
||||
TRUCK_MESH_READY_EVENT,
|
||||
|
||||
@@ -17,7 +17,7 @@ import { t } from "../i18n/translate";
|
||||
import { legendPlan, legendPrintSvg } from "./legendSvg";
|
||||
import { categoryLayerGroups, enablePdfLayers, type PdfLayers } from "./pdfLayers";
|
||||
import { generatePlan, type Plan } from "../plan/generatePlan";
|
||||
import { viewportLevelPlan } from "../plan/viewportPlan";
|
||||
import { snapshotMono, viewportLevelPlan } from "../plan/viewportPlan";
|
||||
import { planToPrintSvg } from "./planToPrintSvg";
|
||||
import { drawTablesPdf, sheetTables } from "./sheetTable";
|
||||
import { collectVisibleCodes } from "../model/types";
|
||||
@@ -169,7 +169,7 @@ async function renderPage(
|
||||
// nach Massstab) — wie ViewportPlan in LayoutSheet.tsx, sonst wiche das PDF von der Vorschau ab.
|
||||
const scaleN = ctx.scaleOverride ?? resolveViewportScale(vp, snap);
|
||||
// Geschoss/Zeichnung, Schnitt oder Ansicht ([115]) — wie ViewportPlanSvg, im Druck-Modus.
|
||||
const planOf = (visible: Set<string>) => viewportLevelPlan(project, snap.activeLevelId, visible, snap.detail, scaleN, true);
|
||||
const planOf = (visible: Set<string>) => viewportLevelPlan(project, snap.activeLevelId, visible, snap.detail, scaleN, true, snapshotMono(project, snap));
|
||||
const draw = async (plan: Plan, transparent: boolean, bounds?: Plan["bounds"]) => {
|
||||
const print = planToPrintSvg(plan, { scaleDenominator: scaleN, pageWidthMm: vp.widthMm, pageHeightMm: vp.heightMm, transparent, bounds });
|
||||
await doc.svg(print.svg, { x: vp.xMm, y: vp.yMm, width: vp.widthMm, height: vp.heightMm });
|
||||
|
||||
+2
-2
@@ -91,7 +91,7 @@ export const de = {
|
||||
"display.style.group": "Darstellungsart",
|
||||
"display.style.hint": "Darstellungsart der aktiven Ansicht",
|
||||
"display.style.color": "Farbig",
|
||||
"display.style.mono": "Schwarz-Weiss",
|
||||
"display.style.mono": "Tusche",
|
||||
"display.style.shaded": "Schattiert",
|
||||
"display.style.shadedEdges": "Schattiert mit Kanten",
|
||||
"display.style.white": "Weiss",
|
||||
@@ -1145,7 +1145,7 @@ export const de = {
|
||||
"resources.viewTemplates.detail": "Detailgrad",
|
||||
"resources.viewTemplates.scale": "Massstab 1:",
|
||||
"resources.viewTemplates.displayMode": "Darstellungsmodus",
|
||||
"resources.viewTemplates.mono": "Schwarz-Weiss",
|
||||
"resources.viewTemplates.mono": "Tusche",
|
||||
"resources.viewTemplates.shadows": "Schatten",
|
||||
"resources.viewTemplates.hiddenLines": "Verdeckte Kanten",
|
||||
"resources.viewTemplates.sketch": "Skizzenstil",
|
||||
|
||||
+2
-2
@@ -90,7 +90,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"display.style.group": "Display style",
|
||||
"display.style.hint": "Display style of the active view",
|
||||
"display.style.color": "Color",
|
||||
"display.style.mono": "Black & white",
|
||||
"display.style.mono": "Ink",
|
||||
"display.style.shaded": "Shaded",
|
||||
"display.style.shadedEdges": "Shaded with edges",
|
||||
"display.style.white": "White",
|
||||
@@ -1139,7 +1139,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"resources.viewTemplates.detail": "Detail level",
|
||||
"resources.viewTemplates.scale": "Scale 1:",
|
||||
"resources.viewTemplates.displayMode": "Display mode",
|
||||
"resources.viewTemplates.mono": "Black and white",
|
||||
"resources.viewTemplates.mono": "Ink",
|
||||
"resources.viewTemplates.shadows": "Shadows",
|
||||
"resources.viewTemplates.hiddenLines": "Hidden lines",
|
||||
"resources.viewTemplates.sketch": "Sketch style",
|
||||
|
||||
@@ -309,8 +309,10 @@ describe("Standardpalette (Kern)", () => {
|
||||
expect(new Set(pens.map((p) => p.id)).size).toBe(255);
|
||||
for (let i = 1; i <= 255; i++) {
|
||||
expect(styles[String(i)].color).toMatch(/^#[0-9a-f]{6}$/);
|
||||
expect(styles[String(i)].weight).toBe(PEN_FALLBACK_WEIGHT);
|
||||
// [140] Strichstärken nach der Plan-Rangfolge (0.25 / 0.18 / 0.13 / 0.1 / 0.02).
|
||||
expect([0.25, 0.18, 0.13, 0.1, 0.02]).toContain(styles[String(i)].weight);
|
||||
}
|
||||
expect(styles["7"].weight).toBe(0.25);
|
||||
});
|
||||
|
||||
it("nutzt für 1-9 die klassischen Grundfarben (Rot/Gelb/.../Grau)", () => {
|
||||
|
||||
@@ -97,7 +97,7 @@ export function presentationTemplate(project: Project): { template: ViewTemplate
|
||||
if (own) return { template: own, isNew: false };
|
||||
const std = (addedItems(standardsMergeOps(project), "viewTemplates") as ViewTemplate[]).find((t) => t.id === PRESENTATION_TEMPLATE_ID);
|
||||
return {
|
||||
template: std ?? { id: PRESENTATION_TEMPLATE_ID, name: "Präsentation", detail: "mittel", mono: false, shadows: true, hiddenLines: false },
|
||||
template: std ?? { id: PRESENTATION_TEMPLATE_ID, name: "Präsentation", detail: "mittel", mono: true, shadows: true, hiddenLines: false },
|
||||
isNew: true,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest";
|
||||
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
|
||||
import { collectVisibleCodes } from "../model/types";
|
||||
import { generatePlan } from "./generatePlan";
|
||||
import { viewportLevelPlan } from "./viewportPlan";
|
||||
import { snapshotMono, viewportLevelPlan } from "./viewportPlan";
|
||||
|
||||
const p = buildComplexSampleProject();
|
||||
const codes = collectVisibleCodes(p.layers);
|
||||
@@ -23,7 +23,30 @@ describe("viewportLevelPlan", () => {
|
||||
|
||||
it("Geschoss: wie bisher generatePlan", async () => {
|
||||
const plan = await viewportLevelPlan(p, "eg", codes, "mittel", 100);
|
||||
expect(plan.primitives.length).toBe(generatePlan(p, "eg", codes, undefined, "mittel", false, false, true, 100).primitives.length);
|
||||
expect(plan.primitives.length).toBe(generatePlan(p, "eg", codes, undefined, "mittel", false, true, true, 100).primitives.length);
|
||||
});
|
||||
|
||||
// [140] Blatt und PDF folgen dem Tusche-Standard der App: keine bunten Farben (Ziegelrot …), ausser
|
||||
// die Vorlage des Ausschnitts wählt Farbe (`mono: false`).
|
||||
it("Tusche als Standard, Farbe nur auf Wunsch", async () => {
|
||||
const bunt = (plan: { primitives: unknown[] }) => {
|
||||
const hex = JSON.stringify(plan.primitives).match(/#[0-9a-fA-F]{6}\b/g) ?? [];
|
||||
return hex.filter((h) => {
|
||||
const [r, g, b] = [1, 3, 5].map((i) => parseInt(h.slice(i, i + 2), 16));
|
||||
return Math.max(r, g, b) - Math.min(r, g, b) > 24;
|
||||
});
|
||||
};
|
||||
expect(bunt(await viewportLevelPlan(p, "ansicht-sued", codes, "mittel", 100))).toEqual([]);
|
||||
expect(bunt(await viewportLevelPlan(p, "ansicht-sued", codes, "mittel", 100, false, false)).length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("snapshotMono: Vorlage mit mono: false = farbig, sonst Tusche", () => {
|
||||
const q = { ...p, viewTemplates: [{ id: "f", name: "F", mono: false }, { id: "t", name: "T", mono: true }] };
|
||||
const snap = { templateId: undefined as string | undefined };
|
||||
expect(snapshotMono(q, snap)).toBe(true);
|
||||
expect(snapshotMono(q, { templateId: "f" })).toBe(false);
|
||||
expect(snapshotMono(q, { templateId: "t" })).toBe(true);
|
||||
expect(snapshotMono(q, { templateId: "weg" })).toBe(true);
|
||||
});
|
||||
|
||||
it("unbekannte Ebene: leer, kein Fehler", async () => {
|
||||
|
||||
@@ -11,11 +11,20 @@ import { computeSection, generateSectionPlan } from "./toSection";
|
||||
import { generateElevationPlan } from "./toElevation";
|
||||
import { levelMarkerPrimitives, levelMarksEnabled } from "./levelMarkers";
|
||||
|
||||
/**
|
||||
* [140] Tusche (Schwarz-Weiss) für einen Viewport: Standard wie in der App; Farbe nur, wenn die
|
||||
* Ansichtsvorlage des Ausschnitts ausdrücklich `mono: false` setzt (Kern: `sheet_viewports::snapshot_mono`).
|
||||
*/
|
||||
export function snapshotMono(project: Pick<Project, "viewTemplates">, snap: { templateId?: string | null }): boolean {
|
||||
if (!snap.templateId) return true;
|
||||
return project.viewTemplates?.find((t) => t.id === snap.templateId)?.mono !== false;
|
||||
}
|
||||
|
||||
const EMPTY: Plan = { primitives: [], bounds: { minX: 0, minY: 0, maxX: 1, maxY: 1 } };
|
||||
|
||||
/**
|
||||
* Plan der Ebene `levelId` für einen Layout-Viewport bzw. dessen PDF (`forPrint`: `noPrint`-Elemente
|
||||
* entfallen). Schnitte brauchen die truck-Körper und sind darum asynchron.
|
||||
* entfallen; `mono`: Tusche, s. {@link snapshotMono}). Schnitte brauchen die truck-Körper und sind darum asynchron.
|
||||
*/
|
||||
export async function viewportLevelPlan(
|
||||
project: Project,
|
||||
@@ -24,23 +33,24 @@ export async function viewportLevelPlan(
|
||||
detail: DetailLevel | undefined,
|
||||
scaleDenominator: number,
|
||||
forPrint = false,
|
||||
mono = true,
|
||||
): Promise<Plan> {
|
||||
const level = project.drawingLevels.find((l) => l.id === levelId);
|
||||
if (!level) return EMPTY;
|
||||
if (level.kind !== "section" && level.kind !== "elevation") {
|
||||
return generatePlan(project, levelId, visibleCodes, undefined, detail, false, false, true, scaleDenominator, forPrint);
|
||||
return generatePlan(project, levelId, visibleCodes, undefined, detail, false, mono, true, scaleDenominator, forPrint);
|
||||
}
|
||||
let raw: Plan | null;
|
||||
if (level.kind === "section") {
|
||||
const out = await computeSection(project, level);
|
||||
raw = out
|
||||
? generateSectionPlan(out, false, { hiddenLines: level.hiddenLines, visibleCodes, openings: true, scaleDenominator })
|
||||
? generateSectionPlan(out, mono, { hiddenLines: level.hiddenLines, visibleCodes, openings: true, scaleDenominator })
|
||||
: null;
|
||||
} else {
|
||||
raw = generateElevationPlan(project, level, { visibleCodes, scaleDenominator });
|
||||
raw = generateElevationPlan(project, level, { visibleCodes, scaleDenominator, mono });
|
||||
}
|
||||
if (!raw || raw.primitives.length === 0) return EMPTY;
|
||||
const own = generatePlan(project, level.id, visibleCodes, undefined, detail, false, false, false, scaleDenominator, forPrint);
|
||||
const own = generatePlan(project, level.id, visibleCodes, undefined, detail, false, mono, false, scaleDenominator, forPrint);
|
||||
const marks = levelMarksEnabled(level) ? levelMarkerPrimitives(project, raw.bounds) : [];
|
||||
const b = { ...raw.bounds };
|
||||
const grow = (x: number, y: number) => {
|
||||
|
||||
@@ -25,7 +25,7 @@ import type {
|
||||
Project,
|
||||
Vec2,
|
||||
} from "../model/types";
|
||||
import { createTable, PX_PER_M, sheetTables, TABLE_SOURCES, tableSourceLabel, viewportLevelPlan } from "../core";
|
||||
import { createTable, PX_PER_M, sheetTables, TABLE_SOURCES, snapshotMono, tableSourceLabel, viewportLevelPlan } from "../core";
|
||||
import type { TableOut } from "../core";
|
||||
import { SheetTableHud } from "./SheetTableHud";
|
||||
import { planToPrintSvg } from "../export/planToPrintSvg";
|
||||
@@ -89,7 +89,7 @@ export function ViewportPlanSvg({
|
||||
// Massstab ZUERST: er geht in die Plan-Erzeugung ein (Bemassung in Papier-mm, s. model/dimension.ts).
|
||||
const scaleN = resolveViewportScale(viewport, snap);
|
||||
// Geschoss/Zeichnung wie bisher; Schnitt/Ansicht über die abgeleitete Projektion ([115], Schnitt asynchron).
|
||||
void viewportLevelPlan(project, snap.activeLevelId, codes, snap.detail, scaleN)
|
||||
void viewportLevelPlan(project, snap.activeLevelId, codes, snap.detail, scaleN, false, snapshotMono(project, snap))
|
||||
.then((plan) => {
|
||||
if (disposed) return;
|
||||
const print = planToPrintSvg(plan, {
|
||||
|
||||
Reference in new issue
Block a user