[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:
21 files changed
+220
-20
No files matched your search
@@ -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);
|
||||
});
|
||||
});
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user