Merge branch 'worktree-agent-ac2733317425a5805' into claude/practical-noether-1hb2s1
This commit is contained in:
14 files changed
+347
-17
No files matched your search
@@ -36,6 +36,8 @@ export type GripRequest =
|
||||
// [193] Höhenlinien-Satz: Punkt (flacher Index über alle Linien) ziehen bzw. hinter Punkt `seg` einfügen (Kern `contour_edit`).
|
||||
| { op: "contourGrip"; id: string; index: number; pt: P }
|
||||
| { op: "contourInsert"; id: string; seg: number; pt: P }
|
||||
// [193] Gelände-Netz: Netzpunkt (Vertex-Nummer) im Grundriss verschieben (Kern `mesh_grip`).
|
||||
| { op: "meshGrip"; id: string; index: number; pt: P }
|
||||
// [26] Dach: Ecke bzw. Kante von Umriss/Hof, flacher Index (erst `outline`, dann `holes` Ring für Ring).
|
||||
| { op: "roofVertex"; id: string; index: number; pt: P }
|
||||
| { op: "roofEdge"; id: string; a: number; b: number; delta: P }
|
||||
|
||||
@@ -2440,6 +2440,13 @@ export const de = {
|
||||
"site.heightOffset.hint": "Alle Höhen des Elements um diesen Wert verschieben (Eingabe mit Enter bestätigen; negativ = tiefer).",
|
||||
"site.contours": "Höhenlinien ({n}) — Höhe [m]",
|
||||
"site.contour.points": "{n} Punkte",
|
||||
"site.meshPoint": "Netzpunkt Nr.",
|
||||
"site.meshPoint.hint": "Nummer des Netzpunkts (1 bis {n}); seine Lage ziehst du im Grundriss am Griff",
|
||||
"site.meshPoint.z": "Höhe des Punkts (m)",
|
||||
"site.meshCrop": "Auf Grundstück zuschneiden",
|
||||
"site.meshCrop.hint": "Entfernt alle Dreiecke, deren Schwerpunkt ausserhalb der Parzelle liegt",
|
||||
"site.meshCrop.noParcel": "Zuerst die Parzelle im Baurecht erfassen",
|
||||
"site.meshCrop.nothing": "Nichts zuzuschneiden: Das Netz liegt ganz innerhalb der Parzelle bzw. ausserhalb davon.",
|
||||
"site.excavation.bottom": "Sohle [m]",
|
||||
"site.excavation.slope": "Böschung [°]",
|
||||
"site.excavation.fillSlope": "Schüttung [°]",
|
||||
|
||||
@@ -2428,6 +2428,13 @@ export const en: Record<TranslationKey, string> = {
|
||||
"site.heightOffset.hint": "Shift all heights of this element by this value (confirm with Enter; negative = lower).",
|
||||
"site.contours": "Contours ({n}) — height [m]",
|
||||
"site.contour.points": "{n} points",
|
||||
"site.meshPoint": "Mesh point no.",
|
||||
"site.meshPoint.hint": "Number of the mesh point (1 to {n}); drag its position in the plan by its grip",
|
||||
"site.meshPoint.z": "Point height (m)",
|
||||
"site.meshCrop": "Crop to parcel",
|
||||
"site.meshCrop.hint": "Removes all triangles whose centroid lies outside the parcel",
|
||||
"site.meshCrop.noParcel": "Enter the parcel under building regulations first",
|
||||
"site.meshCrop.nothing": "Nothing to crop: the mesh lies entirely inside the parcel or entirely outside it.",
|
||||
"site.excavation.bottom": "Bottom [m]",
|
||||
"site.excavation.slope": "Slope [°]",
|
||||
"site.excavation.fillSlope": "Fill slope [°]",
|
||||
|
||||
@@ -171,6 +171,11 @@ export function AppContextMenu(props: {
|
||||
if (room && !room.locked) return { kind: "room" as const, id: room.id, rings: [{ pts: room.boundary, off: 0 }] };
|
||||
const ctx = selection.contextObjects.length === 1 ? (project.context ?? []).find((x) => x.id === selection.contextObjects[0]) : undefined;
|
||||
if (ctx && ctx.type === "excavation") return { kind: "excavation" as const, id: ctx.id, rings: [{ pts: ctx.outline, off: 0 }] };
|
||||
// [193] Höhenlinien-Satz: je Linie ein Ring (flacher Index über alle Linien); offene Linien haben kein Schlusssegment.
|
||||
if (ctx && ctx.type === "contourSet") {
|
||||
return { kind: "contours" as const, id: ctx.id, rings: ctx.contours.reduce<{ pts: Vec2[]; off: number; closed: boolean }[]>(
|
||||
(acc, c) => (c.pts.length >= 2 ? [...acc, { pts: c.pts, off: ctx.contours.slice(0, ctx.contours.indexOf(c)).reduce((n, x) => n + x.pts.length, 0), closed: !!c.closed }] : acc), []) };
|
||||
}
|
||||
return null;
|
||||
})(),
|
||||
insertRingVertex,
|
||||
|
||||
@@ -90,7 +90,7 @@ export interface MenuActions {
|
||||
selectedSectionLine?: { id: string; pts: Vec2[] } | null;
|
||||
insertSectionBend?: (id: string, seg: number, pt: Vec2) => void;
|
||||
/** [26] Einzeln gewähltes Element mit Umriss (Dach samt Höfen, Decke, Raum, Baugrube): Ringe mit Start-Index im flachen Ecken-Index. */
|
||||
selectedRing?: { kind: RingKind; id: string; rings: { pts: Vec2[]; off: number }[] } | null;
|
||||
selectedRing?: { kind: RingKind; id: string; rings: { pts: Vec2[]; off: number; closed?: boolean }[] } | null;
|
||||
insertRingVertex?: (kind: RingKind, id: string, seg: number, pt: Vec2) => void;
|
||||
deleteRingVertex?: (kind: RingKind, id: string, index: number) => void;
|
||||
deleteSectionBend?: (id: string, index: number) => void;
|
||||
@@ -364,8 +364,8 @@ function planMenuItems(
|
||||
// [26] Umriss-Element: Ecke am Klick einfügen bzw. die getroffene Ecke löschen (mindestens drei bleiben).
|
||||
const ring = a.selectedRing;
|
||||
if (ring) {
|
||||
for (const { pts, off } of ring.rings) {
|
||||
const geom = { pts, closed: true };
|
||||
for (const { pts, off, closed = true } of ring.rings) {
|
||||
const geom = { pts, closed };
|
||||
const hit = nearestPolylineTarget(geom, model, toleranceFor(geom));
|
||||
if (!hit) continue;
|
||||
if (hit.kind === "segment" && a.insertRingVertex) {
|
||||
@@ -376,7 +376,7 @@ function planMenuItems(
|
||||
});
|
||||
}
|
||||
if (hit.kind === "vertex" && a.deleteRingVertex) {
|
||||
const enabled = pts.length > 3;
|
||||
const enabled = pts.length > (closed ? 3 : 2);
|
||||
pointItems.push({
|
||||
label: t("ctx.deleteCorner"),
|
||||
icon: <MenuIcon name="do_not_disturb_on" />,
|
||||
|
||||
@@ -65,6 +65,51 @@ const SMOOTH_LEVELS = [0, 1, 2, 3] as const;
|
||||
const RESMOOTH_PASSES = [1, 2, 4] as const;
|
||||
|
||||
|
||||
/** [193] Netzpunkt wählen (Nummer ab 1) und seine Höhe setzen; Zuschneiden des Netzes auf die Parzelle. */
|
||||
function MeshPointFields({ obj }: { obj: Extract<ContextObject, { positions: number[] }> }) {
|
||||
const setMeshPointHeight = useStore((s) => s.setMeshPointHeight);
|
||||
const cropMesh = useStore((s) => s.cropMesh);
|
||||
const notify = useStore((s) => s.notify);
|
||||
const parcel = useStore((s) => s.project.siteRules?.parcel);
|
||||
const [nr, setNr] = useState("1");
|
||||
const n = Math.floor(obj.positions.length / 3);
|
||||
const i = Math.round(Number(nr)) - 1;
|
||||
const valid = Number.isFinite(i) && i >= 0 && i < n;
|
||||
return (
|
||||
<>
|
||||
<label className="site-prop" title={t("site.meshPoint.hint", { n })}>
|
||||
<span>{t("site.meshPoint")}</span>
|
||||
<input type="number" min={1} max={n} step={1} style={{ width: 90 }} data-testid="mesh-point-nr" value={nr} onChange={(e) => setNr(e.target.value)} />
|
||||
</label>
|
||||
<label className="site-prop">
|
||||
<span>{t("site.meshPoint.z")}</span>
|
||||
<input
|
||||
type="number"
|
||||
step={0.1}
|
||||
style={{ width: 90 }}
|
||||
data-testid="mesh-point-z"
|
||||
disabled={!valid}
|
||||
value={valid ? obj.positions[3 * i + 2] : ""}
|
||||
onChange={(e) => {
|
||||
if (valid && e.target.value.trim() !== "") setMeshPointHeight(obj.id, i, Number(e.target.value), `site-${obj.id}-meshZ-${i}`);
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
data-testid="mesh-crop-parcel"
|
||||
disabled={!parcel || parcel.length < 3}
|
||||
title={parcel && parcel.length >= 3 ? t("site.meshCrop.hint") : t("site.meshCrop.noParcel")}
|
||||
onClick={() => {
|
||||
if (parcel && !cropMesh(obj.id, parcel)) notify(t("site.meshCrop.nothing"), "info");
|
||||
}}
|
||||
>
|
||||
{t("site.meshCrop")}
|
||||
</button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
/** [193] Höhenversatz (alle Höhen um dz) und, bei Höhenlinien, die Höhe je Linie. */
|
||||
function HeightFields({ obj }: { obj: ContextObject }) {
|
||||
const offsetContextHeight = useStore((s) => s.offsetContextHeight);
|
||||
@@ -90,6 +135,7 @@ function HeightFields({ obj }: { obj: ContextObject }) {
|
||||
onBlur={apply}
|
||||
/>
|
||||
</label>
|
||||
{(obj.type === "terrainMesh" || obj.type === "importedMesh") && <MeshPointFields obj={obj} />}
|
||||
{obj.type === "contourSet" && (
|
||||
<div className="site-prop" data-testid="contour-heights" style={{ display: "block", maxHeight: 180, overflowY: "auto" }}>
|
||||
<span>{t("site.contours", { n: obj.contours.length })}</span>
|
||||
|
||||
@@ -46,6 +46,11 @@ describe("Höhenlinien: Punkte per Griff", () => {
|
||||
expect(ins.contours[0].pts).toHaveLength(4);
|
||||
expect(ins.contours[0].pts[2]).toEqual({ x: 3, y: 1 });
|
||||
});
|
||||
it("Punkt löschen und Aufräumen laufen über ringDelete/ringTidy", () => {
|
||||
const p = project();
|
||||
expect(commit<ContourSet>(p, { op: "ringDelete", kind: "contours", id: "hl", index: 1 }, "hl").contours[0].pts).toHaveLength(2);
|
||||
expect(commit<ContourSet>(p, { op: "ringTidy", kind: "contours", id: "hl", index: 1, tol: 0.01 }, "hl").contours[0].pts).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Kontext verschieben (Maus-Ziehen im Plan)", () => {
|
||||
@@ -58,3 +63,20 @@ describe("Kontext verschieben (Maus-Ziehen im Plan)", () => {
|
||||
expect(contextAnchor(p, "nix")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Gelände-Netz: Punkte und Zuschnitt [193]", () => {
|
||||
const mesh = {
|
||||
id: "tm", type: "terrainMesh", categoryCode: "02", name: "Gelände",
|
||||
positions: [0, 0, 1, 2, 0, 2, 2, 2, 3, 0, 2, 4], indices: [0, 1, 2, 0, 2, 3],
|
||||
} as unknown as ContextObject;
|
||||
const proj = (): Project => ({ ...sampleProject, context: [mesh] });
|
||||
it("Netzpunkt per Griff verschieben, Höhe setzen, auf Polygon zuschneiden", () => {
|
||||
const p = proj();
|
||||
const m = commit<ContextObject & { positions: number[] }>(p, { op: "meshGrip", id: "tm", index: 1, pt: [5, 6] }, "tm");
|
||||
expect(m.positions.slice(3, 6)).toEqual([5, 6, 2]);
|
||||
const z = documentFor(p).cmdOps({ cmd: "meshPointZ", id: "tm", index: 2, z: 9 });
|
||||
expect(JSON.stringify(z)).toContain("9");
|
||||
const crop = documentFor(p).cmdOps({ cmd: "meshCrop", id: "tm", poly: [-1, -1, 1, -1, 1, 3, -1, 3] });
|
||||
expect(JSON.stringify(crop)).toContain('"indices":[0,1,2]');
|
||||
});
|
||||
});
|
||||
@@ -402,6 +402,8 @@ export interface ProjectSlice {
|
||||
insertRingVertex: (kind: RingKind, id: string, seg: number, pt: Vec2, coalesceKey?: string) => void;
|
||||
/** [26] Ecke löschen (mind. 3 bleiben); ein Undo-Schritt. */
|
||||
deleteRingVertex: (kind: RingKind, id: string, index: number) => void;
|
||||
/** [193] Netzpunkt eines Geländes/Netzes im Grundriss verschieben (Höhe bleibt). */
|
||||
moveMeshPoint: (id: string, index: number, pt: Vec2) => void;
|
||||
/** [191] Bogen-Scheitel der Kante `seg` (Dach: flacher Index) ziehen: setzt den Bulge über die Pfeilhöhe. */
|
||||
setRingArc: (kind: "roof" | "ceiling" | "room", id: string, seg: number, pt: Vec2, coalesceKey?: string) => void;
|
||||
/** [26] Nach dem Ziehen: Ecke auf Nachbar bzw. Gerade zwischen den Nachbarn entfällt. */
|
||||
@@ -1309,8 +1311,9 @@ export function createProjectSlice(
|
||||
},
|
||||
insertRingVertex: (kind, id, seg, pt, coalesceKey) =>
|
||||
applyGrip(kind === "contours" ? { op: "contourInsert", id, seg, pt: gripPt(pt) } : kind === "polyline" ? { op: "insertPoint", id, seg, pt: gripPt(pt) } : { op: "ringInsert", kind, id, seg, pt: gripPt(pt) }, coalesceKey),
|
||||
moveMeshPoint: (id, index, pt) => applyGrip({ op: "meshGrip", id, index, pt: gripPt(pt) }),
|
||||
deleteRingVertex: (kind, id, index) =>
|
||||
kind === "contours" ? undefined : applyGrip(kind === "polyline" ? { op: "deletePoint", id, index } : { op: "ringDelete", kind, id, index }),
|
||||
applyGrip(kind === "polyline" ? { op: "deletePoint", id, index } : { op: "ringDelete", kind, id, index }),
|
||||
setRingArc: (kind, id, seg, pt, coalesceKey) => applyGrip({ op: "ringArc", kind, id, seg, pt: gripPt(pt) }, coalesceKey ?? `ringArc:${kind}:${id}:${seg}`),
|
||||
tidyRingVertex: (kind, id, index, coalesceKey, tol) =>
|
||||
applyGrip({ op: "ringTidy", kind, id, index, ...(tol != null ? { tol } : {}) }, coalesceKey),
|
||||
|
||||
@@ -38,6 +38,10 @@ export interface SiteSlice {
|
||||
offsetContextHeight: (id: string, dz: number) => void;
|
||||
/** [193] Höhe der Höhenlinie `index` eines Höhenlinien-Satzes setzen (Kern `cmd_context.rs`); `coalesceKey` für Tippen. */
|
||||
setContourHeight: (id: string, index: number, z: number, coalesceKey?: string) => void;
|
||||
/** [193] Höhe eines Netzpunkts (Vertex-Nummer ab 0) setzen. */
|
||||
setMeshPointHeight: (id: string, index: number, z: number, coalesceKey?: string) => void;
|
||||
/** [193] Netz auf ein Polygon (Modell-Meter) zuschneiden; false = nichts geändert. */
|
||||
cropMesh: (id: string, poly: Vec2[]) => boolean;
|
||||
/** [193] Kontext-Elemente um `delta` verschieben (Maus-Ziehen im Plan; Kern `cmd_transform.rs`), ein Undo-Schritt. */
|
||||
moveContextBy: (ids: string[], delta: Vec2) => void;
|
||||
/** [T6]/[68] Ändert Felder eines Kontext-Objekts (Gelände, Baugrube) in einem Schritt; `coalesceKey` für Tippen. */
|
||||
@@ -111,6 +115,17 @@ export function createSiteSlice(
|
||||
if (ops.length) get().applyChange(ops, coalesceKey);
|
||||
},
|
||||
|
||||
setMeshPointHeight: (id, index, z, coalesceKey) => {
|
||||
const ops = documentFor(get().project).cmdOps({ cmd: "meshPointZ", id, index, z });
|
||||
if (ops.length) get().applyChange(ops, coalesceKey);
|
||||
},
|
||||
|
||||
cropMesh: (id, poly) => {
|
||||
const ops = documentFor(get().project).cmdOps({ cmd: "meshCrop", id, poly: poly.flatMap((q) => [q.x, q.y]) });
|
||||
if (ops.length) get().applyChange(ops);
|
||||
return ops.length > 0;
|
||||
},
|
||||
|
||||
moveContextBy: (ids, delta) => {
|
||||
if (ids.length === 0 || (delta.x === 0 && delta.y === 0)) return;
|
||||
const ops = transformOps(get().project, { wallIds: [], drawingId: null, contextIds: ids }, "move", [{ x: 0, y: 0 }, delta], "move", 1);
|
||||
|
||||
@@ -195,6 +195,13 @@ export function useGripEditing(opts: {
|
||||
return o && o.type === "contourSet" ? o : null;
|
||||
})()
|
||||
: null;
|
||||
// [193] Einzeln gewähltes Gelände-/Netz-Element: Netzpunkte als Griffe (Kern `grips.rs::mesh_grip`).
|
||||
const selectedMesh = selectedContourSetId
|
||||
? (() => {
|
||||
const o = (project.context ?? []).find((c) => c.id === selectedContourSetId);
|
||||
return o && (o.type === "terrainMesh" || o.type === "importedMesh") ? o : null;
|
||||
})()
|
||||
: null;
|
||||
const selectedTreeId = single(selection, "trees");
|
||||
const selectedTree = selectedTreeId ? (project.trees ?? []).find((x) => x.id === selectedTreeId) : undefined;
|
||||
// [176] Schnitt-/Ansichtslinie im Grundriss: Griffe an Anfang, Knickpunkten (`bendPoints`) und Ende.
|
||||
@@ -541,6 +548,19 @@ export function useGripEditing(opts: {
|
||||
}
|
||||
return pts;
|
||||
}
|
||||
// [193] Gelände-Netz: jeder Netzpunkt ein Griff (xy; die Höhe steht in der Objekt-Info). Grosse Netze (swissALTI3D
|
||||
// mit tausenden Punkten) bekommen keine Griffe — dort hilft Zuschneiden auf das Grundstück.
|
||||
if (selectedMesh && !selectedCeiling && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0) {
|
||||
const n = Math.floor(selectedMesh.positions.length / 3);
|
||||
if (n > MAX_CONTOUR_GRIPS) return [];
|
||||
const pts: Vec2[] = [];
|
||||
for (let i = 0; i < n; i++) {
|
||||
pts.push({ x: selectedMesh.positions[3 * i], y: selectedMesh.positions[3 * i + 1] });
|
||||
gripOwners.push({ localIndex: i });
|
||||
gripOwnerRange.push([0, n - 1]);
|
||||
}
|
||||
return pts;
|
||||
}
|
||||
// [68] Baugrube: Umriss-Ecken + Sohlen-Griff (Lage: Schwerpunkt, y um die Sohlenhöhe versetzt).
|
||||
if (modelEditable && selectedExcavation && !selectedCeiling && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0) {
|
||||
const pts = excavationGripPoints(selectedExcavation);
|
||||
@@ -822,7 +842,7 @@ export function useGripEditing(opts: {
|
||||
/** [193] Aufgeschobenes Ziehen von Gelände-/Umgebungs-Elementen: ungefangenes und gefangenes Gesamt-Delta. */
|
||||
const pendingContextMoveRef = useRef<{ ids: string[]; raw: Vec2; total: Vec2; anchor: Vec2 | null } | null>(null);
|
||||
/** [193] Zug an einem Höhenlinien-Punkt (bzw. einer Einfüge-Raute: `insertSeg`): Vorschau bis zum Setzen, dann EIN Undo-Schritt. */
|
||||
const pendingContourRef = useRef<{ id: string; index: number; pt: Vec2; insertSeg?: number } | null>(null);
|
||||
const pendingContourRef = useRef<{ id: string; index: number; pt: Vec2; insertSeg?: number; mesh?: boolean } | null>(null);
|
||||
/** Aufgeschobene Öffnungs-Verschiebung im Schnitt/in der Ansicht (neue `position`). */
|
||||
const pendingOpeningMoveRef = useRef<{ id: string; position: number } | null>(null);
|
||||
/** Aufgeschobene Höhen-Änderung im Schnitt (Kante `kind` auf die Höhe `y`, Kern `sheetHeight`). */
|
||||
@@ -1149,6 +1169,10 @@ export function useGripEditing(opts: {
|
||||
// auf die Wand/2D-Aktionen. So teilen Plan- UND 3D-Griffe denselben Pfad.
|
||||
const applyGrip = (index: number, pt: Vec2, arcLength?: number) => {
|
||||
// [193] Höhenlinien-Punkt bzw. Einfüge-Raute: nur Vorschau, das Projekt ändert sich beim Setzen (ein Undo-Schritt).
|
||||
if (selectedMesh) {
|
||||
pendingContourRef.current = { id: selectedMesh.id, index, pt, mesh: true };
|
||||
return;
|
||||
}
|
||||
if (selectedContourSet) {
|
||||
const ins = gripOwners[index];
|
||||
pendingContourRef.current = ins?.insertSeg != null
|
||||
@@ -1285,6 +1309,7 @@ export function useGripEditing(opts: {
|
||||
/** Vorschau-Form des ausstehenden Eckpunkt-Zugs (leer, wenn keiner läuft). */
|
||||
const gripPreviewShapes = (): DraftShape[] => {
|
||||
const pc = pendingContourRef.current;
|
||||
if (pc?.mesh) return [];
|
||||
if (pc && selectedContourSet?.id === pc.id) {
|
||||
// Die betroffene Höhenlinie mit dem gezogenen (bzw. eingefügten) Punkt als Linienzug.
|
||||
let off = 0;
|
||||
@@ -1360,9 +1385,12 @@ export function useGripEditing(opts: {
|
||||
if (ph) sheetHeightGrip(ph.kind, ph.id, ph.y, ph.free, ph.from, ph.index);
|
||||
const pc = pendingContourRef.current;
|
||||
pendingContourRef.current = null;
|
||||
if (pc) {
|
||||
if (pc?.mesh) storeState().moveMeshPoint(pc.id, pc.index, pc.pt);
|
||||
else if (pc) {
|
||||
if (pc.insertSeg != null) storeState().insertRingVertex("contours", pc.id, pc.insertSeg, pc.pt);
|
||||
else storeState().moveRingVertex("contours", pc.id, pc.index, pc.pt);
|
||||
// [193] Punkt, der auf einem Nachbarn bzw. auf der Geraden zwischen den Nachbarn landet, entfällt (derselbe Undo-Schritt).
|
||||
storeState().tidyRingVertex("contours", pc.id, pc.index, undefined, ringTidyTol());
|
||||
}
|
||||
const pa = pendingAreaGripRef.current;
|
||||
pendingAreaGripRef.current = null;
|
||||
|
||||
Reference in new issue
Block a user