[149] Bäume: Auswahlrechteck, Gruppen, Art-Beschriftung im Plan, Schatten nicht doppelt
Bäume im Fenster/Kreuzen; Group.treeIds (Rust-Modell, optional) samt Mitgliedschaft im Kern; Feld Tree.showLabel (Art-Name rechts neben dem Stamm, Tusche, Schrift wie die Stempel-Zusatzzeile); Kreis der Baum-Ebene am Ort eines Baum-Objekts wirft keinen zweiten Schatten.
This commit is contained in:
19 files changed
+203
-11
No files matched your search
@@ -3317,6 +3317,20 @@ Format · [90] Versionsvergleich · [91] Assistent · [92] Speckle.
|
||||
nicht im Auswahlrechteck; keine Art-Beschriftung im Plan; Krone im Schatten als konvexe Hülle; Schnitt durch die Krone zeigt die ganze Silhouette (kein Schnittbild); Fuss
|
||||
am Gelände der Stammmitte (Hang unter der Krone nicht berücksichtigt); Kreise der Ebene 13 zusätzlich zum Baum-Objekt
|
||||
werfen weiter Schatten (doppelt, wenn beide gezeichnet sind). · M
|
||||
(6.11., Reste) **Auswahlrechteck:** Bäume im Fenster/Kreuzen (Kronen-Pickfläche, `PlanPickIndex.marquee
|
||||
("contextObjectId")` → `MarqueeSelection.treeIds`). **Gruppierbar:** `Group.treeIds` (Rust-Modell, optional — ältere
|
||||
Dateien unverändert), Kern `groups::Membership.tree_ids` (transitiv, sichtbare Gruppe, Erweitern), TS
|
||||
`GroupMembership.treeIds` (Gruppieren/Auflösen, Klick und Rahmen erweitern auf die Gruppe, Isolation dimmt Bäume
|
||||
ausserhalb über `@tree:`), Objekt-Sperre `treeIds`, Projekt-Prüfung (`project_refs`). **Beschriftung:** neues Feld
|
||||
`Tree.showLabel` („Beschriftung zeigen“ in der Objekt-Info): Art-Name rechts neben dem Stamm (1 mm Papier Abstand),
|
||||
Tusche, Schrift wie die Zusatzzeile des Raumstempels (0.8 × 10 pt, ab 1:200 0.8 × 7 pt; `plan/trees.rs::tree_label`).
|
||||
**Schatten nicht doppelt:** ein Kreis der Baum-Ebene, dessen Mitte höchstens eine halbe Kreisbreite (mind. 0.5 m)
|
||||
vom Stamm eines Baum-Objekts liegt, wirft keinen Schatten mehr (`sun::circle_is_tree_object`). Tests:
|
||||
`groups::baeume_in_gruppen`, `plan::trees::beschriftung_mit_art_name`, `sun::kreis_am_baum_objekt_nicht_doppelt`,
|
||||
vitest `groupActions.test.ts` (Bäume in Gruppen). Geprüft: cargo test Kern, tsc, vitest, CLI-SVG Musterhaus komplex
|
||||
EG 1:100 mit Baum-Objekten samt Beschriftung in Chromium. Offen: Rahmen/Gruppen nicht per e2e und nicht in der
|
||||
Tauri-App geprüft; Beschriftung fest rechts vom Stamm (kein Ausweichen, kein Griff); 3D-Klick erweitert nicht auf
|
||||
die Gruppe; Krone im Schatten als konvexe Hülle; Schnitt durch die Krone zeigt die ganze Silhouette.
|
||||
- ◐ **[68] Baugrube / Geländebearbeitung.** (30.10.) Kontext-Objekt `excavation` (Rust-Modell, `ContextObject`):
|
||||
Sohle (`outline`, `bottom` m ±0.00), Böschung `slope` (Standard 45°, je Kante `edgeSlopes`), Schüttung `fillSlope`
|
||||
(33.7°), Bermen `bermWidth`/`bermHeight`. Neues Gelände = clamp(t, b − d·tan β, b + H(d)) mit d = Abstand zum
|
||||
|
||||
@@ -19,10 +19,12 @@ pub struct Membership {
|
||||
pub column_ids: Vec<String>,
|
||||
pub roof_ids: Vec<String>,
|
||||
pub opening_ids: Vec<String>,
|
||||
/// [149] Bäume.
|
||||
pub tree_ids: Vec<String>,
|
||||
}
|
||||
|
||||
/// Elementart (`MemberKind` in TS: `"wallIds"` …).
|
||||
pub const KINDS: [&str; 8] = ["wallIds", "drawingIds", "ceilingIds", "roomIds", "stairIds", "columnIds", "roofIds", "openingIds"];
|
||||
pub const KINDS: [&str; 9] = ["wallIds", "drawingIds", "ceilingIds", "roomIds", "stairIds", "columnIds", "roofIds", "openingIds", "treeIds"];
|
||||
|
||||
impl Membership {
|
||||
pub fn list(&self, kind: &str) -> Option<&Vec<String>> {
|
||||
@@ -35,6 +37,7 @@ impl Membership {
|
||||
"columnIds" => &self.column_ids,
|
||||
"roofIds" => &self.roof_ids,
|
||||
"openingIds" => &self.opening_ids,
|
||||
"treeIds" => &self.tree_ids,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
@@ -49,6 +52,7 @@ impl Membership {
|
||||
"columnIds" => &mut self.column_ids,
|
||||
"roofIds" => &mut self.roof_ids,
|
||||
"openingIds" => &mut self.opening_ids,
|
||||
"treeIds" => &mut self.tree_ids,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
@@ -63,6 +67,7 @@ impl Membership {
|
||||
column_ids: g.column_ids.clone(),
|
||||
roof_ids: g.roof_ids.clone(),
|
||||
opening_ids: g.opening_ids.clone(),
|
||||
tree_ids: g.tree_ids.clone().unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,4 +195,18 @@ mod tests {
|
||||
assert_eq!(e.wall_ids, ["w5", "w2", "w1"]);
|
||||
assert_eq!(ids, ["outer"]);
|
||||
}
|
||||
|
||||
/// [149] Bäume gehören zu Gruppen wie die übrigen Arten (Feld fehlt in älteren Dateien).
|
||||
#[test]
|
||||
fn baeume_in_gruppen() {
|
||||
let mut t = g("t", &["w1"], &[]);
|
||||
t["treeIds"] = json!(["b1", "b2"]);
|
||||
let p = project(json!([t, g("alt", &["w2"], &[])]));
|
||||
assert_eq!(transitive_membership(&p, "t").tree_ids, ["b1", "b2"]);
|
||||
assert!(transitive_membership(&p, "alt").tree_ids.is_empty());
|
||||
assert_eq!(containing_group_id(&p, "treeIds", "b2", &[]), Some("t".into()));
|
||||
let raw = Membership { tree_ids: vec!["b1".into()], ..Default::default() };
|
||||
let (e, ids) = expand_to_groups(&p, &raw, &[]);
|
||||
assert_eq!((e.wall_ids, e.tree_ids, ids), (vec!["w1".to_string()], vec!["b1".to_string(), "b2".to_string()], vec!["t".to_string()]));
|
||||
}
|
||||
}
|
||||
@@ -3974,6 +3974,10 @@ pub struct Tree {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub species: Option<String>,
|
||||
/// [149] Art-Name als Beschriftung im Grundriss zeigen (nahe am Stamm; Vorgabe aus).
|
||||
#[serde(rename = "showLabel", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub show_label: Option<bool>,
|
||||
/// Höhenversatz des Fusses gegenüber Gelände bzw. Geschoss-UK (m, Vorgabe 0).
|
||||
#[serde(rename = "baseOffset", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
@@ -4014,6 +4018,10 @@ pub struct Group {
|
||||
pub roof_ids: Vec<String>,
|
||||
#[serde(rename = "openingIds")]
|
||||
pub opening_ids: Vec<String>,
|
||||
/// [149] Bäume (fehlt in älteren Dateien).
|
||||
#[serde(rename = "treeIds", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub tree_ids: Option<Vec<String>>,
|
||||
/// Verschachtelte Gruppen (diese Gruppe enthält andere Gruppen als Ganzes).
|
||||
#[serde(rename = "groupIds")]
|
||||
pub group_ids: Vec<String>,
|
||||
|
||||
@@ -23,10 +23,10 @@ const COLUMN_FALLBACK_FILL: &str = "#3a3f47";
|
||||
/// Alpha-Suffix der (unsichtbaren) Raumfüllung.
|
||||
const ROOM_FILL_ALPHA: &str = "00";
|
||||
/// Basis-Schriftgrösse des Raumstempels (pt).
|
||||
const ROOM_STAMP_PT: f64 = 10.0;
|
||||
pub(super) const ROOM_STAMP_PT: f64 = 10.0;
|
||||
/// [140] Raumstempel ab 1:200 (2.5 mm statt 3.5 mm, ohne SIA-Zeile): kleine Räume überlappen sonst.
|
||||
const ROOM_STAMP_SMALL_PT: f64 = 7.0;
|
||||
const ROOM_STAMP_SMALL_FROM: f64 = 200.0;
|
||||
pub(super) const ROOM_STAMP_SMALL_PT: f64 = 7.0;
|
||||
pub(super) const ROOM_STAMP_SMALL_FROM: f64 = 200.0;
|
||||
const NAME_PT: f64 = 12.0;
|
||||
const NUMBER_PT: f64 = 9.0;
|
||||
const LINE2_PT: f64 = 9.0;
|
||||
@@ -689,7 +689,7 @@ const STAMP_PAD_MM: f64 = 0.5;
|
||||
|
||||
/// [140] Ausmass des Stempels in Metern bei 1:`scale` (echte Schriftmetrik, `text_layout::stamp_block_size`)
|
||||
/// samt Rand.
|
||||
fn stamp_size_m(doc: &RichTextDoc, extra: &[StampLine], pt: f64, scale: f64) -> (f64, f64) {
|
||||
pub(super) fn stamp_size_m(doc: &RichTextDoc, extra: &[StampLine], pt: f64, scale: f64) -> (f64, f64) {
|
||||
let rows: Vec<(&str, crate::text_layout::LineAlign)> = extra.iter().map(|l| (l.text.as_str(), crate::text_layout::LineAlign::of(Some(l.align)))).collect();
|
||||
let (w, h) = crate::text_layout::stamp_block_size(doc, &rows, pt, PT_MM * scale / 1000.0);
|
||||
let pad = 2.0 * STAMP_PAD_MM * scale / 1000.0;
|
||||
|
||||
@@ -125,10 +125,36 @@ pub(super) fn plan_trees(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
if t.floor_id != c.a.floor || !c.vis(&t.category_code, &t.id) {
|
||||
continue;
|
||||
}
|
||||
out.extend(tree_symbol(t, &g, c.cat(&t.category_code), Some(c.greyed(&t.category_code))));
|
||||
let greyed = Some(c.greyed(&t.category_code));
|
||||
out.extend(tree_symbol(t, &g, c.cat(&t.category_code), greyed));
|
||||
if let Some(l) = tree_label(t, &g, c.a.scale, greyed) {
|
||||
out.push(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// [149] Schrift der Baum-Beschriftung (pt): wie die Zusatzzeile des Raumstempels (0.8 × Stempelschrift,
|
||||
/// ab 1:200 die kleine Stempelschrift).
|
||||
pub fn label_pt(scale: f64) -> f64 {
|
||||
let base = if scale >= super::domains::ROOM_STAMP_SMALL_FROM { super::domains::ROOM_STAMP_SMALL_PT } else { super::domains::ROOM_STAMP_PT };
|
||||
0.8 * base
|
||||
}
|
||||
|
||||
/// [149] Beschriftung mit dem Art-Namen (`showLabel` und `species` gesetzt): Tusche, rechts neben dem Stamm
|
||||
/// (linker Rand 1 mm Papier neben dem Stamm, auf Stammhöhe zentriert).
|
||||
pub fn tree_label(t: &Tree, g: &TreeGeom, scale: f64, greyed: Option<bool>) -> Option<Primitive> {
|
||||
let name = t.species.as_deref().map(str::trim).filter(|s| !s.is_empty())?;
|
||||
if t.show_label != Some(true) || !(scale > 0.0) || !scale.is_finite() {
|
||||
return None;
|
||||
}
|
||||
let doc = super::domains::doc_from_text(name);
|
||||
let pt = label_pt(scale);
|
||||
let (w, _) = crate::text_layout::stamp_block_size(&doc, &[], pt, crate::text_layout::PT_TO_MM * scale / 1000.0);
|
||||
let gap = 1.0 * scale / 1000.0;
|
||||
let at = v(g.c[0] + g.trunk_r + gap + w / 2.0, g.c[1]);
|
||||
Some(Primitive::Text { at, doc, extra_lines: vec![], base_pt: pt, color: MONO_INK.into(), room_id: None, greyed, opacity: None })
|
||||
}
|
||||
|
||||
/// Planzeichen eines Baums (Grundriss): Pick-Fläche, Kronenumriss, Stamm, ggf. Kreuz.
|
||||
pub fn tree_symbol(t: &Tree, g: &TreeGeom, cat: Option<&LayerCategory>, greyed: Option<bool>) -> Vec<Primitive> {
|
||||
let color = ink(t, cat);
|
||||
@@ -245,6 +271,27 @@ mod tests {
|
||||
plan_domains(p, &a).unwrap().columns
|
||||
}
|
||||
|
||||
/// [149] Art-Name als Beschriftung: nur mit `showLabel` und Art, Tusche, rechts neben dem Stamm, Schrift wie
|
||||
/// die Zusatzzeile des Raumstempels.
|
||||
#[test]
|
||||
fn beschriftung_mit_art_name() {
|
||||
let mut t = tree("a", 0.0, "new", "deciduous");
|
||||
t["species"] = serde_json::json!("Quercus robur");
|
||||
let texts = |p: &Project| plan(p, &["13"]).into_iter().filter(|q| matches!(q, Primitive::Text { .. })).collect::<Vec<_>>();
|
||||
assert!(texts(&project(serde_json::json!([t.clone()]))).is_empty(), "ohne showLabel keine Beschriftung");
|
||||
t["showLabel"] = serde_json::json!(true);
|
||||
let got = texts(&project(serde_json::json!([t.clone()])));
|
||||
assert_eq!(got.len(), 1);
|
||||
let Primitive::Text { at, doc, base_pt, color, room_id, .. } = &got[0] else { unreachable!() };
|
||||
assert_eq!(crate::text_layout::plain_text(doc), "Quercus robur");
|
||||
assert_eq!((color.as_str(), room_id.is_none()), (MONO_INK, true));
|
||||
assert!((base_pt - 8.0).abs() < 1e-9, "1:100: 0.8 × 10 pt");
|
||||
assert!(at.x > 0.2 && at.x < 3.0 && at.y.abs() < 1e-9, "rechts neben dem Stamm: {at:?}");
|
||||
assert!((label_pt(200.0) - 5.6).abs() < 1e-9);
|
||||
t["species"] = serde_json::json!(" ");
|
||||
assert!(texts(&project(serde_json::json!([t]))).is_empty(), "ohne Art keine Beschriftung");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn planzeichen_nach_bestand_und_laub() {
|
||||
let p = project(serde_json::json!([tree("a", 0.0, "existing", "deciduous"), tree("b", 10.0, "new", "conifer"), tree("c", 20.0, "remove", "deciduous")]));
|
||||
|
||||
@@ -154,7 +154,7 @@ pub fn dangling_refs(p: &Project) -> Vec<String> {
|
||||
// Gruppen: Mitglieder und Zyklen.
|
||||
let groups = p.groups.as_deref().unwrap_or(&[]);
|
||||
let group_ids = ids(groups, |g| g.id.as_str());
|
||||
let members: [(&str, HashSet<&str>); 7] = [
|
||||
let members: [(&str, HashSet<&str>); 8] = [
|
||||
("Zeichnung", ids(&p.drawings2d, |d| d.id.as_str())),
|
||||
("Decke", ids(p.ceilings.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
|
||||
("Raum", ids(p.rooms.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
|
||||
@@ -162,12 +162,14 @@ pub fn dangling_refs(p: &Project) -> Vec<String> {
|
||||
("Stütze", ids(p.columns.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
|
||||
("Dach", ids(p.roofs.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
|
||||
("Öffnung", ids(p.openings.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
|
||||
("Baum", ids(p.trees.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
|
||||
];
|
||||
for g in groups {
|
||||
for w in &g.wall_ids {
|
||||
miss(&mut out, "Gruppe", &g.id, "Wand", w, &walls);
|
||||
}
|
||||
let lists = [&g.drawing_ids, &g.ceiling_ids, &g.room_ids, &g.stair_ids, &g.column_ids, &g.roof_ids, &g.opening_ids];
|
||||
let no_trees = Vec::new();
|
||||
let lists = [&g.drawing_ids, &g.ceiling_ids, &g.room_ids, &g.stair_ids, &g.column_ids, &g.roof_ids, &g.opening_ids, g.tree_ids.as_ref().unwrap_or(&no_trees)];
|
||||
for (list, (kind, known)) in lists.into_iter().zip(&members) {
|
||||
for id in list {
|
||||
miss(&mut out, "Gruppe", &g.id, kind, id, known);
|
||||
|
||||
@@ -904,21 +904,26 @@ fn collect(p: &Project, k: [f64; 2], cut: Option<f64>, ground: Option<&Ground>)
|
||||
}
|
||||
}
|
||||
}
|
||||
// [142] Bäume (2D-Kreise der Ebene „Bäume", Code 13): Stamm + Krone.
|
||||
// [142] Bäume (2D-Kreise der Ebene „Bäume", Code 13): Stamm + Krone. [149] Steht ein Baum-Objekt am selben
|
||||
// Ort (Stamm nahe der Kreismitte), zählt nur das Objekt — sonst fiele der Schatten doppelt.
|
||||
let mut clouds: Vec<Vec<[f64; 3]>> = Vec::new();
|
||||
let tree_h = p.sun_study.as_ref().and_then(|s| s.tree_height).filter(|h| *h > 0.0).unwrap_or(DEFAULT_TREE_HEIGHT);
|
||||
let objects = crate::tree::geoms(p);
|
||||
for d in &p.drawings2d {
|
||||
let crate::model::Drawing2DGeom::Circle { center, r } = &d.geom else { continue };
|
||||
if !is_tree_category(p, &d.category_code) {
|
||||
continue;
|
||||
}
|
||||
if objects.iter().any(|(_, g)| circle_is_tree_object(center.x, center.y, *r, g.c)) {
|
||||
continue;
|
||||
}
|
||||
if let Some((trunk, crown)) = tree_caster([center.x, center.y], *r, tree_h, gz(center.x, center.y)) {
|
||||
prisms.push((trunk, vec![]));
|
||||
clouds.push(crown);
|
||||
}
|
||||
}
|
||||
// [149] Bäume als eigene Objekte: Stamm (Prisma) + Krone (Punktwolke) nach eigener Höhe, Krone und Form.
|
||||
for (_, g) in crate::tree::geoms(p) {
|
||||
for (_, g) in objects {
|
||||
prisms.push((Prism { footprint: g.trunk_ring(8), z_bottom: g.base, z_top: g.trunk_top() }, vec![]));
|
||||
clouds.push(g.crown_points());
|
||||
}
|
||||
@@ -989,6 +994,13 @@ fn shadow_plan(p: &Project, sun: SunPosition, cut: Option<f64>, with_ground: boo
|
||||
without_slivers(polygon_bool::union(&out), if site.is_some() { SLIVER_AREA } else { 1e-4 })
|
||||
}
|
||||
|
||||
/// [149] Kreis der Baum-Ebene am Ort eines Baum-Objekts (Stammmitte höchstens eine halbe Kreisbreite, mindestens
|
||||
/// 0.5 m, von der Kreismitte): der Kreis ist dann nur die alte Darstellung desselben Baums.
|
||||
fn circle_is_tree_object(cx: f64, cy: f64, r: f64, stem: [f64; 2]) -> bool {
|
||||
let tol = (0.5 * r).max(0.5);
|
||||
hypot2(stem[0] - cx, stem[1] - cy) <= tol
|
||||
}
|
||||
|
||||
/// Baumhöhe ohne `sunStudy.treeHeight` (m).
|
||||
pub const DEFAULT_TREE_HEIGHT: f64 = 8.0;
|
||||
|
||||
@@ -1344,4 +1356,24 @@ mod terrain_tests {
|
||||
// Kein Baum: kein Schatten.
|
||||
assert!(shadow_polygons_project(&project_json(serde_json::json!({"trees": []})), sun, None).is_empty());
|
||||
}
|
||||
|
||||
/// [149] Kreis der Baum-Ebene am Ort eines Baum-Objekts wirft keinen zweiten Schatten (sonst hier mit
|
||||
/// `treeHeight` 30 m bis y = 30); ein Kreis anderswo wirft weiter.
|
||||
#[test]
|
||||
fn kreis_am_baum_objekt_nicht_doppelt() {
|
||||
let sun = SunPosition { azimuth: 180.0, elevation: 45.0 };
|
||||
let mk = |circle_x: f64| {
|
||||
project_json(serde_json::json!({
|
||||
"sunStudy": {"when": "2026-06-21T10:00:00Z", "show": true, "treeHeight": 30.0},
|
||||
"drawings2d": [{"id": "k", "type": "drawing2d", "levelId": "eg", "categoryCode": "13", "geom": {"shape": "circle", "center": {"x": circle_x, "y": 0.2}, "r": 2.0}}],
|
||||
"trees": [{"id": "t", "type": "tree", "floorId": "eg", "categoryCode": "13", "position": {"x": 0, "y": 0},
|
||||
"trunkDiameter": 0.4, "crownDiameter": 4.0, "crownBase": 2.0, "height": 12.0, "shape": "conical",
|
||||
"status": "existing", "foliage": "deciduous"}]
|
||||
}))
|
||||
};
|
||||
let same = bbox(&shadow_polygons_project(&mk(0.3), sun, None));
|
||||
assert!((same[3] - 12.0).abs() < 0.05, "nur das Objekt: {same:?}");
|
||||
let apart = bbox(&shadow_polygons_project(&mk(20.0), sun, None));
|
||||
assert!(apart[3] > 25.0, "Kreis anderswo wirft weiter: {apart:?}");
|
||||
}
|
||||
}
|
||||
@@ -1808,6 +1808,8 @@ export const de = {
|
||||
"objinfo.tree.section": "Baum",
|
||||
"objinfo.tree.species": "Art",
|
||||
"objinfo.tree.speciesHint": "z. B. Quercus robur",
|
||||
"objinfo.tree.showLabel": "Beschriftung zeigen",
|
||||
"objinfo.tree.showLabelHint": "Art-Name im Grundriss neben dem Stamm",
|
||||
"objinfo.tree.status": "Bestand",
|
||||
"objinfo.tree.status.existing": "bestehend",
|
||||
"objinfo.tree.status.new": "neu",
|
||||
|
||||
@@ -1797,6 +1797,8 @@ export const en: Record<TranslationKey, string> = {
|
||||
"objinfo.tree.section": "Tree",
|
||||
"objinfo.tree.species": "Species",
|
||||
"objinfo.tree.speciesHint": "e.g. Quercus robur",
|
||||
"objinfo.tree.showLabel": "Show label",
|
||||
"objinfo.tree.showLabelHint": "Species name next to the trunk in plan",
|
||||
"objinfo.tree.status": "Status",
|
||||
"objinfo.tree.status.existing": "existing",
|
||||
"objinfo.tree.status.new": "new",
|
||||
|
||||
@@ -16,6 +16,8 @@ export interface GroupMembership {
|
||||
columnIds: string[];
|
||||
roofIds: string[];
|
||||
openingIds: string[];
|
||||
/** [149] Bäume. */
|
||||
treeIds: string[];
|
||||
}
|
||||
|
||||
export type MemberKind = keyof GroupMembership;
|
||||
@@ -29,6 +31,7 @@ export const EMPTY_MEMBERSHIP: GroupMembership = {
|
||||
columnIds: [],
|
||||
roofIds: [],
|
||||
openingIds: [],
|
||||
treeIds: [],
|
||||
};
|
||||
|
||||
/** Letzte transitive Mitgliedschaft (Projekt + Gruppe): Klick-/Rahmen-Filter fragen je Element. */
|
||||
|
||||
@@ -1399,6 +1399,8 @@ export type Group = {
|
||||
columnIds: Array<string>;
|
||||
roofIds: Array<string>;
|
||||
openingIds: Array<string>;
|
||||
/** [149] Bäume (fehlt in älteren Dateien). */
|
||||
treeIds?: Array<string>;
|
||||
/** Verschachtelte Gruppen (diese Gruppe enthält andere Gruppen als Ganzes). */
|
||||
groupIds: Array<string>;
|
||||
};
|
||||
@@ -3284,6 +3286,8 @@ export type Tree = {
|
||||
foliage: TreeFoliage;
|
||||
/** Optionaler Art-Name (z. B. „Quercus robur"), erscheint als Beschriftung im Grundriss. */
|
||||
species?: string;
|
||||
/** [149] Art-Name als Beschriftung im Grundriss zeigen (nahe am Stamm; Vorgabe aus). */
|
||||
showLabel?: boolean;
|
||||
/** Höhenversatz des Fusses gegenüber Gelände bzw. Geschoss-UK (m, Vorgabe 0). */
|
||||
baseOffset?: number;
|
||||
/**
|
||||
|
||||
@@ -2436,6 +2436,17 @@ export function TreeSection({ ids }: { ids: readonly string[] }) {
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.tree.showLabel")}</span>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={tree.showLabel === true}
|
||||
disabled={locked}
|
||||
onChange={(e) => set({ showLabel: e.target.checked }, true)}
|
||||
title={t("objinfo.tree.showLabelHint")}
|
||||
data-testid="tree-show-label"
|
||||
/>
|
||||
</div>
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.tree.status")}</span>
|
||||
<Dropdown
|
||||
|
||||
@@ -191,7 +191,7 @@ export class PlanPickIndex {
|
||||
* Rahmen-Auswahl über Polygone mit Id im Feld `field` (CAD-Konvention): `crossing` = ein Band
|
||||
* berührt das Rechteck, sonst liegen alle Bänder ganz darin. Ids in Auftreten-Reihenfolge.
|
||||
*/
|
||||
marquee(field: "wallId" | "ceilingId" | "roomId" | "stairId" | "columnId" | "roofId", rect: ModelRect, crossing: boolean): string[] {
|
||||
marquee(field: "wallId" | "ceilingId" | "roomId" | "stairId" | "columnId" | "roofId" | "contextObjectId", rect: ModelRect, crossing: boolean): string[] {
|
||||
const r = Float64Array.of(rect.minX, rect.minY, rect.maxX, rect.maxY);
|
||||
return splitIds(core().pick_marquee_polygons(this.ix(), KIND[field], r, crossing));
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ const EMPTY_MEM = {
|
||||
columnIds: [] as string[],
|
||||
roofIds: [] as string[],
|
||||
openingIds: [] as string[],
|
||||
treeIds: [] as string[],
|
||||
};
|
||||
|
||||
function project(groups: Group[]): Project {
|
||||
@@ -184,6 +185,24 @@ describe("applyGroupDimming", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("[149] Bäume in Gruppen", () => {
|
||||
it("gruppieren, erweitern, auflösen und dimmen", () => {
|
||||
const res = groupSelection({ ...EMPTY_MEM, wallIds: ["w1"], treeIds: ["b1", "b2"] }, []);
|
||||
expect(res).not.toBeNull();
|
||||
const p = applyOps(project([]), res!.ops);
|
||||
expect(p.groups![0].treeIds).toEqual(["b1", "b2"]);
|
||||
// Gruppe ohne Bäume schreibt kein leeres Feld (ältere Dateien bleiben gleich).
|
||||
expect(groupSelection({ ...EMPTY_MEM, wallIds: ["w1", "w2"] }, [])!.ops.length).toBe(1);
|
||||
const { expanded, groupIds } = expandToGroups(p, { ...EMPTY_MEM, treeIds: ["b2"] }, []);
|
||||
expect([expanded.wallIds, expanded.treeIds, groupIds]).toEqual([["w1"], ["b1", "b2"], [res!.groupId]]);
|
||||
expect(ungroup(p, res!.groupId)!.members.treeIds).toEqual(["b1", "b2"]);
|
||||
const inside = { kind: "polygon", pts: [], contextObjectId: "@tree:b1" } as unknown as Primitive;
|
||||
const outside = { kind: "polygon", pts: [], contextObjectId: "@tree:b9" } as unknown as Primitive;
|
||||
const out = applyGroupDimming([inside, outside], p, [res!.groupId]);
|
||||
expect([out[0].greyed, out[1].greyed]).toEqual([undefined, true]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("applyGroupDimmingToPlan", () => {
|
||||
const g1: Group = { id: "g1", wallIds: [], drawingIds: ["din"], ceilingIds: [], roomIds: [], stairIds: [], columnIds: [], roofIds: [], openingIds: [], groupIds: [] };
|
||||
const p = project([g1]);
|
||||
|
||||
@@ -26,6 +26,7 @@ const KEYS: MemberKind[] = [
|
||||
"columnIds",
|
||||
"roofIds",
|
||||
"openingIds",
|
||||
"treeIds",
|
||||
];
|
||||
|
||||
/** Vereinigung je Art (erste Vorkommen in Reihenfolge) — für Auswahl-Mengen in der Hülle. */
|
||||
@@ -35,6 +36,9 @@ export function mergeMembership(a: GroupMembership, b: GroupMembership): GroupMe
|
||||
return out;
|
||||
}
|
||||
|
||||
/** [149] Präfix der Baum-Pick-Id im Feld `contextObjectId` (Kern `tree::TREE_PICK_PREFIX`). */
|
||||
const TREE_PICK = "@tree:";
|
||||
|
||||
/** Primitiv-ID-Feld → zugehörige `MemberKind` (Reihenfolge irrelevant). */
|
||||
const ID_FIELD_TO_KIND: [string, MemberKind][] = [
|
||||
["wallId", "wallIds"],
|
||||
@@ -73,6 +77,7 @@ export function applyGroupDimming(
|
||||
columnIds: new Set(mem.columnIds),
|
||||
roofIds: new Set(mem.roofIds),
|
||||
openingIds: new Set(mem.openingIds),
|
||||
treeIds: new Set(mem.treeIds),
|
||||
};
|
||||
return primitives.map((p) => {
|
||||
const rec = p as unknown as Record<string, unknown>;
|
||||
@@ -84,6 +89,12 @@ export function applyGroupDimming(
|
||||
hasId = true;
|
||||
if (sets[kind].has(v)) inside = true;
|
||||
}
|
||||
// [149] Bäume tragen ihre id als `contextObjectId = "@tree:<id>"`.
|
||||
const ctx = rec.contextObjectId;
|
||||
if (typeof ctx === "string" && ctx.startsWith(TREE_PICK)) {
|
||||
hasId = true;
|
||||
if (sets.treeIds.has(ctx.slice(TREE_PICK.length))) inside = true;
|
||||
}
|
||||
return hasId && !inside ? { ...p, greyed: true } : p;
|
||||
});
|
||||
}
|
||||
@@ -135,6 +146,7 @@ export function groupSelection(
|
||||
columnIds: sel.columnIds,
|
||||
roofIds: sel.roofIds,
|
||||
openingIds: sel.openingIds,
|
||||
...(sel.treeIds.length ? { treeIds: sel.treeIds } : {}),
|
||||
groupIds: [...selectedGroupIds],
|
||||
};
|
||||
return { ops: addItems("groups", [g]), groupId: id };
|
||||
@@ -164,6 +176,7 @@ export function ungroup(
|
||||
columnIds: g.columnIds,
|
||||
roofIds: g.roofIds,
|
||||
openingIds: g.openingIds,
|
||||
treeIds: g.treeIds ?? [],
|
||||
},
|
||||
subGroupIds: g.groupIds,
|
||||
};
|
||||
|
||||
@@ -34,6 +34,8 @@ export function isLocked(project: Project, kind: MemberKind, id: string): boolea
|
||||
return !!(project.roofs ?? []).find((r) => r.id === id)?.locked;
|
||||
case "openingIds":
|
||||
return !!(project.openings ?? []).find((o) => o.id === id)?.locked;
|
||||
case "treeIds":
|
||||
return !!(project.trees ?? []).find((t) => t.id === id)?.locked;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +58,8 @@ export function lockOps(project: Project, kind: MemberKind, id: string, locked:
|
||||
return patchItem(project, "roofs", id, { locked });
|
||||
case "openingIds":
|
||||
return patchItem(project, "openings", id, { locked });
|
||||
case "treeIds":
|
||||
return patchItem(project, "trees", id, { locked });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -228,5 +228,6 @@ export function toMembership(sel: Selection): GroupMembership {
|
||||
columnIds: sel.columns,
|
||||
roofIds: sel.roofs,
|
||||
openingIds: sel.openings,
|
||||
treeIds: sel.trees,
|
||||
};
|
||||
}
|
||||
@@ -38,6 +38,7 @@ function selHit(sel: PlanSelection): { kind: MemberKind; id: string } | null {
|
||||
if (sel.roomId) return { kind: "roomIds", id: sel.roomId };
|
||||
if (sel.columnId) return { kind: "columnIds", id: sel.columnId };
|
||||
if (sel.roofId) return { kind: "roofIds", id: sel.roofId };
|
||||
if (sel.treeId) return { kind: "treeIds", id: sel.treeId };
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -314,6 +315,7 @@ export function useMouseSelectionHandlers(opts: {
|
||||
columnIds: [],
|
||||
roofIds: [],
|
||||
openingIds: [],
|
||||
treeIds: sel.treeIds ?? [],
|
||||
};
|
||||
// Gruppen-Isolation: ausserhalb der aktiven Gruppe getroffene Elemente
|
||||
// sind gesperrt (werden ignoriert), wie beim Einzelklick.
|
||||
@@ -329,6 +331,7 @@ export function useMouseSelectionHandlers(opts: {
|
||||
columnIds: [],
|
||||
roofIds: [],
|
||||
openingIds: [],
|
||||
treeIds: raw.treeIds.filter((id) => isInsideActiveGroup(project, "treeIds", id, groupPath)),
|
||||
};
|
||||
// Gruppen-Erweiterung: jedes getroffene Element, das zu einer sichtbaren
|
||||
// Gruppe gehört, zieht deren ganze (transitive) Mitgliedschaft nach.
|
||||
@@ -344,6 +347,7 @@ export function useMouseSelectionHandlers(opts: {
|
||||
ceilings: expanded.ceilingIds,
|
||||
stairs: expanded.stairIds,
|
||||
rooms: expanded.roomIds,
|
||||
trees: expanded.treeIds,
|
||||
groups: groupIds,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -336,6 +336,8 @@ export interface MarqueeSelection {
|
||||
ceilingIds: string[];
|
||||
roomIds: string[];
|
||||
stairIds: string[];
|
||||
/** [149] Getroffene Bäume (Kronenfläche, gleiche Konvention). */
|
||||
treeIds?: string[];
|
||||
/**
|
||||
* Zieh-Richtung: `false` = links→rechts (positiv Δx) → nur VOLLSTÄNDIG
|
||||
* eingeschlossene Wände; `true` = rechts→links (negativ Δx) → auch berührte/
|
||||
@@ -2619,6 +2621,11 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
ceilingIds: getPick().marquee("ceilingId", rect, crossing),
|
||||
roomIds: getPick().marquee("roomId", rect, crossing),
|
||||
stairIds: getPick().marquee("stairId", rect, crossing),
|
||||
// [149] Bäume: Kronen-Pickfläche (`contextObjectId = "@tree:<id>"`).
|
||||
treeIds: getPick()
|
||||
.marquee("contextObjectId", rect, crossing)
|
||||
.filter((id) => id.startsWith(TREE_PICK))
|
||||
.map((id) => id.slice(TREE_PICK.length)),
|
||||
crossing,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user