Merge branch 'worktree-agent-a733d7bc917c3ae8e' into claude/practical-noether-1hb2s1
This commit is contained in:
14 files changed
+178
-49
No files matched your search
@@ -246,6 +246,7 @@ export {
|
||||
sectionUAxisModel,
|
||||
} from "../plan/toSection";
|
||||
export { viewportLevelPlan } from "../plan/viewportPlan";
|
||||
export { snapshotMono } from "../plan/viewportPlan";
|
||||
|
||||
export {
|
||||
TRUCK_MESH_READY_EVENT,
|
||||
|
||||
@@ -17,7 +17,7 @@ import { t } from "../i18n/translate";
|
||||
import { legendPlan, legendPrintSvg } from "./legendSvg";
|
||||
import { categoryLayerGroups, enablePdfLayers, type PdfLayers } from "./pdfLayers";
|
||||
import { generatePlan, type Plan } from "../plan/generatePlan";
|
||||
import { viewportLevelPlan } from "../plan/viewportPlan";
|
||||
import { snapshotMono, viewportLevelPlan } from "../plan/viewportPlan";
|
||||
import { planToPrintSvg } from "./planToPrintSvg";
|
||||
import { drawTablesPdf, sheetTables } from "./sheetTable";
|
||||
import { collectVisibleCodes } from "../model/types";
|
||||
@@ -169,7 +169,7 @@ async function renderPage(
|
||||
// nach Massstab) — wie ViewportPlan in LayoutSheet.tsx, sonst wiche das PDF von der Vorschau ab.
|
||||
const scaleN = ctx.scaleOverride ?? resolveViewportScale(vp, snap);
|
||||
// Geschoss/Zeichnung, Schnitt oder Ansicht ([115]) — wie ViewportPlanSvg, im Druck-Modus.
|
||||
const planOf = (visible: Set<string>) => viewportLevelPlan(project, snap.activeLevelId, visible, snap.detail, scaleN, true);
|
||||
const planOf = (visible: Set<string>) => viewportLevelPlan(project, snap.activeLevelId, visible, snap.detail, scaleN, true, snapshotMono(project, snap));
|
||||
const draw = async (plan: Plan, transparent: boolean, bounds?: Plan["bounds"]) => {
|
||||
const print = planToPrintSvg(plan, { scaleDenominator: scaleN, pageWidthMm: vp.widthMm, pageHeightMm: vp.heightMm, transparent, bounds });
|
||||
await doc.svg(print.svg, { x: vp.xMm, y: vp.yMm, width: vp.widthMm, height: vp.heightMm });
|
||||
|
||||
+2
-2
@@ -91,7 +91,7 @@ export const de = {
|
||||
"display.style.group": "Darstellungsart",
|
||||
"display.style.hint": "Darstellungsart der aktiven Ansicht",
|
||||
"display.style.color": "Farbig",
|
||||
"display.style.mono": "Schwarz-Weiss",
|
||||
"display.style.mono": "Tusche",
|
||||
"display.style.shaded": "Schattiert",
|
||||
"display.style.shadedEdges": "Schattiert mit Kanten",
|
||||
"display.style.white": "Weiss",
|
||||
@@ -1145,7 +1145,7 @@ export const de = {
|
||||
"resources.viewTemplates.detail": "Detailgrad",
|
||||
"resources.viewTemplates.scale": "Massstab 1:",
|
||||
"resources.viewTemplates.displayMode": "Darstellungsmodus",
|
||||
"resources.viewTemplates.mono": "Schwarz-Weiss",
|
||||
"resources.viewTemplates.mono": "Tusche",
|
||||
"resources.viewTemplates.shadows": "Schatten",
|
||||
"resources.viewTemplates.hiddenLines": "Verdeckte Kanten",
|
||||
"resources.viewTemplates.sketch": "Skizzenstil",
|
||||
|
||||
+2
-2
@@ -90,7 +90,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"display.style.group": "Display style",
|
||||
"display.style.hint": "Display style of the active view",
|
||||
"display.style.color": "Color",
|
||||
"display.style.mono": "Black & white",
|
||||
"display.style.mono": "Ink",
|
||||
"display.style.shaded": "Shaded",
|
||||
"display.style.shadedEdges": "Shaded with edges",
|
||||
"display.style.white": "White",
|
||||
@@ -1139,7 +1139,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"resources.viewTemplates.detail": "Detail level",
|
||||
"resources.viewTemplates.scale": "Scale 1:",
|
||||
"resources.viewTemplates.displayMode": "Display mode",
|
||||
"resources.viewTemplates.mono": "Black and white",
|
||||
"resources.viewTemplates.mono": "Ink",
|
||||
"resources.viewTemplates.shadows": "Shadows",
|
||||
"resources.viewTemplates.hiddenLines": "Hidden lines",
|
||||
"resources.viewTemplates.sketch": "Sketch style",
|
||||
|
||||
@@ -309,8 +309,10 @@ describe("Standardpalette (Kern)", () => {
|
||||
expect(new Set(pens.map((p) => p.id)).size).toBe(255);
|
||||
for (let i = 1; i <= 255; i++) {
|
||||
expect(styles[String(i)].color).toMatch(/^#[0-9a-f]{6}$/);
|
||||
expect(styles[String(i)].weight).toBe(PEN_FALLBACK_WEIGHT);
|
||||
// [140] Strichstärken nach der Plan-Rangfolge (0.25 / 0.18 / 0.13 / 0.1 / 0.02).
|
||||
expect([0.25, 0.18, 0.13, 0.1, 0.02]).toContain(styles[String(i)].weight);
|
||||
}
|
||||
expect(styles["7"].weight).toBe(0.25);
|
||||
});
|
||||
|
||||
it("nutzt für 1-9 die klassischen Grundfarben (Rot/Gelb/.../Grau)", () => {
|
||||
|
||||
@@ -97,7 +97,7 @@ export function presentationTemplate(project: Project): { template: ViewTemplate
|
||||
if (own) return { template: own, isNew: false };
|
||||
const std = (addedItems(standardsMergeOps(project), "viewTemplates") as ViewTemplate[]).find((t) => t.id === PRESENTATION_TEMPLATE_ID);
|
||||
return {
|
||||
template: std ?? { id: PRESENTATION_TEMPLATE_ID, name: "Präsentation", detail: "mittel", mono: false, shadows: true, hiddenLines: false },
|
||||
template: std ?? { id: PRESENTATION_TEMPLATE_ID, name: "Präsentation", detail: "mittel", mono: true, shadows: true, hiddenLines: false },
|
||||
isNew: true,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest";
|
||||
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
|
||||
import { collectVisibleCodes } from "../model/types";
|
||||
import { generatePlan } from "./generatePlan";
|
||||
import { viewportLevelPlan } from "./viewportPlan";
|
||||
import { snapshotMono, viewportLevelPlan } from "./viewportPlan";
|
||||
|
||||
const p = buildComplexSampleProject();
|
||||
const codes = collectVisibleCodes(p.layers);
|
||||
@@ -23,7 +23,30 @@ describe("viewportLevelPlan", () => {
|
||||
|
||||
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);
|
||||
expect(plan.primitives.length).toBe(generatePlan(p, "eg", codes, undefined, "mittel", false, true, true, 100).primitives.length);
|
||||
});
|
||||
|
||||
// [140] Blatt und PDF folgen dem Tusche-Standard der App: keine bunten Farben (Ziegelrot …), ausser
|
||||
// die Vorlage des Ausschnitts wählt Farbe (`mono: false`).
|
||||
it("Tusche als Standard, Farbe nur auf Wunsch", async () => {
|
||||
const bunt = (plan: { primitives: unknown[] }) => {
|
||||
const hex = JSON.stringify(plan.primitives).match(/#[0-9a-fA-F]{6}\b/g) ?? [];
|
||||
return hex.filter((h) => {
|
||||
const [r, g, b] = [1, 3, 5].map((i) => parseInt(h.slice(i, i + 2), 16));
|
||||
return Math.max(r, g, b) - Math.min(r, g, b) > 24;
|
||||
});
|
||||
};
|
||||
expect(bunt(await viewportLevelPlan(p, "ansicht-sued", codes, "mittel", 100))).toEqual([]);
|
||||
expect(bunt(await viewportLevelPlan(p, "ansicht-sued", codes, "mittel", 100, false, false)).length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("snapshotMono: Vorlage mit mono: false = farbig, sonst Tusche", () => {
|
||||
const q = { ...p, viewTemplates: [{ id: "f", name: "F", mono: false }, { id: "t", name: "T", mono: true }] };
|
||||
const snap = { templateId: undefined as string | undefined };
|
||||
expect(snapshotMono(q, snap)).toBe(true);
|
||||
expect(snapshotMono(q, { templateId: "f" })).toBe(false);
|
||||
expect(snapshotMono(q, { templateId: "t" })).toBe(true);
|
||||
expect(snapshotMono(q, { templateId: "weg" })).toBe(true);
|
||||
});
|
||||
|
||||
it("unbekannte Ebene: leer, kein Fehler", async () => {
|
||||
|
||||
@@ -11,11 +11,20 @@ import { computeSection, generateSectionPlan } from "./toSection";
|
||||
import { generateElevationPlan } from "./toElevation";
|
||||
import { levelMarkerPrimitives, levelMarksEnabled } from "./levelMarkers";
|
||||
|
||||
/**
|
||||
* [140] Tusche (Schwarz-Weiss) für einen Viewport: Standard wie in der App; Farbe nur, wenn die
|
||||
* Ansichtsvorlage des Ausschnitts ausdrücklich `mono: false` setzt (Kern: `sheet_viewports::snapshot_mono`).
|
||||
*/
|
||||
export function snapshotMono(project: Pick<Project, "viewTemplates">, snap: { templateId?: string | null }): boolean {
|
||||
if (!snap.templateId) return true;
|
||||
return project.viewTemplates?.find((t) => t.id === snap.templateId)?.mono !== false;
|
||||
}
|
||||
|
||||
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.
|
||||
* entfallen; `mono`: Tusche, s. {@link snapshotMono}). Schnitte brauchen die truck-Körper und sind darum asynchron.
|
||||
*/
|
||||
export async function viewportLevelPlan(
|
||||
project: Project,
|
||||
@@ -24,23 +33,24 @@ export async function viewportLevelPlan(
|
||||
detail: DetailLevel | undefined,
|
||||
scaleDenominator: number,
|
||||
forPrint = false,
|
||||
mono = true,
|
||||
): 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);
|
||||
return generatePlan(project, levelId, visibleCodes, undefined, detail, false, mono, 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 })
|
||||
? generateSectionPlan(out, mono, { hiddenLines: level.hiddenLines, visibleCodes, openings: true, scaleDenominator })
|
||||
: null;
|
||||
} else {
|
||||
raw = generateElevationPlan(project, level, { visibleCodes, scaleDenominator });
|
||||
raw = generateElevationPlan(project, level, { visibleCodes, scaleDenominator, mono });
|
||||
}
|
||||
if (!raw || raw.primitives.length === 0) return EMPTY;
|
||||
const own = generatePlan(project, level.id, visibleCodes, undefined, detail, false, false, false, scaleDenominator, forPrint);
|
||||
const own = generatePlan(project, level.id, visibleCodes, undefined, detail, false, mono, false, scaleDenominator, forPrint);
|
||||
const marks = levelMarksEnabled(level) ? levelMarkerPrimitives(project, raw.bounds) : [];
|
||||
const b = { ...raw.bounds };
|
||||
const grow = (x: number, y: number) => {
|
||||
|
||||
@@ -25,7 +25,7 @@ import type {
|
||||
Project,
|
||||
Vec2,
|
||||
} from "../model/types";
|
||||
import { createTable, PX_PER_M, sheetTables, TABLE_SOURCES, tableSourceLabel, viewportLevelPlan } from "../core";
|
||||
import { createTable, PX_PER_M, sheetTables, TABLE_SOURCES, snapshotMono, tableSourceLabel, viewportLevelPlan } from "../core";
|
||||
import type { TableOut } from "../core";
|
||||
import { SheetTableHud } from "./SheetTableHud";
|
||||
import { planToPrintSvg } from "../export/planToPrintSvg";
|
||||
@@ -89,7 +89,7 @@ export function ViewportPlanSvg({
|
||||
// Massstab ZUERST: er geht in die Plan-Erzeugung ein (Bemassung in Papier-mm, s. model/dimension.ts).
|
||||
const scaleN = resolveViewportScale(viewport, snap);
|
||||
// Geschoss/Zeichnung wie bisher; Schnitt/Ansicht über die abgeleitete Projektion ([115], Schnitt asynchron).
|
||||
void viewportLevelPlan(project, snap.activeLevelId, codes, snap.detail, scaleN)
|
||||
void viewportLevelPlan(project, snap.activeLevelId, codes, snap.detail, scaleN, false, snapshotMono(project, snap))
|
||||
.then((plan) => {
|
||||
if (disposed) return;
|
||||
const print = planToPrintSvg(plan, {
|
||||
|
||||
Reference in new issue
Block a user