From a5dc7a85e38407a7662989306f715d60e865100f Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 01:34:47 +0000 Subject: [PATCH] [146] Linienenden und -ecken einstellbar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Projekt-Einstellung lineCap/lineJoin (Standard flach + Gehrung, Grenze 4) in allen Ausgabewegen: render2d, Metal-Chunks (gpu_compile), Plan-SVG, Druck-SVG/PDF, React-SVG-Ansicht. Volle Einzel-Linien und Kantenläufe werden an gemeinsamen Enden zu Zügen genäht (keine Kerbe an Wandecken). UI in den Einstellungen (Projekt), Goldens neu. --- TODO.md | 23 +++ src/App.tsx | 11 ++ src/cli/__golden__/ansicht.svg | 123 ++++++------ src/cli/__golden__/grundriss-eg.svg | 183 ++++++++---------- src/cli/__golden__/schnitt.svg | 151 ++++++--------- src/core/extra.ts | 3 + src/export/planToPrintSvg.ts | 6 + src/export/planToSvgString.ts | 4 +- src/export/sceneToPrintSvg.ts | 9 +- src/i18n/de.ts | 9 + src/i18n/en.ts | 9 + src/model/lineEnds.ts | 6 + src/native/SettingsWindowApp.tsx | 2 + src/native/settingsWindow.ts | 4 + .../komplex-ansicht-ansicht-sued.txt | 10 +- .../__golden__/komplex-grundriss-dg-100.txt | 9 +- .../__golden__/komplex-grundriss-dg-50.txt | 9 +- .../__golden__/komplex-grundriss-eg-100.txt | 12 +- .../__golden__/komplex-grundriss-eg-50.txt | 12 +- .../__golden__/komplex-grundriss-og-100.txt | 12 +- .../__golden__/komplex-grundriss-og-50.txt | 12 +- .../__golden__/komplex-grundriss-ug-100.txt | 12 +- .../__golden__/komplex-grundriss-ug-50.txt | 12 +- .../__golden__/komplex-schnitt-schnitt-a.txt | 10 +- .../muster-ansicht-ansicht-sued.txt | 10 +- .../__golden__/muster-grundriss-eg-100.txt | 11 +- .../__golden__/muster-grundriss-eg-50.txt | 11 +- .../__golden__/muster-grundriss-og-100.txt | 11 +- .../__golden__/muster-grundriss-og-50.txt | 11 +- .../__golden__/muster-schnitt-schnitt-a.txt | 10 +- src/plan/generatePlan.ts | 9 +- src/plan/glPlan/glPlanChunks.ts | 11 ++ src/plan/glPlan/glPlanCompile.test.ts | 8 +- src/plan/glPlan/glPlanCompile.ts | 7 +- src/plan/glPlan/glPlanTypes.ts | 5 + src/plan/lineEnds.test.ts | 74 +++++++ src/plan/planBuf.test.ts | 16 +- src/plan/toElevation.ts | 3 +- src/plan/toRenderScene.test.ts | 5 +- src/plan/toRenderScene.ts | 6 +- src/plan/toSection.ts | 3 +- src/styles.css | 13 +- src/ui/SettingsDialog.tsx | 39 ++++ src/views/plan/PlanView.tsx | 4 + src/views/plan/useNativePlanRenderer.ts | 1 + 45 files changed, 558 insertions(+), 363 deletions(-) create mode 100644 src/plan/lineEnds.test.ts diff --git a/TODO.md b/TODO.md index a520f725..74eb7a68 100644 --- a/TODO.md +++ b/TODO.md @@ -2821,6 +2821,29 @@ Format · [90] Versionsvergleich · [91] Assistent · [92] Speckle. vorher 16/18 Frames hinterher, nachher 0. Nur im Linux-Container (Chromium) geprüft, NICHT in der Tauri-App/Metal: ob Metal-Present und Webview-Commit dort im selben vsync landen, muss der Mac zeigen. Offen, falls es dort noch nachläuft: Raumstempel nativ zeichnen (vtext kann bisher nur einzeilig/linksbündig, eine Schrift, kein Fett). +- ◐ **[146] Linienenden und -ecken einstellbar.** (6.11., Maintainer: „Manche Linienenden sind rund, manche eckig. + Globale Einstellung.") Bestand vorher: render2d (WebGPU-Szene) und Kern `gpu_compile` (Metal-Chunks) zeichneten volle + Striche mit runden Kappen/Ecken, Strich-Shader runde Strichenden, Bögen (SDF) flach; Plan-SVG rund nur bei vollen + Linien/Kantenläufen ([141]), Polygone `linejoin=round`; Druck-SVG (`print_svg.rs`, `sceneToPrintSvg.ts`) rund; React-SVG + über CSS `linecap: round`, `miterlimit 8`. Neu: Projekt-Felder `lineCap` (`butt`/`round`/`square`) und `lineJoin` + (`miter`/`round`/`bevel`), fehlt = flach + Gehrung (Grenze 4, darüber gefast); Kodierung `cap | join << 2` + (`plan/line_ends.rs`, `model/lineEnds.ts`), reist als `Plan.lineEnds` (generatePlan/Schnitt/Ansicht). Wirkt in: + render2d (Gehrungs-/Fasen-Dreiecke, vorstehende Kappe; Szenenkopf-Wort 44 statt Reserve-0; Strich-Shader `count + 16·cap`, + innere Ecken gestrichelter Züge bleiben rund; Bogen-Kappe in `wdash.w`), `gpu_compile` (gleich; gepacktes Miter-Byte jetzt + `(m−1)/3`, Byte 0 = 1, `chunks.rs` dekodiert; Chunk-Cache verwirft bei Wechsel), Plan-SVG (`` mit den Attributen), + Druck-SVG/PDF (Attribute am ``), React-SVG-Ansicht (``, CSS `inherit`). Punkt-Muster bleiben überall rund ([96]). + Kerben an Wandecken: volle Einzel-Linien und Kantenläufe gleicher Farbe/Breite(/Deckkraft) werden an Enden, an denen + genau zwei zusammentreffen, zu Zügen genäht (`stitch_runs_members`; Szene, `gpu_compile` bis zum nächsten Strich-Muster, + Plan-SVG, Druck-SVG), ein Zug steht an der Stelle seines spätesten Teils. UI: Einstellungen → Projekt („Linienenden", + „Linienecken"), beide Felder ein Undo-Schritt. Tests: Rust `line_ends` (Kodierung), render2d (`flach_mit_gehrung_ist_standard`, + `spitzer_winkel_ueber_gehrungsgrenze_wird_gefast`, `vorstehende_und_runde_kappen`, `strich_instanzen_tragen_die_kappe`, + `linienenden_im_kopf`), Kern (`ecke_aus_zwei_linien_wird_ein_zug_mit_gehrung`, `umriss_ecke_als_zug`), vitest + `plan/lineEnds.test.ts`. Goldens neu (Plan/Schnitt/Ansicht + CLI: `` mit Attributen, genähte `` statt + Einzel-``/``, keine `linecap=round` mehr; Komplex-EG 1:50 mit Schraffur 4.95 → 1.05 MB, v. a. Höhenlinien). + Geprüft: cargo test Kern + render2d, WASM gebaut (Linux, `--no-opt`), tsc, vitest, CLI-SVG vorher/nachher in Chromium + (Ecke, T-Stoss, Tür, Masslinie). **Offen:** DXF/DWG ohne Einstellung (acadrust schreibt `$ENDCAPS/$JOINSTYLE` nur in DWG; + CAD zeichnet Stiftbreiten selbst); Druck-SVG streicht Polygone weiter rundum (keine `noStrokeEdges`); Nähen in den + Metal-Chunks nur innerhalb eines Chunks; nicht in der Tauri-App/Metal und nicht im WebGPU-Browser angesehen. · M - ◐ **[68] Baugrube / Geländebearbeitung.** (30.10.) Kontext-Objekt `excavation` (Rust-Modell, `ContextObject`): Sohle (`outline`, `bottom` m ±0.00), Böschung `slope` (Standard 45°, je Kante `edgeSlopes`), Schüttung `fillSlope` (33.7°), Bermen `bermWidth`/`bermHeight`. Neues Gelände = clamp(t, b − d·tan β, b + H(d)) mit d = Abstand zum diff --git a/src/App.tsx b/src/App.tsx index 5ccd36fa..f47557f6 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -29,6 +29,7 @@ import type { } from "./model/types"; import { generatePlan, computeKennzahlen, checkRoomProgram } from "./core"; import { addedItems } from "./core"; +import { lineEndsOf, type LineEnds } from "./core"; import { programStatusLabel } from "./panels/KennzahlenSection"; import { sectionPlaneFromLevel, sectionUAxisModel } from "./core"; import { setDxfImportTrigger } from "./io/dxfImportHook"; @@ -1634,6 +1635,12 @@ export default function App() { // Befehle auf die echten Setter an (siehe native/settingsWindow.ts). const setScaleLineWeights = (on: boolean) => applyChange((p) => setFieldIfChanged(p, "scaleLineWeights", on ? true : undefined)); + // [146] Linienenden/-ecken: Standard (flach, Gehrung) = Feld weglassen; beide Felder ein Undo-Schritt. + const setLineEnds = (e: LineEnds) => + groupChanges(() => { + applyChange((p) => setFieldIfChanged(p, "lineCap", e.cap === "butt" ? undefined : e.cap)); + applyChange((p) => setFieldIfChanged(p, "lineJoin", e.join === "miter" ? undefined : e.join)); + }); useSettingsWindowHost( { themeMode, @@ -1641,6 +1648,7 @@ export default function App() { snapColor, referenceElevationMasl: project.referenceElevationMasl, scaleLineWeights: project.scaleLineWeights === true, + lineEnds: lineEndsOf(project), offline, aiAccess, layout, @@ -1651,6 +1659,7 @@ export default function App() { onSnapColorChange: setSnapColor, onReferenceElevationChange: (n) => applyChange((p) => setFieldIfChanged(p, "referenceElevationMasl", n)), onScaleLineWeightsChange: setScaleLineWeights, + onLineEndsChange: setLineEnds, onOfflineChange, onAiAccessChange: setAiAccessEnabled, onApplyLayout: (l) => setLayout(reconcileLayout(l)), @@ -2728,6 +2737,8 @@ export default function App() { onReferenceElevationChange={(n) => applyChange((p) => setFieldIfChanged(p, "referenceElevationMasl", n))} scaleLineWeights={project.scaleLineWeights === true} onScaleLineWeightsChange={setScaleLineWeights} + lineEnds={lineEndsOf(project)} + onLineEndsChange={setLineEnds} offline={offline} onOfflineChange={onOfflineChange} aiAccess={aiAccess} diff --git a/src/cli/__golden__/ansicht.svg b/src/cli/__golden__/ansicht.svg index 3aff1d35..81a1e9d2 100644 --- a/src/cli/__golden__/ansicht.svg +++ b/src/cli/__golden__/ansicht.svg @@ -1,77 +1,62 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/src/cli/__golden__/grundriss-eg.svg b/src/cli/__golden__/grundriss-eg.svg index 29bf5155..1a595688 100644 --- a/src/cli/__golden__/grundriss-eg.svg +++ b/src/cli/__golden__/grundriss-eg.svg @@ -1,129 +1,116 @@ - - + + + Wohnen 17.01 m² HNF · Hauptnutzfläche - - - - - + + + + - - - - - - - + + + + + + - - - - - - - - + + + + + - - - - - - + + + + - - - - - - + + + + + - - - - - - - + + + + + + - - - - - - - - + + + + + - - - - + + + + - - - - - - - - - - - - + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - - - - - - + + + + + + - - - - + + + A - - - - + + + A - + - - - - + + + Süd - - - - + + + Süd - + + diff --git a/src/cli/__golden__/schnitt.svg b/src/cli/__golden__/schnitt.svg index e530ab09..5e6cce72 100644 --- a/src/cli/__golden__/schnitt.svg +++ b/src/cli/__golden__/schnitt.svg @@ -1,94 +1,65 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/core/extra.ts b/src/core/extra.ts index 22fc5fc4..59394696 100644 --- a/src/core/extra.ts +++ b/src/core/extra.ts @@ -84,3 +84,6 @@ export { callAiTool } from "./aiTools"; export type { AiHost } from "./aiTools"; export { PRESENTATION_TEMPLATE_ID, presentationDefaults, presentationSheetOps, planPresentationSheet } from "../plan/presentationSheet"; export type { PresentationOptions, PresentationPlan, PresentationLabels } from "../plan/presentationSheet"; +export { lineEndsOf, lineEndsCode, lineEndsFromCode, lineEndsSvgAttrs, planLineEndsProps, MITER_LIMIT as LINE_MITER_LIMIT } from "../model/lineEnds"; +export type { LineEnds } from "../model/lineEnds"; +export type { LineCap, LineJoin } from "../model/types"; diff --git a/src/export/planToPrintSvg.ts b/src/export/planToPrintSvg.ts index b2ea8179..ab11c561 100644 --- a/src/export/planToPrintSvg.ts +++ b/src/export/planToPrintSvg.ts @@ -28,6 +28,7 @@ import type { HatchRender, Plan } from "../plan/generatePlan"; import { core } from "../engine/coreWasm"; +import { lineEndsSvgAttrs } from "../model/lineEnds"; import { planParts, withPlanParts } from "../plan/planParts"; /** SVG-Namespace für die programmatisch erzeugten Knoten. */ @@ -107,6 +108,8 @@ export interface PrintSvgOptions { bounds?: { minX: number; minY: number; maxX: number; maxY: number }; /** Ohne weisses Blatt dahinter (als Schicht über anderem Inhalt). */ transparent?: boolean; + /** Linienenden und -ecken ([146], `cap | join << 2`); Standard `plan.lineEnds`. */ + lineEnds?: number; } /** Modell-Meter → Papier-Millimeter im Massstab 1:N. */ @@ -150,6 +153,9 @@ export function planToPrintSvg(plan: Plan, opts: PrintSvgOptions): PrintSvg { svg.setAttribute("width", String(opts.pageWidthMm)); svg.setAttribute("height", String(opts.pageHeightMm)); svg.setAttribute("viewBox", `0 0 ${opts.pageWidthMm} ${opts.pageHeightMm}`); + // Linienenden und -ecken des Projekts ([146]): einmal am Wurzelelement, alle Striche erben sie + // (der Kern setzt nur bei Punkt-Mustern eine eigene runde Kappe). + for (const [k, v] of Object.entries(lineEndsSvgAttrs(opts.lineEnds ?? plan.lineEnds))) svg.setAttribute(k, v); // Weisses Blatt (deckt die volle Seite). const bg = document.createElementNS(SVG_NS, "rect"); diff --git a/src/export/planToSvgString.ts b/src/export/planToSvgString.ts index cf4181e2..2029ef69 100644 --- a/src/export/planToSvgString.ts +++ b/src/export/planToSvgString.ts @@ -16,10 +16,12 @@ export interface SvgStringOptions { marginM?: number; /** Schraffurlinien ausbreiten (wie im Druck); Standard aus. */ hatch?: boolean; + /** Linienenden und -ecken ([146], `cap | join << 2`); Standard `plan.lineEnds`. */ + lineEnds?: number; } export function planToSvgString(plan: Plan, opts: SvgStringOptions = {}): string { const b = plan.bounds; - const o = Float64Array.from([opts.scaleDenominator ?? 100, opts.marginM ?? 0.5, b.minX, b.minY, b.maxX, b.maxY, ...(opts.hatch ? [1] : [])]); + const o = Float64Array.from([opts.scaleDenominator ?? 100, opts.marginM ?? 0.5, b.minX, b.minY, b.maxX, b.maxY, opts.hatch ? 1 : 0, opts.lineEnds ?? plan.lineEnds ?? 0]); return withPlanParts(planParts(plan, true), (segs) => core().plan_svg_string(segs, o)); } diff --git a/src/export/sceneToPrintSvg.ts b/src/export/sceneToPrintSvg.ts index bdafcb04..737598f6 100644 --- a/src/export/sceneToPrintSvg.ts +++ b/src/export/sceneToPrintSvg.ts @@ -22,6 +22,7 @@ // // Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md). +import { lineEndsSvgAttrs } from "../model/lineEnds"; import type { RArc, RFill, @@ -134,6 +135,8 @@ export function sceneToPrintSvg(scene: RScene, opts: PrintSceneOptions): PrintSc svg.setAttribute("width", String(opts.pageWidthMm)); svg.setAttribute("height", String(opts.pageHeightMm)); svg.setAttribute("viewBox", `0 0 ${opts.pageWidthMm} ${opts.pageHeightMm}`); + // Linienenden und -ecken des Projekts ([146]): einmal am Wurzelelement, alle Striche erben sie. + for (const [k, v] of Object.entries(lineEndsSvgAttrs(scene.lineEnds))) svg.setAttribute(k, v); const bg = document.createElementNS(SVG_NS, "rect"); bg.setAttribute("x", "0"); @@ -269,12 +272,12 @@ function appendStroke( el.setAttribute("stroke", rgbCss(color)); setOpacityAttr(el, "stroke-opacity", color[3]); el.setAttribute("stroke-width", String(strokeMm)); - el.setAttribute("stroke-linejoin", "round"); - el.setAttribute("stroke-linecap", "round"); if (dash && dash.length) { // Strichmuster ist bereits in Papier-mm definiert (siehe `toRenderScene.ts`: // „unveraendert durchgereicht"), also direkt uebernehmen. el.setAttribute("stroke-dasharray", dash.map((d) => round(d)).join(" ")); + // Punkte (Strich 0) brauchen runde Enden, sonst unsichtbar ([96]). + if (dash.some((d) => d === 0)) el.setAttribute("stroke-linecap", "round"); } svg.appendChild(el); } @@ -292,9 +295,9 @@ function appendLine(svg: SVGSVGElement, l: RLine, map: Mapper, _mmPerM: number): el.setAttribute("stroke", rgbCss(l.color)); setOpacityAttr(el, "stroke-opacity", l.color[3]); el.setAttribute("stroke-width", String(quantizePen(l.widthMm))); - el.setAttribute("stroke-linecap", "round"); if (l.dash && l.dash.length) { el.setAttribute("stroke-dasharray", l.dash.map((d) => round(d)).join(" ")); + if (l.dash.some((d) => d === 0)) el.setAttribute("stroke-linecap", "round"); } svg.appendChild(el); } diff --git a/src/i18n/de.ts b/src/i18n/de.ts index 519996b6..e244eb20 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -2647,6 +2647,15 @@ export const de = { "settings.referenceElevation": "Höhe ±0.00 (m ü. M.)", "settings.referenceElevation.hint": "OK fertig Boden des Bezugsgeschosses (±0.00) über Meer; erscheint in Schnitten und Ansichten an der Kote ±0.00.", + "settings.lineCap": "Linienenden", + "settings.lineCap.butt": "Flach", + "settings.lineCap.round": "Rund", + "settings.lineCap.square": "Vorstehend (eckig)", + "settings.lineJoin": "Linienecken", + "settings.lineJoin.miter": "Gehrung (spitz)", + "settings.lineJoin.round": "Rund", + "settings.lineJoin.bevel": "Gefast", + "settings.lineEnds.hint": "Gilt für alle Striche im Grundriss, Schnitt und in der Ansicht – am Bildschirm, in Layouts, im Druck/PDF und im SVG-Export. Sehr spitze Ecken werden gefast (Gehrungsgrenze 4).", "settings.scaleLineWeights": "Strichstärken nach Massstab", "settings.scaleLineWeights.hint": "Grundriss-Strichstärken werden mit (100/n)^¼ skaliert: 1:200 ≈ 84 %, 1:50 ≈ 119 %. Gilt am Bildschirm, in Layouts und im Export.", "settings.section.shortcuts": "Befehlszeilen-Kürzel (Tipp-Alias)", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index c9cd4b2f..70d88606 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -2634,6 +2634,15 @@ export const en: Record = { "settings.referenceElevation": "Elevation of ±0.00 (m a.s.l.)", "settings.referenceElevation.hint": "Finished floor of the datum storey (±0.00) above sea level; shown in sections and elevations at the ±0.00 level mark.", + "settings.lineCap": "Line ends", + "settings.lineCap.butt": "Flat", + "settings.lineCap.round": "Round", + "settings.lineCap.square": "Projecting (square)", + "settings.lineJoin": "Line corners", + "settings.lineJoin.miter": "Miter (sharp)", + "settings.lineJoin.round": "Round", + "settings.lineJoin.bevel": "Bevel", + "settings.lineEnds.hint": "Applies to all strokes in plans, sections and elevations – on screen, in layouts, print/PDF and SVG export. Very sharp corners are bevelled (miter limit 4).", "settings.scaleLineWeights": "Line weights by scale", "settings.scaleLineWeights.hint": "Plan line weights are scaled by (100/n)^¼: 1:200 ≈ 84 %, 1:50 ≈ 119 %. Applies on screen, in layouts and exports.", "settings.section.shortcuts": "Command-line shortcuts (typed alias)", diff --git a/src/model/lineEnds.ts b/src/model/lineEnds.ts index a6e702cd..083f491b 100644 --- a/src/model/lineEnds.ts +++ b/src/model/lineEnds.ts @@ -39,3 +39,9 @@ export function lineEndsSvgAttrs(code: number | undefined): Record<"stroke-linec const e = lineEndsFromCode(code); return { "stroke-linecap": e.cap, "stroke-linejoin": e.join, "stroke-miterlimit": String(MITER_LIMIT) }; } + +/** Wie {@link lineEndsSvgAttrs} als React-SVG-Eigenschaften (PlanView-Gruppe der Plan-Striche). */ +export function planLineEndsProps(code: number | undefined): { strokeLinecap: LineCap; strokeLinejoin: LineJoin; strokeMiterlimit: number } { + const e = lineEndsFromCode(code); + return { strokeLinecap: e.cap, strokeLinejoin: e.join, strokeMiterlimit: MITER_LIMIT }; +} diff --git a/src/native/SettingsWindowApp.tsx b/src/native/SettingsWindowApp.tsx index 8fe99b87..af59eeff 100644 --- a/src/native/SettingsWindowApp.tsx +++ b/src/native/SettingsWindowApp.tsx @@ -95,6 +95,8 @@ export function SettingsWindowApp() { onReferenceElevationChange={handlers.onReferenceElevationChange} scaleLineWeights={state.scaleLineWeights} onScaleLineWeightsChange={handlers.onScaleLineWeightsChange} + lineEnds={state.lineEnds} + onLineEndsChange={handlers.onLineEndsChange} offline={state.offline} onOfflineChange={handlers.onOfflineChange} aiAccess={state.aiAccess} diff --git a/src/native/settingsWindow.ts b/src/native/settingsWindow.ts index f3b206f9..50ea2762 100644 --- a/src/native/settingsWindow.ts +++ b/src/native/settingsWindow.ts @@ -12,6 +12,7 @@ // // Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md). +import type { LineEnds } from "../core"; import type { AiAccessView } from "../ui/AiAccessSection"; import type { LayoutState } from "../panels/types"; import type { ThemeMode } from "../theme/themeMode"; @@ -27,6 +28,8 @@ export interface SettingsSyncState { snapColor: string; referenceElevationMasl: number | undefined; scaleLineWeights: boolean; + /** Projekt-Option: Linienenden und -ecken ([146]). */ + lineEnds: LineEnds; offline: boolean; /** [9] KI-Zugriff (Schalter, Sitzungsschlüssel, Stand). */ aiAccess: AiAccessView; @@ -40,6 +43,7 @@ export interface SettingsCommandHandlers { onSnapColorChange: (hex: string) => void; onReferenceElevationChange: (n: number | undefined) => void; onScaleLineWeightsChange: (on: boolean) => void; + onLineEndsChange: (ends: LineEnds) => void; onOfflineChange: (offline: boolean) => void; onAiAccessChange: (on: boolean) => void; onApplyLayout: (layout: LayoutState) => void; diff --git a/src/plan/__golden__/komplex-ansicht-ansicht-sued.txt b/src/plan/__golden__/komplex-ansicht-ansicht-sued.txt index 4ae17af0..680eab98 100644 --- a/src/plan/__golden__/komplex-ansicht-ansicht-sued.txt +++ b/src/plan/__golden__/komplex-ansicht-ansicht-sued.txt @@ -1,9 +1,11 @@ viewBox -4.2 0 37.045 17.778 -bytes 375391 +bytes 265283 circle 4 -line 1272 -polygon 1541 +g 1 +line 615 +polygon 1555 +polyline 68 rect 1 svg 1 text 4 -hash ba128fc3cd96941c +hash 18d42b37d5c973f7 diff --git a/src/plan/__golden__/komplex-grundriss-dg-100.txt b/src/plan/__golden__/komplex-grundriss-dg-100.txt index c5de23ad..b7ded20d 100644 --- a/src/plan/__golden__/komplex-grundriss-dg-100.txt +++ b/src/plan/__golden__/komplex-grundriss-dg-100.txt @@ -1,10 +1,11 @@ viewBox -4 0 23 18 -bytes 408672 +bytes 317361 circle 14 -line 3444 -path 7 +g 1 +line 3227 polygon 75 +polyline 73 rect 1 svg 1 text 36 -hash e873dd1daa6ea113 +hash b639c8605f1c4c9d diff --git a/src/plan/__golden__/komplex-grundriss-dg-50.txt b/src/plan/__golden__/komplex-grundriss-dg-50.txt index 1becb0ee..9640bf2e 100644 --- a/src/plan/__golden__/komplex-grundriss-dg-50.txt +++ b/src/plan/__golden__/komplex-grundriss-dg-50.txt @@ -1,10 +1,11 @@ viewBox -4 0 23 18 -bytes 416589 +bytes 323049 circle 14 -line 3484 -path 7 +g 1 +line 3240 polygon 75 +polyline 84 rect 1 svg 1 text 36 -hash 10e9a3b43fd5705a +hash 67469479cfe01b3d diff --git a/src/plan/__golden__/komplex-grundriss-eg-100.txt b/src/plan/__golden__/komplex-grundriss-eg-100.txt index 3979d86a..b39ffeb0 100644 --- a/src/plan/__golden__/komplex-grundriss-eg-100.txt +++ b/src/plan/__golden__/komplex-grundriss-eg-100.txt @@ -1,10 +1,12 @@ viewBox -41.5 0 95 63.6 -bytes 154702 +bytes 109717 circle 16 -line 742 -path 63 -polygon 256 +g 1 +line 338 +path 39 +polygon 259 +polyline 126 rect 1 svg 1 text 121 -hash 31eb0ce63a3514ff +hash 6872e879c06f7f46 diff --git a/src/plan/__golden__/komplex-grundriss-eg-50.txt b/src/plan/__golden__/komplex-grundriss-eg-50.txt index 4709bdf3..3bc169d5 100644 --- a/src/plan/__golden__/komplex-grundriss-eg-50.txt +++ b/src/plan/__golden__/komplex-grundriss-eg-50.txt @@ -1,10 +1,12 @@ viewBox -41.5 0 95 63.6 -bytes 165876 +bytes 114546 circle 16 -line 834 -path 69 -polygon 256 +g 1 +line 349 +path 45 +polygon 259 +polyline 151 rect 1 svg 1 text 121 -hash a9e2d4dd24b3f54c +hash 49fa5877b4a27a36 diff --git a/src/plan/__golden__/komplex-grundriss-og-100.txt b/src/plan/__golden__/komplex-grundriss-og-100.txt index 29301995..66d8e2e0 100644 --- a/src/plan/__golden__/komplex-grundriss-og-100.txt +++ b/src/plan/__golden__/komplex-grundriss-og-100.txt @@ -1,10 +1,12 @@ viewBox -4.055 0 25.109 23.11 -bytes 494072 +bytes 366491 circle 14 -line 3915 -path 36 -polygon 226 +g 1 +line 3333 +path 21 +polygon 227 +polyline 169 rect 1 svg 1 text 91 -hash 3a01d6133c531e3d +hash 48bd54ad5e8b1c20 diff --git a/src/plan/__golden__/komplex-grundriss-og-50.txt b/src/plan/__golden__/komplex-grundriss-og-50.txt index ba4f8266..880d2837 100644 --- a/src/plan/__golden__/komplex-grundriss-og-50.txt +++ b/src/plan/__golden__/komplex-grundriss-og-50.txt @@ -1,10 +1,12 @@ viewBox -4.055 0 25.109 23.11 -bytes 507906 +bytes 374934 circle 14 -line 4002 -path 42 -polygon 226 +g 1 +line 3350 +path 27 +polygon 227 +polyline 195 rect 1 svg 1 text 91 -hash 50c683de7aeef5d0 +hash 7bd001e733642672 diff --git a/src/plan/__golden__/komplex-grundriss-ug-100.txt b/src/plan/__golden__/komplex-grundriss-ug-100.txt index 3cb16b53..15497bb5 100644 --- a/src/plan/__golden__/komplex-grundriss-ug-100.txt +++ b/src/plan/__golden__/komplex-grundriss-ug-100.txt @@ -1,10 +1,12 @@ viewBox -10.004 0 31.058 26.958 -bytes 90451 +bytes 61153 circle 14 -line 466 -path 28 -polygon 103 +g 1 +line 171 +path 13 +polygon 105 +polyline 77 rect 1 svg 1 text 75 -hash 3dae77c418383e16 +hash d31704c307ac309d diff --git a/src/plan/__golden__/komplex-grundriss-ug-50.txt b/src/plan/__golden__/komplex-grundriss-ug-50.txt index dbe471d1..bb058b7e 100644 --- a/src/plan/__golden__/komplex-grundriss-ug-50.txt +++ b/src/plan/__golden__/komplex-grundriss-ug-50.txt @@ -1,10 +1,12 @@ viewBox -10.004 0 31.058 26.958 -bytes 91807 +bytes 62007 circle 14 -line 475 -path 30 -polygon 103 +g 1 +line 173 +path 15 +polygon 105 +polyline 80 rect 1 svg 1 text 75 -hash 45fabe68cc29824d +hash eba7b491c822b768 diff --git a/src/plan/__golden__/komplex-schnitt-schnitt-a.txt b/src/plan/__golden__/komplex-schnitt-schnitt-a.txt index 4598e3eb..44e07947 100644 --- a/src/plan/__golden__/komplex-schnitt-schnitt-a.txt +++ b/src/plan/__golden__/komplex-schnitt-schnitt-a.txt @@ -1,9 +1,11 @@ viewBox 4.457 0 21.343 17.778 -bytes 72287 +bytes 41694 circle 3 -line 376 -polygon 168 +g 1 +line 96 +polygon 186 +polyline 13 rect 1 svg 1 text 3 -hash 20b9f7ab702f9ed7 +hash 471491b0c51f190a diff --git a/src/plan/__golden__/muster-ansicht-ansicht-sued.txt b/src/plan/__golden__/muster-ansicht-ansicht-sued.txt index 45bdf02f..04a5230b 100644 --- a/src/plan/__golden__/muster-ansicht-ansicht-sued.txt +++ b/src/plan/__golden__/muster-ansicht-ansicht-sued.txt @@ -1,7 +1,9 @@ viewBox 0.1 0 6.8 7.586 -bytes 9105 -line 31 -polygon 42 +bytes 6297 +g 1 +line 7 +polygon 43 +polyline 6 rect 1 svg 1 -hash 8989d8c3eda53c4f +hash 965767e4ac42c4f0 diff --git a/src/plan/__golden__/muster-grundriss-eg-100.txt b/src/plan/__golden__/muster-grundriss-eg-100.txt index 8a74da8a..4ea5f9b6 100644 --- a/src/plan/__golden__/muster-grundriss-eg-100.txt +++ b/src/plan/__golden__/muster-grundriss-eg-100.txt @@ -1,9 +1,10 @@ viewBox -0.672 0 6.345 5.345 -bytes 15406 -line 49 -path 8 -polygon 61 +bytes 11826 +g 1 +line 33 +polygon 62 +polyline 8 rect 1 svg 1 text 7 -hash 5ab24b7693923d27 +hash 6d3b7926ca1a3a6d diff --git a/src/plan/__golden__/muster-grundriss-eg-50.txt b/src/plan/__golden__/muster-grundriss-eg-50.txt index 685f9679..ad064cfe 100644 --- a/src/plan/__golden__/muster-grundriss-eg-50.txt +++ b/src/plan/__golden__/muster-grundriss-eg-50.txt @@ -1,9 +1,10 @@ viewBox -0.672 0 6.345 5.345 -bytes 17388 -line 67 -path 8 -polygon 61 +bytes 12491 +g 1 +line 34 +polygon 62 +polyline 13 rect 1 svg 1 text 7 -hash 76655e0c29ed72d2 +hash 7378e595c698986f diff --git a/src/plan/__golden__/muster-grundriss-og-100.txt b/src/plan/__golden__/muster-grundriss-og-100.txt index 49852e51..65fbc77a 100644 --- a/src/plan/__golden__/muster-grundriss-og-100.txt +++ b/src/plan/__golden__/muster-grundriss-og-100.txt @@ -1,9 +1,10 @@ viewBox -0.9 0 6.8 5.8 -bytes 7329 -line 27 -path 4 -polygon 23 +bytes 5572 +g 1 +line 15 +polygon 26 +polyline 4 rect 1 svg 1 text 4 -hash ce46a0be23194084 +hash 97d2aa8ea90eafff diff --git a/src/plan/__golden__/muster-grundriss-og-50.txt b/src/plan/__golden__/muster-grundriss-og-50.txt index 7009363f..88855425 100644 --- a/src/plan/__golden__/muster-grundriss-og-50.txt +++ b/src/plan/__golden__/muster-grundriss-og-50.txt @@ -1,9 +1,10 @@ viewBox -0.9 0 6.8 5.8 -bytes 8243 -line 35 -path 4 -polygon 23 +bytes 5816 +g 1 +line 15 +polygon 28 +polyline 4 rect 1 svg 1 text 4 -hash 1ed106fb31a8203a +hash 7ca726f020333afb diff --git a/src/plan/__golden__/muster-schnitt-schnitt-a.txt b/src/plan/__golden__/muster-schnitt-schnitt-a.txt index a9bf8b35..0aad82ff 100644 --- a/src/plan/__golden__/muster-schnitt-schnitt-a.txt +++ b/src/plan/__golden__/muster-schnitt-schnitt-a.txt @@ -1,7 +1,9 @@ viewBox 0.1 0 6.8 7.586 -bytes 11068 -line 59 -polygon 31 +bytes 6668 +g 1 +line 21 +polygon 34 +polyline 4 rect 1 svg 1 -hash 9f3f228ecf8a3650 +hash 8ce8b71fc217069c diff --git a/src/plan/generatePlan.ts b/src/plan/generatePlan.ts index b927a324..6e492661 100644 --- a/src/plan/generatePlan.ts +++ b/src/plan/generatePlan.ts @@ -25,6 +25,7 @@ import type { Vec2, } from "../model/types"; import { documentFor } from "../core/document"; +import { lineEndsCode } from "../model/lineEnds"; import { registerCoreRestore } from "../engine/coreWasm"; import { decodePlanBuf, type DecodedPlanBuf } from "./planBuf"; import { @@ -86,6 +87,11 @@ export interface Plan { * Verbraucher prüft die Objekt-Identität und fällt sonst auf die Objekte zurück. */ bufRuns?: PlanBufRun[]; + /** + * Linienenden und -ecken des Projekts ([146], `cap | join << 2`, s. `model/lineEnds.ts`); fehlt = 0 + * (flach + Gehrung). Alle Ausgabewege (Szene, GPU-Chunks, Plan-SVG, Druck) lesen es von hier. + */ + lineEnds?: number; } /** `primitives[at + k]` ist (solange nicht ersetzt) `buf.prims[from + k]`, `k < to − from`. */ @@ -288,7 +294,7 @@ export function generatePlan( })); // Ausmass samt Schatten, Baurecht und Kontext (immer gesetzt, ohne Punkte 0,0–1,1). const [minX, minY, maxX, maxY] = dom.buf.bounds ?? [0, 0, 1, 1]; - return lazyPlan({ bounds: { minX, minY, maxX, maxY }, backgroundImages, ...(underlay.length ? { underlay } : {}) }, pieces); + return lazyPlan({ bounds: { minX, minY, maxX, maxY }, backgroundImages, lineEnds: lineEndsCode(project), ...(underlay.length ? { underlay } : {}) }, pieces); } /** @@ -404,6 +410,7 @@ export function generateVisibleLevelsPlan( { bounds, backgroundImages: activePlan.backgroundImages, + lineEnds: lineEndsCode(project), ...(greyedRanges.length ? { greyedRanges } : {}), ...(underlay.length ? { underlay } : {}), }, diff --git a/src/plan/glPlan/glPlanChunks.ts b/src/plan/glPlan/glPlanChunks.ts index 7434e684..ebfd1850 100644 --- a/src/plan/glPlan/glPlanChunks.ts +++ b/src/plan/glPlan/glPlanChunks.ts @@ -299,6 +299,17 @@ export class GpuChunkCache { /** Geometrien in Zeichenreihenfolge (nur bei `update`/`dispose` neu aufgebaut). */ geometries: GpuGeometry[] = []; + /** + * Linienenden und -ecken ([146], `Plan.lineEnds`): bei einem Wechsel sind alle Chunks veraltet + * (andere Tessellierung) — verwerfen, das nächste `update` kompiliert neu. + */ + setLineEnds(code: number | undefined): void { + const c = code ?? 0; + if ((this.gl.lineEnds ?? 0) === c) return; + this.dispose(); + (this.gl as { lineEnds?: number }).lineEnds = c; + } + update( primitives: readonly Primitive[], pxPerMeter: number, diff --git a/src/plan/glPlan/glPlanCompile.test.ts b/src/plan/glPlan/glPlanCompile.test.ts index 611becd2..15fe86d2 100644 --- a/src/plan/glPlan/glPlanCompile.test.ts +++ b/src/plan/glPlan/glPlanCompile.test.ts @@ -18,8 +18,9 @@ const glStub = { STATIC_DRAW: 3, } as unknown as WebGL2RenderingContext; +// Runde Enden/Ecken ([146] `lineEnds` 1 | 1 << 2): nur dort kosten Kappen eigene Dreiecke. const lineIndexCount = (prims: Primitive[]): number => - compilePrimitivesToGpu(glStub, prims, 90).line.batches.reduce((s, b) => s + b.indexCount, 0); + compilePrimitivesToGpu({ ...glStub, lineEnds: 1 | (1 << 2) }, prims, 90).line.batches.reduce((s, b) => s + b.indexCount, 0); const seg = (ax: number, ay: number, bx: number, by: number, drawingId: string): Primitive => ({ kind: 'line', @@ -43,10 +44,11 @@ describe('compilePrimitivesToGpu: zusammenhängende Linien-Segmente', () => { expect(merged).toBe(single + 2 * 6); }); - it('verkettet NICHT über Elementgrenzen, auch bei gemeinsamem Eckpunkt', () => { + it('[146] näht gleich gestylte volle Linien auch über Elementgrenzen (Ecke statt zweier Enden)', () => { const single = lineIndexCount([seg(0, 0, 1, 0, 'a')]); const twoDrawings = lineIndexCount([seg(0, 0, 1, 0, 'a'), seg(1, 0, 2, 0, 'b')]); - expect(twoDrawings).toBe(2 * single); + // Ein Zug: zweites Quad, aber keine Kappen am gemeinsamen Punkt (Wandecken ohne Kerbe). + expect(twoDrawings).toBe(single + 6); }); it('verkettet NICHT bei unterschiedlichem Stil', () => { diff --git a/src/plan/glPlan/glPlanCompile.ts b/src/plan/glPlan/glPlanCompile.ts index 73903296..a6722e8d 100644 --- a/src/plan/glPlan/glPlanCompile.ts +++ b/src/plan/glPlan/glPlanCompile.ts @@ -42,7 +42,7 @@ export function compilePrimitivesToGpu( pxPerMeter = 0, ): GpuGeometry { const packed = gl.packedLineVertices === true; - const out = core().gpu_compile_flat(encodePlanBuf(primitives, { lean: true }), 0, primitives.length, pxPerMeter, packed); + const out = core().gpu_compile_flat(encodePlanBuf(primitives, { lean: true }), 0, primitives.length, pxPerMeter, packed, gl.lineEnds ?? 0); return uploadCompiled(gl, out); } @@ -53,13 +53,14 @@ export function compilePrimitivesToGpu( */ export function compilePlanBufRange(gl: BufferGl, src: DecodedPlanBuf, from: number, to: number, pxPerMeter = 0): GpuGeometry { const packed = gl.packedLineVertices === true; + const ends = gl.lineEnds ?? 0; const c = core(); if (src.holdEpoch !== coreEpoch()) src.hold = 0; // Nummer aus einer Kern-Instanz vor dem Neustart ([118]) - let out = src.hold ? c.gpu_compile_held(src.hold, from, to, pxPerMeter, packed) : new Uint32Array(0); + let out = src.hold ? c.gpu_compile_held(src.hold, from, to, pxPerMeter, packed, ends) : new Uint32Array(0); if (out.length === 0) { src.hold = c.plan_buf_hold(src.bytes); src.holdEpoch = coreEpoch(); - out = src.hold ? c.gpu_compile_held(src.hold, from, to, pxPerMeter, packed) : c.gpu_compile_flat(src.bytes, from, to, pxPerMeter, packed); + out = src.hold ? c.gpu_compile_held(src.hold, from, to, pxPerMeter, packed, ends) : c.gpu_compile_flat(src.bytes, from, to, pxPerMeter, packed, ends); } return uploadCompiled(gl, out); } diff --git a/src/plan/glPlan/glPlanTypes.ts b/src/plan/glPlan/glPlanTypes.ts index 95625b65..63c81d99 100644 --- a/src/plan/glPlan/glPlanTypes.ts +++ b/src/plan/glPlan/glPlanTypes.ts @@ -121,6 +121,11 @@ export interface BufferGl { * der WebGL-Pfad bleibt beim 6-Float-Layout. */ readonly packedLineVertices?: boolean; + /** + * Linienenden und -ecken ([146], `cap | join << 2`, `Plan.lineEnds`) für die Kompilierung; + * gesetzt über `GpuChunkCache.setLineEnds` (verwirft bei Wechsel alle Chunks). Fehlt = 0. + */ + lineEnds?: number; readonly ARRAY_BUFFER: number; readonly ELEMENT_ARRAY_BUFFER: number; readonly STATIC_DRAW: number; diff --git a/src/plan/lineEnds.test.ts b/src/plan/lineEnds.test.ts new file mode 100644 index 00000000..bfdf4fbb --- /dev/null +++ b/src/plan/lineEnds.test.ts @@ -0,0 +1,74 @@ +/** + * [146] Linienenden und -ecken: eine Projekt-Einstellung (`lineCap`/`lineJoin`), Standard flach + + * Gehrung. Sie reist als `Plan.lineEnds` in alle Ausgabewege: render2d-Szene (Kopfwort), Plan-SVG + * (``), GPU-Chunks (`BufferGl.lineEnds`). + */ + +import { describe, expect, it } from "vitest"; +import { generatePlan } from "./generatePlan"; +import { planSceneBin } from "./toRenderScene"; +import { planToSvgString } from "../export/planToSvgString"; +import { sampleProject } from "../model/sampleProject"; +import { flattenCategories, type Project } from "../model/types"; +import { lineEndsCode, lineEndsFromCode, lineEndsOf, lineEndsSvgAttrs } from "../model/lineEnds"; +import { GpuChunkCache } from "./glPlan/glPlanChunks"; +import type { BufferGl } from "./glPlan/glPlanTypes"; + +const ALL = new Set(flattenCategories(sampleProject.layers).map((c) => c.code)); +const floor = sampleProject.drawingLevels.find((l) => l.kind === "floor")!.id; +const planOf = (p: Project) => generatePlan(p, floor, ALL); + +describe("[146] Linienenden und -ecken", () => { + it("Kodierung: fehlt = flach + Gehrung, Rundreise, Unsinn = Standard", () => { + expect(lineEndsOf({})).toEqual({ cap: "butt", join: "miter" }); + expect(lineEndsCode({})).toBe(0); + expect(lineEndsCode({ lineCap: "square", lineJoin: "bevel" })).toBe(2 | (2 << 2)); + expect(lineEndsFromCode(1 | (1 << 2))).toEqual({ cap: "round", join: "round" }); + expect(lineEndsFromCode(Number.NaN)).toEqual({ cap: "butt", join: "miter" }); + expect(lineEndsSvgAttrs(0)).toEqual({ "stroke-linecap": "butt", "stroke-linejoin": "miter", "stroke-miterlimit": "4" }); + }); + + it("Plan trägt die Einstellung; Plan-SVG und render2d-Szene übernehmen sie", () => { + const std = planOf(sampleProject); + expect(std.lineEnds).toBe(0); + const round = planOf({ ...sampleProject, lineCap: "round", lineJoin: "bevel" }); + expect(round.lineEnds).toBe(1 | (2 << 2)); + + const svg0 = planToSvgString(std, { scaleDenominator: 100 }); + expect(svg0).toContain(''); + // Volle Linien tragen keine eigene Kappe mehr (nur Punkt-Muster runden selbst). + expect(svg0).not.toMatch(/]*stroke-linecap="round"(?![^>]*stroke-dasharray)/); + const svg1 = planToSvgString(round, { scaleDenominator: 100 }); + expect(svg1).toContain(' new DataView(b.buffer, b.byteOffset, b.byteLength).getUint32(44, true); + expect(head(planSceneBin(std))).toBe(0); + expect(head(planSceneBin(round))).toBe(1 | (2 << 2)); + }); + + it("GPU-Chunks: Wechsel der Einstellung verwirft die Chunks und kompiliert mit ihr", () => { + const uploads: number[] = []; + const gl: BufferGl = { + packedLineVertices: true, + ARRAY_BUFFER: 1, + ELEMENT_ARRAY_BUFFER: 2, + STATIC_DRAW: 3, + createBuffer: () => ({}) as WebGLBuffer, + bindBuffer: () => {}, + bufferData: (_t, data) => void uploads.push(data.byteLength), + deleteBuffer: () => {}, + }; + const cache = new GpuChunkCache(gl); + const run = (p: Project) => { + const plan = planOf(p); + cache.setLineEnds(plan.lineEnds); + cache.update(plan.primitives, 0, -Infinity, plan.greyedRanges, plan.underlay, plan.bufRuns); + return cache.lastStats.recompiled; + }; + expect(run(sampleProject)).toBeGreaterThan(0); + expect(run(sampleProject)).toBe(0); + expect(gl.lineEnds ?? 0).toBe(0); + expect(run({ ...sampleProject, lineCap: "square" })).toBeGreaterThan(0); + expect(gl.lineEnds).toBe(2); + }); +}); diff --git a/src/plan/planBuf.test.ts b/src/plan/planBuf.test.ts index 7c649f84..6ee61420 100644 --- a/src/plan/planBuf.test.ts +++ b/src/plan/planBuf.test.ts @@ -142,8 +142,8 @@ describe("Plan-Puffer v2", () => { expect(lean.byteLength).toBeLessThan(encodePlanBuf(prims).byteLength); expect(() => decodePlanBuf(lean).prims).toThrow(); // Die GPU-Kompilierung liest beide gleich. - const a = core().gpu_compile_flat(lean, 0, prims.length, 90, true); - const b = core().gpu_compile_flat(encodePlanBuf(prims), 0, prims.length, 90, true); + const a = core().gpu_compile_flat(lean, 0, prims.length, 90, true, 0); + const b = core().gpu_compile_flat(encodePlanBuf(prims), 0, prims.length, 90, true, 0); expect(a.length).toBeGreaterThan(30); expect(Array.from(a)).toEqual(Array.from(b)); }); @@ -170,13 +170,13 @@ describe("Plan-Puffer v2", () => { const wrong = buf.slice(); new Float64Array(wrong.buffer, 0, 2)[1] = PLAN_BUF_VERSION + 1; expect(core().plan_buf_recode(wrong).length).toBe(0); - expect(core().gpu_compile_flat(wrong, 0, 1, 90, true).length).toBe(0); + expect(core().gpu_compile_flat(wrong, 0, 1, 90, true, 0).length).toBe(0); expect(() => decodePlanBuf(wrong)).toThrow(/Version/); expect(core().plan_buf_recode(buf.subarray(0, buf.length - 3)).length).toBe(0); expect(() => decodePlanBuf(buf.subarray(0, buf.length - 2))).toThrow(); - expect(core().gpu_compile_flat(new Uint8Array([1, 2, 3]), 0, 0, 90, false).length).toBe(0); - expect(core().gpu_compile_flat(buf, 0, prims.length + 1, 90, false).length).toBe(0); - expect(core().gpu_compile_held(424242, 0, 1, 90, false).length).toBe(0); + expect(core().gpu_compile_flat(new Uint8Array([1, 2, 3]), 0, 0, 90, false, 0).length).toBe(0); + expect(core().gpu_compile_flat(buf, 0, prims.length + 1, 90, false, 0).length).toBe(0); + expect(core().gpu_compile_held(424242, 0, 1, 90, false, 0).length).toBe(0); expect(core().plan_buf_hold(wrong)).toBe(0); // Danach arbeitet der Kern normal weiter. expect(canon(decodePlanBuf(core().plan_buf_recode(buf)).prims)).toBe(canon(prims)); @@ -187,9 +187,9 @@ describe("Plan-Puffer v2", () => { const buf = encodePlanBuf(prims); const id = core().plan_buf_hold(buf); expect(id).toBeGreaterThan(0); - expect(Array.from(core().gpu_compile_held(id, 1, 5, 90, true))).toEqual(Array.from(core().gpu_compile_flat(buf, 1, 5, 90, true))); + expect(Array.from(core().gpu_compile_held(id, 1, 5, 90, true, 0))).toEqual(Array.from(core().gpu_compile_flat(buf, 1, 5, 90, true, 0))); core().plan_buf_release(id); - expect(core().gpu_compile_held(id, 1, 5, 90, true).length).toBe(0); + expect(core().gpu_compile_held(id, 1, 5, 90, true, 0).length).toBe(0); }); it("Puffer einer Runde verdrängen sich nicht gegenseitig (viele Zeichnungs-Stücke)", () => { diff --git a/src/plan/toElevation.ts b/src/plan/toElevation.ts index 96691b85..0ee7b0cb 100644 --- a/src/plan/toElevation.ts +++ b/src/plan/toElevation.ts @@ -5,6 +5,7 @@ import type { DrawingLevel, Project } from "../model/types"; import { documentFor } from "../core/document"; +import { lineEndsCode } from "../model/lineEnds"; import { decodePlanBuf } from "./planBuf"; import { lazyPlan } from "./planLazy"; import { hasLine, levelArg, visibilityArgs } from "./toSection"; @@ -38,7 +39,7 @@ export function generateElevationPlan(project: Project, level: DrawingLevel, opt if (buf.groups.length === 0) return null; const b = buf.bounds ?? [0, 0, 1, 1]; return lazyPlan( - { bounds: { minX: b[0], minY: b[1], maxX: b[2], maxY: b[3] } }, + { bounds: { minX: b[0], minY: b[1], maxX: b[2], maxY: b[3] }, lineEnds: lineEndsCode(project) }, buf.groups.map(([from, to]) => ({ buf, from, to })), ); } diff --git a/src/plan/toRenderScene.test.ts b/src/plan/toRenderScene.test.ts index dbf85bd6..e7e88a4d 100644 --- a/src/plan/toRenderScene.test.ts +++ b/src/plan/toRenderScene.test.ts @@ -21,8 +21,9 @@ const line = (ax: number, ay: number, bx: number, by: number, extra: Partial { it("verkettet 2D-Zeichenlinien zu Polylinie bzw. Umriss", () => { const open = planToRenderScene(planOf([line(0, 0, 1, 0), line(1, 0, 1, 1), line(5, 5, 6, 6, { drawingId: undefined })])); - expect(open.polylines.map((p) => p.pts.length)).toEqual([3]); - expect(open.lines.length).toBe(1); + // [146] Die volle Einzel-Linie ohne Zeichnung läuft über die Naht-Gruppen (Ecken statt Enden). + expect(open.polylines.map((p) => p.pts.length)).toEqual([3, 2]); + expect(open.lines.length).toBe(0); const ring = planToRenderScene(planOf([line(0, 0, 1, 0), line(1, 0, 1, 1), line(1, 1, 0, 0)])); expect(ring.outlines.map((o) => o.pts.length)).toEqual([3]); expect(ring.outlines[0].dash).toBeNull(); diff --git a/src/plan/toRenderScene.ts b/src/plan/toRenderScene.ts index 2b1c5f59..38b222a5 100644 --- a/src/plan/toRenderScene.ts +++ b/src/plan/toRenderScene.ts @@ -123,6 +123,8 @@ export interface RScene { * Felder ohne `deny_unknown_fields`), also rückwirkungsfrei fürs GPU-Backend. */ bounds: RBounds; + /** Linienenden und -ecken ([146], `Plan.lineEnds`); fehlt = flach + Gehrung. */ + lineEnds?: number; } /** @@ -182,7 +184,7 @@ function emptySceneBin(): Uint8Array { */ export function planSceneBin(plan: Plan, paperScaleN: number = STAMP_DEFAULT_N): Uint8Array { const greyed = greyedFlat(plan); - const out = withPlanParts(planParts(plan), (segs) => core().plan_scene_bin(segs, greyed, paperScaleN)); + const out = withPlanParts(planParts(plan), (segs) => core().plan_scene_bin(segs, greyed, paperScaleN, plan.lineEnds ?? 0)); return out.length ? out : emptySceneBin(); } @@ -260,5 +262,5 @@ function decodeSceneF64(f: Float64Array): SceneGeometry { export function planToRenderScene(plan: Plan, paperScaleN: number = STAMP_DEFAULT_N): RScene { const greyed = greyedFlat(plan); const geo = decodeSceneF64(withPlanParts(planParts(plan), (segs) => core().plan_scene_f64(segs, greyed))); - return { ...geo, texts: sceneTexts(plan, paperScaleN), images: sceneImages(plan), bounds: { ...plan.bounds } }; + return { ...geo, texts: sceneTexts(plan, paperScaleN), images: sceneImages(plan), bounds: { ...plan.bounds }, lineEnds: plan.lineEnds ?? 0 }; } diff --git a/src/plan/toSection.ts b/src/plan/toSection.ts index ddfc9162..7e01617f 100644 --- a/src/plan/toSection.ts +++ b/src/plan/toSection.ts @@ -12,6 +12,7 @@ import { buildSolidMesh } from "../engine/truckSolid"; import { extrudedSolidSpec } from "./extrudedSolidSpec"; import { decodePlanBuf } from "./planBuf"; import { lazyPlan } from "./planLazy"; +import { lineEndsCode } from "../model/lineEnds"; import type { CategoryDisplayResolver, Plan } from "./generatePlan"; /** Vorbereitete Eingabe eines Schnitts: Projekt, Ebene und die truck-Körper (flach). */ @@ -141,7 +142,7 @@ export function generateSectionPlan( if (buf.groups.length === 0) return { primitives: [], bounds: { minX: 0, minY: 0, maxX: 1, maxY: 1 } }; const b = buf.bounds ?? [0, 0, 1, 1]; return lazyPlan( - { bounds: { minX: b[0], minY: b[1], maxX: b[2], maxY: b[3] } }, + { bounds: { minX: b[0], minY: b[1], maxX: b[2], maxY: b[3] }, lineEnds: lineEndsCode(project) }, buf.groups.map(([from, to]) => ({ buf, from, to })), ); } diff --git a/src/styles.css b/src/styles.css index 9ee65ffc..de68256b 100644 --- a/src/styles.css +++ b/src/styles.css @@ -2146,17 +2146,16 @@ body { vector-effect: non-scaling-stroke; } -/* CAD-typische Ecken: alle Plan-Striche gehren (miter) statt an dicken Ecken eine - Stufe/Butt-Cap-Lücke zu zeigen. Der Miter-Grenzwert verhindert überlange Spitzen - bei sehr spitzen Winkeln (dann kappen die Enden rund). Gilt für Poché-Umrisse - (polygon), Wand-/Tür-/2D-Linien und Bögen gleichermaßen. */ +/* Linienenden und -ecken der Plan-Striche ([146]): Projekt-Einstellung, gesetzt als Attribute am + umschliessenden in PlanView (`planLineEndsProps`); die Elemente erben sie. Ausserhalb dieser + Gruppe gelten die SVG-Standardwerte (flach, Gehrung, Grenze 4) bzw. die eigenen Klassen. */ .plan-svg polygon, .plan-svg polyline, .plan-svg line, .plan-svg path { - stroke-linejoin: miter; - stroke-linecap: round; - stroke-miterlimit: 8; + stroke-linejoin: inherit; + stroke-linecap: inherit; + stroke-miterlimit: inherit; } /* Tür-/Fenster- + Referenz-Linien: NUR Farbe + fill hier. Strichstärke und diff --git a/src/ui/SettingsDialog.tsx b/src/ui/SettingsDialog.tsx index 0e1b0189..6f77e1ba 100644 --- a/src/ui/SettingsDialog.tsx +++ b/src/ui/SettingsDialog.tsx @@ -17,6 +17,7 @@ import { LayoutMenu } from "./LayoutMenu"; import { AiAccessSection, type AiAccessView } from "./AiAccessSection"; import { APP_VERSION } from "./TopBar"; import type { LayoutState } from "../panels/types"; +import type { LineCap, LineEnds, LineJoin } from "../core"; import type { ThemeMode } from "../theme/themeMode"; import { checkForUpdate, getUpdateSnoozeUntil, setUpdateSnooze } from "../update/checkForUpdate"; import { getRunningVersion } from "../update/version"; @@ -77,6 +78,9 @@ export interface SettingsDialogProps { /** Projekt-Option: Strichstärken nach Massstab ([32]). */ scaleLineWeights: boolean; onScaleLineWeightsChange: (on: boolean) => void; + /** Projekt-Option: Linienenden und -ecken aller Striche ([146]). */ + lineEnds: LineEnds; + onLineEndsChange: (ends: LineEnds) => void; /** Offline-Modus: sperrt alle entfernten Abrufe (Materialbibliothek, swisstopo, OSM). */ offline: boolean; onOfflineChange: (offline: boolean) => void; @@ -126,6 +130,8 @@ export function SettingsDialog({ onReferenceElevationChange, scaleLineWeights, onScaleLineWeightsChange, + lineEnds, + onLineEndsChange, offline, onOfflineChange, aiAccess, @@ -292,6 +298,7 @@ export function SettingsDialog({ />
{t("settings.referenceElevation.hint")}
+ )} @@ -731,6 +738,38 @@ function ShortcutRemapSection({ ); } +const LINE_CAPS: readonly LineCap[] = ["butt", "round", "square"]; +const LINE_JOINS: readonly LineJoin[] = ["miter", "round", "bevel"]; + +/** Projekt-Option „Linienenden und -ecken" ([146], `model/lineEnds.ts`): gilt in allen Ausgaben. */ +function LineEndsField({ value, onChange }: { value: LineEnds; onChange: (e: LineEnds) => void }) { + return ( + <> + + +
{t("settings.lineEnds.hint")}
+ + ); +} + /** Projekt-Option „Strichstärken nach Massstab" ([32], `plan/lineWeightScale.ts`). */ function LineWeightScaleField({ enabled, onChange }: { enabled: boolean; onChange: (on: boolean) => void }) { return ( diff --git a/src/views/plan/PlanView.tsx b/src/views/plan/PlanView.tsx index 7da9895f..c1887d95 100644 --- a/src/views/plan/PlanView.tsx +++ b/src/views/plan/PlanView.tsx @@ -18,6 +18,7 @@ import { import type { ComponentProps, CSSProperties, ReactNode } from "react"; import type { HatchRender, Plan, PlanImage, Primitive } from "../../core"; import { materializeGreyed, materializeUnderlay, type UnderlayGroup } from "../../core"; +import { planLineEndsProps } from "../../core"; import type { Drawing2D, EdgeGrip, Vec2 } from "../../model/types"; import { t } from "../../i18n"; import type { ToolHandlers, ToolId, ToolMods } from "../../tools/types"; @@ -3254,11 +3255,14 @@ export const PlanView = forwardRef( })} {/* 2D-Zeichen-Linien mit drawingId werden gemergt (drawingRuns) als EIN Zug gezeichnet → gehrte Ecken statt Butt-Cap-Stufe; im Memo übersprungen. */} + {/* Linienenden und -ecken des Projekts ([146], `Plan.lineEnds`) für alle Plan-Striche. */} + {primitiveEls} {/* Zusammenhängende 2D-Zeichen-Linienzüge als EIN /: CAD-typische Gehrung an den Ecken (stroke-linejoin), keine Stufe bei dicken Linien. Nach der Haupt-Ebene gezeichnet (2D liegt ohnehin oben). */} {drawingRunEls} + {/* Ist eine GRUPPE gewählt, ersetzt die Bounding-Box unten die einzelnen Mitglieds-Hervorhebungen (s. `groupBBox`) — dieser ganze Block bleibt dann aus. */} diff --git a/src/views/plan/useNativePlanRenderer.ts b/src/views/plan/useNativePlanRenderer.ts index 34d02a4d..f6bf3c81 100644 --- a/src/views/plan/useNativePlanRenderer.ts +++ b/src/views/plan/useNativePlanRenderer.ts @@ -256,6 +256,7 @@ export function useNativePlanRenderer( const invoke = invokeRef.current; if (!cache || !gl || !invoke || !plan) return; try { + cache.setLineEnds(plan.lineEnds); cache.update( plan.primitives, pxPerMeter,