[115] Schnitt/Ansicht: Wechsel ins 3D (mit Live-Schnitt an der Schnittlinie) und Schnitt/Ansicht im Layout-Viewport und PDF
This commit is contained in:
9 files changed
+278
-65
No files matched your search
@@ -0,0 +1,33 @@
|
||||
// [115] Layout-Viewport zeigt Schnitt und Ansicht wie einen Grundriss (vorher nur Geschoss/Zeichnung).
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
|
||||
import { collectVisibleCodes } from "../model/types";
|
||||
import { generatePlan } from "./generatePlan";
|
||||
import { viewportLevelPlan } from "./viewportPlan";
|
||||
|
||||
const p = buildComplexSampleProject();
|
||||
const codes = collectVisibleCodes(p.layers);
|
||||
|
||||
describe("viewportLevelPlan", () => {
|
||||
it("Schnitt: Schnittfläche + Koten, Grenzen über die Höhe", async () => {
|
||||
const plan = await viewportLevelPlan(p, "schnitt-a", codes, "mittel", 100);
|
||||
expect(plan.primitives.length).toBeGreaterThan(200);
|
||||
// Höhe (y) statt Grundriss-Tiefe: das Haus reicht über mehrere Geschosse.
|
||||
expect(plan.bounds.maxY - plan.bounds.minY).toBeGreaterThan(8);
|
||||
});
|
||||
|
||||
it("Ansicht: Fassade", async () => {
|
||||
const plan = await viewportLevelPlan(p, "ansicht-sued", codes, "mittel", 100);
|
||||
expect(plan.primitives.length).toBeGreaterThan(100);
|
||||
});
|
||||
|
||||
it("Geschoss: wie bisher generatePlan", async () => {
|
||||
const plan = await viewportLevelPlan(p, "eg", codes, "mittel", 100);
|
||||
expect(plan.primitives.length).toBe(generatePlan(p, "eg", codes, undefined, "mittel", false, false, true, 100).primitives.length);
|
||||
});
|
||||
|
||||
it("unbekannte Ebene: leer, kein Fehler", async () => {
|
||||
const plan = await viewportLevelPlan(p, "gibt-es-nicht", codes, "mittel", 100);
|
||||
expect(plan.primitives.length).toBe(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,59 @@
|
||||
// [115] Inhalt eines Layout-Viewports: der Plan der Ebene, auf die sein Ausschnitt zeigt — Geschoss und
|
||||
// Zeichnung wie bisher über `generatePlan`, Schnitt und Ansicht wie in der Schnitt-/Ansichts-Ansicht
|
||||
// (`SectionPlanView`): abgeleitete Projektion aus dem Kern, automatische Koten und die eigenen
|
||||
// 2D-Elemente der Ebene. Vorher rechneten Viewports nur Grundrisse — ein Schnitt-Ausschnitt auf dem
|
||||
// Blatt zeigte bloss seine 2D-Elemente. Nur Zusammensetzen vorhandener Kern-Abfragen.
|
||||
|
||||
import type { DetailLevel } from "../model/viewTypes";
|
||||
import type { Project } from "../model/types";
|
||||
import { generatePlan, type Plan, type Primitive } from "./generatePlan";
|
||||
import { computeSection, generateSectionPlan } from "./toSection";
|
||||
import { generateElevationPlan } from "./toElevation";
|
||||
import { levelMarkerPrimitives, levelMarksEnabled } from "./levelMarkers";
|
||||
|
||||
const EMPTY: Plan = { primitives: [], bounds: { minX: 0, minY: 0, maxX: 1, maxY: 1 } };
|
||||
|
||||
/**
|
||||
* Plan der Ebene `levelId` für einen Layout-Viewport bzw. dessen PDF (`forPrint`: `noPrint`-Elemente
|
||||
* entfallen). Schnitte brauchen die truck-Körper und sind darum asynchron.
|
||||
*/
|
||||
export async function viewportLevelPlan(
|
||||
project: Project,
|
||||
levelId: string,
|
||||
visibleCodes: Set<string>,
|
||||
detail: DetailLevel | undefined,
|
||||
scaleDenominator: number,
|
||||
forPrint = false,
|
||||
): Promise<Plan> {
|
||||
const level = project.drawingLevels.find((l) => l.id === levelId);
|
||||
if (!level) return EMPTY;
|
||||
if (level.kind !== "section" && level.kind !== "elevation") {
|
||||
return generatePlan(project, levelId, visibleCodes, undefined, detail, false, false, true, scaleDenominator, forPrint);
|
||||
}
|
||||
let raw: Plan | null;
|
||||
if (level.kind === "section") {
|
||||
const out = await computeSection(project, level);
|
||||
raw = out
|
||||
? generateSectionPlan(out, false, { hiddenLines: level.hiddenLines, visibleCodes, openings: true, scaleDenominator })
|
||||
: null;
|
||||
} else {
|
||||
raw = generateElevationPlan(project, level, { visibleCodes, scaleDenominator });
|
||||
}
|
||||
if (!raw || raw.primitives.length === 0) return EMPTY;
|
||||
const own = generatePlan(project, level.id, visibleCodes, undefined, detail, false, false, false, scaleDenominator, forPrint);
|
||||
const marks = levelMarksEnabled(level) ? levelMarkerPrimitives(project, raw.bounds) : [];
|
||||
const b = { ...raw.bounds };
|
||||
const grow = (x: number, y: number) => {
|
||||
b.minX = Math.min(b.minX, x);
|
||||
b.minY = Math.min(b.minY, y);
|
||||
b.maxX = Math.max(b.maxX, x);
|
||||
b.maxY = Math.max(b.maxY, y);
|
||||
};
|
||||
if (own.primitives.length > 0) {
|
||||
grow(own.bounds.minX, own.bounds.minY);
|
||||
grow(own.bounds.maxX, own.bounds.maxY);
|
||||
}
|
||||
for (const pr of marks) if (pr.kind === "line") grow(pr.a.x, pr.a.y);
|
||||
const primitives: Primitive[] = [...raw.primitives, ...marks, ...own.primitives];
|
||||
return { primitives, bounds: b };
|
||||
}
|
||||
Reference in new issue
Block a user