Archived
Schnitt: geschnittene Wand/Decke waagrecht ziehen (Grundriss-Verschiebung entlang der Schnittlinie, Vorschau im Blatt); automatische Hoehenkoten in Schnitt und Ansicht
This commit is contained in:
1 parent
f44ba9ed85
commit
50bff03b51
11 files changed
+276
-38
No files matched your search
+14
-1
@@ -36,7 +36,7 @@ import { activePenSet, resolvePenColor, resolvePenWeight } from "./model/penSets
|
||||
import { PenColorField } from "./ui/PenColorField";
|
||||
import { generatePlan } from "./plan/generatePlan";
|
||||
import type { CategoryDisplayResolver } from "./plan/generatePlan";
|
||||
import { sectionPlaneFromLevel } from "./plan/toSection";
|
||||
import { sectionPlaneFromLevel, sectionUAxisModel } from "./plan/toSection";
|
||||
import { roofBaseElevation, roofGeometry } from "./geometry/roof";
|
||||
import { setDxfImportTrigger } from "./io/dxfImportHook";
|
||||
import { ImportDialog } from "./ui/ImportDialog";
|
||||
@@ -1689,6 +1689,18 @@ export default function App() {
|
||||
|
||||
// 2D-Griff-Editieren (Eckpunkt-/Kanten-Griffe + Feld-Controller) der aktuellen
|
||||
// Auswahl — siehe state/useGripEditing.ts.
|
||||
// Schnitt-Blatt: geschnittene Wände/Decken lassen sich dort waagrecht entlang
|
||||
// der Schnittlinie ziehen (s. useGripEditing `sheet`). Nur echte Schnitte —
|
||||
// die Ansicht trägt keine Bauteil-IDs an ihren Flächen.
|
||||
const sectionSheet = useMemo(() => {
|
||||
if (activeLevel.kind !== "section") return null;
|
||||
const plane = sectionPlaneFromLevel(activeLevel);
|
||||
if (!plane) return null;
|
||||
const u = sectionUAxisModel(plane);
|
||||
const len = Math.hypot(u.x, u.y) || 1;
|
||||
return { levelId: activeLevel.id, uAxis: { x: u.x / len, y: u.y / len } };
|
||||
}, [activeLevel]);
|
||||
|
||||
const {
|
||||
grips,
|
||||
gripHandleLines,
|
||||
@@ -1721,6 +1733,7 @@ export default function App() {
|
||||
selectedDrawingIds,
|
||||
levelId: activeLevel.id,
|
||||
modelEditable: activeLevel.kind !== "section" && activeLevel.kind !== "elevation",
|
||||
sheet: sectionSheet,
|
||||
visibleCodes,
|
||||
scaleDenominator,
|
||||
snap,
|
||||
|
||||
@@ -696,6 +696,7 @@ export const de = {
|
||||
"objinfo.sectionLine.hiddenLines": "Verdeckte Kanten",
|
||||
"objinfo.sectionLine.planUnderlay": "Grundriss darunter",
|
||||
"objinfo.sectionLine.planUnderlay.none": "Keiner",
|
||||
"objinfo.sectionLine.levelMarks": "Höhenkoten",
|
||||
"objinfo.sectionLine.depthHint": "leer = unbegrenzt",
|
||||
"objinfo.sectionLine.delete": "Schnittlinie löschen",
|
||||
"objinfo.extrudedSolid.section": "Extrusion",
|
||||
|
||||
@@ -692,6 +692,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"objinfo.sectionLine.hiddenLines": "Hidden lines",
|
||||
"objinfo.sectionLine.planUnderlay": "Plan below",
|
||||
"objinfo.sectionLine.planUnderlay.none": "None",
|
||||
"objinfo.sectionLine.levelMarks": "Level marks",
|
||||
"objinfo.sectionLine.depthHint": "empty = unlimited",
|
||||
"objinfo.sectionLine.delete": "Delete section line",
|
||||
"objinfo.extrudedSolid.section": "Extrusion",
|
||||
|
||||
@@ -959,6 +959,12 @@ export interface DrawingLevel {
|
||||
* Fehlt ⇒ keine Unterlage.
|
||||
*/
|
||||
planUnderlayId?: string;
|
||||
/**
|
||||
* Automatische Höhenkoten (nur Schnitt/Ansicht): je Geschoss OK fertig Boden
|
||||
* + oberste Kante, links neben der Zeichnung (`plan/levelMarkers.ts`).
|
||||
* Fehlt ⇒ an; `false` ⇒ aus.
|
||||
*/
|
||||
levelMarks?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -539,6 +539,17 @@ export function SectionLineSection({
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Automatische Höhenkoten (Geschosse + oberste Kante). */}
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.sectionLine.levelMarks")}</span>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={level.levelMarks !== false}
|
||||
onChange={(e) => host.onSetSectionLinePatch({ levelMarks: e.target.checked ? undefined : false })}
|
||||
title={t("objinfo.sectionLine.levelMarks")}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Grundriss-Unterlage: ein Geschoss ausgerichtet unter dem Schnitt/der Ansicht. */}
|
||||
{line && (
|
||||
<div className="objinfo-field">
|
||||
|
||||
@@ -156,6 +156,51 @@ const XLINE_DASH: number[] = [0.3, 0.1, 0.03, 0.1]; // Strich-Punkt (CAD-Mittell
|
||||
// ── Leader (Vorführungspfeil) ────────────────────────────────────────────────
|
||||
|
||||
|
||||
/**
|
||||
* Höhenkote (SIA 400 B.5.4/Figur 18) als Primitive: OK = Spitze nach unten,
|
||||
* UK = Spitze nach oben; fertig = Kontur (hohl), roh = voll gefüllt. `at` ist
|
||||
* die Spitze. Geteilt vom 2D-Element `kote` und den automatischen Koten im
|
||||
* Schnitt/in der Ansicht (`plan/levelMarkers.ts`).
|
||||
*/
|
||||
export function pushKote(
|
||||
out: Primitive[],
|
||||
at: Vec2,
|
||||
value: number,
|
||||
kind: "okFertig" | "ukFertig" | "okRoh" | "ukRoh",
|
||||
color: string,
|
||||
weightMm: number,
|
||||
greyed: boolean,
|
||||
drawingId?: string,
|
||||
): void {
|
||||
const up = kind === "okFertig" || kind === "okRoh" ? 1 : -1;
|
||||
const filled = kind === "okRoh" || kind === "ukRoh";
|
||||
const pts: Vec2[] = [
|
||||
at,
|
||||
{ x: at.x - KOTE_TRI_HALF_W_M, y: at.y + up * KOTE_TRI_SIZE_M },
|
||||
{ x: at.x + KOTE_TRI_HALF_W_M, y: at.y + up * KOTE_TRI_SIZE_M },
|
||||
];
|
||||
out.push({
|
||||
kind: "polygon",
|
||||
pts,
|
||||
fill: filled ? color : "none",
|
||||
stroke: color,
|
||||
strokeWidthMm: weightMm,
|
||||
hatch: NO_HATCH,
|
||||
greyed,
|
||||
drawingId,
|
||||
});
|
||||
out.push({
|
||||
kind: "drawingText",
|
||||
at: { x: at.x + KOTE_TRI_HALF_W_M + KOTE_TEXT_GAP_M, y: at.y + up * KOTE_TRI_SIZE_M * 0.5 },
|
||||
text: formatKoteLabel(value),
|
||||
heightM: KOTE_TEXT_HEIGHT_M,
|
||||
angle: 0,
|
||||
color,
|
||||
greyed,
|
||||
drawingId,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Erzeugt die Plan-Primitive EINES 2D-Elements. Hülle um
|
||||
* {@link addDrawing2DInner}: sie stempelt am Ende die Objekt-Transparenz
|
||||
@@ -691,35 +736,7 @@ function addDrawing2DInner(
|
||||
break;
|
||||
}
|
||||
case "kote": {
|
||||
// SIA 400 B.5.4/Figur 18: OK = Spitze nach unten, UK = Spitze nach oben;
|
||||
// fertig = Kontur (hohl), roh = voll gefüllt. `at` ist die Spitze.
|
||||
const up = g.kind === "okFertig" || g.kind === "okRoh" ? 1 : -1;
|
||||
const filled = g.kind === "okRoh" || g.kind === "ukRoh";
|
||||
const pts: Vec2[] = [
|
||||
g.at,
|
||||
{ x: g.at.x - KOTE_TRI_HALF_W_M, y: g.at.y + up * KOTE_TRI_SIZE_M },
|
||||
{ x: g.at.x + KOTE_TRI_HALF_W_M, y: g.at.y + up * KOTE_TRI_SIZE_M },
|
||||
];
|
||||
out.push({
|
||||
kind: "polygon",
|
||||
pts,
|
||||
fill: filled ? color : "none",
|
||||
stroke: color,
|
||||
strokeWidthMm: weightMm,
|
||||
hatch: NO_HATCH,
|
||||
greyed,
|
||||
drawingId: d.id,
|
||||
});
|
||||
out.push({
|
||||
kind: "drawingText",
|
||||
at: { x: g.at.x + KOTE_TRI_HALF_W_M + KOTE_TEXT_GAP_M, y: g.at.y + up * KOTE_TRI_SIZE_M * 0.5 },
|
||||
text: formatKoteLabel(g.value),
|
||||
heightM: KOTE_TEXT_HEIGHT_M,
|
||||
angle: 0,
|
||||
color,
|
||||
greyed,
|
||||
drawingId: d.id,
|
||||
});
|
||||
pushKote(out, g.at, g.value, g.kind, color, weightMm, greyed, d.id);
|
||||
break;
|
||||
}
|
||||
case "detailref": {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import type { Primitive } from "./generatePlan";
|
||||
import { levelMarkerPrimitives, levelMarksEnabled } from "./levelMarkers";
|
||||
|
||||
const texts = (prims: Primitive[]) =>
|
||||
prims.filter((p): p is Extract<Primitive, { kind: "drawingText" }> => p.kind === "drawingText").map((p) => p.text);
|
||||
|
||||
describe("levelMarkerPrimitives", () => {
|
||||
it("Kote je Geschoss (OK fertig Boden) + oberste Kante, links der Zeichnung", () => {
|
||||
const prims = levelMarkerPrimitives(sampleProject, { minX: 0, minY: -0.3, maxX: 5, maxY: 6.2 });
|
||||
expect(texts(prims)).toEqual(["±0.00", "+2.60", "+6.20"]);
|
||||
for (const p of prims) {
|
||||
if (p.kind === "line") expect(Math.max(p.a.x, p.b.x)).toBeLessThan(0);
|
||||
}
|
||||
});
|
||||
|
||||
it("Geschosse ausserhalb der Zeichnung entfallen", () => {
|
||||
const prims = levelMarkerPrimitives(sampleProject, { minX: 0, minY: 2, maxX: 5, maxY: 6 });
|
||||
expect(texts(prims)).toEqual(["+2.60", "+6.00"]);
|
||||
});
|
||||
|
||||
it("standardmässig an, abschaltbar", () => {
|
||||
const lv = sampleProject.drawingLevels.find((l) => l.kind === "section")!;
|
||||
expect(levelMarksEnabled(lv)).toBe(true);
|
||||
expect(levelMarksEnabled({ ...lv, levelMarks: false })).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,55 @@
|
||||
// Automatische Höhenkoten im Schnitt/in der Ansicht: je Geschoss die Kote
|
||||
// OK fertig Boden (`baseElevation`, ±0.00 = Bezug) plus die oberste Kante des
|
||||
// Gebäudes (First/OK Dach), links neben der Zeichnung mit einer kurzen
|
||||
// Bezugslinie zur Geometrie. Symbol = dieselbe SIA-400-Kote wie das 2D-Element
|
||||
// `kote` (`pushKote`). Abschaltbar je Ebene (`DrawingLevel.levelMarks`).
|
||||
|
||||
import type { DrawingLevel, Project } from "../model/types";
|
||||
import { pushKote } from "./generatePlan/drawing2d";
|
||||
import type { Primitive } from "./generatePlan";
|
||||
|
||||
const INK = "#1f242c";
|
||||
/** Abstand der Kote links von der Zeichnung (Meter). */
|
||||
const MARK_OFFSET_M = 1.2;
|
||||
/** Länge der Bezugslinie (Meter, endet knapp vor der Zeichnung). */
|
||||
const LEADER_GAP_M = 0.15;
|
||||
|
||||
/** Ob eine Ebene automatische Koten trägt (Default an). */
|
||||
export function levelMarksEnabled(level: DrawingLevel): boolean {
|
||||
return level.levelMarks !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Kote-Primitive für eine Zeichnung mit den Grenzen `bounds` (u, Höhe). Höhen
|
||||
* ausserhalb der Zeichnung (Geschosse, die der Schnitt nicht zeigt) entfallen.
|
||||
*/
|
||||
export function levelMarkerPrimitives(
|
||||
project: Project,
|
||||
bounds: { minX: number; minY: number; maxX: number; maxY: number },
|
||||
): Primitive[] {
|
||||
if (!(bounds.maxX > bounds.minX) || !(bounds.maxY > bounds.minY)) return [];
|
||||
const x = bounds.minX - MARK_OFFSET_M;
|
||||
const heights: number[] = [];
|
||||
const pushH = (z: number) => {
|
||||
if (z < bounds.minY - 1e-6 || z > bounds.maxY + 1e-6) return;
|
||||
if (heights.some((h) => Math.abs(h - z) < 0.05)) return;
|
||||
heights.push(z);
|
||||
};
|
||||
for (const l of project.drawingLevels) {
|
||||
if (l.kind === "floor" && l.baseElevation !== undefined) pushH(l.baseElevation);
|
||||
}
|
||||
pushH(bounds.maxY);
|
||||
const out: Primitive[] = [];
|
||||
for (const z of heights) {
|
||||
out.push({
|
||||
kind: "line",
|
||||
a: { x: x - 0.3, y: z },
|
||||
b: { x: bounds.minX - LEADER_GAP_M, y: z },
|
||||
cls: "section-level-leader",
|
||||
weightMm: 0.13,
|
||||
color: INK,
|
||||
});
|
||||
pushKote(out, { x, y: z }, Math.round(z * 100) / 100, "okFertig", INK, 0.18, false);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import { drawingPreviewShapes } from "../tools/drawingPreview";
|
||||
import type { DraftShape, SnapResult, SnapSettings, ToolDraft, ToolMods } from "../tools/types";
|
||||
import { applyAngleConstraint, computeSnap } from "../tools/snapping";
|
||||
import { useCommandTabShortcut } from "./useKeyboardShortcuts";
|
||||
import { sheetOwnerOutlines } from "../tools/sheetSnapGeometry";
|
||||
import type { CommandLineHandle } from "../ui/CommandLine";
|
||||
import type { CommandEngine } from "../commands/engine";
|
||||
|
||||
@@ -49,6 +50,13 @@ export function useGripEditing(opts: {
|
||||
* selbst bleiben voll editierbar (sie leben im Blatt-Raum).
|
||||
*/
|
||||
modelEditable?: boolean;
|
||||
/**
|
||||
* Schnitt-Blatt (nur bei `modelEditable === false`): geschnittene Wände/Decken
|
||||
* lassen sich dort WAAGRECHT ziehen — das Blatt-Delta (u) wird entlang der
|
||||
* Schnitt-u-Achse `uAxis` (Grundriss, Einheit) aufs Bauteil übertragen, die
|
||||
* Vorschau zeigt die verschobenen Schnittflächen im Blatt.
|
||||
*/
|
||||
sheet?: { levelId: string; uAxis: Vec2 } | null;
|
||||
visibleCodes: Set<string>;
|
||||
/** Papier-Massstab (1:N) — die Bemassungs-Griffe hängen daran (Papier-mm). */
|
||||
scaleDenominator: number;
|
||||
@@ -96,6 +104,7 @@ export function useGripEditing(opts: {
|
||||
selectedDrawingIds,
|
||||
levelId,
|
||||
modelEditable = true,
|
||||
sheet = null,
|
||||
visibleCodes,
|
||||
scaleDenominator,
|
||||
snap,
|
||||
@@ -488,6 +497,8 @@ export function useGripEditing(opts: {
|
||||
const pendingAreaGripRef = useRef<{ kind: "room" | "ceiling"; id: string; index: number; flat: number; pt: Vec2 } | null>(null);
|
||||
const pendingAreaMoveRef = useRef<{ kind: "ceiling" | "room" | "stair"; id: string; total: Vec2 } | null>(null);
|
||||
const pendingWallMoveRef = useRef<{ wallId: string; total: Vec2 } | null>(null);
|
||||
/** Laufendes Blatt-Delta (u, Meter) eines Zugs im Schnitt (s. moveInSheet). */
|
||||
const sheetDuRef = useRef<{ id: string; du: number } | null>(null);
|
||||
const pendingBodyRef = useRef<{ drawingId: string; total: Vec2 } | null>(null);
|
||||
const pendingEdgeRef = useRef<{ edge: EdgeGrip; delta: Vec2 } | null>(null);
|
||||
// Position des gezogenen Griffs VOR dem Drag (beim ersten Move-Event nach dem
|
||||
@@ -974,6 +985,7 @@ export function useGripEditing(opts: {
|
||||
const commitPendingBody = () => {
|
||||
const pwm = pendingWallMoveRef.current;
|
||||
pendingWallMoveRef.current = null;
|
||||
sheetDuRef.current = null;
|
||||
if (pwm && (pwm.total.x !== 0 || pwm.total.y !== 0)) {
|
||||
moveElementByOf(null, pwm.wallId, pwm.total);
|
||||
for (const c of moveCoincidentRef.current ?? []) {
|
||||
@@ -1070,6 +1082,7 @@ export function useGripEditing(opts: {
|
||||
pendingAreaGripRef.current = null;
|
||||
pendingAreaMoveRef.current = null;
|
||||
pendingWallMoveRef.current = null;
|
||||
sheetDuRef.current = null;
|
||||
pendingBodyRef.current = null;
|
||||
pendingEdgeRef.current = null;
|
||||
gripOriginRef.current = null; // Flucht-Bezugspunkt verwerfen
|
||||
@@ -1078,6 +1091,50 @@ export function useGripEditing(opts: {
|
||||
setEdgeEdit(null); // Kanten-Feld-Controller schließen
|
||||
};
|
||||
|
||||
// Ziehen einer geschnittenen Wand/Decke im Schnitt-Blatt (s. Option `sheet`):
|
||||
// nur die waagrechte Komponente zählt (Höhe ist kein Grundriss-Delta). Das
|
||||
// Projekt ändert sich — wie im Grundriss — erst beim Loslassen
|
||||
// (commitPendingBody: pendingWallMoveRef/pendingAreaMoveRef, Grundriss-Delta).
|
||||
const moveInSheet = (
|
||||
sh: { levelId: string; uAxis: Vec2 },
|
||||
delta: Vec2,
|
||||
target?: { wallId?: string; drawingId?: string },
|
||||
) => {
|
||||
if (target?.drawingId) {
|
||||
// 2D-Element der Ebene selbst: normales Körper-Verschieben im Blatt-Raum.
|
||||
const prev = pendingBodyRef.current;
|
||||
const total = prev && prev.drawingId === target.drawingId
|
||||
? { x: prev.total.x + delta.x, y: prev.total.y + delta.y }
|
||||
: delta;
|
||||
if (!deferrableDrawing(target.drawingId)) return;
|
||||
pendingBodyRef.current = { drawingId: target.drawingId, total };
|
||||
setDraft({ preview: bodyPreviewShapes(), vertices: [], snap: null });
|
||||
return;
|
||||
}
|
||||
const wallId = target ? target.wallId ?? null : selectedWallId;
|
||||
const ceilingId = !target && !wallId ? selectedCeilingId : null;
|
||||
const kind = wallId ? "wall" : ceilingId ? "ceiling" : null;
|
||||
const id = wallId ?? ceilingId;
|
||||
if (!kind || !id) return;
|
||||
if (kind === "wall" && project.walls.find((w) => w.id === id)?.locked) return;
|
||||
const prevDu = sheetDuRef.current && sheetDuRef.current.id === id ? sheetDuRef.current.du : 0;
|
||||
const du = prevDu + delta.x;
|
||||
sheetDuRef.current = { id, du };
|
||||
const total = scale(sh.uAxis, du);
|
||||
if (kind === "wall") {
|
||||
if (moveCoincidentRef.current === null) moveCoincidentRef.current = findMoveCoincident2D(null, id);
|
||||
pendingWallMoveRef.current = { wallId: id, total };
|
||||
} else {
|
||||
pendingAreaMoveRef.current = { kind: "ceiling", id, total };
|
||||
}
|
||||
const preview: DraftShape[] = sheetOwnerOutlines(sh.levelId, kind, id).map((pts) => ({
|
||||
kind: "poly",
|
||||
pts: pts.map((q) => ({ x: q.x + du, y: q.y })),
|
||||
closed: true,
|
||||
}));
|
||||
setDraft({ preview, vertices: [], snap: null });
|
||||
};
|
||||
|
||||
const gripHandlers = {
|
||||
onGripMove: (index: number, raw: Vec2, pxPerMeter: number, mods: ToolMods) => {
|
||||
// Erster Move-Event nach dem Grab (gripDragInfoRef noch leer): die
|
||||
@@ -1172,9 +1229,14 @@ export function useGripEditing(opts: {
|
||||
if (Math.abs(delta.x) >= Math.abs(delta.y)) delta = { x: delta.x, y: 0 };
|
||||
else delta = { x: 0, y: delta.y };
|
||||
}
|
||||
// Schnitt-Blatt: geschnittene Wand/Decke waagrecht entlang der Schnittlinie.
|
||||
if (!modelEditable) {
|
||||
if (sheet) moveInSheet(sheet, delta, target);
|
||||
return;
|
||||
}
|
||||
// Decke: ganzen Umriss verschieben (kein Multi-Koinzidenz-Handling nötig).
|
||||
// Decke/Treppe/Raum: nur Gesamt-Delta + Vorschau, Projekt erst beim Loslassen.
|
||||
const areaTarget: { kind: "ceiling" | "room" | "stair"; id: string } | null = target || !modelEditable
|
||||
const areaTarget: { kind: "ceiling" | "room" | "stair"; id: string } | null = target
|
||||
? null
|
||||
: selectedCeilingId
|
||||
? { kind: "ceiling", id: selectedCeilingId }
|
||||
@@ -1198,8 +1260,7 @@ export function useGripEditing(opts: {
|
||||
// Gegriffenes Element: bei Mehrfachauswahl das unter dem Cursor (target),
|
||||
// sonst das einzeln selektierte. Wand UND 2D schließen sich aus.
|
||||
const moveDrawingId = target ? target.drawingId ?? null : selectedDrawingId;
|
||||
const moveWallId = modelEditable ? (target ? target.wallId ?? null : selectedWallId) : null;
|
||||
if (!moveDrawingId && !moveWallId) return;
|
||||
const moveWallId = target ? target.wallId ?? null : selectedWallId;
|
||||
// 2D-Element: nur Gesamt-Delta merken + Vorschau; Projekt erst beim Loslassen.
|
||||
// Wand: Gesamt-Delta + Vorschau; beim Loslassen folgen verbundene Eckpunkte.
|
||||
if (moveWallId && !moveDrawingId) {
|
||||
|
||||
@@ -11,6 +11,8 @@ import type { Primitive } from "../plan/generatePlan";
|
||||
export type SnapSeg = [Vec2, Vec2];
|
||||
|
||||
const byLevel = new Map<string, SnapSeg[]>();
|
||||
/** Je Ebene: Umriss-Polygone je Bauteil (`wall:<id>` / `ceiling:<id>`) — Vorschau beim Ziehen im Schnitt. */
|
||||
const outlinesByLevel = new Map<string, Map<string, Vec2[][]>>();
|
||||
|
||||
/** Strecken der Ebene `levelId` setzen (leeres Array/`null` = entfernen). */
|
||||
export function setSheetSnapSegments(levelId: string, segs: SnapSeg[] | null): void {
|
||||
@@ -56,3 +58,34 @@ export function snapSegmentsFromPrimitives(prims: readonly Primitive[]): SnapSeg
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Bauteil-Art, deren Schnittflächen im Blatt gezogen werden können. */
|
||||
export type SheetOwnerKind = "wall" | "ceiling";
|
||||
|
||||
/**
|
||||
* Schnittflächen der Ebene `levelId` je Quell-Bauteil ablegen (aus den Plan-
|
||||
* Primitiven: `wallId`/`ceilingId` an Polygonen). `null` = entfernen.
|
||||
*/
|
||||
export function setSheetOwnerOutlines(levelId: string, prims: readonly Primitive[] | null): void {
|
||||
if (!prims) {
|
||||
outlinesByLevel.delete(levelId);
|
||||
return;
|
||||
}
|
||||
const map = new Map<string, Vec2[][]>();
|
||||
const add = (key: string, pts: Vec2[]) => {
|
||||
const list = map.get(key);
|
||||
if (list) list.push(pts);
|
||||
else map.set(key, [pts]);
|
||||
};
|
||||
for (const p of prims) {
|
||||
if (p.kind !== "polygon") continue;
|
||||
if (p.wallId) add(`wall:${p.wallId}`, p.pts);
|
||||
else if (p.ceilingId) add(`ceiling:${p.ceilingId}`, p.pts);
|
||||
}
|
||||
outlinesByLevel.set(levelId, map);
|
||||
}
|
||||
|
||||
/** Schnittflächen eines Bauteils im Blatt der Ebene `levelId` (leer, wenn nicht geschnitten). */
|
||||
export function sheetOwnerOutlines(levelId: string, kind: SheetOwnerKind, id: string): readonly Vec2[][] {
|
||||
return outlinesByLevel.get(levelId)?.get(`${kind}:${id}`) ?? [];
|
||||
}
|
||||
@@ -29,7 +29,8 @@ import type { SectionOutput } from "../plan/toSection";
|
||||
import { generateElevationPlan } from "../plan/toElevation";
|
||||
import { crossKindOverlayAllowed, planUnderlayPrimitives } from "../plan/planUnderlay";
|
||||
import { sectionOpeningPrimitives } from "../plan/sectionOpenings";
|
||||
import { setSheetSnapSegments, snapSegmentsFromPrimitives } from "../tools/sheetSnapGeometry";
|
||||
import { levelMarkerPrimitives, levelMarksEnabled } from "../plan/levelMarkers";
|
||||
import { setSheetOwnerOutlines, setSheetSnapSegments, snapSegmentsFromPrimitives } from "../tools/sheetSnapGeometry";
|
||||
import { pushNativeScene, pushNativeWalls } from "../plan/nativeSync";
|
||||
import { selectionHighlightLines } from "../plan/toWalls3d";
|
||||
import { applyGroupDimmingToPlan } from "../state/groupActions";
|
||||
@@ -1196,9 +1197,15 @@ function SectionPlanView({
|
||||
),
|
||||
[project, level.id, visibleCodes, categoryDisplay, detail, referenceLines, mono, scaleDenominator],
|
||||
);
|
||||
// Automatische Höhenkoten links neben der Zeichnung (abschaltbar je Ebene).
|
||||
const marks = useMemo(
|
||||
() =>
|
||||
rawPlan && levelMarksEnabled(level) ? levelMarkerPrimitives(project, rawPlan.bounds) : [],
|
||||
[rawPlan, level, project],
|
||||
);
|
||||
const withOverlay = useMemo(() => {
|
||||
if (!rawPlan) return rawPlan;
|
||||
const extra = sheetDrawings.primitives;
|
||||
const extra = [...marks, ...sheetDrawings.primitives];
|
||||
if (overlayPrimitives.length === 0 && extra.length === 0) return rawPlan;
|
||||
const b = { ...rawPlan.bounds };
|
||||
const grow = (x: number, y: number) => {
|
||||
@@ -1211,14 +1218,15 @@ function SectionPlanView({
|
||||
if (pr.kind === "polygon") for (const p of pr.pts) grow(p.x, p.y);
|
||||
else if (pr.kind === "line") { grow(pr.a.x, pr.a.y); grow(pr.b.x, pr.b.y); }
|
||||
}
|
||||
if (extra.length > 0) {
|
||||
if (sheetDrawings.primitives.length > 0) {
|
||||
const eb = sheetDrawings.bounds;
|
||||
grow(eb.minX, eb.minY);
|
||||
grow(eb.maxX, eb.maxY);
|
||||
}
|
||||
for (const pr of marks) if (pr.kind === "line") grow(pr.a.x, pr.a.y);
|
||||
// Unterlage zuunterst, Blatt-Zeichnungen obenauf.
|
||||
return { ...rawPlan, primitives: [...overlayPrimitives, ...rawPlan.primitives, ...extra], bounds: b };
|
||||
}, [rawPlan, overlayPrimitives, sheetDrawings]);
|
||||
}, [rawPlan, overlayPrimitives, sheetDrawings, marks]);
|
||||
// Fangkanten der abgeleiteten Geometrie (Schnitt-/Ansichtskanten + Unterlage)
|
||||
// für `computeSnap` bereitstellen — die stehen nicht im Projekt. Die eigenen
|
||||
// 2D-Elemente fängt computeSnap ohnehin über `drawings2d`.
|
||||
@@ -1228,7 +1236,11 @@ function SectionPlanView({
|
||||
level.id,
|
||||
snapSegmentsFromPrimitives([...overlayPrimitives, ...rawPlan.primitives]),
|
||||
);
|
||||
return () => setSheetSnapSegments(level.id, null);
|
||||
setSheetOwnerOutlines(level.id, rawPlan.primitives);
|
||||
return () => {
|
||||
setSheetSnapSegments(level.id, null);
|
||||
setSheetOwnerOutlines(level.id, null);
|
||||
};
|
||||
}, [rawPlan, overlayPrimitives, level.id]);
|
||||
// Gruppen-Isolation ("Gruppe betreten") gilt auch für Schnitt-/Ansichts-
|
||||
// Pläne, s. state/groupActions.ts::applyGroupDimming.
|
||||
|
||||
Reference in new issue
Block a user