[333] Grundriss: Griffe für Stützen, freie Körper und Bibliotheks-Objekte
Stütze: Mitte verschiebt, Eck-Griffe setzen Breite/Tiefe symmetrisch um die Mitte (auch gedreht), Rundprofil Radius-Griff, Dreh-Griff (Kern grips.rs columnGrip). Freier Körper: Profil-Ecken + Verschiebe-Griff, Kreis/B-Rep nur verschieben (solidGrip). Bibliotheks-Objekt: Dreh-Griff neben dem Einfügepunkt. Rust-Tests + e2e grips333.
This commit is contained in:
8 files changed
+342
-4
No files matched your search
+1
-1
@@ -86,7 +86,7 @@ export { EMPTY_MEMBERSHIP, containingGroupId, expandToGroups, isInsideActiveGrou
|
||||
export type { GroupMembership, MemberKind } from "../model/groups";
|
||||
export { arcApex, drawingVertices, gripPt, openEdges, polylineEdgeGrips, ringEdges } from "../geometry/grips";
|
||||
export { verticalExtents } from "../geometry/grips";
|
||||
export { cameraGripPoints, beamGripPoints } from "../geometry/grips";
|
||||
export { cameraGripPoints, beamGripPoints, columnGripPoints, solidGripPoints } from "../geometry/grips";
|
||||
export type { VerticalExtent } from "../geometry/grips";
|
||||
export type { GripRequest, RingKind } from "../geometry/grips";
|
||||
export { edgeArcToggle, type ArcRingKind } from "../geometry/grips";
|
||||
|
||||
@@ -49,6 +49,8 @@ export type GripRequest =
|
||||
// [213] Kamera: 0 = Standpunkt, 1 = Ziel, 2 = Bildwinkel bzw. Sichtbreite (Kern `camera::grip_edit`); `cameraBy` verschiebt Standpunkt und Ziel.
|
||||
| { op: "cameraGrip"; id: string; index: number; pt: P }
|
||||
| { op: "beamGrip"; id: string; index: number; pt: P }
|
||||
// [333] Stütze: 0 = Mitte, Rechteck 1..4 Ecken + 5 Drehen, Rund 1 = Radius; freier Körper: Ecke bzw. (Index = Eckenzahl) Verschieben.
|
||||
| { op: "columnGrip" | "solidGrip"; id: string; index: number; pt: P }
|
||||
| { op: "ceilingSlopeGrip"; id: string; index: number; pt: P }
|
||||
| { op: "cameraBy"; id: string; delta: P }
|
||||
| { op: "sectionBendDelete"; id: string; index: number }
|
||||
@@ -121,6 +123,30 @@ export function beamGripPoints(b: { start: Vec2; end: Vec2 }): Vec2[] {
|
||||
return [b.start, b.end, { x: (b.start.x + b.end.x) / 2, y: (b.start.y + b.end.y) / 2 }];
|
||||
}
|
||||
|
||||
/**
|
||||
* [333] Griffe einer Stütze im Grundriss (Kern `grips.rs`, `columnGrip`): 0 = Mitte; Rechteck 1..4 = Ecken (Querschnitt
|
||||
* symmetrisch um die Mitte, im gedrehten Profil-Rahmen) und 5 = Dreh-Griff ausserhalb der +x-Seite; Rund 1 = Radius-Griff.
|
||||
*/
|
||||
export function columnGripPoints(c: { position: Vec2; rotation?: number; profile: { kind: "rect"; width: number; depth: number } | { kind: "round"; radius: number } }): Vec2[] {
|
||||
const rot = c.rotation ?? 0;
|
||||
const [cos, sin] = [Math.cos(rot), Math.sin(rot)];
|
||||
const at = (lx: number, ly: number): Vec2 => ({ x: c.position.x + lx * cos - ly * sin, y: c.position.y + lx * sin + ly * cos });
|
||||
if (c.profile.kind === "round") return [c.position, at(c.profile.radius, 0)];
|
||||
const [hw, hd] = [c.profile.width / 2, c.profile.depth / 2];
|
||||
return [c.position, at(-hw, -hd), at(hw, -hd), at(hw, hd), at(-hw, hd), at(hw + 0.3, 0)];
|
||||
}
|
||||
|
||||
/**
|
||||
* [333] Griffe eines freien Körpers im Grundriss (`solidGrip`): die Profil-Ecken, dahinter der Verschiebe-Griff im
|
||||
* Schwerpunkt. Kreis- und B-Rep-Körper: nur der Verschiebe-Griff (Index = Eckenzahl, so zählt auch der Kern).
|
||||
*/
|
||||
export function solidGripPoints(s: { points: readonly Vec2[]; circle?: unknown; brep?: unknown }): { pts: Vec2[]; first: number } {
|
||||
const n = s.points.length;
|
||||
const c = n ? { x: s.points.reduce((a, p) => a + p.x, 0) / n, y: s.points.reduce((a, p) => a + p.y, 0) / n } : { x: 0, y: 0 };
|
||||
const derived = !!s.circle || !!s.brep;
|
||||
return { pts: derived ? [c] : [...s.points, c], first: derived ? n : 0 };
|
||||
}
|
||||
|
||||
type Owner = { drawingId?: string; wallId?: string };
|
||||
|
||||
function flat(verts: readonly Vec2[]): Float64Array {
|
||||
|
||||
@@ -396,6 +396,9 @@ export interface ProjectSlice {
|
||||
moveCameraGrip: (id: string, index: number, pt: Vec2) => void;
|
||||
/** [280] Träger: Griff 0 Anfang, 1 Ende, 2 Mitte (verschiebt den Träger), Kern `grips.rs`. */
|
||||
moveBeamGrip: (id: string, index: number, pt: Vec2) => void;
|
||||
/** [333] Stütze (Mitte, Ecken, Drehen/Radius) bzw. freier Körper (Ecke, Verschieben); Kern `grips.rs`. */
|
||||
moveColumnGrip: (id: string, index: number, pt: Vec2) => void;
|
||||
moveSolidGrip: (id: string, index: number, pt: Vec2) => void;
|
||||
/** [176] Knick in Segment `seg` (Mittel-Griff) einfügen; `coalesceKey` fasst den anschliessenden Zug zusammen. */
|
||||
insertSectionBend: (id: string, seg: number, pt: Vec2, coalesceKey?: string) => void;
|
||||
/** [176] Knick löschen (`index` wie bei {@link moveSectionLineGrip}; Anfang/Ende lassen sich nicht löschen). */
|
||||
@@ -1327,6 +1330,8 @@ export function createProjectSlice(
|
||||
moveSectionLineGrip: (id, index, pt, coalesceKey) =>
|
||||
applyGrip({ op: "sectionLineGrip", id, index, pt: gripPt(pt) }, coalesceKey ?? `moveSectionLineGrip:${id}:${index}`),
|
||||
moveCameraGrip: (id, index, pt) => applyGrip({ op: "cameraGrip", id, index, pt: gripPt(pt) }, `moveCameraGrip:${id}:${index}`),
|
||||
moveColumnGrip: (id, index, pt) => applyGrip({ op: "columnGrip", id, index, pt: gripPt(pt) }, `moveColumnGrip:${id}:${index}`),
|
||||
moveSolidGrip: (id, index, pt) => applyGrip({ op: "solidGrip", id, index, pt: gripPt(pt) }, `moveSolidGrip:${id}:${index}`),
|
||||
moveBeamGrip: (id, index, pt) => applyGrip({ op: "beamGrip", id, index, pt: gripPt(pt) }, `moveBeamGrip:${id}:${index}`),
|
||||
insertSectionBend: (id, seg, pt, coalesceKey) => applyGrip({ op: "sectionBendInsert", id, seg, pt: gripPt(pt) }, coalesceKey),
|
||||
deleteSectionBend: (id, index) => applyGrip({ op: "sectionBendDelete", id, index }),
|
||||
|
||||
@@ -111,6 +111,13 @@ declare global {
|
||||
/** [253] Objekte der Bibliothek im Projekt (Id, Lage, Drehung, Parameter, Seed, Klasse) mit Ausmass ihrer Plan-Linien (1:50) im aktiven Geschoss; dazu die Klassen-Codes des Projekts. */
|
||||
libobjs: () => { items: { id: string; libId: string; at: { x: number; y: number }; rotation: number; params: Record<string, number | boolean | string>; seed: number | undefined; categoryCode: string; lines: number; w: number; h: number }[]; layers: string[] };
|
||||
/** [202] Treppe (Antritt, Zentrum), erster Punkt des ersten Lochs der Decke `ceilingId` und Zahl der Plan-Linien der Treppe im aktiven Geschoss. */
|
||||
/** [333] Lage/Querschnitt der Stützen und Profil-Ecken der freien Körper (Griff-Test). */
|
||||
/** [333] Stützen-Griff ohne Maus auslösen (Testvorbereitung: Stütze aufziehen, damit die Griffe trennbar sind). */
|
||||
columnGrip: (id: string, index: number, x: number, y: number) => void;
|
||||
gripGeom: () => {
|
||||
columns: { id: string; position: { x: number; y: number }; rotation: number; width: number; depth: number; radius: number }[];
|
||||
solids: { id: string; points: { x: number; y: number }[] }[];
|
||||
};
|
||||
stairHole: (stairId: string, ceilingId: string) => { start: { x: number; y: number }; center: { x: number; y: number } | null; hole0: { x: number; y: number } | null; lines: number };
|
||||
/** [203] Grundriss der aktiven Ebene wie in der Ansicht (Geschoss-Überlagerung nach Zeichnungsebenen-Modus): Raumstempel je Geschoss (gesamt/gedimmt) und Zahl der Achs-Beschriftungen `axis`. */
|
||||
planStamps: (axis: string) => { floors: Record<string, { n: number; greyed: number }>; axis: number };
|
||||
@@ -544,6 +551,18 @@ export function installTestHooks(): void {
|
||||
return { wallId: s.project.walls.find((w) => w.floorId === s.activeLevelId)?.id ?? s.project.walls[0]?.id ?? "", visible: vis.sort(), prims: prims.length, wallPrims: prims.filter((q) => !!(q as { wallId?: string }).wallId).length };
|
||||
},
|
||||
selected: () => ({ drawings: [...getState().selection.drawings], groups: [...getState().selection.groups], all: JSON.stringify(getState().selection) }),
|
||||
columnGrip: (id, index, x, y) => getState().moveColumnGrip(id, index, { x, y }),
|
||||
gripGeom: () => {
|
||||
const p = getState().project;
|
||||
return {
|
||||
columns: (p.columns ?? []).map((c) => ({
|
||||
id: c.id, position: c.position, rotation: c.rotation,
|
||||
width: c.profile.kind === "rect" ? c.profile.width : NaN, depth: c.profile.kind === "rect" ? c.profile.depth : NaN,
|
||||
radius: c.profile.kind === "round" ? c.profile.radius : NaN,
|
||||
})),
|
||||
solids: (p.extrudedSolids ?? []).map((x) => ({ id: x.id, points: x.points })),
|
||||
};
|
||||
},
|
||||
stairHole: (stairId, ceilingId) => {
|
||||
const s = getState();
|
||||
const st = (s.project.stairs ?? []).find((x) => x.id === stairId)!;
|
||||
|
||||
@@ -53,7 +53,7 @@ import { growRect, meshGripIndices } from "../core";
|
||||
import { patchItem, verticalExtents } from "../core";
|
||||
import { treeGripPatch, treeGripPoints } from "./treeGrips";
|
||||
import { railingGripPatch, railingGripPoints } from "./railingGrips";
|
||||
import { beamGripPoints, cameraGripPoints } from "../core";
|
||||
import { beamGripPoints, cameraGripPoints, columnGripPoints, solidGripPoints } from "../core";
|
||||
import type { Selection } from "./selection";
|
||||
|
||||
export interface GripEditFieldsState {
|
||||
@@ -226,6 +226,10 @@ export function useGripEditing(opts: {
|
||||
// [280] Träger liegen im Auswahlkanal der Stützen: ein gewählter einzelner Träger zeigt Anfang-, Ende- und Mitte-Griff.
|
||||
const selectedColumnId = single(selection, "columns");
|
||||
const selectedBeam = selectedColumnId ? (project.beams ?? []).find((x) => x.id === selectedColumnId && x.floorId === levelId) : undefined;
|
||||
// [333] Stütze und freier Körper: eigene Griffe im Grundriss (Mitte/Ecken/Drehen bzw. Ecken/Verschieben).
|
||||
const selectedColumn = selectedColumnId && !selectedBeam ? (project.columns ?? []).find((x) => x.id === selectedColumnId && x.floorId === levelId) : undefined;
|
||||
const selectedSolidId = single(selection, "solids");
|
||||
const selectedSolid = selectedSolidId ? (project.extrudedSolids ?? []).find((x) => x.id === selectedSolidId && x.levelId === levelId) : undefined;
|
||||
const selectedCamera = selectedCameraId ? (project.cameras ?? []).find((x) => x.id === selectedCameraId && x.floorId === levelId) : undefined;
|
||||
// [176] Schnitt-/Ansichtslinie im Grundriss: Griffe an Anfang, Knickpunkten (`bendPoints`) und Ende.
|
||||
const selectedSectionLineId = single(selection, "sectionLines");
|
||||
@@ -574,6 +578,16 @@ export function useGripEditing(opts: {
|
||||
pts.forEach((_, i) => { gripOwners.push({ localIndex: i }); gripOwnerRange.push([0, pts.length - 1]); });
|
||||
return pts;
|
||||
}
|
||||
if (selectedColumn && modelEditable && !selectedColumn.locked) {
|
||||
const pts = columnGripPoints(selectedColumn);
|
||||
pts.forEach((_, i) => { gripOwners.push({ localIndex: i }); gripOwnerRange.push([0, pts.length - 1]); });
|
||||
return pts;
|
||||
}
|
||||
if (selectedSolid && modelEditable) {
|
||||
const { pts, first } = solidGripPoints(selectedSolid);
|
||||
pts.forEach((_, i) => { gripOwners.push({ localIndex: first + i }); gripOwnerRange.push([first, first + pts.length - 1]); });
|
||||
return pts;
|
||||
}
|
||||
if (selectedCamera && modelEditable && !selectedCamera.locked) {
|
||||
const pts = cameraGripPoints(selectedCamera, scaleDenominator);
|
||||
pts.forEach((_, i) => { gripOwners.push({ localIndex: i }); gripOwnerRange.push([0, pts.length - 1]); });
|
||||
@@ -1337,6 +1351,15 @@ export function useGripEditing(opts: {
|
||||
if (!selectedBeam.locked) storeState().moveBeamGrip(selectedBeam.id, index, pt);
|
||||
return;
|
||||
}
|
||||
// [333] Stütze / freier Körper: Griff live über den Kern, ein Undo-Schritt je Zug.
|
||||
if (selectedColumn) {
|
||||
if (!selectedColumn.locked) storeState().moveColumnGrip(selectedColumn.id, index, pt);
|
||||
return;
|
||||
}
|
||||
if (selectedSolid) {
|
||||
storeState().moveSolidGrip(selectedSolid.id, index, pt);
|
||||
return;
|
||||
}
|
||||
// [213] Kamera: Standpunkt, Ziel bzw. Sichtkegel-Rand live (Kern `camera::grip_edit`), ein Undo-Schritt je Zug.
|
||||
if (selectedCamera) {
|
||||
if (!selectedCamera.locked) storeState().moveCameraGrip(selectedCamera.id, index, pt);
|
||||
|
||||
Reference in new issue
Block a user