Merge [266] Wettbewerb-Durchlauf
This commit is contained in:
24 files changed
+290
-49
No files matched your search
+4
-2
@@ -42,6 +42,7 @@ import { useT } from "./i18n";
|
||||
import { useStore } from "./state/appStore";
|
||||
import { setCursor } from "./state/cursorStore";
|
||||
import { setLiveScale } from "./state/liveScaleStore";
|
||||
import { planViewMounted } from "./state/planViewport";
|
||||
import { openMeshFileDialog, requestMeshImport, splitMeshFiles } from "./state/meshImportStore";
|
||||
import { openPointCloudFileDialog } from "./state/pointCloudStore";
|
||||
import { clearKinds, toIdLists } from "./state/selection";
|
||||
@@ -573,9 +574,10 @@ export default function App() {
|
||||
|
||||
// Solange keine Plan-Ansicht montiert ist, gibt es keinen Live-Massstab.
|
||||
// (PlanView meldet beim Montieren/Zoomen sofort wieder einen Wert.)
|
||||
const planMounted = planViewMounted(activeLevel.kind, viewType);
|
||||
useEffect(() => {
|
||||
if (!planActive) setLiveScale(null);
|
||||
}, [planActive]);
|
||||
if (!planMounted) setLiveScale(null);
|
||||
}, [planMounted]);
|
||||
|
||||
// Zoom-Buttons der Oberleiste an die montierte Plan-Ansicht weiterreichen.
|
||||
const fitPlan = () => planViewRef.current?.fit();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
viewBox -13.448 0 38.615 33.813
|
||||
bytes 26551
|
||||
bytes 26549
|
||||
circle 14
|
||||
g 1
|
||||
line 99
|
||||
@@ -9,4 +9,4 @@ rect 1
|
||||
svg 1
|
||||
text 42
|
||||
tspan 9
|
||||
hash df0ffc600942c7a3
|
||||
hash 1ec4678629321460
|
||||
@@ -1,12 +1,12 @@
|
||||
viewBox -12.974 0 37.808 33.406
|
||||
bytes 326212
|
||||
bytes 325502
|
||||
circle 14
|
||||
g 1
|
||||
line 3244
|
||||
line 3236
|
||||
polygon 88
|
||||
polyline 83
|
||||
rect 1
|
||||
svg 1
|
||||
text 42
|
||||
tspan 9
|
||||
hash 6927ee5ae03f3392
|
||||
hash 3830b7a049964f28
|
||||
@@ -1,5 +1,5 @@
|
||||
viewBox -41.5 0 95 63.6
|
||||
bytes 69794
|
||||
bytes 69802
|
||||
circle 16
|
||||
g 1
|
||||
line 143
|
||||
@@ -10,4 +10,4 @@ rect 1
|
||||
svg 1
|
||||
text 116
|
||||
tspan 25
|
||||
hash 3928da4130757743
|
||||
hash 2cb6a8616b72208d
|
||||
@@ -1,5 +1,5 @@
|
||||
viewBox -41.5 0 95 63.6
|
||||
bytes 111887
|
||||
bytes 111889
|
||||
circle 16
|
||||
g 1
|
||||
line 356
|
||||
@@ -10,4 +10,4 @@ rect 1
|
||||
svg 1
|
||||
text 116
|
||||
tspan 25
|
||||
hash 661b96d9cf41d1eb
|
||||
hash 1aa65b0693a07894
|
||||
@@ -1,5 +1,5 @@
|
||||
viewBox -13.448 0 38.615 33.813
|
||||
bytes 45535
|
||||
bytes 45544
|
||||
circle 14
|
||||
g 1
|
||||
line 115
|
||||
@@ -10,4 +10,4 @@ rect 1
|
||||
svg 1
|
||||
text 86
|
||||
tspan 18
|
||||
hash 05c3cd9ed4740373
|
||||
hash 2d5548d07c8acf24
|
||||
@@ -1,8 +1,8 @@
|
||||
viewBox -12.974 0 37.808 33.406
|
||||
bytes 355483
|
||||
bytes 355847
|
||||
circle 14
|
||||
g 1
|
||||
line 3244
|
||||
line 3248
|
||||
path 26
|
||||
polygon 171
|
||||
polyline 160
|
||||
@@ -10,4 +10,4 @@ rect 1
|
||||
svg 1
|
||||
text 86
|
||||
tspan 18
|
||||
hash fe98ae3971ccdb07
|
||||
hash 23868b53e5143434
|
||||
@@ -1,5 +1,5 @@
|
||||
viewBox -13.693 0 38.86 33.813
|
||||
bytes 42938
|
||||
bytes 42942
|
||||
circle 16
|
||||
g 1
|
||||
line 99
|
||||
@@ -10,4 +10,4 @@ rect 1
|
||||
svg 1
|
||||
text 71
|
||||
tspan 15
|
||||
hash 6ba46134563b73f9
|
||||
hash 3784d073814a426b
|
||||
@@ -1,5 +1,5 @@
|
||||
viewBox -13.693 0 38.527 33.406
|
||||
bytes 50398
|
||||
bytes 50390
|
||||
circle 16
|
||||
g 1
|
||||
line 94
|
||||
@@ -10,4 +10,4 @@ rect 1
|
||||
svg 1
|
||||
text 71
|
||||
tspan 15
|
||||
hash 9cf652b310c3fce6
|
||||
hash 92682c4ba0246e9a
|
||||
@@ -121,6 +121,53 @@ describe("[66] Präsentationsplan", () => {
|
||||
expect(levelHasContent(withEmpty, floor.id)).toBe(true);
|
||||
});
|
||||
|
||||
// [266] Kataster-DXF mit den Vorgaben (neue Zeichnungsebene) importiert: die Situation des Plakats zeigte nur das Geschoss
|
||||
// (Gebäude und Parzelle), ohne Nachbarn, Strassen und Parzellennummern. Jetzt nimmt sie die Zeichnungsebene, deren
|
||||
// Zeichnung das Gebäude umgibt (dort zeichnet die Vorlage „Situation WBW“ das eigene Gebäude gefüllt dazu).
|
||||
it("[266] Plakat-Situation auf der Kataster-Zeichnungsebene, die das Gebäude umgibt", () => {
|
||||
const p0 = st().project;
|
||||
const floor = p0.drawingLevels.find((l) => l.kind === "floor" && !l.layoutId)!;
|
||||
const xs = p0.walls.filter((w) => w.floorId === floor.id).flatMap((w) => [w.start.x, w.end.x]);
|
||||
const ys = p0.walls.filter((w) => w.floorId === floor.id).flatMap((w) => [w.start.y, w.end.y]);
|
||||
const [x0, x1, y0, y1] = [Math.min(...xs) - 30, Math.max(...xs) + 30, Math.min(...ys) - 30, Math.max(...ys) + 30];
|
||||
const ring = [{ x: x0, y: y0 }, { x: x1, y: y0 }, { x: x1, y: y1 }, { x: x0, y: y1 }];
|
||||
const kat = { id: "lv-kataster", name: "kataster", kind: "drawing" as const, visible: true, locked: false };
|
||||
const d = (id: string, geom: unknown) => ({ id, type: "drawing2d", levelId: kat.id, categoryCode: "20", geom }) as unknown as Project["drawings2d"][number];
|
||||
const withKat: Project = {
|
||||
...p0,
|
||||
drawingLevels: [...p0.drawingLevels, kat, { id: "lv-skizze", name: "Skizze", kind: "drawing", visible: true, locked: false }],
|
||||
drawings2d: [
|
||||
...p0.drawings2d,
|
||||
d("k1", { shape: "polyline", pts: ring, closed: true }),
|
||||
d("k2", { shape: "text", at: { x: x0 + 1, y: y0 + 1 }, text: "1003", height: 2, rotation: 0 }),
|
||||
// Skizze weit weg: nicht die Situation.
|
||||
{ ...d("s1", { shape: "line", a: { x: x1 + 500, y: y1 + 500 }, b: { x: x1 + 510, y: y1 + 500 } }), levelId: "lv-skizze" },
|
||||
],
|
||||
};
|
||||
const sit0 = planPresentationSheet(p0, { ...presentationDefaults(p0), scale: 200, poster: "poster-a1-landscape", extras: POSTER_EXTRAS_DEFAULT }).items.find((i) => i.kind === "situation")!;
|
||||
// Ohne Kataster-Ebene bleibt es das Erdgeschoss.
|
||||
expect(p0.drawingLevels.find((l) => l.id === sit0.levelId)!.kind).toBe("floor");
|
||||
st().loadProject(withKat);
|
||||
const p1 = st().project;
|
||||
const o = { ...presentationDefaults(p1), scale: 200, poster: "poster-a1-landscape", extras: POSTER_EXTRAS_DEFAULT };
|
||||
const sit = planPresentationSheet(p1, o).items.find((i) => i.kind === "situation")!;
|
||||
expect(sit.levelId).toBe("lv-kataster");
|
||||
}, 60_000);
|
||||
|
||||
it("[266] Geschoss nur mit Bauteilen (Wände/Räume tragen `floorId`, nicht `levelId`) gilt nicht als leer", () => {
|
||||
const floor = project.drawingLevels.find((l) => l.kind === "floor" && !l.layoutId)!;
|
||||
const wall = project.walls[0];
|
||||
const room = project.rooms![0];
|
||||
const onlyParts = {
|
||||
...project,
|
||||
drawingLevels: [...project.drawingLevels, { ...floor, id: "lv-bau", name: "OG Bauteile", baseElevation: 99 }],
|
||||
walls: [...project.walls, { ...wall, id: "w-bau", floorId: "lv-bau" }],
|
||||
rooms: [...project.rooms!, { ...room, id: "r-bau", floorId: "lv-bau" }],
|
||||
};
|
||||
expect(levelHasContent(onlyParts, "lv-bau")).toBe(true);
|
||||
expect(presentationDefaults(onlyParts).floors).toContain("lv-bau");
|
||||
});
|
||||
|
||||
it("[224] fester Massstab und Massstab je Viewport landen in Ausschnitt und Viewport", () => {
|
||||
const floors = project.drawingLevels.filter((l) => l.kind === "floor" && !l.layoutId).slice(0, 2).map((l) => l.id);
|
||||
const res = presentationSheetOps(project, { floors, elevationIds: [], scale: 200, scales: { [floors[1]]: 100 }, sectionId: null, paper: "a1", orientation: "landscape", sketch: false }, LABELS, "t4")!;
|
||||
|
||||
@@ -153,7 +153,9 @@ const isFloor = (l: DrawingLevel) => l.kind === "floor" && !l.layoutId;
|
||||
export function levelHasContent(project: Project, levelId: string): boolean {
|
||||
for (const [key, v] of Object.entries(project as unknown as Record<string, unknown>)) {
|
||||
if (key === "drawingLevels" || !Array.isArray(v)) continue;
|
||||
if (v.some((it) => typeof it === "object" && it !== null && (it as { levelId?: string }).levelId === levelId)) return true;
|
||||
// Bauteile (Wände, Decken, Dächer, Treppen, Räume, Stützen …) tragen `floorId`, 2D-Elemente und Körper `levelId` ([266]).
|
||||
const on = (it: unknown) => typeof it === "object" && it !== null && ((it as { levelId?: string }).levelId === levelId || (it as { floorId?: string }).floorId === levelId);
|
||||
if (v.some(on)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -259,6 +261,42 @@ function groundFloorId(project: Project, o: PresentationOptions): string | undef
|
||||
return (pool.find((l) => l.zeroLevel) ?? [...pool].sort((a, b) => Math.abs(a.baseElevation ?? 0) - Math.abs(b.baseElevation ?? 0))[0])?.id;
|
||||
}
|
||||
|
||||
/** Alle Koordinatenpaare `{x, y}` einer Geometrie (Linie, Polylinie, Kreis, Text …), rekursiv. */
|
||||
function geomPoints(g: unknown, out: { x: number; y: number }[] = []): { x: number; y: number }[] {
|
||||
if (Array.isArray(g)) for (const v of g) geomPoints(v, out);
|
||||
else if (g && typeof g === "object") {
|
||||
const o = g as Record<string, unknown>;
|
||||
if (typeof o.x === "number" && typeof o.y === "number" && Number.isFinite(o.x) && Number.isFinite(o.y)) out.push({ x: o.x, y: o.y });
|
||||
else for (const v of Object.values(o)) geomPoints(v, out);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* [266] Ebene der Plakat-Situation: eine freie Zeichnungsebene (z. B. der Kataster-Import mit den Vorgaben), deren Zeichnung die
|
||||
* Mitte des Gebäudes umgibt — dort zeichnet die Vorlage „Situation WBW“ Nachbarn, Strassen und Parzellen und das eigene Gebäude
|
||||
* gefüllt. Bei mehreren die mit den meisten Elementen; ohne solche Ebene das Erdgeschoss.
|
||||
*/
|
||||
function situationLevelId(project: Project, o: PresentationOptions): string | undefined {
|
||||
const ground = groundFloorId(project, o);
|
||||
const parts = project.walls.filter((w) => w.floorId === ground).flatMap((w) => [w.start, w.end]);
|
||||
if (parts.length === 0) return ground;
|
||||
const cx = (Math.min(...parts.map((p) => p.x)) + Math.max(...parts.map((p) => p.x))) / 2;
|
||||
const cy = (Math.min(...parts.map((p) => p.y)) + Math.max(...parts.map((p) => p.y))) / 2;
|
||||
let best: { id: string; n: number } | null = null;
|
||||
for (const l of project.drawingLevels) {
|
||||
if (l.kind !== "drawing" || l.layoutId) continue;
|
||||
const items = project.drawings2d.filter((d) => d.levelId === l.id);
|
||||
const pts = items.flatMap((d) => geomPoints(d.geom));
|
||||
if (pts.length < 2) continue;
|
||||
const xs = pts.map((p) => p.x);
|
||||
const ys = pts.map((p) => p.y);
|
||||
const around = Math.min(...xs) < cx && cx < Math.max(...xs) && Math.min(...ys) < cy && cy < Math.max(...ys);
|
||||
if (around && (!best || items.length > best.n)) best = { id: l.id, n: items.length };
|
||||
}
|
||||
return best?.id ?? ground;
|
||||
}
|
||||
|
||||
/** Sichtbarkeit des Situationsplans: alle Klassen ausser denen, die die Vorlage „Situation WBW“ ausblendet (Umgebung bleibt), ohne Schattenstudie. */
|
||||
function situationVisibility(project: Project, t: ViewTemplate): Record<string, boolean> {
|
||||
const vis: Record<string, boolean> = {};
|
||||
@@ -293,7 +331,7 @@ export function planPresentationSheet(project: Project, o: PresentationOptions):
|
||||
if (poster) {
|
||||
const ex = o.extras;
|
||||
const sit = ex?.situation ? situationTemplate(project) : null;
|
||||
const sitLevel = sit && groundFloorId(project, o);
|
||||
const sitLevel = sit && situationLevelId(project, o);
|
||||
const m = posterTextMetrics(size);
|
||||
const sitTpl = sit?.template ?? (project.viewTemplates ?? []).find((t) => t.id === SITUATION_TEMPLATE_ID);
|
||||
posterReq = {
|
||||
|
||||
@@ -222,3 +222,33 @@ describe("Darstellung im Grundriss [260]", () => {
|
||||
expect(getState().project.openings!.find((o) => o.id === win.id)!.planMode).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
// [266] Der Befehl `raum` legt den Stempel-Text als Kopie des Namens an („Raum 1“). Umbenennen in der Objekt-Info
|
||||
// änderte nur den Namen: im Plan stand weiter „Raum 1“. Jetzt folgt der Stempel, solange er nur den alten Namen trägt.
|
||||
describe("Raumname und Stempel [266]", () => {
|
||||
it("Stempel mit dem alten Namen folgt dem neuen Namen (Ausrichtung bleibt), ein Undo-Schritt", () => {
|
||||
getState().loadProject(buildComplexSampleProject());
|
||||
const r = getState().project.rooms![0];
|
||||
const doc = { version: 1 as const, paragraphs: [{ runs: [{ text: r.name, marks: { bold: true } }], align: "center" as const }] };
|
||||
getState().setRoomStampDoc(r.id, doc);
|
||||
setState({ selection: { ...EMPTY_SELECTION, rooms: [r.id] } });
|
||||
const depth = getState().undoDepth;
|
||||
(hostFor("room", r.id).onSetRoomName as (x: string) => void)("Wohnen/Essen");
|
||||
const after = getState().project.rooms!.find((x) => x.id === r.id)!;
|
||||
expect(after.name).toBe("Wohnen/Essen");
|
||||
expect(after.stampDoc).toEqual({ version: 1, paragraphs: [{ runs: [{ text: "Wohnen/Essen", marks: { bold: true } }], align: "center" }] });
|
||||
expect(getState().undoDepth).toBe(depth + 1);
|
||||
});
|
||||
|
||||
it("eigener Stempel-Text (anders als der Name) bleibt", () => {
|
||||
getState().loadProject(buildComplexSampleProject());
|
||||
const r = getState().project.rooms![0];
|
||||
const doc = { version: 1 as const, paragraphs: [{ runs: [{ text: "Atelier", marks: {} }] }, { runs: [{ text: "mit Galerie", marks: {} }] }] };
|
||||
getState().setRoomStampDoc(r.id, doc);
|
||||
setState({ selection: { ...EMPTY_SELECTION, rooms: [r.id] } });
|
||||
(hostFor("room", r.id).onSetRoomName as (x: string) => void)("Werkstatt");
|
||||
const after = getState().project.rooms!.find((x) => x.id === r.id)!;
|
||||
expect(after.name).toBe("Werkstatt");
|
||||
expect(after.stampDoc).toEqual(doc);
|
||||
});
|
||||
});
|
||||
@@ -311,7 +311,15 @@ export function buildElementAttributesHost(c: FlatHostOpts) {
|
||||
// ── Raum-Attribute (nur bei selektiertem Raum) ─────────────────────────
|
||||
onSetRoomName: (name) => {
|
||||
// Raumnamen sind je Raum verschieden ⇒ bewusst nur das erste Element (das Feld ist bei Mehrfachauswahl gesperrt).
|
||||
if (selection?.kind === "room") updateRoom(selection.id, { name });
|
||||
if (selection?.kind !== "room") return;
|
||||
// [266] Trägt der Stempel nur den alten Namen (so legt ihn der Befehl `raum` an), folgt er dem neuen Namen —
|
||||
// sonst stünde im Plan weiter „Raum 1“. Ein eigener Stempel-Text bleibt.
|
||||
const room = getState().project.rooms?.find((r) => r.id === selection.id);
|
||||
const doc = room?.stampDoc;
|
||||
const run = doc?.paragraphs.length === 1 && doc.paragraphs[0].runs.length === 1 ? doc.paragraphs[0].runs[0] : undefined;
|
||||
if (room && doc && run && run.text === room.name) {
|
||||
updateRoom(selection.id, { name, stampDoc: { ...doc, paragraphs: [{ ...doc.paragraphs[0], runs: [{ ...run, text: name }] }] } });
|
||||
} else updateRoom(selection.id, { name });
|
||||
},
|
||||
onSetRoomSia: (category) => {
|
||||
if (selection?.kind === "room") patchAll("rooms", selection.id, { siaCategory: category });
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// [266] Einpassen/Zoom der Oberleiste: gesperrt nur ohne Plan-Ansicht (3D), nicht in Zeichnung, Schnitt oder Ansicht.
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { planViewMounted } from "./planViewport";
|
||||
|
||||
describe("planViewMounted [266]", () => {
|
||||
it("Plan-Ansicht in Geschoss, Schnitt, Ansicht, Zeichnung (z. B. Kataster-Import) und Deckenspiegel", () => {
|
||||
for (const kind of ["floor", "section", "elevation", "drawing", "ceiling"] as const) expect(planViewMounted(kind, "grundriss"), kind).toBe(true);
|
||||
});
|
||||
it("3D-Ansicht: keine Plan-Ansicht; Zeichnung und Deckenspiegel haben kein 3D und bleiben Plan", () => {
|
||||
expect(planViewMounted("floor", "perspektive")).toBe(false);
|
||||
expect(planViewMounted("section", "perspektive")).toBe(false);
|
||||
expect(planViewMounted("elevation", "perspektive")).toBe(false);
|
||||
expect(planViewMounted("drawing", "perspektive")).toBe(true);
|
||||
expect(planViewMounted("ceiling", "perspektive")).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -3,6 +3,16 @@
|
||||
// rechnet) an `useGripEditing`. Kein Zustand im Store: reiner Anzeige-Ausschnitt, ändert das Projekt nie.
|
||||
|
||||
import type { MeshRect } from "../core";
|
||||
import type { DrawingLevelKind, ViewType } from "../model/types";
|
||||
|
||||
/**
|
||||
* [266] Ist eine Plan-Ansicht montiert (Grundriss, Schnitt, Ansicht, Zeichnung, Deckenspiegel, Blatt)? Dann gelten Einpassen,
|
||||
* Zoom und Massstab der Oberleiste. Nur die 3D-Ansicht hat keine; Zeichnung und Deckenspiegel sind immer Plan.
|
||||
* (Vorher nur im Geschoss-Grundriss: nach dem Kataster-Import oder im Schnitt war „Auf Plan einpassen“ gesperrt.)
|
||||
*/
|
||||
export function planViewMounted(kind: DrawingLevelKind, viewType: ViewType): boolean {
|
||||
return viewType !== "perspektive" || kind === "drawing" || kind === "ceiling";
|
||||
}
|
||||
|
||||
let current: MeshRect | null = null;
|
||||
const listeners = new Set<() => void>();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// zuvor ([121]), damit ein App-Render sie nicht neu zeichnet. Aufgerufen von `App.tsx` für die `TopBar`.
|
||||
|
||||
import { isPlanKindActive } from "../state/viewTabs";
|
||||
import { planViewMounted } from "../state/planViewport";
|
||||
import { useMemo } from "react";
|
||||
import type { DrawingLevel, ModelViewOption, ViewType } from "../model/types";
|
||||
import { currentModelViewId, modelViewChoices } from "../state/modelViews";
|
||||
@@ -204,7 +205,7 @@ export function useTopBarElements(opts: {
|
||||
detailEnabled={planActive || viewType === "perspektive" || (viewType === "grundriss" && (activeLevel.kind === "section" || activeLevel.kind === "elevation"))}
|
||||
scaleDenominator={scaleDenominator}
|
||||
onApplyScale={ev.applyScale}
|
||||
zoomEnabled={planActive}
|
||||
zoomEnabled={planViewMounted(activeLevel.kind, viewType)}
|
||||
onFit={ev.fitPlan}
|
||||
onFitSelection={ev.fitSelection}
|
||||
onZoom100={ev.zoomToApplied}
|
||||
|
||||
Reference in new issue
Block a user