[285] Kataster/Kontext im Arbeitsgrundriss als halbtransparente Unterlage

Klassen "Als Unterlage" (LayerCategory.underlay, Vorgabe: Kontext-Klassen und Klassen aus
Landeskoordinaten-Importen) zeigt der Arbeitsgrundriss mit Deckkraft 0.35, damit Wände darüber
lesbar bleiben; Druck, PDF, SVG und CLI unverändert, Gruppenreihenfolge und Goldens unverändert.
This commit is contained in:
Claude committed 2026-11-18 14:53:13 +00:00
1 parent 188e05d8fe
commit 539d4e12dc
21 files changed
+220 -20

No files matched your search

+2
View File
@@ -1208,6 +1208,8 @@ export const de = {
"editor.fill": "Füllung",
"editor.fillNone": "keine",
"editor.hatch": "Schraffur",
"editor.underlay": "Als Unterlage",
"editor.underlay.hint": "Im Arbeitsgrundriss halbtransparent zeigen, damit Wände darüber lesbar bleiben (Druck und Export unverändert)",
"editor.floorHeight": "Geschosshöhe",
"editor.cutHeight": "Schnitthöhe",
"editor.levelElevation": "OK fertig Boden",
+2
View File
@@ -1202,6 +1202,8 @@ export const en: Record<TranslationKey, string> = {
"editor.fill": "Fill",
"editor.fillNone": "none",
"editor.hatch": "Hatch",
"editor.underlay": "As underlay",
"editor.underlay.hint": "Show semi-transparent in the working plan so walls on top stay readable (print and export unchanged)",
"editor.floorHeight": "Floor height",
"editor.cutHeight": "Cut height",
"editor.levelElevation": "Finished floor level",
+10 -1
View File
@@ -7,7 +7,7 @@
import type { ComponentProps } from "react";
import { t } from "../i18n";
import { activePenSet, resolvePenColor, resolvePenWeight } from "../model/penSets";
import { findCategory, formatElevation } from "../model/layers";
import { findCategory, formatElevation, isUnderlayCategory } from "../model/layers";
import type { DrawingLevel, LayerCategory } from "../model/types";
import { getState, useStore } from "../state/appStore";
import { EditorField } from "../ui/EditorField";
@@ -86,6 +86,15 @@ export function LayerInlineEditor({
<EditorField label={t("editor.fill")}>
<OptionalColorField value={cat.fill} onChange={(fill) => patchCategory(cat.code, { fill })} />
</EditorField>
<EditorField label={t("editor.underlay")}>
<input
type="checkbox"
data-testid="layer-underlay"
title={t("editor.underlay.hint")}
checked={isUnderlayCategory(project.layers, cat.code)}
onChange={(e) => patchCategory(cat.code, { underlay: e.target.checked })}
/>
</EditorField>
<EditorField label={t("editor.hatch")}>
<span className="editor-hatch">
<select
+11
View File
@@ -47,6 +47,17 @@ export function findCategory(cats: LayerCategory[], code: string): LayerCategory
* keine Ebene verweist (verwaister `categoryCode`). Nicht-werfend, damit die Attribut-Resolve-Kette
* (`plan/generatePlan.ts`) robust auf einen fehlenden Ebenen-Wert zurückfallen kann.
*/
/**
* [285] Zeigt der Arbeitsgrundriss die Klasse als halbtransparente Unterlage? `LayerCategory.underlay`, ohne Angabe
* die Umgebungsklassen („05 Kontext" und Kinder: Kataster, Strassen, Gelände …) wie im Kern (`plan/drawings.rs`).
*/
export function isUnderlayCategory(cats: LayerCategory[], code: string): boolean {
const own = findCategory(cats, code)?.underlay;
if (own !== undefined) return own;
const ctx = findCategory(cats, "05");
return !!ctx && (code === "05" || flattenCategories(ctx.children ?? []).some((c) => c.code === code));
}
export const getLayerCategory = (project: Project, code: string): LayerCategory | undefined => findCategory(project.layers, code);
/** Menge aller Codes sichtbarer Kategorien (Baum berücksichtigt). */
+5
View File
@@ -2106,6 +2106,11 @@ export type LayerCategory = {
* Fehlt sie, gilt die Körper-Konvention (ab 1:100 schwarz). Situation/Schwarzplan färben selbst ([207]).
*/
fill?: string;
/**
* [285] Im Arbeitsgrundriss (Bildschirm, nie Druck/Export) halbtransparent als Unterlage zeigen, damit Wände darüber
* lesbar bleiben. Fehlt: an für Umgebungsklassen („05 Kontext" und Kinder: Kataster, Strassen, Gelände …), sonst aus.
*/
underlay?: boolean;
/** Unterkategorien (Baum). */
children?: Array<LayerCategory>;
};
+4 -1
View File
@@ -43,7 +43,7 @@ export function LayerSettingsWindowApp() {
};
}, []);
const patch = (p: Partial<{ name: string; color: string; lw: number; fill: string | undefined; hatch: string | undefined }>) => {
const patch = (p: Partial<{ name: string; color: string; lw: number; fill: string | undefined; hatch: string | undefined; underlay: boolean }>) => {
if (!state) return;
void import("@tauri-apps/api/event").then(({ emitTo }) =>
emitTo("main", "layer-settings-command", {
@@ -115,6 +115,9 @@ export function LayerSettingsWindowApp() {
<EditorField label={t("editor.fill")}>
<OptionalColorField value={state.fill} onChange={(fill) => patch({ fill })} />
</EditorField>
<EditorField label={t("editor.underlay")}>
<input type="checkbox" title={t("editor.underlay.hint")} checked={state.underlay} onChange={(e) => patch({ underlay: e.target.checked })} />
</EditorField>
<EditorField label={t("editor.hatch")}>
<span className="editor-hatch">
<select
+4 -1
View File
@@ -21,7 +21,7 @@
//
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
import { findCategory } from "../model/layers";
import { findCategory, isUnderlayCategory } from "../model/layers";
import type { HatchStyle, LayerCategory, Project } from "../model/types";
import { BORDERLESS_WINDOW_CHROME } from "./windowChrome";
import { useWindowBridgeHost } from "./windowBridge";
@@ -35,6 +35,8 @@ export interface LayerSettingsSyncState {
color: string;
lw: number;
fill: string | undefined;
/** [285] Als Unterlage (wirksam, mit Vorgabe der Umgebungsklassen). */
underlay: boolean;
hatchId: string | undefined;
hatches: { id: string; name: string }[];
}
@@ -74,6 +76,7 @@ function stateFor(project: Pick<Project, "layers" | "hatches">, code: string): L
color: cat.color,
lw: cat.lw,
fill: cat.fill,
underlay: isUnderlayCategory(project.layers, cat.code),
hatchId: cat.hatch,
hatches: project.hatches.map((h: HatchStyle) => ({ id: h.id, name: h.name })),
};
@@ -0,0 +1,72 @@
// [285] Kataster/Kontext als Unterlage: im Arbeitsgrundriss (`contextUnderlay`) halbtransparent, Wände darüber bleiben
// lesbar; ohne den Schalter (Druck/Export, CLI) und für andere Klassen deckend. `LayerCategory.underlay` schaltet je Klasse.
import { describe, it, expect } from "vitest";
import { generatePlan } from "./generatePlan";
import { isUnderlayCategory } from "../model/layers";
import type { Drawing2D, Project } from "../model/types";
const line = (id: string, code: string): Drawing2D => ({
id,
type: "drawing2d",
levelId: "eg",
categoryCode: code,
geom: { shape: "line", a: { x: 0, y: 0 }, b: { x: 1, y: 0 } },
});
function project(extra: Record<string, unknown> = {}): Project {
return {
id: "t",
name: "T",
lineStyles: [],
hatches: [],
components: [],
wallTypes: [],
drawingLevels: [{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0 }],
layers: [
{ code: "05", name: "Kontext", color: "#707078", lw: 0.13, visible: true, locked: false, children: [{ code: "06", name: "Kataster", color: "#707078", lw: 0.13, visible: true, locked: false }] },
{ code: "20", name: "Zeichnung", color: "#0a0a0a", lw: 0.5, visible: true, locked: false },
],
walls: [],
openings: [],
ceilings: [],
stairs: [],
rooms: [],
drawings2d: [line("k", "05"), line("z", "20")],
context: [],
...extra,
} as unknown as Project;
}
const visible = new Set(["05", "06", "20"]);
const opacities = (p: Project, underlay: boolean, forPrint = false) => {
const prims = generatePlan(p, "eg", visible, undefined, "mittel", false, false, true, undefined, forPrint, false, null, null, null, underlay).primitives;
const by = (id: string) => prims.find((q) => q.kind === "line" && q.drawingId === id) as { opacity?: number } | undefined;
return { kontext: by("k")?.opacity ?? 1, zeichnung: by("z")?.opacity ?? 1 };
};
describe("[285] Kontext-Klassen als Unterlage", () => {
it("Arbeitsgrundriss: Kontext halbtransparent, eigene Zeichnung deckend", () => {
const o = opacities(project(), true);
expect(o.kontext).toBeLessThan(0.6);
expect(o.zeichnung).toBe(1);
});
it("ohne Schalter (CLI/Export) und im Druck deckend", () => {
expect(opacities(project(), false).kontext).toBe(1);
expect(opacities(project(), true, true).kontext).toBe(1);
});
it("Klasse ausdrücklich ein-/ausschalten", () => {
const layers = [
{ code: "05", name: "Kontext", color: "#707078", lw: 0.13, visible: true, locked: false, underlay: false },
{ code: "20", name: "Zeichnung", color: "#0a0a0a", lw: 0.5, visible: true, locked: false, underlay: true },
];
const o = opacities(project({ layers }), true);
expect(o.kontext).toBe(1);
expect(o.zeichnung).toBeLessThan(0.6);
});
it("Vorgabe im Editor: Kontext-Kinder an, andere aus", () => {
const p = project();
expect(isUnderlayCategory(p.layers, "06")).toBe(true);
expect(isUnderlayCategory(p.layers, "20")).toBe(false);
});
});
+18 -6
View File
@@ -271,6 +271,11 @@ export function generatePlan(
* `grey` alles ausserhalb grau (Kern `renovation::View::editing`). Nie im Druck/Export (dort fehlt sie).
*/
designOptionEdit?: DesignOptionEditArg | null,
/**
* [285] Arbeitsgrundriss (Bildschirm): Klassen „als Unterlage" (`LayerCategory.underlay`, vorgegeben die Umgebungsklassen:
* Kataster, Strassen, Gelände …) halbtransparent, damit Wände darüber lesbar bleiben. Nie im Druck/Export (dort fehlt es).
*/
contextUnderlay = false,
): Plan {
const compact = compactUnderlay && !forPrint;
// Blatt-Ebene eines Layouts (Papier 1:1): ohne projektglobale Zutaten (Kontext, Luftbilder,
@@ -286,7 +291,7 @@ export function generatePlan(
// Zeitpunkt der Schattenstudie: `Date` nimmt das Datum, wie es in der Datei steht (Ortszeit ohne Zone).
const study = project.sunStudy;
const sunWhen = includeGlobal && study?.show ? new Date(study.when).getTime() : NaN;
const dom = planDomains(project, floorId, visibleCodes, categoryDisplay, detail, showReferenceLines, includeGlobal, scaleDenominator, forPrint, compact, mono, sunWhen, overrideRuleIds, traceOf, forPrint ? null : designOptionEdit);
const dom = planDomains(project, floorId, visibleCodes, categoryDisplay, detail, showReferenceLines, includeGlobal, scaleDenominator, forPrint, compact, mono, sunWhen, overrideRuleIds, traceOf, forPrint ? null : designOptionEdit, contextUnderlay && !forPrint);
const pieces: PlanPiece[] = [];
const pushGroups = (first: number, last: number): void => {
const from = dom.buf.groups[first][0];
@@ -369,6 +374,8 @@ export function generateVisibleLevelsPlan(
compactUnderlay = false,
/** [272] Bearbeitungsvariante der Bildschirm-Ansicht (s. {@link generatePlan}). */
designOptionEdit?: DesignOptionEditArg | null,
/** [285] Klassen „als Unterlage" halbtransparent (s. {@link generatePlan}) — nur die aktive Ebene. */
contextUnderlay = false,
): Plan {
const active = project.drawingLevels.find((l) => l.id === activeLevelId);
const siblings =
@@ -451,6 +458,7 @@ export function generateVisibleLevelsPlan(
null,
null,
designOptionEdit,
contextUnderlay,
);
const activeCount = planCount(activePlan);
for (const pc of piecesOf(activePlan)) pieces.push(pc);
@@ -522,6 +530,7 @@ function planDomainsArgs(
rules?: readonly string[] | null,
traceOf?: string | null,
designOptionEdit?: DesignOptionEditArg | null,
contextUnderlay = false,
): Record<string, unknown> {
// Sichtbar und gezeichnet bzw. gedimmt: über die sichtbaren Codes (wenige), nicht über alle
// Elemente — der Kern zeichnet ein Element genau dann, wenn sein Code in `show` steht.
@@ -537,6 +546,7 @@ function planDomainsArgs(
if (rules) out.rules = [...rules];
if (traceOf) out.traceOf = traceOf;
if (designOptionEdit) out.designOptionEdit = designOptionEdit;
if (contextUnderlay) out.contextUnderlay = true;
return out;
}
@@ -593,8 +603,9 @@ function planDomains(
rules?: readonly string[] | null,
traceOf?: string | null,
designOptionEdit?: DesignOptionEditArg | null,
contextUnderlay = false,
): DomainPrims {
const args = JSON.stringify(planDomainsArgs(floorId, visibleCodes, categoryDisplay, referenceLines, global, scale, forPrint, compact, mono, sunWhen, rules, traceOf, designOptionEdit));
const args = JSON.stringify(planDomainsArgs(floorId, visibleCodes, categoryDisplay, referenceLines, global, scale, forPrint, compact, mono, sunWhen, rules, traceOf, designOptionEdit, contextUnderlay));
const held = chunkStores.get(args);
const query = held && held.size ? `${args.slice(0, -1)},"have":[${[...held.keys()].join(",")}]}` : args;
const res = readPlanMulti(documentFor(project).queryBin("planDomains", [DETAIL_CODE[detail] ?? 1], query), held);
@@ -669,21 +680,22 @@ function underlayGroups(project: Project, dom: DomainPrims, scaleDenominator: nu
const out: UnderlayGroup[] = [];
let k = 1;
for (let g = 0; g < f[0]; g++) {
const catGreyed = f[k] === 1;
const catGreyed = (f[k] & 1) === 1;
const asUnderlay = (f[k] & 2) === 2;
const n = f[k + 1];
const drawings: Drawing2D[] = new Array(n);
for (let i = 0; i < n; i++) drawings[i] = all[f[k + 2 + i]];
k += 2 + n;
const buildBuf = (list: Drawing2D[]): DecodedPlanBuf => {
// Schalter: Bit 1 = gedimmt, Bit 2 = Schwarz-Weiss ([140]).
const args = [scaleDenominator, (catGreyed ? 1 : 0) + (mono ? 2 : 0)];
// Schalter: Bit 1 = gedimmt, Bit 2 = Schwarz-Weiss ([140]), Bit 3 = Klasse als Unterlage ([285]).
const args = [scaleDenominator, (catGreyed ? 1 : 0) + (mono ? 2 : 0) + (asUnderlay ? 4 : 0)];
for (const d of list) {
const i = indexOf(d);
if (i !== undefined) args.push(i);
}
return decodePlanBuf(documentFor(project).queryBin("drawingLines", args));
};
out.push({ drawings, catGreyed, tint: false, above: true, ctx, build: (list) => buildBuf(list).prims, buildBuf });
out.push({ drawings, catGreyed, tint: false, above: true, ctx: asUnderlay ? [...ctx, "underlay"] : ctx, build: (list) => buildBuf(list).prims, buildBuf });
}
return out;
}
+2
View File
@@ -809,6 +809,8 @@ function LevelPlanView({
true,
// [272] Bearbeitungsvariante (Stift): sichtbar, ausserhalb grau — nur hier, nie im Druck.
designOptionEdit,
// [285] Kataster/Kontext halbtransparent als Unterlage (nur Bildschirm, nie Druck).
true,
);
// Überlagerung anhängen, ohne die Primitive des Plans zu lesen (lazy, [K3d]).
const withOverlay = overlayPrimitives.length === 0 ? p : planWithExtra(p, [], overlayPrimitives);