Merge [276] Schnitt- und Ansichtslinien: Linie, Marke, Lage und Beschriftung einstellbar
This commit is contained in:
20 files changed
+1114
-180
No files matched your search
@@ -73,6 +73,7 @@ Kennwort, anonym) als PDF; Austausch mit Fachplanern über DXF/IFC.
|
||||
Geprüft und in Ordnung: Anonymität (Plakat-PDF Titel „FALKE 7“, Producer leer, Datum 2000, Schriften eingebettet, `pdftotext` ohne Projekt-/Büronamen; Kennzahlen-PDF nach „anonym“ ebenso; DXF/IFC ohne Projektnamen), Ansichten/Schnitt stimmig zum Grundriss (Fensterlagen nachgemessen), Kennzahlen-Tabelle Plakat = Flächenbilanz, ÜZ 127.71/900, Kosten 2’844 CHF/m² GF plausibel (mit Befund 1), IFC mit Georeferenz LV95 (IfcMapConversion). **Nicht geprüft:** Tauri-App/Mac (Metal, 3D-Bild, Schatten, Rendering), Mausbedienung (alles über Befehlszeile und Test-Naht), Druck des A1-Plakats, DXF/IFC in Fremdsoftware. · M (Reste)
|
||||
|
||||
- ◐ **[270]** Blickrichtungen überall gleich, Marken weichen aus (17.11.). **Befund:** das 3D-Fenster (render3d, Browser und Metal) zeigte das Modell **gespiegelt**: Bauteile liegen in der Welt (x, Höhe, y), ein Achsentausch (Determinante −1), und `look_at` ist rechtshändig — von Süden gesehen lag der Erker im Osten links, die Draufsicht stand kopfüber (Süden oben). Gelände, Importe/Verbau und Punktwolken negierten y (Fix 24.9. „swisstopo gespiegelt“) und lagen damit an y = 0 gespiegelt unter dem Haus. Vektor-Axonometrie, Cycles, Blender, glTF/OBJ und die Ansichten Nord/Ost/Süd/West waren seitenrichtig, aber die Namen widersprachen sich: `iso` = von Nordost (3D, Axo-Alias), von Südwest (Cycles/Blender); `front` = von Norden (3D, Axo) bzw. Süden (Cycles); „Axonometrie Südost“ im Musterhaus komplex stand auf `isoFrontLeft`. **Behoben:** eine Tabelle `render3d/src/view_dir.rs` für 3D-Presets (`math::preset_camera`), Axonometrie (`plan/axo.rs::preset`), Cycles (`cycles_scene.rs::preset`, CLI `render --view` nimmt auch `southeast` …), Blender-Skript (Kopie, per vitest geprüft): vorne = Süden, rechts = Osten, `iso` = Südost, `isoFrontLeft` = Südwest, `isoBackRight` = Nordost, `isoBackLeft` = Nordwest, `top` mit Norden oben; Beschriftungen „Isometrie Südost“, „Südwest“ … Die Spiegelung gleicht die Kamera an einer Stelle aus (`math::view_matrix`: Bild-rechts = oben × Blick; Culling `FrontFace::Cw`; Pathtracer-Strahlen; TS `screenRight`/`orbitRight` für Pick-Strahl, Griffe, Pan, Zoom zum Cursor, Begehen, Orbit-Richtung); Gelände/Import/Punktwolke/Luftbild ohne y-Negation. Ausschnitt „Axonometrie Südost“ → `iso`. **Marken ([266]/8):** Ansichtsmarken werden nach den Schnitten gesetzt und weichen Schnittlinien, -pfeilen und anderen Ansichtsmarken aus (zusätzlich seitlich entlang ihrer Linie, bis 15 mm; `plan/context.rs::view_marker`); Schnittpfeile sind Hindernis für Beschriftungen. Tests: Rust render3d `kamera_zeigt_modell_seitenrichtig` (vorher rot), `aussenflaechen_erscheinen_im_uhrzeigersinn`, `view_dir::tests`; Kern `axo::testhaus_seitenrichtig_in_allen_vorgaben`, `cycles_scene::voreinstellungen_heissen_wie_im_3d`, `context::ansichtsmarken_weichen_schnittmarken_aus` (vorher rot); vitest `view270.test.ts`, `viewDirections.test.ts`. Bilder und Testhaus (Erker Ost, Garage West, Turm Nordwest; `testhaus.py`) in `doc/review-270/`. **Offen:** 3D-Bild nur numerisch (Kameramatrix, Pick-Strahl) geprüft, kein Bild aus render3d unter Linux, nicht auf dem Mac/Metal (Prüfschritt `doc/RELEASE-1.0.md` 13.36); natives Spike-Fenster `src-tauri/src/native.rs` (Orbit-Richtung) nicht angepasst; gespeicherte Ausschnitte mit `isoBackRight`/`isoFrontLeft` zeigen jetzt die Richtung ihres Namens (keine produktiven Projekte). · M
|
||||
- ◐ **[276]** Schnitt-/Ansichtslinie im Plan einstellbar (Wunsch Maintainer 17.11., „wie Archicad“; 17.11.). **Archicad** (Hilfe „Section/Elevation Marker“, Marker- und Marker-Head-Bereich der Schnitt-Einstellungen, Modellansicht-Option „Show Section and Elevation Markers“, [Quellen nur über die Suche gelesen, Feldnamen nicht je Version geprüft]): Marke an Anfang, Ende oder beiden Enden bzw. eine in der Mitte, Markentyp und Symbol, Linientyp und Stift der Linie, Beschriftung. **Übernommen (schlank):** je Schnitt- und Ansichtslinie `lineMode` (full | ends | none), `endLengthMm`, `lineStyleId` (Linientyp), `linePenId` (Stift des aktiven Stiftsatzes: Farbe + Stärke), `marker` (arrow | lAngle | triangle | none; Ansicht: triangle | arrow | none), `markerAt` (both | start | end, nur Schnitt), `markerLabel`; Vorgabe getrennt für Schnitte (`sectionMarks`) und Ansichten (`elevationMarks`) in der Modelldarstellung (Ebene > Modelldarstellung des gezeigten Plans > Basis), dort ohne Linientyp/Stift (Auswahl nur feste Werte). `markerStyle`/`sectionMarks.style` gehen darin auf; Basis = heutiges Bild (Goldens unverändert): Schnitt = dünne Strichpunktlinie mit kräftigen Endstücken + Pfeile + Beschriftung, Ansicht = nur Dreieck + Beschriftung. Ansichtslinie wird jetzt auf Wunsch gezeichnet und ist dann anwählbar. Der frühere L (`lAngle`) heisst jetzt `lineMode: ends` + `marker: lAngle`. Kern: `plan/misc.rs` (`SectionLook`, `section_polyline_look`, `view_symbol`, `view_line_parts`), `plan/model_view.rs::mark_look`, `plan/context.rs` (Linientyp/Stift, Beschriftung nur an markierten Enden, Ausweichen [270] und Knicke [176] unverändert). Oberfläche: `SectionLookFields.tsx` in der Objekt-Info (Symbol-Knöpfe mit Vorschau; Mehrfachauswahl ändert alle gewählten Linien in einem Undo-Schritt), Ressourcen > Modelldarstellung (Schnitt- und Ansichtsmarken). Tests: Rust `misc::darstellung_varianten`, `ansicht_zeichen_und_linie`, `context::schnittlinie_varianten_im_grundriss`, `schnittlinie_linientyp_und_stift`, `ansichtslinie_varianten`; vitest `SectionLookFields.test.ts`; e2e `sectionLook276.spec.ts`. Bilder: `doc/review-276/`. **Offen:** nicht in der Tauri-App/auf dem Mac geprüft (nur CLI-SVG in Chromium und Browser-Build); Linientyp/Stift in der Modelldarstellung wählbar machen (dynamische Werte); Marke „Kreis mit Pfeil“ für Ansichten; Marken-Versatz wie bei Archicad (Symbol unabhängig von der Schnittlinie verschieben) · S.
|
||||
- ◐ **[271]** Umbaufilter wie Archicad (Wunsch Maintainer 17.11.). **Modell:** `renovation: {status: existing|demolish|new, phase?}` an Wand, Öffnung (ohne eigenen Status folgt sie der Wand), Decke, Dach, Treppe, Stütze, Körper und Raum (Raum nur Sichtbarkeit/Flächen, keine Farbe — kein Bauteil); `Project.renovation` (Etappen, Farben, eigene Filter); `DrawingLevel`/`ViewTemplate`/`ViewSnapshot.renovationFilter`+`renovationPhase` (der Filter gehört zur Ebene wie die Modelldarstellung [173], damit je Reiter/Ausschnitt/Vorlage). **Kern** `renovation.rs` (ein Ort, `doc/ARCHITEKTUR.md` 3.8): Vorgaben Bestand/Abbruch/Neubau/Umbauplan/Endzustand, SIA-400-Farben (Bestand grau, Abbruch gelb gestrichelt, Neu rot, anpassbar), Etappen „bis n“ (Neues früherer Etappen = Bestand, Abbruch früherer weg, spätere Neue fehlen), Öffnung neu in Bestandswand = Abbruch-Stück bzw. zugemauerte Öffnung = Ausfachung (Wand zu, wo die Öffnung ausgeblendet ist). Umbau-Farben bleiben auch in Tusche (Schwarz-Weiss, `extras::KeepColors`); gefüllt werden nur Schnittflächen (Wand, Stütze), Symbole (Fenster, Türflügel, Tritte) nur in Linienfarbe. Angebunden: Grundriss, Schnitt, Ansicht, Vektor-Axo, 3D-Fenster (Filter der aktiven Ebene) und `model3d`, Kennzahlen/Flächen (Zustand Bestand/Endzustand im Panel), DXF (Layer `<Klasse>_Abbruch`/`_Neu`), IFC (`Status` NEW/EXISTING/DEMOLISH im `Pset_*Common`, Etappe in `Dossier_Umbau`). **Bedienung:** Objekt-Info/Objekteinstellungen „Umbau“ + „Etappe“ (Mehrfachauswahl, ein Undo-Schritt), Statusleiste „Umbau: …“ (Zeichen-Status neuer Bauteile, Vorgabe Bestand, Kern `commands::stamp_renovation`; Umbaufilter und Etappe der Ansicht; mit der Pausfolie im Überlauf „⋯“), Befehl `umbau` (B/A/N; die Befehlszeile nimmt getippte Options-Kürzel jetzt auch mit Enter an, `engine.ts`), Ressourcen-Tab „Umbau“ (Etappen, Farben), Vorlage „Beispiel Umbau“ (`model/sampleProjectUmbau.ts`, CLI `:umbau`), CLI `--renovation`/`--phase` (plan, section, elevation, axo, model3d, kennzahlen). Tests: Kern `renovation_tests.rs` (19), Robustheit, vitest `model/renovation.test.ts`, `commands/cmds/renovation.test.ts`, e2e `renovation271.spec.ts` (2× grün, Port 5195; dazu `uxReview263`, `objectSettings`, `modelViews`, `release10`, `editing` grün); Bilder `doc/review-271/` (CLI-SVG `--hatch` in Chromium, App-Screenshot). **Offen:** 3D-Fenster nur im Code angebunden (Kern-Teile per Test geprüft, Bild nicht angesehen: kein render3d unter Linux); Blender-Paket ohne Umbau-Farben (nur Ausblenden); Ansichtsleiste/Werkzeugleiste ohne eigene Filter-Wahl (Statusleiste und Panel Umbau); eigene Filter nur im Modell (keine Bearbeitung in der Oberfläche); Tauri/Mac nicht geprüft (Prüfschritt `doc/RELEASE-1.0.md` 13.37). **Nachtrag 17.11. (Panel):** eigenes Dock-Panel „Umbau“ (`panels/RenovationPanel.tsx`, Reiter rechts oben neben Objekt-Info/Flächenbilanz, Layout v16): Zeichen-Status Bestand/Abbruch/Neu mit SIA-Farbmuster + Etappe, Umbaufilter der aktiven Ansicht als Liste mit Vorschau je Status (wie gezeichnet/ausgeblendet/Umbau-Farbe) + „bis Etappe“, Status der Auswahl (gemischt-Marke) mit Setzen und Etappe (ein Undo-Schritt), „Nach Status wählen“ (Geschoss), Etappenliste (anlegen, umbenennen, Reihenfolge, Löschen mit Rückfrage über `ui/ConfirmDialog`, Verweis auf die Farben in den Ressourcen). Statusleisten-Popover und Objekt-Info teilen Zustand und Aktionen mit dem Panel (`state/renovationHook.ts`, keine Doppelspur) und lesen nur schmale Teile des Projekts: behebt die 45 Renders je Wand-Änderung in `renderCount.spec.ts` (jetzt 42, Grenze unverändert; `RenovationField` ist `memo`). Filter-Vorschau der eingebauten Filter spiegelt `renovation::builtin` in `model/renovation.ts` (vitest prüft gegen den Plan des Kerns; sauberer wäre, die Anteile in `filter_list` mitzuliefern). Tests: vitest `model/renovation.test.ts` (+3), e2e `renovationPanel271.spec.ts` (Port 5193); Bild `doc/review-271/05-panel-umbau.png`. Nicht geprüft: Tauri/Mac. **Offen:** Panel-Bild nur hell/1280×800 angesehen (dunkel ebenfalls ok, schmale Leiste nicht eigens). **Nachtrag 17.11. (Exporte und Rendering folgen der Ansicht, mit [272]):** neue gemeinsame Ansicht `export/exportView.ts` (`levelExportView` = Umbaufilter, Etappe und Variantenkombination der aktiven Ebene; `exportViewText` = Text der Kern-Abfragen, `renovation::view_from_text`), die EIN Weg für IFC (`exportIfcSpf({view})`), OBJ/STL/glTF (`MeshOptions.view`), STEP (`exportProjectStep(…, view)`), Blender-Paket (`RenderOptions.view`) und Cycles-Szene ist. Ausgeblendetes fehlt dort; die Cycles-Szene malt Umbau-Farben nur auf Wunsch (Option `renovationColors`, `cycles_scene_styled`; Vorgabe Materialfarben). App: Export-Dialog (IFC, OBJ, STL, glTF, STEP) und Rendering-Dialog zeigen die Ansicht der aktiven Ebene („Umbau: …“, „Variante: …“) und lassen „Hauptvarianten/kein Filter“ wählen; Rendering mit Cycles hat das HäkchenLine truncated
|
||||
- ◐ **[274]** Umbau je Schicht: Sanierung mehrschichtiger Bauteile (Feedback Maintainer 17.11., typbasiert nach Rückfrage). **Modell:** `WallType.renovationTarget` (Sanierungstyp), `renovationSide` (Bezugsseite innen/aussen), `renovationOld`/`renovationNew` (manuelle Zuordnung je Schicht, Vorgabe „auto“); Wand `renovation.renovated` (nutzt den Sanierungstyp ihres Typs) bzw. `renovation.newTypeId` (Ausnahme); wirkt nur beim Status Bestand, Etappe = `renovation.phase`; ohne Umbaufilter gilt der Bestandstyp. **Kern** `renovation::build_up` (ein Ort, `doc/ARCHITEKTUR.md` 3.8): Zuordnung von der Bezugsseite her (gleicher Baustoff + Dicke + Lage = Bestand, nur alt = Abbruch, nur neu = Neu; manuell überschreibbar, weil z. B. ein ersetzter Baustoff gleicher Dicke sonst als Bestand gälte; das automatisch gepaarte Gegenstück folgt), gezeigter Aufbau je Filter (Abbruch sichtbar ⇒ alt, Neu sichtbar ⇒ neu, beide ⇒ überlagert in Teilschichten), Ersatzwand mit Ersatztyp und Achsversatz (Bezugsseite bleibt stehen, Achse bleibt) für Grundriss, Schnitt, Ansicht, Axo, 3D, Kennzahlen/GF, IFC-Schichten; Farben je Schicht (Grundriss über die Schicht-Aktionen [33], Kanten der Abbruch-Schichten gestrichelt, im Umbauplan Abbruch als gelbe gestrichelte Kontur über der roten Füllung; Schnitt je Schnittfläche; Ansicht/Axo/3D Farbe der äussersten Schicht); Öffnungsleibungen folgen dem gezeigten Aufbau. Abfragen `renovationPair`/`renovationPairs`. **Bedienung:** Objekt-Info/Objekteinstellungen „Neuer Aufbau (Sanierung)“ (keiner / wie Typ / anderer Wandtyp; Mehrfachauswahl ein Undo-Schritt) mit Streifen Alt/Neu/Ergebnis in SIA-Farben (`ui/RenovationStrip.tsx`); Umbau-Panel Abschnitt „Sanierung“ (`panels/RenovationSanierung.tsx`): Zähler „Sanierte Bauteile“, Typ-Paare mit „x von n Wänden saniert“, „Alle Wände vom Typ sanieren“ (ein Undo-Schritt), „Sanierungstyp anlegen …“ (Kopie des Bestandstyps), Typ-Paar-Editor (Alt/Neu nebeneinander, Zuordnung je Schicht, Bezugsseite, Ergebnis-Streifen). Status/Etappe setzen und Etappe löschen behalten die Sanierung. Beispiel Umbau: Südwand W1 Beton 20 + Dämmung 10 + Putz → Dämmung 20 + Putz (Etappe 1), neuer Schnitt C durch die Wand. Tests: Kern `renovation_layers_tests.rs` (11: Zuordnung inkl. gleicher Baustoff andere Dicke, vertauscht, Bezugsseite aussen, manuell, NaN/leer/fehlender Typ; Grundriss und Schnitt je Filter; Kennzahlen je Zustand; Öffnung; 3D/Ansicht; Umstellen idempotent; Abfragen), vitest `model/renovationLayers.test.ts`, e2e `renovation274.spec.ts` (2× grün, Port 5195; dazu `renovation271`, `renovationPanel271`, `objectSettings`, `renderCount` 2× grün, Renders je Wand-Änderung 43 bei unveränderter Grenze); Bilder `doc/review-274/` (CLI-SVG `--hatch` Grundriss 1:50/1:100 und Schnitt C in allen fünf Filtern, Chromium; App-Screenshots Feld und Panel). **Offen:** Decken und Dächer ohne Sanierung je Schicht (Modell-Felder nur am Wandtyp); Bogenwände ohne gestrichelte Abbruch-Kanten (Füllung je Schicht ja); im Schnitt Abbruch-Kontur schwarz gestrichelt statt gelb, Aussenkante der Abbruch-Schicht unter der schweren Schnittkante durchgezogen (wie [271]); 3D/Ansicht nur Farbe der äussersten Schicht (Teile je Schicht im 3D wären möglich), 3D-Bild nicht angesehen; IFC: Endzustand-Aufbau als Materialschichten über die Ersatzwand (Weg wie Kennzahlen, nicht eigens geprüft), kein Status je Schicht als Eigenschaft; DXF: Schichten nicht auf eigenen Umbau-Layern (Wand-Layer nach Wand-Status); Instanz-Schichtliste (eigene Schichten je Wand) bewusst nicht, nur anderer Typ als Ausnahme; Achse auf der bewegten Seite bei dünnerem neuem Aufbau bleibt in der Wand (Bezugsseite verschiebt sich dann); Tauri/Mac nicht geprüft (Prüfschritt `doc/RELEASE-1.0.md` 13.39). **Zusammenführung mit [271]-Rest (17.11.):** sanierte Wände zeigen auch die Projektionslinien des Schnitts in der Farbe ihrer äussersten Schicht (`CutRules::edge` über `Resolved::faces`); die Ersatzstücke der Öffnungen in Schnitt und Ansicht rechnen aus dem Projekt mit allem, aber mit dem gezeigten Aufbau (`renovation::apply` ohne Ausgeblendetes); Beispiel `:umbau` vereint Südwand W1/Schnitt C mit Möbeln, Bäumen und Ansicht West. · M
|
||||
- ◐ **[275]** Umbau-Farben als Farbe oder Stift, gedämpfte Vorgabe, eigene Farben je Etappe (Wunsch Maintainer 17.11.: „eine Farbe oder ein Stift … weniger leuchtendes Gelb und Rot“). **Vorgabe** (`renovation::default_style`, Konstanten `DEMOLISH_FILL`/`NEW_FILL`/`NEW_LINE`): Abbruch ruhiges Ocker-Gelb `#e8c35a` (statt `#ffd800`), Neu gedämpftes Ziegelrot `#c8524a`, Linie `#9e3a33` (statt `#e3001b`/`#c00016`), Bestand `#a6a6a6` unverändert; gilt überall über `renovation::style` (Plan, Schnitt, Ansicht, Axo, 3D, Cycles-Umbaufarben, Panel/Statusleiste; CSS über `--reno-*`). **Modell:** `RenovationStyle.fillPen`/`linePen` (ColorPen-Id; Farbe aus dem aktiven Stiftsatz, beim Lesen aufgelöst, nicht eingebacken — S/W-Stiftsatz färbt den Umbauplan um; Stift ohne Eintrag ⇒ freie Farbe/Vorgabe), `RenovationPhase.styles` (eigene Farben der Etappe über der Projektfarbe; `View::treat` nimmt sie, solange das Element seinen eigenen Status zeigt, Ersatzstücke nach der Etappe ihrer Öffnung). Abfrage `renovationStyles` (Vorgabe/Projekt/Etappen aufgelöst) — die Oberfläche rechnet keine Farben mehr selbst (`DEFAULT_RENOVATION_STYLES` in TS entfernt). `project_refs` prüft die Stifte. **Oberfläche:** gemeinsamer Editor `ui/RenovationStyleEditor.tsx` (je Status Füllung/Linie mit dem `PenColorField` der App: Frei/Stift, „gestrichelt“, Zurücksetzen) im Umbau-Panel (Abschnitt „Darstellung“ mit Knopf „SIA-Vorgabe“; je Etappe Farbmuster-Knopf mit eigenem Editor und „Farben des Projekts verwenden“) und im Ressourcen-Tab „Umbau“ (ersetzt die `input type=color`); Ops `setRenovationStylesOps`/`setPhaseStylesOps`/`patchRenovationStyles` (Farbe und Stift schliessen sich aus). Beispiel `:umbau`: Etappe 2 (Anbau) Neu gedämpft blau `#5b84b1`. Tests: Kern `renovation_style_tests.rs` (6: Vorgabe, Stift + Stiftsatz-Wechsel, Etappe inkl. „bis Etappe“, Ersatzstück, Unsinn, Abfrage), vitest `model/renovationStyles.test.ts` (4), e2e `renovationStyles275.spec.ts` (Port 5196); Bilder `doc/review-275/` (CLI-SVG `--hatch` Grundriss EG 1:50 und Schnitt C vorher/nachher, Etappe 2 blau; App-Panel hell/dunkel). **Offen:** dünnes Strichwerk im Abbruch (Möbel, Baum „zu fällen“) bleibt auf weissem Papier blass (Linie = Füllfarbe; mit eigener Abbruch-Linie z. B. dunklem Ocker kräftiger, dann aber auch die Wandkontur ocker statt schwarz gestrichelt — bewusst nicht als Vorgabe); Etappen-Farben nur für Neu/Abbruch in der Oberfläche (Modell kennt auch Bestand); Stift-Strichstärke wirkt nicht (nur Farbe); Tauri/Mac und 3D-Fenster (render3d) nicht angesehen. · S
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 176 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 101 KiB |
@@ -0,0 +1,85 @@
|
||||
// [276] Darstellung der Schnitt-/Ansichtslinie: in der Objekt-Info Linie (durchgehend / nur Enden / keine), Marke
|
||||
// (Pfeil / L / Dreieck / keine) wählen; Mehrfachauswahl ändert alle gewählten Linien in einem Undo-Schritt.
|
||||
// Eigener Port: E2E_PORT=5197 npx playwright test e2e/sectionLook276.spec.ts
|
||||
import type { Page } from "@playwright/test";
|
||||
import { blurFocus, commandInput, expect, finishCommand, startNewProject, test, typeCommand } from "./app";
|
||||
|
||||
test.use({ viewport: { width: 1280, height: 800 } });
|
||||
|
||||
async function screenOf(page: Page, x: number, y: number): Promise<{ x: number; y: number }> {
|
||||
return page.locator("svg.plan-svg").evaluate(
|
||||
(el, [mx, my]) => {
|
||||
const [vx, vy, vw, vh] = el.getAttribute("viewBox")!.split(/\s+/).map(Number);
|
||||
const ox = Number(el.getAttribute("data-origin-x") ?? 0);
|
||||
const oy = Number(el.getAttribute("data-origin-y") ?? 0);
|
||||
const r = el.getBoundingClientRect();
|
||||
const s = Math.min(r.width / vw, r.height / vh);
|
||||
return { x: r.left + (r.width - vw * s) / 2 + (mx * 90 - ox - vx) * s, y: r.top + (r.height - vh * s) / 2 + (-my * 90 - oy - vy) * s };
|
||||
},
|
||||
[x, y],
|
||||
);
|
||||
}
|
||||
|
||||
async function drawSection(page: Page, a: string, b: string): Promise<void> {
|
||||
await commandInput(page).focus();
|
||||
await typeCommand(page, "schnittlinie");
|
||||
await typeCommand(page, a);
|
||||
await typeCommand(page, b);
|
||||
await finishCommand(page);
|
||||
await blurFocus(page);
|
||||
}
|
||||
|
||||
const name = (page: Page) => page.getByTitle("Name", { exact: true }).first();
|
||||
const isOn = (page: Page, id: string) => expect(page.getByTestId(`look-${id}`).first()).toHaveAttribute("aria-pressed", "true");
|
||||
|
||||
test("Schnittlinie: Linie und Marke wählen, Mehrfachauswahl ändert beide, ein Undo", async ({ page }) => {
|
||||
await startNewProject(page);
|
||||
await drawSection(page, "0,0", "10,0");
|
||||
await drawSection(page, "0,6", "10,6");
|
||||
await page.locator('[title="Auf Plan einpassen"]').first().click();
|
||||
|
||||
// Erste Linie wählen (kräftiges Endstück am Anfang): Basis = durchgehend + Pfeil.
|
||||
const p1 = await screenOf(page, 0.9, 0);
|
||||
await page.mouse.click(p1.x, p1.y);
|
||||
await expect(page.getByTestId("look-ends")).toBeVisible();
|
||||
await isOn(page, "full");
|
||||
await isOn(page, "arrow");
|
||||
|
||||
// Nur Enden + L.
|
||||
await page.getByTestId("look-ends").click();
|
||||
await page.getByTestId("look-lAngle").click();
|
||||
await isOn(page, "ends");
|
||||
await isOn(page, "lAngle");
|
||||
// Marke an: nur Anfang.
|
||||
await page.getByTestId("look-start").click();
|
||||
await isOn(page, "start");
|
||||
if (process.env.E2E_SHOTS) await page.screenshot({ path: `${process.env.E2E_SHOTS}/objektinfo-schnittlinie.png` });
|
||||
|
||||
// Beide Linien wählen (Umschalt): eine Änderung trifft beide.
|
||||
const p2 = await screenOf(page, 0.9, 6);
|
||||
await page.keyboard.down("Shift");
|
||||
await page.mouse.click(p2.x, p2.y);
|
||||
await page.keyboard.up("Shift");
|
||||
await page.getByTestId("look-triangle").click();
|
||||
|
||||
// Einzeln prüfen: beide zeigen Dreieck.
|
||||
await blurFocus(page);
|
||||
await page.mouse.click(p2.x, p2.y);
|
||||
await expect(name(page)).toHaveValue(/C$/);
|
||||
await isOn(page, "triangle");
|
||||
await page.waitForTimeout(600);
|
||||
await page.mouse.click(p1.x, p1.y);
|
||||
await expect(name(page)).toHaveValue(/B$/);
|
||||
await isOn(page, "triangle");
|
||||
|
||||
// Ein Undo nimmt die Mehrfachänderung für beide zurück (Linie 1 wieder L, Linie 2 wieder Pfeil).
|
||||
await blurFocus(page);
|
||||
await page.keyboard.press("Control+z");
|
||||
await page.mouse.click(p1.x, p1.y);
|
||||
await expect(name(page)).toHaveValue(/B$/);
|
||||
await isOn(page, "lAngle");
|
||||
await page.waitForTimeout(600);
|
||||
await page.mouse.click(p2.x, p2.y);
|
||||
await expect(name(page)).toHaveValue(/C$/);
|
||||
await isOn(page, "arrow");
|
||||
});
|
||||
@@ -1878,11 +1878,38 @@ pub struct DrawingLevel {
|
||||
#[serde(rename = "autoLine", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub auto_line: Option<bool>,
|
||||
/// [176] Schnittmarke im Grundriss: "arrow" (Pfeil mit Dreieck, Basis) oder "lAngle" (nur ein L je Ende). Fehlt ⇒ die
|
||||
/// Vorgabe der Modelldarstellung (`sectionMarks.style`), sonst Pfeil. Nur Schnitt.
|
||||
#[serde(rename = "markerStyle", default, skip_serializing_if = "Option::is_none")]
|
||||
/// [276] Darstellung der Linie im Grundriss: "full" (Basis: Schnitt = dünne Strichpunktlinie mit kräftigen Endstücken),
|
||||
/// "ends" (nur die Endstücke) oder "none" (keine Linie). Fehlt ⇒ Vorgabe der Modelldarstellung (`sectionMarks` bzw.
|
||||
/// `elevationMarks`), sonst Schnitt "full", Ansicht "none". Nur Schnitt/Ansicht.
|
||||
#[serde(rename = "lineMode", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub marker_style: Option<SectionMarkerStyle>,
|
||||
pub line_mode: Option<SectionLineMode>,
|
||||
/// [276] Länge der Endstücke in Papier-mm (Basis 12; an Knicken die Hälfte).
|
||||
#[serde(rename = "endLengthMm", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub end_length_mm: Option<f64>,
|
||||
/// [276] Linientyp (`LineStyle.id`) der Linie; fehlt ⇒ Basis (Strichpunkt, bei "ends" durchgezogen).
|
||||
#[serde(rename = "lineStyleId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub line_style_id: Option<String>,
|
||||
/// [276] Stift (`ColorPen.id`) der Linie (Farbe und Strichstärke des aktiven Stiftsatzes); fehlt ⇒ Basis.
|
||||
#[serde(rename = "linePenId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub line_pen_id: Option<String>,
|
||||
/// [276] Marke an den Enden bzw. (Ansicht) in der Mitte: "arrow" (Schenkel mit Dreieck), "lAngle" (nur Schenkel, ein L
|
||||
/// mit dem Endstück), "triangle" (nur gefülltes Dreieck) oder "none". Fehlt ⇒ Vorgabe der Modelldarstellung, sonst
|
||||
/// Schnitt "arrow", Ansicht "triangle". Ansichten kennen "arrow", "triangle", "none".
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub marker: Option<SectionMarker>,
|
||||
/// [276] Wo die Marke steht (nur Schnitt): beide Enden (Basis), nur am Anfang oder nur am Ende.
|
||||
#[serde(rename = "markerAt", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub marker_at: Option<SectionMarkerAt>,
|
||||
/// [276] Beschriftung der Marke (Basis: ja).
|
||||
#[serde(rename = "markerLabel", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub marker_label: Option<bool>,
|
||||
/// Blickrichtung relativ zur Schnittlinie (nur Schnitt/Ansicht).
|
||||
#[serde(rename = "directionSign", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional, type = "1 | -1")]
|
||||
@@ -2147,6 +2174,10 @@ pub struct ModelViewOption {
|
||||
#[serde(rename = "sectionMarks", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub section_marks: Option<ModelViewSectionMarks>,
|
||||
/// [276] Ansichtslinien und -marken im Grundriss.
|
||||
#[serde(rename = "elevationMarks", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub elevation_marks: Option<ModelViewSectionMarks>,
|
||||
/// [173] Raumstempel: welche Zeilen (die Einstellung am Stempel geht vor).
|
||||
#[serde(rename = "roomStamps", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
@@ -2271,28 +2302,82 @@ pub enum ModelViewDimChains {
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// [176] Schnittmarken in der Modelldarstellung (fehlt ⇒ Pfeil).
|
||||
/// [176]/[276] Schnitt- bzw. Ansichtsmarken in der Modelldarstellung (fehlt ⇒ Basis; die Ebene geht vor). Dieselben
|
||||
/// Felder wie an der Ebene (`DrawingLevel.lineMode` …) ohne Linientyp und Stift.
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct ModelViewSectionMarks {
|
||||
/// Markentyp der Schnitte (die Ebene geht vor; Basis: Pfeil).
|
||||
/// Linie: durchgehend, nur Endstücke, keine.
|
||||
#[serde(rename = "lineMode", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub line_mode: Option<SectionLineMode>,
|
||||
/// Länge der Endstücke in Papier-mm.
|
||||
#[serde(rename = "endLengthMm", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub end_length_mm: Option<f64>,
|
||||
/// Marke (Pfeil, L, Dreieck, keine).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub style: Option<SectionMarkerStyle>,
|
||||
pub marker: Option<SectionMarker>,
|
||||
/// Wo die Marke steht (nur Schnitt).
|
||||
#[serde(rename = "markerAt", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub marker_at: Option<SectionMarkerAt>,
|
||||
/// Beschriftung der Marke.
|
||||
#[serde(rename = "markerLabel", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub marker_label: Option<bool>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// [176] Markentyp einer Schnittlinie im Grundriss: Pfeil (kräftige Endstücke, dünne Linie, Schenkel mit Dreieck)
|
||||
/// oder nur ein L an jedem Ende (langer Schenkel längs der Linie, kurzer in Blickrichtung, keine Linie dazwischen).
|
||||
/// [276] Linie einer Schnitt-/Ansichtslinie im Grundriss.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
|
||||
pub enum SectionMarkerStyle {
|
||||
pub enum SectionLineMode {
|
||||
/// Ganze Linie (dünn, Strichpunkt) mit kräftigen Endstücken.
|
||||
#[default]
|
||||
#[serde(rename = "full")]
|
||||
Full,
|
||||
/// Nur die Endstücke (und Knickstücke).
|
||||
#[serde(rename = "ends")]
|
||||
Ends,
|
||||
/// Keine Linie.
|
||||
#[serde(rename = "none")]
|
||||
None,
|
||||
#[serde(other)]
|
||||
#[ts(skip)]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// [276] Marke einer Schnitt-/Ansichtslinie: Pfeil (Schenkel in Blickrichtung mit Dreieck), L (nur Schenkel), gefülltes
|
||||
/// Dreieck, keine.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
|
||||
pub enum SectionMarker {
|
||||
#[default]
|
||||
#[serde(rename = "arrow")]
|
||||
Arrow,
|
||||
#[serde(rename = "lAngle")]
|
||||
LAngle,
|
||||
#[serde(rename = "triangle")]
|
||||
Triangle,
|
||||
#[serde(rename = "none")]
|
||||
None,
|
||||
#[serde(other)]
|
||||
#[ts(skip)]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// [276] An welchem Ende einer Schnittlinie die Marke steht.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
|
||||
pub enum SectionMarkerAt {
|
||||
#[default]
|
||||
#[serde(rename = "both")]
|
||||
Both,
|
||||
#[serde(rename = "start")]
|
||||
Start,
|
||||
#[serde(rename = "end")]
|
||||
End,
|
||||
#[serde(other)]
|
||||
#[ts(skip)]
|
||||
Unknown,
|
||||
|
||||
@@ -23,6 +23,65 @@ const SECTION_LINE_DASH: [f64; 4] = super::line_pattern::SECTION_LINE;
|
||||
/// [176] Beschriftungshöhe in Papier-mm (Modell-Meter = mm · Massstab/1000).
|
||||
const SECTION_LABEL_MM: f64 = 3.5;
|
||||
|
||||
/// [276] Farbe, Strichstärken und Linientyp einer Schnitt-/Ansichtslinie: Stift (aktiver Stiftsatz) > Linientyp > Basis.
|
||||
struct LineInk {
|
||||
color: String,
|
||||
main_w: f64,
|
||||
mark_w: f64,
|
||||
main_dash: Option<Vec<f64>>,
|
||||
piece_dash: Option<Vec<f64>>,
|
||||
zigzag: Option<LineStyleZigzag>,
|
||||
motif: Option<LineStyleMotif>,
|
||||
/// Zickzack/Motiv gelten für die Hauptlinie (`full`) bzw. die Endstücke (`ends`).
|
||||
styled_ends: bool,
|
||||
}
|
||||
|
||||
fn line_ink(p: &Project, level: &DrawingLevel, look: &crate::plan::misc::SectionLook) -> LineInk {
|
||||
let ls = level.line_style_id.as_deref().filter(|s| !s.is_empty()).and_then(|id| p.line_style(id));
|
||||
let pen = level.line_pen_id.as_deref().filter(|s| !s.is_empty()).and_then(|id| {
|
||||
let set = p.pen_sets.as_deref()?.iter().find(|s| Some(&s.id) == p.active_pen_set_id.as_ref())?;
|
||||
Some(set.pens.get(id).map_or((crate::pens::PEN_FALLBACK_COLOR.to_string(), crate::pens::PEN_FALLBACK_WEIGHT), |st| (st.color.clone(), st.weight)))
|
||||
});
|
||||
let ends = look.line == SectionLineMode::Ends;
|
||||
let pen_w = pen.as_ref().map(|x| x.1).filter(|w| w.is_finite() && *w > 0.0);
|
||||
let color = pen.as_ref().map(|x| x.0.clone()).or_else(|| ls.map(|l| l.color.clone()).filter(|c| !c.is_empty())).unwrap_or_else(|| SECTION_LINE_INK.to_string());
|
||||
LineInk {
|
||||
color,
|
||||
main_w: pen_w.unwrap_or(SECTION_LINE_MM),
|
||||
mark_w: if ends || look.line == SectionLineMode::None { pen_w.unwrap_or(SECTION_LINE_MARK_MM) } else { pen_w.map_or(SECTION_LINE_MARK_MM, |w| w.max(SECTION_LINE_MARK_MM)) },
|
||||
main_dash: match ls {
|
||||
Some(l) => l.dash.clone().filter(|d| !d.is_empty()),
|
||||
None => Some(SECTION_LINE_DASH.to_vec()),
|
||||
},
|
||||
piece_dash: if ends { ls.and_then(|l| l.dash.clone()).filter(|d| !d.is_empty()) } else { None },
|
||||
zigzag: ls.filter(|l| l.kind == Some(LineStyleKind::Zigzag)).and_then(|l| l.zigzag.clone()),
|
||||
motif: ls.filter(|l| l.kind == Some(LineStyleKind::Custom)).and_then(|l| l.motif.clone()),
|
||||
styled_ends: ends,
|
||||
}
|
||||
}
|
||||
|
||||
impl LineInk {
|
||||
/// Linie `a`–`b`: `main` = dünne Hauptlinie, sonst kräftiges Stück bzw. Schenkel.
|
||||
fn line(&self, a: Vec2, b: Vec2, main: bool, greyed: Option<bool>) -> Primitive {
|
||||
let styled = main != self.styled_ends;
|
||||
Primitive::Line {
|
||||
a,
|
||||
b,
|
||||
cls: "section-line".into(),
|
||||
weight_mm: if main { self.main_w } else { self.mark_w },
|
||||
dash: if main { Some(self.main_dash.clone()) } else { self.piece_dash.clone().map(Some) },
|
||||
zigzag: if styled { self.zigzag.clone() } else { None },
|
||||
motif: if styled { self.motif.clone() } else { None },
|
||||
color: Some(self.color.clone().into()),
|
||||
drawing_id: None,
|
||||
opening_id: None,
|
||||
stair_id: None,
|
||||
greyed,
|
||||
opacity: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn v2(x: f64, y: f64) -> Vec2 {
|
||||
Vec2 { x, y }
|
||||
}
|
||||
@@ -926,6 +985,24 @@ pub fn section_label_tag(name: &str) -> String {
|
||||
/// die Bezeichnung waagrecht dahinter (auf der dem Blick abgewandten Seite); Pick-Band über Dreieck und Text.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn view_marker(c: &Ctx, level: &DrawingLevel, p0: Vec2, p1: Vec2, sign: f64, k: f64, tag: &str, greyed: Option<bool>, obst: &mut super::stamp_place::Obstacles, out: &mut Vec<Primitive>) {
|
||||
let look = c.mv().mark_look(level);
|
||||
let ink = line_ink(c.p, level, &look);
|
||||
// [276] Die Linie selbst (Basis: keine) liegt exakt auf der Ansichtslinie.
|
||||
{
|
||||
let f = crate::plan::misc::view_line_parts((p0.x, p0.y), (p1.x, p1.y), k, &look);
|
||||
let mut i = 1;
|
||||
for _ in 0..f.first().copied().unwrap_or(0.0) as usize {
|
||||
let (a, b) = (v2(f[i + 2], f[i + 3]), v2(f[i + 4], f[i + 5]));
|
||||
let main = f[i + 1] == 0.0;
|
||||
let pieces = if main { c.cut_at_gaps(a, b) } else { vec![(a, b)] };
|
||||
for (a, b) in pieces {
|
||||
let line = ink.line(a, b, main, greyed);
|
||||
obst.add_prim(&line);
|
||||
out.push(line);
|
||||
}
|
||||
i += 6;
|
||||
}
|
||||
}
|
||||
let h = SECTION_LABEL_MM * k;
|
||||
let w = crate::text_layout::text_width_em(tag, false) * h;
|
||||
// [199] Steht der Marker auf der Bemassung (Massketten rücken bei 1:200 auf 7 mm Abstand hinaus), rückt er
|
||||
@@ -937,7 +1014,7 @@ fn view_marker(c: &Ctx, level: &DrawingLevel, p0: Vec2, p1: Vec2, sign: f64, k:
|
||||
let ul = if len > 1e-9 { v2((p1.x - p0.x) / len, (p1.y - p0.y) / len) } else { v2(0.0, 0.0) };
|
||||
let at = |(s, t): (f64, f64)| {
|
||||
let (dx, dy) = (-bn.x * s + ul.x * t, -bn.y * s + ul.y * t);
|
||||
crate::plan::misc::view_marker_sized(p0.x + dx, p0.y + dy, p1.x + dx, p1.y + dy, sign, k, w)
|
||||
crate::plan::misc::view_symbol(p0.x + dx, p0.y + dy, p1.x + dx, p1.y + dy, sign, k, w, look.marker, look.label)
|
||||
};
|
||||
let band = |f: &[f64]| -> Option<Vec<[f64; 2]>> {
|
||||
let mut i = 1;
|
||||
@@ -945,6 +1022,7 @@ fn view_marker(c: &Ctx, level: &DrawingLevel, p0: Vec2, p1: Vec2, sign: f64, k:
|
||||
match f.get(i).copied()? {
|
||||
3.0 => i += 7,
|
||||
5.0 => i += 3,
|
||||
2.0 => i += 6,
|
||||
_ => return Some((0..4).map(|j| [f[i + 1 + 2 * j], f[i + 2 + 2 * j]]).collect()),
|
||||
}
|
||||
}
|
||||
@@ -965,6 +1043,7 @@ fn view_marker(c: &Ctx, level: &DrawingLevel, p0: Vec2, p1: Vec2, sign: f64, k:
|
||||
out.push(vec![[x - pad, y - pad], [x + w + pad, y - pad], [x + w + pad, y + 0.75 * h + pad], [x - pad, y + 0.75 * h + pad]]);
|
||||
i += 3;
|
||||
}
|
||||
Some(2.0) => i += 6,
|
||||
Some(_) => i += 9,
|
||||
None => break,
|
||||
}
|
||||
@@ -986,13 +1065,18 @@ fn view_marker(c: &Ctx, level: &DrawingLevel, p0: Vec2, p1: Vec2, sign: f64, k:
|
||||
}
|
||||
let mut i = 1;
|
||||
for _ in 0..f[0] as usize {
|
||||
if f[i] == 3.0 {
|
||||
if f[i] == 2.0 {
|
||||
let line = ink.line(v2(f[i + 2], f[i + 3]), v2(f[i + 4], f[i + 5]), false, greyed);
|
||||
obst.add_prim(&line);
|
||||
out.push(line);
|
||||
i += 6;
|
||||
} else if f[i] == 3.0 {
|
||||
let pts: Vec<Vec2> = (0..3).map(|j| v2(f[i + 1 + 2 * j], f[i + 2 + 2 * j])).collect();
|
||||
let ring: Vec<[f64; 2]> = pts.iter().map(|q| [q.x, q.y]).collect();
|
||||
obst.area(ring);
|
||||
let mut tri = pick_band(pts, None, None);
|
||||
if let Primitive::Polygon { fill, .. } = &mut tri {
|
||||
*fill = SECTION_LINE_INK.into();
|
||||
*fill = ink.color.clone().into();
|
||||
}
|
||||
out.push(tri);
|
||||
i += 7;
|
||||
@@ -1009,7 +1093,7 @@ fn view_marker(c: &Ctx, level: &DrawingLevel, p0: Vec2, p1: Vec2, sign: f64, k:
|
||||
text: tag.to_string(),
|
||||
height_m: h,
|
||||
angle: 0.0,
|
||||
color: SECTION_LINE_INK.into(),
|
||||
color: ink.color.clone().into(),
|
||||
marks: None,
|
||||
wrap_width: None,
|
||||
doc: None,
|
||||
@@ -1041,7 +1125,7 @@ pub fn plan_section_lines(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
let k = n / 1000.0;
|
||||
// [157] Beschriftungen zuletzt: sie weichen Masszahlen, Texten, Achsblasen, allen Linien und Marken der
|
||||
// Schnittführungen und den schon gesetzten Beschriftungen aus.
|
||||
let mut labels: Vec<(Vec2, String, Vec2, Vec2)> = Vec::new();
|
||||
let mut labels: Vec<(Vec2, String, Vec2, Vec2, String)> = Vec::new();
|
||||
let mut obst = super::stamp_place::Obstacles::default();
|
||||
// [270] Erst die Schnitte, dann die Ansichtsmarken: diese weichen den Schnittmarken aus (`view_marker`).
|
||||
let sections = c.p.drawing_levels.iter().filter(|l| matches!(l.kind, DrawingLevelKind::Section));
|
||||
@@ -1059,7 +1143,10 @@ pub fn plan_section_lines(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
let mut path: Vec<(f64, f64)> = vec![(p0.x, p0.y)];
|
||||
path.extend(level.bend_points.iter().flatten().map(|q| (q.x, q.y)));
|
||||
path.push((p1.x, p1.y));
|
||||
let f = crate::plan::misc::section_polyline_styled(&path, sign, k, label_w, c.mv().section_marker(level.marker_style));
|
||||
let look = c.mv().mark_look(level);
|
||||
let ink = line_ink(c.p, level, &look);
|
||||
let marked = look.marked_ends();
|
||||
let f = crate::plan::misc::section_polyline_look(&path, sign, k, label_w, &look);
|
||||
if f.is_empty() {
|
||||
continue;
|
||||
}
|
||||
@@ -1083,21 +1170,7 @@ pub fn plan_section_lines(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
// Musterhaus komplex EG/DG); die kräftigen Endstücke bleiben ganz.
|
||||
let pieces = if main { c.cut_at_gaps(a, b) } else { vec![(a, b)] };
|
||||
for (a, b) in pieces {
|
||||
let line = Primitive::Line {
|
||||
a,
|
||||
b,
|
||||
cls: "section-line".into(),
|
||||
weight_mm: if main { SECTION_LINE_MM } else { SECTION_LINE_MARK_MM },
|
||||
dash: main.then(|| Some(SECTION_LINE_DASH.to_vec())),
|
||||
zigzag: None,
|
||||
motif: None,
|
||||
color: Some(SECTION_LINE_INK.into()),
|
||||
drawing_id: None,
|
||||
opening_id: None,
|
||||
stair_id: None,
|
||||
greyed,
|
||||
opacity: None,
|
||||
};
|
||||
let line = ink.line(a, b, main, greyed);
|
||||
obst.add_prim(&line);
|
||||
out.push(line);
|
||||
}
|
||||
@@ -1108,14 +1181,14 @@ pub fn plan_section_lines(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
obst.area(pts.iter().map(|q| [q.x, q.y]).collect());
|
||||
let mut tri = pick_band(pts, None, None);
|
||||
if let Primitive::Polygon { fill, .. } = &mut tri {
|
||||
*fill = SECTION_LINE_INK.into();
|
||||
*fill = ink.color.clone().into();
|
||||
}
|
||||
out.push(tri);
|
||||
i += 7;
|
||||
} else if f[i] == 5.0 {
|
||||
let (outward, bn) = ends[end_no.min(1)];
|
||||
let (outward, bn) = ends[marked.get(end_no).copied().unwrap_or(1).min(1)];
|
||||
end_no += 1;
|
||||
labels.push((v2(f[i + 1], f[i + 2]), tag.clone(), bn, outward));
|
||||
labels.push((v2(f[i + 1], f[i + 2]), tag.clone(), bn, outward, ink.color.clone()));
|
||||
i += 3;
|
||||
} else {
|
||||
let pts = (0..4).map(|j| v2(f[i + 1 + 2 * j], f[i + 2 + 2 * j])).collect();
|
||||
@@ -1158,7 +1231,7 @@ pub fn plan_section_lines(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
let cost = |&(so, sb): &(f64, f64)| so.hypot(sb) + if sb < 0.0 || so < 0.0 { 0.5 } else { 0.0 };
|
||||
steps.sort_by(|a, b| cost(a).total_cmp(&cost(b)).then(a.0.total_cmp(&b.0).reverse()).then(a.1.total_cmp(&b.1).reverse()));
|
||||
let steps = &steps;
|
||||
for (at, tag, bn, outward) in labels {
|
||||
for (at, tag, bn, outward, ink_color) in labels {
|
||||
let w = crate::text_layout::text_width_em(&tag, false) * h;
|
||||
let rect = |a: Vec2| -> Vec<[f64; 2]> {
|
||||
let pad = 0.1 * h;
|
||||
@@ -1179,7 +1252,7 @@ pub fn plan_section_lines(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
text: tag,
|
||||
height_m: h,
|
||||
angle: 0.0,
|
||||
color: SECTION_LINE_INK.into(),
|
||||
color: ink_color.into(),
|
||||
marks: None,
|
||||
wrap_width: None,
|
||||
doc: None,
|
||||
@@ -1401,36 +1474,108 @@ mod tests {
|
||||
assert!((ost[1][0] - 15.0).abs() < 1e-9 && ((ost[1][1] + ost[2][1]) / 2.0 - 5.0).abs() < 1e-9, "Ost bleibt in der Mitte: {ost:?}");
|
||||
}
|
||||
|
||||
/// [176] Schnittmarke als L: Ebenenfeld `markerStyle` bzw. Vorgabe der Modelldarstellung (`sectionMarks.style`);
|
||||
/// Ebene > Modelldarstellung > Pfeil. L: keine dünne Linie, kein Dreieck.
|
||||
/// Projekt mit einem Schnitt (`kind` "section") oder einer Ansicht; `lv` ergänzt Felder der Ebene, `mv` die Modelldarstellung "m".
|
||||
fn look_project(kind: &str, lv: serde_json::Value, mv: Option<serde_json::Value>) -> Project {
|
||||
let mut lvl = serde_json::json!({ "id": "s", "name": "Schnitt A-A", "kind": kind, "visible": true, "locked": false,
|
||||
"linePoints": [{ "x": 0.0, "y": 0.0 }, { "x": 10.0, "y": 0.0 }] });
|
||||
for (k, v) in lv.as_object().unwrap() {
|
||||
lvl[k] = v.clone();
|
||||
}
|
||||
let mut p = Project { drawing_levels: vec![serde_json::from_value(lvl).unwrap()], ..Default::default() };
|
||||
if let Some(m) = mv {
|
||||
let mut o = serde_json::json!({ "id": "m", "name": "M" });
|
||||
for (k, v) in m.as_object().unwrap() {
|
||||
o[k] = v.clone();
|
||||
}
|
||||
p.model_view_options = Some(vec![serde_json::from_value(o).unwrap()]);
|
||||
}
|
||||
p
|
||||
}
|
||||
|
||||
fn run_lines(p: &Project, mv: bool) -> Vec<Primitive> {
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"show": ["02", "90"], "scale": 100, "global": true{}}}"#, if mv { r#", "modelView": "m""# } else { "" })).unwrap();
|
||||
let mut out = Vec::new();
|
||||
plan_section_lines(&Ctx::new(p, &a), &mut out);
|
||||
out
|
||||
}
|
||||
|
||||
/// (dünne Linien, kräftige Linien, Dreiecke, Texte)
|
||||
fn count_parts(out: &[Primitive]) -> (usize, usize, usize, usize) {
|
||||
let thin = out.iter().filter(|q| matches!(q, Primitive::Line { dash: Some(_), .. })).count();
|
||||
let heavy = out.iter().filter(|q| matches!(q, Primitive::Line { dash: None, weight_mm, .. } if *weight_mm > 0.4)).count();
|
||||
let tri = out.iter().filter(|q| matches!(q, Primitive::Polygon { fill, .. } if fill != "none")).count();
|
||||
let txt = out.iter().filter(|q| matches!(q, Primitive::DrawingText { .. })).count();
|
||||
(thin, heavy, tri, txt)
|
||||
}
|
||||
|
||||
/// [176] Schnittmarke als L: Ebenenfeld `marker`/`lineMode` bzw. Vorgabe der Modelldarstellung (`sectionMarks`); die
|
||||
/// Ebene geht vor. L mit "ends": keine dünne Linie, kein Dreieck.
|
||||
#[test]
|
||||
fn schnittmarke_als_l_nach_ebene_und_modelldarstellung() {
|
||||
let mk = |style: Option<&str>| -> Project {
|
||||
let mut lv = serde_json::json!({ "id": "s", "name": "Schnitt A-A", "kind": "section", "visible": true, "locked": false,
|
||||
"linePoints": [{ "x": 0.0, "y": 0.0 }, { "x": 10.0, "y": 0.0 }] });
|
||||
if let Some(st) = style {
|
||||
lv["markerStyle"] = st.into();
|
||||
}
|
||||
let mut p = Project { drawing_levels: vec![serde_json::from_value(lv).unwrap()], ..Default::default() };
|
||||
p.model_view_options = Some(vec![serde_json::from_value(serde_json::json!({ "id": "m", "name": "M", "sectionMarks": { "style": "lAngle" } })).unwrap()]);
|
||||
p
|
||||
};
|
||||
let run = |p: &Project, mv: bool| {
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"show": ["02", "90"], "scale": 100, "global": true{}}}"#, if mv { r#", "modelView": "m""# } else { "" })).unwrap();
|
||||
let mut out = Vec::new();
|
||||
plan_section_lines(&Ctx::new(p, &a), &mut out);
|
||||
out
|
||||
};
|
||||
let is_l = |out: &[Primitive]| !out.iter().any(|q| matches!(q, Primitive::Line { dash: Some(_), .. })) && !out.iter().any(|q| matches!(q, Primitive::Polygon { fill, .. } if fill != "none"));
|
||||
let heavy = |out: &[Primitive]| out.iter().filter(|q| matches!(q, Primitive::Line { weight_mm, .. } if *weight_mm > 0.4)).count();
|
||||
assert!(!is_l(&run(&mk(None), false)), "Basis = Pfeil");
|
||||
assert!(!is_l(&run(&mk(None), false)));
|
||||
let l = run(&mk(Some("lAngle")), false);
|
||||
assert!(is_l(&l));
|
||||
assert_eq!(heavy(&l), 4, "je Ende zwei Schenkel");
|
||||
assert_eq!(l.iter().filter(|q| matches!(q, Primitive::DrawingText { .. })).count(), 2);
|
||||
assert!(is_l(&run(&mk(None), true)), "Vorgabe der Modelldarstellung");
|
||||
assert!(!is_l(&run(&mk(Some("arrow")), true)), "Ebene geht vor");
|
||||
let mvl = serde_json::json!({ "sectionMarks": { "lineMode": "ends", "marker": "lAngle" } });
|
||||
let base = run_lines(&look_project("section", serde_json::json!({}), Some(mvl.clone())), false);
|
||||
let (thin, heavy, tri, txt) = count_parts(&base);
|
||||
assert!(thin == 1 && tri == 2 && heavy == 4 && txt == 2, "Basis = Pfeil: {:?}", count_parts(&base));
|
||||
let l = run_lines(&look_project("section", serde_json::json!({ "lineMode": "ends", "marker": "lAngle" }), None), false);
|
||||
assert_eq!(count_parts(&l), (0, 4, 0, 2), "je Ende zwei Schenkel");
|
||||
let via_mv = run_lines(&look_project("section", serde_json::json!({}), Some(mvl.clone())), true);
|
||||
assert_eq!(count_parts(&via_mv), (0, 4, 0, 2), "Vorgabe der Modelldarstellung");
|
||||
let ebene = run_lines(&look_project("section", serde_json::json!({ "marker": "arrow", "lineMode": "full" }), Some(mvl)), true);
|
||||
assert_eq!(count_parts(&ebene), (1, 4, 2, 2), "Ebene geht vor");
|
||||
}
|
||||
|
||||
/// [276] Varianten im Grundriss: Linie keine/Enden, Dreieck, nur Anfang, ohne Beschriftung; Pick-Band bleibt immer.
|
||||
#[test]
|
||||
fn schnittlinie_varianten_im_grundriss() {
|
||||
let run = |lv: serde_json::Value| run_lines(&look_project("section", lv, None), false);
|
||||
assert_eq!(count_parts(&run(serde_json::json!({ "lineMode": "none", "marker": "triangle" }))), (0, 0, 2, 2));
|
||||
assert_eq!(count_parts(&run(serde_json::json!({ "lineMode": "none", "marker": "none", "markerLabel": false }))), (0, 0, 0, 0));
|
||||
assert_eq!(count_parts(&run(serde_json::json!({ "markerAt": "start" }))), (1, 3, 1, 1));
|
||||
assert_eq!(count_parts(&run(serde_json::json!({ "markerLabel": false }))), (1, 4, 2, 0));
|
||||
let leer = run(serde_json::json!({ "lineMode": "none", "marker": "none", "markerLabel": false }));
|
||||
assert!(leer.iter().any(|q| matches!(q, Primitive::Polygon { section_line_id: Some(_), .. })), "Pick-Band bleibt");
|
||||
// Nur Anfang: die Beschriftung steht am Anfang (links, x < 0), nicht am Ende.
|
||||
let start = run(serde_json::json!({ "markerAt": "start" }));
|
||||
let x = start.iter().find_map(|q| if let Primitive::DrawingText { at, .. } = q { Some(at.x) } else { None }).unwrap();
|
||||
assert!(x < 3.0, "Anfang: {x}");
|
||||
let end = run(serde_json::json!({ "markerAt": "end" }));
|
||||
let x = end.iter().find_map(|q| if let Primitive::DrawingText { at, .. } = q { Some(at.x) } else { None }).unwrap();
|
||||
assert!(x > 7.0, "Ende: {x}");
|
||||
}
|
||||
|
||||
/// [276] Linientyp und Stift der Linie: Stift (Farbe, Stärke) und Linientyp (Muster) wirken auf die Hauptlinie.
|
||||
#[test]
|
||||
fn schnittlinie_linientyp_und_stift() {
|
||||
let mut p = look_project("section", serde_json::json!({ "lineStyleId": "ls", "linePenId": "pen" }), None);
|
||||
p.line_styles.push(serde_json::from_value(serde_json::json!({ "id": "ls", "name": "Punkt", "color": "#00ff00", "dash": [0.0, 1.0] })).unwrap());
|
||||
p.active_pen_set_id = Some("set".into());
|
||||
p.pen_sets = Some(vec![serde_json::from_value(serde_json::json!({ "id": "set", "name": "S", "pens": { "pen": { "color": "#ff0000", "weight": 0.35 } } })).unwrap()]);
|
||||
let out = run_lines(&p, false);
|
||||
let main = out.iter().find_map(|q| match q {
|
||||
Primitive::Line { dash: Some(d), weight_mm, color, .. } => Some((d.clone(), *weight_mm, color.clone())),
|
||||
_ => None,
|
||||
});
|
||||
let (d, w, col) = main.expect("Hauptlinie");
|
||||
assert_eq!(d, Some(vec![0.0, 1.0]));
|
||||
assert!((w - 0.35).abs() < 1e-12);
|
||||
assert_eq!(col.as_deref(), Some("#ff0000"));
|
||||
// Ohne Stift: Farbe des Linientyps.
|
||||
p.drawing_levels[0].line_pen_id = None;
|
||||
let out = run_lines(&p, false);
|
||||
assert!(out.iter().any(|q| matches!(q, Primitive::Line { color: Some(c), dash: Some(_), .. } if &**c == "#00ff00")));
|
||||
}
|
||||
|
||||
/// [276] Ansicht: Basis wie bisher (nur Dreieck + Bezeichnung, keine Linie); mit Linie, Pfeil oder ohne Zeichen.
|
||||
#[test]
|
||||
fn ansichtslinie_varianten() {
|
||||
let run = |lv: serde_json::Value| run_lines(&look_project("elevation", lv, None), false);
|
||||
assert_eq!(count_parts(&run(serde_json::json!({}))), (0, 0, 1, 1));
|
||||
assert_eq!(count_parts(&run(serde_json::json!({ "lineMode": "full" }))), (1, 2, 1, 1));
|
||||
assert_eq!(count_parts(&run(serde_json::json!({ "lineMode": "ends", "marker": "none" }))), (0, 2, 0, 1));
|
||||
assert_eq!(count_parts(&run(serde_json::json!({ "marker": "arrow" }))), (0, 1, 1, 1));
|
||||
assert_eq!(count_parts(&run(serde_json::json!({ "marker": "none", "markerLabel": false }))), (0, 0, 0, 0));
|
||||
let mv = serde_json::json!({ "elevationMarks": { "lineMode": "full" } });
|
||||
assert_eq!(count_parts(&run_lines(&look_project("elevation", serde_json::json!({}), Some(mv)), true)), (1, 2, 1, 1), "Vorgabe Ansichten");
|
||||
}
|
||||
|
||||
/// [176] Geknickter Schnitt: Knickpunkte aus `bendPoints` erscheinen als kräftige Stücke im Grundriss; ohne
|
||||
|
||||
+227
-70
@@ -15,9 +15,10 @@
|
||||
//! 5 label [5, x, y] (unten links; Kurz-Tag setzt der Aufrufer)
|
||||
//! 1 polygon [1, x0, y0 … x3, y3] (unsichtbares Pick-Band)
|
||||
//! ```
|
||||
//! L-Marke ([176], `SectionMarkerStyle::LAngle`): `section_polyline_styled(.., LAngle)` → je Ende zwei kräftige Linien
|
||||
//! (langer Schenkel längs der Linie nach innen, kurzer in Blickrichtung), Label, an Knicken Knickstücke; keine Linie dazwischen,
|
||||
//! kein Dreieck, Pick-Band je Segment.
|
||||
//! Darstellung ([276], [`SectionLook`]): Linie `full` (dünn + kräftige Endstücke) | `ends` (nur Endstücke) | `none`; Marke je Ende
|
||||
//! (`markerAt`) `arrow` (Schenkel + Dreieck) | `lAngle` (Schenkel, mit dem Endstück ein L) | `triangle` | `none`; Beschriftung an/aus.
|
||||
//! `section_polyline_look`; Ansicht: `view_symbol` (Zeichen in der Mitte), `view_line_parts` (Linie).
|
||||
|
||||
//! Ansicht ([176]): `view_marker_sized` → `[n, 3 triangle (flach), 5 label, 1 polygon]`, kein Kreis.
|
||||
//!
|
||||
//! ## Linienende
|
||||
@@ -31,7 +32,7 @@
|
||||
|
||||
use crate::jsmath::hypot2;
|
||||
use crate::jsnum::round;
|
||||
use crate::model::SectionMarkerStyle;
|
||||
use crate::model::{SectionLineMode, SectionMarker, SectionMarkerAt};
|
||||
use std::collections::HashSet;
|
||||
|
||||
const FOOTPRINT_Z_TOL: f64 = 0.6;
|
||||
@@ -49,6 +50,9 @@ const L_SHORT_MM: f64 = 6.0;
|
||||
/// [176] Ansichtsmarker: flaches gefülltes Dreieck, Basis 6 mm, Höhe 3 mm in Blickrichtung.
|
||||
const VIEW_MARKER_HEIGHT_MM: f64 = 3.0;
|
||||
const VIEW_MARKER_HALF_MM: f64 = 3.0;
|
||||
/// [276] Marke „Dreieck" an Schnittenden: Höhe und halbe Basis in Papier-mm.
|
||||
const TRIANGLE_HEIGHT_MM: f64 = 4.5;
|
||||
const TRIANGLE_HALF_MM: f64 = 2.0;
|
||||
const ARROW_ASPECT: f64 = 0.32;
|
||||
|
||||
/// Ganzzahl-Schlüssel für die Quantisierung; NaN/∞ bekommen feste Platzhalter (wie ihre Textform in JS).
|
||||
@@ -168,15 +172,72 @@ pub fn section_line_sized(p0x: f64, p0y: f64, p1x: f64, p1y: f64, sign: f64, mm:
|
||||
/// Stücke (6 mm) auf beiden Seiten; Schenkel/Dreieck/Beschriftung an den Enden gehören zum ersten bzw. letzten
|
||||
/// Segment; je Segment ein Pick-Band. Mit zwei Punkten identisch zur geraden Linie. Segmente unter 1 µm entfallen.
|
||||
pub fn section_polyline_sized(pts: &[(f64, f64)], sign: f64, mm: f64, label_w: f64) -> Vec<f64> {
|
||||
section_polyline_styled(pts, sign, mm, label_w, SectionMarkerStyle::Arrow)
|
||||
section_polyline_look(pts, sign, mm, label_w, &SectionLook::default())
|
||||
}
|
||||
|
||||
/// [176] Wie [`section_polyline_sized`] mit Markentyp: `Arrow` = bisher; `LAngle` = an jedem Ende ein L (langer Schenkel
|
||||
/// 12 mm längs der Linie nach innen, kurzer 6 mm in Blickrichtung, beide kräftig), keine Linie dazwischen und kein Dreieck;
|
||||
/// die Beschriftung steht waagrecht neben dem Ende des kurzen Schenkels, ausserhalb der Linie. An Knicken die
|
||||
/// Knickstücke wie beim Pfeil.
|
||||
pub fn section_polyline_styled(pts: &[(f64, f64)], sign: f64, mm: f64, label_w: f64, style: SectionMarkerStyle) -> Vec<f64> {
|
||||
let l_angle = style == SectionMarkerStyle::LAngle;
|
||||
/// [276] Darstellung einer Schnittlinie: Linie, Endstücke, Marke und Beschriftung.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct SectionLook {
|
||||
pub line: SectionLineMode,
|
||||
/// Länge der Endstücke in Papier-mm (an Knicken die Hälfte).
|
||||
pub end_mm: f64,
|
||||
pub marker: SectionMarker,
|
||||
pub at: SectionMarkerAt,
|
||||
pub label: bool,
|
||||
}
|
||||
|
||||
impl Default for SectionLook {
|
||||
/// Heutiges Bild des Schnitts: dünne Linie mit kräftigen Endstücken, Pfeil an beiden Enden, Beschriftung.
|
||||
fn default() -> Self {
|
||||
SectionLook { line: SectionLineMode::Full, end_mm: SECTION_END_PIECE_MM, marker: SectionMarker::Arrow, at: SectionMarkerAt::Both, label: true }
|
||||
}
|
||||
}
|
||||
|
||||
impl SectionLook {
|
||||
/// Welche Enden eine Marke tragen (0 = Anfang, 1 = Ende).
|
||||
pub fn marked_ends(&self) -> Vec<usize> {
|
||||
if self.marker == SectionMarker::None && !self.label {
|
||||
return Vec::new();
|
||||
}
|
||||
match self.at {
|
||||
SectionMarkerAt::Start => vec![0],
|
||||
SectionMarkerAt::End => vec![1],
|
||||
_ => vec![0, 1],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// [276] Die Linienstücke einer Linie `pts` nach `look.line`: `[2, art, ax, ay, bx, by]` je Stück (Art 0 dünne Hauptlinie,
|
||||
/// Art 1 kräftiges End-/Knickstück), Endstücke höchstens ein Drittel des Segments.
|
||||
fn line_parts(pts: &[(f64, f64)], dirs: &[(f64, f64)], mm: f64, look: &SectionLook, o: &mut Vec<f64>, n: &mut usize) {
|
||||
if look.line == SectionLineMode::None {
|
||||
return;
|
||||
}
|
||||
let segs = pts.len() - 1;
|
||||
let end_mm = if look.end_mm.is_finite() && look.end_mm > 0.0 { look.end_mm } else { SECTION_END_PIECE_MM };
|
||||
let bend_mm = end_mm / 2.0;
|
||||
let mut line = |art: f64, a: (f64, f64), b: (f64, f64)| {
|
||||
o.extend([2.0, art, a.0, a.1, b.0, b.1]);
|
||||
*n += 1;
|
||||
};
|
||||
for i in 0..segs {
|
||||
let (a, b, (ux, uy)) = (pts[i], pts[i + 1], dirs[i]);
|
||||
let len = hypot2(b.0 - a.0, b.1 - a.1);
|
||||
let ps = (if i == 0 { end_mm } else { bend_mm } * mm).min(len / 3.0);
|
||||
let pe = (if i == segs - 1 { end_mm } else { bend_mm } * mm).min(len / 3.0);
|
||||
line(1.0, a, (a.0 + ux * ps, a.1 + uy * ps));
|
||||
if look.line != SectionLineMode::Ends {
|
||||
line(0.0, (a.0 + ux * ps, a.1 + uy * ps), (b.0 - ux * pe, b.1 - uy * pe));
|
||||
}
|
||||
line(1.0, (b.0 - ux * pe, b.1 - uy * pe), b);
|
||||
}
|
||||
}
|
||||
|
||||
/// [176]/[276] Schnittlinie nach `look`: Linie (`line_parts`), je Marke (Ende laut `look.at`): `arrow` = Schenkel (8 mm) in
|
||||
/// Blickrichtung mit gefülltem Dreieck, `lAngle` = Schenkel 6 mm (zusammen mit dem Endstück ein L), `triangle` = nur ein
|
||||
/// gefülltes Dreieck am Ende, `none` = nichts; Beschriftung (wenn `look.label`) vor der Spitze bzw. neben dem Ende;
|
||||
/// je Segment ein Pick-Band. Kurzes Beispiel: `Default` = bisheriger Pfeil.
|
||||
pub fn section_polyline_look(pts: &[(f64, f64)], sign: f64, mm: f64, label_w: f64, look: &SectionLook) -> Vec<f64> {
|
||||
if pts.len() < 2 || !pts.iter().all(|p| p.0.is_finite() && p.1.is_finite()) || ![sign, mm, label_w].iter().all(|x| x.is_finite()) || !(mm > 0.0) {
|
||||
return Vec::new();
|
||||
}
|
||||
@@ -185,10 +246,8 @@ pub fn section_polyline_styled(pts: &[(f64, f64)], sign: f64, mm: f64, label_w:
|
||||
if pts.len() < 2 {
|
||||
return Vec::new();
|
||||
}
|
||||
let leg = SECTION_LEG_MM * mm;
|
||||
let label_h = SECTION_LABEL_MM * mm * 0.75;
|
||||
let segs = pts.len() - 1;
|
||||
// Einheitsrichtung je Segment.
|
||||
let dirs: Vec<(f64, f64)> = (0..segs)
|
||||
.map(|i| {
|
||||
let (ax, ay) = (pts[i + 1].0 - pts[i].0, pts[i + 1].1 - pts[i].1);
|
||||
@@ -198,56 +257,47 @@ pub fn section_polyline_styled(pts: &[(f64, f64)], sign: f64, mm: f64, label_w:
|
||||
.collect();
|
||||
let mut o: Vec<f64> = Vec::new();
|
||||
let mut n = 0usize;
|
||||
let line = |o: &mut Vec<f64>, n: &mut usize, art: f64, a: (f64, f64), b: (f64, f64)| {
|
||||
o.extend([2.0, art, a.0, a.1, b.0, b.1]);
|
||||
*n += 1;
|
||||
};
|
||||
// Endstück: höchstens ein Drittel des Segments, damit bei kurzen Segmenten noch ein dünnes Stück bleibt;
|
||||
// an den Knicken das kürzere Knickstück.
|
||||
for i in 0..segs {
|
||||
let (a, b, (ux, uy)) = (pts[i], pts[i + 1], dirs[i]);
|
||||
let len = hypot2(b.0 - a.0, b.1 - a.1);
|
||||
let ps = (if i == 0 { SECTION_END_PIECE_MM } else { SECTION_BEND_PIECE_MM } * mm).min(len / 3.0);
|
||||
let pe = (if i == segs - 1 { SECTION_END_PIECE_MM } else { SECTION_BEND_PIECE_MM } * mm).min(len / 3.0);
|
||||
if l_angle {
|
||||
// Langer Schenkel am Ende (12 mm), Knickstücke (6 mm) an den Knicken; dazwischen nichts.
|
||||
let (ps, pe) = ((if i == 0 { L_LONG_MM } else { SECTION_BEND_PIECE_MM } * mm).min(len / 3.0), (if i == segs - 1 { L_LONG_MM } else { SECTION_BEND_PIECE_MM } * mm).min(len / 3.0));
|
||||
line(&mut o, &mut n, 1.0, a, (a.0 + ux * ps, a.1 + uy * ps));
|
||||
line(&mut o, &mut n, 1.0, (b.0 - ux * pe, b.1 - uy * pe), b);
|
||||
continue;
|
||||
}
|
||||
line(&mut o, &mut n, 1.0, a, (a.0 + ux * ps, a.1 + uy * ps));
|
||||
line(&mut o, &mut n, 0.0, (a.0 + ux * ps, a.1 + uy * ps), (b.0 - ux * pe, b.1 - uy * pe));
|
||||
line(&mut o, &mut n, 1.0, (b.0 - ux * pe, b.1 - uy * pe), b);
|
||||
}
|
||||
if l_angle {
|
||||
let short = L_SHORT_MM * mm;
|
||||
for (end, (ux, uy), outward) in [(pts[0], dirs[0], -1.0), (pts[segs], dirs[segs - 1], 1.0)] {
|
||||
let (bnx, bny) = (-uy * sign, ux * sign);
|
||||
let tip = (end.0 + bnx * short, end.1 + bny * short);
|
||||
line(&mut o, &mut n, 1.0, end, tip);
|
||||
// Beschriftung neben dem Ende des kurzen Schenkels, nach aussen (längs der Linie, vom Ende weg).
|
||||
let (ox, oy) = (ux * outward, uy * outward);
|
||||
let reach = mm * 1.0 + ox.abs() * label_w / 2.0 + oy.abs() * label_h / 2.0;
|
||||
let (cx, cy) = (tip.0 + ox * reach, tip.1 + oy * reach);
|
||||
line_parts(&pts, &dirs, mm, look, &mut o, &mut n);
|
||||
let (head_l, head_hw) = (SECTION_HEAD_LEN_MM * mm, SECTION_HEAD_HALF_MM * mm);
|
||||
for which in look.marked_ends() {
|
||||
let (end, (ux, uy)) = if which == 0 { (pts[0], dirs[0]) } else { (pts[segs], dirs[segs - 1]) };
|
||||
let (bnx, bny) = (-uy * sign, ux * sign);
|
||||
// Spitze der Marke und Richtung, in der die Beschriftung davor steht.
|
||||
let (tip, label_dir) = match look.marker {
|
||||
SectionMarker::Arrow => {
|
||||
let tip = (end.0 + bnx * SECTION_LEG_MM * mm, end.1 + bny * SECTION_LEG_MM * mm);
|
||||
o.extend([2.0, 1.0, end.0, end.1, tip.0, tip.1]);
|
||||
n += 1;
|
||||
let hb = (tip.0 - bnx * head_l, tip.1 - bny * head_l);
|
||||
o.extend([3.0, tip.0, tip.1, hb.0 + ux * head_hw, hb.1 + uy * head_hw, hb.0 - ux * head_hw, hb.1 - uy * head_hw]);
|
||||
n += 1;
|
||||
(tip, (bnx, bny))
|
||||
}
|
||||
SectionMarker::Triangle => {
|
||||
// Gefülltes Dreieck am Ende, Basis auf der Linie quer zur Blickrichtung (zeigt in Blickrichtung).
|
||||
let tip = (end.0 + bnx * TRIANGLE_HEIGHT_MM * mm, end.1 + bny * TRIANGLE_HEIGHT_MM * mm);
|
||||
let hw = TRIANGLE_HALF_MM * mm;
|
||||
o.extend([3.0, tip.0, tip.1, end.0 + ux * hw, end.1 + uy * hw, end.0 - ux * hw, end.1 - uy * hw]);
|
||||
n += 1;
|
||||
(tip, (bnx, bny))
|
||||
}
|
||||
SectionMarker::LAngle => {
|
||||
let tip = (end.0 + bnx * L_SHORT_MM * mm, end.1 + bny * L_SHORT_MM * mm);
|
||||
o.extend([2.0, 1.0, end.0, end.1, tip.0, tip.1]);
|
||||
n += 1;
|
||||
// Beschriftung neben dem Ende des kurzen Schenkels, nach aussen (längs der Linie, vom Ende weg).
|
||||
(tip, if which == 0 { (-ux, -uy) } else { (ux, uy) })
|
||||
}
|
||||
_ => (end, if which == 0 { (-ux, -uy) } else { (ux, uy) }),
|
||||
};
|
||||
if look.label {
|
||||
// Kastenmitte vor der Spitze: Abstand + halbe Ausdehnung des Kastens in Richtung `label_dir`.
|
||||
let reach = mm * 1.0 + label_dir.0.abs() * label_w / 2.0 + label_dir.1.abs() * label_h / 2.0;
|
||||
let (cx, cy) = (tip.0 + label_dir.0 * reach, tip.1 + label_dir.1 * reach);
|
||||
o.extend([5.0, cx - label_w / 2.0, cy - label_h / 2.0]);
|
||||
n += 1;
|
||||
}
|
||||
}
|
||||
let (head_l, head_hw) = (SECTION_HEAD_LEN_MM * mm, SECTION_HEAD_HALF_MM * mm);
|
||||
for (end, (ux, uy)) in if l_angle { vec![] } else { vec![(pts[0], dirs[0]), (pts[segs], dirs[segs - 1])] } {
|
||||
let (bnx, bny) = (-uy * sign, ux * sign);
|
||||
let tip = (end.0 + bnx * leg, end.1 + bny * leg);
|
||||
line(&mut o, &mut n, 1.0, end, tip);
|
||||
let hb = (tip.0 - bnx * head_l, tip.1 - bny * head_l);
|
||||
o.extend([3.0, tip.0, tip.1, hb.0 + ux * head_hw, hb.1 + uy * head_hw, hb.0 - ux * head_hw, hb.1 - uy * head_hw]);
|
||||
n += 1;
|
||||
// Kastenmitte vor der Spitze: Abstand + halbe Ausdehnung des Kastens in Pfeilrichtung.
|
||||
let reach = mm * 1.0 + bnx.abs() * label_w / 2.0 + bny.abs() * label_h / 2.0;
|
||||
let (cx, cy) = (tip.0 + bnx * reach, tip.1 + bny * reach);
|
||||
o.extend([5.0, cx - label_w / 2.0, cy - label_h / 2.0]);
|
||||
n += 1;
|
||||
}
|
||||
let ph = SECTION_PICK_HALF.max(1.2 * mm);
|
||||
for i in 0..segs {
|
||||
let (a, b, (ux, uy)) = (pts[i], pts[i + 1], dirs[i]);
|
||||
@@ -268,6 +318,14 @@ pub fn section_polyline_styled(pts: &[(f64, f64)], sign: f64, mm: f64, label_w:
|
||||
/// `5 label [5, x, y]` (unten links) und `1 polygon` (Pick-Band über Dreieck und Text). Kein Kreis, keine Linie.
|
||||
/// Leer bei zu kurzer Linie oder Unsinn.
|
||||
pub fn view_marker_sized(p0x: f64, p0y: f64, p1x: f64, p1y: f64, sign: f64, mm: f64, label_w: f64) -> Vec<f64> {
|
||||
view_symbol(p0x, p0y, p1x, p1y, sign, mm, label_w, SectionMarker::Triangle, true)
|
||||
}
|
||||
|
||||
/// [276] Ansichtsmarke nach Art: `Triangle` = wie [`view_marker_sized`]; `Arrow` = kräftiger Schenkel (8 mm) in Blickrichtung
|
||||
/// mit gefülltem Dreieck (Eintrag `2 line` + `3 triangle`); sonst (`None`) kein Zeichen. Bezeichnung (wenn `label`) hinter
|
||||
/// der Mitte der Linie; das Pick-Band reicht über Zeichen und Text.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn view_symbol(p0x: f64, p0y: f64, p1x: f64, p1y: f64, sign: f64, mm: f64, label_w: f64, marker: SectionMarker, label: bool) -> Vec<f64> {
|
||||
if ![p0x, p0y, p1x, p1y, sign, mm, label_w].iter().all(|x| x.is_finite()) || !(mm > 0.0) {
|
||||
return Vec::new();
|
||||
}
|
||||
@@ -279,22 +337,56 @@ pub fn view_marker_sized(p0x: f64, p0y: f64, p1x: f64, p1y: f64, sign: f64, mm:
|
||||
let (ux, uy) = (ax / len, ay / len);
|
||||
let (bnx, bny) = (-uy * sign, ux * sign);
|
||||
let (cx, cy) = ((p0x + p1x) / 2.0, (p0y + p1y) / 2.0);
|
||||
let (tip_l, hw) = (VIEW_MARKER_HEIGHT_MM * mm, VIEW_MARKER_HALF_MM * mm);
|
||||
let tip = (cx + bnx * tip_l, cy + bny * tip_l);
|
||||
let mut o = vec![3.0, tip.0, tip.1, cx + ux * hw, cy + uy * hw, cx - ux * hw, cy - uy * hw];
|
||||
let mut o: Vec<f64> = Vec::new();
|
||||
let mut n = 0.0;
|
||||
let (mut tip, mut hw) = ((cx, cy), VIEW_MARKER_HALF_MM * mm);
|
||||
match marker {
|
||||
SectionMarker::Arrow => {
|
||||
tip = (cx + bnx * SECTION_LEG_MM * mm, cy + bny * SECTION_LEG_MM * mm);
|
||||
hw = SECTION_HEAD_HALF_MM * mm;
|
||||
let hb = (tip.0 - bnx * SECTION_HEAD_LEN_MM * mm, tip.1 - bny * SECTION_HEAD_LEN_MM * mm);
|
||||
o.extend([2.0, 1.0, cx, cy, tip.0, tip.1, 3.0, tip.0, tip.1, hb.0 + ux * hw, hb.1 + uy * hw, hb.0 - ux * hw, hb.1 - uy * hw]);
|
||||
n += 2.0;
|
||||
}
|
||||
SectionMarker::None => {}
|
||||
_ => {
|
||||
tip = (cx + bnx * VIEW_MARKER_HEIGHT_MM * mm, cy + bny * VIEW_MARKER_HEIGHT_MM * mm);
|
||||
o.extend([3.0, tip.0, tip.1, cx + ux * hw, cy + uy * hw, cx - ux * hw, cy - uy * hw]);
|
||||
n += 1.0;
|
||||
}
|
||||
}
|
||||
// Bezeichnung hinter der Basis (gegen die Blickrichtung): Mitte im Abstand 1 mm + halbe Kastenausdehnung.
|
||||
let label_h = SECTION_LABEL_MM * mm * 0.75;
|
||||
let ext = bnx.abs() * label_w / 2.0 + bny.abs() * label_h / 2.0;
|
||||
let reach = mm * 1.0 + ext;
|
||||
let (lx, ly) = (cx - bnx * reach, cy - bny * reach);
|
||||
o.extend([5.0, lx - label_w / 2.0, ly - label_h / 2.0]);
|
||||
// Pick-Band: orientiertes Rechteck von der Rückseite des Textes bis zur Spitze, breit genug für Dreieck und Text.
|
||||
let back_d = reach + ext;
|
||||
let half_u = hw.max(ux.abs() * label_w / 2.0 + uy.abs() * label_h / 2.0);
|
||||
let back_d = if label {
|
||||
o.extend([5.0, lx - label_w / 2.0, ly - label_h / 2.0]);
|
||||
n += 1.0;
|
||||
reach + ext
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
// Pick-Band: orientiertes Rechteck von der Rückseite des Textes bis zur Spitze, breit genug für Zeichen und Text.
|
||||
let half_u = if label { hw.max(ux.abs() * label_w / 2.0 + uy.abs() * label_h / 2.0) } else { hw.max(mm) };
|
||||
let back = (cx - bnx * back_d, cy - bny * back_d);
|
||||
o.push(1.0);
|
||||
o.extend([back.0 + ux * half_u, back.1 + uy * half_u, tip.0 + ux * half_u, tip.1 + uy * half_u, tip.0 - ux * half_u, tip.1 - uy * half_u, back.0 - ux * half_u, back.1 - uy * half_u]);
|
||||
let mut out = vec![3.0];
|
||||
n += 1.0;
|
||||
let mut out = vec![n];
|
||||
out.extend(o);
|
||||
out
|
||||
}
|
||||
|
||||
/// [276] Linienstücke der Ansichtslinie `p0`–`p1` nach `look.line` (`[n, 2 line × n]`, Art 0/1 wie bei der Schnittlinie).
|
||||
pub fn view_line_parts(p0: (f64, f64), p1: (f64, f64), mm: f64, look: &SectionLook) -> Vec<f64> {
|
||||
let l = hypot2(p1.0 - p0.0, p1.1 - p0.1);
|
||||
if !(l > 1e-6) || ![p0.0, p0.1, p1.0, p1.1, mm].iter().all(|x| x.is_finite()) || !(mm > 0.0) {
|
||||
return Vec::new();
|
||||
}
|
||||
let (mut o, mut n) = (Vec::new(), 0usize);
|
||||
line_parts(&[p0, p1], &[((p1.0 - p0.0) / l, (p1.1 - p0.1) / l)], mm, look, &mut o, &mut n);
|
||||
let mut out = vec![n as f64];
|
||||
out.extend(o);
|
||||
out
|
||||
}
|
||||
@@ -410,11 +502,76 @@ mod tests {
|
||||
assert!(view_marker_sized(f64::NAN, 0.0, 1.0, 0.0, 1.0, 0.2, 1.0).is_empty());
|
||||
}
|
||||
|
||||
const L_LOOK: SectionLook = SectionLook { line: SectionLineMode::Ends, end_mm: 12.0, marker: SectionMarker::LAngle, at: SectionMarkerAt::Both, label: true };
|
||||
|
||||
/// Zählt Einträge je Art (2 line art 0, 2 line art 1, 3 triangle, 5 label, 1 polygon).
|
||||
fn kinds(f: &[f64]) -> (usize, usize, usize, usize, usize) {
|
||||
let (mut i, mut r) = (1, (0, 0, 0, 0, 0));
|
||||
for _ in 0..f[0] as usize {
|
||||
match f[i] {
|
||||
2.0 => {
|
||||
if f[i + 1] == 0.0 { r.0 += 1 } else { r.1 += 1 }
|
||||
i += 6;
|
||||
}
|
||||
3.0 => {
|
||||
r.2 += 1;
|
||||
i += 7;
|
||||
}
|
||||
5.0 => {
|
||||
r.3 += 1;
|
||||
i += 3;
|
||||
}
|
||||
_ => {
|
||||
r.4 += 1;
|
||||
i += 9;
|
||||
}
|
||||
}
|
||||
}
|
||||
r
|
||||
}
|
||||
|
||||
/// [276] Varianten: Linie durchgehend/Enden/keine, Marke Pfeil/L/Dreieck/keine, Ende Anfang/Ende, ohne Beschriftung.
|
||||
#[test]
|
||||
fn darstellung_varianten() {
|
||||
let pts = [(0.0, 0.0), (10.0, 0.0)];
|
||||
let run = |l: SectionLook| kinds(§ion_polyline_look(&pts, 1.0, 0.2, 1.0, &l));
|
||||
let base = SectionLook::default();
|
||||
// (dünn, kräftig, Dreieck, Label, Pick)
|
||||
assert_eq!(run(base), (1, 4, 2, 2, 1));
|
||||
assert_eq!(run(SectionLook { line: SectionLineMode::Ends, ..base }), (0, 4, 2, 2, 1));
|
||||
assert_eq!(run(SectionLook { line: SectionLineMode::None, ..base }), (0, 2, 2, 2, 1));
|
||||
assert_eq!(run(SectionLook { line: SectionLineMode::None, marker: SectionMarker::Triangle, ..base }), (0, 0, 2, 2, 1));
|
||||
assert_eq!(run(SectionLook { line: SectionLineMode::None, marker: SectionMarker::None, label: false, ..base }), (0, 0, 0, 0, 1));
|
||||
assert_eq!(run(SectionLook { marker: SectionMarker::Triangle, at: SectionMarkerAt::Start, ..base }), (1, 2, 1, 1, 1));
|
||||
assert_eq!(run(SectionLook { marker: SectionMarker::LAngle, at: SectionMarkerAt::End, label: false, ..base }), (1, 3, 0, 0, 1));
|
||||
// Dreieck am Ende: Basis auf der Linie, Spitze in Blickrichtung.
|
||||
let f = section_polyline_look(&pts, 1.0, 0.2, 1.0, &SectionLook { line: SectionLineMode::None, marker: SectionMarker::Triangle, at: SectionMarkerAt::End, label: false, ..base });
|
||||
assert_eq!(f[0], 2.0);
|
||||
assert!((f[2] - 10.0).abs() < 1e-9 && (f[3] - 0.9).abs() < 1e-9, "{f:?}");
|
||||
// Länge der Endstücke.
|
||||
let f = section_polyline_look(&pts, 1.0, 0.2, 1.0, &SectionLook { end_mm: 15.0, marker: SectionMarker::None, label: false, ..base });
|
||||
assert!((f[5] - 3.0).abs() < 1e-9, "15 mm · 0.2 = 3 m: {f:?}");
|
||||
}
|
||||
|
||||
/// [276] Ansicht: Dreieck (heute), Pfeil, keine Marke; Linie nur bei `full`/`ends`.
|
||||
#[test]
|
||||
fn ansicht_zeichen_und_linie() {
|
||||
let sym = |m, label| kinds(&view_symbol(0.0, 0.0, 10.0, 0.0, 1.0, 0.2, 1.0, m, label));
|
||||
assert_eq!(sym(SectionMarker::Triangle, true), (0, 0, 1, 1, 1));
|
||||
assert_eq!(view_symbol(0.0, 0.0, 10.0, 0.0, 1.0, 0.2, 1.0, SectionMarker::Triangle, true), view_marker_sized(0.0, 0.0, 10.0, 0.0, 1.0, 0.2, 1.0));
|
||||
assert_eq!(sym(SectionMarker::Arrow, true), (0, 1, 1, 1, 1));
|
||||
assert_eq!(sym(SectionMarker::None, false), (0, 0, 0, 0, 1));
|
||||
let look = SectionLook::default();
|
||||
assert_eq!(kinds(&view_line_parts((0.0, 0.0), (10.0, 0.0), 0.2, &look)), (1, 2, 0, 0, 0));
|
||||
assert_eq!(kinds(&view_line_parts((0.0, 0.0), (10.0, 0.0), 0.2, &SectionLook { line: SectionLineMode::Ends, ..look })), (0, 2, 0, 0, 0));
|
||||
assert_eq!(view_line_parts((0.0, 0.0), (10.0, 0.0), 0.2, &SectionLook { line: SectionLineMode::None, ..look })[0], 0.0);
|
||||
}
|
||||
|
||||
/// [176] L-Marke: je Ende zwei kräftige Linien (12 mm längs der Linie nach innen, 6 mm in Blickrichtung), keine
|
||||
/// dünne Linie, kein Dreieck; Label ausserhalb neben dem kurzen Schenkel; Pick-Band je Segment.
|
||||
#[test]
|
||||
fn l_marke_zwei_schenkel_je_ende_ohne_linie() {
|
||||
let f = section_polyline_styled(&[(0.0, 0.0), (10.0, 0.0)], 1.0, 0.2, 1.0, SectionMarkerStyle::LAngle);
|
||||
let f = section_polyline_look(&[(0.0, 0.0), (10.0, 0.0)], 1.0, 0.2, 1.0, &L_LOOK);
|
||||
// 2 × (langer + kurzer Schenkel + Label) + 1 Pick = 7
|
||||
assert_eq!(f[0], 7.0);
|
||||
let near = |x: &[f64], y: &[f64]| x.iter().zip(y).all(|(a, b)| (a - b).abs() < 1e-9);
|
||||
@@ -438,13 +595,13 @@ mod tests {
|
||||
}
|
||||
}
|
||||
// Pfeil unverändert.
|
||||
assert_eq!(section_polyline_styled(&[(0.0, 0.0), (10.0, 0.0)], 1.0, 0.2, 1.0, SectionMarkerStyle::Arrow), section_line_sized(0.0, 0.0, 10.0, 0.0, 1.0, 0.2, 1.0));
|
||||
assert_eq!(section_polyline_look(&[(0.0, 0.0), (10.0, 0.0)], 1.0, 0.2, 1.0, &SectionLook::default()), section_line_sized(0.0, 0.0, 10.0, 0.0, 1.0, 0.2, 1.0));
|
||||
}
|
||||
|
||||
/// [176] L-Marke mit Knick: Knickstücke (6 mm) bleiben, Schenkel nur an den Enden.
|
||||
#[test]
|
||||
fn l_marke_geknickt_behaelt_knickstuecke() {
|
||||
let f = section_polyline_styled(&[(0.0, 0.0), (10.0, 0.0), (10.0, 8.0)], 1.0, 0.2, 1.0, SectionMarkerStyle::LAngle);
|
||||
let f = section_polyline_look(&[(0.0, 0.0), (10.0, 0.0), (10.0, 8.0)], 1.0, 0.2, 1.0, &L_LOOK);
|
||||
// 4 Endstücke/Knickstücke je Segment 2 = 4, 2 kurze Schenkel, 2 Label, 2 Pick = 10
|
||||
assert_eq!(f[0], 10.0);
|
||||
let near = |x: &[f64], y: &[f64]| x.iter().zip(y).all(|(a, b)| (a - b).abs() < 1e-9);
|
||||
|
||||
@@ -330,8 +330,9 @@ pub struct Options {
|
||||
pub elevation: ElevOpts,
|
||||
pub floor_finish_mv: Option<FloorFinishDisplay>,
|
||||
pub terrain_mv: Option<bool>,
|
||||
/// [176] Markentyp der Schnitte laut Modelldarstellung (die Ebene geht vor, s. [`Options::section_marker`]).
|
||||
pub section_marker_mv: Option<SectionMarkerStyle>,
|
||||
/// [176]/[276] Schnitt- bzw. Ansichtsmarken laut Modelldarstellung (die Ebene geht vor, s. [`Options::mark_look`]).
|
||||
pub section_marks_mv: Option<ModelViewSectionMarks>,
|
||||
pub elevation_marks_mv: Option<ModelViewSectionMarks>,
|
||||
/// Raumstempel.
|
||||
pub stamp: StampOpts,
|
||||
/// Bemassung.
|
||||
@@ -395,9 +396,19 @@ impl Options {
|
||||
pub fn terrain(&self, level: Option<bool>) -> Option<bool> {
|
||||
level.or(self.terrain_mv)
|
||||
}
|
||||
/// [176] Schnittmarke: Ebene > Modelldarstellung > Pfeil.
|
||||
pub fn section_marker(&self, level: Option<SectionMarkerStyle>) -> SectionMarkerStyle {
|
||||
level.filter(|s| *s != SectionMarkerStyle::Unknown).or(self.section_marker_mv).unwrap_or(SectionMarkerStyle::Arrow)
|
||||
/// [276] Darstellung der Schnitt-/Ansichtslinie: Ebene > Modelldarstellung > Basis (Schnitt: Linie mit Endstücken, Pfeile
|
||||
/// an beiden Enden; Ansicht: keine Linie, Dreieck in der Mitte; beide mit Beschriftung).
|
||||
pub fn mark_look(&self, level: &DrawingLevel) -> crate::plan::misc::SectionLook {
|
||||
use crate::plan::misc::SectionLook;
|
||||
let elev = matches!(level.kind, DrawingLevelKind::Elevation);
|
||||
let mv = if elev { self.elevation_marks_mv.as_ref() } else { self.section_marks_mv.as_ref() };
|
||||
let base = SectionLook::default();
|
||||
let line = level.line_mode.or(mv.and_then(|m| m.line_mode)).filter(|x| *x != SectionLineMode::Unknown).unwrap_or(if elev { SectionLineMode::None } else { base.line });
|
||||
let marker = level.marker.or(mv.and_then(|m| m.marker)).filter(|x| *x != SectionMarker::Unknown).unwrap_or(if elev { SectionMarker::Triangle } else { base.marker });
|
||||
let at = level.marker_at.or(mv.and_then(|m| m.marker_at)).filter(|x| *x != SectionMarkerAt::Unknown).unwrap_or(base.at);
|
||||
let end_mm = level.end_length_mm.or(mv.and_then(|m| m.end_length_mm)).filter(|v| v.is_finite() && *v > 0.0).unwrap_or(base.end_mm);
|
||||
let label = level.marker_label.or(mv.and_then(|m| m.marker_label)).unwrap_or(true);
|
||||
SectionLook { line, end_mm, marker, at, label }
|
||||
}
|
||||
/// Automatische Höhenkoten in Schnitt/Ansicht: Ebene > Modelldarstellung > an.
|
||||
pub fn level_marks(&self, level: Option<bool>) -> bool {
|
||||
@@ -560,7 +571,8 @@ pub fn resolve(mv: Option<&ModelViewOption>, detail: Detail, scale: f64) -> Opti
|
||||
elevation: ElevOpts { shadows_mv: el.and_then(|e| e.shadows), material_hatch: el.and_then(|e| e.material_hatch).unwrap_or(true) },
|
||||
floor_finish_mv: mv.and_then(|m| m.slabs.as_ref()).and_then(|s| s.floor_finish).filter(|f| *f != FloorFinishDisplay::Unknown),
|
||||
terrain_mv: mv.and_then(|m| m.site.as_ref()).and_then(|s| s.terrain),
|
||||
section_marker_mv: mv.and_then(|m| m.section_marks.as_ref()).and_then(|s| s.style).filter(|s| *s != SectionMarkerStyle::Unknown),
|
||||
section_marks_mv: mv.and_then(|m| m.section_marks.clone()),
|
||||
elevation_marks_mv: mv.and_then(|m| m.elevation_marks.clone()),
|
||||
stamp: mv.and_then(|m| m.room_stamps.as_ref()).map_or_else(StampOpts::default, |r| StampOpts { number: r.number, area: r.area, usage: r.usage, height: r.height, finish: r.finish, divider: r.divider }),
|
||||
dims: {
|
||||
let d = mv.and_then(|m| m.dimensions.as_ref());
|
||||
|
||||
@@ -563,7 +563,7 @@ fn managed(key: &str) -> &'static [&'static str] {
|
||||
"overrideRules" => &["condition", "conditions", "actions"],
|
||||
// [173] Stufen der Modelldarstellung: Basis und alle Abschnitte.
|
||||
"modelViewOptions" => &[
|
||||
"baseDetail", "doors", "windows", "stairs", "walls", "slabs", "roofs", "columns", "elevation", "site", "sectionMarks", "roomStamps", "dimensions",
|
||||
"baseDetail", "doors", "windows", "stairs", "walls", "slabs", "roofs", "columns", "elevation", "site", "sectionMarks", "elevationMarks", "roomStamps", "dimensions",
|
||||
],
|
||||
_ => &["layers"],
|
||||
}
|
||||
|
||||
+36
-3
@@ -1365,11 +1365,44 @@ export const de = {
|
||||
"resources.modelViews.val.symbolisch": "symbolisch",
|
||||
"resources.modelViews.val.geschnitten": "geschnitten",
|
||||
"resources.modelViews.opt.slabs.floorFinish": "Bodenbelag",
|
||||
"resources.modelViews.opt.sectionMarks.style": "Markentyp der Schnitte",
|
||||
"resources.modelViews.section.elevationMarks": "Ansichtsmarken",
|
||||
"resources.modelViews.opt.sectionMarks.lineMode": "Schnittlinie",
|
||||
"resources.modelViews.opt.sectionMarks.endLengthMm": "Länge der Endstücke",
|
||||
"resources.modelViews.opt.sectionMarks.marker": "Marke der Schnitte",
|
||||
"resources.modelViews.opt.sectionMarks.markerAt": "Marke an",
|
||||
"resources.modelViews.opt.sectionMarks.markerLabel": "Beschriftung der Schnitte",
|
||||
"resources.modelViews.opt.elevationMarks.lineMode": "Ansichtslinie",
|
||||
"resources.modelViews.opt.elevationMarks.endLengthMm": "Länge der Endstücke (Ansicht)",
|
||||
"resources.modelViews.opt.elevationMarks.marker": "Marke der Ansichten",
|
||||
"resources.modelViews.opt.elevationMarks.markerLabel": "Beschriftung der Ansichten",
|
||||
"resources.modelViews.val.full": "Durchgehend",
|
||||
"resources.modelViews.val.ends": "Nur Enden",
|
||||
"resources.modelViews.val.none": "Keine",
|
||||
"resources.modelViews.val.triangle": "Dreieck",
|
||||
"resources.modelViews.val.both": "Anfang und Ende",
|
||||
"resources.modelViews.val.start": "Nur Anfang",
|
||||
"resources.modelViews.val.end": "Nur Ende",
|
||||
"resources.modelViews.val.arrow": "Pfeil",
|
||||
"resources.modelViews.val.lAngle": "Nur L",
|
||||
"objinfo.sectionLine.marker": "Schnittmarke",
|
||||
"objinfo.sectionLine.marker.model": "wie Modelldarstellung",
|
||||
"objinfo.sectionLine.look": "Darstellung im Plan",
|
||||
"objinfo.sectionLine.look.line": "Linie",
|
||||
"objinfo.sectionLine.look.lineStyle": "Linientyp",
|
||||
"objinfo.sectionLine.look.pen": "Stift",
|
||||
"objinfo.sectionLine.look.endLength": "Endstücke (mm)",
|
||||
"objinfo.sectionLine.look.marker": "Marke",
|
||||
"objinfo.sectionLine.look.markerAt": "Marke an",
|
||||
"objinfo.sectionLine.look.label": "Beschriftung",
|
||||
"objinfo.sectionLine.look.model": "wie Modelldarstellung",
|
||||
"objinfo.sectionLine.look.full": "Durchgehend",
|
||||
"objinfo.sectionLine.look.ends": "Nur Enden",
|
||||
"objinfo.sectionLine.look.none": "Keine",
|
||||
"objinfo.sectionLine.look.arrow": "Pfeil",
|
||||
"objinfo.sectionLine.look.lAngle": "L",
|
||||
"objinfo.sectionLine.look.triangle": "Dreieck",
|
||||
"objinfo.sectionLine.look.both": "Beide",
|
||||
"objinfo.sectionLine.look.start": "Anfang",
|
||||
"objinfo.sectionLine.look.end": "Ende",
|
||||
"objinfo.sectionLine.look.reset": "Auf Vorgabe zurücksetzen",
|
||||
"resources.modelViews.opt.site.terrain": "Gelände im Grundriss",
|
||||
"resources.modelViews.val.gestrichelt": "gestrichelt",
|
||||
"resources.modelViews.val.punktiert": "punktiert",
|
||||
|
||||
+36
-3
@@ -1359,11 +1359,44 @@ export const en: Record<TranslationKey, string> = {
|
||||
"resources.modelViews.val.symbolisch": "symbolic",
|
||||
"resources.modelViews.val.geschnitten": "cut",
|
||||
"resources.modelViews.opt.slabs.floorFinish": "Floor finish",
|
||||
"resources.modelViews.opt.sectionMarks.style": "Section marker type",
|
||||
"resources.modelViews.section.elevationMarks": "Elevation marks",
|
||||
"resources.modelViews.opt.sectionMarks.lineMode": "Section line",
|
||||
"resources.modelViews.opt.sectionMarks.endLengthMm": "End piece length",
|
||||
"resources.modelViews.opt.sectionMarks.marker": "Section marker",
|
||||
"resources.modelViews.opt.sectionMarks.markerAt": "Marker at",
|
||||
"resources.modelViews.opt.sectionMarks.markerLabel": "Section label",
|
||||
"resources.modelViews.opt.elevationMarks.lineMode": "Elevation line",
|
||||
"resources.modelViews.opt.elevationMarks.endLengthMm": "End piece length (elevation)",
|
||||
"resources.modelViews.opt.elevationMarks.marker": "Elevation marker",
|
||||
"resources.modelViews.opt.elevationMarks.markerLabel": "Elevation label",
|
||||
"resources.modelViews.val.full": "Continuous",
|
||||
"resources.modelViews.val.ends": "Ends only",
|
||||
"resources.modelViews.val.none": "None",
|
||||
"resources.modelViews.val.triangle": "Triangle",
|
||||
"resources.modelViews.val.both": "Start and end",
|
||||
"resources.modelViews.val.start": "Start only",
|
||||
"resources.modelViews.val.end": "End only",
|
||||
"resources.modelViews.val.arrow": "Arrow",
|
||||
"resources.modelViews.val.lAngle": "L only",
|
||||
"objinfo.sectionLine.marker": "Section marker",
|
||||
"objinfo.sectionLine.marker.model": "as model view",
|
||||
"objinfo.sectionLine.look": "Plan appearance",
|
||||
"objinfo.sectionLine.look.line": "Line",
|
||||
"objinfo.sectionLine.look.lineStyle": "Line type",
|
||||
"objinfo.sectionLine.look.pen": "Pen",
|
||||
"objinfo.sectionLine.look.endLength": "End pieces (mm)",
|
||||
"objinfo.sectionLine.look.marker": "Marker",
|
||||
"objinfo.sectionLine.look.markerAt": "Marker at",
|
||||
"objinfo.sectionLine.look.label": "Label",
|
||||
"objinfo.sectionLine.look.model": "as model view",
|
||||
"objinfo.sectionLine.look.full": "Continuous",
|
||||
"objinfo.sectionLine.look.ends": "Ends only",
|
||||
"objinfo.sectionLine.look.none": "None",
|
||||
"objinfo.sectionLine.look.arrow": "Arrow",
|
||||
"objinfo.sectionLine.look.lAngle": "L",
|
||||
"objinfo.sectionLine.look.triangle": "Triangle",
|
||||
"objinfo.sectionLine.look.both": "Both",
|
||||
"objinfo.sectionLine.look.start": "Start",
|
||||
"objinfo.sectionLine.look.end": "End",
|
||||
"objinfo.sectionLine.look.reset": "Reset to default",
|
||||
"resources.modelViews.opt.site.terrain": "Terrain in plan",
|
||||
"resources.modelViews.val.gestrichelt": "dashed",
|
||||
"resources.modelViews.val.punktiert": "dotted",
|
||||
|
||||
@@ -1358,10 +1358,31 @@ export type DrawingLevel = {
|
||||
*/
|
||||
autoLine?: boolean;
|
||||
/**
|
||||
* [176] Schnittmarke im Grundriss: "arrow" (Pfeil mit Dreieck, Basis) oder "lAngle" (nur ein L je Ende). Fehlt ⇒ die
|
||||
* Vorgabe der Modelldarstellung (`sectionMarks.style`), sonst Pfeil. Nur Schnitt.
|
||||
* [276] Darstellung der Linie im Grundriss: "full" (Basis: Schnitt = dünne Strichpunktlinie mit kräftigen Endstücken),
|
||||
* "ends" (nur die Endstücke) oder "none" (keine Linie). Fehlt ⇒ Vorgabe der Modelldarstellung (`sectionMarks` bzw.
|
||||
* `elevationMarks`), sonst Schnitt "full", Ansicht "none". Nur Schnitt/Ansicht.
|
||||
*/
|
||||
markerStyle?: SectionMarkerStyle;
|
||||
lineMode?: SectionLineMode;
|
||||
/** [276] Länge der Endstücke in Papier-mm (Basis 12; an Knicken die Hälfte). */
|
||||
endLengthMm?: number;
|
||||
/**
|
||||
* [276] Linientyp (`LineStyle.id`) der Linie; fehlt ⇒ Basis (Strichpunkt, bei "ends" durchgezogen).
|
||||
*/
|
||||
lineStyleId?: string;
|
||||
/**
|
||||
* [276] Stift (`ColorPen.id`) der Linie (Farbe und Strichstärke des aktiven Stiftsatzes); fehlt ⇒ Basis.
|
||||
*/
|
||||
linePenId?: string;
|
||||
/**
|
||||
* [276] Marke an den Enden bzw. (Ansicht) in der Mitte: "arrow" (Schenkel mit Dreieck), "lAngle" (nur Schenkel, ein L
|
||||
* mit dem Endstück), "triangle" (nur gefülltes Dreieck) oder "none". Fehlt ⇒ Vorgabe der Modelldarstellung, sonst
|
||||
* Schnitt "arrow", Ansicht "triangle". Ansichten kennen "arrow", "triangle", "none".
|
||||
*/
|
||||
marker?: SectionMarker;
|
||||
/** [276] Wo die Marke steht (nur Schnitt): beide Enden (Basis), nur am Anfang oder nur am Ende. */
|
||||
markerAt?: SectionMarkerAt;
|
||||
/** [276] Beschriftung der Marke (Basis: ja). */
|
||||
markerLabel?: boolean;
|
||||
/** Blickrichtung relativ zur Schnittlinie (nur Schnitt/Ansicht). */
|
||||
directionSign?: 1 | -1;
|
||||
/**
|
||||
@@ -2468,6 +2489,8 @@ export type ModelViewOption = {
|
||||
elevation?: ModelViewElevation;
|
||||
/** [176] Schnittmarken im Grundriss. */
|
||||
sectionMarks?: ModelViewSectionMarks;
|
||||
/** [276] Ansichtslinien und -marken im Grundriss. */
|
||||
elevationMarks?: ModelViewSectionMarks;
|
||||
/** [173] Raumstempel: welche Zeilen (die Einstellung am Stempel geht vor). */
|
||||
roomStamps?: ModelViewRoomStamps;
|
||||
/** [173] Bemassung: Massketten der automatischen Aussenbemassung, Höhenkoten. */
|
||||
@@ -2509,10 +2532,21 @@ export type ModelViewRoomStamps = {
|
||||
divider?: boolean;
|
||||
};
|
||||
|
||||
/** [176] Schnittmarken in der Modelldarstellung (fehlt ⇒ Pfeil). */
|
||||
/**
|
||||
* [176]/[276] Schnitt- bzw. Ansichtsmarken in der Modelldarstellung (fehlt ⇒ Basis; die Ebene geht vor). Dieselben
|
||||
* Felder wie an der Ebene (`DrawingLevel.lineMode` …) ohne Linientyp und Stift.
|
||||
*/
|
||||
export type ModelViewSectionMarks = {
|
||||
/** Markentyp der Schnitte (die Ebene geht vor; Basis: Pfeil). */
|
||||
style?: SectionMarkerStyle;
|
||||
/** Linie: durchgehend, nur Endstücke, keine. */
|
||||
lineMode?: SectionLineMode;
|
||||
/** Länge der Endstücke in Papier-mm. */
|
||||
endLengthMm?: number;
|
||||
/** Marke (Pfeil, L, Dreieck, keine). */
|
||||
marker?: SectionMarker;
|
||||
/** Wo die Marke steht (nur Schnitt). */
|
||||
markerAt?: SectionMarkerAt;
|
||||
/** Beschriftung der Marke. */
|
||||
markerLabel?: boolean;
|
||||
};
|
||||
|
||||
/** [173] Gelände in der Modelldarstellung. */
|
||||
@@ -3876,11 +3910,17 @@ export type SashDef = {
|
||||
hingeSide?: "left" | "right";
|
||||
};
|
||||
|
||||
/** [276] Linie einer Schnitt-/Ansichtslinie im Grundriss. */
|
||||
export type SectionLineMode = "full" | "ends" | "none";
|
||||
|
||||
/**
|
||||
* [176] Markentyp einer Schnittlinie im Grundriss: Pfeil (kräftige Endstücke, dünne Linie, Schenkel mit Dreieck)
|
||||
* oder nur ein L an jedem Ende (langer Schenkel längs der Linie, kurzer in Blickrichtung, keine Linie dazwischen).
|
||||
* [276] Marke einer Schnitt-/Ansichtslinie: Pfeil (Schenkel in Blickrichtung mit Dreieck), L (nur Schenkel), gefülltes
|
||||
* Dreieck, keine.
|
||||
*/
|
||||
export type SectionMarkerStyle = "arrow" | "lAngle";
|
||||
export type SectionMarker = "arrow" | "lAngle" | "triangle" | "none";
|
||||
|
||||
/** [276] An welchem Ende einer Schnittlinie die Marke steht. */
|
||||
export type SectionMarkerAt = "both" | "start" | "end";
|
||||
|
||||
/**
|
||||
* Sequenz-Regel: fasst mehrere Unterregeln zusammen und wendet sie geordnet an.
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// Abschnitt „Schnitt-/Ansichtslinie" der Attribute ([165] aus `ObjectInfoPanel.tsx`): Name, Art, Tiefe,
|
||||
// Umkehren, Höhenmarken, Plan-Unterlage. Gerufen von `AttributesPanel`.
|
||||
// Umkehren, Höhenmarken, Plan-Unterlage, Darstellung im Plan ([276]). Gerufen von `AttributesPanel`.
|
||||
|
||||
import type { DrawingLevel, Vec2 } from "../../model/types";
|
||||
import { usePanelHost } from "../host";
|
||||
import { t } from "../../i18n";
|
||||
import type { TranslationKey } from "../../i18n";
|
||||
import { Dropdown } from "../../ui/Dropdown";
|
||||
import { useStore } from "../../state/appStore";
|
||||
import { SectionLookFields } from "./SectionLookFields";
|
||||
|
||||
// ── Schnitt-/Ansichtslinien-Abschnitt (Object-Info; nur die gewählte Linie) ──
|
||||
// Name (editierbar), Blickrichtung umkehren (directionSign-Flip), Endpunkt-
|
||||
@@ -19,6 +20,8 @@ export function SectionLineSection({
|
||||
level: DrawingLevel;
|
||||
host: ReturnType<typeof usePanelHost>;
|
||||
}) {
|
||||
const project = useStore((s) => s.project);
|
||||
const activeLevelId = useStore((s) => s.activeLevelId);
|
||||
const line = level.linePoints;
|
||||
const isElev = level.kind === "elevation";
|
||||
const kindLabel =
|
||||
@@ -126,24 +129,6 @@ export function SectionLineSection({
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* [176] Schnittmarke im Grundriss: leer = Vorgabe der Modelldarstellung (sonst Pfeil). */}
|
||||
{level.kind === "section" && (
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.sectionLine.marker")}</span>
|
||||
<Dropdown
|
||||
value={level.markerStyle ?? ""}
|
||||
onChange={(v) => host.onSetSectionLinePatch({ markerStyle: v === "arrow" || v === "lAngle" ? v : undefined })}
|
||||
options={[
|
||||
{ value: "", label: t("objinfo.sectionLine.marker.model") },
|
||||
{ value: "arrow", label: t("resources.modelViews.val.arrow") },
|
||||
{ value: "lAngle", label: t("resources.modelViews.val.lAngle") },
|
||||
]}
|
||||
title={t("objinfo.sectionLine.marker")}
|
||||
width={150}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Verdeckte Kanten (gestrichelt) — Default aus (blasses Liniengewirr). */}
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.sectionLine.hiddenLines")}</span>
|
||||
@@ -166,6 +151,9 @@ export function SectionLineSection({
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* [276] Darstellung im Plan: Linie, Linientyp, Stift, Marke, Beschriftung. */}
|
||||
<SectionLookFields level={level} project={project} planLevelId={activeLevelId} onPatch={host.onSetSectionLinePatch} />
|
||||
|
||||
{/* Löschen: linePoints zurücksetzen (die Ebene bleibt bestehen). */}
|
||||
<button type="button" className="objinfo-btn" onClick={() => host.onDeleteSectionLine()}>
|
||||
{t(isElev ? "objinfo.sectionLine.delete.elevation" : "objinfo.sectionLine.delete")}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// [276] Wirksame Darstellung einer Schnitt-/Ansichtslinie: Ebene > Modelldarstellung des gezeigten Plans > Basis.
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { DrawingLevel, Project } from "../../model/types";
|
||||
import { effectiveSectionLook, marksOfPlan } from "./SectionLookFields";
|
||||
|
||||
const lvl = (o: Partial<DrawingLevel>): DrawingLevel => ({ id: "s", name: "Schnitt A", kind: "section", visible: true, locked: false, ...o }) as DrawingLevel;
|
||||
|
||||
describe("effectiveSectionLook", () => {
|
||||
it("Basis: Schnitt = durchgehend + Pfeil, Ansicht = keine Linie + Dreieck", () => {
|
||||
expect(effectiveSectionLook(lvl({}), undefined)).toEqual({ lineMode: "full", endLengthMm: 12, marker: "arrow", markerAt: "both", markerLabel: true });
|
||||
const e = effectiveSectionLook(lvl({ kind: "elevation" }), undefined);
|
||||
expect([e.lineMode, e.marker]).toEqual(["none", "triangle"]);
|
||||
});
|
||||
it("Ebene geht vor der Modelldarstellung", () => {
|
||||
const e = effectiveSectionLook(lvl({ marker: "arrow" }), { lineMode: "ends", marker: "lAngle", markerLabel: false });
|
||||
expect([e.lineMode, e.marker, e.markerLabel]).toEqual(["ends", "arrow", false]);
|
||||
});
|
||||
it("Modelldarstellung des gezeigten Plans", () => {
|
||||
const p = {
|
||||
drawingLevels: [{ id: "eg", modelViewOptionId: "m" }],
|
||||
modelViewOptions: [{ id: "m", name: "M", sectionMarks: { marker: "triangle" }, elevationMarks: { lineMode: "full" } }],
|
||||
} as unknown as Project;
|
||||
expect(marksOfPlan(p, "eg", false)).toEqual({ marker: "triangle" });
|
||||
expect(marksOfPlan(p, "eg", true)).toEqual({ lineMode: "full" });
|
||||
expect(marksOfPlan(p, "x", false)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,287 @@
|
||||
// Darstellung einer Schnitt-/Ansichtslinie im Plan ([276]): Linie (durchgehend / nur Enden / keine), Linientyp, Stift,
|
||||
// Marke (Pfeil / L / Dreieck / keine), Marke an Anfang/Ende/beiden, Beschriftung — mit kleinen Vorschau-Symbolen je Option.
|
||||
// Gerufen von `SectionLineSection`. Die Werte der Ebene gehen vor, danach die Vorgabe der Modelldarstellung des gerade
|
||||
// gezeigten Plans (Ressourcen > Modelldarstellung > Schnitt-/Ansichtsmarken), zuletzt die Basis (wie bisher).
|
||||
|
||||
import type { ReactNode } from "react";
|
||||
import type { DrawingLevel, ModelViewSectionMarks, Project, SectionLineMode, SectionMarker, SectionMarkerAt } from "../../model/types";
|
||||
import { t } from "../../i18n";
|
||||
import type { TranslationKey } from "../../i18n";
|
||||
import { Dropdown } from "../../ui/Dropdown";
|
||||
|
||||
/** Wirksame Darstellung einer Linie: Ebene > Vorgabe der Modelldarstellung > Basis (gleiche Reihenfolge wie der Kern). */
|
||||
export interface SectionLookValues {
|
||||
lineMode: SectionLineMode;
|
||||
endLengthMm: number;
|
||||
marker: SectionMarker;
|
||||
markerAt: SectionMarkerAt;
|
||||
markerLabel: boolean;
|
||||
}
|
||||
|
||||
export function effectiveSectionLook(level: DrawingLevel, marks: ModelViewSectionMarks | undefined): SectionLookValues {
|
||||
const elev = level.kind === "elevation";
|
||||
return {
|
||||
lineMode: level.lineMode ?? marks?.lineMode ?? (elev ? "none" : "full"),
|
||||
endLengthMm: level.endLengthMm ?? marks?.endLengthMm ?? 12,
|
||||
marker: level.marker ?? marks?.marker ?? (elev ? "triangle" : "arrow"),
|
||||
markerAt: level.markerAt ?? marks?.markerAt ?? "both",
|
||||
markerLabel: level.markerLabel ?? marks?.markerLabel ?? true,
|
||||
};
|
||||
}
|
||||
|
||||
/** Vorgabe der Modelldarstellung des gezeigten Plans für Schnitte bzw. Ansichten. */
|
||||
export function marksOfPlan(project: Project, planLevelId: string, elev: boolean): ModelViewSectionMarks | undefined {
|
||||
const mvId = project.drawingLevels.find((l) => l.id === planLevelId)?.modelViewOptionId;
|
||||
const mv = mvId ? project.modelViewOptions?.find((m) => m.id === mvId) : undefined;
|
||||
return elev ? mv?.elevationMarks : mv?.sectionMarks;
|
||||
}
|
||||
|
||||
const INK = "currentColor";
|
||||
|
||||
/** Kleine Vorschau (36 × 20): Linie waagrecht, Blickrichtung nach unten. */
|
||||
function Svg({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<svg width="36" height="20" viewBox="0 0 36 20" aria-hidden="true" className="look-icon">
|
||||
{children}
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
const ICONS: Record<string, ReactNode> = {
|
||||
// Linie
|
||||
"line:full": (
|
||||
<Svg>
|
||||
<line x1="2" y1="6" x2="9" y2="6" stroke={INK} strokeWidth="2.4" />
|
||||
<line x1="9" y1="6" x2="27" y2="6" stroke={INK} strokeWidth="1" strokeDasharray="5 1.5 1 1.5" />
|
||||
<line x1="27" y1="6" x2="34" y2="6" stroke={INK} strokeWidth="2.4" />
|
||||
</Svg>
|
||||
),
|
||||
"line:ends": (
|
||||
<Svg>
|
||||
<line x1="2" y1="6" x2="9" y2="6" stroke={INK} strokeWidth="2.4" />
|
||||
<line x1="27" y1="6" x2="34" y2="6" stroke={INK} strokeWidth="2.4" />
|
||||
</Svg>
|
||||
),
|
||||
"line:none": (
|
||||
<Svg>
|
||||
<line x1="2" y1="6" x2="34" y2="6" stroke={INK} strokeWidth="1" strokeDasharray="1 3" opacity="0.4" />
|
||||
<line x1="12" y1="2" x2="24" y2="10" stroke={INK} strokeWidth="1.2" opacity="0.7" />
|
||||
</Svg>
|
||||
),
|
||||
// Marke
|
||||
"marker:arrow": (
|
||||
<Svg>
|
||||
<line x1="4" y1="3" x2="4" y2="13" stroke={INK} strokeWidth="2" />
|
||||
<polygon points="4,18 1,12 7,12" fill={INK} />
|
||||
<line x1="32" y1="3" x2="32" y2="13" stroke={INK} strokeWidth="2" />
|
||||
<polygon points="32,18 29,12 35,12" fill={INK} />
|
||||
</Svg>
|
||||
),
|
||||
"marker:lAngle": (
|
||||
<Svg>
|
||||
<polyline points="12,3 4,3 4,14" fill="none" stroke={INK} strokeWidth="2" />
|
||||
<polyline points="24,3 32,3 32,14" fill="none" stroke={INK} strokeWidth="2" />
|
||||
</Svg>
|
||||
),
|
||||
"marker:triangle": (
|
||||
<Svg>
|
||||
<polygon points="4,16 0.5,6 7.5,6" fill={INK} />
|
||||
<polygon points="32,16 28.5,6 35.5,6" fill={INK} />
|
||||
</Svg>
|
||||
),
|
||||
"marker:none": (
|
||||
<Svg>
|
||||
<line x1="12" y1="4" x2="24" y2="14" stroke={INK} strokeWidth="1.2" opacity="0.7" />
|
||||
</Svg>
|
||||
),
|
||||
// Marke an
|
||||
"at:both": (
|
||||
<Svg>
|
||||
<line x1="4" y1="6" x2="32" y2="6" stroke={INK} strokeWidth="1" opacity="0.5" />
|
||||
<polygon points="4,16 1,8 7,8" fill={INK} />
|
||||
<polygon points="32,16 29,8 35,8" fill={INK} />
|
||||
</Svg>
|
||||
),
|
||||
"at:start": (
|
||||
<Svg>
|
||||
<line x1="4" y1="6" x2="32" y2="6" stroke={INK} strokeWidth="1" opacity="0.5" />
|
||||
<polygon points="4,16 1,8 7,8" fill={INK} />
|
||||
</Svg>
|
||||
),
|
||||
"at:end": (
|
||||
<Svg>
|
||||
<line x1="4" y1="6" x2="32" y2="6" stroke={INK} strokeWidth="1" opacity="0.5" />
|
||||
<polygon points="32,16 29,8 35,8" fill={INK} />
|
||||
</Svg>
|
||||
),
|
||||
};
|
||||
|
||||
/** Elevation: ein Zeichen in der Mitte statt je Ende. */
|
||||
const ELEVATION_ICONS: Record<string, ReactNode> = {
|
||||
"marker:arrow": (
|
||||
<Svg>
|
||||
<line x1="18" y1="3" x2="18" y2="13" stroke={INK} strokeWidth="2" />
|
||||
<polygon points="18,18 15,12 21,12" fill={INK} />
|
||||
</Svg>
|
||||
),
|
||||
"marker:triangle": (
|
||||
<Svg>
|
||||
<polygon points="18,16 14.5,6 21.5,6" fill={INK} />
|
||||
</Svg>
|
||||
),
|
||||
};
|
||||
|
||||
interface Choice<T extends string> {
|
||||
value: T;
|
||||
label: string;
|
||||
icon: ReactNode;
|
||||
}
|
||||
|
||||
/** Gruppe von Symbol-Knöpfen (eine Wahl); der Tooltip trägt die Beschriftung. */
|
||||
export function IconChoice<T extends string>({ value, onChange, options, label }: { value: T; onChange: (v: T) => void; options: Choice<T>[]; label: string }) {
|
||||
return (
|
||||
<div className="look-choice" role="group" aria-label={label}>
|
||||
{options.map((o) => (
|
||||
<button
|
||||
key={o.value}
|
||||
type="button"
|
||||
className={`look-choice-btn${value === o.value ? " active" : ""}`}
|
||||
aria-pressed={value === o.value}
|
||||
title={o.label}
|
||||
aria-label={o.label}
|
||||
data-testid={`look-${o.value}`}
|
||||
onClick={() => onChange(o.value)}
|
||||
>
|
||||
{o.icon}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const lbl = (k: string) => t(`objinfo.sectionLine.look.${k}` as TranslationKey);
|
||||
|
||||
export function SectionLookFields({
|
||||
level,
|
||||
project,
|
||||
planLevelId,
|
||||
onPatch,
|
||||
}: {
|
||||
level: DrawingLevel;
|
||||
project: Project;
|
||||
planLevelId: string;
|
||||
onPatch: (patch: Partial<DrawingLevel>) => void;
|
||||
}) {
|
||||
const elev = level.kind === "elevation";
|
||||
const eff = effectiveSectionLook(level, marksOfPlan(project, planLevelId, elev));
|
||||
const icon = (key: string) => (elev ? ELEVATION_ICONS[key] : undefined) ?? ICONS[key];
|
||||
const modes: SectionLineMode[] = ["full", "ends", "none"];
|
||||
const markers: SectionMarker[] = elev ? ["triangle", "arrow", "none"] : ["arrow", "lAngle", "triangle", "none"];
|
||||
const ats: SectionMarkerAt[] = ["both", "start", "end"];
|
||||
const pens = project.pens ?? [];
|
||||
const penSet = project.penSets?.find((s) => s.id === project.activePenSetId);
|
||||
const overridden = [level.lineMode, level.endLengthMm, level.lineStyleId, level.linePenId, level.marker, level.markerAt, level.markerLabel].some((v) => v !== undefined);
|
||||
return (
|
||||
<>
|
||||
<div className="objinfo-sep" />
|
||||
<div className="objinfo-section-label">{t("objinfo.sectionLine.look")}</div>
|
||||
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{lbl("line")}</span>
|
||||
<IconChoice
|
||||
label={lbl("line")}
|
||||
value={eff.lineMode}
|
||||
onChange={(v) => onPatch({ lineMode: v })}
|
||||
options={modes.map((m) => ({ value: m, label: lbl(m), icon: icon(`line:${m}`) }))}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{eff.lineMode !== "none" && (
|
||||
<>
|
||||
{eff.lineMode === "ends" && (
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{lbl("endLength")}</span>
|
||||
<input
|
||||
type="number"
|
||||
className="objinfo-text"
|
||||
step={1}
|
||||
min={2}
|
||||
max={60}
|
||||
value={level.endLengthMm ?? eff.endLengthMm}
|
||||
onChange={(e) => {
|
||||
const v = Number(e.target.value);
|
||||
if (Number.isFinite(v) && v > 0) onPatch({ endLengthMm: v });
|
||||
}}
|
||||
title={lbl("endLength")}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{lbl("lineStyle")}</span>
|
||||
<Dropdown
|
||||
value={level.lineStyleId ?? ""}
|
||||
onChange={(v) => onPatch({ lineStyleId: v === "" ? undefined : v })}
|
||||
options={[{ value: "", label: t("attr.lineStyle.none") }, ...project.lineStyles.map((l) => ({ value: l.id, label: l.name }))]}
|
||||
title={lbl("lineStyle")}
|
||||
width={150}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{lbl("pen")}</span>
|
||||
<Dropdown
|
||||
value={level.linePenId ?? ""}
|
||||
onChange={(v) => onPatch({ linePenId: v === "" ? undefined : v })}
|
||||
options={[
|
||||
{ value: "", label: t("attr.lineStyle.none") },
|
||||
...pens.map((p) => {
|
||||
const w = penSet?.pens[p.id]?.weight;
|
||||
return { value: p.id, label: w ? `${p.name} · ${w} mm` : p.name };
|
||||
}),
|
||||
]}
|
||||
title={lbl("pen")}
|
||||
width={150}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{lbl("marker")}</span>
|
||||
<IconChoice
|
||||
label={lbl("marker")}
|
||||
value={eff.marker}
|
||||
onChange={(v) => onPatch({ marker: v })}
|
||||
options={markers.map((m) => ({ value: m, label: lbl(m), icon: icon(`marker:${m}`) }))}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{!elev && eff.marker !== "none" && (
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{lbl("markerAt")}</span>
|
||||
<IconChoice
|
||||
label={lbl("markerAt")}
|
||||
value={eff.markerAt}
|
||||
onChange={(v) => onPatch({ markerAt: v })}
|
||||
options={ats.map((m) => ({ value: m, label: lbl(m), icon: icon(`at:${m}`) }))}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{lbl("label")}</span>
|
||||
<input type="checkbox" checked={eff.markerLabel} onChange={(e) => onPatch({ markerLabel: e.target.checked })} title={lbl("label")} />
|
||||
</div>
|
||||
|
||||
{overridden && (
|
||||
<button
|
||||
type="button"
|
||||
className="objinfo-btn"
|
||||
onClick={() => onPatch({ lineMode: undefined, endLengthMm: undefined, lineStyleId: undefined, linePenId: undefined, marker: undefined, markerAt: undefined, markerLabel: undefined })}
|
||||
>
|
||||
{lbl("reset")}
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
+10
-1
@@ -33,6 +33,7 @@ export type ModelViewSection =
|
||||
| "elevation"
|
||||
| "site"
|
||||
| "sectionMarks"
|
||||
| "elevationMarks"
|
||||
| "roomStamps"
|
||||
| "dimensions"
|
||||
| "situation";
|
||||
@@ -210,7 +211,15 @@ export const MODEL_VIEW_FIELDS: readonly ModelViewField[] = [
|
||||
{ section: "elevation", key: "shadows", values: "bool" },
|
||||
{ section: "elevation", key: "materialHatch", values: "bool" },
|
||||
{ section: "site", key: "terrain", values: "bool" },
|
||||
{ section: "sectionMarks", key: "style", values: ["arrow", "lAngle"] },
|
||||
{ section: "sectionMarks", key: "lineMode", values: ["full", "ends", "none"] },
|
||||
{ section: "sectionMarks", key: "endLengthMm", values: [6, 9, 12, 15, 20] },
|
||||
{ section: "sectionMarks", key: "marker", values: ["arrow", "lAngle", "triangle", "none"] },
|
||||
{ section: "sectionMarks", key: "markerAt", values: ["both", "start", "end"] },
|
||||
{ section: "sectionMarks", key: "markerLabel", values: "bool" },
|
||||
{ section: "elevationMarks", key: "lineMode", values: ["full", "ends", "none"] },
|
||||
{ section: "elevationMarks", key: "endLengthMm", values: [6, 9, 12, 15, 20] },
|
||||
{ section: "elevationMarks", key: "marker", values: ["triangle", "arrow", "none"] },
|
||||
{ section: "elevationMarks", key: "markerLabel", values: "bool" },
|
||||
{ section: "roomStamps", key: "number", values: "bool" },
|
||||
{ section: "roomStamps", key: "area", values: "bool" },
|
||||
{ section: "roomStamps", key: "usage", values: "bool" },
|
||||
|
||||
@@ -258,8 +258,13 @@ export function buildElementAttributesHost(c: FlatHostOpts) {
|
||||
},
|
||||
// ── Schnitt-/Ansichtslinie (nur bei selektierter Linie) ────────────────
|
||||
sectionLine,
|
||||
// Mehrfachauswahl ([276]): die Änderung trifft alle gewählten Schnitt-/Ansichtslinien, ein Undo-Schritt.
|
||||
onSetSectionLinePatch: (patch) => {
|
||||
if (sectionLine) patchLevel(sectionLine.id, patch);
|
||||
if (!sectionLine) return;
|
||||
const ids = getState().selection.sectionLines;
|
||||
if (ids.length > 1 && ids.includes(sectionLine.id)) {
|
||||
applyChange((p) => patchItems(p, "drawingLevels", ids, (l) => ({ ...l, ...patch })));
|
||||
} else patchLevel(sectionLine.id, patch);
|
||||
},
|
||||
onDeleteSectionLine: () => {
|
||||
if (sectionLine) patchLevel(sectionLine.id, { linePoints: undefined });
|
||||
|
||||
@@ -45,7 +45,8 @@ export function useSelectionState() {
|
||||
selectedWallId: selection.walls[0] ?? null,
|
||||
selectedDrawingId: single(selection, "drawings"),
|
||||
selectedCeilingId: single(selection, "ceilings"),
|
||||
selectedSectionLineId: single(selection, "sectionLines"),
|
||||
// Bei Mehrfachauswahl zeigt die Objekt-Info die erste Linie; Änderungen treffen alle ([276]).
|
||||
selectedSectionLineId: selection.sectionLines[0] ?? null,
|
||||
selectedRoomId: single(selection, "rooms"),
|
||||
elementClipboard,
|
||||
setElementClipboard,
|
||||
|
||||
@@ -10468,3 +10468,29 @@ body {
|
||||
.reno-phase-styles .reno-link-btn {
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
/* [276] Darstellung der Schnitt-/Ansichtslinie: Symbol-Knöpfe mit Vorschau (Objekt-Info). */
|
||||
.look-choice {
|
||||
display: inline-flex;
|
||||
gap: 2px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.look-choice-btn {
|
||||
padding: 2px 3px;
|
||||
border: 1px solid var(--border, #3a3f47);
|
||||
border-radius: 4px;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
line-height: 0;
|
||||
}
|
||||
.look-choice-btn:hover {
|
||||
background: var(--hover, rgba(127, 127, 127, 0.15));
|
||||
}
|
||||
.look-choice-btn.active {
|
||||
border-color: var(--accent, #4c8dff);
|
||||
background: var(--accent-soft, rgba(76, 141, 255, 0.18));
|
||||
}
|
||||
.look-icon {
|
||||
display: block;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ export interface ModelViewHandlers {
|
||||
onSetModelViewOption?: (id: string, section: ModelViewSection, key: string, value: string | number | boolean | null) => void;
|
||||
}
|
||||
|
||||
const SECTIONS: ModelViewSection[] = ["doors", "windows", "stairs", "walls", "slabs", "roofs", "columns", "elevation", "site", "sectionMarks", "roomStamps", "dimensions", "situation"];
|
||||
const SECTIONS: ModelViewSection[] = ["doors", "windows", "stairs", "walls", "slabs", "roofs", "columns", "elevation", "site", "sectionMarks", "elevationMarks", "roomStamps", "dimensions", "situation"];
|
||||
|
||||
/** Anzeige eines Auswahlwerts (Zahlen mit Einheit, Rest übersetzt). */
|
||||
function valueLabel(f: ModelViewField, v: string | number): string {
|
||||
|
||||
Reference in new issue
Block a user