Merge branch 'worktree-agent-a51ea478afbfa7f47' into claude/practical-noether-1hb2s1
This commit is contained in:
4 files changed
+89
-28
No files matched your search
@@ -1930,8 +1930,13 @@ pub fn plan_drawings(c: &Ctx, sink: &mut Sink, bounds: &mut Bounds) -> Result<()
|
||||
/// auf Klassen, die `pred` (Klassen-Code) wählt und die der Plan zeigt; je Klasse in Projekt-Reihenfolge. Quelle der
|
||||
/// gefüllten Kataster-Gebäude und -Gewässer im Situationsplan (`situation.rs`).
|
||||
pub fn closed_rings_by_class(c: &Ctx, pred: impl Fn(&str) -> bool) -> Vec<(String, Vec<Vec<[f64; 2]>>)> {
|
||||
closed_rings_by_class_ids(c, pred).into_iter().map(|(k, v)| (k, v.into_iter().map(|(_, r)| r).collect())).collect()
|
||||
}
|
||||
|
||||
/// Wie [`closed_rings_by_class`], aber jeder Ring trägt die Id seiner Zeichnung (Anwahl der gefüllten Flächen).
|
||||
pub fn closed_rings_by_class_ids(c: &Ctx, pred: impl Fn(&str) -> bool) -> Vec<(String, Vec<(String, Vec<[f64; 2]>)>)> {
|
||||
let mut memo = Memo::default();
|
||||
let mut out: Vec<(String, Vec<Vec<[f64; 2]>>)> = Vec::new();
|
||||
let mut out: Vec<(String, Vec<(String, Vec<[f64; 2]>)>)> = Vec::new();
|
||||
for d in &c.p.drawings2d {
|
||||
if !matches!(d.geom, Drawing2DGeom::Polyline { closed: true, .. } | Drawing2DGeom::Rect { .. }) || !pred(&d.category_code) || !on_floor(c, d) {
|
||||
continue;
|
||||
@@ -1952,9 +1957,10 @@ pub fn closed_rings_by_class(c: &Ctx, pred: impl Fn(&str) -> bool) -> Vec<(Strin
|
||||
if rings.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let rings = rings.into_iter().map(|r| (d.id.clone(), r));
|
||||
match out.iter_mut().find(|(k, _)| *k == d.category_code) {
|
||||
Some((_, v)) => v.extend(rings),
|
||||
None => out.push((d.category_code.clone(), rings)),
|
||||
None => out.push((d.category_code.clone(), rings.collect())),
|
||||
}
|
||||
}
|
||||
out
|
||||
|
||||
@@ -193,12 +193,31 @@ pub fn mesh_polygons(positions: &[f64], indices: &[f64]) -> Vec<Polygon> {
|
||||
|
||||
/// Gefüllte Flächen: ein Polygon je Fläche; Löcher sind über Brücken eingebunden (Brückenkanten ohne Strich).
|
||||
fn fill_polygons(polys: &[Polygon], f: (&str, &str), context_id: Option<&str>, greyed: bool, out: &mut Vec<Primitive>) {
|
||||
fill_polygons_of(polys, f, context_id, greyed, out, |_| None)
|
||||
}
|
||||
|
||||
/// Wie [`fill_polygons`]; `drawing_of` nennt je Polygon die Zeichnung, der es gehört (Anwahl im Plan).
|
||||
fn fill_polygons_of(polys: &[Polygon], f: (&str, &str), context_id: Option<&str>, greyed: bool, out: &mut Vec<Primitive>, drawing_of: impl Fn(&Polygon) -> Option<String>) {
|
||||
for poly in polys {
|
||||
let Some(outer) = poly.first().filter(|r| r.len() >= 3) else { continue };
|
||||
let from = out.len();
|
||||
fill_polygon(poly, f, context_id, greyed, out);
|
||||
if let Some(id) = drawing_of(poly) {
|
||||
for q in &mut out[from..] {
|
||||
if let Primitive::Polygon { drawing_id, .. } = q {
|
||||
*drawing_id = Some(id.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn fill_polygon(poly: &Polygon, f: (&str, &str), context_id: Option<&str>, greyed: bool, out: &mut Vec<Primitive>) {
|
||||
{
|
||||
let Some(outer) = poly.first().filter(|r| r.len() >= 3) else { return };
|
||||
let holes: Vec<Ring> = poly.iter().skip(1).filter(|r| r.len() >= 3).cloned().collect();
|
||||
if holes.is_empty() {
|
||||
out.push(polygon(outer.iter().map(|q| v2(*q)).collect(), f.0, f.1, OUTLINE_MM, context_id, greyed));
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
let merged = crate::polygon_holes::merge_holes(outer, &holes, 1e-4);
|
||||
let mut prim = polygon(merged.ring.iter().map(|q| v2(*q)).collect(), f.0, f.1, OUTLINE_MM, context_id, greyed);
|
||||
@@ -231,15 +250,17 @@ fn name_has(c: &Ctx, code: &str, words: &[&str]) -> bool {
|
||||
/// der Klasse der Zeichnung (die Klasse bestimmt über [`super::drawings::closed_rings_by_class`], ob sie erscheinen).
|
||||
/// Innenhöfe sind Löcher. Unterhalb der Zeichnungen; deren Linien bleiben darüber.
|
||||
pub fn cadastre_prims(c: &Ctx, s: &Opts, out: &mut Vec<Primitive>) {
|
||||
let fills = |kind: fn(&Ctx, &str) -> bool| super::drawings::closed_rings_by_class(c, |code| kind(c, code));
|
||||
let fills = |kind: fn(&Ctx, &str) -> bool| super::drawings::closed_rings_by_class_ids(c, |code| kind(c, code));
|
||||
if let Some(f) = colors(s.context) {
|
||||
for (code, rings) in fills(is_building_class) {
|
||||
fill_polygons(&crate::polygon_bool::nest_even_odd(&rings), f, None, c.greyed(&code), out);
|
||||
let (polys, owner) = nest_with_owner(&rings);
|
||||
fill_polygons_of(&polys, f, None, c.greyed(&code), out, owner);
|
||||
}
|
||||
}
|
||||
for (code, rings) in fills(is_water_class) {
|
||||
let from = out.len();
|
||||
fill_polygons(&crate::polygon_bool::nest_even_odd(&rings), WATER, None, c.greyed(&code), out);
|
||||
let (polys, owner) = nest_with_owner(&rings);
|
||||
fill_polygons_of(&polys, WATER, None, c.greyed(&code), out, owner);
|
||||
for q in &mut out[from..] {
|
||||
if let Primitive::Polygon { hatch, .. } = q {
|
||||
*hatch = Box::new(water_hatch(c.a.scale));
|
||||
@@ -248,6 +269,24 @@ pub fn cadastre_prims(c: &Ctx, s: &Opts, out: &mut Vec<Primitive>) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Verschachtelt die Ringe (gerade/ungerade) und liefert dazu die Zuordnung Polygon → Zeichnung: Der Aussenring eines
|
||||
/// Polygons gehört der Zeichnung, deren Ring denselben Eckpunkt hat (kleinster Flächenunterschied bei mehreren).
|
||||
fn nest_with_owner(rings: &[(String, Ring)]) -> (Vec<Polygon>, impl Fn(&Polygon) -> Option<String> + '_) {
|
||||
let plain: Vec<Ring> = rings.iter().map(|(_, r)| r.clone()).collect();
|
||||
let area = |r: &Ring| (0..r.len()).map(|i| r[i][0] * r[(i + 1) % r.len()][1] - r[(i + 1) % r.len()][0] * r[i][1]).sum::<f64>().abs() / 2.0;
|
||||
let owner = move |poly: &Polygon| -> Option<String> {
|
||||
let outer = poly.first()?;
|
||||
let a = area(outer);
|
||||
let p0 = *outer.first()?;
|
||||
rings
|
||||
.iter()
|
||||
.filter(|(_, r)| r.contains(&p0))
|
||||
.min_by(|x, y| (area(&x.1) - a).abs().total_cmp(&(area(&y.1) - a).abs()))
|
||||
.map(|(id, _)| id.clone())
|
||||
};
|
||||
(crate::polygon_bool::nest_even_odd(&plain), owner)
|
||||
}
|
||||
|
||||
/// Wasser als feine waagrechte Parallelschraffur (Plangrafik-Brauch für Gewässer): bleibt in Tusche erhalten, wo die
|
||||
/// hellblaue Fläche weiss wird (`extras::Post`: bunte Fläche → Papier, bunte Schraffur → Tinte). Abstand auf dem
|
||||
/// Papier fest ([`WATER_HATCH_MM`]), unabhängig vom Massstab; Musterabstand = 8 · scale / 90 m.
|
||||
|
||||
@@ -36,7 +36,7 @@ import { ViewShadowsInfo, MeasurementSection } from "./objectInfo/InfoBlocks";
|
||||
import { DimensionField, RotateField } from "./objectInfo/fields";
|
||||
import { elementDimensions } from "./objectInfo/elementDims";
|
||||
import { InfoGroups, hasInfoGroups } from "./objectInfo/InfoGroups";
|
||||
import { InfoGroup } from "./objectInfo/InfoGroup";
|
||||
import { infoGroupFrame, useInfoGroupState } from "./objectInfo/InfoGroup";
|
||||
|
||||
// ── Bezugspunkt-Raster ───────────────────────────────────────────────────────
|
||||
// Neun Anker als 3×3-Raster. Zeile 0 = oben (fy=0), Spalte 0 = links (fx=0).
|
||||
@@ -63,6 +63,8 @@ function toDeg360(rad: number): number {
|
||||
export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: boolean } = {}) {
|
||||
const host = usePanelHost();
|
||||
const storeProject = useStore((st) => st.project);
|
||||
// [121] Abschnitts-Rahmen ohne eigene Komponente (kein Render je Abschnitt bei Inhaltsänderung).
|
||||
const gst = useInfoGroupState();
|
||||
const sel = useSelectionInfo();
|
||||
|
||||
// Gewählter Bezugspunkt — Default Mitte (Vectorworks-Standardanker beim
|
||||
@@ -194,7 +196,7 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool
|
||||
|
||||
{showPlacement && (
|
||||
<>
|
||||
<InfoGroup id="refpoint">
|
||||
{infoGroupFrame(gst, "refpoint", <>
|
||||
{/* Bezugspunkt-Würfel (3×3, immer quadratisch) links, X/Y/Z als Spalte
|
||||
rechts daneben (Nutzer-Wunsch). */}
|
||||
<div className="objinfo-refrow">
|
||||
@@ -248,9 +250,9 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool
|
||||
<RotateField onCommit={(deg) => host.onRotateSelectionAround(px, py, deg)} />
|
||||
</div>
|
||||
</div>
|
||||
</InfoGroup>
|
||||
</>)}
|
||||
|
||||
<InfoGroup id="dimensions">
|
||||
{infoGroupFrame(gst, "dimensions", <>
|
||||
{/* Maße (editierbar) — Commit auf blur/Enter skaliert um den Anker. */}
|
||||
{elementDims ? (
|
||||
// [204a] Wand: Länge/Dicke/Höhe, Öffnung: Breite/Höhe/Brüstung (nur Anzeige).
|
||||
@@ -351,7 +353,7 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</InfoGroup>
|
||||
</>)}
|
||||
</>
|
||||
)}
|
||||
{/* Gelände-/Umgebungs-Element (Netzkörper, Gelände, Höhenlinien …): Art, Herkunft (nur Auskunft, [181]),
|
||||
@@ -359,7 +361,7 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool
|
||||
georeferenziert importiert wurde (Nutzer-Wunsch zum Prüfen). */}
|
||||
{sel.contextObject && (
|
||||
<>
|
||||
<InfoGroup id="contextProps">
|
||||
{infoGroupFrame(gst, "contextProps", <>
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.contextObject.type")}</span>
|
||||
<span className="objinfo-fval">{t(`objinfo.contextObject.type.${sel.contextObject.objType}`)}</span>
|
||||
@@ -369,9 +371,9 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool
|
||||
<ContextObjectProps obj={ctxObj} quantities={quantities} />
|
||||
</div>
|
||||
)}
|
||||
</InfoGroup>
|
||||
</>)}
|
||||
{/* [239] Herkunft und LV95 stehen in eigener Gruppe (Standard zugeklappt: nur Auskunft). */}
|
||||
<InfoGroup id="georef">
|
||||
{infoGroupFrame(gst, "georef", <>
|
||||
{sel.contextObject.source && (
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.contextObject.source")}</span>
|
||||
@@ -394,7 +396,7 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool
|
||||
<span className="objinfo-fval objinfo-muted">{t("objinfo.contextObject.noAnchor")}</span>
|
||||
</div>
|
||||
)}
|
||||
</InfoGroup>
|
||||
</>)}
|
||||
</>
|
||||
)}
|
||||
{/* [189] Bauteil-/BIM-Abschnitte (Wand, Decke, Öffnung, Treppe, Raum …) als einklappbare Gruppen. */}
|
||||
|
||||
@@ -1,25 +1,34 @@
|
||||
// [189] Einklappbarer Abschnitt der Objekt-Info: Kopfzeile (Knopf mit Pfeil) und Inhalt. Die Abschnitts-
|
||||
// Komponenten (`WallSection` …) bringen ihre eigene Kopf-Trennlinie mit; die erste blendet das CSS im Rumpf aus.
|
||||
|
||||
import { useEffect, useRef, useSyncExternalStore, type ReactNode } from "react";
|
||||
import { useSyncExternalStore, type ReactNode } from "react";
|
||||
import { t } from "../../i18n";
|
||||
import { INFO_GROUP_TITLE, type InfoGroupId } from "./groups";
|
||||
import { clearInfoGroupFocus, getInfoGroupState, isInfoGroupOpen, subscribeInfoGroups, toggleInfoGroup } from "./infoGroupState";
|
||||
|
||||
export function InfoGroup({ id, children }: { id: InfoGroupId; children: ReactNode }) {
|
||||
const st = useSyncExternalStore(subscribeInfoGroups, getInfoGroupState, getInfoGroupState);
|
||||
type GroupState = ReturnType<typeof getInfoGroupState>;
|
||||
|
||||
/** Zustand der Abschnitte (offen/zu, Fokus-Anfrage) für [`infoGroupFrame`]. */
|
||||
export function useInfoGroupState(): GroupState {
|
||||
return useSyncExternalStore(subscribeInfoGroups, getInfoGroupState, getInfoGroupState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Abschnitt als blosses Markup, ohne eigene Komponente: Das Panel liest den Zustand einmal ([`useInfoGroupState`])
|
||||
* und rahmt damit mehrere Abschnitte, ohne dass je Abschnitt ein Komponenten-Render bei jeder Änderung des Inhalts
|
||||
* anfällt ([121], Render-Zählung). Die Fokus-Anfrage löst der Ref des Kopfknopfs ein.
|
||||
*/
|
||||
export function infoGroupFrame(st: GroupState, id: InfoGroupId, children: ReactNode): ReactNode {
|
||||
const open = isInfoGroupOpen(st, id);
|
||||
const head = useRef<HTMLButtonElement>(null);
|
||||
useEffect(() => {
|
||||
if (st.focus?.id !== id) return;
|
||||
head.current?.scrollIntoView?.({ block: "nearest" });
|
||||
head.current?.focus();
|
||||
clearInfoGroupFocus();
|
||||
}, [st.focus, id]);
|
||||
return (
|
||||
<section className="objinfo-group" data-group={id} data-open={open}>
|
||||
<section key={id} className="objinfo-group" data-group={id} data-open={open}>
|
||||
<button
|
||||
ref={head}
|
||||
ref={(el) => {
|
||||
if (!el || st.focus?.id !== id) return;
|
||||
el.scrollIntoView?.({ block: "nearest" });
|
||||
el.focus();
|
||||
clearInfoGroupFocus();
|
||||
}}
|
||||
type="button"
|
||||
className="objinfo-group-head"
|
||||
aria-expanded={open}
|
||||
@@ -33,3 +42,8 @@ export function InfoGroup({ id, children }: { id: InfoGroupId; children: ReactNo
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export function InfoGroup({ id, children }: { id: InfoGroupId; children: ReactNode }) {
|
||||
const st = useInfoGroupState();
|
||||
return infoGroupFrame(st, id, children);
|
||||
}
|
||||
Reference in new issue
Block a user