[137] Objekt-Info für Gelände/Baugrube, Schatten und Baurechtslinien anwählbar (Pseudo-Auswahl site)
This commit is contained in:
15 files changed
+447
-232
No files matched your search
@@ -798,7 +798,7 @@ pub fn plan_domains_buf(p: &Project, a: &PlanArgs) -> Result<Vec<u8>, String> {
|
||||
/// beim projektglobalen Aufruf (`global`).
|
||||
fn extras_of(p: &Project, a: &PlanArgs) -> (Vec<(Primitive, u32)>, Vec<Primitive>) {
|
||||
if a.global {
|
||||
super::extras::site_and_shadow(p, &a.floor, a.sun_when)
|
||||
super::extras::site_and_shadow(p, &a.floor, a.sun_when, a.scale)
|
||||
} else {
|
||||
(Vec::new(), Vec::new())
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ use crate::jsnum;
|
||||
use crate::model::*;
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// [137] Pick-Ids der abgeleiteten Lage-Darstellung (im Feld `contextObjectId`, mit `@` — keine Element-Id
|
||||
/// beginnt so): Schattenflächen wählen den Sonnenstand, die Baurechtslinien (unsichtbare Bänder) das Baurecht.
|
||||
pub const SITE_PICK_SUN: &str = "@sunStudy";
|
||||
pub const SITE_PICK_RULES: &str = "@siteRules";
|
||||
|
||||
/// Füllfarbe der Schattenflächen.
|
||||
pub const SUN_SHADOW_FILL: &str = "#3a4a66";
|
||||
const SUN_SHADOW_OPACITY: f64 = 0.28;
|
||||
@@ -91,42 +96,15 @@ pub fn sun_shadow(p: &Project, floor: &str, when_ms: Option<f64>, out: &mut Vec<
|
||||
let sun = crate::sun::sun_position(lat, lon, t);
|
||||
for poly in crate::sun::shadow_polygons_project(p, sun) {
|
||||
for r in crate::sun::without_holes(&poly) {
|
||||
out.push(flat_polygon(ring_pts(&r), SUN_SHADOW_FILL, SUN_SHADOW_OPACITY));
|
||||
let mut q = flat_polygon(ring_pts(&r), SUN_SHADOW_FILL, SUN_SHADOW_OPACITY);
|
||||
if let Primitive::Polygon { context_object_id, .. } = &mut q {
|
||||
*context_object_id = Some(SITE_PICK_SUN.into());
|
||||
}
|
||||
out.push(q);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// [137] Abgeleitete Lage-Darstellung unter dem Punkt (x, y) im Geschoss `floor` (dieselben Bedingungen
|
||||
/// wie die Zeichnung): `"siteRules"` näher als `tol` (m) an Parzellengrenze oder zulässiger Fläche,
|
||||
/// `"sunStudy"` in einer Schattenfläche zum Zeitpunkt `when_ms`, sonst `""`. Die Auswahl öffnet dann die
|
||||
/// Einstellungen der Quelle (Baurecht bzw. Sonnenstand) — Schatten und Baurechtslinien sind keine Elemente.
|
||||
pub fn site_pick(p: &Project, floor: &str, when_ms: Option<f64>, x: f64, y: f64, tol: f64) -> &'static str {
|
||||
if !(x.is_finite() && y.is_finite()) {
|
||||
return "";
|
||||
}
|
||||
let tol = if tol.is_finite() && tol > 0.0 { tol } else { 0.0 };
|
||||
let near_ring = |r: &[Vec2]| (0..r.len()).any(|i| crate::plan::pick::point_seg_dist(x, y, r[i].x, r[i].y, r[(i + 1) % r.len()].x, r[(i + 1) % r.len()].y) <= tol);
|
||||
if let (Some(check), Some(rules)) = (site_check(p, floor), p.site_rules.as_ref()) {
|
||||
if near_ring(&rules.parcel) || check.allowed.iter().flatten().any(|r| near_ring(r)) {
|
||||
return "siteRules";
|
||||
}
|
||||
}
|
||||
let mut shadow = Vec::new();
|
||||
sun_shadow(p, floor, when_ms, &mut shadow);
|
||||
let inside = shadow.iter().any(|q| match q {
|
||||
Primitive::Polygon { pts, .. } => {
|
||||
let flat: Vec<f64> = pts.iter().flat_map(|v| [v.x, v.y]).collect();
|
||||
crate::plan::pick::point_in_polygon(x, y, &flat)
|
||||
}
|
||||
_ => false,
|
||||
});
|
||||
if inside {
|
||||
"sunStudy"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
/// Baurecht im Geschoss nächst ±0.00 (ohne `show: false`): Prüfung des Modells, `None` ohne
|
||||
/// gültiges Baurecht.
|
||||
fn site_check(p: &Project, floor: &str) -> Option<crate::site_rules::SiteCheckOut> {
|
||||
@@ -160,10 +138,27 @@ fn ring_lines(out: &mut Vec<(Primitive, u32)>, pts: &[Vec2], cls: &str, color: &
|
||||
}
|
||||
}
|
||||
|
||||
/// [137] Unsichtbares Rechteck der halben Breite `half` um die Strecke a–b mit der Pick-Id des Baurechts.
|
||||
fn seg_band(a: Vec2, b: Vec2, half: f64) -> Option<Primitive> {
|
||||
let (dx, dy) = (b.x - a.x, b.y - a.y);
|
||||
let l = dx.hypot(dy);
|
||||
if !(l > 1e-9) {
|
||||
return None;
|
||||
}
|
||||
let (nx, ny) = (-dy / l * half, dx / l * half);
|
||||
let pts = vec![Vec2 { x: a.x + nx, y: a.y + ny }, Vec2 { x: b.x + nx, y: b.y + ny }, Vec2 { x: b.x - nx, y: b.y - ny }, Vec2 { x: a.x - nx, y: a.y - ny }];
|
||||
let mut q = flat_polygon(pts, "none", 1.0);
|
||||
if let Primitive::Polygon { context_object_id, opacity, .. } = &mut q {
|
||||
*context_object_id = Some(SITE_PICK_RULES.into());
|
||||
*opacity = None;
|
||||
}
|
||||
Some(q)
|
||||
}
|
||||
|
||||
/// Unterste Gruppe: Schatten, dann Parzellengrenze (Strich-Punkt) und zulässige Fläche
|
||||
/// (gestrichelt); mit Strichmuster-Kennung je Primitiv. Dazu die Verstösse (Gebäude-Grundfläche
|
||||
/// ausserhalb der zulässigen Fläche) für die oberste Gruppe.
|
||||
pub fn site_and_shadow(p: &Project, floor: &str, when_ms: Option<f64>) -> (Vec<(Primitive, u32)>, Vec<Primitive>) {
|
||||
pub fn site_and_shadow(p: &Project, floor: &str, when_ms: Option<f64>, scale: f64) -> (Vec<(Primitive, u32)>, Vec<Primitive>) {
|
||||
let mut shadow = Vec::new();
|
||||
sun_shadow(p, floor, when_ms, &mut shadow);
|
||||
let mut under: Vec<(Primitive, u32)> = shadow.into_iter().map(|q| (q, 0)).collect();
|
||||
@@ -177,6 +172,16 @@ pub fn site_and_shadow(p: &Project, floor: &str, when_ms: Option<f64>) -> (Vec<(
|
||||
ring_lines(&mut under, ring, SITE_ALLOWED_CLS, ALLOWED_COLOR, 0.25, &ALLOWED_DASH, r);
|
||||
}
|
||||
}
|
||||
// [137] Unsichtbare Pick-Bänder (±1.5 mm Papier) über den Linien: ein Klick wählt das Baurecht.
|
||||
let half = 0.0015 * if scale.is_finite() && scale > 0.0 { scale } else { 100.0 };
|
||||
let rings = std::iter::once(rules.parcel.as_slice()).chain(check.allowed.iter().flatten().map(|r| r.as_slice()));
|
||||
for ring in rings {
|
||||
for i in 0..ring.len() {
|
||||
if let Some(band) = seg_band(ring[i], ring[(i + 1) % ring.len()], half) {
|
||||
under.push((band, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
for poly in &check.violations {
|
||||
let rings: Vec<Vec<[f64; 2]>> = poly.iter().map(|r| r.iter().map(|q| [q.x, q.y]).collect()).collect();
|
||||
for ring in crate::sun::without_holes(&rings) {
|
||||
@@ -559,43 +564,57 @@ mod tests {
|
||||
serde_json::from_value(v).unwrap()
|
||||
};
|
||||
p.site_rules = Some(rules(serde_json::json!({})));
|
||||
let n0 = site_and_shadow(&p, &floor, None).1.len();
|
||||
let n0 = site_and_shadow(&p, &floor, None, 100.0).1.len();
|
||||
p.site_rules = Some(rules(serde_json::json!({"profileAngle": 10.0, "profileHeight": 0.01})));
|
||||
let c = crate::site_rules::check_project(&p).unwrap();
|
||||
assert!(c.profile_exceeded);
|
||||
let n1 = site_and_shadow(&p, &floor, None).1.len();
|
||||
let n1 = site_and_shadow(&p, &floor, None, 100.0).1.len();
|
||||
assert!(n1 > n0, "{n0} {n1}");
|
||||
}
|
||||
|
||||
/// [137] Klick in eine Schattenfläche wählt den Sonnenstand, Klick auf eine Baurechtslinie das Baurecht;
|
||||
/// ohne sichtbare Studie bzw. in einem anderen Geschoss nichts.
|
||||
/// Oberste Fläche mit Pick-Id unter dem Punkt (wie `PickIndex::polygons_at`, Maske „Kontext").
|
||||
fn top_pick(prims: &[(Primitive, u32)], x: f64, y: f64) -> Option<String> {
|
||||
prims.iter().rev().find_map(|(q, _)| match q {
|
||||
Primitive::Polygon { pts, context_object_id: Some(id), .. } => {
|
||||
let flat: Vec<f64> = pts.iter().flat_map(|v| [v.x, v.y]).collect();
|
||||
crate::plan::pick::point_in_polygon(x, y, &flat).then(|| id.clone())
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
/// [137] Schattenflächen tragen die Pick-Id des Sonnenstands, die Baurechtslinien unsichtbare Bänder mit der
|
||||
/// des Baurechts (Klick darauf öffnet deren Einstellungen); ohne sichtbare Studie bzw. in einem anderen
|
||||
/// Geschoss nichts.
|
||||
#[test]
|
||||
fn klick_auf_schatten_und_baurecht() {
|
||||
let mut p = sample();
|
||||
let floor = ground_floor_id(&p).unwrap().to_string();
|
||||
p.sun_study = Some(SunStudy { when: "2026-12-21T09:00:00Z".into(), show: true, ..Default::default() });
|
||||
let when = Some(1_797_843_600_000.0); // 2026-12-21T09:00:00Z
|
||||
let mut shadow = Vec::new();
|
||||
sun_shadow(&p, &floor, when, &mut shadow);
|
||||
assert!(!shadow.is_empty());
|
||||
// Ein Punkt in einer Schattenfläche (Raster über die erste Fläche).
|
||||
let Primitive::Polygon { pts, .. } = &shadow[0] else { panic!() };
|
||||
let (under, _) = site_and_shadow(&p, &floor, when, 100.0);
|
||||
let shadows: Vec<&Primitive> = under.iter().map(|(q, _)| q).filter(|q| matches!(q, Primitive::Polygon { fill, .. } if fill == SUN_SHADOW_FILL)).collect();
|
||||
assert!(!shadows.is_empty());
|
||||
assert!(shadows.iter().all(|q| matches!(q, Primitive::Polygon { context_object_id: Some(id), .. } if id == SITE_PICK_SUN)));
|
||||
// Ein Punkt in der ersten Schattenfläche (Raster über ihr Ausmass).
|
||||
let Primitive::Polygon { pts, .. } = shadows[0] else { panic!() };
|
||||
let flat: Vec<f64> = pts.iter().flat_map(|v| [v.x, v.y]).collect();
|
||||
let (x0, x1) = pts.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |a, v| (a.0.min(v.x), a.1.max(v.x)));
|
||||
let (y0, y1) = pts.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |a, v| (a.0.min(v.y), a.1.max(v.y)));
|
||||
let inside = (0..400).map(|k| (x0 + (x1 - x0) * ((k % 20) as f64 + 0.5) / 20.0, y0 + (y1 - y0) * ((k / 20) as f64 + 0.5) / 20.0)).find(|q| crate::plan::pick::point_in_polygon(q.0, q.1, &flat)).unwrap();
|
||||
assert_eq!(site_pick(&p, &floor, when, inside.0, inside.1, 0.1), "sunStudy");
|
||||
assert_eq!(site_pick(&p, &floor, when, 1e4, 1e4, 0.1), "");
|
||||
assert_eq!(site_pick(&p, "anderes-geschoss", when, inside.0, inside.1, 0.1), "");
|
||||
assert_eq!(site_pick(&p, &floor, None, inside.0, inside.1, 0.1), "");
|
||||
assert_eq!(site_pick(&p, &floor, when, f64::NAN, 0.0, 0.1), "");
|
||||
assert_eq!(top_pick(&under, inside.0, inside.1).as_deref(), Some(SITE_PICK_SUN));
|
||||
assert_eq!(top_pick(&under, 1e4, 1e4), None);
|
||||
assert!(site_and_shadow(&p, "anderes-geschoss", when, 100.0).0.is_empty());
|
||||
p.sun_study.as_mut().unwrap().show = false;
|
||||
assert_eq!(site_pick(&p, &floor, when, inside.0, inside.1, 0.1), "");
|
||||
// Baurecht: Parzellengrenze bei x = −30 (weit weg vom Gebäude, kein Schatten dort).
|
||||
assert_eq!(top_pick(&site_and_shadow(&p, &floor, when, 100.0).0, inside.0, inside.1), None);
|
||||
// Baurecht: Parzellengrenze bei x = −30, Grenzabstand 3 m → zulässige Fläche ab x = −27; Band ±0.15 m bei 1:100.
|
||||
p.site_rules = Some(serde_json::from_value(serde_json::json!({"parcel": [{"x": -30, "y": -30}, {"x": 40, "y": -30}, {"x": 40, "y": 40}, {"x": -30, "y": 40}], "defaultSetback": 3.0})).unwrap());
|
||||
assert_eq!(site_pick(&p, &floor, when, -30.05, 5.0, 0.1), "siteRules");
|
||||
assert_eq!(site_pick(&p, &floor, when, -27.0, 5.0, 0.1), "siteRules", "zulässige Fläche 3 m innen");
|
||||
assert_eq!(site_pick(&p, &floor, when, -28.5, 5.0, 0.1), "");
|
||||
let (under, _) = site_and_shadow(&p, &floor, when, 100.0);
|
||||
assert_eq!(top_pick(&under, -30.1, 5.0).as_deref(), Some(SITE_PICK_RULES));
|
||||
assert_eq!(top_pick(&under, -27.0, 5.0).as_deref(), Some(SITE_PICK_RULES), "zulässige Fläche");
|
||||
assert_eq!(top_pick(&under, -28.5, 5.0), None);
|
||||
// Massstab 1:500: Band ±0.75 m.
|
||||
assert_eq!(top_pick(&site_and_shadow(&p, &floor, when, 500.0).0, -29.4, 5.0).as_deref(), Some(SITE_PICK_RULES));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -57,8 +57,6 @@ pub fn run(p: &Project, name: &str, args: &[f64], text: &str) -> Result<String,
|
||||
("siteCheck", _) => json(&site_rules::check_project(p)),
|
||||
("dormerStatus", _) => json(&crate::dormer::status(p)),
|
||||
("excavationQuantities", _) => json(&crate::excavation::quantities(p)),
|
||||
// [137] Klick auf Schatten/Baurechtslinien: args = [x, y, Toleranz m, Zeitpunkt ms (NaN = keiner)], text = Geschoss.
|
||||
("sitePick", 4) => json(&crate::plan::extras::site_pick(p, text, Some(args[3]).filter(|t| t.is_finite()), args[0], args[1], args[2])),
|
||||
("buildingFootprint", _) => json(&site_rules::building_footprint(p)),
|
||||
("modelTop", _) => json(&site_rules::model_top(p)),
|
||||
("shadows", 2) => json(&site_rules::area_out(&sun::shadow_polygons_project(p, sun::SunPosition { azimuth: args[0], elevation: args[1] }))),
|
||||
|
||||
@@ -457,6 +457,10 @@ export const de = {
|
||||
"objinfo.kind.column": "Stütze",
|
||||
"objinfo.kind.roof": "Dach",
|
||||
"objinfo.kind.contextObject": "Kontext-Objekt",
|
||||
"objinfo.kind.sunStudy": "Schatten (Sonnenstand)",
|
||||
"objinfo.kind.siteRules": "Baurecht",
|
||||
"objinfo.sunStudy.hint": "Schatten werden aus dem Modell abgeleitet — Datum und Uhrzeit hier ändern.",
|
||||
"objinfo.siteRules.hint": "Parzellengrenze und zulässige Fläche kommen aus dem Baurecht — hier bearbeiten.",
|
||||
// ── Kontext-Objekt-Attribute (Object-Info-Panel) ────────────────────────
|
||||
"objinfo.contextObject.section": "Georeferenzierung",
|
||||
"objinfo.contextObject.type": "Art",
|
||||
@@ -464,6 +468,7 @@ export const de = {
|
||||
"objinfo.contextObject.type.terrainMesh": "Gelände",
|
||||
"objinfo.contextObject.type.contourSet": "Höhenlinien",
|
||||
"objinfo.contextObject.type.image": "Luftbild",
|
||||
"objinfo.contextObject.type.excavation": "Baugrube",
|
||||
"objinfo.contextObject.lv95E": "LV95 Ost (E)",
|
||||
"objinfo.contextObject.lv95N": "LV95 Nord (N)",
|
||||
"objinfo.contextObject.noAnchor": "Kein Standort-Bezug im Projekt",
|
||||
@@ -2087,6 +2092,12 @@ export const de = {
|
||||
"site.excavation.shoring": "Verbau (senkrecht), Kante",
|
||||
"site.excavation.shoringHint": "Gewählte Kanten: senkrechte Wand (Spundwand) statt Böschung",
|
||||
"site.earthDepth": "Erdreich-Band im Schnitt [m]",
|
||||
"site.terrain.visible": "Gelände sichtbar",
|
||||
"site.terrain.visible.hint": "Blendet die Kategorie {name} ein oder aus (alle Ansichten, ein Undo-Schritt)",
|
||||
"site.terrain.smooth": "Glättung",
|
||||
"site.terrain.smooth.hint": "Gelände aus den Höhenlinien neu erzeugen (Bruchkanten bleiben, ein Undo-Schritt)",
|
||||
"site.terrain.smooth.raw": "roh (ohne Glättung)",
|
||||
"site.terrain.smooth.level": "Stufe {n}",
|
||||
"site.type.image": "Luftbild",
|
||||
"site.group.image": "Luftbild",
|
||||
"site.dwgHint": "DWG? Zuerst mit dem gratis ODA File Converter in DXF umwandeln.",
|
||||
@@ -2174,6 +2185,9 @@ export const de = {
|
||||
"pick.kind.room": "Raum",
|
||||
"pick.kind.roof": "Dach",
|
||||
"pick.kind.context": "Kontext-Objekt",
|
||||
"pick.kind.site": "Lage",
|
||||
"pick.site.sunStudy": "Schatten (Sonnenstand)",
|
||||
"pick.site.siteRules": "Baurecht",
|
||||
"pick.shape.line": "Linie",
|
||||
"pick.shape.polyline": "Polylinie",
|
||||
"pick.shape.area": "Fläche",
|
||||
|
||||
@@ -455,6 +455,10 @@ export const en: Record<TranslationKey, string> = {
|
||||
"objinfo.kind.column": "Column",
|
||||
"objinfo.kind.roof": "Roof",
|
||||
"objinfo.kind.contextObject": "Context object",
|
||||
"objinfo.kind.sunStudy": "Shadow (sun position)",
|
||||
"objinfo.kind.siteRules": "Building regulations",
|
||||
"objinfo.sunStudy.hint": "Shadows are derived from the model — change date and time here.",
|
||||
"objinfo.siteRules.hint": "Parcel boundary and buildable area come from the building regulations — edit them here.",
|
||||
// ── Context object attributes (object info panel) ───────────────────────
|
||||
"objinfo.contextObject.section": "Georeferencing",
|
||||
"objinfo.contextObject.type": "Type",
|
||||
@@ -462,6 +466,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"objinfo.contextObject.type.terrainMesh": "Terrain",
|
||||
"objinfo.contextObject.type.contourSet": "Contours",
|
||||
"objinfo.contextObject.type.image": "Aerial image",
|
||||
"objinfo.contextObject.type.excavation": "Excavation",
|
||||
"objinfo.contextObject.lv95E": "LV95 East (E)",
|
||||
"objinfo.contextObject.lv95N": "LV95 North (N)",
|
||||
"objinfo.contextObject.noAnchor": "No location reference in project",
|
||||
@@ -2073,6 +2078,12 @@ export const en: Record<TranslationKey, string> = {
|
||||
"site.excavation.shoring": "Shoring (vertical), edge",
|
||||
"site.excavation.shoringHint": "Selected edges: vertical wall (sheet piling) instead of a slope",
|
||||
"site.earthDepth": "Earth band in section [m]",
|
||||
"site.terrain.visible": "Terrain visible",
|
||||
"site.terrain.visible.hint": "Shows or hides the category {name} (all views, one undo step)",
|
||||
"site.terrain.smooth": "Smoothing",
|
||||
"site.terrain.smooth.hint": "Regenerate the terrain from its contour lines (breaklines kept, one undo step)",
|
||||
"site.terrain.smooth.raw": "raw (no smoothing)",
|
||||
"site.terrain.smooth.level": "Level {n}",
|
||||
"site.excavation.qty": "Cut {cut} m³ · Fill {fill} m³ · Backfill {backfill} m³",
|
||||
"site.excavation.noTerrain": "No terrain below the excavation",
|
||||
"site.type.image": "Aerial",
|
||||
@@ -2162,6 +2173,9 @@ export const en: Record<TranslationKey, string> = {
|
||||
"pick.kind.room": "Room",
|
||||
"pick.kind.roof": "Roof",
|
||||
"pick.kind.context": "Context object",
|
||||
"pick.kind.site": "Site",
|
||||
"pick.site.sunStudy": "Shadow (sun position)",
|
||||
"pick.site.siteRules": "Building regulations",
|
||||
"pick.shape.line": "Line",
|
||||
"pick.shape.polyline": "Polyline",
|
||||
"pick.shape.area": "Area",
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
// Einstellungen eines Kontext-Objekts (importiertes Mesh, Gelände, Baugrube) — gemeinsam für die Liste im
|
||||
// Panel „Gelände & Kontext" und die Objekt-Info ([137]: ein angeklicktes Gelände bzw. eine Baugrube zeigt
|
||||
// dort dieselben Felder). Gelände zusätzlich: Sichtbarkeit seiner Kategorie und Glättung (aus den
|
||||
// Höhenlinien neu erzeugt, ein Undo-Schritt).
|
||||
//
|
||||
// Bezeichner englisch, UI-Text/Kommentare deutsch. Alle sichtbaren Texte über t(...).
|
||||
|
||||
import { t } from "../i18n";
|
||||
import { usePanelHost } from "./host";
|
||||
import { useStore } from "../state/appStore";
|
||||
import type { ContextObject } from "../model/types";
|
||||
import { flattenCategories } from "../model/types";
|
||||
import type { ExcavationQuantity } from "../core";
|
||||
|
||||
/** Zahl-Eingabe für ein Feld eines Kontext-Objekts (leer = Standard, ungültig = keine Änderung). */
|
||||
export function NumField(props: {
|
||||
label: string;
|
||||
value: number | undefined;
|
||||
step: number;
|
||||
min?: number;
|
||||
placeholder?: string;
|
||||
onChange: (v: number | undefined) => void;
|
||||
}) {
|
||||
return (
|
||||
<label className="site-prop">
|
||||
<span>{props.label}</span>
|
||||
<input
|
||||
type="number"
|
||||
step={props.step}
|
||||
min={props.min}
|
||||
placeholder={props.placeholder}
|
||||
value={props.value ?? ""}
|
||||
onChange={(e) => {
|
||||
const raw = e.target.value.trim();
|
||||
if (raw === "") return props.onChange(undefined);
|
||||
const v = Number(raw);
|
||||
if (Number.isFinite(v)) props.onChange(v);
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
);
|
||||
}
|
||||
|
||||
const fmt1 = (v: number) => v.toLocaleString("de-CH", { maximumFractionDigits: 1, minimumFractionDigits: 1 });
|
||||
|
||||
function ExcavationQty({ q }: { q: ExcavationQuantity | undefined }) {
|
||||
if (!q) return <div className="site-qty">{t("site.excavation.noTerrain")}</div>;
|
||||
return (
|
||||
<div className="site-qty">
|
||||
{t("site.excavation.qty", { cut: fmt1(q.cut), fill: fmt1(q.fill), backfill: fmt1(q.backfill) })}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Glättungsstufen der Gelände-Erzeugung (`terrain.rs`, 0 = roh). */
|
||||
const SMOOTH_LEVELS = [0, 1, 2, 3] as const;
|
||||
|
||||
/** Felder eines Kontext-Objekts; `null` für Arten ohne eigene Einstellungen (Höhenlinien, Luftbild). */
|
||||
export function ContextObjectProps({ obj, quantities }: { obj: ContextObject; quantities: readonly ExcavationQuantity[] }) {
|
||||
const host = usePanelHost();
|
||||
const notify = useStore((s) => s.notify);
|
||||
const regenerateTerrain = useStore((s) => s.regenerateTerrain);
|
||||
const patch = (field: string) => (v: number | undefined) => host.onPatchContextObject(obj.id, { [field]: v }, `site-${obj.id}-${field}`);
|
||||
|
||||
if (obj.type === "importedMesh") {
|
||||
// [T4] Glatt oder kantig schattieren, Knickwinkel je Mesh (Vorgabe 30°).
|
||||
return (
|
||||
<div className="site-props">
|
||||
<label className="site-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={obj.smoothShading === true}
|
||||
onChange={(e) => host.onPatchContextObject(obj.id, { smoothShading: e.target.checked }, `site-${obj.id}-smoothShading`)}
|
||||
/>
|
||||
{t("site.smoothShading")}
|
||||
</label>
|
||||
{obj.smoothShading === true && (
|
||||
<NumField label={t("site.creaseAngle")} value={obj.creaseAngle} step={5} min={1} placeholder="30" onChange={patch("creaseAngle")} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.type === "terrainMesh") {
|
||||
const cat = obj.categoryCode ? flattenCategories(host.project.layers).find((c) => c.code === obj.categoryCode) : undefined;
|
||||
const hasSource = (host.project.context ?? []).some((o) => o.type === "contourSet");
|
||||
return (
|
||||
<div className="site-props">
|
||||
{cat && (
|
||||
<label className="site-check" title={t("site.terrain.visible.hint", { name: `${cat.code} ${cat.name}` })}>
|
||||
<input type="checkbox" data-testid="terrain-visible" checked={cat.visible} onChange={() => host.onToggleCategory(cat.code)} />
|
||||
{t("site.terrain.visible")}
|
||||
</label>
|
||||
)}
|
||||
{hasSource && (
|
||||
<label className="site-prop" title={t("site.terrain.smooth.hint")}>
|
||||
<span>{t("site.terrain.smooth")}</span>
|
||||
<select
|
||||
data-testid="terrain-smooth"
|
||||
value={obj.smooth === undefined ? "" : String(obj.smooth)}
|
||||
onChange={(e) => {
|
||||
const v = Number(e.target.value);
|
||||
if (e.target.value === "" || !Number.isFinite(v)) return;
|
||||
if (!regenerateTerrain(obj.id, v)) notify(t("site.terrainFailed"), "error");
|
||||
}}
|
||||
>
|
||||
{obj.smooth === undefined && <option value="">—</option>}
|
||||
{SMOOTH_LEVELS.map((n) => (
|
||||
<option key={n} value={String(n)}>
|
||||
{n === 0 ? t("site.terrain.smooth.raw") : t("site.terrain.smooth.level", { n })}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
<NumField label={t("site.contourInterval")} value={obj.contourInterval} step={0.5} min={0} placeholder="—" onChange={patch("contourInterval")} />
|
||||
<NumField label={t("site.contourIndexEvery")} value={obj.contourIndexEvery} step={1} min={1} placeholder="5" onChange={patch("contourIndexEvery")} />
|
||||
<NumField label={t("site.earthDepth")} value={obj.earthDepth} step={0.5} min={0.1} placeholder="1.5" onChange={patch("earthDepth")} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (obj.type === "excavation") {
|
||||
return (
|
||||
<div className="site-props">
|
||||
<NumField label={t("site.excavation.bottom")} value={obj.bottom} step={0.05} onChange={(v) => v !== undefined && patch("bottom")(v)} />
|
||||
<NumField label={t("site.excavation.slope")} value={obj.slope} step={5} min={5} placeholder="45" onChange={patch("slope")} />
|
||||
<NumField label={t("site.excavation.fillSlope")} value={obj.fillSlope} step={5} min={5} placeholder="33.7" onChange={patch("fillSlope")} />
|
||||
<NumField label={t("site.excavation.bermWidth")} value={obj.bermWidth} step={0.25} min={0} placeholder="—" onChange={patch("bermWidth")} />
|
||||
<NumField label={t("site.excavation.bermHeight")} value={obj.bermHeight} step={0.5} min={0} placeholder="—" onChange={patch("bermHeight")} />
|
||||
<NumField label={t("site.excavation.workingSpace")} value={obj.workingSpace} step={0.1} min={0} placeholder="0" onChange={patch("workingSpace")} />
|
||||
<div className="site-prop" title={t("site.excavation.shoringHint")}>
|
||||
<span>{t("site.excavation.shoring")}</span>
|
||||
<span>
|
||||
{obj.outline.map((_, i) => (
|
||||
<label key={i} style={{ marginRight: 6 }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
data-testid={`excavation-shoring-${i}`}
|
||||
checked={obj.edgeShoring?.[i] === true}
|
||||
onChange={(e) => {
|
||||
const next = obj.outline.map((__, k) => (k === i ? e.target.checked : obj.edgeShoring?.[k] === true));
|
||||
host.onPatchContextObject(obj.id, { edgeShoring: next.some(Boolean) ? next : undefined }, `site-${obj.id}-edgeShoring`);
|
||||
}}
|
||||
/>
|
||||
{i + 1}
|
||||
</label>
|
||||
))}
|
||||
</span>
|
||||
</div>
|
||||
<ExcavationQty q={quantities.find((x) => x.id === obj.id)} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -59,6 +59,11 @@ import type {
|
||||
WallInfo,
|
||||
} from "../state/selectionInfo";
|
||||
import type { MeasurementReadout } from "../tools/types";
|
||||
import { useStore } from "../state/appStore";
|
||||
import { excavationQuantities } from "../core";
|
||||
import { ContextObjectProps } from "./ContextObjectProps";
|
||||
import { SunStudySection } from "./SunStudySection";
|
||||
import { SiteRulesSection } from "./SiteRulesSection";
|
||||
|
||||
// ── Bezugspunkt-Raster ───────────────────────────────────────────────────────
|
||||
// Neun Anker als 3×3-Raster. Zeile 0 = oben (fy=0), Spalte 0 = links (fx=0).
|
||||
@@ -91,7 +96,27 @@ export function ObjectInfoPanel() {
|
||||
// (das Mess-Werkzeug erzeugt kein Element). Hat Vorrang vor dem Leerzustand.
|
||||
const m = host.measurement;
|
||||
|
||||
// [137] Lage-Darstellung angeklickt (Schattenfläche / Baurechtslinie): Einstellungen der Quelle.
|
||||
const site = useStore((s) => s.selection.site);
|
||||
const ctxObj = sel?.kind === "contextObject" ? (host.project.context ?? []).find((o) => o.id === sel.id) : undefined;
|
||||
const quantities = useMemo(
|
||||
() => (ctxObj?.type === "excavation" ? excavationQuantities(host.project) : []),
|
||||
[ctxObj?.type, host.project],
|
||||
);
|
||||
|
||||
// ── Leerzustand ───────────────────────────────────────────────────────────
|
||||
if (sel === null && site.length > 0) {
|
||||
const sun = site[0] === "sunStudy";
|
||||
return (
|
||||
<div className="objinfo-panel">
|
||||
<div className="objinfo-head">
|
||||
<span className="objinfo-kind">{t(sun ? "objinfo.kind.sunStudy" : "objinfo.kind.siteRules")}</span>
|
||||
</div>
|
||||
<div className="objinfo-muted objinfo-site-hint">{t(sun ? "objinfo.sunStudy.hint" : "objinfo.siteRules.hint")}</div>
|
||||
<div className="site-panel objinfo-site">{sun ? <SunStudySection /> : <SiteRulesSection />}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (sel === null) {
|
||||
return (
|
||||
<div className="objinfo-panel">
|
||||
@@ -340,6 +365,11 @@ export function ObjectInfoPanel() {
|
||||
<span className="objinfo-flabel">{t("objinfo.contextObject.type")}</span>
|
||||
<span className="objinfo-fval">{t(`objinfo.contextObject.type.${sel.contextObject.objType}`)}</span>
|
||||
</div>
|
||||
{ctxObj && (
|
||||
<div className="site-panel objinfo-site">
|
||||
<ContextObjectProps obj={ctxObj} quantities={quantities} />
|
||||
</div>
|
||||
)}
|
||||
{sel.contextObject.lv95Center ? (
|
||||
<>
|
||||
<div className="objinfo-field">
|
||||
|
||||
+2
-158
@@ -27,6 +27,7 @@ import { SunStudySection } from "./SunStudySection";
|
||||
import { SiteRulesSection } from "./SiteRulesSection";
|
||||
import { PointCloudSection } from "./PointCloudSection";
|
||||
import { excavationQuantities } from "../core";
|
||||
import { ContextObjectProps } from "./ContextObjectProps";
|
||||
|
||||
/** Typ-spezifisches Badge-Label (i18n-Key) je Kontext-Objekt-Art. */
|
||||
function typeBadgeKey(obj: ContextObject): TranslationKey {
|
||||
@@ -61,37 +62,6 @@ function layerOf(obj: ContextObject): string {
|
||||
}
|
||||
}
|
||||
|
||||
/** Zahl-Eingabe für ein Feld eines Kontext-Objekts (leer = Standard, ungültig = keine Änderung). */
|
||||
function NumField(props: {
|
||||
label: string;
|
||||
value: number | undefined;
|
||||
step: number;
|
||||
min?: number;
|
||||
placeholder?: string;
|
||||
onChange: (v: number | undefined) => void;
|
||||
}) {
|
||||
return (
|
||||
<label className="site-prop">
|
||||
<span>{props.label}</span>
|
||||
<input
|
||||
type="number"
|
||||
step={props.step}
|
||||
min={props.min}
|
||||
placeholder={props.placeholder}
|
||||
value={props.value ?? ""}
|
||||
onChange={(e) => {
|
||||
const raw = e.target.value.trim();
|
||||
if (raw === "") return props.onChange(undefined);
|
||||
const v = Number(raw);
|
||||
if (Number.isFinite(v)) props.onChange(v);
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
);
|
||||
}
|
||||
|
||||
const fmt1 = (v: number) => v.toLocaleString("de-CH", { maximumFractionDigits: 1, minimumFractionDigits: 1 });
|
||||
|
||||
/** Gruppiert Kontext-Objekte nach Ebene, Reihenfolge des ersten Auftretens. */
|
||||
function groupByLayer(objects: ContextObject[]): { layer: string; items: ContextObject[] }[] {
|
||||
const order: string[] = [];
|
||||
@@ -109,15 +79,6 @@ function groupByLayer(objects: ContextObject[]): { layer: string; items: Context
|
||||
return order.map((layer) => ({ layer, items: byLayer.get(layer)! }));
|
||||
}
|
||||
|
||||
function ExcavationQty({ q }: { q: { cut: number; fill: number; backfill: number } | undefined }) {
|
||||
if (!q) return <div className="site-qty">{t("site.excavation.noTerrain")}</div>;
|
||||
return (
|
||||
<div className="site-qty">
|
||||
{t("site.excavation.qty", { cut: fmt1(q.cut), fill: fmt1(q.fill), backfill: fmt1(q.backfill) })}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function SitePanel() {
|
||||
const host = usePanelHost();
|
||||
// Gewählte Kontext-Objekte schmal aus dem Store ([121], [130]).
|
||||
@@ -140,8 +101,6 @@ export function SitePanel() {
|
||||
const [smooth, setSmooth] = useState(true);
|
||||
// [68] Mengen der Baugruben (Kern), nur neu, wenn sich das Projekt ändert.
|
||||
const quantities = useMemo(() => excavationQuantities(host.project), [host.project]);
|
||||
const patch = (id: string, field: string) => (v: number | undefined) =>
|
||||
host.onPatchContextObject(id, { [field]: v }, `site-${id}-${field}`);
|
||||
|
||||
const onGenerate = () => {
|
||||
if (!effectiveSet) return;
|
||||
@@ -278,122 +237,7 @@ export function SitePanel() {
|
||||
>
|
||||
×
|
||||
</button>
|
||||
{obj.type === "importedMesh" && (
|
||||
// [T4] Glatt oder kantig schattieren, Knickwinkel je Mesh (Vorgabe 30°).
|
||||
<div className="site-props">
|
||||
<label className="site-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={obj.smoothShading === true}
|
||||
onChange={(e) =>
|
||||
host.onPatchContextObject(obj.id, { smoothShading: e.target.checked }, `site-${obj.id}-smoothShading`)
|
||||
}
|
||||
/>
|
||||
{t("site.smoothShading")}
|
||||
</label>
|
||||
{obj.smoothShading === true && (
|
||||
<NumField
|
||||
label={t("site.creaseAngle")}
|
||||
value={obj.creaseAngle}
|
||||
step={5}
|
||||
min={1}
|
||||
placeholder="30"
|
||||
onChange={patch(obj.id, "creaseAngle")}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{obj.type === "terrainMesh" && (
|
||||
<div className="site-props">
|
||||
<NumField
|
||||
label={t("site.contourInterval")}
|
||||
value={obj.contourInterval}
|
||||
step={0.5}
|
||||
min={0}
|
||||
placeholder="—"
|
||||
onChange={patch(obj.id, "contourInterval")}
|
||||
/>
|
||||
<NumField
|
||||
label={t("site.contourIndexEvery")}
|
||||
value={obj.contourIndexEvery}
|
||||
step={1}
|
||||
min={1}
|
||||
placeholder="5"
|
||||
onChange={patch(obj.id, "contourIndexEvery")}
|
||||
/>
|
||||
<NumField
|
||||
label={t("site.earthDepth")}
|
||||
value={obj.earthDepth}
|
||||
step={0.5}
|
||||
min={0.1}
|
||||
placeholder="1.5"
|
||||
onChange={patch(obj.id, "earthDepth")}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{obj.type === "excavation" && (
|
||||
<div className="site-props">
|
||||
<NumField
|
||||
label={t("site.excavation.bottom")}
|
||||
value={obj.bottom}
|
||||
step={0.05}
|
||||
onChange={(v) => v !== undefined && patch(obj.id, "bottom")(v)}
|
||||
/>
|
||||
<NumField label={t("site.excavation.slope")} value={obj.slope} step={5} min={5} placeholder="45" onChange={patch(obj.id, "slope")} />
|
||||
<NumField
|
||||
label={t("site.excavation.fillSlope")}
|
||||
value={obj.fillSlope}
|
||||
step={5}
|
||||
min={5}
|
||||
placeholder="33.7"
|
||||
onChange={patch(obj.id, "fillSlope")}
|
||||
/>
|
||||
<NumField
|
||||
label={t("site.excavation.bermWidth")}
|
||||
value={obj.bermWidth}
|
||||
step={0.25}
|
||||
min={0}
|
||||
placeholder="—"
|
||||
onChange={patch(obj.id, "bermWidth")}
|
||||
/>
|
||||
<NumField
|
||||
label={t("site.excavation.bermHeight")}
|
||||
value={obj.bermHeight}
|
||||
step={0.5}
|
||||
min={0}
|
||||
placeholder="—"
|
||||
onChange={patch(obj.id, "bermHeight")}
|
||||
/>
|
||||
<NumField
|
||||
label={t("site.excavation.workingSpace")}
|
||||
value={obj.workingSpace}
|
||||
step={0.1}
|
||||
min={0}
|
||||
placeholder="0"
|
||||
onChange={patch(obj.id, "workingSpace")}
|
||||
/>
|
||||
<div className="site-prop" title={t("site.excavation.shoringHint")}>
|
||||
<span>{t("site.excavation.shoring")}</span>
|
||||
<span>
|
||||
{obj.outline.map((_, i) => (
|
||||
<label key={i} style={{ marginRight: 6 }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
data-testid={`excavation-shoring-${i}`}
|
||||
checked={obj.edgeShoring?.[i] === true}
|
||||
onChange={(e) => {
|
||||
const next = obj.outline.map((__, k) => (k === i ? e.target.checked : obj.edgeShoring?.[k] === true));
|
||||
host.onPatchContextObject(obj.id, { edgeShoring: next.some(Boolean) ? next : undefined }, `site-${obj.id}-edgeShoring`);
|
||||
}}
|
||||
/>
|
||||
{i + 1}
|
||||
</label>
|
||||
))}
|
||||
</span>
|
||||
</div>
|
||||
<ExcavationQty q={quantities.find((x) => x.id === obj.id)} />
|
||||
</div>
|
||||
)}
|
||||
<ContextObjectProps obj={obj} quantities={quantities} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
@@ -8,7 +8,7 @@ import { flattenCategories } from "../model/types";
|
||||
/** Art eines auswählbaren Objekts an einer Klickstelle (Reihenfolge = Standard-Priorität). */
|
||||
export type PickKind =
|
||||
| "section" | "opening" | "wall" | "column" | "drawing" | "solid"
|
||||
| "ceiling" | "stair" | "room" | "roof" | "context";
|
||||
| "ceiling" | "stair" | "room" | "roof" | "site" | "context";
|
||||
|
||||
type WithCategory = { id: string; categoryCode?: string };
|
||||
|
||||
@@ -25,7 +25,8 @@ function collection(project: Project, kind: PickKind): readonly WithCategory[] {
|
||||
case "column": return p.columns ?? [];
|
||||
case "context": return p.context ?? [];
|
||||
case "solid": return p.extrudedSolids ?? [];
|
||||
case "section": return [];
|
||||
case "section":
|
||||
case "site": return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,11 @@ export interface Selection {
|
||||
contextObjects: string[];
|
||||
/** Schnitt-/Ansichtslinien (DrawingLevel-Ids). */
|
||||
sectionLines: string[];
|
||||
/**
|
||||
* [137] Abgeleitete Lage-Darstellung (kein Modellelement): `"sunStudy"` (Schattenfläche angeklickt)
|
||||
* bzw. `"siteRules"` (Baurechtslinie) — die Objekt-Info zeigt die Einstellungen der Quelle.
|
||||
*/
|
||||
site: string[];
|
||||
/**
|
||||
* Gewählte Gruppen — rein informativ (Bounding-Box, Doppelklick-Ziel); die
|
||||
* Mitglieder stehen zusätzlich in den übrigen Arten (s. `groupActions.ts`).
|
||||
@@ -54,6 +59,7 @@ export const SELECTION_KINDS: readonly SelectionKind[] = [
|
||||
"roofs",
|
||||
"contextObjects",
|
||||
"sectionLines",
|
||||
"site",
|
||||
"groups",
|
||||
];
|
||||
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
// [137] Alles Sichtbare anwählbar (Musterhaus komplex): Klick im Grundriss auf Baugrube, Gelände,
|
||||
// Schatten und Baurechtslinien; Objekt-Info der Baugrube; Gelände neu glätten mit Undo.
|
||||
|
||||
import { beforeAll, describe, expect, it } from "vitest";
|
||||
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
|
||||
import { collectVisibleCodes } from "../model/layers";
|
||||
import { generatePlan } from "../plan/generatePlan";
|
||||
import { PlanPickIndex } from "../plan/planView/planPick";
|
||||
import { planPrimAt } from "../plan/planLazy";
|
||||
import { deriveSelection } from "./selectionInfo";
|
||||
import { getState, setState } from "./appStore";
|
||||
import type { Project, TerrainMesh } from "../model/types";
|
||||
|
||||
let p: Project;
|
||||
let terrainId: string;
|
||||
beforeAll(() => {
|
||||
p = buildComplexSampleProject();
|
||||
terrainId = p.context!.find((c) => c.type === "terrainMesh")!.id;
|
||||
});
|
||||
|
||||
/** Pick-Ids (Feld `contextObjectId`) unter (x, y) im EG 1:500, oberste zuerst — wie `PlanView.contextIdsAt`. */
|
||||
const idsAt = (proj: Project, pts: [number, number][]): string[][] => {
|
||||
const plan = generatePlan(proj, "eg", collectVisibleCodes(proj.layers), undefined, "mittel", false, false, true, 500);
|
||||
const ix = new PlanPickIndex(plan);
|
||||
const out = pts.map(([x, y]) => ix.polygonsAt({ x, y }, "contextObjectId").map((i) => (planPrimAt(plan, i) as { contextObjectId?: string }).contextObjectId!));
|
||||
ix.release();
|
||||
return out;
|
||||
};
|
||||
/** Erstes Kontext-Objekt (ohne Lage-Darstellung `@…`). */
|
||||
const contextAt = (proj: Project, x: number, y: number): string | null => idsAt(proj, [[x, y]])[0].find((id) => !id.startsWith("@")) ?? null;
|
||||
|
||||
describe("[137] Grundriss: Kontext anwählen", () => {
|
||||
it("Baugrube (Sohle und Böschung) vor dem Gelände, daneben das Gelände", () => {
|
||||
expect(contextAt(p, 8, -0.5)).toBe("baugrube");
|
||||
// Südwest-Böschung: ausserhalb der Sohle (Arbeitsraum 0.8 m um −0.36), noch im Wirkbereich.
|
||||
expect(contextAt(p, -1.6, 4)).toBe("baugrube");
|
||||
expect(contextAt(p, 25, -10)).toBe(terrainId);
|
||||
});
|
||||
|
||||
it("Objekt-Info der Baugrube: Kontext-Objekt der Art Baugrube", () => {
|
||||
const sel = deriveSelection(p, { contextObjects: ["baugrube"] });
|
||||
expect(sel?.kind).toBe("contextObject");
|
||||
expect(sel?.contextObject?.objType).toBe("excavation");
|
||||
});
|
||||
});
|
||||
|
||||
describe("[137] Schatten und Baurecht anwählen", () => {
|
||||
it("Parzellengrenze → Baurecht, Schattenfläche → Sonnenstand (Pick-Ids im Plan)", () => {
|
||||
// Westgrenze der Parzelle von (−14, −12) nach (−15, 24): bei y = 6 liegt sie auf x = −14.5.
|
||||
const grid: [number, number][] = [];
|
||||
for (let y = 22; y >= -4; y -= 1) for (let x = -10; x <= 26; x += 1) grid.push([x, y]);
|
||||
const [parcel, far, ...rest] = idsAt(p, [[-14.5, 6], [-40, -40], ...grid]);
|
||||
expect(parcel).toContain("@siteRules");
|
||||
expect(far).toEqual([]);
|
||||
// Schatten (21. Juni, 10 Uhr): irgendwo neben dem Haus.
|
||||
expect(rest.some((ids) => ids.includes("@sunStudy"))).toBe(true);
|
||||
// Studie aus: keine Schatten-Ids mehr.
|
||||
const off = idsAt({ ...p, sunStudy: { ...p.sunStudy!, show: false } }, grid);
|
||||
expect(off.some((ids) => ids.includes("@sunStudy"))).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("[137] Gelände neu glätten", () => {
|
||||
it("andere Stufe ersetzt das Netz (gleiche Id), Undo stellt es wieder her", () => {
|
||||
const terrain = () => getState().project.context!.find((c) => c.id === terrainId) as TerrainMesh;
|
||||
setState({ project: p, undoDepth: 0, redoDepth: 0, canUndo: false, canRedo: false });
|
||||
getState().clearHistory();
|
||||
const before = terrain();
|
||||
expect(before.smooth).toBe(2);
|
||||
expect(before.sourceId).toBe("hoehenlinien");
|
||||
expect(getState().regenerateTerrain(terrainId, 0)).toBe(true);
|
||||
const raw = terrain();
|
||||
expect(raw.smooth).toBe(0);
|
||||
expect(raw.indices.length).toBeLessThan(before.indices.length);
|
||||
expect(raw.contourInterval).toBe(before.contourInterval);
|
||||
getState().undo();
|
||||
expect(terrain().indices.length).toBe(before.indices.length);
|
||||
expect(terrain().smooth).toBe(2);
|
||||
});
|
||||
});
|
||||
+22
-1
@@ -35,6 +35,12 @@ export interface SiteSlice {
|
||||
generateTerrain: (contourSetId: string, opts?: TerrainOptions) => string | null;
|
||||
/** [T6]/[68] Ändert Felder eines Kontext-Objekts (Gelände, Baugrube) in einem Schritt; `coalesceKey` für Tippen. */
|
||||
patchContextObject: (id: string, patch: Record<string, unknown>, coalesceKey?: string) => void;
|
||||
/**
|
||||
* [137] Gelände `terrainId` aus seinen Höhenlinien (`sourceId`, sonst dem ersten Höhenlinien-Satz) mit
|
||||
* Glättungsstufe `smooth` (0 = roh) neu erzeugen — gleiche Id und Einstellungen, ein Undo-Schritt.
|
||||
* `false`, wenn es keine Quelle gibt oder kein Netz entsteht.
|
||||
*/
|
||||
regenerateTerrain: (terrainId: string, smooth: number) => boolean;
|
||||
/** Leert die gesamte Kontext-Schicht. */
|
||||
clearContext: () => void;
|
||||
}
|
||||
@@ -94,10 +100,25 @@ export function createSiteSlice(
|
||||
if (!set || set.type !== "contourSet") return null;
|
||||
const terrain = generateTerrainFromContours(set.contours, opts);
|
||||
if (terrain.indices.length === 0) return null; // kein sinnvolles TIN
|
||||
addToContext([terrain]);
|
||||
addToContext([{ ...terrain, sourceId: set.id }]);
|
||||
return terrain.id;
|
||||
},
|
||||
|
||||
regenerateTerrain: (terrainId, smooth) => {
|
||||
const ctx = get().project.context ?? [];
|
||||
const terrain = ctx.find((o) => o.id === terrainId && o.type === "terrainMesh");
|
||||
if (!terrain || terrain.type !== "terrainMesh") return false;
|
||||
const sets = ctx.filter((o) => o.type === "contourSet");
|
||||
const set = sets.find((o) => o.id === terrain.sourceId) ?? sets[0];
|
||||
if (!set || set.type !== "contourSet") return false;
|
||||
const fresh = generateTerrainFromContours(set.contours, { smooth });
|
||||
if (fresh.indices.length === 0) return false;
|
||||
get().applyChange((p) =>
|
||||
patchItem(p, "context", terrainId, (o) => ({ ...o, positions: fresh.positions, indices: fresh.indices, smooth, sourceId: set.id }) as ContextObject),
|
||||
);
|
||||
return true;
|
||||
},
|
||||
|
||||
clearContext: () => get().applyChange((p) => fieldOps(p, "context", [])),
|
||||
};
|
||||
}
|
||||
@@ -206,6 +206,7 @@ export function useMouseSelectionHandlers(opts: {
|
||||
column: "columns",
|
||||
roof: "roofs",
|
||||
context: "contextObjects",
|
||||
site: "site",
|
||||
} as const satisfies Record<string, SelectionKind>;
|
||||
type Kind = keyof typeof channels;
|
||||
const target: { kind: Kind; id: string } | null = sel.sectionLineId
|
||||
@@ -286,7 +287,9 @@ export function useMouseSelectionHandlers(opts: {
|
||||
? ["roofs", sel.roofId]
|
||||
: sel.contextObjectId
|
||||
? ["contextObjects", sel.contextObjectId]
|
||||
: null;
|
||||
: sel.siteId
|
||||
? ["site", sel.siteId]
|
||||
: null;
|
||||
setSelection({ ...clearKinds(), groups: [], ...(one ? { [one[0]]: [one[1]] } : {}) });
|
||||
};
|
||||
// Links-Drag (Marquee) im Grundriss: die getroffene Wand-MENGE übernehmen
|
||||
|
||||
+43
-15
@@ -189,7 +189,7 @@ export interface PlanViewHandle {
|
||||
|
||||
const PICK_ORDER: readonly PickKind[] = [
|
||||
"section", "opening", "wall", "column", "drawing", "solid",
|
||||
"ceiling", "stair", "room", "roof", "context",
|
||||
"ceiling", "stair", "room", "roof", "site", "context",
|
||||
];
|
||||
|
||||
/** Ein Objekt unter dem Cursor — für das Durchschalten übereinanderliegender Objekte. */
|
||||
@@ -218,6 +218,7 @@ const EMPTY_PICK: PickIds = {
|
||||
roofId: null,
|
||||
sectionLineId: null,
|
||||
contextObjectId: null,
|
||||
siteId: null,
|
||||
};
|
||||
|
||||
/** Mac: Cmd+Klick; sonst Strg+Klick (Alt+Klick ist die Schere, Ctrl+Klick unter macOS das Kontextmenü). */
|
||||
@@ -292,6 +293,11 @@ export interface PlanSelection {
|
||||
* (alle anderen gehen vor, analog `roofId`); sonst `null`.
|
||||
*/
|
||||
contextObjectId: string | null;
|
||||
/**
|
||||
* [137] Getroffene Lage-Darstellung (Schattenfläche → `"sunStudy"`, Baurechtslinie → `"siteRules"`),
|
||||
* wenn kein Element höherer Priorität getroffen wurde; Vorrang vor Kontext-Objekten (sie liegt darüber).
|
||||
*/
|
||||
siteId?: string | null;
|
||||
/**
|
||||
* War beim Klick Shift gedrückt? Dann ERWEITERT der Aufrufer (App) die
|
||||
* Auswahl um das getroffene Element (bzw. schaltet es ab/zu), statt sie zu
|
||||
@@ -675,6 +681,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
columns: selectedColumnIds,
|
||||
groups: selectedGroupIds,
|
||||
drawings: selectedDrawingIds,
|
||||
site: selectedSite,
|
||||
} = selection;
|
||||
const selectedDrawingId = single(selection, "drawings");
|
||||
// Linke Maustaste liegt beim Werkzeug/der Transformation, wenn App das meldet
|
||||
@@ -1565,12 +1572,24 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
// Grundriss-Pick-Band (Bounding-Box) per Punkt-in-Polygon — macht es wie eine
|
||||
// Wand irgendwo innerhalb seiner Fläche anklickbar, nicht nur exakt auf der
|
||||
// dünnen Umrisslinie.
|
||||
const pickContextObject = (clientX: number, clientY: number): string | null => {
|
||||
// Pick-Ids unter dem Cursor im Feld `contextObjectId`, oberste zuerst. Die abgeleitete Lage-Darstellung
|
||||
// ([137], Kern `plan/extras.rs`) trägt dort `@sunStudy`/`@siteRules` (Schattenflächen, Baurechts-Bänder).
|
||||
const contextIdsAt = (clientX: number, clientY: number): string[] => {
|
||||
const v = clientToView(clientX, clientY, view);
|
||||
const i = getPick().topPolygon(viewToModel(v.x, v.y), "contextObjectId");
|
||||
return i === null ? null : (planPrimAt(plan, i) as { contextObjectId?: string }).contextObjectId!;
|
||||
const pick = getPick();
|
||||
return pick.polygonsAt(viewToModel(v.x, v.y), "contextObjectId").map((i) => (pick.prim(i) as { contextObjectId?: string }).contextObjectId!);
|
||||
};
|
||||
|
||||
// [137] Getroffene Lage-Darstellung: Quelle `"sunStudy"`/`"siteRules"` (Baurechtslinie vor Schatten) oder null.
|
||||
const pickSiteAt = (clientX: number, clientY: number): string | null => {
|
||||
const ids = contextIdsAt(clientX, clientY).filter((id) => id.startsWith("@"));
|
||||
const id = ids.find((x) => x === "@siteRules") ?? ids[0];
|
||||
return id ? id.slice(1) : null;
|
||||
};
|
||||
|
||||
const pickContextObject = (clientX: number, clientY: number): string | null =>
|
||||
contextIdsAt(clientX, clientY).find((id) => !id.startsWith("@")) ?? null;
|
||||
|
||||
// Getroffener extrudierter Körper (truck-Integration): der Footprint-Umriss
|
||||
// ist ein reiner Haarlinien-Umriss (fill:"none"), aber per Punkt-in-Polygon
|
||||
// trotzdem als FLÄCHE anklickbar (analog Raum, nicht nur auf der Linie).
|
||||
@@ -2119,8 +2138,13 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
// Kontext-Objekt (Gebäude/Terrain) als ALLERLETZTE Priorität — seine
|
||||
// Bbox-Pick-Fläche kann grosszügig überlappen, daher erst wenn wirklich
|
||||
// nichts anderes getroffen wurde.
|
||||
const contextObjectId =
|
||||
// [137] Schatten/Baurechtslinien (Lage-Darstellung) über dem Gelände, unter allen Bauteilen.
|
||||
const siteId =
|
||||
openingId || wallId || columnId || drawingId || extrudedSolidId || ceilingId || stairId || roomId || roofId
|
||||
? null
|
||||
: pickSiteAt(clientX, clientY);
|
||||
const contextObjectId =
|
||||
openingId || wallId || columnId || drawingId || extrudedSolidId || ceilingId || stairId || roomId || roofId || siteId
|
||||
? null
|
||||
: pickContextObject(clientX, clientY);
|
||||
return {
|
||||
@@ -2136,6 +2160,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
roofId,
|
||||
sectionLineId: null,
|
||||
contextObjectId,
|
||||
siteId,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -2236,7 +2261,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
const key = `${kind}:${id}`;
|
||||
if (seen.has(key)) return;
|
||||
seen.add(key);
|
||||
const base = kind === "drawing" ? drawingLabel(id) : t(`pick.kind.${kind}`);
|
||||
const base = kind === "drawing" ? drawingLabel(id) : kind === "site" ? t(id === "siteRules" ? "pick.site.siteRules" : "pick.site.sunStudy") : t(`pick.kind.${kind}`);
|
||||
const cat = describePick?.(kind, id);
|
||||
out.push({ kind, id, hitIndex, label: cat ? `${base} · ${cat}` : base });
|
||||
};
|
||||
@@ -2251,6 +2276,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
add("stair", dp.stairId, dp.hitIndex);
|
||||
add("room", dp.roomId, dp.hitIndex);
|
||||
add("roof", dp.roofId, dp.hitIndex);
|
||||
add("site", dp.siteId, dp.hitIndex);
|
||||
add("context", dp.contextObjectId, dp.hitIndex);
|
||||
const first = out.slice();
|
||||
// 2) Alles Übrige an dieser Stelle, nach Standard-Priorität sortiert.
|
||||
@@ -2272,7 +2298,8 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
addRest("stair", p.stairId, idx);
|
||||
addRest("room", p.roomId, idx);
|
||||
addRest("roof", p.roofId, idx);
|
||||
addRest("context", p.contextObjectId, idx);
|
||||
if (p.contextObjectId?.startsWith("@")) addRest("site", p.contextObjectId.slice(1), idx);
|
||||
else addRest("context", p.contextObjectId, idx);
|
||||
addRest("section", p.sectionLineId, idx);
|
||||
}
|
||||
for (const id of nearDrawingIds(clientX, clientY)) addRest("drawing", id, null);
|
||||
@@ -2282,6 +2309,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
addRest("stair", pickStair(clientX, clientY), null);
|
||||
addRest("room", pickRoom(clientX, clientY), null);
|
||||
addRest("roof", pickRoof(clientX, clientY), null);
|
||||
addRest("site", pickSiteAt(clientX, clientY), null);
|
||||
addRest("context", pickContextObject(clientX, clientY), null);
|
||||
addRest("section", pickSectionLine(clientX, clientY), null);
|
||||
// Stabil nach Standard-Priorität ordnen (innerhalb einer Art bleibt die Fundreihenfolge).
|
||||
@@ -2317,6 +2345,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
roofId: c.kind === "roof" ? c.id : null,
|
||||
sectionLineId: c.kind === "section" ? c.id : null,
|
||||
contextObjectId: c.kind === "context" ? c.id : null,
|
||||
siteId: c.kind === "site" ? c.id : null,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -2794,14 +2823,12 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
// Hervorhebung der selektierten Kontext-Objekte (Gebäude/Terrain): das
|
||||
// (unsichtbare) Bbox-Pick-Band mit contextObjectId als Akzentkontur
|
||||
// überzeichnen — analog zur Dach-/Raum-Auswahl.
|
||||
// [137] Gewählte Lage-Darstellung (Schatten/Baurecht): ihre Flächen bzw. Bänder (`@…`-Ids) ebenso.
|
||||
const highlightContextObjectPolys = useMemo(() => {
|
||||
const ids =
|
||||
selectedContextObjectIds && selectedContextObjectIds.length
|
||||
? new Set(selectedContextObjectIds)
|
||||
: null;
|
||||
if (!ids) return [];
|
||||
return primsOwnedBy("contextObjectId", selectedContextObjectIds, (p): p is Extract<Primitive, { kind: "polygon" }> => p.kind === "polygon");
|
||||
}, [plan, selectedContextObjectIds]);
|
||||
const ids = [...(selectedContextObjectIds ?? []), ...(selectedSite ?? []).map((s) => "@" + s)];
|
||||
if (!ids.length) return [];
|
||||
return primsOwnedBy("contextObjectId", ids, (p): p is Extract<Primitive, { kind: "polygon" }> => p.kind === "polygon");
|
||||
}, [plan, selectedContextObjectIds, selectedSite]);
|
||||
|
||||
// Hervorhebung der selektierten Schnitt-/Ansichtslinie: das (unsichtbare)
|
||||
// Pick-Band (Polygon mit sectionLineId) mit Akzentkontur überzeichnen.
|
||||
@@ -2838,7 +2865,8 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
// Primitive des per Listen-Hover vorgemerkten Objekts (Vorschau-Hervorhebung).
|
||||
const hoverPrims = useMemo((): Primitive[] => {
|
||||
if (!hoverPick) return [];
|
||||
const field: Record<PickKind, OwnerField> = {
|
||||
if (hoverPick.kind === "site") return primsOwnedBy("contextObjectId", ["@" + hoverPick.id], (_p): _p is Primitive => true);
|
||||
const field: Record<Exclude<PickKind, "site">, OwnerField> = {
|
||||
wall: "wallId", drawing: "drawingId", ceiling: "ceilingId", opening: "openingId",
|
||||
stair: "stairId", room: "roomId", roof: "roofId", context: "contextObjectId",
|
||||
section: "sectionLineId", solid: "extrudedSolidId", column: "columnId",
|
||||
|
||||
@@ -828,6 +828,7 @@ function LevelPlanView({
|
||||
[project],
|
||||
);
|
||||
|
||||
|
||||
// Live-Spiegelung in die nativen wgpu-Fenster (No-op ohne Tauri, debounced):
|
||||
// EXAKT der sichtbare Plan (gleiches Geschoss, gleicher Detailgrad) fürs
|
||||
// 2D-Fenster, die Projekt-Wände fürs 3D-Fenster.
|
||||
|
||||
Reference in new issue
Block a user