Merge [271] Umbaufilter
This commit is contained in:
73 files changed
+2887
-55
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
|
||||
- ◐ **[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); Ersatzstücke der Öffnungen nur im Grundriss (Schnitt/Ansicht: Öffnung fehlt bzw. ist da, ohne gelbes/rotes Stück); Linien der Projektion im Schnitt und Öffnungen in der Ansicht ohne Umbau-Farbe; Bogenwände ohne Ersatzstück; Cycles/Blender und Explosionsaxonometrie ohne Filter; Picken im 3D trifft ausgeblendete Bauteile; 2D-Zeichnungen, Bäume (eigener Status [149]) und Bibliotheksobjekte ohne Status; Ansichtsleiste/Werkzeugleiste ohne eigene Filter-Wahl (nur Statusleiste); 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). · M
|
||||
- ◐ **[269]** Pläne schöner, Befunde aus Screenshots des Koordinators (16.11.; CLI `plan|section|elevation --hatch --template "Eingabeplan 1:100"`, SVG → Chromium; Bilder vorher/nachher `doc/review-269/`). **Behoben 17.11.:** (1) **Ausschnitt mit Parzelle:** das Plan-Ausmass endet bei Parzelle + 5 m (`SITE_MARGIN_M`) vereinigt mit Haus ± Marken-Reichweite und den nicht weitreichenden Zeichnungen (Titel, Massstab, Bemassung; Kataster/Strassen/Höhenlinien/Bäume/Kontext-Klassen zählen nicht, `drawings::is_far_class`); keine Beschneidung im Situationsplan und bei sichtbarem Schatten (`extras::site_clip`, in beiden Puffer-Wegen von `domains.rs`). Wettbewerb EG 1:200: SVG 85 × 54.9 m → 46 × 37.9 m; Musterhaus komplex EG 99 × 63.6 → 55 × 46.6 m. Layout-Viewports/Plakat croppen schon über [208] (`crop`, Haus + 20 mm) und ändern sich praktisch nicht; Einpassen beim Öffnen nutzt `house`. Die Linien ausserhalb bleiben im SVG (werden von der viewBox abgeschnitten), nicht geometrisch gekappt. (2) **Gartenkörper:** Brunnen, Loft, Rotationskörper im Musterhaus komplex lagen auf „20 Wände“, jetzt Klasse „24 Fahrzeuge & Freiflächen“ (`GARDEN_CLASS`) — in Grundriss, Schnitt und Ansicht ausschaltbar. Die Vorlage „Eingabeplan 1:100“ blendet 24 NICHT aus (würde auch Parkfelder/Fahrzeuge im Grundriss ausblenden; fachlicher Entscheid offen für den Maintainer); im Nachher-Bild `--hide …,24`. Der Standard für neue freie Körper bleibt die aktive Klasse. (3) **Dachziegel/Ansichtsschraffur:** Musterlinien in der Ansicht nie enger als 2.5 mm Papier (`PATTERN_MIN_PAPER_MM`, dünnt bei 1:100 und 1:200 gleich aus, vorher 0.7 mm), Standardstärke 0.05 statt 0.1 mm (höchstens 0.09), Vorgabefarbe unverändert. (4) **Hinweistext:** im Beispiel jetzt im Wohnraum über der Hebeschiebetür mit kurzer Führungslinie; Führungslinien setzen vor Masszahlen, Texten und Koten aus (`cut_at_gaps`, mit Wächter gegen Rekursion in der Hindernisberechnung — erste Fassung stürzte im WASM mit Stack-Überlauf ab, im nativen Test nicht); Titel „Erdgeschoss“ und Massstabsbalken rücken ans Haus. Tests: Rust `ausmass_endet_an_parzelle_plus_rand`, `fuehrungslinie_setzt_vor_masszahlen_aus`, `ansichtsschraffur_massstabsgerecht_und_fein`; Goldens `komplex-ansicht-ansicht-sued`, `komplex-grundriss-eg-100/-50` (Hinweis/Titel/Massstab verschoben, Ansichtsschraffur dünner und seltener). **Offen:** Ausschnitt nur Linux/CLI angesehen (nicht in der App/Metal), Beschriftung am Rand (z. B. „Kat.-Nr. 1188“) kann angeschnitten sein; Schnitt/Ansicht-Ausmass nicht beschnitten (Gelände); Eingabeplan-Klasse 24 s. o.; Stossfugen-Muster (Läuferverband) in der Ansicht nicht eigens geprüft. · S
|
||||
- ◐ **[268]** Review der Änderungen vom 15./16.11. auf echte Fehler vor der Beta (16.11.; [256] [260] [261] [262] [263] [264] [265] [266] [267] [170] [30]). **Behoben 16.11.:** (1) **Datenverlust nach Sprachwechsel** ([264] `LanguageRoot` baut die App neu auf): zuletzt gespeicherter Stand, Pfad, Lock und Autosave-Stand lagen in `useRef` von `useProjectFileActions` und wurden zurückgesetzt — danach galten ungespeicherte Änderungen als gespeichert, Neu/Öffnen/Fenster schliessen verwarfen sie ohne Rückfrage, Cmd+S fragte neu nach dem Pfad, der Lock der offenen Datei blieb liegen; zudem erschien die Autosave-Kopie der laufenden Sitzung als „Ungesicherte Arbeit gefunden“. Jetzt Sitzungszustand ausserhalb von React (`FileSession`), Suche nach Kopien einmal je Seitenladen; e2e `languageSwitch268.spec.ts` (vorher rot, beide Fälle). (2) **Release-Skript** (`scripts/release-gitea.mjs`): jeder Fehler beim Lesen von `versions.json` (Netz, 5xx, Proxy) galt als „leer“ — `--publish` überschrieb den Versionsverlauf mit nur der neuen Version; ein nicht lesbares `SHA256SUMS.txt` der anderen Plattform fiel stillschweigend aus den Prüfsummen. Jetzt nur 404 = leer, sonst Abbruch (`fetchExisting`, `parseSums` in `release-gitea-lib.cjs`, Test `releaseGitea.test.ts`). **Offen (Verdacht ohne Nachweis, Befund · Ort · Szenario · Grösse):** ~~a.~~ **Behoben 16.11. (Electron-Links):** `setWindowOpenHandler` (nie ein Kindfenster; https/mailto → `shell.openExternal`, sonst verwerfen), `will-navigate`/`will-redirect` nur im App-Ursprung (`dossier://app`, Dev-Server `localhost:5187`; fremdes https → System-Browser), CSP in `onHeadersReceived` nur für den App-Ursprung; Entscheide als reine Funktionen in `scripts/electron-links.cjs` (im Paket, `electron-builder.yml`), Test `src/native/electronLinks.test.ts` und e2e `linuxApp170.spec.ts` („Externe Links“: `window.open`/Navigation erzeugen kein Fenster, `shell.openExternal` im Hauptprozess abgefangen; mit gebautem AppImage grün). `openExternalUrl` (Fehler melden, Blender laden) nutzt unter Electron `window.open` und landet damit im System-Browser, keine App-Änderung nötig. Offen: Tauri/Mac unberührt (dort `plugin-shell`), echter Browser-Start nicht geprüft (nur Hook). b. Sprachwechsel setzt weiteren UI-Zustand zurück: Fang-Einstellungen (`useDrawingToolState`, `DEFAULT_SNAP`), aktives Werkzeug, laufender Befehl, Element-Zwischenablage (`useSelectionState`), offene Dialoge ausser Einstellungen · kein Datenverlust, aber z. B. ausgeschalteter Ortho-Fang ist danach wieder an · S. ~~c.~~ **Behoben 16.11.:** `uploadAsset` lädt beim Ersetzen erst unter `<name>.upload-<ms>` hoch, löscht dann den alten Anhang und benennt per PATCH um (`latest.json` fehlt nie; Rest `.upload-…` bei Abbruch in Gitea löschen; gegen echte Gitea-API nicht geprüft, nur `--dry-run`). ~~d.~~ **Behoben 16.11.:** ohne `--publish` auf ein veröffentlichtes Release Abbruch, bewusst mit `--replace-published` (`preflight` in `release-gitea-lib.cjs`, läuft vor dem Anlegen des Entwurfs). ~~e.~~ **Behoben 16.11.:** `--publish` ohne Mac-Pakete (weder im Ordner noch am Release) bricht ab, bewusst nur Linux mit `--linux-only`; Tests `releaseGitea.test.ts`, README „Release auf Gitea“ nachgeführt. **Geprüft ohne Befund:** `elevation_set.rs` (Faltung, Namen, vorhandene Seiten), `kernel2d/src/rooms.rs` (Offset je Kante, NaN), `standards_names.rs`/Standards-Abgleich (kein Duplikat, „Aktualisieren“ hält englische Namen), `stamp_place.rs` `cut_out` (NaN ohne Panic), [262] Offline-Pfade und Host-/CSP-Listen (Overpass, http-Fähigkeit Gitea), [261] `build-number.cjs`, Kurzanleitung (`miniMarkdown` ohne HTML), Dock-Einklappen (`reconcileLayout`), Electron-Argumentdatei (`take-open-file` einmalig). Nicht geprüft: Mac/Tauri, Electron-Paket, GPU-Renderer über mehrere Sprachwechsel (Speicher), [216] Erker und [208] DXF-MTEXT im Detail.
|
||||
- ◐ **[263]** Visuelle und UX-Prüfung des Referenz-Ablaufs (15.11., Wunsch Maintainer „prüfe auch visuell und UX“): Chromium/Linux, Screenshots 1280×800 (de hell, de dunkel, en hell, 1440×900 und 1920×1080 stichprobenweise) von Start, Neues Projekt, allen Dock-Reitern, Menüs, Einstellungen/Über/Kürzel/Ressourcen/Verlauf/BCF/3D-Bild/Rendering/DXF-/IFC-Export/Standort-Import, Musterhaus, Musterhaus komplex, Wettbewerb (Plan, Objekt-Info, Taste T, Mappe, Plakat-Blatt, Publikationssatz). Automatisch geprüft: Symbolknöpfe ohne Tooltip (0 Funde), rohe Übersetzungs-Schlüssel (0), abgeschnittene Texte, Esc/Enter an Dialogen (alle modalen Dialoge schliessen mit Esc). **Behoben 15.11.:** (1) unbekannter Befehl in der Befehlszeile tat nichts, jetzt Meldung „Unbekannter Befehl …“ (`engine.ts`, `cmd.unknown`); (2) Layout-Werkzeugleiste: Tabellen-Auswahl auf den Pfeil geschrumpft und „Einpassen“ ausserhalb, jetzt Umbruch; (3) Attribute-Panel: Quellen-Auswahl neben der Strichstärke zeigte „e ▾“ (Label-Spalte höchstens 42 %); (4) Standort-Import: Platzhalter der Bezugspunkt-Felder abgeschnitten; (5) Ansichtsleiste: Ausblendung am rechten Rand, wenn dort noch Bedienelemente liegen; (6) Schreibweise: de „Schließen/Maßstab/Außen“ gemischt mit „Schliessen/Massstab/Aussen“ → überall Schweizer „ss“ (Test `src/i18n/spelling.test.ts`), „Snap-/Endpunkt-Farbe“ → „Fang-“, en „room program“/„colour“ → „room programme“/„color“. e2e: `e2e/uxReview263.spec.ts`. **Nachtrag 17.11. (Statusleiste, in GitHub Actions rot):** Der Wertcluster schnitt bei breiteren System-Schriften (ubuntu-latest) Felder ab. Jetzt kürzt sich die Leiste nach Priorität (`StatusBar.tsx`, gemessen per `scrollWidth`/ResizeObserver, kein Abschneiden mehr): 1 Beschriftungen weg (Tooltip bleibt, X/Y und LV95 behalten sie) · 2 Einheit und Build weg · 3 Linien-Darstellung, 4 Pausfolie, 5 Fang und Referenzlinien in ein Überlauf-Menü „⋯“ (Popover nach oben, Esc schliesst); Geschoss und Ebene bleiben immer. Der Cluster-Rand ist nicht mehr `overflow: hidden` (Popover wurden sonst beschnitten). e2e simuliert die CI-Schrift (DejaVu Sans + Zeichenabstand) bei 1280, 1440 und 1024 px (vorher rot). Nicht auf dem Mac geprüft. **Offen (nach Wichtigkeit, Grösse):**
|
||||
|
||||
@@ -463,6 +463,19 @@ sich mit starrer Geometrie nicht speichern. Aufbau in `src-tauri/core/src/furnit
|
||||
Neues eingebautes Objekt: Eintrag in `furniture_lib.rs::build()` (Definition + Zeichenfunktion), Namen in `de.ts`/`en.ts`.
|
||||
Standards laden ergänzt die Klassen „Möbel", „Sanitär" und „Fahrzeuge & Freiflächen" (`standards.rs::merge_plan`).
|
||||
|
||||
### 3.8 Umbaufilter ([271])
|
||||
|
||||
Wie Archicads „Renovation": Bauteile und Räume tragen `renovation: { status: existing | demolish | new, phase? }` (fehlt =
|
||||
Bestand; Öffnung ohne eigenen Status folgt ihrer Wand), das Projekt `renovation` (Etappen, Farben, eigene Filter). **Ein Ort:**
|
||||
`src-tauri/core/src/renovation.rs` — `View` (Filter + Etappe, aufgelöst: angefragt über Argument `renovation`/`renovationPhase`,
|
||||
sonst `DrawingLevel.renovationFilter`, wie die Modelldarstellung) und `View::resolve` → `Resolved` (ausgeblendete Ids, Farbe je Id,
|
||||
Ersatzstücke der Öffnungen in Bestandswänden). Es fragen: Grundriss (`Ctx::new` legt Ausgeblendetes zu `hidden` — dieselbe Wirkung
|
||||
wie die Regel „Ausblenden“, eine Öffnung schliesst ihre Wand; Farben je Element-Bereich in `walls.rs::plan_walls` und
|
||||
`domains_before`), Schnitt (`without_elements` + `CutRules::with_renovation`), Ansicht (`elevation_plan_buf`, `face::renovation_faces`),
|
||||
Vektor-Axo (`axo_plan_buf`), 3D (`model3dParts` mit `text.renovation`, ohne Teil-Cache; `color_parts`), Kennzahlen/Flächen
|
||||
(`text` = Filter-Id), DXF (`dxf.rs::renovation_layers`) und IFC (`ifc_data.rs::renovation_props`). Neue Bauteile der Zeichenbefehle
|
||||
bekommen den Zeichen-Status über `commands::stamp_renovation` (Anfrage-Feld `renovation`, gesetzt in `projectSlice.applyCmd`).
|
||||
|
||||
---
|
||||
|
||||
## 4. Schnitt
|
||||
|
||||
@@ -344,6 +344,29 @@ Speichern. Meldet Dossier, dass die automatische Sicherung nicht geschrieben wer
|
||||
|
||||
Zum Schluss ⌘S. Das Projekt (`.obp`) enthält Volumen, Räume, Baurecht, Raumprogramm, Blätter und Publikationssätze.
|
||||
|
||||
## 12. Umbau
|
||||
|
||||
Für Umbauten trägt jedes Bauteil (Wand, Öffnung, Decke, Dach, Treppe, Stütze, Körper) und jeder Raum einen Umbau-Status:
|
||||
„Bestand“, „Abbruch“ oder „Neu“. Zum Ausprobieren: *Datei → Neu aus Vorlage: Beispiel Umbau* (Zwischenwand abgebrochen,
|
||||
Fenster zugemauert, neues Fenster in der Westwand, Anbau in der zweiten Etappe).
|
||||
|
||||
- **Status setzen:** Bauteile wählen, in der **Objekt-Info** (auch Objekteinstellungen, Taste T) das Feld „Umbau“ und die
|
||||
„Etappe“ wählen; bei Mehrfachauswahl ändern sich alle in einem Schritt. Oder den Befehl `umbau` tippen und B, A oder N.
|
||||
- **Neue Bauteile:** Vorgabe ist „Bestand“. Rechts in der Statusleiste zeigt der Knopf Umbau den Zeichen-Status; ein Klick
|
||||
öffnet „Neue Bauteile zeichnen als“ (Status und Etappe). Bei wenig Platz liegt er unter ⋯.
|
||||
- **Umbaufilter:** im selben Popover der „Umbaufilter“ der aktiven Ansicht (Geschoss, Schnitt, Ansicht): „Bestand“ (alles,
|
||||
was heute steht), „Abbruch“ (Abbruch gelb und gestrichelt), „Neubau“ (Neu rot, Abbruch weg), „Umbauplan“ (Bestand grau,
|
||||
Abbruch gelb, Neu rot nach SIA 400) und „Endzustand“ (ohne Farben, Abbruch weg). Mit „Filter bis Etappe“ zeigt der Plan den
|
||||
Stand einer Etappe. Der Filter gehört zur Ebene wie die Modelldarstellung; Ausschnitte und Ansichtsvorlagen merken ihn.
|
||||
- **Öffnungen in Bestandswänden:** eine neue Öffnung bricht Mauerwerk ab (im Umbauplan ein gelbes Stück, im Bestand ist die
|
||||
Wand zu), eine Öffnung „Abbruch“ wird zugemauert (rote Ausfachung, im Neubau und Endzustand ist die Wand zu).
|
||||
- **Etappen und Farben:** *Fenster → Ressourcen*, Reiter „Umbau“: „Etappe hinzufügen“, umbenennen, Reihenfolge; die
|
||||
„Umbau-Farben“ je Status (Füllung, Linie, gestrichelt).
|
||||
- **Flächen:** Panel Flächenbilanz, „Zustand“ Bestand oder Endzustand.
|
||||
- **Exporte:** DXF legt Abbruch und Neu auf eigene Layer (z. B. 20_Wände_Abbruch), IFC schreibt den Status als `Status` im
|
||||
`Pset_WallCommon` (NEW, EXISTING, DEMOLISH) und die Etappe in `Dossier_Umbau`. Kommandozeile: `--renovation umbauplan`
|
||||
(und `--phase`) bei plan, section, elevation, axo, model3d und kennzahlen.
|
||||
|
||||
---
|
||||
|
||||
## Noch offen
|
||||
|
||||
@@ -178,6 +178,7 @@ und Befunde in `TODO.md` eintragen.
|
||||
| 13.34 | **Grafikkarte weg, Plan und 3D ([118], [206]):** Plan und 3D offen, im Begehen (Umschalt+F) die Kamera verstellen, dann Mac in den Ruhezustand/Grafik wechseln; mehrmals wiederholen | Plan bleibt dabei beim SVG und flackert nicht; 3D baut nach Pausen neu auf, Kamera, Standpunkt und Begehen bleiben erhalten, G/WASD wirken weiter; bei dauerndem Ausfall Hinweis «3D-Engine nicht verfügbar», Speichern geht |
|
||||
| 13.35 | **Version und Build ([261]):** `npm run tauri:build`, App im Finder wählen → Informationen; Dossier → Über dossier; Statusleiste rechts unten | Finder: Version 1.0.0-beta.1 (Build 261115.N in der Bundle-Version); Über-Dialog „1.0.0-beta.1 (Build …)“ gleiche Nummer; Statusleiste „Build …“ |
|
||||
| 13.36 | **Blickrichtungen seitenrichtig ([270]):** Musterhaus komplex (Erker im Osten = Plan rechts); 3D-Fenster (Metal) nacheinander Oben, Vorne, Rechts, Isometrie Südost, Südwest, Nordost, Nordwest; dann Ausschnitt „Axonometrie Südost“ auf einem Blatt und `rendering` mit Kamera „Südost“; im 3D Maus nach rechts ziehen (Orbit), rechte Maustaste ziehen (Pan), Begehen mit D, Umschauen; Gelände/Kataster-Kontext (swisstopo) und eine Punktwolke laden; Luftbild drapieren | Oben = Grundriss (Norden oben, Erker rechts, nicht kopfüber); Vorne = Südfassade mit Erker rechts; Rechts = Ostfassade; Isometrie Südost zeigt Süd- und Ostfassade, Erker rechts — gleich wie Axonometrie Südost, Cycles „Südost“ und die Ansicht Süd; Orbit dreht das Modell mit der Maus, Pan folgt der Maus, D läuft nach rechts; Gelände, Baugrube, Verbau, Punktwolke und Luftbild liegen deckungsgleich unter dem Haus (nicht an y = 0 gespiegelt), Strassen/Gebäude des Kontexts seitenrichtig; Schatten fallen auf die richtige Seite (Nachmittag: nach Osten) |
|
||||
| 13.37 | **Umbau ([271]):** *Datei → Neu aus Vorlage: Beispiel Umbau*; Statusleiste „Umbau“ → Umbaufilter nacheinander Bestand, Abbruch, Neubau, Umbauplan, Endzustand (Erdgeschoss, dann Schnitt A); Wand W9 wählen, Objekt-Info „Umbau“ auf Neu, ⌘Z; Zeichen-Status Neu, eine Wand zeichnen; Flächenbilanz „Zustand“ Bestand/Endzustand; PDF und DXF des Umbauplans | Bestand ohne Anbau und neues Fenster (Westwand zu); Abbruch: Zwischenwand gelb gestrichelt, gelbes Stück im neuen Fenster; Neubau: Anbau und neue Tür rot, Nordfenster rot zugemauert; Umbauplan alle drei Farben; Endzustand ohne Farben; Schnitt gleich; neue Wand rot im Umbauplan; ⌘Z nimmt die Status-Änderung in einem Schritt zurück; GF im Endzustand grösser; DXF mit Layern „…_Abbruch“/„…_Neu“; am Bildschirm (Metal) wie im PDF |
|
||||
|
||||
## 14. Datensicherheit auf dem Mac ([116], Audit 14.11.)
|
||||
|
||||
|
||||
@@ -84,6 +84,12 @@ in `doc/KURZANLEITUNG.md`):
|
||||
LV95-Lage als Georeferenz (Versatz und ±0.00 m ü. M.), Räume mit Nummer, Name, Fläche und SIA-416-Kategorie, Geschossflächen und
|
||||
Gebäudesummen; Mengen stimmen mit der Geometrie überein (mit ifcopenshell gegengeprüft, alle drei Beispielprojekte ohne Befund). Option
|
||||
«Kontext mitgeben (Gelände, Nachbargebäude)» im Export-Dialog bzw. `--kontext` (Vorgabe aus). Die Objektbibliothek (Möbel, Sanitär) wird nicht ins IFC geschrieben. Was in welche Richtung verloren geht, steht in `doc/DATEIFORMATE.md`.
|
||||
13. **Umbau (17.11., [271]).** Jedes Bauteil und jeder Raum trägt einen Umbau-Status Bestand, Abbruch oder Neu und optional eine Etappe
|
||||
(Objekt-Info, Befehl `umbau`; neue Bauteile mit dem Zeichen-Status aus der Statusleiste, Vorgabe Bestand). Umbaufilter wie in Archicad
|
||||
je Ansicht: Bestand, Abbruch, Neubau, Umbauplan (SIA 400: Bestand grau, Abbruch gelb gestrichelt, Neu rot) und Endzustand, bis zu einer
|
||||
Etappe; neue Öffnungen in Bestandswänden zeigen das abgebrochene Mauerwerk, zugemauerte Öffnungen die Ausfachung. Gilt in Grundriss,
|
||||
Schnitt, Ansicht, Vektor-Axonometrie, Kennzahlen (Bestand/Endzustand) und Exporten (DXF-Layer je Status, IFC `Status` im
|
||||
`Pset_*Common`). Beispiel: *Datei → Neu aus Vorlage: Beispiel Umbau*. Das 3D-Fenster folgt dem Filter der aktiven Ebene (noch ohne Bildprüfung); Cycles/Blender noch ohne Filter.
|
||||
|
||||
**Erker und Wiederanlauf (15.11.).** Fenster in Bogenwänden (Erker) sitzen in Schnitt und Ansicht wie im 3D und im Grundriss auf der Sehne; die Sehnen-Zonen
|
||||
gelten über alle Geschosse, der Deckenrand folgt der Sehne ([216]). Raumstempel rücken in Lücken zwischen den Linien, bevor sie schrumpfen; die Baulinie setzt vor
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 70 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 76 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 161 KiB |
@@ -0,0 +1,70 @@
|
||||
// [271] Umbau: Beispiel Umbau öffnen, Umbaufilter in der Statusleiste umschalten (Plan-Farben nach SIA), Undo des
|
||||
// Filters, Status einer Wand in der Objekt-Info setzen (ein Undo-Schritt), Befehl `umbau` auf der Auswahl, Zeichen-Status.
|
||||
// Geprüft über die sichtbare UI und den Plan (Test-Naht `planFillColors`, `renovation`), nicht über Pixel.
|
||||
import { blurFocus, discardIfAsked, expect, fileMenu, openTab, test, typeCommand } from "./app";
|
||||
|
||||
const GREY = "#a6a6a6";
|
||||
const YELLOW = "#ffd800";
|
||||
const RED = "#e3001b";
|
||||
|
||||
test("Umbaufilter, Status setzen und Undo ([271])", async ({ page }) => {
|
||||
await page.goto("/?dossierTest");
|
||||
await page.getByRole("button", { name: /Neues Projekt/ }).first().click();
|
||||
await expect(page.getByRole("group", { name: "Befehlszeile" })).toBeVisible();
|
||||
await fileMenu(page, /^Neu aus Vorlage: Beispiel Umbau$/);
|
||||
await discardIfAsked(page);
|
||||
await expect(page.locator(".project-name")).toHaveText("Beispiel Umbau");
|
||||
const fills = () => page.evaluate(() => window.__dossierTest!.planFillColors());
|
||||
const ren = () => page.evaluate(() => window.__dossierTest!.renovation());
|
||||
// Ohne Filter: keine Umbau-Farben.
|
||||
expect(Object.keys(await fills())).not.toContain(RED);
|
||||
|
||||
// Statusleiste: Umbau → Umbaufilter „Umbauplan“.
|
||||
const toggle = page.getByTestId("renovation-toggle");
|
||||
await expect(toggle).toContainText("Bestand");
|
||||
await toggle.click();
|
||||
const panel = page.getByTestId("renovation-panel");
|
||||
await expect(panel).toBeVisible();
|
||||
await panel.getByTestId("renovation-filter").selectOption("umbauplan");
|
||||
await expect.poll(async () => (await ren()).filter).toBe("umbauplan");
|
||||
await expect.poll(async () => Object.keys(await fills()).filter((c) => [GREY, YELLOW, RED].includes(c)).sort()).toEqual([GREY, RED, YELLOW].sort());
|
||||
await page.screenshot({ path: "test-results/renovation271-umbauplan.png" });
|
||||
|
||||
// Neubau: Abbruch weg (kein Gelb), Neu rot.
|
||||
await panel.getByTestId("renovation-filter").selectOption("neubau");
|
||||
await expect.poll(async () => (await ren()).filter).toBe("neubau");
|
||||
await expect.poll(async () => Object.keys(await fills())).not.toContain(YELLOW);
|
||||
expect(Object.keys(await fills())).toContain(RED);
|
||||
await page.keyboard.press("Escape");
|
||||
await blurFocus(page);
|
||||
// Undo nimmt den Filterwechsel zurück (Feld der Ebene).
|
||||
await page.keyboard.press("ControlOrMeta+z");
|
||||
await expect.poll(async () => (await ren()).filter).toBe("umbauplan");
|
||||
|
||||
// Wand W1 wählen, Objekt-Info: Umbau → Neu; Undo in einem Schritt.
|
||||
await page.evaluate(() => window.__dossierTest!.select({ walls: ["W1"] }));
|
||||
await openTab(page, "Objekt-Info");
|
||||
const field = page.getByTestId("objinfo-renovation");
|
||||
await expect(field).toBeVisible();
|
||||
await field.getByRole("button", { name: "Umbau" }).click();
|
||||
await page.getByRole("option", { name: "Neu", exact: true }).click();
|
||||
await expect.poll(async () => (await ren()).walls.W1).toBe("new");
|
||||
await blurFocus(page);
|
||||
await page.keyboard.press("ControlOrMeta+z");
|
||||
await expect.poll(async () => (await ren()).walls.W1).toBe("existing");
|
||||
|
||||
// Befehl `umbau` auf der Auswahl: Option A (Abbruch).
|
||||
await page.evaluate(() => window.__dossierTest!.select({ walls: ["W1", "W2"] }));
|
||||
await typeCommand(page, "umbau");
|
||||
await typeCommand(page, "A");
|
||||
await expect.poll(async () => {
|
||||
const w = (await ren()).walls;
|
||||
return [w.W1, w.W2];
|
||||
}).toEqual(["demolish", "demolish"]);
|
||||
|
||||
// Zeichen-Status in der Statusleiste: Neu.
|
||||
await page.getByTestId("renovation-toggle").click();
|
||||
await page.getByTestId("renovation-draw-status").selectOption("new");
|
||||
await expect.poll(async () => (await ren()).draw).toBe("new");
|
||||
await expect(page.getByTestId("renovation-toggle")).toContainText("Neu");
|
||||
});
|
||||
@@ -32,6 +32,7 @@ Neues Modul: `<modul>.rs` und `mod` in `lib.rs`, Bindungen in `web/<modul>.rs` u
|
||||
| `plan/` | Grundriss, Deckenspiegel, Schnitt, Ansicht, Ausgaben; eigene `plan/README.md` |
|
||||
| `gpu_compile.rs` | GPU-Kompilierung von Plan-Puffern (nativer macOS-Weg) |
|
||||
| `style.rs` | Farben, Schraffur und Schnitt-Linienstil aus dem Modell |
|
||||
| `renovation.rs` | [271] Umbau: Status je Bauteil, Etappen, Umbaufilter (`View`, `Resolved`), SIA-Farben; ein Ort für „sichtbar/wie gezeichnet im Filter“ (s. `doc/ARCHITEKTUR.md` 3.8) |
|
||||
| `standards.rs` | Standard-Bibliothek: Baustoffe mit SIA-400-Schraffur und Kennwerten, Linientypen, Standard-Aufbauten |
|
||||
| `standards_names.rs` | [264] Englische Namen der Standards nach Kennung (`Lang`, `name_in`); neue Projekte in englischer UI bekommen sie über `standardsMergeOps(lang)` |
|
||||
| `furniture_lib.rs` | Objektbibliothek 2D ([253]): Katalog der Standard-Symbole mit Parametern (Definition) und Zeichenfunktionen nach Detailgrad (Erzeugung), Register, Platzhalter für unbekannte Ids; s. `doc/ARCHITEKTUR.md` 3.7 |
|
||||
|
||||
@@ -33,7 +33,8 @@ pub fn ops(root: &Map<String, Value>, p: &Project, text: &str) -> Result<Vec<Op>
|
||||
return Ok(ops);
|
||||
}
|
||||
if let Some(ops) = crate::cmd_create::ops(root, p, &v) {
|
||||
return Ok(ops);
|
||||
// [271] Aktueller Zeichen-Status (`renovation` der Anfrage): neue Bauteile tragen ihn (Bestand = ohne Feld).
|
||||
return Ok(stamp_renovation(ops, v.get("renovation")));
|
||||
}
|
||||
if let Some(ops) = crate::cmd_context::ops(root, p, &v) {
|
||||
return Ok(ops);
|
||||
@@ -50,6 +51,34 @@ pub fn ops(root: &Map<String, Value>, p: &Project, text: &str) -> Result<Vec<Op>
|
||||
})
|
||||
}
|
||||
|
||||
/// Listen, deren neue Elemente den Zeichen-Status bekommen ([271]).
|
||||
const RENOVATION_COLLECTIONS: [&str; 8] = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms"];
|
||||
|
||||
/// [271] Neue Bauteile der Ops (`add` in [`RENOVATION_COLLECTIONS`]) erhalten `renovation` (ein Objekt mit gültigem
|
||||
/// `status`), sofern sie keines tragen; sonst unverändert.
|
||||
pub fn stamp_renovation(mut ops: Vec<Op>, ren: Option<&Value>) -> Vec<Op> {
|
||||
let Some(r) = ren.filter(|r| matches!(r.get("status").and_then(Value::as_str), Some("new" | "demolish" | "existing"))) else { return ops };
|
||||
let r = match (r.get("status").and_then(Value::as_str), r.get("phase").and_then(Value::as_str).filter(|x| !x.is_empty())) {
|
||||
(Some("existing"), None) => return ops,
|
||||
(Some(st), Some(ph)) => serde_json::json!({"status": st, "phase": ph}),
|
||||
(Some(st), None) => serde_json::json!({"status": st}),
|
||||
_ => return ops,
|
||||
};
|
||||
for op in ops.iter_mut() {
|
||||
if let Op::Add { collection, items, .. } = op {
|
||||
if !RENOVATION_COLLECTIONS.contains(&collection.as_str()) {
|
||||
continue;
|
||||
}
|
||||
for it in items.iter_mut() {
|
||||
if let Some(o) = it.as_object_mut() {
|
||||
o.entry("renovation").or_insert_with(|| r.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ops
|
||||
}
|
||||
|
||||
/// Wie [`ops`], mit Hinweis-Schlüssel (i18n) für die Hülle; bisher nur Verschieben ([144]: Öffnung an
|
||||
/// der Nachbaröffnung angehalten).
|
||||
pub fn result(root: &Map<String, Value>, p: &Project, text: &str) -> Result<GripResult, String> {
|
||||
|
||||
@@ -124,6 +124,22 @@ fn structure_props(external: Option<bool>, load_bearing: Option<bool>) -> Vec<Pr
|
||||
v
|
||||
}
|
||||
|
||||
/// [271] Umbau-Status als `Status` im `Pset_<Bauteil>Common` (IFC4 `PEnum_ElementStatus`: NEW, EXISTING, DEMOLISH; das
|
||||
/// IFC-Mittel für Umbau, das Revit/Archicad beim Austausch lesen) und die Etappe als `Dossier_Umbau.Etappe` (IFC kennt
|
||||
/// Bauphasen nur über Vorgänge `IfcTask` — für Austausch und Filter genügt die Eigenschaft). Nur mit Angabe im Modell.
|
||||
fn renovation_props(p: &Project, psets: &mut Vec<Pset>, common: &'static str, r: Option<&Renovation>) {
|
||||
let Some(r) = r else { return };
|
||||
let status = Prop::Label("Status", crate::renovation::ifc_status(crate::renovation::status_of(Some(r))).to_string());
|
||||
match psets.iter_mut().find(|ps| ps.name == common) {
|
||||
Some(ps) => ps.props.push(status),
|
||||
None => psets.insert(0, Pset { name: common, props: vec![status] }),
|
||||
}
|
||||
let phase = r.phase.as_deref().and_then(|id| crate::renovation::phases(p).iter().find(|x| x.id == id)).map(|x| x.name.trim()).filter(|n| !n.is_empty());
|
||||
if let Some(n) = phase {
|
||||
psets.push(Pset { name: "Dossier_Umbau", props: vec![Prop::Label("Etappe", n.to_string())] });
|
||||
}
|
||||
}
|
||||
|
||||
fn ident(name: &'static str, v: &str) -> Prop {
|
||||
Prop::Ident(name, v.to_string())
|
||||
}
|
||||
@@ -757,6 +773,7 @@ fn fill_psets(p: &Project, o: &Opening, width: f64, height: f64) -> Vec<Pset> {
|
||||
props.extend(o.u_value.filter(|u| *u > 0.0).map(|u| Prop::Thermal("ThermalTransmittance", u)));
|
||||
props.extend(label("SecurityRating", &o.burglary_class));
|
||||
let mut psets = vec![Pset { name: pset_name, props }];
|
||||
renovation_props(p, &mut psets, pset_name, crate::renovation::opening_renovation(p, o));
|
||||
psets.extend(qto(if is_door { "Qto_DoorBaseQuantities" } else { "Qto_WindowBaseQuantities" }, qty::opening_quantities(width, height)));
|
||||
psets
|
||||
}
|
||||
@@ -1128,12 +1145,14 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
props.extend(structure_props(wall.is_external, wall.load_bearing));
|
||||
props.extend(crate::u_value::wall_u_value(p, wall).and_then(|u| u.u).map(|u| Prop::Thermal("ThermalTransmittance", u)));
|
||||
let mut ps = vec![Pset { name: "Pset_WallCommon", props }];
|
||||
renovation_props(p, &mut ps, "Pset_WallCommon", wall.renovation.as_ref());
|
||||
ps.extend(q);
|
||||
(wt.name.clone(), Some((wt.id.clone(), wt.name.clone(), layers)), ps)
|
||||
}
|
||||
None => {
|
||||
props.extend(structure_props(wall.is_external, wall.load_bearing));
|
||||
let mut ps = if props.is_empty() { Vec::new() } else { vec![Pset { name: "Pset_WallCommon", props }] };
|
||||
renovation_props(p, &mut ps, "Pset_WallCommon", wall.renovation.as_ref());
|
||||
ps.extend(q);
|
||||
(wall.id.clone(), None, ps)
|
||||
}
|
||||
@@ -1405,6 +1424,7 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
if !slab_props.is_empty() {
|
||||
psets.push(Pset { name: "Pset_SlabCommon", props: slab_props });
|
||||
}
|
||||
renovation_props(&p, &mut psets, "Pset_SlabCommon", c.renovation.as_ref());
|
||||
// Aussparungen (wie im 3D) als innere Ringe des Profils; Netto zieht sie ab.
|
||||
let hole_rings = crate::opening_shape::ceiling_hole_rings(&p, c);
|
||||
let inner: Vec<&[Vec2]> = hole_rings.iter().filter(|r| r.len() >= 3).map(|r| r.as_slice()).collect();
|
||||
@@ -1717,6 +1737,7 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
props.push(Prop::Bool("IsExternal", true));
|
||||
props.extend(crate::u_value::roof_u_value(&p, roof).and_then(|u| u.u).map(|u| Prop::Thermal("ThermalTransmittance", u)));
|
||||
let mut psets = vec![Pset { name: "Pset_RoofCommon", props }];
|
||||
renovation_props(&p, &mut psets, "Pset_RoofCommon", roof.renovation.as_ref());
|
||||
let (roof_q, dormer_q) = roof_base_quantities(&p, roof);
|
||||
psets.extend(qto("Qto_RoofBaseQuantities", roof_q));
|
||||
psets.extend(qto("Qto_DossierDormerQuantities", dormer_q));
|
||||
@@ -1783,6 +1804,7 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
classified.push((format!("column/{}", col.id), Kind::Column, col.category_code.clone()));
|
||||
let label = crate::plan::domains::column_label(col);
|
||||
let mut psets = vec![Pset { name: "Pset_ColumnCommon", props: vec![ident("Reference", &label)] }];
|
||||
renovation_props(&p, &mut psets, "Pset_ColumnCommon", col.renovation.as_ref());
|
||||
let quantities = if let [(footprint, zb, zt)] = pieces.as_slice() {
|
||||
qty::column_quantities(footprint, zt - zb)
|
||||
} else {
|
||||
|
||||
@@ -59,6 +59,7 @@ pub use dossier_hatch::jsnum;
|
||||
pub use dossier_hatch::hatch;
|
||||
pub mod hatch_flat;
|
||||
pub mod plan;
|
||||
pub mod renovation;
|
||||
pub mod project_format;
|
||||
pub mod queries;
|
||||
pub mod gpu_compile;
|
||||
|
||||
@@ -1953,6 +1953,16 @@ pub struct DrawingLevel {
|
||||
#[serde(rename = "modelViewOptionId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub model_view_option_id: Option<String>,
|
||||
/// [271] Umbaufilter (eingebaut „bestand“, „abbruch“, „neubau“, „umbauplan“, „endzustand“ oder Id aus
|
||||
/// `Project.renovation.filters`). Fehlt ⇒ kein Filter: alle Bauteile wie ohne Umbau-Angaben.
|
||||
#[serde(rename = "renovationFilter", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation_filter: Option<String>,
|
||||
/// [271] Etappe, bis zu der der Umbaufilter gilt (Id aus `Project.renovation.phases`): Neues späterer Etappen fehlt
|
||||
/// noch, Abbruch späterer Etappen steht noch als Bestand. Fehlt ⇒ alle Etappen.
|
||||
#[serde(rename = "renovationPhase", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation_phase: Option<String>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -2038,6 +2048,16 @@ pub struct ViewTemplate {
|
||||
#[serde(rename = "modelViewOptionId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub model_view_option_id: Option<String>,
|
||||
/// [271] Umbaufilter (eingebaut „bestand“, „abbruch“, „neubau“, „umbauplan“, „endzustand“ oder Id aus
|
||||
/// `Project.renovation.filters`). Fehlt ⇒ kein Filter: alle Bauteile wie ohne Umbau-Angaben.
|
||||
#[serde(rename = "renovationFilter", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation_filter: Option<String>,
|
||||
/// [271] Etappe, bis zu der der Umbaufilter gilt (Id aus `Project.renovation.phases`): Neues späterer Etappen fehlt
|
||||
/// noch, Abbruch späterer Etappen steht noch als Bestand. Fehlt ⇒ alle Etappen.
|
||||
#[serde(rename = "renovationPhase", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation_phase: Option<String>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -2913,6 +2933,136 @@ pub enum SliceTermination {
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// [271] Umbau-Status eines Bauteils (Archicad „Renovation Status“; SIA 400: Bestand schwarz/grau, Abbruch gelb,
|
||||
/// Neu rot).
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
|
||||
pub enum RenovationStatus {
|
||||
#[default]
|
||||
#[serde(rename = "existing")]
|
||||
Existing,
|
||||
#[serde(rename = "demolish")]
|
||||
Demolish,
|
||||
#[serde(rename = "new")]
|
||||
New,
|
||||
#[serde(other)]
|
||||
#[ts(skip)]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// [271] Umbau-Angaben eines Elements.
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct Renovation {
|
||||
pub status: RenovationStatus,
|
||||
/// Etappe (`Project.renovation.phases`, Id): beim Status „neu“ die Bau-, bei „abbruch“ die Abbruch-Etappe.
|
||||
/// Fehlt ⇒ erste Etappe.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub phase: Option<String>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// [271] Eine Bau-Etappe (Reihenfolge = Reihenfolge der Liste).
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct RenovationPhase {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// [271] Darstellung eines Status im Umbaufilter.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
|
||||
pub enum RenovationShow {
|
||||
/// Normal zeichnen (wie ohne Umbau-Angaben).
|
||||
#[default]
|
||||
#[serde(rename = "show")]
|
||||
Show,
|
||||
/// Ausblenden (wie nicht vorhanden: verdeckt nichts, eine Öffnung schliesst ihre Wand).
|
||||
#[serde(rename = "hide")]
|
||||
Hide,
|
||||
/// Mit der Umbau-Farbe des Status (`RenovationStyle`).
|
||||
#[serde(rename = "override")]
|
||||
Override,
|
||||
#[serde(other)]
|
||||
#[ts(skip)]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// [271] Umbau-Farbe eines Status: Füllung der Schnittflächen, Linienfarbe, gestrichelt. Fehlende Felder ⇒ SIA-Vorgabe.
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct RenovationStyle {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub fill: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub line: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub dashed: Option<bool>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// [271] Umbau-Farben je Status (fehlt ⇒ SIA-400-Vorgabe, `renovation::default_style`).
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct RenovationStyles {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub existing: Option<RenovationStyle>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub demolish: Option<RenovationStyle>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub new: Option<RenovationStyle>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// [271] Ein Umbaufilter (wie Archicads „Renovation Filter“): Darstellung je Status.
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct RenovationFilter {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub existing: RenovationShow,
|
||||
pub demolish: RenovationShow,
|
||||
pub new: RenovationShow,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// [271] Umbau-Einstellungen des Projekts.
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct RenovationSettings {
|
||||
/// Etappen in ihrer Reihenfolge (Neubau/Abbruch Etappe 1, 2 …).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub phases: Option<Vec<RenovationPhase>>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub styles: Option<RenovationStyles>,
|
||||
/// Eigene Umbaufilter (zusätzlich zu den eingebauten).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub filters: Option<Vec<RenovationFilter>>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// Eine Wand, definiert über ihre Achse (Centerline) und ihren Typ.
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
@@ -3082,6 +3232,10 @@ pub struct Wall {
|
||||
#[serde(rename = "surfacePatternOffset", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub surface_pattern_offset: Option<Vec2>,
|
||||
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<Renovation>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -3240,6 +3394,10 @@ pub struct Ceiling {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub bottom: Option<VerticalAnchor>,
|
||||
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<Renovation>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -3443,6 +3601,10 @@ pub struct Roof {
|
||||
#[serde(rename = "parapetComponentId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub parapet_component_id: Option<String>,
|
||||
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<Renovation>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -3935,6 +4097,10 @@ pub struct Opening {
|
||||
#[serde(rename = "doorFrame", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub door_frame: Option<DoorFrameDetail>,
|
||||
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand wie die Wand (eine neue Öffnung in einer Bestandswand bricht die Wand dort ab, eine Öffnung „Abbruch“ wird zugemauert).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<Renovation>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -4196,6 +4362,10 @@ pub struct Stair {
|
||||
#[serde(rename = "postDepth", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub post_depth: Option<f64>,
|
||||
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<Renovation>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -4472,6 +4642,10 @@ pub struct Room {
|
||||
#[serde(rename = "floorBuildUp", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub floor_build_up: Option<String>,
|
||||
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand (nur Sichtbarkeit und Flächen je Zustand, keine Umbau-Farbe: ein Raum ist kein Bauteil).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<Renovation>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -4820,6 +4994,10 @@ pub struct ExtrudedSolid {
|
||||
#[serde(rename = "componentId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub component_id: Option<String>,
|
||||
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<Renovation>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -4927,6 +5105,10 @@ pub struct Column {
|
||||
#[serde(rename = "hatchSource", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub hatch_source: Option<AttributeSource>,
|
||||
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<Renovation>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -5478,6 +5660,16 @@ pub struct ViewSnapshot {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub doc3d: Option<Doc3d>,
|
||||
/// [271] Umbaufilter (eingebaut „bestand“, „abbruch“, „neubau“, „umbauplan“, „endzustand“ oder Id aus
|
||||
/// `Project.renovation.filters`). Fehlt ⇒ kein Filter: alle Bauteile wie ohne Umbau-Angaben.
|
||||
#[serde(rename = "renovationFilter", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation_filter: Option<String>,
|
||||
/// [271] Etappe, bis zu der der Umbaufilter gilt (Id aus `Project.renovation.phases`): Neues späterer Etappen fehlt
|
||||
/// noch, Abbruch späterer Etappen steht noch als Bestand. Fehlt ⇒ alle Etappen.
|
||||
#[serde(rename = "renovationPhase", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation_phase: Option<String>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -6568,6 +6760,10 @@ pub struct Project {
|
||||
#[serde(rename = "geoAnchor", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional, inline)]
|
||||
pub geo_anchor: Option<ProjectGeoAnchor>,
|
||||
/// [271] Umbau: Etappen, Farben je Status (SIA 400) und eigene Umbaufilter.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<RenovationSettings>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
|
||||
@@ -705,8 +705,21 @@ pub fn axo_plan_buf(p: &Project, args: &[f64], text: &str) -> Result<Vec<u8>, St
|
||||
let mono = args.first().is_some_and(|&x| x != 0.0);
|
||||
let scale = args.get(1).copied().filter(|s| s.is_finite() && *s > 0.0).unwrap_or(100.0);
|
||||
let mut w = crate::plan::buf::Writer::new(true);
|
||||
// [271] Umbaufilter (`renovation`, `renovationPhase`): Ausgeblendetes fehlt, Flächen in der Umbau-Farbe.
|
||||
let ren = crate::renovation::View::new(p, v.get("renovation").and_then(|x| x.as_str()), v.get("renovationPhase").and_then(|x| x.as_str())).map(|r| r.resolve(p));
|
||||
let filtered = ren.as_ref().filter(|r| !r.hidden.is_empty()).map(|r| crate::renovation::without_hidden(p, &r.hidden));
|
||||
let p = filtered.as_ref().unwrap_or(p);
|
||||
let Some(a) = AxoArgs::parse(p, &v) else { return Ok(w.finish()) };
|
||||
if let Some((mut prims, bounds)) = axo_primitives(p, &a, mono)? {
|
||||
if let Some(r) = ren.as_ref().filter(|r| !r.styled.is_empty()) {
|
||||
for q in prims.iter_mut() {
|
||||
let Some(st) = crate::renovation::prim_element(q).and_then(|id| r.styled.get(id)) else { continue };
|
||||
if let Primitive::Polygon { fill, stroke, .. } = q {
|
||||
*fill = st.fill.clone();
|
||||
*stroke = st.fill.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
super::extras::scale_line_weights(p, scale, &mut prims);
|
||||
w.group(&prims);
|
||||
w.bounds = Some(bounds);
|
||||
|
||||
@@ -148,6 +148,7 @@ pub fn ctx_key(a: &PlanArgs) -> String {
|
||||
});
|
||||
format!("{}\u{1}{:?}\u{1}{}\u{1}{}\u{1}{}\u{1}{}\u{1}{}\u{1}{}\u{1}{}\u{1}{}", a.floor, a.detail, a.reference_lines, a.global, a.scale.to_bits(), a.for_print, a.compact, a.mono, a.auto_coarse, rules) + &a.model_view.as_deref().map_or(String::new(), |m| format!("\u{1}mv:{m}"))
|
||||
+ &a.trace_of.as_deref().map_or(String::new(), |t| format!("\u{1}trace:{t}"))
|
||||
+ &a.renovation.as_deref().map_or(String::new(), |t| format!("\u{1}ren:{t}:{}", a.renovation_phase.as_deref().unwrap_or("")))
|
||||
}
|
||||
|
||||
/// Sichtbarkeit und Dimmen als vergleichbarer Text (Mengen sortiert).
|
||||
|
||||
@@ -55,6 +55,8 @@ fn floor_args(a: &PlanArgs, floor: &str) -> PlanArgs {
|
||||
// [173] Die Modelldarstellung der Deckenspiegel-Ebene gilt auch für das Bezugsgeschoss.
|
||||
model_view: a.model_view.clone(),
|
||||
trace_of: None,
|
||||
renovation: a.renovation.clone(),
|
||||
renovation_phase: a.renovation_phase.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,10 @@ pub struct PlanArgs {
|
||||
/// [203] Pausfolie: dieser Plan liegt gedimmt unter dem Grundriss des Geschosses `trace_of` (Zeichnungsebenen-Modus
|
||||
/// „Andere grau"). Achsraster, die auch dort stehen, fehlen hier — sie stehen nur einmal im Bild. `None` = eigener Plan.
|
||||
pub trace_of: Option<String>,
|
||||
/// [271] Ausdrücklich angefragter Umbaufilter (Id oder Name; CLI `--renovation`, Blatt-Ausschnitt) und Etappe;
|
||||
/// `None` = der der Ebene (`DrawingLevel.renovationFilter`), sonst kein Filter (`renovation.rs`).
|
||||
pub renovation: Option<String>,
|
||||
pub renovation_phase: Option<String>,
|
||||
}
|
||||
|
||||
/// [140] Ab diesem Massstab (1:N) zeichnet der Detailgrad „mittel" wie „grob".
|
||||
@@ -110,6 +114,8 @@ impl PlanArgs {
|
||||
rules: v.get("rules").and_then(|a| a.as_array()).map(|a| a.iter().filter_map(|s| s.as_str().map(String::from)).collect()),
|
||||
model_view: v.get("modelView").and_then(|m| m.as_str()).filter(|m| !m.is_empty()).map(String::from),
|
||||
trace_of: v.get("traceOf").and_then(|m| m.as_str()).filter(|m| !m.is_empty()).map(String::from),
|
||||
renovation: v.get("renovation").and_then(|m| m.as_str()).filter(|m| !m.is_empty()).map(String::from),
|
||||
renovation_phase: v.get("renovationPhase").and_then(|m| m.as_str()).filter(|m| !m.is_empty()).map(String::from),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -156,6 +162,8 @@ pub struct Ctx<'a> {
|
||||
bubble_obst: std::cell::OnceCell<super::stamp_place::Obstacles>,
|
||||
/// [207] Linienzüge der Strassen-Klasse („11“) je Geschoss für Strassennamen entlang der Achse (`plan/text_curve.rs`).
|
||||
road_axes: std::cell::OnceCell<Vec<(String, Vec<crate::model::Vec2>)>>,
|
||||
/// [271] Umbaufilter dieser Plan-Erzeugung (ausgeblendete Elemente stehen zusätzlich in `hidden`).
|
||||
ren: Option<crate::renovation::Resolved>,
|
||||
}
|
||||
|
||||
impl<'a> Ctx<'a> {
|
||||
@@ -164,10 +172,27 @@ impl<'a> Ctx<'a> {
|
||||
for c in p.flat_categories() {
|
||||
cats.insert(c.code.as_str(), c);
|
||||
}
|
||||
let hidden = overrides::hidden_elements(p, overrides::RuleView::at(a.scale, a.rules.as_ref()).view("plan"));
|
||||
let mut hidden = overrides::hidden_elements(p, overrides::RuleView::at(a.scale, a.rules.as_ref()).view("plan"));
|
||||
// [271] Umbaufilter: ausgeblendete Bauteile wie bei der Regel „Ausblenden“ (eine Öffnung schliesst ihre Wand).
|
||||
let ren = crate::renovation::View::for_level(p, &a.floor, a.renovation.as_deref(), a.renovation_phase.as_deref()).map(|v| v.resolve(p)).filter(|r| !r.is_empty());
|
||||
if let Some(r) = &ren {
|
||||
hidden.extend(r.hidden.iter().cloned());
|
||||
}
|
||||
let mv_sel = super::model_view::selected_id(p, &a.floor, a.model_view.as_deref()).and_then(|id| super::model_view::find(p, id));
|
||||
let mv = super::model_view::resolve(mv_sel, a.detail, a.scale);
|
||||
Ctx { p, a, cats, hidden, mv_sel, mv, house: Default::default(), drawn_obst: Default::default(), obst_busy: Default::default(), bubble_obst: Default::default(), road_axes: Default::default() }
|
||||
Ctx { p, a, cats, hidden, mv_sel, mv, house: Default::default(), drawn_obst: Default::default(), obst_busy: Default::default(), bubble_obst: Default::default(), road_axes: Default::default(), ren }
|
||||
}
|
||||
|
||||
/// [271] Umbaufilter (Farben, Ersatzstücke der Öffnungen); `None` ohne Filter.
|
||||
pub fn renovation(&self) -> Option<&crate::renovation::Resolved> {
|
||||
self.ren.as_ref()
|
||||
}
|
||||
|
||||
/// [271] Umbau-Farben auf `out[from..]` (Primitive nach ihrem Element, sonst nach `owner`).
|
||||
pub fn renovation_restyle(&self, out: &mut Vec<Primitive>, from: usize, owner: Option<&str>) {
|
||||
if let Some(r) = &self.ren {
|
||||
crate::renovation::restyle_range(r, out, from, owner);
|
||||
}
|
||||
}
|
||||
|
||||
/// [179] Aussenringe der Gebäudegrundfläche (`context::building_rings`), einmal je Plan.
|
||||
@@ -1643,7 +1668,7 @@ pub fn room_stamp_spots(p: &Project, floor: &str, show: &HashSet<String>, scale:
|
||||
return out;
|
||||
}
|
||||
let (detail, auto_coarse) = effective_detail(Detail::Mittel, scale);
|
||||
let a = PlanArgs { floor: floor.to_string(), detail, show: show.clone(), grey: HashSet::new(), reference_lines: false, global: true, scale, for_print: false, compact: false, mono: false, sun_when: None, auto_coarse, rules: None, model_view: None, trace_of: None };
|
||||
let a = PlanArgs { floor: floor.to_string(), detail, show: show.clone(), grey: HashSet::new(), reference_lines: false, global: true, scale, for_print: false, compact: false, mono: false, sun_when: None, auto_coarse, rules: None, model_view: None, trace_of: None, renovation: None, renovation_phase: None };
|
||||
let Ok(d) = plan_domains(p, &a) else { return out };
|
||||
for q in d.rooms.iter().chain(&d.sections) {
|
||||
if let Primitive::Text { at, room_id: Some(id), .. } = q {
|
||||
@@ -1967,6 +1992,12 @@ fn domains_before(c: &Ctx, out: &mut DomainPrims, bounds: &mut Bounds) -> Result
|
||||
// [149] Bäume (Planzeichen) mit den Stützen in einer Gruppe.
|
||||
super::trees::plan_trees(c, &mut out.columns);
|
||||
solids(c, &mut out.solids);
|
||||
// [271] Umbaufilter: Decken, Dächer, Treppen, Stützen und Körper in ihrer Umbau-Farbe (Wände: `plan_walls`).
|
||||
if c.renovation().is_some() {
|
||||
for v in [&mut out.ceilings, &mut out.roofs, &mut out.stairs, &mut out.columns, &mut out.solids] {
|
||||
c.renovation_restyle(v, 0, None);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -1460,7 +1460,9 @@ pub fn collect(parts: &mut [Part], project: &Project, o: &DxfOptions) -> Option<
|
||||
cx.flat.add_layer(LAYER_EXTRUSION, Some(rgb_from_hex("#d98c40")), 13.0);
|
||||
cx.flat.add_layer(LAYER_ZERO, None, 25.0);
|
||||
|
||||
emit_entries(&mut cx, &mut main, &entries, &layer_by_code, true);
|
||||
// [271] Umbau: Bauteile mit Status Abbruch/Neu auf eigene Ebenen „<Ebene>_Abbruch“ bzw. „<Ebene>_Neu“ (Bestand bleibt).
|
||||
let ren_layer = renovation_layers(&mut cx, &cats);
|
||||
emit_entries(&mut cx, &mut main, &entries, &layer_by_code, &ren_layer, true);
|
||||
cx.flat.set_pen(&mut main, -1.0);
|
||||
cx.flat.set_epen(&mut main, -1.0, -1.0, -1.0);
|
||||
|
||||
@@ -1484,7 +1486,37 @@ pub fn collect(parts: &mut [Part], project: &Project, o: &DxfOptions) -> Option<
|
||||
/// Bemassungen, Blockinstanzen und Öffnungen als CAD-Objekte, der Rest je Primitiv.
|
||||
/// `objects = false`: auch Bemassungen, Blockinstanzen und Öffnungen nur als ihre Primitive (Inhalt
|
||||
/// eines Blocks, der keine weiteren Blöcke definieren darf).
|
||||
fn emit_entries(cx: &mut Ctx, main: &mut Buf, entries: &[Entry], layer_by_code: &HashMap<&str, String>, objects: bool) {
|
||||
/// [271] Ebene je Bauteil mit Umbau-Status Abbruch/Neu (Wände, Stützen, Öffnungen samt Wand-Rückfall): Element-Id →
|
||||
/// Ebenen-Name, die Ebenen sind angelegt (Farbe und Strichstärke der Kategorie).
|
||||
fn renovation_layers(cx: &mut Ctx, cats: &[&LayerCategory]) -> HashMap<String, String> {
|
||||
use crate::model::RenovationStatus as S;
|
||||
let p = cx.project;
|
||||
let mut items: Vec<(&str, &str, S)> = Vec::new();
|
||||
for w in &p.walls {
|
||||
items.push((&w.id, &w.category_code, crate::renovation::status_of(w.renovation.as_ref())));
|
||||
}
|
||||
for c in p.columns.iter().flatten() {
|
||||
items.push((&c.id, &c.category_code, crate::renovation::status_of(c.renovation.as_ref())));
|
||||
}
|
||||
for o in p.openings.iter().flatten() {
|
||||
items.push((&o.id, &o.category_code, crate::renovation::status_of(crate::renovation::opening_renovation(p, o))));
|
||||
}
|
||||
let mut out = HashMap::new();
|
||||
for (id, code, st) in items {
|
||||
let suffix = match st {
|
||||
S::Demolish => "Abbruch",
|
||||
S::New => "Neu",
|
||||
_ => continue,
|
||||
};
|
||||
let Some(c) = cats.iter().find(|c| c.code == code) else { continue };
|
||||
let name = format!("{}_{}_{}", c.code, c.name, suffix);
|
||||
cx.flat.add_layer(&name, Some(rgb_from_hex(&c.color)), mm_to_lwe(c.lw));
|
||||
out.insert(id.to_string(), name);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
fn emit_entries(cx: &mut Ctx, main: &mut Buf, entries: &[Entry], layer_by_code: &HashMap<&str, String>, ren_layer: &HashMap<String, String>, objects: bool) {
|
||||
let project = cx.project;
|
||||
// 2) Rückverweise Primitiv → Kategorie.
|
||||
let code_by_wall: HashMap<&str, &str> = project.walls.iter().map(|w| (w.id.as_str(), w.category_code.as_str())).collect();
|
||||
@@ -1501,6 +1533,9 @@ fn emit_entries(cx: &mut Ctx, main: &mut Buf, entries: &[Entry], layer_by_code:
|
||||
let layer_for = |e: &Entry| -> String {
|
||||
match e.tag {
|
||||
T_POLYGON => {
|
||||
if let Some(l) = e.ids.wall.as_ref().or(e.ids.column.as_ref()).and_then(|id| ren_layer.get(id)) {
|
||||
return l.clone();
|
||||
}
|
||||
if let Some(w) = &e.ids.wall {
|
||||
return layer_of_code(&code_by_wall, w).unwrap_or_else(|| LAYER_DEFAULT.to_string());
|
||||
}
|
||||
@@ -1668,7 +1703,7 @@ fn emit_entries(cx: &mut Ctx, main: &mut Buf, entries: &[Entry], layer_by_code:
|
||||
}
|
||||
_ => {
|
||||
let op = opening_by_id[id];
|
||||
let layer = layer_by_code.get(op.category_code.as_str()).cloned().unwrap_or_else(|| LAYER_SYMBOLS.to_string());
|
||||
let layer = ren_layer.get(&op.id).or_else(|| layer_by_code.get(op.category_code.as_str())).cloned().unwrap_or_else(|| LAYER_SYMBOLS.to_string());
|
||||
if !cx.opening(main, op, &members, &layer, &mut names) {
|
||||
for m in &members {
|
||||
let l = layer_for(m);
|
||||
@@ -1746,6 +1781,8 @@ fn sheets(cx: &mut Ctx, main: &mut Buf, layer_by_code: &HashMap<&str, String>) {
|
||||
rules: None,
|
||||
model_view: None,
|
||||
trace_of: None,
|
||||
renovation: None,
|
||||
renovation_phase: None,
|
||||
};
|
||||
if let Some(entries) = plan_domains_buf(p, &args).ok().and_then(|buf| {
|
||||
let view = View::parse(&buf)?;
|
||||
@@ -1756,7 +1793,7 @@ fn sheets(cx: &mut Ctx, main: &mut Buf, layer_by_code: &HashMap<&str, String>) {
|
||||
let o1 = DxfOptions { scale: 1.0, include_hatches: cx.o.include_hatches, dim_cm: cx.o.dim_cm, paper_layout: false, bounds: [0.0; 4], default_font: cx.o.default_font.clone(), floor: String::new(), table_labels: String::new() };
|
||||
let mut sub = Ctx { project: p, o: &o1, flat: std::mem::replace(&mut cx.flat, Flat::new()) };
|
||||
let mut content = Buf::block();
|
||||
emit_entries(&mut sub, &mut content, &entries, layer_by_code, false);
|
||||
emit_entries(&mut sub, &mut content, &entries, layer_by_code, &HashMap::new(), false);
|
||||
let bname = format!("SHEET_{}", n + 1);
|
||||
sub.flat.define_block(main, &bname, &name, &[], content);
|
||||
cx.flat = sub.flat;
|
||||
|
||||
@@ -102,6 +102,22 @@ fn surf_ov(p: &Project, v: RuleView, kind: &str, code: &str, name: Option<&str>,
|
||||
(o.fill.is_some() || o.no_pattern || o.outline.is_some() || o.color.is_some() || o.lineweight.is_some() || o.dash.is_some() || o.hide).then(|| Rc::new(o))
|
||||
}
|
||||
|
||||
/// [271] Umbau-Farben je Ansichtsfläche (Füllung ohne Muster, Kanten in der Linienfarbe, gestrichelt bei Abbruch); gehen
|
||||
/// den Regeln vor.
|
||||
pub(super) fn renovation_faces(faces: &mut [Face], r: &crate::renovation::Resolved) {
|
||||
if r.styled.is_empty() {
|
||||
return;
|
||||
}
|
||||
let mut memo: HashMap<String, Rc<SurfOv>> = HashMap::new();
|
||||
for f in faces.iter_mut().filter(|f| !f.id.is_empty()) {
|
||||
let Some(st) = r.styled.get(&f.id) else { continue };
|
||||
let o = memo.entry(f.id.clone()).or_insert_with(|| {
|
||||
Rc::new(SurfOv { fill: Some(st.fill.clone()), no_pattern: true, hatch: None, outline: None, color: st.line.clone(), lineweight: None, dash: st.dashed.then(|| Some(crate::renovation::DEMOLISH_DASH.to_vec())), hide: false })
|
||||
});
|
||||
f.ov = Some(o.clone());
|
||||
}
|
||||
}
|
||||
|
||||
/// [33] Override-Regeln je Ansichtsfläche: Wand (Wandtyp, sichtbare Seite = äusserste bzw. innerste
|
||||
/// Schicht), Decke/Bodenplatte, Treppe, Dach (Eindeckung = erste Schicht), Stütze. Ohne aktive Regel nichts.
|
||||
pub(super) fn face_overrides(p: &Project, faces: &mut [Face], v: RuleView) {
|
||||
|
||||
@@ -205,6 +205,12 @@ pub fn elevation_primitives(p: &Project, level: &LevelSpec, shadows: bool, mono:
|
||||
/// `None` = Schalter im Projekt). [33] Regeln wirken auf Flächen (Füllung, Schraffur, ausblenden), Kanten
|
||||
/// (Farbe, Stärke, Umriss aus) und Öffnungen (Linien, Glasfüllung).
|
||||
pub fn elevation_primitives_with(p: &Project, level: &LevelSpec, shadows: bool, mono: bool, vis: &Visibility, scale: f64, rules: Option<&HashSet<String>>) -> Result<Option<(Vec<Primitive>, [f64; 4])>, String> {
|
||||
elevation_primitives_ren(p, level, shadows, mono, vis, scale, rules, None)
|
||||
}
|
||||
|
||||
/// [271] Wie [`elevation_primitives_with`] mit den Umbau-Farben `ren` (das Ausgeblendete fehlt schon in `p`).
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn elevation_primitives_ren(p: &Project, level: &LevelSpec, shadows: bool, mono: bool, vis: &Visibility, scale: f64, rules: Option<&HashSet<String>>, ren: Option<&crate::renovation::Resolved>) -> Result<Option<(Vec<Primitive>, [f64; 4])>, String> {
|
||||
let Some(plane) = level.plane() else { return Ok(None) };
|
||||
let frame = frame_of(&plane);
|
||||
let mut walls = model3d::emit_walls_with(p, false, false)?;
|
||||
@@ -295,6 +301,9 @@ pub fn elevation_primitives_with(p: &Project, level: &LevelSpec, shadows: bool,
|
||||
// Wände samt ihren Öffnungen.
|
||||
let rv = RuleView::at(scale, rules).view("elevation");
|
||||
face_overrides(p, &mut faces, rv);
|
||||
if let Some(r) = ren {
|
||||
face::renovation_faces(&mut faces, r);
|
||||
}
|
||||
let hidden_walls: HashSet<String> = faces.iter().filter(|f| f.role == Role::Wall && f.ov.as_ref().is_some_and(|o| o.hide)).map(|f| f.id.clone()).collect();
|
||||
faces.retain(|f| !f.ov.as_ref().is_some_and(|o| o.hide));
|
||||
|
||||
@@ -958,7 +967,11 @@ pub fn elevation_plan_buf(p: &Project, args: &[f64], text: &str) -> Result<Vec<u
|
||||
w.post = super::extras::sketch_post(Some(level.sketch), scale);
|
||||
// [33] Eingeschaltete Override-Regeln eines Blatt-Viewports (`rules`: ids; fehlt = Schalter im Projekt).
|
||||
let on: Option<HashSet<String>> = v.get("rules").and_then(|a| a.as_array()).map(|a| a.iter().filter_map(|s| s.as_str().map(String::from)).collect());
|
||||
if let Some((mut prims, bounds)) = elevation_primitives_with(p, &level, shadows, mono, &vis, scale, on.as_ref())? {
|
||||
// [271] Umbaufilter (angefragt, sonst der der Ebene): Ausgeblendetes fehlt (verdeckt nichts), Farben auf die Flächen.
|
||||
let ren = super::section::query::renovation_view(p, &v, &level).map(|r| r.resolve(p)).filter(|r| !r.is_empty());
|
||||
let filtered = ren.as_ref().filter(|r| !r.hidden.is_empty()).map(|r| crate::renovation::without_hidden(p, &r.hidden));
|
||||
let p = filtered.as_ref().unwrap_or(p);
|
||||
if let Some((mut prims, bounds)) = elevation_primitives_ren(p, &level, shadows, mono, &vis, scale, on.as_ref(), ren.as_ref())? {
|
||||
super::extras::scale_line_weights(p, scale, &mut prims);
|
||||
w.group(&prims);
|
||||
// Achsraster ([112]): Achsen quer zur Blickebene.
|
||||
|
||||
@@ -636,6 +636,40 @@ pub struct Post {
|
||||
pub lw: f64,
|
||||
/// Skizzenstil ([67], `plan/sketch.rs`): Meter Modell je Papier-mm; 0 = aus.
|
||||
pub sketch: f64,
|
||||
/// [271] Farben, die Schwarz-Weiss nicht ändert (Umbau-Farben: im Umbauplan sind sie die Aussage).
|
||||
pub keep: KeepColors,
|
||||
}
|
||||
|
||||
/// [271] Bis zu sechs Farben (RGB), die [`Post`] in Schwarz-Weiss stehen lässt.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Default)]
|
||||
pub struct KeepColors {
|
||||
rgb: [u32; 6],
|
||||
n: u8,
|
||||
}
|
||||
|
||||
impl KeepColors {
|
||||
/// Aus Hex-Farben (`#rrggbb`); ungültige und überzählige fallen weg.
|
||||
pub fn of<'a>(colors: impl IntoIterator<Item = &'a str>) -> KeepColors {
|
||||
let mut k = KeepColors::default();
|
||||
for c in colors {
|
||||
if let Some(v) = hex_rgb(c) {
|
||||
if (k.n as usize) < k.rgb.len() && !k.rgb[..k.n as usize].contains(&v) {
|
||||
k.rgb[k.n as usize] = v;
|
||||
k.n += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
k
|
||||
}
|
||||
|
||||
pub fn has(&self, c: &str) -> bool {
|
||||
self.n > 0 && hex_rgb(c).is_some_and(|v| self.rgb[..self.n as usize].contains(&v))
|
||||
}
|
||||
}
|
||||
|
||||
fn hex_rgb(c: &str) -> Option<u32> {
|
||||
let h = c.trim().strip_prefix('#')?;
|
||||
(h.len() == 6).then(|| u32::from_str_radix(h, 16).ok()).flatten()
|
||||
}
|
||||
|
||||
impl Post {
|
||||
@@ -666,12 +700,12 @@ impl Post {
|
||||
if *fill != "none" {
|
||||
if solid {
|
||||
*fill = HATCH_INK.into();
|
||||
} else if !is_neutral(fill) {
|
||||
} else if !is_neutral(fill) && !self.keep.has(fill) {
|
||||
*fill = "#ffffff".into();
|
||||
}
|
||||
}
|
||||
// [140] „none" bleibt (Wandschichten ohne Umriss: sonst Kontur statt Schraffur).
|
||||
if *stroke != "none" && !is_neutral(stroke) {
|
||||
if *stroke != "none" && !is_neutral(stroke) && !self.keep.has(stroke) {
|
||||
*stroke = MONO_INK.into();
|
||||
}
|
||||
}
|
||||
@@ -692,7 +726,7 @@ impl Post {
|
||||
}
|
||||
}
|
||||
Primitive::Line { weight_mm, color, .. } => {
|
||||
if self.mono && !color.as_deref().is_some_and(is_neutral) {
|
||||
if self.mono && !color.as_deref().is_some_and(|c| is_neutral(c) || self.keep.has(c)) {
|
||||
*color = Some(MONO_INK.into());
|
||||
}
|
||||
if self.lw != 1.0 {
|
||||
@@ -710,7 +744,7 @@ impl Post {
|
||||
|
||||
/// Farbe und Stärke einer Linie.
|
||||
pub fn line<'a>(&self, color: Option<&'a str>, w: f64) -> (Option<&'a str>, f64) {
|
||||
(if self.mono && !color.is_some_and(is_neutral) { Some(MONO_INK) } else { color }, scale_weight(w, self.lw))
|
||||
(if self.mono && !color.is_some_and(|c| is_neutral(c) || self.keep.has(c)) { Some(MONO_INK) } else { color }, scale_weight(w, self.lw))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -735,7 +769,7 @@ pub fn scale_line_weights(p: &Project, scale: f64, prims: &mut [Primitive]) {
|
||||
if lw == 1.0 {
|
||||
return;
|
||||
}
|
||||
let post = Post { mono: false, lw, sketch: 0.0 };
|
||||
let post = Post { mono: false, lw, sketch: 0.0, keep: KeepColors::default() };
|
||||
for q in prims.iter_mut() {
|
||||
match q {
|
||||
Primitive::Line { weight_mm, .. } => *weight_mm = scale_weight(*weight_mm, lw),
|
||||
@@ -750,7 +784,13 @@ pub fn post_for(p: &Project, a: &super::domains::PlanArgs) -> Option<Post> {
|
||||
let level = p.floor(&a.floor);
|
||||
let sheet = level.is_some_and(|l| l.layout_id.is_some());
|
||||
let sketch = if sheet { 0.0 } else { sketch_k(level.and_then(|l| l.sketch), a.scale) };
|
||||
Some(Post { mono: a.mono, lw: if sheet { 1.0 } else { line_weight_factor(p, a.scale) }, sketch }).filter(Post::active)
|
||||
// [271] Umbau-Farben bleiben auch in Schwarz-Weiss (Tusche): ohne sie sagt ein Umbauplan nichts.
|
||||
let keep = if a.mono {
|
||||
crate::renovation::View::for_level(p, &a.floor, a.renovation.as_deref(), a.renovation_phase.as_deref()).map_or_else(KeepColors::default, |v| KeepColors::of(v.colors().iter().map(String::as_str)))
|
||||
} else {
|
||||
KeepColors::default()
|
||||
};
|
||||
Some(Post { mono: a.mono, lw: if sheet { 1.0 } else { line_weight_factor(p, a.scale) }, sketch, keep }).filter(Post::active)
|
||||
}
|
||||
|
||||
/// [67] Skizzenstil einer Ebene beim Massstab 1:`scale`: Meter je Papier-mm, 0 = aus.
|
||||
@@ -764,7 +804,7 @@ pub fn sketch_k(on: Option<bool>, scale: f64) -> f64 {
|
||||
|
||||
/// [67] Nachbearbeitung nur mit Skizzenstil (Schnitt/Ansicht; `None` = aus).
|
||||
pub fn sketch_post(on: Option<bool>, scale: f64) -> Option<Post> {
|
||||
Some(Post { mono: false, lw: 1.0, sketch: sketch_k(on, scale) }).filter(Post::active)
|
||||
Some(Post { mono: false, lw: 1.0, sketch: sketch_k(on, scale), keep: KeepColors::default() }).filter(Post::active)
|
||||
}
|
||||
|
||||
// ── Ausmass ─────────────────────────────────────────────────────────────────────────────────────
|
||||
@@ -1124,7 +1164,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn mono_poche_bleibt_schwarz() {
|
||||
let post = Post { mono: true, lw: 1.0, sketch: 0.0 };
|
||||
let post = Post { mono: true, lw: 1.0, sketch: 0.0, keep: KeepColors::default() };
|
||||
let mut solid = HatchRender { pattern: HatchPattern::Solid, ..no_hatch() };
|
||||
solid.color = "#123456".into();
|
||||
let mut p = flat_polygon(vec![], "#abcdef", 1.0);
|
||||
@@ -1156,10 +1196,10 @@ mod tests {
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let mut p = stamp();
|
||||
Post { mono: true, lw: 1.0, sketch: 0.0 }.apply(&mut p);
|
||||
Post { mono: true, lw: 1.0, sketch: 0.0, keep: KeepColors::default() }.apply(&mut p);
|
||||
assert_eq!(colors(&p), (MONO_INK.to_string(), vec![Some("#808080".into()), Some(MONO_INK.into())]));
|
||||
let mut p = stamp();
|
||||
Post { mono: false, lw: 0.8, sketch: 0.0 }.apply(&mut p);
|
||||
Post { mono: false, lw: 0.8, sketch: 0.0, keep: KeepColors::default() }.apply(&mut p);
|
||||
assert_eq!(colors(&p), ("#2255cc".to_string(), vec![Some("#808080".into()), Some("#d0342c".into())]));
|
||||
}
|
||||
|
||||
@@ -1167,7 +1207,7 @@ mod tests {
|
||||
/// die Kontur die Schraffur), Grautöne (Schatten, Gelände, Treppe) bleiben, bunte Farben werden Tinte/Papier.
|
||||
#[test]
|
||||
fn mono_behaelt_grau_und_ohne_umriss() {
|
||||
let post = Post { mono: true, lw: 1.0, sketch: 0.0 };
|
||||
let post = Post { mono: true, lw: 1.0, sketch: 0.0, keep: KeepColors::default() };
|
||||
let mut p = flat_polygon(vec![], "#3c3c3c", 0.0);
|
||||
if let Primitive::Polygon { stroke, hatch, .. } = &mut p {
|
||||
*stroke = "none".into();
|
||||
|
||||
@@ -26,7 +26,7 @@ mod meshes;
|
||||
mod projection;
|
||||
mod primitives;
|
||||
mod openings;
|
||||
mod query;
|
||||
pub(crate) mod query;
|
||||
pub mod unfold;
|
||||
|
||||
use input::*;
|
||||
@@ -131,6 +131,9 @@ pub struct LevelSpec {
|
||||
pub cut_hatch: bool,
|
||||
/// [173] Modelldarstellung der Ebene (`modelViewOptionId`; Ansicht: Öffnungslinien der Fenster).
|
||||
pub model_view: Option<String>,
|
||||
/// [271] Umbaufilter und Etappe der Ebene (`renovationFilter`, `renovationPhase`).
|
||||
pub renovation: Option<String>,
|
||||
pub renovation_phase: Option<String>,
|
||||
}
|
||||
|
||||
impl LevelSpec {
|
||||
@@ -149,6 +152,8 @@ impl LevelSpec {
|
||||
sketch: v.get("sketch").and_then(|b| b.as_bool()).unwrap_or(false),
|
||||
cut_hatch: v.get("cutHatch").and_then(|b| b.as_bool()).unwrap_or(false),
|
||||
model_view: v.get("modelViewOptionId").and_then(|m| m.as_str()).filter(|m| !m.is_empty()).map(String::from),
|
||||
renovation: v.get("renovationFilter").and_then(|m| m.as_str()).filter(|m| !m.is_empty()).map(String::from),
|
||||
renovation_phase: v.get("renovationPhase").and_then(|m| m.as_str()).filter(|m| !m.is_empty()).map(String::from),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,6 +303,27 @@ pub struct CutRules {
|
||||
}
|
||||
|
||||
impl CutRules {
|
||||
/// [271] Umbau-Farben als Override der Schnittflächen: Füllung der Farbe, ohne Muster, Umriss gestrichelt bei
|
||||
/// Abbruch. Geht den Regeln vor (der Umbaufilter ist die Aussage des Plans).
|
||||
pub fn with_renovation(mut self, out: &Output, r: Option<&crate::renovation::Resolved>) -> CutRules {
|
||||
let Some(r) = r.filter(|r| !r.styled.is_empty()) else { return self };
|
||||
if out.cuts.iter().all(|c| c.source_id.as_ref().is_none_or(|s| !r.styled.contains_key(s))) {
|
||||
return self;
|
||||
}
|
||||
self.ov.resize(out.cuts.len(), None);
|
||||
for (i, c) in out.cuts.iter().enumerate() {
|
||||
let Some(st) = c.source_id.as_ref().and_then(|s| r.styled.get(s)) else { continue };
|
||||
let prev = self.ov[i].take();
|
||||
self.ov[i] = Some(CutOv {
|
||||
fill: Some(st.fill.clone()),
|
||||
hatch: HatchOv::None,
|
||||
outline: prev.as_ref().and_then(|o| o.outline).or(Some(true)),
|
||||
dash: if st.dashed { Some(Some(crate::renovation::DEMOLISH_DASH.to_vec())) } else { prev.and_then(|o| o.dash) },
|
||||
});
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
/// `v`: Massstab und eingeschaltete Regeln der Darstellung ([`super::overrides::RuleView`]).
|
||||
pub fn of(p: &Project, out: &Output, v: RuleView) -> CutRules {
|
||||
let ts = crate::excavation::terrains(p);
|
||||
|
||||
@@ -40,6 +40,17 @@ fn cache_put(key: (f64, u64), o: std::rc::Rc<Output>) {
|
||||
});
|
||||
}
|
||||
|
||||
/// [271] Umbaufilter eines Schnitts/einer Ansicht: `renovation`/`renovationPhase` im Aufruf (CLI, Blatt-Ausschnitt), sonst
|
||||
/// die Felder der Ebene (`renovationFilter`, `renovationPhase`).
|
||||
pub fn renovation_view(p: &Project, v: &serde_json::Value, level: &LevelSpec) -> Option<crate::renovation::View> {
|
||||
let req = v.get("renovation").and_then(|m| m.as_str()).filter(|m| !m.is_empty());
|
||||
let (f, ph) = match req {
|
||||
Some(f) => (Some(f), v.get("renovationPhase").and_then(|m| m.as_str())),
|
||||
None => (level.renovation.as_deref(), level.renovation_phase.as_deref()),
|
||||
};
|
||||
crate::renovation::View::new(p, f, ph)
|
||||
}
|
||||
|
||||
/// Abfrage `sectionPlan`: `args` = `[mono, openings, key]` (`key` > 0
|
||||
/// = Schlüssel des vorbereiteten Schnitts, s. Cache unten, 0 = immer rechnen),
|
||||
/// `text` = `{"level": {...}, "hiddenLines", "hasVis", "invisible", "hasDisplay", "norender", "grey"}`.
|
||||
@@ -57,7 +68,12 @@ pub fn section_plan_buf(p: &Project, args: &[f64], text: &str) -> Result<Vec<u8>
|
||||
let on: Option<HashSet<String>> = v.get("rules").and_then(|a| a.as_array()).map(|a| a.iter().filter_map(|s| s.as_str().map(String::from)).collect());
|
||||
let rv = RuleView::at(scale, on.as_ref()).view("section");
|
||||
// [33] Regel „Ausblenden“: Schnitt ohne diese Elemente (sie verdecken nichts, Wände samt Öffnungen).
|
||||
let hidden_ids = crate::plan::overrides::hidden_elements(p, rv);
|
||||
let mut hidden_ids = crate::plan::overrides::hidden_elements(p, rv);
|
||||
// [271] Umbaufilter (angefragt, sonst der der Ebene): Ausgeblendetes wie „Ausblenden“, Farben auf die Schnittflächen.
|
||||
let ren = renovation_view(p, &v, &level).map(|r| r.resolve(p));
|
||||
if let Some(r) = &ren {
|
||||
hidden_ids.extend(r.hidden.iter().cloned());
|
||||
}
|
||||
let filtered = (!hidden_ids.is_empty()).then(|| without_elements(p, &hidden_ids));
|
||||
let p = filtered.as_ref().unwrap_or(p);
|
||||
// [184] Öffnungen mit Detailgrad grob (Strich im Schnitt): Wandschnitt an Sturz/Brüstung flach. Das ändert die
|
||||
@@ -118,7 +134,7 @@ pub fn section_plan_buf(p: &Project, args: &[f64], text: &str) -> Result<Vec<u8>
|
||||
let mvo = mv_id.map(|id| crate::plan::model_view::for_view(p, Some(id), detail, scale));
|
||||
let smv = mvo.as_ref().map(|o| SectionMv::of(p, &out, o));
|
||||
let detail = mvo.as_ref().map_or(detail, |o| o.detail);
|
||||
let (mut prims, bounds) = section_primitives_mv(&out, mono, hidden, &vis, scale, detail, level.cut_hatch, &CutRules::of(p, &out, rv), smv.as_ref());
|
||||
let (mut prims, bounds) = section_primitives_mv(&out, mono, hidden, &vis, scale, detail, level.cut_hatch, &CutRules::of(p, &out, rv).with_renovation(&out, ren.as_ref()), smv.as_ref());
|
||||
w.post = crate::plan::extras::sketch_post(Some(level.sketch), scale);
|
||||
// Strichstärken nach Massstab ([32]) wie im Grundriss.
|
||||
crate::plan::extras::scale_line_weights(p, scale, &mut prims);
|
||||
|
||||
@@ -168,7 +168,7 @@ fn tiefe_blendet_ferne_bauteile_aus() {
|
||||
let mut p = Project::default();
|
||||
// quer: von der Ebene geschnitten und weit nach hinten; nah: 3 m, fern: 10 m hinter der Ebene (höher).
|
||||
p.walls = vec![wall("quer", (0.0, -1.0), (0.0, 12.0), 2.5), wall("nah", (2.0, 3.0), (6.0, 3.0), 2.5), wall("fern", (2.0, 10.0), (6.0, 10.0), 4.0)];
|
||||
let lv = |depth: Option<f64>| LevelSpec { model_view: None, bends: Vec::new(), sketch: false, cut_hatch: false, kind: "section".into(), line: Some([Vec2 { x: -1.0, y: 0.0 }, Vec2 { x: 8.0, y: 0.0 }]), direction_sign: Some(1.0), depth, shadows: false, hidden_lines: false };
|
||||
let lv = |depth: Option<f64>| LevelSpec { model_view: None, renovation: None, renovation_phase: None, bends: Vec::new(), sketch: false, cut_hatch: false, kind: "section".into(), line: Some([Vec2 { x: -1.0, y: 0.0 }, Vec2 { x: 8.0, y: 0.0 }]), direction_sign: Some(1.0), depth, shadows: false, hidden_lines: false };
|
||||
let top = |o: &Output| o.visible.iter().map(|e| e.a[1].max(e.b[1])).fold(f64::NEG_INFINITY, f64::max);
|
||||
let all = compute_section(&p, &lv(None), &[]).unwrap().unwrap();
|
||||
assert!(top(&all) > 3.9, "ohne Tiefe ist die ferne Wand sichtbar: {}", top(&all));
|
||||
|
||||
@@ -220,7 +220,7 @@ fn kataster_gewaesser_mit_schraffur_auch_in_tusche() {
|
||||
// Abstand 1.2 mm auf dem Papier bei 1:500: 8 · scale / 90 m = 0.6 m.
|
||||
assert!((8.0 * hatch.scale / 90.0 - 0.6).abs() < 1e-9, "Abstand {}", 8.0 * hatch.scale / 90.0);
|
||||
let mut q = water[0].clone();
|
||||
Post { mono: true, lw: 1.0, sketch: 0.0 }.apply(&mut q);
|
||||
Post { mono: true, lw: 1.0, sketch: 0.0, keep: Default::default() }.apply(&mut q);
|
||||
let Primitive::Polygon { fill, hatch, .. } = &q else { unreachable!() };
|
||||
assert_eq!(fill, "#ffffff");
|
||||
assert_eq!(hatch.pattern, HatchPattern::Diagonal);
|
||||
|
||||
@@ -1247,6 +1247,27 @@ pub fn plan_walls(c: &Ctx, reference_lines: bool, out: &mut Vec<Primitive>, boun
|
||||
if let Some(d) = range.restyle_dash(zone) {
|
||||
super::view_range::restyle(out, out_start, d);
|
||||
}
|
||||
// [271] Umbaufilter: Wand und Öffnungen in ihrer Umbau-Farbe; Ersatzstücke neuer (Abbruch-Stück) bzw.
|
||||
// zugemauerter Öffnungen (Ausfachung) — über der geschlossenen Wand, sonst unter dem Öffnungssymbol.
|
||||
if let Some(r) = c.renovation() {
|
||||
crate::renovation::restyle_range(r, out, out_start, Some(&w.id));
|
||||
if zone == Zone::Cut && !cut.covered {
|
||||
for pa in r.patches.iter().filter(|pa| pa.wall_id == w.id) {
|
||||
let Some(o) = p.openings_of_wall(&w.id).find(|o| o.id == pa.opening_id) else { continue };
|
||||
let Some(ring) = crate::renovation::patch_ring(p, w, o) else { continue };
|
||||
let q = crate::renovation::patch_prims(ring, &pa.style, lw * c.a.detail.outline_factor(), &o.id);
|
||||
if pa.closed {
|
||||
out.extend(q);
|
||||
} else {
|
||||
let n = q.len();
|
||||
out.splice(out_start..out_start, q);
|
||||
for s in closed_syms.iter_mut().filter(|s| s.0 >= out_start) {
|
||||
*s = (s.0 + n, s.1 + n);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// [256] Auf schwarzer Sammelfläche (ab 1:100) verschwände das Symbol: der Teil in der Fläche wird hell
|
||||
// (Modelldarstellung `walls.contrastOnSolid`, Basis an). Hinten anfangen, die Bereiche verschieben sich.
|
||||
|
||||
@@ -15,7 +15,7 @@ const REQUIRED_ARRAYS: [&str; 3] = ["walls", "layers", "drawingLevels"];
|
||||
const DEFAULT_ARRAYS: [&str; 5] = ["lineStyles", "hatches", "components", "wallTypes", "drawings2d"];
|
||||
|
||||
/// Bekannte Felder von `Project` (für die Meldung unbekannter Felder).
|
||||
const KNOWN_KEYS: [&str; 59] = [
|
||||
const KNOWN_KEYS: [&str; 60] = [
|
||||
"formatVersion", "id", "name", "lineStyles", "textStyles", "hatches", "components", "wallTypes",
|
||||
"ceilingTypes", "roofTypes", "blockDefs", "doorTypes", "windowTypes", "stairTypes", "pens",
|
||||
"penSets", "activePenSetId", "customPalettes", "builtinPaletteBanks", "drawingLevels", "layers",
|
||||
@@ -26,6 +26,7 @@ const KNOWN_KEYS: [&str; 59] = [
|
||||
"lineCap", "lineJoin", "trees", "uiState",
|
||||
"modelViewOptions", "cameras",
|
||||
"costEstimate",
|
||||
"renovation",
|
||||
];
|
||||
|
||||
/// Ergebnis des Einlesens.
|
||||
|
||||
@@ -16,7 +16,7 @@ pub fn run_doc(d: &mut crate::document::Document, name: &str, args: &[f64], text
|
||||
// des Aufrufers (0 = alles), Antwort als Änderung (`model3d_cache::write_delta`).
|
||||
let delta = (name == "model3dPartsDelta").then(|| args.get(5).copied().filter(|m| m.is_finite() && *m >= 0.0).unwrap_or(0.0) as u64);
|
||||
// [173] Mit Modelldarstellung (`text`) ohne den Cache (eigene Teile, s. `model3d_mv`).
|
||||
if (name == "model3dParts" || delta.is_some()) && args.len() >= 3 && !explode && model3d_mv_id(text).is_none() {
|
||||
if (name == "model3dParts" || delta.is_some()) && args.len() >= 3 && !explode && model3d_mv_id(text).is_none() && !text.contains("\"renovation\"") {
|
||||
let voids = args.get(3).is_some_and(|v| *v != 0.0);
|
||||
// [214] Ohne Abzugskörper braucht es die Wände/Decken nicht als Werte (spart das Kopieren): leere `voidMeshes`.
|
||||
if voids && crate::plan::extras::void_prisms(d.project()?).is_empty() {
|
||||
@@ -68,11 +68,29 @@ fn model3d_mv(p: &Project, text: &str, detail: f64) -> (f64, bool) {
|
||||
(base, o.stair.handrail.is_some())
|
||||
}
|
||||
|
||||
/// [271] Projekt im Umbau-Zustand des Texts (`renovation::view_from_text`), sonst unverändert.
|
||||
fn renovation_state<'a>(p: &'a Project, text: &str) -> std::borrow::Cow<'a, Project> {
|
||||
match crate::renovation::view_from_text(p, text) {
|
||||
Some(v) => {
|
||||
let r = v.resolve(p);
|
||||
if r.hidden.is_empty() {
|
||||
std::borrow::Cow::Borrowed(p)
|
||||
} else {
|
||||
std::borrow::Cow::Owned(crate::renovation::without_hidden(p, &r.hidden))
|
||||
}
|
||||
}
|
||||
None => std::borrow::Cow::Borrowed(p),
|
||||
}
|
||||
}
|
||||
|
||||
/// Führt die Abfrage `name` aus. `args`: Zahlen, `text`: ein Text (z. B. eine id).
|
||||
pub fn run(p: &Project, name: &str, args: &[f64], text: &str) -> Result<String, String> {
|
||||
match (name, args.len()) {
|
||||
("kennzahlen", _) => json(&kennzahlen::compute(p)),
|
||||
("areaTable", _) => json(&flaechen::area_table(p)),
|
||||
// [271] Mit Umbau-Zustand (`text` = Filter-Id, z. B. „bestand“ oder „endzustand“; leer = alles).
|
||||
("kennzahlen", _) => json(&kennzahlen::compute(&renovation_state(p, text))),
|
||||
("areaTable", _) => json(&flaechen::area_table(&renovation_state(p, text))),
|
||||
// [271] Umbaufilter (eingebaute und eigene) für die Oberfläche.
|
||||
("renovationFilters", _) => json(&crate::renovation::filter_list(p)),
|
||||
// [209] Kostenschätzung grob; `costDefaults` mit Text „gf“/„gv“ = Beispielwerte der Methode.
|
||||
("costEstimate", _) => json(&crate::kosten::estimate(p)),
|
||||
("costDefaults", _) => json(&crate::kosten::default_estimate(if text.trim() == "gf" { crate::model::CostMethod::Gf } else { crate::model::CostMethod::Gv })),
|
||||
@@ -153,8 +171,15 @@ pub fn run(p: &Project, name: &str, args: &[f64], text: &str) -> Result<String,
|
||||
}
|
||||
return Ok(v.to_string());
|
||||
}
|
||||
// [271] Umbaufilter (`text` = `{"renovation": …, "renovationPhase": …}`): Ausgeblendetes fehlt, Farben je Status.
|
||||
let ren = crate::renovation::view_from_text(p, text).map(|v| v.resolve(p));
|
||||
let filtered = ren.as_ref().filter(|r| !r.hidden.is_empty()).map(|r| crate::renovation::without_hidden(p, &r.hidden));
|
||||
let p = filtered.as_ref().unwrap_or(p);
|
||||
let (detail, rails) = model3d_mv(p, text, args[1]);
|
||||
let mut parts = model3d::parts_filtered(p, args[0] != 0.0, detail, args[2] != 0.0, &filter)?;
|
||||
if let Some(r) = &ren {
|
||||
crate::renovation::color_parts(p, &mut parts, r);
|
||||
}
|
||||
if !rails {
|
||||
parts.stair_railings.clear();
|
||||
}
|
||||
@@ -329,7 +354,7 @@ pub fn run_bin(p: &Project, name: &str, args: &[f64], text: &str) -> Result<Vec<
|
||||
let c = domains::Ctx::new(p, &a);
|
||||
let flags = if args[1].is_finite() && args[1] >= 0.0 { args[1] as u32 } else { 0 };
|
||||
// Strichstärken nach Massstab wie im übrigen Plan.
|
||||
let post = Some(crate::plan::extras::Post { mono: flags & 2 != 0, lw: crate::plan::extras::line_weight_factor(p, args[0]), sketch: 0.0 }).filter(crate::plan::extras::Post::active);
|
||||
let post = Some(crate::plan::extras::Post { mono: flags & 2 != 0, lw: crate::plan::extras::line_weight_factor(p, args[0]), sketch: 0.0, keep: Default::default() }).filter(crate::plan::extras::Post::active);
|
||||
buf_with(post, |sink| drawings::underlay_lines(&c, &args[2..], flags & 1 != 0, sink))
|
||||
}
|
||||
// Primitive einer Zeichnung (JSON in `text`, ohne Override-Regeln) beim Massstab `args[0]`.
|
||||
|
||||
@@ -0,0 +1,594 @@
|
||||
//! [271] Umbau wie Archicads „Renovation“: Status je Bauteil (Bestand, Abbruch, Neu), Etappen und Umbaufilter.
|
||||
//!
|
||||
//! **Ein Ort im Kern** für „ist sichtbar / wie gezeichnet im Filter F“: Grundriss (`plan/domains.rs::Ctx`), Schnitt
|
||||
//! (`plan/section/query.rs`), Ansicht (`plan/elevation`), 3D (`model3d`), Kennzahlen und Exporte fragen [`View`]
|
||||
//! bzw. [`Resolved`] — wie die Klassen-Sichtbarkeit ([180]) und die Regel „Ausblenden“ ([33]).
|
||||
//!
|
||||
//! - **Status** (`Renovation.status`) fehlt ⇒ Bestand (Vorgabe beim Zeichnen, Wunsch Maintainer 17.11.). Eine Öffnung
|
||||
//! ohne eigenen Status folgt ihrer Wand.
|
||||
//! - **Filter** (eingebaut, s. [`BUILTIN`], oder `Project.renovation.filters`): je Status zeigen, ausblenden oder mit
|
||||
//! Umbau-Farbe ([`Style`], SIA 400: Bestand grau, Abbruch gelb gestrichelt, Neu rot; anpassbar in
|
||||
//! `Project.renovation.styles`). Ausgeblendetes ist wie nicht vorhanden: es verdeckt nichts, eine ausgeblendete
|
||||
//! Öffnung schliesst ihre Wand (wie die Regel „Ausblenden“).
|
||||
//! - **Etappen** (`Project.renovation.phases`, Reihenfolge der Liste): Ein Filter „bis Etappe n“ zeigt den Stand
|
||||
//! der Etappe n — Neues früherer Etappen ist dann Bestand, Abbruch früherer Etappen ist weg, Neues späterer
|
||||
//! Etappen fehlt noch, Abbruch späterer Etappen steht noch als Bestand. Ohne Etappe gelten die Status unverändert.
|
||||
//! - **Öffnungen in Bestandswänden** (fachlich wie im Umbauplan üblich): Eine neue Öffnung in einer Bestandswand
|
||||
//! bricht dort Mauerwerk ab — der Wandteil in der Öffnung ist ein Abbruch-Stück ([`Patch`], gelb). Eine Öffnung
|
||||
//! „Abbruch“ wird zugemauert — die Ausfachung ist ein Neu-Stück (rot). Ist die Öffnung ausgeblendet (Bestand:
|
||||
//! die neue Öffnung gibt es noch nicht; Neubau/Endzustand: die alte ist zu), ist die Wand dort geschlossen.
|
||||
|
||||
use crate::model::*;
|
||||
use crate::plan::prim::Primitive;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
/// Eingebaute Umbaufilter (Ids; Namen übersetzt die Oberfläche).
|
||||
pub const BUILTIN: [&str; 5] = ["bestand", "abbruch", "neubau", "umbauplan", "endzustand"];
|
||||
|
||||
/// Strichmuster (Papier-mm) für Abbruch: gestrichelt wie verdeckte Kanten.
|
||||
pub const DEMOLISH_DASH: [f64; 2] = crate::plan::line_pattern::HIDDEN;
|
||||
|
||||
/// Eingebauter Filter nach Id.
|
||||
pub fn builtin(id: &str) -> Option<RenovationFilter> {
|
||||
use RenovationShow::{Hide, Override, Show};
|
||||
let (existing, demolish, new) = match id {
|
||||
// Bestandsplan: alles, was heute steht (auch das, was abgebrochen wird), ohne Farbe.
|
||||
"bestand" => (Show, Show, Hide),
|
||||
// Abbruchplan: Bestand, Abbruch gelb.
|
||||
"abbruch" => (Show, Override, Hide),
|
||||
// Neubauplan: Bestand, Neu rot, Abbruch weg.
|
||||
"neubau" => (Show, Hide, Override),
|
||||
// Umbauplan: alle drei in den Umbau-Farben.
|
||||
"umbauplan" => (Override, Override, Override),
|
||||
// Endzustand: Bestand und Neu ohne Farbe, Abbruch weg.
|
||||
"endzustand" => (Show, Hide, Show),
|
||||
_ => return None,
|
||||
};
|
||||
Some(RenovationFilter { id: id.to_string(), name: id.to_string(), existing, demolish, new, ..Default::default() })
|
||||
}
|
||||
|
||||
/// Filter nach Id (eigene vor eingebauten), sonst nach Name ohne Gross-/Kleinschreibung (CLI `--renovation`).
|
||||
pub fn find_filter(p: &Project, key: &str) -> Option<RenovationFilter> {
|
||||
let key = key.trim();
|
||||
if key.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let own = p.renovation.as_ref().and_then(|r| r.filters.as_deref()).unwrap_or(&[]);
|
||||
if let Some(f) = own.iter().find(|f| f.id == key) {
|
||||
return Some(f.clone());
|
||||
}
|
||||
if let Some(f) = builtin(key) {
|
||||
return Some(f);
|
||||
}
|
||||
let low = key.to_lowercase();
|
||||
if let Some(f) = own.iter().find(|f| f.name.to_lowercase() == low) {
|
||||
return Some(f.clone());
|
||||
}
|
||||
builtin(&low)
|
||||
}
|
||||
|
||||
/// Etappen des Projekts in ihrer Reihenfolge.
|
||||
pub fn phases(p: &Project) -> &[RenovationPhase] {
|
||||
p.renovation.as_ref().and_then(|r| r.phases.as_deref()).unwrap_or(&[])
|
||||
}
|
||||
|
||||
/// Index einer Etappe nach Id oder Name (ohne Gross-/Kleinschreibung); `None` = unbekannt.
|
||||
pub fn phase_index(p: &Project, key: &str) -> Option<usize> {
|
||||
let ph = phases(p);
|
||||
let low = key.trim().to_lowercase();
|
||||
ph.iter().position(|x| x.id == key).or_else(|| ph.iter().position(|x| x.name.to_lowercase() == low))
|
||||
}
|
||||
|
||||
/// Status eines Elements (fehlt/unbekannt ⇒ Bestand).
|
||||
pub fn status_of(r: Option<&Renovation>) -> RenovationStatus {
|
||||
match r.map(|r| r.status) {
|
||||
Some(RenovationStatus::Demolish) => RenovationStatus::Demolish,
|
||||
Some(RenovationStatus::New) => RenovationStatus::New,
|
||||
_ => RenovationStatus::Existing,
|
||||
}
|
||||
}
|
||||
|
||||
/// Umbau-Angaben einer Öffnung: eigene, sonst die ihrer Wand.
|
||||
pub fn opening_renovation<'a>(p: &'a Project, o: &'a Opening) -> Option<&'a Renovation> {
|
||||
o.renovation.as_ref().or_else(|| p.walls.iter().find(|w| w.id == o.host_wall_id).and_then(|w| w.renovation.as_ref()))
|
||||
}
|
||||
|
||||
/// Umbau-Farbe eines Status, aufgelöst (Projekt-Vorgabe über der SIA-Vorgabe).
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Style {
|
||||
/// Füllung der Schnittflächen (ohne Muster).
|
||||
pub fill: String,
|
||||
/// Linienfarbe (`None` = Linien wie ohne Filter).
|
||||
pub line: Option<String>,
|
||||
/// Linien gestrichelt ([`DEMOLISH_DASH`]).
|
||||
pub dashed: bool,
|
||||
}
|
||||
|
||||
/// SIA-400-Vorgabe: Bestand grau, Abbruch gelb und gestrichelt, Neu rot.
|
||||
pub fn default_style(s: RenovationStatus) -> Style {
|
||||
match s {
|
||||
RenovationStatus::Demolish => Style { fill: "#ffd800".into(), line: None, dashed: true },
|
||||
RenovationStatus::New => Style { fill: "#e3001b".into(), line: Some("#c00016".into()), dashed: false },
|
||||
_ => Style { fill: "#a6a6a6".into(), line: None, dashed: false },
|
||||
}
|
||||
}
|
||||
|
||||
/// Umbau-Farbe eines Status im Projekt.
|
||||
pub fn style(p: &Project, s: RenovationStatus) -> Style {
|
||||
let mut st = default_style(s);
|
||||
let own = p.renovation.as_ref().and_then(|r| r.styles.as_ref()).and_then(|x| match s {
|
||||
RenovationStatus::Demolish => x.demolish.as_ref(),
|
||||
RenovationStatus::New => x.new.as_ref(),
|
||||
_ => x.existing.as_ref(),
|
||||
});
|
||||
if let Some(o) = own {
|
||||
if let Some(f) = o.fill.as_deref().map(str::trim).filter(|f| !f.is_empty()) {
|
||||
st.fill = f.to_string();
|
||||
}
|
||||
if let Some(l) = o.line.as_deref().map(str::trim) {
|
||||
st.line = (!l.is_empty()).then(|| l.to_string());
|
||||
}
|
||||
if let Some(d) = o.dashed {
|
||||
st.dashed = d;
|
||||
}
|
||||
}
|
||||
st
|
||||
}
|
||||
|
||||
/// Wie ein Element im Filter erscheint.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum Treat {
|
||||
Show,
|
||||
Hide,
|
||||
Style(Style),
|
||||
}
|
||||
|
||||
/// Ein aufgelöster Umbaufilter einer Darstellung.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct View {
|
||||
pub filter: RenovationFilter,
|
||||
/// Etappe, bis zu der der Filter gilt (Index), `None` = alle.
|
||||
pub upto: Option<usize>,
|
||||
phases: HashMap<String, usize>,
|
||||
styles: [Style; 3],
|
||||
}
|
||||
|
||||
impl View {
|
||||
/// Filter `filter` (Id oder Name) bis Etappe `phase` (Id oder Name); `None` ohne (gültigen) Filter.
|
||||
pub fn new(p: &Project, filter: Option<&str>, phase: Option<&str>) -> Option<View> {
|
||||
let filter = find_filter(p, filter?)?;
|
||||
let upto = phase.filter(|s| !s.trim().is_empty()).and_then(|s| phase_index(p, s));
|
||||
let phases = phases(p).iter().enumerate().map(|(i, x)| (x.id.clone(), i)).collect();
|
||||
let styles = [style(p, RenovationStatus::Existing), style(p, RenovationStatus::Demolish), style(p, RenovationStatus::New)];
|
||||
Some(View { filter, upto, phases, styles })
|
||||
}
|
||||
|
||||
/// Filter einer Darstellung: ausdrücklich angefragt (CLI, Blatt-Ausschnitt), sonst der der Ebene `level_id`
|
||||
/// (`DrawingLevel.renovationFilter`/`renovationPhase`, wie die Modelldarstellung [173]).
|
||||
pub fn for_level(p: &Project, level_id: &str, filter: Option<&str>, phase: Option<&str>) -> Option<View> {
|
||||
let l = p.floor(level_id);
|
||||
let f = filter.filter(|s| !s.is_empty()).or_else(|| l.and_then(|l| l.renovation_filter.as_deref()));
|
||||
let ph = if filter.is_some_and(|s| !s.is_empty()) { phase } else { phase.or_else(|| l.and_then(|l| l.renovation_phase.as_deref())) };
|
||||
Self::new(p, f, ph)
|
||||
}
|
||||
|
||||
/// Zustand des Elements in der Etappe des Filters; `None` = es steht dort (noch/schon) nicht.
|
||||
pub fn state(&self, r: Option<&Renovation>) -> Option<RenovationStatus> {
|
||||
let s = status_of(r);
|
||||
let Some(l) = self.upto else { return Some(s) };
|
||||
let i = r.and_then(|r| r.phase.as_deref()).and_then(|id| self.phases.get(id).copied()).unwrap_or(0);
|
||||
use std::cmp::Ordering::*;
|
||||
match (s, i.cmp(&l)) {
|
||||
(RenovationStatus::New, Greater) | (RenovationStatus::Demolish, Less) => None,
|
||||
(RenovationStatus::New, Less) | (RenovationStatus::Demolish, Greater) => Some(RenovationStatus::Existing),
|
||||
(s, _) => Some(s),
|
||||
}
|
||||
}
|
||||
|
||||
/// Darstellung eines Zustands im Filter.
|
||||
pub fn treat_state(&self, s: Option<RenovationStatus>) -> Treat {
|
||||
let Some(s) = s else { return Treat::Hide };
|
||||
let (show, k) = match s {
|
||||
RenovationStatus::Demolish => (self.filter.demolish, 1),
|
||||
RenovationStatus::New => (self.filter.new, 2),
|
||||
_ => (self.filter.existing, 0),
|
||||
};
|
||||
match show {
|
||||
RenovationShow::Hide => Treat::Hide,
|
||||
RenovationShow::Override => Treat::Style(self.styles[k].clone()),
|
||||
_ => Treat::Show,
|
||||
}
|
||||
}
|
||||
|
||||
/// Darstellung eines Elements mit diesen Umbau-Angaben.
|
||||
pub fn treat(&self, r: Option<&Renovation>) -> Treat {
|
||||
self.treat_state(self.state(r))
|
||||
}
|
||||
|
||||
/// Ist ein Element mit diesen Angaben im Filter sichtbar?
|
||||
pub fn visible(&self, r: Option<&Renovation>) -> bool {
|
||||
self.treat(r) != Treat::Hide
|
||||
}
|
||||
|
||||
/// Ausgeblendete Elemente, Umbau-Farben und Ersatzstücke der Öffnungen für das ganze Projekt.
|
||||
pub fn resolve(&self, p: &Project) -> Resolved {
|
||||
let mut out = Resolved::default();
|
||||
let mut put = |id: &str, t: Treat, out: &mut Resolved| match t {
|
||||
Treat::Hide => {
|
||||
out.hidden.insert(id.to_string());
|
||||
}
|
||||
Treat::Style(s) => {
|
||||
out.styled.insert(id.to_string(), s);
|
||||
}
|
||||
Treat::Show => {}
|
||||
};
|
||||
let mut wall_state: HashMap<&str, Option<RenovationStatus>> = HashMap::new();
|
||||
for w in &p.walls {
|
||||
let s = self.state(w.renovation.as_ref());
|
||||
wall_state.insert(w.id.as_str(), s);
|
||||
put(&w.id, self.treat_state(s), &mut out);
|
||||
}
|
||||
for o in p.openings.iter().flatten() {
|
||||
let host = wall_state.get(o.host_wall_id.as_str()).copied().flatten();
|
||||
if out.hidden.contains(&o.host_wall_id) {
|
||||
out.hidden.insert(o.id.clone());
|
||||
continue;
|
||||
}
|
||||
let s = self.state(opening_renovation(p, o));
|
||||
put(&o.id, self.treat_state(s), &mut out);
|
||||
// Ersatzstück nur, wenn die Öffnung einen anderen Zustand hat als ihre (Bestands-)Wand.
|
||||
if o.renovation.is_none() || host != Some(RenovationStatus::Existing) {
|
||||
continue;
|
||||
}
|
||||
let virt = match s {
|
||||
Some(RenovationStatus::New) => RenovationStatus::Demolish,
|
||||
Some(RenovationStatus::Demolish) => RenovationStatus::New,
|
||||
_ => continue,
|
||||
};
|
||||
if let Treat::Style(st) = self.treat_state(Some(virt)) {
|
||||
out.patches.push(Patch { opening_id: o.id.clone(), wall_id: o.host_wall_id.clone(), status: virt, style: st, closed: out.hidden.contains(&o.id) });
|
||||
}
|
||||
}
|
||||
for x in p.ceilings.iter().flatten() {
|
||||
put(&x.id, self.treat(x.renovation.as_ref()), &mut out);
|
||||
}
|
||||
for x in p.roofs.iter().flatten() {
|
||||
put(&x.id, self.treat(x.renovation.as_ref()), &mut out);
|
||||
}
|
||||
for x in p.stairs.iter().flatten() {
|
||||
put(&x.id, self.treat(x.renovation.as_ref()), &mut out);
|
||||
}
|
||||
for x in p.columns.iter().flatten() {
|
||||
put(&x.id, self.treat(x.renovation.as_ref()), &mut out);
|
||||
}
|
||||
for x in p.extruded_solids.iter().flatten() {
|
||||
put(&x.id, self.treat(x.renovation.as_ref()), &mut out);
|
||||
}
|
||||
// Räume: nur sichtbar oder nicht (ein Raum ist kein Bauteil, er bekommt keine Umbau-Farbe).
|
||||
for x in p.rooms.iter().flatten() {
|
||||
if !self.visible(x.renovation.as_ref()) {
|
||||
out.hidden.insert(x.id.clone());
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Füll- und Linienfarben der Status, die der Filter farbig zeigt (bleiben in Schwarz-Weiss erhalten).
|
||||
pub fn colors(&self) -> Vec<String> {
|
||||
let mut out = Vec::new();
|
||||
for (show, st) in [(self.filter.existing, &self.styles[0]), (self.filter.demolish, &self.styles[1]), (self.filter.new, &self.styles[2])] {
|
||||
if show == RenovationShow::Override {
|
||||
out.push(st.fill.clone());
|
||||
out.extend(st.line.clone());
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Schlüssel für Caches (Filter samt Darstellungen, Etappe, Farben).
|
||||
pub fn key(&self) -> String {
|
||||
format!("{}:{:?}{:?}{:?}:{:?}:{:?}", self.filter.id, self.filter.existing, self.filter.demolish, self.filter.new, self.upto, self.styles)
|
||||
}
|
||||
}
|
||||
|
||||
/// Ersatzstück einer Öffnung in einer Bestandswand: abgebrochenes Mauerwerk (neue Öffnung) bzw. Ausfachung
|
||||
/// (zugemauerte Öffnung), mit der Umbau-Farbe seines Status.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Patch {
|
||||
pub opening_id: String,
|
||||
pub wall_id: String,
|
||||
/// Status des Stücks (Abbruch für eine neue Öffnung, Neu für eine zugemauerte).
|
||||
pub status: RenovationStatus,
|
||||
pub style: Style,
|
||||
/// Die Öffnung ist ausgeblendet (die Wand ist dort geschlossen): das Stück liegt über der Wand.
|
||||
pub closed: bool,
|
||||
}
|
||||
|
||||
/// Ergebnis eines Filters für ein Projekt.
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct Resolved {
|
||||
/// Ausgeblendete Elemente (ids): Wände nehmen ihre Öffnungen mit.
|
||||
pub hidden: HashSet<String>,
|
||||
/// Elemente mit Umbau-Farbe (id → Farbe).
|
||||
pub styled: HashMap<String, Style>,
|
||||
pub patches: Vec<Patch>,
|
||||
}
|
||||
|
||||
impl Resolved {
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.hidden.is_empty() && self.styled.is_empty() && self.patches.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
/// Das Projekt ohne die im Filter ausgeblendeten Elemente (Kennzahlen, 3D, Exporte, Schnitt und Ansicht).
|
||||
pub fn without_hidden(p: &Project, hidden: &HashSet<String>) -> Project {
|
||||
let mut q = crate::plan::section::without_elements(p, hidden);
|
||||
if let Some(v) = &mut q.extruded_solids {
|
||||
v.retain(|x| !hidden.contains(&x.id));
|
||||
}
|
||||
q
|
||||
}
|
||||
|
||||
/// Das Projekt im Zustand eines Filters (`filter`: Id/Name, `phase`: Etappe); ohne gültigen Filter unverändert.
|
||||
pub fn project_in_state<'a>(p: &'a Project, filter: Option<&str>, phase: Option<&str>) -> std::borrow::Cow<'a, Project> {
|
||||
match View::new(p, filter, phase) {
|
||||
Some(v) => {
|
||||
let r = v.resolve(p);
|
||||
if r.hidden.is_empty() {
|
||||
std::borrow::Cow::Borrowed(p)
|
||||
} else {
|
||||
std::borrow::Cow::Owned(without_hidden(p, &r.hidden))
|
||||
}
|
||||
}
|
||||
None => std::borrow::Cow::Borrowed(p),
|
||||
}
|
||||
}
|
||||
|
||||
/// Ist eine Füllung sichtbar (nicht leer/„none“/ganz durchsichtig)? Nur solche Flächen bekommen die Umbau-Farbe.
|
||||
fn solid_fill(fill: &str) -> bool {
|
||||
let f = fill.trim();
|
||||
!(f.is_empty() || f == "none" || f == "transparent" || (f.starts_with('#') && f.len() == 9 && f.ends_with("00")))
|
||||
}
|
||||
|
||||
/// Umbau-Farbe auf ein Primitiv: Schnittflächen in der Füllfarbe ohne Muster, Linien in der Linienfarbe,
|
||||
/// gestrichelt bei Abbruch. Umrisse von Flächen werden dafür als Linien ausgegeben (`extra`), weil Flächen kein
|
||||
/// Strichmuster tragen.
|
||||
pub fn restyle(q: &mut Primitive, st: &Style, extra: &mut Vec<Primitive>) {
|
||||
restyle_with(q, st, extra, true);
|
||||
}
|
||||
|
||||
/// Wie [`restyle`]; `fill = false` lässt die Füllung von Flächen (nur Linien in Farbe und Strichmuster).
|
||||
pub fn restyle_with(q: &mut Primitive, st: &Style, extra: &mut Vec<Primitive>, with_fill: bool) {
|
||||
let dash = || Some(Some(DEMOLISH_DASH.to_vec()));
|
||||
match q {
|
||||
Primitive::Polygon { pts, fill, stroke, stroke_width_mm, hatch, no_stroke_edges, greyed, .. } => {
|
||||
if with_fill && solid_fill(fill) {
|
||||
*fill = st.fill.clone();
|
||||
*hatch = Box::new(crate::plan::style::no_hatch());
|
||||
}
|
||||
if let Some(l) = &st.line {
|
||||
if stroke.trim() != "none" && !stroke.is_empty() {
|
||||
*stroke = l.clone();
|
||||
}
|
||||
}
|
||||
if st.dashed && stroke.trim() != "none" && !stroke.is_empty() && *stroke_width_mm > 0.0 && pts.len() >= 2 {
|
||||
let skip: HashSet<usize> = no_stroke_edges.iter().flatten().filter(|x| x.is_finite() && **x >= 0.0).map(|x| *x as usize).collect();
|
||||
let n = pts.len();
|
||||
for i in 0..n {
|
||||
if skip.contains(&i) {
|
||||
continue;
|
||||
}
|
||||
let (a, b) = (pts[i], pts[(i + 1) % n]);
|
||||
extra.push(Primitive::Line { a, b, cls: "renovation-outline".into(), weight_mm: *stroke_width_mm, dash: dash(), zigzag: None, motif: None, color: Some(stroke.clone().into()), drawing_id: None, opening_id: None, stair_id: None, greyed: *greyed, opacity: None });
|
||||
}
|
||||
*stroke = "none".into();
|
||||
}
|
||||
}
|
||||
Primitive::Line { color, dash: d, .. } => {
|
||||
if let Some(l) = &st.line {
|
||||
*color = Some(l.clone().into());
|
||||
}
|
||||
if st.dashed {
|
||||
*d = dash();
|
||||
}
|
||||
}
|
||||
Primitive::Arc { color, dash: d, .. } => {
|
||||
if let Some(l) = &st.line {
|
||||
*color = Some(l.clone().into());
|
||||
}
|
||||
if st.dashed {
|
||||
*d = dash();
|
||||
}
|
||||
}
|
||||
Primitive::DrawingCircle { stroke, dash: d, .. } | Primitive::DrawingArc { stroke, dash: d, .. } => {
|
||||
if let Some(l) = &st.line {
|
||||
*stroke = l.clone();
|
||||
}
|
||||
if st.dashed {
|
||||
*d = dash();
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
/// Element-Id eines Primitivs (Öffnung vor Wand und übrigen Bauteilen).
|
||||
pub fn prim_element(q: &Primitive) -> Option<&str> {
|
||||
match q {
|
||||
Primitive::Polygon { opening_id, wall_id, ceiling_id, stair_id, extruded_solid_id, column_id, roof_id, .. } => {
|
||||
opening_id.as_deref().or(wall_id.as_deref()).or(ceiling_id.as_deref()).or(stair_id.as_deref()).or(extruded_solid_id.as_deref()).or(column_id.as_deref()).or(roof_id.as_deref())
|
||||
}
|
||||
Primitive::Line { opening_id, stair_id, .. } | Primitive::Arc { opening_id, stair_id, .. } => opening_id.as_deref().or(stair_id.as_deref()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Umbau-Farben auf `prims[from..]`: jedes Primitiv nach seinem Element ([`prim_element`]), sonst nach `owner`
|
||||
/// (z. B. die Wand, deren Umrisslinien keine Id tragen). Umrisslinien gestrichelter Flächen kommen dahinter.
|
||||
pub fn restyle_range(r: &Resolved, prims: &mut Vec<Primitive>, from: usize, owner: Option<&str>) {
|
||||
if r.styled.is_empty() || from >= prims.len() {
|
||||
return;
|
||||
}
|
||||
let mut extra = Vec::new();
|
||||
for q in prims[from..].iter_mut() {
|
||||
let id = prim_element(q).or(owner);
|
||||
if let Some(st) = id.and_then(|id| r.styled.get(id)) {
|
||||
// Symbole und Ansichten (Fenster, Türflügel, Treppenstufen, Decken- und Dachkanten): nur Linien.
|
||||
let f = cut_fill(q);
|
||||
restyle_with(q, st, &mut extra, f);
|
||||
}
|
||||
}
|
||||
prims.extend(extra);
|
||||
}
|
||||
|
||||
/// Schnittfläche eines Bauteils (Wand-Poché, geschnittene Stütze), die die Umbau-Füllung bekommt — nicht die Flächen der
|
||||
/// Öffnungssymbole, Treppenstufen, Decken und Dächer (sonst wären Fensterrahmen oder Tritte grau/rot gefüllt).
|
||||
fn cut_fill(q: &Primitive) -> bool {
|
||||
matches!(q, Primitive::Polygon { opening_id: None, wall_id: Some(_), .. } | Primitive::Polygon { opening_id: None, column_id: Some(_), .. })
|
||||
}
|
||||
|
||||
/// Grundriss: Fläche eines Ersatzstücks (Wandband zwischen den Leibungen der Öffnung), `None` bei Bogenwänden
|
||||
/// oder ohne gültige Lage.
|
||||
pub fn patch_ring(p: &Project, w: &Wall, o: &Opening) -> Option<Vec<Vec2>> {
|
||||
if crate::wall_arc::WallArc::of_wall(w).is_some() {
|
||||
return None;
|
||||
}
|
||||
let total = p.wall_thickness(w, 0.2);
|
||||
let ref_off = crate::joins::reference_offset(crate::model3d::wall_reference(w), total);
|
||||
let wr = crate::opening_geom::WallRef { start: crate::opening_geom::v(w.start.x, w.start.y), end: crate::opening_geom::v(w.end.x, w.end.y), total, ref_off };
|
||||
let (from, to) = crate::opening_geom::opening_interval(&wr, o.position, o.width)?;
|
||||
let fp = crate::plan::wall_poche::wall_footprint([w.start.x, w.start.y], [w.end.x, w.end.y], total, ref_off);
|
||||
let at = |s: f64, n: f64| Vec2 { x: fp.a[0] + fp.u[0] * s + fp.m[0] * n, y: fp.a[1] + fp.u[1] * s + fp.m[1] * n };
|
||||
let (n0, n1) = (ref_off - fp.half, ref_off + fp.half);
|
||||
let ring = vec![at(from, n0), at(to, n0), at(to, n1), at(from, n1)];
|
||||
ring.iter().all(|v| v.x.is_finite() && v.y.is_finite()).then_some(ring)
|
||||
}
|
||||
|
||||
/// Grundriss: Ersatzstück als Fläche mit Umriss (gestrichelt bei Abbruch), an der Öffnung (Picken wählt sie).
|
||||
pub fn patch_prims(ring: Vec<Vec2>, st: &Style, weight_mm: f64, opening_id: &str) -> Vec<Primitive> {
|
||||
let stroke = st.line.clone().unwrap_or_else(|| "#000000".into());
|
||||
let mut q = Primitive::Polygon {
|
||||
pts: ring,
|
||||
fill: st.fill.clone(),
|
||||
stroke,
|
||||
stroke_width_mm: weight_mm,
|
||||
hatch: Box::new(crate::plan::style::no_hatch()),
|
||||
greyed: None,
|
||||
opacity: None,
|
||||
no_stroke_edges: None,
|
||||
wall_id: None,
|
||||
drawing_id: None,
|
||||
ceiling_id: None,
|
||||
opening_id: Some(opening_id.to_string()),
|
||||
stair_id: None,
|
||||
room_id: None,
|
||||
extruded_solid_id: None,
|
||||
context_object_id: None,
|
||||
column_id: None,
|
||||
roof_id: None,
|
||||
section_line_id: None,
|
||||
};
|
||||
let mut extra = Vec::new();
|
||||
if st.dashed {
|
||||
restyle(&mut q, &Style { fill: st.fill.clone(), line: None, dashed: true }, &mut extra);
|
||||
}
|
||||
// Linien des Stücks tragen die Öffnung (Picken, Kontrast).
|
||||
for l in extra.iter_mut() {
|
||||
if let Primitive::Line { opening_id: oid, .. } = l {
|
||||
*oid = Some(opening_id.to_string());
|
||||
}
|
||||
}
|
||||
let mut out = vec![q];
|
||||
out.extend(extra);
|
||||
out
|
||||
}
|
||||
|
||||
/// Umbaufilter aus einem JSON-Text (`{"renovation": Id/Name, "renovationPhase": Etappe}`, 3D und Kennzahlen);
|
||||
/// ein Text ohne `{` ist selbst die Filter-Id. `None` ohne Filter.
|
||||
pub fn view_from_text(p: &Project, text: &str) -> Option<View> {
|
||||
let t = text.trim();
|
||||
if t.is_empty() {
|
||||
return None;
|
||||
}
|
||||
if !t.starts_with('{') {
|
||||
return View::new(p, Some(t), None);
|
||||
}
|
||||
let v: serde_json::Value = serde_json::from_str(t).ok()?;
|
||||
let f = v.get("renovation").and_then(|x| x.as_str())?;
|
||||
View::new(p, Some(f), v.get("renovationPhase").and_then(|x| x.as_str()))
|
||||
}
|
||||
|
||||
/// 3D: Teile in der Umbau-Farbe (Füllfarbe des Status) — Wände, Decken, Dächer, Stützen, Treppen, Körper.
|
||||
pub fn color_parts(p: &Project, parts: &mut crate::model3d::Parts, r: &Resolved) {
|
||||
if r.styled.is_empty() {
|
||||
return;
|
||||
}
|
||||
let rgb = |id: &str| r.styled.get(id).map(|s| crate::style::hex_to_rgb(&s.fill, crate::style::WALL_RGB));
|
||||
for w in &mut parts.walls {
|
||||
if let Some(c) = rgb(&w.wall_id) {
|
||||
w.color = c;
|
||||
w.material_index = None;
|
||||
}
|
||||
}
|
||||
for s in &mut parts.slabs {
|
||||
if let Some(c) = rgb(&s.ceiling_id) {
|
||||
s.color = c;
|
||||
}
|
||||
}
|
||||
let meshes = [&mut parts.column_meshes, &mut parts.stair_meshes, &mut parts.roof_meshes, &mut parts.solid_meshes, &mut parts.stair_railings];
|
||||
for list in meshes {
|
||||
for m in list.iter_mut() {
|
||||
if let Some(c) = m.owner.id(p).and_then(rgb) {
|
||||
m.color = c;
|
||||
m.vertex_colors = None;
|
||||
m.material_index = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
for l in &mut parts.roof_layers {
|
||||
if let Some(c) = l.owner.id(p).and_then(rgb) {
|
||||
l.color = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Liste der Filter für die Oberfläche (Abfrage `renovationFilters`): eingebaute, dann eigene.
|
||||
pub fn filter_list(p: &Project) -> Vec<serde_json::Value> {
|
||||
let mut out: Vec<serde_json::Value> = BUILTIN.iter().map(|id| serde_json::json!({"id": id, "name": id, "builtin": true})).collect();
|
||||
for f in p.renovation.as_ref().and_then(|r| r.filters.as_deref()).unwrap_or(&[]) {
|
||||
out.push(serde_json::json!({"id": f.id, "name": f.name, "builtin": false}));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Statuswort für Exporte (DXF-Layer-Endung, IFC `Pset_*Common.Status`).
|
||||
pub fn ifc_status(s: RenovationStatus) -> &'static str {
|
||||
match s {
|
||||
RenovationStatus::Demolish => "DEMOLISH",
|
||||
RenovationStatus::New => "NEW",
|
||||
_ => "EXISTING",
|
||||
}
|
||||
}
|
||||
|
||||
/// Umbau-Angaben eines Bauteils nach Id (Wand, Öffnung mit Wand-Rückfall, Decke, Dach, Treppe, Stütze, Körper, Raum).
|
||||
pub fn renovation_of<'a>(p: &'a Project, id: &str) -> Option<&'a Renovation> {
|
||||
if let Some(w) = p.walls.iter().find(|w| w.id == id) {
|
||||
return w.renovation.as_ref();
|
||||
}
|
||||
if let Some(o) = p.openings.iter().flatten().find(|o| o.id == id) {
|
||||
return opening_renovation(p, o);
|
||||
}
|
||||
macro_rules! look {
|
||||
($($f:ident),*) => {$(
|
||||
if let Some(x) = p.$f.iter().flatten().find(|x| x.id == id) {
|
||||
return x.renovation.as_ref();
|
||||
}
|
||||
)*};
|
||||
}
|
||||
look!(ceilings, roofs, stairs, columns, extruded_solids, rooms);
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "renovation_tests.rs"]
|
||||
mod tests;
|
||||
@@ -0,0 +1,491 @@
|
||||
//! [271] Tests des Umbaufilters: Vorgaben, Etappen, Öffnungen in Bestandswänden, Robustheit.
|
||||
|
||||
use super::*;
|
||||
use serde_json::{json, Value};
|
||||
|
||||
/// Musterhaus (Fixture) mit Umbau-Angaben: W2 Abbruch, W9 Neu (Etappe 2), O1 neue Öffnung in Bestandswand W1,
|
||||
/// O2 zugemauert (Abbruch) in W3, Decke C1 Bestand; Etappen e1, e2.
|
||||
pub(crate) fn umbau_fixture() -> Value {
|
||||
let mut v: Value = serde_json::from_str(include_str!("../tests/fixtures/sample_project.json")).unwrap();
|
||||
let set = |v: &mut Value, coll: &str, id: &str, r: Value| {
|
||||
for x in v[coll].as_array_mut().unwrap() {
|
||||
if x["id"] == id {
|
||||
x["renovation"] = r.clone();
|
||||
}
|
||||
}
|
||||
};
|
||||
set(&mut v, "walls", "W2", json!({"status": "demolish"}));
|
||||
set(&mut v, "walls", "W9", json!({"status": "new", "phase": "e2"}));
|
||||
set(&mut v, "openings", "O1", json!({"status": "new"}));
|
||||
set(&mut v, "openings", "O2", json!({"status": "demolish"}));
|
||||
v["renovation"] = json!({"phases": [{"id": "e1", "name": "Etappe 1"}, {"id": "e2", "name": "Etappe 2"}]});
|
||||
v
|
||||
}
|
||||
|
||||
pub(crate) fn project(v: &Value) -> Project {
|
||||
serde_json::from_value(v.clone()).unwrap()
|
||||
}
|
||||
|
||||
fn st(s: &str) -> Option<Renovation> {
|
||||
Some(Renovation { status: serde_json::from_value(json!(s)).unwrap(), ..Default::default() })
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vorgaben_je_status() {
|
||||
let p = project(&umbau_fixture());
|
||||
let t = |f: &str, s: &str| View::new(&p, Some(f), None).unwrap().treat(st(s).as_ref());
|
||||
let ex = |s| Treat::Style(default_style(s));
|
||||
// Bestand: alles, was heute steht.
|
||||
assert_eq!(t("bestand", "existing"), Treat::Show);
|
||||
assert_eq!(t("bestand", "demolish"), Treat::Show);
|
||||
assert_eq!(t("bestand", "new"), Treat::Hide);
|
||||
// Abbruch: Abbruch gelb, Neues fehlt.
|
||||
assert_eq!(t("abbruch", "demolish"), ex(RenovationStatus::Demolish));
|
||||
assert_eq!(t("abbruch", "new"), Treat::Hide);
|
||||
// Neubau: Neu rot, Abbruch weg.
|
||||
assert_eq!(t("neubau", "new"), ex(RenovationStatus::New));
|
||||
assert_eq!(t("neubau", "demolish"), Treat::Hide);
|
||||
assert_eq!(t("neubau", "existing"), Treat::Show);
|
||||
// Umbauplan: alle drei farbig.
|
||||
assert_eq!(t("umbauplan", "existing"), ex(RenovationStatus::Existing));
|
||||
assert_eq!(t("umbauplan", "demolish"), ex(RenovationStatus::Demolish));
|
||||
assert_eq!(t("umbauplan", "new"), ex(RenovationStatus::New));
|
||||
// Endzustand: ohne Farbe, Abbruch weg.
|
||||
assert_eq!(t("endzustand", "new"), Treat::Show);
|
||||
assert_eq!(t("endzustand", "demolish"), Treat::Hide);
|
||||
// Fehlender Status = Bestand.
|
||||
assert_eq!(View::new(&p, Some("umbauplan"), None).unwrap().treat(None), ex(RenovationStatus::Existing));
|
||||
// SIA: Abbruch gelb gestrichelt, Neu rot.
|
||||
assert!(default_style(RenovationStatus::Demolish).dashed);
|
||||
assert!(default_style(RenovationStatus::New).fill.starts_with("#e3"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kein_filter_ohne_gueltige_id() {
|
||||
let p = project(&umbau_fixture());
|
||||
assert!(View::new(&p, None, None).is_none());
|
||||
assert!(View::new(&p, Some(""), None).is_none());
|
||||
assert!(View::new(&p, Some("gibts-nicht"), None).is_none());
|
||||
// Name ohne Gross-/Kleinschreibung (CLI).
|
||||
assert_eq!(View::new(&p, Some("Umbauplan"), None).unwrap().filter.id, "umbauplan");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eigene_farben_und_filter() {
|
||||
let mut v = umbau_fixture();
|
||||
v["renovation"]["styles"] = json!({"new": {"fill": "#00ff00", "line": ""}, "demolish": {"dashed": false}});
|
||||
v["renovation"]["filters"] = json!([{"id": "f1", "name": "Nur Neu", "existing": "hide", "demolish": "hide", "new": "override"}]);
|
||||
let p = project(&v);
|
||||
let s = style(&p, RenovationStatus::New);
|
||||
assert_eq!(s.fill, "#00ff00");
|
||||
assert_eq!(s.line, None);
|
||||
assert!(!style(&p, RenovationStatus::Demolish).dashed);
|
||||
let f = View::new(&p, Some("Nur Neu"), None).unwrap();
|
||||
assert_eq!(f.treat(None), Treat::Hide);
|
||||
assert_eq!(f.treat(st("new").as_ref()), Treat::Style(s));
|
||||
assert_eq!(filter_list(&p).len(), 6);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn etappen() {
|
||||
let p = project(&umbau_fixture());
|
||||
let e = |s: &str, ph: Option<&str>| Some(Renovation { status: serde_json::from_value(json!(s)).unwrap(), phase: ph.map(String::from), ..Default::default() });
|
||||
let v1 = View::new(&p, Some("umbauplan"), Some("e1")).unwrap();
|
||||
let v2 = View::new(&p, Some("umbauplan"), Some("Etappe 2")).unwrap();
|
||||
assert_eq!(v2.upto, Some(1));
|
||||
// Neu in Etappe 2: in Etappe 1 noch nicht da, in Etappe 2 neu.
|
||||
assert_eq!(v1.state(e("new", Some("e2")).as_ref()), None);
|
||||
assert_eq!(v2.state(e("new", Some("e2")).as_ref()), Some(RenovationStatus::New));
|
||||
// Neu in Etappe 1 (auch ohne Etappe = erste): in Etappe 2 Bestand.
|
||||
assert_eq!(v2.state(e("new", None).as_ref()), Some(RenovationStatus::Existing));
|
||||
// Abbruch in Etappe 2: in Etappe 1 noch Bestand; Abbruch in Etappe 1: in Etappe 2 schon weg.
|
||||
assert_eq!(v1.state(e("demolish", Some("e2")).as_ref()), Some(RenovationStatus::Existing));
|
||||
assert_eq!(v2.state(e("demolish", Some("e1")).as_ref()), None);
|
||||
assert_eq!(v2.treat(e("demolish", Some("e1")).as_ref()), Treat::Hide);
|
||||
// Ohne Etappe im Filter: Status unverändert.
|
||||
let all = View::new(&p, Some("umbauplan"), None).unwrap();
|
||||
assert_eq!(all.state(e("new", Some("e2")).as_ref()), Some(RenovationStatus::New));
|
||||
// Unbekannte Etappe im Filter = alle; unbekannte Etappe am Element = erste.
|
||||
assert_eq!(View::new(&p, Some("umbauplan"), Some("x")).unwrap().upto, None);
|
||||
assert_eq!(v2.state(e("new", Some("x")).as_ref()), Some(RenovationStatus::Existing));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn aufloesen_mit_oeffnungen_in_bestandswand() {
|
||||
let p = project(&umbau_fixture());
|
||||
// Bestand: neue Wand W9 und neue Öffnung O1 fehlen (O1 schliesst die Wand), kein Ersatzstück.
|
||||
let r = View::new(&p, Some("bestand"), None).unwrap().resolve(&p);
|
||||
assert!(r.hidden.contains("W9") && r.hidden.contains("O1") && !r.hidden.contains("W2") && !r.hidden.contains("O2"));
|
||||
assert!(r.styled.is_empty() && r.patches.is_empty());
|
||||
// Abbruch: W2 und O2 gelb; O1 fehlt, an ihrer Stelle das gelbe Abbruch-Stück über der geschlossenen Wand.
|
||||
let r = View::new(&p, Some("abbruch"), None).unwrap().resolve(&p);
|
||||
assert!(r.styled.contains_key("W2") && r.styled.contains_key("O2"));
|
||||
assert_eq!(r.patches.len(), 1);
|
||||
assert_eq!((r.patches[0].opening_id.as_str(), r.patches[0].status, r.patches[0].closed), ("O1", RenovationStatus::Demolish, true));
|
||||
// Neubau: W2 weg, O2 zugemauert (ausgeblendet, rote Ausfachung), O1 rot, ohne Abbruch-Stück.
|
||||
let r = View::new(&p, Some("neubau"), None).unwrap().resolve(&p);
|
||||
assert!(r.hidden.contains("W2") && r.hidden.contains("O2") && !r.hidden.contains("O1"));
|
||||
assert!(r.styled.contains_key("O1") && r.styled.contains_key("W9") && !r.styled.contains_key("W1"));
|
||||
assert_eq!(r.patches.iter().map(|x| (x.opening_id.as_str(), x.status, x.closed)).collect::<Vec<_>>(), vec![("O2", RenovationStatus::New, true)]);
|
||||
// Umbauplan: beide Ersatzstücke in der offenen Öffnung, Bestand grau.
|
||||
let r = View::new(&p, Some("umbauplan"), None).unwrap().resolve(&p);
|
||||
assert_eq!(r.patches.len(), 2);
|
||||
assert!(r.patches.iter().all(|x| !x.closed));
|
||||
assert_eq!(r.styled["W1"], default_style(RenovationStatus::Existing));
|
||||
// Die Tür D1 ohne eigenen Status folgt ihrer Bestandswand.
|
||||
assert_eq!(r.styled["D1"], default_style(RenovationStatus::Existing));
|
||||
// Endzustand: wie Neubau ohne Farbe.
|
||||
let r = View::new(&p, Some("endzustand"), None).unwrap().resolve(&p);
|
||||
assert!(r.hidden.contains("W2") && r.hidden.contains("O2") && r.styled.is_empty() && r.patches.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn oeffnung_folgt_abgebrochener_wand() {
|
||||
let mut v = umbau_fixture();
|
||||
for w in v["walls"].as_array_mut().unwrap() {
|
||||
if w["id"] == "W1" {
|
||||
w["renovation"] = json!({"status": "demolish"});
|
||||
}
|
||||
}
|
||||
let p = project(&v);
|
||||
let r = View::new(&p, Some("neubau"), None).unwrap().resolve(&p);
|
||||
// Ausgeblendete Wand nimmt ihre Öffnungen mit, auch die „neue“ O1.
|
||||
assert!(r.hidden.contains("W1") && r.hidden.contains("D1") && r.hidden.contains("O1"));
|
||||
let r = View::new(&p, Some("abbruch"), None).unwrap().resolve(&p);
|
||||
assert!(r.styled.contains_key("D1"));
|
||||
// Kein Ersatzstück in einer Abbruch-Wand.
|
||||
assert!(r.patches.iter().all(|x| x.wall_id != "W1"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn robust_bei_unbekannten_werten() {
|
||||
let mut v = umbau_fixture();
|
||||
for w in v["walls"].as_array_mut().unwrap() {
|
||||
if w["id"] == "W3" {
|
||||
w["renovation"] = json!({"status": "abgerissen", "phase": "nirgends"});
|
||||
}
|
||||
if w["id"] == "W4" {
|
||||
w["renovation"] = json!({});
|
||||
}
|
||||
}
|
||||
let p = project(&v);
|
||||
assert_eq!(status_of(p.walls.iter().find(|w| w.id == "W3").unwrap().renovation.as_ref()), RenovationStatus::Existing);
|
||||
assert_eq!(status_of(p.walls.iter().find(|w| w.id == "W4").unwrap().renovation.as_ref()), RenovationStatus::Existing);
|
||||
let r = View::new(&p, Some("umbauplan"), Some("e2")).unwrap().resolve(&p);
|
||||
assert!(r.styled.contains_key("W3") && r.styled.contains_key("W4"));
|
||||
// Rundreise: unbekannter Status bleibt nicht als Text erhalten, das Feld aber lädt.
|
||||
assert!(serde_json::to_value(&p).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn projekt_im_zustand() {
|
||||
let p = project(&umbau_fixture());
|
||||
let b = project_in_state(&p, Some("bestand"), None);
|
||||
assert!(b.walls.iter().all(|w| w.id != "W9"));
|
||||
assert!(b.openings.iter().flatten().all(|o| o.id != "O1"));
|
||||
let e = project_in_state(&p, Some("endzustand"), None);
|
||||
assert!(e.walls.iter().all(|w| w.id != "W2"));
|
||||
assert!(e.walls.iter().any(|w| w.id == "W9"));
|
||||
// Ohne Filter unverändert (geliehen).
|
||||
assert!(matches!(project_in_state(&p, None, None), std::borrow::Cow::Borrowed(_)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn restyle_flaechen_und_linien() {
|
||||
let ring = vec![Vec2 { x: 0.0, y: 0.0 }, Vec2 { x: 1.0, y: 0.0 }, Vec2 { x: 1.0, y: 0.2 }, Vec2 { x: 0.0, y: 0.2 }];
|
||||
let q = patch_prims(ring, &default_style(RenovationStatus::Demolish), 0.25, "O1");
|
||||
// Fläche gelb ohne Strich, vier gestrichelte Umrisslinien an der Öffnung.
|
||||
assert_eq!(q.len(), 5);
|
||||
match &q[0] {
|
||||
Primitive::Polygon { fill, stroke, opening_id, .. } => {
|
||||
assert_eq!(fill, "#ffd800");
|
||||
assert_eq!(stroke, "none");
|
||||
assert_eq!(opening_id.as_deref(), Some("O1"));
|
||||
}
|
||||
_ => panic!(),
|
||||
}
|
||||
assert!(q[1..].iter().all(|l| matches!(l, Primitive::Line { dash: Some(Some(_)), opening_id: Some(_), .. })));
|
||||
// Leere Füllung bleibt leer.
|
||||
let mut poly = q[0].clone();
|
||||
if let Primitive::Polygon { fill, .. } = &mut poly {
|
||||
*fill = "none".into();
|
||||
}
|
||||
let mut extra = Vec::new();
|
||||
restyle(&mut poly, &default_style(RenovationStatus::New), &mut extra);
|
||||
assert!(matches!(&poly, Primitive::Polygon { fill, .. } if fill == "none"));
|
||||
}
|
||||
|
||||
// ── Ableitungen ───────────────────────────────────────────────────────────
|
||||
|
||||
use crate::plan::domains::{plan_domains, PlanArgs};
|
||||
|
||||
fn plan_with(p: &Project, extra: Value) -> Vec<Primitive> {
|
||||
let codes: Vec<String> = (0..100).map(|k| format!("{k:02}")).collect();
|
||||
let mut t = json!({"floor": "eg", "show": codes, "scale": 100});
|
||||
for (k, x) in extra.as_object().unwrap() {
|
||||
t[k] = x.clone();
|
||||
}
|
||||
let d = plan_domains(p, &PlanArgs::parse_in(p, 1.0, &t.to_string()).unwrap()).unwrap();
|
||||
[d.walls, d.ceilings, d.roofs, d.stairs, d.columns, d.solids].concat()
|
||||
}
|
||||
|
||||
fn has_wall(prims: &[Primitive], id: &str) -> bool {
|
||||
prims.iter().any(|q| matches!(q, Primitive::Polygon { wall_id: Some(w), .. } if w == id))
|
||||
}
|
||||
|
||||
fn has_opening(prims: &[Primitive], id: &str) -> bool {
|
||||
prims.iter().any(|q| match q {
|
||||
Primitive::Polygon { opening_id: Some(o), .. } | Primitive::Line { opening_id: Some(o), .. } | Primitive::Arc { opening_id: Some(o), .. } => o == id,
|
||||
_ => false,
|
||||
})
|
||||
}
|
||||
|
||||
fn fills_of(prims: &[Primitive], id: &str) -> Vec<String> {
|
||||
prims
|
||||
.iter()
|
||||
.filter_map(|q| match q {
|
||||
Primitive::Polygon { fill, wall_id, opening_id, .. } if opening_id.as_deref().or(wall_id.as_deref()) == Some(id) => Some(fill.clone()),
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn grundriss_je_filter() {
|
||||
let p = project(&umbau_fixture());
|
||||
let red = default_style(RenovationStatus::New).fill;
|
||||
let yellow = default_style(RenovationStatus::Demolish).fill;
|
||||
// Ohne Filter: alles wie bisher, keine Umbau-Farbe.
|
||||
let all = plan_with(&p, json!({}));
|
||||
assert!(has_wall(&all, "W2") && has_wall(&all, "W9") && has_opening(&all, "O1"));
|
||||
assert!(fills_of(&all, "W9").iter().all(|f| *f != red));
|
||||
// Bestand: neue Wand und neue Öffnung fehlen.
|
||||
let b = plan_with(&p, json!({"renovation": "bestand"}));
|
||||
assert!(has_wall(&b, "W2") && !has_wall(&b, "W9") && !has_opening(&b, "O1") && has_opening(&b, "O2"));
|
||||
// Abbruch: W2 gelb mit gestrichelten Umrissen; O1 als gelbes Abbruch-Stück in der geschlossenen Wand.
|
||||
let a = plan_with(&p, json!({"renovation": "abbruch"}));
|
||||
assert!(fills_of(&a, "W2").iter().any(|f| *f == yellow), "{:?}", fills_of(&a, "W2"));
|
||||
assert_eq!(fills_of(&a, "O1"), vec![yellow.clone()]);
|
||||
assert!(a.iter().any(|q| matches!(q, Primitive::Line { dash: Some(Some(_)), opening_id: Some(o), .. } if o == "O1")));
|
||||
// Neubau: W2 weg, W9 rot, O2 zugemauert mit roter Ausfachung, Fenster O1 in roten Linien.
|
||||
let n = plan_with(&p, json!({"renovation": "neubau"}));
|
||||
assert!(!has_wall(&n, "W2"));
|
||||
assert!(fills_of(&n, "W9").iter().any(|f| *f == red), "{:?}", fills_of(&n, "W9"));
|
||||
assert_eq!(fills_of(&n, "O2"), vec![red.clone()]);
|
||||
let line = default_style(RenovationStatus::New).line.unwrap();
|
||||
assert!(n.iter().any(|q| matches!(q, Primitive::Line { opening_id: Some(o), color: Some(c), .. } if o == "O1" && **c == *line)));
|
||||
// Umbauplan: beide Ersatzstücke, Bestand grau.
|
||||
let u = plan_with(&p, json!({"renovation": "umbauplan"}));
|
||||
assert!(fills_of(&u, "W1").iter().any(|f| *f == default_style(RenovationStatus::Existing).fill));
|
||||
assert!(fills_of(&u, "O1").contains(&yellow) && fills_of(&u, "O2").contains(&red));
|
||||
// Endzustand: ohne Farbe, W2 und O2 weg.
|
||||
let e = plan_with(&p, json!({"renovation": "endzustand"}));
|
||||
assert!(!has_wall(&e, "W2") && !has_opening(&e, "O2") && has_wall(&e, "W9"));
|
||||
assert!(fills_of(&e, "W9").iter().all(|f| *f != red));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn grundriss_filter_der_ebene_und_etappe() {
|
||||
let mut v = umbau_fixture();
|
||||
for l in v["drawingLevels"].as_array_mut().unwrap() {
|
||||
if l["id"] == "eg" {
|
||||
l["renovationFilter"] = json!("neubau");
|
||||
l["renovationPhase"] = json!("e1");
|
||||
}
|
||||
}
|
||||
let p = project(&v);
|
||||
// Filter der Ebene wirkt ohne Argument; W9 (Neu in Etappe 2) fehlt in Etappe 1 noch.
|
||||
let q = plan_with(&p, json!({}));
|
||||
assert!(!has_wall(&q, "W2") && !has_wall(&q, "W9"));
|
||||
// Angefragter Filter geht vor (ohne Etappe: alle).
|
||||
let q = plan_with(&p, json!({"renovation": "bestand"}));
|
||||
assert!(has_wall(&q, "W2") && !has_wall(&q, "W9"));
|
||||
let q = plan_with(&p, json!({"renovation": "neubau", "renovationPhase": "e2"}));
|
||||
assert!(has_wall(&q, "W9"));
|
||||
}
|
||||
|
||||
fn section_prims(p: &Project, extra: Value) -> Vec<Primitive> {
|
||||
let level = p.drawing_levels.iter().find(|l| l.id == "schnitt-a").unwrap();
|
||||
let mut v = json!({"level": level, "scale": 50, "detail": "mittel"});
|
||||
for (k, x) in extra.as_object().unwrap() {
|
||||
v[k] = x.clone();
|
||||
}
|
||||
let buf = crate::queries::run_bin(p, "sectionPlan", &[0.0, 1.0, 0.0], &v.to_string()).unwrap();
|
||||
crate::plan::buf::View::parse(&buf).and_then(|v| v.prims()).unwrap_or_default()
|
||||
}
|
||||
|
||||
fn cut_fills(prims: &[Primitive], id: &str) -> Vec<String> {
|
||||
prims
|
||||
.iter()
|
||||
.filter_map(|q| match q {
|
||||
Primitive::Polygon { fill, wall_id: Some(w), .. } if w == id => Some(fill.clone()),
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn schnitt_je_filter() {
|
||||
let p = project(&umbau_fixture());
|
||||
let all = section_prims(&p, json!({}));
|
||||
assert!(!cut_fills(&all, "W2").is_empty() && !cut_fills(&all, "W9").is_empty());
|
||||
let u = section_prims(&p, json!({"renovation": "umbauplan"}));
|
||||
assert!(!cut_fills(&u, "W2").is_empty());
|
||||
assert!(cut_fills(&u, "W2").iter().all(|f| *f == default_style(RenovationStatus::Demolish).fill), "{:?}", cut_fills(&u, "W2"));
|
||||
assert!(cut_fills(&u, "W9").iter().all(|f| *f == default_style(RenovationStatus::New).fill));
|
||||
assert!(cut_fills(&u, "W4").iter().all(|f| *f == default_style(RenovationStatus::Existing).fill));
|
||||
let n = section_prims(&p, json!({"renovation": "neubau"}));
|
||||
assert!(cut_fills(&n, "W2").is_empty() && !cut_fills(&n, "W9").is_empty());
|
||||
// Filter der Ebene.
|
||||
let mut v = umbau_fixture();
|
||||
for l in v["drawingLevels"].as_array_mut().unwrap() {
|
||||
if l["id"] == "schnitt-a" {
|
||||
l["renovationFilter"] = json!("bestand");
|
||||
}
|
||||
}
|
||||
let q = project(&v);
|
||||
let b = section_prims(&q, json!({}));
|
||||
assert!(cut_fills(&b, "W9").is_empty() && !cut_fills(&b, "W2").is_empty());
|
||||
}
|
||||
|
||||
fn elevation_prims(p: &Project, extra: Value) -> Vec<Primitive> {
|
||||
let level = p.drawing_levels.iter().find(|l| l.id == "ansicht-sued").unwrap();
|
||||
let mut v = json!({"level": level});
|
||||
for (k, x) in extra.as_object().unwrap() {
|
||||
v[k] = x.clone();
|
||||
}
|
||||
let buf = crate::queries::run_bin(p, "elevationPlan", &[0.0, 0.0, 100.0], &v.to_string()).unwrap();
|
||||
crate::plan::buf::View::parse(&buf).and_then(|v| v.prims()).unwrap_or_default()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ansicht_je_filter() {
|
||||
let p = project(&umbau_fixture());
|
||||
let grey = default_style(RenovationStatus::Existing).fill;
|
||||
let all = elevation_prims(&p, json!({}));
|
||||
assert!(!all.iter().any(|q| matches!(q, Primitive::Polygon { fill, .. } if *fill == grey)));
|
||||
let u = elevation_prims(&p, json!({"renovation": "umbauplan"}));
|
||||
assert!(u.iter().any(|q| matches!(q, Primitive::Polygon { fill, .. } if *fill == grey)), "Bestandswand W1 grau");
|
||||
// Bestand: die neue Öffnung O1 fehlt (Wand geschlossen) — weniger Linien als im Endzustand.
|
||||
let b = elevation_prims(&p, json!({"renovation": "bestand"}));
|
||||
let e = elevation_prims(&p, json!({"renovation": "endzustand"}));
|
||||
let lines = |v: &[Primitive]| v.iter().filter(|q| matches!(q, Primitive::Line { .. })).count();
|
||||
assert!(lines(&b) < lines(&e), "bestand {} endzustand {}", lines(&b), lines(&e));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kennzahlen_bestand_und_endzustand() {
|
||||
let mut v = umbau_fixture();
|
||||
// Ein neuer Raum (Anbau) zählt nur im Endzustand.
|
||||
let mut neu = v["rooms"][0].clone();
|
||||
neu["id"] = json!("R-neu");
|
||||
neu["name"] = json!("Anbau");
|
||||
neu["renovation"] = json!({"status": "new"});
|
||||
v["rooms"].as_array_mut().unwrap().push(neu);
|
||||
let p = project(&v);
|
||||
let b = crate::queries::run(&p, "kennzahlen", &[], "bestand").unwrap();
|
||||
let e = crate::queries::run(&p, "kennzahlen", &[], "endzustand").unwrap();
|
||||
assert_ne!(b, e);
|
||||
// Flächentabelle: Text als JSON oder als Filter-Id gleichwertig; der neue Raum fehlt im Bestand.
|
||||
let tb = crate::queries::run(&p, "areaTable", &[], "{\"renovation\": \"bestand\"}").unwrap();
|
||||
assert_eq!(tb, crate::queries::run(&p, "areaTable", &[], "bestand").unwrap());
|
||||
assert_ne!(tb, crate::queries::run(&p, "areaTable", &[], "endzustand").unwrap());
|
||||
assert!(crate::queries::run(&p, "renovationFilters", &[], "").unwrap().contains("umbauplan"));
|
||||
}
|
||||
|
||||
fn dxf_strings(p: &Project) -> Vec<String> {
|
||||
let a = PlanArgs::parse(1.0, r#"{"floor":"eg","show":["20","21","22","23","30","31","40"],"scale":100}"#).unwrap();
|
||||
let buf = crate::plan::domains::plan_domains_buf(p, &a).unwrap();
|
||||
let view = crate::plan::buf::View::parse(&buf).unwrap();
|
||||
let len = view.len();
|
||||
let mut parts = [crate::plan::parts::Part::new(view, 0, len).unwrap()];
|
||||
let o = crate::plan::dxf::DxfOptions { scale: 100.0, include_hatches: true, dim_cm: false, paper_layout: false, bounds: [0.0, 0.0, 10.0, 4.0], default_font: "Arial".into(), floor: "eg".into(), table_labels: String::new() };
|
||||
crate::plan::dxf::collect(&mut parts, p, &o).unwrap().strings
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dxf_ebenen_je_status() {
|
||||
let s = dxf_strings(&project(&umbau_fixture()));
|
||||
assert!(s.iter().any(|s| s.ends_with("_Abbruch")), "{:?}", s.iter().take(30).collect::<Vec<_>>());
|
||||
assert!(s.iter().any(|s| s.ends_with("_Neu")));
|
||||
// Ohne Umbau-Angaben keine Status-Ebenen.
|
||||
let q: Project = serde_json::from_str(include_str!("../tests/fixtures/sample_project.json")).unwrap();
|
||||
assert!(!dxf_strings(&q).iter().any(|s| s.ends_with("_Abbruch") || s.ends_with("_Neu")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ifc_status_und_etappe() {
|
||||
let p = project(&umbau_fixture());
|
||||
let f = crate::ifc_data::ifc_export_data(&p, &crate::ifc_data::IfcOptions::default()).unwrap();
|
||||
let (_, text) = crate::export_flat::from_bytes(&f.to_bytes()).unwrap();
|
||||
let s: Vec<&str> = text.split('\0').collect();
|
||||
for want in ["Status", "DEMOLISH", "NEW", "Dossier_Umbau", "Etappe 2"] {
|
||||
assert!(s.contains(&want), "fehlt: {want}");
|
||||
}
|
||||
let q: Project = serde_json::from_str(include_str!("../tests/fixtures/sample_project.json")).unwrap();
|
||||
let f = crate::ifc_data::ifc_export_data(&q, &crate::ifc_data::IfcOptions::default()).unwrap();
|
||||
let (_, text) = crate::export_flat::from_bytes(&f.to_bytes()).unwrap();
|
||||
assert!(!text.split('\0').any(|x| x == "DEMOLISH" || x == "Dossier_Umbau"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn drei_d_ausblenden_und_farbe() {
|
||||
let p = project(&umbau_fixture());
|
||||
let parts = |t: &str| -> Value { serde_json::from_str(&crate::queries::run(&p, "model3dParts", &[1.0, 1.0, 0.0], t).unwrap()).unwrap() };
|
||||
let all = parts("");
|
||||
let n = parts(r#"{"renovation":"neubau"}"#);
|
||||
let ids = |v: &Value| v["walls"].as_array().unwrap().iter().map(|w| w["wallId"].as_str().unwrap().to_string()).collect::<Vec<_>>();
|
||||
assert!(ids(&all).contains(&"W2".to_string()) && !ids(&n).contains(&"W2".to_string()));
|
||||
let w9 = n["walls"].as_array().unwrap().iter().find(|w| w["wallId"] == "W9").unwrap();
|
||||
let c = crate::style::hex_to_rgb(&default_style(RenovationStatus::New).fill, [0.0; 3]);
|
||||
assert!((w9["color"][0].as_f64().unwrap() - c[0]).abs() < 1e-9);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn neue_bauteile_tragen_den_zeichen_status() {
|
||||
use crate::ops::Op;
|
||||
let add = |c: &str| Op::Add { collection: c.into(), items: vec![json!({"id": "x"}), json!({"id": "y", "renovation": {"status": "existing"}})], at: None };
|
||||
let out = crate::commands::stamp_renovation(vec![add("walls"), add("drawings2d")], Some(&json!({"status": "new", "phase": "e2"})));
|
||||
match &out[0] {
|
||||
Op::Add { items, .. } => {
|
||||
assert_eq!(items[0]["renovation"], json!({"status": "new", "phase": "e2"}));
|
||||
// Eigene Angabe bleibt.
|
||||
assert_eq!(items[1]["renovation"]["status"], "existing");
|
||||
}
|
||||
_ => panic!(),
|
||||
}
|
||||
// 2D-Zeichnungen bekommen keinen Status.
|
||||
assert!(matches!(&out[1], Op::Add { items, .. } if items[0].get("renovation").is_none()));
|
||||
// Bestand ohne Etappe = ohne Feld; Unsinn wird ignoriert.
|
||||
for r in [json!({"status": "existing"}), json!({"status": "kaputt"}), json!(42), json!(null)] {
|
||||
let o = crate::commands::stamp_renovation(vec![add("walls")], Some(&r));
|
||||
assert!(matches!(&o[0], Op::Add { items, .. } if items[0].get("renovation").is_none()), "{}", r);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tusche_behaelt_umbau_farben_und_symbole_ohne_fuellung() {
|
||||
let p = project(&umbau_fixture());
|
||||
let codes: Vec<String> = (0..100).map(|k| format!("{k:02}")).collect();
|
||||
let buf = |ren: &str| {
|
||||
let t = json!({"floor": "eg", "show": codes, "scale": 100, "mono": true, "renovation": ren}).to_string();
|
||||
let b = crate::plan::domains::plan_domains_buf(&p, &PlanArgs::parse(1.0, &t).unwrap()).unwrap();
|
||||
crate::plan::buf::View::parse(&b).and_then(|v| v.prims()).unwrap_or_default()
|
||||
};
|
||||
let fills = |v: &[Primitive]| v.iter().filter_map(|q| if let Primitive::Polygon { fill, .. } = q { Some(fill.clone()) } else { None }).collect::<Vec<_>>();
|
||||
// Schwarz-Weiss (Tusche): Rot und Gelb bleiben, sonst wäre der Umbauplan stumm.
|
||||
let u = fills(&buf("umbauplan"));
|
||||
assert!(u.contains(&default_style(RenovationStatus::New).fill) && u.contains(&default_style(RenovationStatus::Demolish).fill));
|
||||
// Ohne Filter keine Umbau-Farbe (und Bunt wird wie bisher Papier).
|
||||
assert!(!fills(&buf("")).contains(&default_style(RenovationStatus::New).fill));
|
||||
// Flächen der Öffnungssymbole (Rahmen, Glas, Flügel) bleiben ohne Umbau-Füllung — nur die Ersatzstücke sind farbig.
|
||||
let n = plan_with(&p, json!({"renovation": "umbauplan"}));
|
||||
let o1: Vec<String> = n
|
||||
.iter()
|
||||
.filter_map(|q| match q {
|
||||
Primitive::Polygon { fill, opening_id: Some(o), .. } if o == "D1" => Some(fill.clone()),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert!(o1.iter().all(|f| *f != default_style(RenovationStatus::Existing).fill), "{o1:?}");
|
||||
}
|
||||
@@ -102,7 +102,7 @@ pub fn level_with_template(l: &DrawingLevel, t: &ViewTemplate) -> DrawingLevel {
|
||||
macro_rules! take {
|
||||
($($f:ident),*) => { $(if t.$f.is_some() { l.$f = t.$f.clone(); })* };
|
||||
}
|
||||
take!(cut_height, view_top, view_bottom, view_depth, shadows, hidden_lines, sketch, cut_hatch, floor_finish, show_terrain, model_view_option_id);
|
||||
take!(cut_height, view_top, view_bottom, view_depth, shadows, hidden_lines, sketch, cut_hatch, floor_finish, show_terrain, model_view_option_id, renovation_filter, renovation_phase);
|
||||
l
|
||||
}
|
||||
|
||||
@@ -140,6 +140,9 @@ pub fn viewport_args(p: &Project, snap: &ViewSnapshot, scale: f64, mono: bool) -
|
||||
// [173] Modelldarstellung des Ausschnitts (sonst die der Ebene, auch über die verknüpfte Vorlage).
|
||||
model_view: snap.model_view_option_id.clone().filter(|s| !s.is_empty()),
|
||||
trace_of: None,
|
||||
// [271] Umbaufilter des Ausschnitts (sonst der der Ebene).
|
||||
renovation: snap.renovation_filter.clone().filter(|s| !s.is_empty()),
|
||||
renovation_phase: snap.renovation_phase.clone().filter(|s| !s.is_empty()),
|
||||
};
|
||||
a.apply_model_view(p);
|
||||
a
|
||||
|
||||
@@ -239,6 +239,11 @@ fn derive_all(d: &mut Document, tag: &str, depth: Depth, fails: &mut Fails) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// [271] Umbaufilter (eingebaut, mit Etappe, Unsinn).
|
||||
for ren in [json!({"renovation": "umbauplan"}), json!({"renovation": "neubau", "renovationPhase": "x"}), json!({"renovation": "?"})] {
|
||||
let t = plan_text(&p, fl, 100.0, ren.clone());
|
||||
fails.run(|| format!("{tag} Grundriss {fl} Umbau {ren}"), || dossier_core::queries::run_bin_doc(d, "planDomains", &[1.0], &t));
|
||||
}
|
||||
if full {
|
||||
let t = plan_text(&p, fl, 100.0, json!({"mono": true, "forPrint": true, "compact": true}));
|
||||
fails.run(|| format!("{tag} Grundriss {fl} mono/Druck"), || dossier_core::queries::run_bin_doc(d, "planDomains", &[1.0], &t));
|
||||
@@ -273,6 +278,10 @@ fn derive_all(d: &mut Document, tag: &str, depth: Depth, fails: &mut Fails) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// [271] Umbaufilter im Schnitt/in der Ansicht.
|
||||
let t = if section { json!({"level": level, "scale": 100.0, "detail": "mittel", "renovation": "umbauplan"}) } else { json!({"level": level, "renovation": "abbruch"}) }.to_string();
|
||||
let args = if section { vec![0.0, 1.0, 0.0] } else { vec![0.0, 0.0, 100.0] };
|
||||
fails.run(|| format!("{tag} {kind} {} Umbau", lv.id), || dossier_core::queries::run_bin_doc(d, if section { "sectionPlan" } else { "elevationPlan" }, &args, &t));
|
||||
}
|
||||
dossier_core::model::DrawingLevelKind::Ceiling | dossier_core::model::DrawingLevelKind::Drawing if full => {
|
||||
let t = plan_text(&p, &lv.id, 100.0, json!({}));
|
||||
@@ -319,6 +328,11 @@ fn derive_all(d: &mut Document, tag: &str, depth: Depth, fails: &mut Fails) {
|
||||
("openingSchedule", vec![], ""),
|
||||
("elementSchedule", vec![], ""),
|
||||
("shadows", vec![180.0, 45.0, 2.5], ""),
|
||||
// [271] Umbaufilter: Kennzahlen/Flächen im Zustand, Filterliste, 3D mit Filter.
|
||||
("kennzahlen", vec![], "endzustand"),
|
||||
("areaTable", vec![], "{\"renovation\": \"bestand\", \"renovationPhase\": 7}"),
|
||||
("renovationFilters", vec![], ""),
|
||||
("model3dParts", vec![0.0, 1.0, 0.0, 1.0], "{\"renovation\": \"umbauplan\"}"),
|
||||
];
|
||||
if heavy {
|
||||
q.push(("pickGeometry", vec![0.0], ""));
|
||||
|
||||
+2
-1
@@ -406,7 +406,7 @@ export default function App() {
|
||||
);
|
||||
const {
|
||||
projectFileInputRef, projectTemplateFileInputRef, openImportForFile, onSaveProject, onSaveProjectAs, onRestoreBackup,
|
||||
onNewProject, onNewProjectFromSample, onNewProjectFromComplexSample, onNewProjectFromWettbewerbSample, onNewProjectFromTemplate,
|
||||
onNewProject, onNewProjectFromSample, onNewProjectFromComplexSample, onNewProjectFromWettbewerbSample, onNewProjectFromUmbauSample, onNewProjectFromTemplate,
|
||||
onProjectTemplateFileChosen, onExportIfc, onExportObj, onExportStl, onOpenProject, onProjectFileChosen,
|
||||
} = files;
|
||||
|
||||
@@ -715,6 +715,7 @@ export default function App() {
|
||||
onNewProjectFromSample,
|
||||
onNewProjectFromComplexSample,
|
||||
onNewProjectFromWettbewerbSample,
|
||||
onNewProjectFromUmbauSample,
|
||||
onNewProjectFromTemplate,
|
||||
onOpenProject,
|
||||
onSaveProject,
|
||||
|
||||
@@ -84,8 +84,9 @@ export interface Ivhb {
|
||||
}
|
||||
|
||||
/** SIA-416-Flächentabelle je Geschoss und total. */
|
||||
export function computeAreaTable(project: Project): AreaTable {
|
||||
return documentFor(project).query<AreaTable>("areaTable");
|
||||
export function computeAreaTable(project: Project, renovation = ""): AreaTable {
|
||||
// [271] `renovation`: Umbau-Zustand (Filter-Id); leer = alle Bauteile.
|
||||
return documentFor(project).query<AreaTable>("areaTable", [], renovation);
|
||||
}
|
||||
|
||||
/** IVHB-Kennziffern (GFZ, AZ, BMZ, ÜZ, GZ, Höhen). */
|
||||
|
||||
@@ -61,8 +61,9 @@ export function solidVolume(s: ExtrudedSolid): number {
|
||||
* Flächen je Geschoss (SIA 416), Gebäudevolumen, Ausnützungs- und Überbauungsziffer. Rechnet der
|
||||
* Kern auf dem Projekt-Dokument (`kennzahlen.rs`, [K4] S2).
|
||||
*/
|
||||
export function computeKennzahlen(project: Project): Kennzahlen {
|
||||
return documentFor(project).query<Kennzahlen>("kennzahlen");
|
||||
export function computeKennzahlen(project: Project, renovation = ""): Kennzahlen {
|
||||
// [271] `renovation`: Umbau-Zustand (Filter-Id, z. B. „bestand“ oder „endzustand“); leer = alle Bauteile.
|
||||
return documentFor(project).query<Kennzahlen>("kennzahlen", [], renovation);
|
||||
}
|
||||
|
||||
export type { ProgramStatus } from "./roomProgram";
|
||||
|
||||
+31
-5
@@ -19,6 +19,8 @@
|
||||
// Override-Regel ein (auch Standard-Baustein, z. B. --rule "Deckenaufbau weiss") [33];
|
||||
// das Massstab-Kriterium einer Regel (ab/bis 1:n) gilt nach --scale;
|
||||
// --model-view <Name> wählt eine Modelldarstellung (eigene Stufe oder grob/mittel/fein) [173]
|
||||
// --renovation <Filter> Umbaufilter (bestand, abbruch, neubau, umbauplan, endzustand oder eigener)
|
||||
// mit --phase <Etappe> (Name oder id); auch für axo, model3d und kennzahlen [271]
|
||||
// --hide <Code|Name,…> blendet Klassen aus (z. B. --hide "Schatten,Auto-Bemassung") [180]
|
||||
// --snapshot <Name|id> übernimmt Geschoss, Massstab, Vorlage und Sichtbarkeit eines Ausschnitts [207]
|
||||
// dossier-cli <projekt.obp> axo [--view southeast|southwest|northeast|northwest|iso|…] [--projection iso|military|military30]
|
||||
@@ -60,7 +62,8 @@
|
||||
//
|
||||
// Statt einer Datei nimmt `:beispiel` das eingebaute Demo-Haus (sampleProject), `:musterhaus-komplex` das
|
||||
// grosse Beispiel (model/sampleProjectComplex.ts; als Datei: `dossier-cli :musterhaus-komplex migrate --out mk.obp`),
|
||||
// `:wettbewerb` das Wettbewerbs-Beispiel der Kurzanleitung (model/sampleProjectWettbewerb.ts, [210]).
|
||||
// `:wettbewerb` das Wettbewerbs-Beispiel der Kurzanleitung (model/sampleProjectWettbewerb.ts, [210]), `:umbau` das
|
||||
// Umbau-Beispiel (model/sampleProjectUmbau.ts, [271]).
|
||||
//
|
||||
// WASM-Pakete (src/engine/pkg*) werden aus DOSSIER_WASM_DIR bzw. `<repo>/src/engine` gelesen.
|
||||
|
||||
@@ -141,6 +144,8 @@ import {
|
||||
generateSectionPlan,
|
||||
viewportLevelPlan,
|
||||
generateAxoPlan,
|
||||
renovationFilterList,
|
||||
buildUmbauSampleProject,
|
||||
type AxoOptions,
|
||||
planToRenderScene,
|
||||
projectToModel3d,
|
||||
@@ -252,6 +257,7 @@ function loadProject(path: string, args: Args): Project {
|
||||
if (path === ":beispiel") return sampleProject;
|
||||
if (path === ":musterhaus-komplex") return buildComplexSampleProject();
|
||||
if (path === ":wettbewerb") return buildWettbewerbSampleProject();
|
||||
if (path === ":umbau") return buildUmbauSampleProject();
|
||||
if (path === ":gross") return buildBigSampleProject({ floors: Number(args.flags.get("floors") ?? 8), apartments: Number(args.flags.get("apartments") ?? 15) });
|
||||
let text: string;
|
||||
try {
|
||||
@@ -364,9 +370,28 @@ function withTemplate(project: Project, levelId: string, tpl: ViewTemplate | und
|
||||
if (!mv) fail(`Modelldarstellung nicht gefunden: ${mName} (vorhanden: grob, mittel, fein${(p.modelViewOptions ?? []).map((m) => `, ${m.name}`).join("")})`);
|
||||
p = { ...p, drawingLevels: p.drawingLevels.map((l) => (l.id === levelId ? { ...l, modelViewOptionId: mv } : l)) };
|
||||
}
|
||||
// [271] `--renovation <Filter>` (und `--phase <Etappe>`): Umbaufilter der Ebene; geht der Vorlage vor.
|
||||
const ren = renovationFlags(p, args);
|
||||
if (ren) p = { ...p, drawingLevels: p.drawingLevels.map((l) => (l.id === levelId ? { ...l, renovationFilter: ren.renovation, renovationPhase: ren.renovationPhase } : l)) };
|
||||
return p;
|
||||
}
|
||||
|
||||
/** [271] `--renovation <Filter>` und `--phase <Etappe>` geprüft (Filter-Id oder Name; Etappe Name oder id); ohne Flag `null`. */
|
||||
function renovationFlags(project: Project, args: Args): { renovation: string; renovationPhase?: string } | null {
|
||||
const name = args.flags.get("renovation");
|
||||
if (!name || name === "true") return null;
|
||||
const filters = renovationFilterList(project);
|
||||
const n = name.toLowerCase();
|
||||
const hit = filters.find((f) => f.id.toLowerCase() === n || f.name.toLowerCase() === n);
|
||||
if (!hit) fail(`Umbaufilter nicht gefunden: ${name} (vorhanden: ${filters.map((f) => f.name).join(", ")})`);
|
||||
const ph = args.flags.get("phase");
|
||||
if (!ph || ph === "true") return { renovation: hit.id };
|
||||
const phases = project.renovation?.phases ?? [];
|
||||
const p = phases.find((x) => x.id === ph || x.name.toLowerCase() === ph.toLowerCase());
|
||||
if (!p) fail(`Etappe nicht gefunden: ${ph} (vorhanden: ${phases.map((x) => x.name).join(", ") || "keine"})`);
|
||||
return { renovation: hit.id, renovationPhase: p.id };
|
||||
}
|
||||
|
||||
/** `--sketch` ([67]): die Ebene im Skizzenstil (wie `DrawingLevel.sketch`); sonst das Projekt unverändert. */
|
||||
function withSketch(project: Project, levelId: string, args: Args): Project {
|
||||
if (!args.flags.has("sketch")) return project;
|
||||
@@ -606,7 +631,7 @@ function importParsedDrawing(base: Project, parsed: ReturnType<typeof parseDxf>,
|
||||
/** Liest Eingabe nach Endung in ein Projekt: obp direkt, dxf/dwg als 2D-Zeichnung + Meshes, ifc als Kontext-Meshes (`--elements`: Bauteile). */
|
||||
async function importAny(path: string, args: Args): Promise<Project> {
|
||||
const ext = extOf(path);
|
||||
if (ext === "obp" || ext === "json" || path === ":beispiel" || path === ":musterhaus-komplex" || path === ":wettbewerb") return loadProject(path, args);
|
||||
if (ext === "obp" || ext === "json" || path === ":beispiel" || path === ":musterhaus-komplex" || path === ":wettbewerb" || path === ":umbau") return loadProject(path, args);
|
||||
let bytes: Uint8Array;
|
||||
try {
|
||||
bytes = new Uint8Array(readFileSync(path));
|
||||
@@ -1208,7 +1233,7 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
if (on("context")) opts.context = true;
|
||||
const mono = f.has("color") ? inkArg(args) : true;
|
||||
const t0 = Date.now();
|
||||
const plan = generateAxoPlan(project, { ...opts, visibleCodes: codes, scaleDenominator: axScale, mono });
|
||||
const plan = generateAxoPlan(project, { ...opts, ...(renovationFlags(project, args) ?? {}), visibleCodes: codes, scaleDenominator: axScale, mono });
|
||||
if (!plan) fail("kein 3D-Dokument (keine sichtbaren Bauteile oder unbrauchbare Kamera)");
|
||||
if (f.has("time")) process.stderr.write(`axo: ${Date.now() - t0} ms, ${plan.primitives.length} Primitive\n`);
|
||||
const name = `axo-${opts.view ?? opts.cameraId ?? "kamera"}`;
|
||||
@@ -1307,7 +1332,8 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
else throw new Error("--format: json, csv, svg oder pdf");
|
||||
return 0;
|
||||
}
|
||||
const k = computeKennzahlen(project);
|
||||
// [271] `--renovation bestand|endzustand`: Kennzahlen im Umbau-Zustand.
|
||||
const k = computeKennzahlen(project, renovationFlags(project, args)?.renovation ?? "");
|
||||
const prog = checkRoomProgram(project);
|
||||
const baurecht = checkSiteRules(project);
|
||||
// [68] Erdarbeiten je Baugrube (Abtrag/Auftrag/Hinterfüllung, m³).
|
||||
@@ -1492,7 +1518,7 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
const filter: Filter3d = { hide: hideFlagCodes(project, args), grey: hideFlagCodes(project, args, "grey"), greyFloors: greyFloorIds(project, args) };
|
||||
const ghost = ghostFilter3d(filter);
|
||||
const model = {
|
||||
...projectToModel3d(project, { explode, hide: filter }),
|
||||
...projectToModel3d(project, { explode, hide: filter, ...(renovationFlags(project, args) ?? {}) }),
|
||||
// Flächenmuster ([100]) des Modells (render_png zeichnet sie in den Kanten-Stilen).
|
||||
patternLines: Array.from(emitSurfacePatternLines(project, explode, filter)),
|
||||
// [212] Materialtabelle des Pathtracers (render_png `--style pathtrace`).
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// [271] Befehl „Umbau-Status setzen …“: Optionen B/A/N, Mehrfachauswahl in einem Schritt, ohne Auswahl kein Start.
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { renovationCommand, renovationSelectionIds } from "./renovation";
|
||||
import type { CommandContext } from "../types";
|
||||
import { sampleProject } from "../../model/sampleProject";
|
||||
import { applyOps } from "../../core/ops";
|
||||
|
||||
function ctx(sel: Partial<CommandContext["selection"]>): CommandContext {
|
||||
return {
|
||||
project: sampleProject,
|
||||
level: sampleProject.drawingLevels[0],
|
||||
defaultCategoryCode: "20",
|
||||
activeLineStyleId: "solid",
|
||||
activeWallTypeId: "aw",
|
||||
lastPoint: null,
|
||||
selection: { wallIds: [], drawingId: null, ...sel },
|
||||
};
|
||||
}
|
||||
|
||||
describe("[271] renovation", () => {
|
||||
it("ohne Auswahl: Hinweis statt Start", () => {
|
||||
expect(renovationCommand.precondition?.(ctx({}))).toBe("cmd.renovation.needsSelection");
|
||||
expect(renovationCommand.precondition?.(ctx({ wallIds: ["W1"] }))).toBeNull();
|
||||
});
|
||||
|
||||
it("Option „Abbruch“ setzt den Status aller gewählten Bauteile in einem Schritt", () => {
|
||||
const c = ctx({ wallIds: ["W9"], openingIds: ["O2"], ceilingIds: ["C1"] });
|
||||
expect(renovationSelectionIds(c.selection)).toEqual(["W9", "O2", "C1"]);
|
||||
expect(renovationCommand.options(renovationCommand.init()).map((o) => o.id)).toEqual(["existing", "demolish", "new"]);
|
||||
const [, res] = renovationCommand.onInput(renovationCommand.init(), { kind: "option", id: "demolish" }, c);
|
||||
expect(res.done).toBe(true);
|
||||
const ops = res.commit!.toOps(sampleProject);
|
||||
expect(ops).toHaveLength(3);
|
||||
const p = applyOps(sampleProject, ops);
|
||||
expect(p.walls.find((w) => w.id === "W9")?.renovation?.status).toBe("demolish");
|
||||
expect(p.openings?.find((o) => o.id === "O2")?.renovation?.status).toBe("demolish");
|
||||
});
|
||||
|
||||
it("getippt: Kürzel N; Unsinn bleibt im Schritt", () => {
|
||||
const c = ctx({ wallIds: ["W1"] });
|
||||
const [, bad] = renovationCommand.onInput(renovationCommand.init(), { kind: "text", text: "xyz" }, c);
|
||||
expect(bad.done).toBeFalsy();
|
||||
const [, res] = renovationCommand.onInput(renovationCommand.init(), { kind: "text", text: "n" }, c);
|
||||
const p = applyOps(sampleProject, res.commit!.toOps(sampleProject));
|
||||
expect(p.walls.find((w) => w.id === "W1")?.renovation).toEqual({ status: "new" });
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
// [271] Befehl „Umbau-Status setzen …“ (`renovation`, Kürzel `umbau`): setzt den Umbau-Status der gewählten Bauteile —
|
||||
// Bestand, Abbruch oder Neu (Optionen B/A/N) — in einem Undo-Schritt. Die Etappe bleibt; sie stellt die Objekt-Info ein.
|
||||
// Ohne Auswahl startet der Befehl nicht (Hinweis).
|
||||
|
||||
import { opsMutation, setRenovationOps } from "../../core";
|
||||
import type { RenovationStatus } from "../../model/types";
|
||||
import type { CmdOption, Command, CommandContext, CommandResult, CommandSelection, CommandState } from "../types";
|
||||
|
||||
/** Gewählte Bauteile mit Umbau-Status (Wände, Öffnungen, Decken, Dächer, Treppen, Räume, Stütze, Körper). */
|
||||
export function renovationSelectionIds(sel: CommandSelection): string[] {
|
||||
return [
|
||||
...sel.wallIds,
|
||||
...(sel.openingIds ?? []),
|
||||
...(sel.ceilingIds ?? []),
|
||||
...(sel.roofIds ?? []),
|
||||
...(sel.stairIds ?? []),
|
||||
...(sel.roomIds ?? []),
|
||||
...(sel.columnId ? [sel.columnId] : []),
|
||||
...(sel.extrudedSolidId ? [sel.extrudedSolidId] : []),
|
||||
];
|
||||
}
|
||||
|
||||
const STATUS_OPTIONS: Array<{ id: RenovationStatus; key: string; labelKey: CmdOption["labelKey"] }> = [
|
||||
{ id: "existing", key: "B", labelKey: "renovation.status.existing" },
|
||||
{ id: "demolish", key: "A", labelKey: "renovation.status.demolish" },
|
||||
{ id: "new", key: "N", labelKey: "renovation.status.new" },
|
||||
];
|
||||
|
||||
const idle = (): CommandState => ({ phase: "pick", lastPoint: null });
|
||||
const done = (commit?: CommandResult["commit"]): [CommandState, CommandResult] => [idle(), { draft: null, done: true, ...(commit ? { commit } : {}) }];
|
||||
|
||||
export const renovationCommand: Command = {
|
||||
name: "renovation",
|
||||
labelKey: "cmd.renovation.label",
|
||||
prompt: () => "cmd.renovation.prompt",
|
||||
accepts: () => ["option"],
|
||||
options: () => STATUS_OPTIONS.map((o) => ({ id: o.id, labelKey: o.labelKey, key: o.key })),
|
||||
precondition: (ctx: CommandContext) => (renovationSelectionIds(ctx.selection).length === 0 ? "cmd.renovation.needsSelection" : null),
|
||||
init: idle,
|
||||
|
||||
onInput: (state, input, ctx): [CommandState, CommandResult] => {
|
||||
const id = input.kind === "option" ? input.id : input.kind === "text" ? input.text.trim().toLowerCase() : "";
|
||||
const hit = STATUS_OPTIONS.find((o) => o.id === id || o.key.toLowerCase() === id);
|
||||
if (!hit) return [state, { draft: null }];
|
||||
const ids = renovationSelectionIds(ctx.selection);
|
||||
if (ids.length === 0) return done();
|
||||
return done(opsMutation((p) => setRenovationOps(p, ids, hit.id)));
|
||||
},
|
||||
onMove: (state): [CommandState, CommandResult] => [state, { draft: null }],
|
||||
onConfirm: (): [CommandState, CommandResult] => done(),
|
||||
onCancel: (): [CommandState, CommandResult] => done(),
|
||||
};
|
||||
@@ -479,7 +479,8 @@ export class CommandEngine {
|
||||
if (accepts.includes("option")) {
|
||||
const opts = this.command.options(this.state);
|
||||
const q = text.toLowerCase();
|
||||
const hit = opts.find((o) => o.id.toLowerCase().startsWith(q));
|
||||
// [271] Sonst das Kürzel der Option (z. B. „A“ für Abbruch bei der Id `demolish`), getippt mit Enter.
|
||||
const hit = opts.find((o) => o.id.toLowerCase().startsWith(q)) ?? opts.find((o) => o.key?.toLowerCase() === q);
|
||||
if (hit) {
|
||||
this.feed({ kind: "option", id: hit.id });
|
||||
return;
|
||||
|
||||
@@ -47,6 +47,7 @@ import { textboxCommand } from "./cmds/textbox";
|
||||
import { mirrorCommand, moveCommand, rotateCommand } from "./cmds/transform";
|
||||
import { scaleCommand } from "./cmds/scale";
|
||||
import { explodeCommand } from "./cmds/explode";
|
||||
import { renovationCommand } from "./cmds/renovation";
|
||||
import { dimdetachCommand } from "./cmds/dimdetach";
|
||||
import { autodimCommand } from "./cmds/autodim";
|
||||
import { gridCommand } from "./cmds/grid";
|
||||
@@ -132,6 +133,7 @@ export const COMMANDS: Record<string, Command> = {
|
||||
rotate: rotateCommand,
|
||||
scale: scaleCommand,
|
||||
explode: explodeCommand,
|
||||
renovation: renovationCommand,
|
||||
dimdetach: dimdetachCommand,
|
||||
autodim: autodimCommand,
|
||||
grid: gridCommand,
|
||||
@@ -283,6 +285,7 @@ export const ALIASES: Record<string, string> = {
|
||||
skalieren: "scale",
|
||||
x: "explode",
|
||||
aufloesen: "explode",
|
||||
umbau: "renovation",
|
||||
bml: "dimdetach",
|
||||
bemassungloesen: "dimdetach",
|
||||
ab: "autodim",
|
||||
|
||||
@@ -181,6 +181,7 @@ export type QueryName =
|
||||
| "presentationSheet"
|
||||
| "kennzahlen"
|
||||
| "areaTable"
|
||||
| "renovationFilters"
|
||||
| "costEstimate"
|
||||
| "costDefaults"
|
||||
| "programCompare"
|
||||
|
||||
@@ -120,3 +120,10 @@ export type { CyclesHost, CyclesPackage, CyclesSceneInfo, CyclesSceneOptions, Cy
|
||||
export { computeCostEstimate, defaultCostEstimate, formatChf } from "../analysis/costEstimate";
|
||||
export type { CostResult, CostRow, CostQuantities, CostEstimate, CostGroup, CostMethod, CostBasis } from "../analysis/costEstimate";
|
||||
export { buildCostReport, costGroupLabel, costUnitLabel } from "../export/costReport";
|
||||
// [271] Umbau: Status je Bauteil, Etappen, Umbaufilter (Regeln im Kern `renovation.rs`)
|
||||
export {
|
||||
BUILTIN_RENOVATION_FILTERS, RENOVATION_STATUSES, RENOVATION_COLLECTIONS, DEFAULT_RENOVATION_STYLES, renovationFilterList, renovationStatus, renovationPhases,
|
||||
renovationForNew, setRenovationOps, renovatableIds, commonRenovation, setPhasesOps, newPhaseId,
|
||||
} from "../model/renovation";
|
||||
export type { RenovationFilterEntry, RenovationCollection } from "../model/renovation";
|
||||
export { buildUmbauSampleProject } from "../model/sampleProjectUmbau";
|
||||
@@ -4680,6 +4680,49 @@ export const de = {
|
||||
"preview.tip": "Noch nicht fertig — Ergebnisse können abweichen",
|
||||
"settings.update.onStart": "Beim Start nach Updates suchen",
|
||||
"settings.update.onStart.hint": "Aus: Dossier nimmt von sich aus keinen Kontakt zum Update-Server auf (Datenschutz). «Nach Updates suchen» und der Versionsverlauf (beim Öffnen dieses Reiters) fragen nur auf deinen Klick bzw. Reiterwechsel.",
|
||||
// [271] Umbau
|
||||
"renovation.label": "Umbau",
|
||||
"renovation.title": "Umbau",
|
||||
"renovation.mixed": "gemischt",
|
||||
"renovation.status.existing": "Bestand",
|
||||
"renovation.status.demolish": "Abbruch",
|
||||
"renovation.status.new": "Neu",
|
||||
"renovation.phase": "Etappe",
|
||||
"renovation.phase.none": "ohne Etappe",
|
||||
"renovation.phase.all": "alle Etappen",
|
||||
"renovation.filter": "Umbaufilter",
|
||||
"renovation.filter.none": "kein Filter",
|
||||
"renovation.filter.bestand": "Bestand",
|
||||
"renovation.filter.abbruch": "Abbruch",
|
||||
"renovation.filter.neubau": "Neubau",
|
||||
"renovation.filter.umbauplan": "Umbauplan",
|
||||
"renovation.filter.endzustand": "Endzustand",
|
||||
"renovation.short": "Umbau: {status}",
|
||||
"renovation.status.hint": "Neue Bauteile: {status} · Umbaufilter dieser Ansicht: {filter}",
|
||||
"renovation.drawStatus": "Neue Bauteile zeichnen als",
|
||||
"renovation.filterPhase": "Filter bis Etappe",
|
||||
"renovation.state": "Zustand",
|
||||
"renovation.state.all": "alle Bauteile",
|
||||
"renovation.phases.title": "Etappen",
|
||||
"renovation.phases.hint": "Reihenfolge der Bau- und Abbruch-Etappen. Ein Umbaufilter „bis Etappe n“ zeigt Neues früherer Etappen als Bestand und lässt Abbruch früherer Etappen weg.",
|
||||
"renovation.phases.empty": "Keine Etappen: alle Bauteile gehören zur ersten.",
|
||||
"renovation.phases.up": "Nach oben",
|
||||
"renovation.phases.down": "Nach unten",
|
||||
"renovation.phases.remove": "Etappe entfernen",
|
||||
"renovation.phases.add": "Etappe hinzufügen",
|
||||
"renovation.phases.defaultName": "Etappe {n}",
|
||||
"renovation.styles.title": "Umbau-Farben",
|
||||
"renovation.styles.hint": "Vorgabe nach SIA 400: Bestand grau, Abbruch gelb und gestrichelt, Neu rot. Gilt in Grundriss, Schnitt, Ansicht und 3D, wo der Umbaufilter einen Status farbig zeigt.",
|
||||
"renovation.styles.fill": "Füllung",
|
||||
"renovation.styles.line": "Linie",
|
||||
"renovation.styles.dashed": "gestrichelt",
|
||||
"renovation.styles.reset": "Vorgabe",
|
||||
"resources.tab.renovation": "Umbau",
|
||||
"file.newFromUmbauSample": "Neu aus Vorlage: Beispiel Umbau",
|
||||
"menu.native.newFromUmbauSample": "Beispiel Umbau",
|
||||
"cmd.renovation.label": "Umbau-Status setzen …",
|
||||
"cmd.renovation.prompt": "Umbau-Status der Auswahl",
|
||||
"cmd.renovation.needsSelection": "Zuerst Bauteile wählen, dann den Umbau-Status setzen.",
|
||||
} as const;
|
||||
|
||||
export type TranslationKey = keyof typeof de;
|
||||
@@ -4666,4 +4666,47 @@ export const en: Record<TranslationKey, string> = {
|
||||
"preview.tip": "Not finished yet — results may differ",
|
||||
"settings.update.onStart": "Check for updates on startup",
|
||||
"settings.update.onStart.hint": "Off: Dossier does not contact the update server on its own (privacy). “Check for updates” and the version history (loaded when you open this tab) only ask when you click or open the tab.",
|
||||
// [271] Umbau
|
||||
"renovation.label": "Renovation",
|
||||
"renovation.title": "Renovation",
|
||||
"renovation.mixed": "mixed",
|
||||
"renovation.status.existing": "Existing",
|
||||
"renovation.status.demolish": "To be demolished",
|
||||
"renovation.status.new": "New",
|
||||
"renovation.phase": "Phase",
|
||||
"renovation.phase.none": "no phase",
|
||||
"renovation.phase.all": "all phases",
|
||||
"renovation.filter": "Renovation filter",
|
||||
"renovation.filter.none": "no filter",
|
||||
"renovation.filter.bestand": "Existing",
|
||||
"renovation.filter.abbruch": "Demolition",
|
||||
"renovation.filter.neubau": "New construction",
|
||||
"renovation.filter.umbauplan": "Renovation plan",
|
||||
"renovation.filter.endzustand": "Final state",
|
||||
"renovation.short": "Renovation: {status}",
|
||||
"renovation.status.hint": "New elements: {status} · Renovation filter of this view: {filter}",
|
||||
"renovation.drawStatus": "Draw new elements as",
|
||||
"renovation.filterPhase": "Filter up to phase",
|
||||
"renovation.state": "State",
|
||||
"renovation.state.all": "all elements",
|
||||
"renovation.phases.title": "Phases",
|
||||
"renovation.phases.hint": "Order of construction and demolition phases. A renovation filter “up to phase n” shows new elements of earlier phases as existing and leaves out demolition of earlier phases.",
|
||||
"renovation.phases.empty": "No phases: all elements belong to the first.",
|
||||
"renovation.phases.up": "Move up",
|
||||
"renovation.phases.down": "Move down",
|
||||
"renovation.phases.remove": "Remove phase",
|
||||
"renovation.phases.add": "Add phase",
|
||||
"renovation.phases.defaultName": "Phase {n}",
|
||||
"renovation.styles.title": "Renovation colors",
|
||||
"renovation.styles.hint": "Default per SIA 400: existing grey, demolition yellow and dashed, new red. Applies in plan, section, elevation and 3D wherever the renovation filter shows a status in color.",
|
||||
"renovation.styles.fill": "Fill",
|
||||
"renovation.styles.line": "Line",
|
||||
"renovation.styles.dashed": "dashed",
|
||||
"renovation.styles.reset": "Default",
|
||||
"resources.tab.renovation": "Renovation",
|
||||
"file.newFromUmbauSample": "New From Template: Renovation Example",
|
||||
"menu.native.newFromUmbauSample": "Renovation Example",
|
||||
"cmd.renovation.label": "Set renovation status …",
|
||||
"cmd.renovation.prompt": "Renovation status of the selection",
|
||||
"cmd.renovation.needsSelection": "Select elements first, then set the renovation status.",
|
||||
};
|
||||
@@ -0,0 +1,77 @@
|
||||
// [271] Umbau: Ops zum Setzen von Status/Etappe, gemeinsame Werte bei Mehrfachauswahl, Etappen-Liste, Kern-Abfragen am
|
||||
// Umbau-Beispiel (Grundriss je Filter, Kennzahlen Bestand/Endzustand, neue Bauteile mit Zeichen-Status).
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { applyOps } from "../core/ops";
|
||||
import { documentFor } from "../core/document";
|
||||
import { commonRenovation, renovationFilterList, renovationForNew, setPhasesOps, setRenovationOps } from "./renovation";
|
||||
import { buildUmbauSampleProject } from "./sampleProjectUmbau";
|
||||
import { sampleProject } from "./sampleProject";
|
||||
import { generatePlan } from "../plan/generatePlan";
|
||||
import { computeKennzahlen } from "../analysis/kennzahlen";
|
||||
import { computeAreaTable } from "../analysis/areaTable";
|
||||
import type { Project } from "./types";
|
||||
|
||||
const ALL = new Set(["20", "21", "30", "31", "40", "60"]);
|
||||
|
||||
function fills(p: Project, filter?: string): string[] {
|
||||
const q = filter ? { ...p, drawingLevels: p.drawingLevels.map((l) => (l.id === "eg" ? { ...l, renovationFilter: filter } : l)) } : p;
|
||||
return generatePlan(q, "eg", ALL).primitives.flatMap((x) => (x.kind === "polygon" ? [x.fill] : []));
|
||||
}
|
||||
|
||||
describe("[271] Umbau", () => {
|
||||
it("Status und Etappe setzen: ein Op je geändertem Element, Bestand ohne Etappe entfernt das Feld", () => {
|
||||
const p = sampleProject;
|
||||
const ops = setRenovationOps(p, ["W1", "W9", "O1", "nix"], "new", "e1");
|
||||
expect(ops).toHaveLength(3);
|
||||
const q = applyOps(p, ops);
|
||||
expect(q.walls.find((w) => w.id === "W1")?.renovation).toEqual({ status: "new", phase: "e1" });
|
||||
expect(commonRenovation(q, ["W1", "W9"])).toEqual({ status: "new", phase: "e1" });
|
||||
expect(commonRenovation(q, ["W1", "W2"]).status).toBe("mixed");
|
||||
// Nur den Status ändern: Etappe bleibt.
|
||||
const r = applyOps(q, setRenovationOps(q, ["W1"], "demolish"));
|
||||
expect(r.walls.find((w) => w.id === "W1")?.renovation).toEqual({ status: "demolish", phase: "e1" });
|
||||
// Zurück auf Bestand ohne Etappe: Feld weg.
|
||||
const s = applyOps(r, setRenovationOps(r, ["W1"], "existing", null));
|
||||
expect(s.walls.find((w) => w.id === "W1")).not.toHaveProperty("renovation");
|
||||
// Nichts zu ändern: keine Op (kein leerer Undo-Schritt).
|
||||
expect(setRenovationOps(s, ["W1"], "existing", null)).toHaveLength(0);
|
||||
expect(renovationForNew("existing")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("Etappe entfernen: Elemente verlieren sie, Status bleibt", () => {
|
||||
const p = buildUmbauSampleProject();
|
||||
const q = applyOps(p, setPhasesOps(p, [{ id: "etappe-1", name: "Etappe 1" }]));
|
||||
expect(q.renovation?.phases).toHaveLength(1);
|
||||
expect(q.walls.find((w) => w.id === "W10")?.renovation).toEqual({ status: "new" });
|
||||
expect(q.walls.find((w) => w.id === "W9")?.renovation).toEqual({ status: "demolish", phase: "etappe-1" });
|
||||
});
|
||||
|
||||
it("Kern: Filterliste, Grundriss je Filter, Kennzahlen Bestand vs. Endzustand", () => {
|
||||
const p = buildUmbauSampleProject();
|
||||
expect(renovationFilterList(p).map((f) => f.id)).toEqual(["bestand", "abbruch", "neubau", "umbauplan", "endzustand"]);
|
||||
// Ohne Filter keine Umbau-Farben; Umbauplan grau, gelb und rot.
|
||||
expect(fills(p)).not.toContain("#e3001b");
|
||||
const u = fills(p, "umbauplan");
|
||||
for (const c of ["#a6a6a6", "#ffd800", "#e3001b"]) expect(u).toContain(c);
|
||||
// Neubau: kein Gelb (Abbruch weg), Rot da.
|
||||
const n = fills(p, "neubau");
|
||||
expect(n).not.toContain("#ffd800");
|
||||
expect(n).toContain("#e3001b");
|
||||
// Kennzahlen: der Anbau zählt nur im Endzustand.
|
||||
const b = computeKennzahlen(p, "bestand");
|
||||
const e = computeKennzahlen(p, "endzustand");
|
||||
expect(e.gf).toBeGreaterThan(b.gf);
|
||||
expect(computeAreaTable(p, "bestand")).not.toEqual(computeAreaTable(p, "endzustand"));
|
||||
});
|
||||
|
||||
it("Zeichen-Status: der Kern gibt ihn neuen Bauteilen eines Zeichenbefehls", () => {
|
||||
const p = sampleProject;
|
||||
const doc = documentFor(p);
|
||||
const req = { cmd: "column", ctx: { level: "eg", cat: "50" }, stamp: "t271", at: { x: 1, y: 1 } };
|
||||
const added = (r: object) => doc.cmdOps(r).flatMap((o) => (o.kind === "add" ? (o.items as unknown as Array<{ renovation?: unknown }>) : []));
|
||||
expect(added({ ...req, renovation: { status: "new", phase: "e2" } })[0].renovation).toEqual({ status: "new", phase: "e2" });
|
||||
// Vorgabe Bestand: ohne Feld.
|
||||
expect(added(req)[0]).not.toHaveProperty("renovation");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,147 @@
|
||||
// [271] Umbau (Archicad „Renovation“): Status je Bauteil, Etappen, Umbaufilter. Die Regeln („sichtbar/wie gezeichnet im
|
||||
// Filter F“) stehen im Kern (`src-tauri/core/src/renovation.rs`); hier nur, was die Oberfläche zum Lesen und Setzen braucht.
|
||||
|
||||
import type { CoreOp } from "../core/ops";
|
||||
import { documentFor } from "../core/document";
|
||||
import { patchItems, setField } from "../core/opsBuild";
|
||||
import type { Project, Renovation, RenovationPhase, RenovationStatus } from "./types";
|
||||
|
||||
/** Eingebaute Umbaufilter (Ids; Namen über `t("renovation.filter.<id>")`). */
|
||||
export const BUILTIN_RENOVATION_FILTERS = ["bestand", "abbruch", "neubau", "umbauplan", "endzustand"] as const;
|
||||
|
||||
/** Status in der Reihenfolge der Oberfläche. */
|
||||
export const RENOVATION_STATUSES: readonly RenovationStatus[] = ["existing", "demolish", "new"];
|
||||
|
||||
/** Listen mit Umbau-Status (Räume nur Sichtbarkeit/Flächen, keine Farbe). */
|
||||
export const RENOVATION_COLLECTIONS = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms"] as const;
|
||||
export type RenovationCollection = (typeof RENOVATION_COLLECTIONS)[number];
|
||||
|
||||
/** SIA-400-Vorgabe der Umbau-Farben (gleich wie `renovation::default_style` im Kern). */
|
||||
export const DEFAULT_RENOVATION_STYLES: Record<RenovationStatus, { fill: string; line?: string; dashed: boolean }> = {
|
||||
existing: { fill: "#a6a6a6", dashed: false },
|
||||
demolish: { fill: "#ffd800", dashed: true },
|
||||
new: { fill: "#e3001b", line: "#c00016", dashed: false },
|
||||
};
|
||||
|
||||
export interface RenovationFilterEntry {
|
||||
id: string;
|
||||
name: string;
|
||||
builtin: boolean;
|
||||
}
|
||||
|
||||
/** Eingebaute und eigene Umbaufilter (Kern-Abfrage `renovationFilters`). */
|
||||
export function renovationFilterList(project: Project): RenovationFilterEntry[] {
|
||||
return documentFor(project).query<RenovationFilterEntry[]>("renovationFilters");
|
||||
}
|
||||
|
||||
/** Status eines Elements (fehlt/unbekannt ⇒ Bestand). */
|
||||
export function renovationStatus(r: Renovation | undefined | null): RenovationStatus {
|
||||
return r?.status === "demolish" || r?.status === "new" ? r.status : "existing";
|
||||
}
|
||||
|
||||
/** Etappen des Projekts in ihrer Reihenfolge. */
|
||||
export function renovationPhases(project: Project): readonly RenovationPhase[] {
|
||||
return project.renovation?.phases ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Umbau-Angaben für ein neues Element nach dem aktuellen Zeichen-Status: Bestand (Vorgabe) ohne Feld, sonst Status
|
||||
* und Etappe.
|
||||
*/
|
||||
export function renovationForNew(status: RenovationStatus, phase?: string | null): Renovation | undefined {
|
||||
if (status === "existing" && !phase) return undefined;
|
||||
return phase ? { status, phase } : { status };
|
||||
}
|
||||
|
||||
/**
|
||||
* Ops: Status (und Etappe) für alle Elemente mit id in `ids` setzen (ein Undo-Schritt, wenn zusammen angewandt).
|
||||
* `phase`: `undefined` = Etappe unverändert, `null` = keine Etappe. Bestand ohne Etappe entfernt das Feld.
|
||||
*/
|
||||
export function setRenovationOps(project: Project, ids: Iterable<string>, status: RenovationStatus | undefined, phase?: string | null): CoreOp[] {
|
||||
const set = new Set(ids);
|
||||
const ops: CoreOp[] = [];
|
||||
for (const c of RENOVATION_COLLECTIONS) {
|
||||
ops.push(
|
||||
...patchItems(project, c, set, (e) => {
|
||||
const old = (e as { renovation?: Renovation }).renovation;
|
||||
const st = status ?? renovationStatus(old);
|
||||
const ph = phase === undefined ? old?.phase : phase ?? undefined;
|
||||
const next = renovationForNew(st, ph);
|
||||
const { renovation: _drop, ...rest } = e as { renovation?: Renovation } & Record<string, unknown>;
|
||||
void _drop;
|
||||
return (next ? { ...rest, renovation: next } : rest) as unknown as typeof e;
|
||||
}),
|
||||
);
|
||||
}
|
||||
return ops;
|
||||
}
|
||||
|
||||
/** Element-Ids der Auswahl, die einen Umbau-Status tragen können. */
|
||||
export function renovatableIds(project: Project, ids: Iterable<string>): string[] {
|
||||
const set = new Set(ids);
|
||||
const out: string[] = [];
|
||||
for (const c of RENOVATION_COLLECTIONS) {
|
||||
for (const e of (project[c] ?? []) as { id: string }[]) if (set.has(e.id)) out.push(e.id);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Gemeinsamer Status bzw. gemeinsame Etappe der Elemente `ids` (`"mixed"` bei verschiedenen Werten, `null` ohne Elemente). */
|
||||
export function commonRenovation(project: Project, ids: Iterable<string>): { status: RenovationStatus | "mixed" | null; phase: string | "mixed" | null } {
|
||||
const set = new Set(ids);
|
||||
let status: RenovationStatus | "mixed" | null = null;
|
||||
let phase: string | "mixed" | null = null;
|
||||
let first = true;
|
||||
for (const c of RENOVATION_COLLECTIONS) {
|
||||
for (const e of (project[c] ?? []) as { id: string; renovation?: Renovation }[]) {
|
||||
if (!set.has(e.id)) continue;
|
||||
const s = renovationStatus(e.renovation);
|
||||
const ph = e.renovation?.phase ?? "";
|
||||
if (first) {
|
||||
status = s;
|
||||
phase = ph;
|
||||
first = false;
|
||||
} else {
|
||||
if (status !== s) status = "mixed";
|
||||
if (phase !== ph) phase = "mixed";
|
||||
}
|
||||
}
|
||||
}
|
||||
return { status, phase };
|
||||
}
|
||||
|
||||
/** Ops: Etappen-Liste ersetzen (Namen, Reihenfolge); Elemente mit einer entfernten Etappe verlieren sie. */
|
||||
export function setPhasesOps(project: Project, phases: readonly RenovationPhase[]): CoreOp[] {
|
||||
const keep = new Set(phases.map((p) => p.id));
|
||||
const settings = { ...(project.renovation ?? {}), phases: phases.length ? [...phases] : undefined };
|
||||
if (!settings.phases) delete settings.phases;
|
||||
const ops: CoreOp[] = [setField("renovation", Object.keys(settings).length ? settings : undefined)];
|
||||
for (const c of RENOVATION_COLLECTIONS) {
|
||||
ops.push(
|
||||
...patchItems(
|
||||
project,
|
||||
c,
|
||||
(e) => {
|
||||
const ph = (e as { renovation?: Renovation }).renovation?.phase;
|
||||
return !!ph && !keep.has(ph);
|
||||
},
|
||||
(e) => {
|
||||
const r = (e as { renovation?: Renovation }).renovation!;
|
||||
const next = renovationForNew(renovationStatus(r), null);
|
||||
const { renovation: _drop, ...rest } = e as { renovation?: Renovation } & Record<string, unknown>;
|
||||
void _drop;
|
||||
return (next ? { ...rest, renovation: next } : rest) as unknown as typeof e;
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
return ops;
|
||||
}
|
||||
|
||||
/** Nächste freie Etappen-Id. */
|
||||
export function newPhaseId(project: Project): string {
|
||||
const used = new Set(renovationPhases(project).map((p) => p.id));
|
||||
let i = used.size + 1;
|
||||
while (used.has(`etappe-${i}`)) i++;
|
||||
return `etappe-${i}`;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// [271] „Beispiel Umbau": das Demo-Haus (sampleProject) als Bestand, umgebaut in zwei Etappen — Vorlage für Tests, die
|
||||
// Kurzanleitung (Abschnitt Umbau) und die Prüfbilder (`doc/review-271`).
|
||||
//
|
||||
// Etappe 1 (innen): die Zwischenwand W9 wird abgebrochen, das Nordfenster O2 zugemauert (Öffnung „Abbruch“: im Neubau-
|
||||
// und Endzustand ist die Wand dort zu, mit roter Ausfachung im Umbauplan), in die Westwand W4 kommt ein neues Fenster O3
|
||||
// (Öffnung „Neu“ in Bestandswand: im Bestand ist die Wand dort zu, im Umbauplan gelbes Abbruch-Stück).
|
||||
// Etappe 2 (Anbau): ein eingeschossiger Anbau im Norden (Wände, Decke, Raum, Fenster) und eine neue Tür in W3.
|
||||
// Nur Modellfelder, keine Kern-Befehle: das Modul ist ohne geladenen Kern auswertbar.
|
||||
|
||||
import type { Ceiling, DrawingLevel, Opening, Project, Renovation, Room, Wall } from "./types";
|
||||
import { sampleProject } from "./sampleProject";
|
||||
|
||||
const E1: Renovation = { status: "new", phase: "etappe-1" };
|
||||
const E2: Renovation = { status: "new", phase: "etappe-2" };
|
||||
const D1: Renovation = { status: "demolish", phase: "etappe-1" };
|
||||
|
||||
const wall = (id: string, x0: number, y0: number, x1: number, y1: number): Wall => ({
|
||||
id, type: "wall", floorId: "eg", categoryCode: "20", start: { x: x0, y: y0 }, end: { x: x1, y: y1 }, wallTypeId: "aw", height: 2.6, renovation: E2,
|
||||
});
|
||||
|
||||
const win = (id: string, hostWallId: string, position: number, width: number, renovation?: Renovation): Opening => ({
|
||||
id, type: "opening", hostWallId, categoryCode: "21", kind: "window", typeId: "window-standard", position, width, height: 1.2, sillHeight: 0.9,
|
||||
...(renovation ? { renovation } : {}),
|
||||
});
|
||||
|
||||
/** Das Umbau-Beispiel (frische Kopie bei jedem Aufruf). */
|
||||
export function buildUmbauSampleProject(): Project {
|
||||
const base = structuredClone(sampleProject);
|
||||
const levels: DrawingLevel[] = [
|
||||
...base.drawingLevels,
|
||||
// Schnitt durch den Anbau (Nord–Süd, Blick nach Osten): zeigt Bestand, Abbruch W9 nicht, aber Anbau und neue Tür.
|
||||
{ id: "schnitt-b", name: "Schnitt B", kind: "section", visible: true, locked: false, linePoints: [{ x: 1.4, y: -1 }, { x: 1.4, y: 8 }], directionSign: -1 },
|
||||
];
|
||||
const walls: Wall[] = base.walls.map((w) => (w.id === "W9" ? { ...w, renovation: D1 } : w));
|
||||
walls.push(wall("W10", 0, 4, 0, 7), wall("W11", 0, 7, 3, 7), wall("W12", 3, 7, 3, 4));
|
||||
const openings: Opening[] = (base.openings ?? []).map((o) => (o.id === "O2" ? { ...o, renovation: D1 } : o));
|
||||
openings.push(
|
||||
win("O3", "W4", 1.5, 1.0, E1),
|
||||
// Neue Tür in der Bestandswand W3 (W3 läuft von x 5 nach x 0: Tür x 1.9–1.0) zum Anbau.
|
||||
{ id: "O4", type: "opening", hostWallId: "W3", categoryCode: "21", kind: "door", typeId: "door-standard", position: 3.1, width: 0.9, height: 2.1, sillHeight: 0, swing: "left", hinge: "start", renovation: E2 },
|
||||
// Fenster des Anbaus: ohne eigenen Status, folgt der neuen Wand.
|
||||
win("O5", "W11", 0.9, 1.2),
|
||||
);
|
||||
const c1 = (base.ceilings ?? [])[0];
|
||||
const ceilings: Ceiling[] = [
|
||||
...(base.ceilings ?? []),
|
||||
{ ...c1, id: "C2", outline: [{ x: 0, y: 4 }, { x: 3, y: 4 }, { x: 3, y: 7 }, { x: 0, y: 7 }], renovation: E2 },
|
||||
];
|
||||
const r1 = (base.rooms ?? [])[0];
|
||||
const h = 0.1725;
|
||||
const rooms: Room[] = [
|
||||
...(base.rooms ?? []),
|
||||
{
|
||||
...r1, id: "R2", name: "Anbau", siaCategory: "HNF",
|
||||
boundary: [{ x: h, y: 4 + h }, { x: 3 - h, y: 4 + h }, { x: 3 - h, y: 7 - h }, { x: h, y: 7 - h }],
|
||||
stampAnchor: { x: 1.5, y: 5.8 },
|
||||
renovation: E2,
|
||||
},
|
||||
];
|
||||
return {
|
||||
...base,
|
||||
id: "beispiel-umbau",
|
||||
name: "Beispiel Umbau",
|
||||
drawingLevels: levels,
|
||||
walls,
|
||||
openings,
|
||||
ceilings,
|
||||
rooms,
|
||||
renovation: {
|
||||
phases: [
|
||||
{ id: "etappe-1", name: "Etappe 1" },
|
||||
{ id: "etappe-2", name: "Etappe 2" },
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -222,6 +222,8 @@ export type Ceiling = {
|
||||
* Z-Wert; „floor" bindet die UK an ein Geschoss.
|
||||
*/
|
||||
bottom?: VerticalAnchor;
|
||||
/** [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand. */
|
||||
renovation?: Renovation;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -327,6 +329,8 @@ export type Column = {
|
||||
strokeWeightSource?: AttributeSource;
|
||||
/** Quelle der Schraffur, analog {@link Column.foregroundSource}. */
|
||||
hatchSource?: AttributeSource;
|
||||
/** [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand. */
|
||||
renovation?: Renovation;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1393,6 +1397,16 @@ export type DrawingLevel = {
|
||||
* Fehlt ⇒ der Detailgrad allein bestimmt die Darstellung (heutiges Verhalten).
|
||||
*/
|
||||
modelViewOptionId?: string;
|
||||
/**
|
||||
* [271] Umbaufilter (eingebaut „bestand“, „abbruch“, „neubau“, „umbauplan“, „endzustand“ oder Id aus
|
||||
* `Project.renovation.filters`). Fehlt ⇒ kein Filter: alle Bauteile wie ohne Umbau-Angaben.
|
||||
*/
|
||||
renovationFilter?: string;
|
||||
/**
|
||||
* [271] Etappe, bis zu der der Umbaufilter gilt (Id aus `Project.renovation.phases`): Neues späterer Etappen fehlt
|
||||
* noch, Abbruch späterer Etappen steht noch als Bestand. Fehlt ⇒ alle Etappen.
|
||||
*/
|
||||
renovationPhase?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1541,6 +1555,8 @@ export type ExtrudedSolid = {
|
||||
* Grundriss und im Schnitt. Fehlt = neutrale Körper-Füllung mit Rückfall-Schraffur.
|
||||
*/
|
||||
componentId?: string;
|
||||
/** [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand. */
|
||||
renovation?: Renovation;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -2779,6 +2795,10 @@ export type Opening = {
|
||||
doorFrameKind?: "zarge" | "blockrahmen" | "blendrahmen" | "umfassungszarge" | "eckzarge" | "blockzarge" | "futter";
|
||||
/** Übersteuert die Zargen-/Rahmenmasse des Türtyps feldweise ([105]). */
|
||||
doorFrame?: DoorFrameDetail;
|
||||
/**
|
||||
* [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand wie die Wand (eine neue Öffnung in einer Bestandswand bricht die Wand dort ab, eine Öffnung „Abbruch“ wird zugemauert).
|
||||
*/
|
||||
renovation?: Renovation;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -3233,6 +3253,8 @@ export type Project = {
|
||||
/** Anzeige-Adresse/Bezeichnung des Bezugspunkts. */
|
||||
label?: string;
|
||||
};
|
||||
/** [271] Umbau: Etappen, Farben je Status (SIA 400) und eigene Umbaufilter. */
|
||||
renovation?: RenovationSettings;
|
||||
};
|
||||
|
||||
/** Protokolleintrag einer Publikation ([79]): Datum, Blätter mit Revision, erzeugte Dateien. */
|
||||
@@ -3301,6 +3323,54 @@ export type ReferenceLineRule = {
|
||||
target: "all" | "exterior" | string;
|
||||
};
|
||||
|
||||
/** [271] Umbau-Angaben eines Elements. */
|
||||
export type Renovation = {
|
||||
status: RenovationStatus;
|
||||
/**
|
||||
* Etappe (`Project.renovation.phases`, Id): beim Status „neu“ die Bau-, bei „abbruch“ die Abbruch-Etappe.
|
||||
* Fehlt ⇒ erste Etappe.
|
||||
*/
|
||||
phase?: string;
|
||||
};
|
||||
|
||||
/** [271] Ein Umbaufilter (wie Archicads „Renovation Filter“): Darstellung je Status. */
|
||||
export type RenovationFilter = {
|
||||
id: string;
|
||||
name: string;
|
||||
existing: RenovationShow;
|
||||
demolish: RenovationShow;
|
||||
new: RenovationShow;
|
||||
};
|
||||
|
||||
/** [271] Eine Bau-Etappe (Reihenfolge = Reihenfolge der Liste). */
|
||||
export type RenovationPhase = { id: string; name: string };
|
||||
|
||||
/** [271] Umbau-Einstellungen des Projekts. */
|
||||
export type RenovationSettings = {
|
||||
/** Etappen in ihrer Reihenfolge (Neubau/Abbruch Etappe 1, 2 …). */
|
||||
phases?: Array<RenovationPhase>;
|
||||
styles?: RenovationStyles;
|
||||
/** Eigene Umbaufilter (zusätzlich zu den eingebauten). */
|
||||
filters?: Array<RenovationFilter>;
|
||||
};
|
||||
|
||||
/** [271] Darstellung eines Status im Umbaufilter. */
|
||||
export type RenovationShow = "show" | "hide" | "override";
|
||||
|
||||
/**
|
||||
* [271] Umbau-Status eines Bauteils (Archicad „Renovation Status“; SIA 400: Bestand schwarz/grau, Abbruch gelb,
|
||||
* Neu rot).
|
||||
*/
|
||||
export type RenovationStatus = "existing" | "demolish" | "new";
|
||||
|
||||
/**
|
||||
* [271] Umbau-Farbe eines Status: Füllung der Schnittflächen, Linienfarbe, gestrichelt. Fehlende Felder ⇒ SIA-Vorgabe.
|
||||
*/
|
||||
export type RenovationStyle = { fill?: string; line?: string; dashed?: boolean };
|
||||
|
||||
/** [271] Umbau-Farben je Status (fehlt ⇒ SIA-400-Vorgabe, `renovation::default_style`). */
|
||||
export type RenovationStyles = { existing?: RenovationStyle; demolish?: RenovationStyle; new?: RenovationStyle };
|
||||
|
||||
/** Wie eine Wandschicht an der Öffnung anschliesst ([106]). */
|
||||
export type RevealMode = "buendig" | "zurueck" | "leibung" | "ueberdaemmt";
|
||||
|
||||
@@ -3433,6 +3503,8 @@ export type Roof = {
|
||||
parapetWidth?: number;
|
||||
/** Attika: Bauteil/Material (Farbe, Schnittschraffur); fehlt ⇒ Wandfarbe ohne Schraffur. */
|
||||
parapetComponentId?: string;
|
||||
/** [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand. */
|
||||
renovation?: Renovation;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -3533,6 +3605,10 @@ export type Room = {
|
||||
ceilingFinish?: string;
|
||||
/** [158] Bodenaufbau als Freitext (z. B. „Parkett 15, UB 80, TSD 20"). */
|
||||
floorBuildUp?: string;
|
||||
/**
|
||||
* [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand (nur Sichtbarkeit und Flächen je Zustand, keine Umbau-Farbe: ein Raum ist kein Bauteil).
|
||||
*/
|
||||
renovation?: Renovation;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -3941,6 +4017,8 @@ export type Stair = {
|
||||
* [T3] Pfosten-Tiefe in Metern, quer zum Handlauf (rechteckig: fehlt = 0.03; Flachstahl: Dicke, fehlt = 0.01; rund: ohne Wirkung).
|
||||
*/
|
||||
postDepth?: number;
|
||||
/** [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand. */
|
||||
renovation?: Renovation;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -4307,6 +4385,16 @@ export type ViewSnapshot = {
|
||||
* Blickwinkel `view3d`. Fehlt ⇒ Blickwinkel `view3d`, Isometrie, getönte Flächen.
|
||||
*/
|
||||
doc3d?: Doc3d;
|
||||
/**
|
||||
* [271] Umbaufilter (eingebaut „bestand“, „abbruch“, „neubau“, „umbauplan“, „endzustand“ oder Id aus
|
||||
* `Project.renovation.filters`). Fehlt ⇒ kein Filter: alle Bauteile wie ohne Umbau-Angaben.
|
||||
*/
|
||||
renovationFilter?: string;
|
||||
/**
|
||||
* [271] Etappe, bis zu der der Umbaufilter gilt (Id aus `Project.renovation.phases`): Neues späterer Etappen fehlt
|
||||
* noch, Abbruch späterer Etappen steht noch als Bestand. Fehlt ⇒ alle Etappen.
|
||||
*/
|
||||
renovationPhase?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -4368,6 +4456,16 @@ export type ViewTemplate = {
|
||||
* Fehlt ⇒ der Detailgrad allein bestimmt die Darstellung (heutiges Verhalten).
|
||||
*/
|
||||
modelViewOptionId?: string;
|
||||
/**
|
||||
* [271] Umbaufilter (eingebaut „bestand“, „abbruch“, „neubau“, „umbauplan“, „endzustand“ oder Id aus
|
||||
* `Project.renovation.filters`). Fehlt ⇒ kein Filter: alle Bauteile wie ohne Umbau-Angaben.
|
||||
*/
|
||||
renovationFilter?: string;
|
||||
/**
|
||||
* [271] Etappe, bis zu der der Umbaufilter gilt (Id aus `Project.renovation.phases`): Neues späterer Etappen fehlt
|
||||
* noch, Abbruch späterer Etappen steht noch als Bestand. Fehlt ⇒ alle Etappen.
|
||||
*/
|
||||
renovationPhase?: string;
|
||||
};
|
||||
|
||||
/** Ansichtstyp eines Geschosses (wie in App). */
|
||||
@@ -4524,6 +4622,8 @@ export type Wall = {
|
||||
* der Elementkante.
|
||||
*/
|
||||
surfacePatternOffset?: Vec2;
|
||||
/** [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand. */
|
||||
renovation?: Renovation;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,6 +35,7 @@ export interface NativeAppMenuHandlers {
|
||||
onNewProjectFromSample: () => void;
|
||||
onNewProjectFromComplexSample: () => void;
|
||||
onNewProjectFromWettbewerbSample: () => void;
|
||||
onNewProjectFromUmbauSample: () => void;
|
||||
onNewProjectFromTemplate: () => void;
|
||||
onOpenProject: () => void;
|
||||
onSaveProject: () => void;
|
||||
@@ -189,6 +190,10 @@ export function useNativeAppMenu(
|
||||
text: t("menu.native.newFromWettbewerbSample"),
|
||||
action: () => handlersRef.current.onNewProjectFromWettbewerbSample(),
|
||||
}),
|
||||
await MenuItem.new({
|
||||
text: t("menu.native.newFromUmbauSample"),
|
||||
action: () => handlersRef.current.onNewProjectFromUmbauSample(),
|
||||
}),
|
||||
await MenuItem.new({
|
||||
text: t("menu.native.newFromTemplateFile"),
|
||||
action: () => handlersRef.current.onNewProjectFromTemplate(),
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// kommt aus `checkRoomProgram`.
|
||||
// Änderungen laufen über `applyChange` (Ops) mit coalesceKey, damit Tippen einen Undo-Schritt ergibt.
|
||||
|
||||
import { useState } from "react";
|
||||
import { t } from "../i18n";
|
||||
import type { TranslationKey } from "../i18n";
|
||||
import { useStore } from "../state/appStore";
|
||||
@@ -37,13 +38,21 @@ function parseNum(text: string): number | null {
|
||||
return text.trim() !== "" && Number.isFinite(v) ? v : null;
|
||||
}
|
||||
|
||||
/** [271] Trägt ein Bauteil oder Raum einen Umbau-Status (sonst bleibt die Wahl „Zustand“ verborgen)? */
|
||||
function hasRenovation(p: Project): boolean {
|
||||
const lists = [p.walls, p.openings, p.ceilings, p.roofs, p.stairs, p.columns, p.extrudedSolids, p.rooms] as Array<readonly { renovation?: unknown }[] | undefined>;
|
||||
return lists.some((l) => (l ?? []).some((e) => e.renovation !== undefined));
|
||||
}
|
||||
|
||||
const fmt = (n: number, d = 1) => n.toLocaleString("de-CH", { minimumFractionDigits: d, maximumFractionDigits: d });
|
||||
|
||||
export function KennzahlenSection() {
|
||||
const applyChange = useStore((s) => s.applyChange);
|
||||
const notify = useStore((s) => s.notify);
|
||||
const project = useStore((s) => s.project);
|
||||
const k = computeKennzahlen(project);
|
||||
// [271] Umbau: Kennzahlen im Zustand Bestand bzw. Endzustand (Kern `renovation.rs`); leer = alle Bauteile.
|
||||
const [renState, setRenState] = useState("");
|
||||
const k = computeKennzahlen(project, renState);
|
||||
const prog = checkRoomProgram(project);
|
||||
const rows = project.roomProgram ?? [];
|
||||
|
||||
@@ -73,6 +82,16 @@ export function KennzahlenSection() {
|
||||
|
||||
return (
|
||||
<div className="kz-section">
|
||||
{hasRenovation(project) && (
|
||||
<label className="kz-parcel" data-testid="kz-renovation-state">
|
||||
<span>{t("renovation.state")}</span>
|
||||
<select className="kz-input" value={renState} onChange={(e) => setRenState(e.target.value)} aria-label={t("renovation.state")}>
|
||||
<option value="">{t("renovation.state.all")}</option>
|
||||
<option value="bestand">{t("renovation.filter.bestand")}</option>
|
||||
<option value="endzustand">{t("renovation.filter.endzustand")}</option>
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
<div className="kz-bar">
|
||||
{tiles.map((tile) => (
|
||||
<div key={tile.label} className="kz-tile" title={t(tile.title)}>
|
||||
|
||||
@@ -38,6 +38,7 @@ import { LibObjectSection } from "./objectInfo/LibObjectSection";
|
||||
import { elementDimensions } from "./objectInfo/elementDims";
|
||||
import { InfoGroups, hasInfoGroups } from "./objectInfo/InfoGroups";
|
||||
import { infoGroupFrame, useInfoGroupState } from "./objectInfo/InfoGroup";
|
||||
import { RenovationField } from "./objectInfo/RenovationField";
|
||||
|
||||
// ── Bezugspunkt-Raster ───────────────────────────────────────────────────────
|
||||
// Neun Anker als 3×3-Raster. Zeile 0 = oben (fy=0), Spalte 0 = links (fx=0).
|
||||
@@ -195,6 +196,9 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* [271] Umbau: Status und Etappe der Auswahl (Mehrfachauswahl in einem Undo-Schritt). */}
|
||||
<RenovationField />
|
||||
|
||||
{showPlacement && (
|
||||
<>
|
||||
{infoGroupFrame(gst, "refpoint", <>
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
// [271] Objekt-Info und Objekteinstellungen: „Umbau“ — Status (Bestand, Abbruch, Neu) und Etappe der Auswahl.
|
||||
// Mehrfachauswahl: alle gewählten Bauteile in einem Undo-Schritt; verschiedene Werte zeigen „gemischt“.
|
||||
|
||||
import { useMemo } from "react";
|
||||
import { t } from "../../i18n";
|
||||
import type { RenovationStatus } from "../../model/types";
|
||||
import { commonRenovation, renovatableIds, renovationPhases, RENOVATION_STATUSES, setRenovationOps } from "../../core";
|
||||
import { useStore } from "../../state/appStore";
|
||||
import type { Selection } from "../../state/selection";
|
||||
import { Dropdown } from "../../ui/Dropdown";
|
||||
|
||||
const MIXED = "__mixed";
|
||||
const NO_PHASE = "";
|
||||
|
||||
/** Ids der Auswahl, die einen Umbau-Status tragen (Wände, Öffnungen, Decken, Dächer, Treppen, Stützen, Körper, Räume). */
|
||||
export function selectionRenovationIds(sel: Selection): string[] {
|
||||
return [...sel.walls, ...sel.openings, ...sel.ceilings, ...sel.roofs, ...sel.stairs, ...sel.columns, ...sel.solids, ...sel.rooms];
|
||||
}
|
||||
|
||||
export function RenovationField() {
|
||||
const project = useStore((s) => s.project);
|
||||
const selection = useStore((s) => s.selection);
|
||||
const applyChange = useStore((s) => s.applyChange);
|
||||
const ids = useMemo(() => renovatableIds(project, selectionRenovationIds(selection)), [project, selection]);
|
||||
const common = useMemo(() => commonRenovation(project, ids), [project, ids]);
|
||||
if (ids.length === 0) return null;
|
||||
const phases = renovationPhases(project);
|
||||
const statusValue = common.status === "mixed" || common.status === null ? MIXED : common.status;
|
||||
const phaseValue = common.phase === "mixed" ? MIXED : (common.phase ?? NO_PHASE);
|
||||
const statusOptions = [
|
||||
...(statusValue === MIXED ? [{ value: MIXED, label: t("renovation.mixed") }] : []),
|
||||
...RENOVATION_STATUSES.map((s) => ({ value: s, label: t(`renovation.status.${s}`) })),
|
||||
];
|
||||
const phaseOptions = [
|
||||
...(phaseValue === MIXED ? [{ value: MIXED, label: t("renovation.mixed") }] : []),
|
||||
{ value: NO_PHASE, label: t("renovation.phase.none") },
|
||||
...phases.map((p) => ({ value: p.id, label: p.name })),
|
||||
];
|
||||
return (
|
||||
<>
|
||||
<div className="objinfo-field" data-testid="objinfo-renovation">
|
||||
<span className="objinfo-flabel">{t("renovation.label")}</span>
|
||||
<Dropdown
|
||||
value={statusValue}
|
||||
onChange={(v) => {
|
||||
if (v === MIXED) return;
|
||||
applyChange((p) => setRenovationOps(p, ids, v as RenovationStatus));
|
||||
}}
|
||||
options={statusOptions}
|
||||
title={t("renovation.label")}
|
||||
width={150}
|
||||
/>
|
||||
</div>
|
||||
{phases.length > 0 && (
|
||||
<div className="objinfo-field" data-testid="objinfo-renovation-phase">
|
||||
<span className="objinfo-flabel">{t("renovation.phase")}</span>
|
||||
<Dropdown
|
||||
value={phaseValue}
|
||||
onChange={(v) => {
|
||||
if (v === MIXED) return;
|
||||
applyChange((p) => setRenovationOps(p, ids, undefined, v === NO_PHASE ? null : v));
|
||||
}}
|
||||
options={phaseOptions}
|
||||
title={t("renovation.phase")}
|
||||
width={150}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -21,6 +21,9 @@ export interface AxoOptions extends Doc3d {
|
||||
mono?: boolean;
|
||||
/** Massstabsnenner (Strichstärken nach Massstab); Vorgabe 100. */
|
||||
scaleDenominator?: number;
|
||||
/** [271] Umbaufilter (Id oder Name) und Etappe. */
|
||||
renovation?: string;
|
||||
renovationPhase?: string;
|
||||
}
|
||||
|
||||
/** Kern-Abfrage `axoPlan`. */
|
||||
|
||||
@@ -84,6 +84,9 @@ export function levelArg(level: DrawingLevel) {
|
||||
// [173] Modelldarstellung der Ebene (Schnitt: Schichten, Öffnungsdetail, Treppen; Ansicht: Schatten,
|
||||
// Materialschraffur, Fenster).
|
||||
modelViewOptionId: level.modelViewOptionId,
|
||||
// [271] Umbaufilter und Etappe der Ebene (Kern `renovation.rs`).
|
||||
renovationFilter: level.renovationFilter,
|
||||
renovationPhase: level.renovationPhase,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+23
-3
@@ -97,6 +97,10 @@ export function classFilterText(hide?: Hide3d, extra?: Record<string, unknown>):
|
||||
if (f.greyFloors?.length) h.greyFloors = f.greyFloors;
|
||||
if (f.lock?.length) h.lock = f.lock;
|
||||
if (f.ghost) h.ghost = true;
|
||||
if (f.renovation) {
|
||||
h.renovation = f.renovation;
|
||||
if (f.renovationPhase) h.renovationPhase = f.renovationPhase;
|
||||
}
|
||||
return Object.keys(h).length || extra ? JSON.stringify({ ...extra, ...h }) : "";
|
||||
}
|
||||
|
||||
@@ -118,6 +122,9 @@ export interface Filter3d {
|
||||
lock?: readonly string[];
|
||||
/** [180] Geisterschicht: nur die grauen Elemente. */
|
||||
ghost?: boolean;
|
||||
/** [271] Umbaufilter der Ansicht (Id) und Etappe: Ausgeblendetes fehlt, Bauteile in der Umbau-Farbe (ohne Teil-Cache). */
|
||||
renovation?: string;
|
||||
renovationPhase?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -295,6 +302,12 @@ export interface Model3dOptions {
|
||||
* Öffnungsdetail, „Handlauf aus" lässt die Handläufe weg. Rechnet ohne den inkrementellen Kern-Cache.
|
||||
*/
|
||||
modelView?: string;
|
||||
/**
|
||||
* [271] Umbaufilter (Id oder Name, `renovation.rs`) und Etappe: Ausgeblendetes fehlt, Bauteile in der Umbau-Farbe.
|
||||
* Rechnet ohne den inkrementellen Kern-Cache.
|
||||
*/
|
||||
renovation?: string;
|
||||
renovationPhase?: string;
|
||||
/**
|
||||
* [180] Klassen, die zusätzlich zum Ebenen-Baum nicht gezeichnet werden (Darstellungsmodus des Ebenen-Panels).
|
||||
* Ausgeblendete Klassen fehlen im Modell, in der Pick-Geometrie und im Export der Ansicht (Kern filtert nach dem
|
||||
@@ -315,8 +328,14 @@ export function projectToModel3d(project: Project, opts: Model3dOptions = {}): R
|
||||
const args = [layered ? 1 : 0, DETAIL_CODE[detail] ?? 3, opts.forSection ? 1 : 0, voids ? 1 : 0, explode];
|
||||
// Ohne Explosion inkrementell ([58]): nur geänderte Wände reisen aus dem Kern und werden gelesen.
|
||||
const doc = documentFor(project);
|
||||
const text = classFilterText(opts.hide, opts.modelView ? { modelView: opts.modelView } : undefined);
|
||||
const parts = opts.modelView || explode > 0 ? doc.query<Model3dParts>("model3dParts", args, text) : doc.model3dParts<Model3dParts>(args, text);
|
||||
const extra: Record<string, unknown> = {};
|
||||
if (opts.modelView) extra.modelView = opts.modelView;
|
||||
if (opts.renovation) {
|
||||
extra.renovation = opts.renovation;
|
||||
if (opts.renovationPhase) extra.renovationPhase = opts.renovationPhase;
|
||||
}
|
||||
const text = classFilterText(opts.hide, Object.keys(extra).length ? extra : undefined);
|
||||
const parts = opts.modelView || opts.renovation || filter3d(opts.hide).renovation || explode > 0 ? doc.query<Model3dParts>("model3dParts", args, text) : doc.model3dParts<Model3dParts>(args, text);
|
||||
// [115] Freie Körper als Kern-Netze (`model3d/solids.rs`) zwischen Kontext-Meshes und Stützen.
|
||||
const meshes: RMesh[] = [...parts.contextMeshes];
|
||||
for (const m of parts.solidMeshes) meshes.push(m);
|
||||
@@ -369,7 +388,8 @@ export interface Model3dPart {
|
||||
export function projectToModel3dParts(project: Project, opts: Model3dOptions = {}): Model3dPart[] | null {
|
||||
const layered = opts.layeredWalls ?? true;
|
||||
const detail = opts.detail ?? "fein";
|
||||
if (explodeGap(opts.explode) > 0) return null;
|
||||
// [271] Mit Umbaufilter ohne Teil-Cache: das ganze Modell (`projectToModel3d`).
|
||||
if (explodeGap(opts.explode) > 0 || opts.renovation || filter3d(opts.hide).renovation) return null;
|
||||
const voids = !!opts.voids;
|
||||
const args = [layered ? 1 : 0, DETAIL_CODE[detail] ?? 3, opts.forSection ? 1 : 0, voids ? 1 : 0, 0];
|
||||
const { parts, keyed } = documentFor(project).model3dPartsKeyed<Model3dParts>(args, classFilterText(opts.hide));
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { DrawingLevel, Project, ViewTemplate } from "../model/types";
|
||||
import type { DetailLevel } from "../model/viewTypes";
|
||||
|
||||
/** Ebenen-Felder, die eine Vorlage setzt (fehlt das Vorlagen-Feld, bleibt die Ansicht unberührt). */
|
||||
export const TEMPLATE_LEVEL_KEYS = ["cutHeight", "viewTop", "viewBottom", "viewDepth", "shadows", "hiddenLines", "sketch", "cutHatch", "floorFinish", "showTerrain", "modelViewOptionId"] as const;
|
||||
export const TEMPLATE_LEVEL_KEYS = ["cutHeight", "viewTop", "viewBottom", "viewDepth", "shadows", "hiddenLines", "sketch", "cutHatch", "floorFinish", "showTerrain", "modelViewOptionId", "renovationFilter", "renovationPhase"] as const;
|
||||
|
||||
/** Teilobjekt für die Ebene aus den gesetzten Feldern der Vorlage. */
|
||||
export function templateLevelPatch(t: ViewTemplate): Partial<DrawingLevel> {
|
||||
|
||||
@@ -80,9 +80,19 @@ export async function viewportLevelPlan(
|
||||
*/
|
||||
export async function viewportSnapshotPlan(project: Project, snap: ViewSnapshot, visibleCodes: Set<string>, scaleDenominator: number, forPrint = false): Promise<Plan> {
|
||||
if (isDoc3dSnapshot(snap)) return snapshotAxoPlan(project, snap, visibleCodes, scaleDenominator, snapshotMono(project, snap)) ?? EMPTY;
|
||||
// [271] Umbaufilter des Ausschnitts: geht dem der Ebene vor (wie im Kern `sheet_viewports::viewport_args`).
|
||||
if (snap.renovationFilter) {
|
||||
const rp = projectWithRenovation(project, snap.activeLevelId, snap.renovationFilter, snap.renovationPhase);
|
||||
return withDocument(rp, () => viewportLevelPlan(rp, snap.activeLevelId, visibleCodes, snap.detail, scaleDenominator, forPrint, snapshotMono(rp, snap), snapshotOverrideRuleIds(rp, snap), snapshotTemplate(rp, snap), snap.modelViewOptionId));
|
||||
}
|
||||
return viewportLevelPlan(project, snap.activeLevelId, visibleCodes, snap.detail, scaleDenominator, forPrint, snapshotMono(project, snap), snapshotOverrideRuleIds(project, snap), snapshotTemplate(project, snap), snap.modelViewOptionId);
|
||||
}
|
||||
|
||||
/** [271] Das Projekt mit Umbaufilter `filter` (und Etappe) an der Ebene `levelId`. */
|
||||
export function projectWithRenovation(project: Project, levelId: string, filter: string, phase?: string): Project {
|
||||
return { ...project, drawingLevels: project.drawingLevels.map((l) => (l.id === levelId ? { ...l, renovationFilter: filter, ...(phase ? { renovationPhase: phase } : {}) } : l)) };
|
||||
}
|
||||
|
||||
/** [173] Das Projekt mit der Modelldarstellung `id` an der Ebene `levelId` (wie die Vorlage ein Ebenen-Feld). */
|
||||
export function projectWithModelView(project: Project, levelId: string, id: string): Project {
|
||||
return { ...project, drawingLevels: project.drawingLevels.map((l) => (l.id === levelId ? { ...l, modelViewOptionId: id } : l)) };
|
||||
|
||||
@@ -576,7 +576,10 @@ export function createProjectSlice(
|
||||
|
||||
// Befehl ([K4] S3, `commands.rs`): der Kern rechnet ihn auf dem Dokument und wendet ihn im selben
|
||||
// Aufruf an (`cmdMutation`); Prüfung, Verlauf und Meldungen wie `commitOps`.
|
||||
const applyCmd = (req: object, coalesceKey?: string) => {
|
||||
const applyCmd = (req0: object, coalesceKey?: string) => {
|
||||
// [271] Aktueller Zeichen-Status: der Kern gibt ihn neuen Bauteilen der Zeichenbefehle (`commands::stamp_renovation`).
|
||||
const dr = (get() as unknown as { drawRenovation?: { status: string; phase?: string } }).drawRenovation;
|
||||
const req = dr && (dr.status !== "existing" || dr.phase) ? { ...req0, renovation: dr } : req0;
|
||||
if (forwarded(() => storeDocument(get().project).cmdOps(req), coalesceKey)) return;
|
||||
let notice: string | undefined;
|
||||
set((s) => {
|
||||
|
||||
@@ -60,6 +60,10 @@ declare global {
|
||||
sectionWalls: () => Promise<{ n: number; area: number }>;
|
||||
/** [193] Gelände-/Umgebungs-Elemente (Art, Id, bei der Baugrube die erste Umrissecke, bei Höhenlinien der erste Punkt). */
|
||||
context: () => { id: string; type: string; first?: { x: number; y: number } }[];
|
||||
/** [271] Füllfarben der Element-Flächen im Grundriss der aktiven Ebene (Farbe → Anzahl, alle Klassen, 1:100). */
|
||||
planFillColors: () => Record<string, number>;
|
||||
/** [271] Umbau: Filter und Etappe der aktiven Ebene, Zeichen-Status, Status je Wand. */
|
||||
renovation: () => { filter: string | null; phase: string | null; draw: string; walls: Record<string, string> };
|
||||
/** [193] Gefüllte Flächen (Füllfarbe gesetzt) im Grundriss der aktiven Ebene (alle Kategorien, 1:100); bei 0 ist nichts Gefülltes mehr zu sehen. */
|
||||
planFills: () => number;
|
||||
/** [193] Höhe (z) des ersten Gelände-Netz-Punkts. */
|
||||
@@ -153,6 +157,33 @@ export function installTestHooks(): void {
|
||||
walk(s.project.layers);
|
||||
return generatePlan(s.project, s.activeLevelId, codes, undefined, s.detail, false, false, true, 50).primitives.filter((q) => q.kind === "line" && q.cls === cls).length;
|
||||
},
|
||||
planFillColors: () => {
|
||||
const s = getState();
|
||||
const codes = new Set<string>();
|
||||
const walk = (cs: { code: string; children?: unknown[] }[]): void => {
|
||||
for (const c of cs) {
|
||||
codes.add(c.code);
|
||||
walk((c.children ?? []) as { code: string; children?: unknown[] }[]);
|
||||
}
|
||||
};
|
||||
walk(s.project.layers);
|
||||
const out: Record<string, number> = {};
|
||||
for (const q of generatePlan(s.project, s.activeLevelId, codes, undefined, s.detail, false, false, true, 100).primitives) {
|
||||
if (q.kind !== "polygon" || !q.fill || !Object.entries(q).some(([k, v]) => k.endsWith("Id") && !!v)) continue;
|
||||
out[q.fill] = (out[q.fill] ?? 0) + 1;
|
||||
}
|
||||
return out;
|
||||
},
|
||||
renovation: () => {
|
||||
const s = getState();
|
||||
const l = s.project.drawingLevels.find((x) => x.id === s.activeLevelId);
|
||||
return {
|
||||
filter: l?.renovationFilter ?? null,
|
||||
phase: l?.renovationPhase ?? null,
|
||||
draw: s.drawRenovation.status,
|
||||
walls: Object.fromEntries(s.project.walls.map((w) => [w.id, w.renovation?.status ?? "existing"])),
|
||||
};
|
||||
},
|
||||
context: () =>
|
||||
(getState().project.context ?? []).map((c) => ({ id: c.id, type: c.type, first: c.type === "excavation" ? c.outline[0] : c.type === "contourSet" ? c.contours[0]?.pts[0] : undefined })),
|
||||
planFills: () => {
|
||||
|
||||
@@ -89,6 +89,7 @@ export function useNativeMenu(opts: {
|
||||
onNewProjectFromSample,
|
||||
onNewProjectFromComplexSample,
|
||||
onNewProjectFromWettbewerbSample,
|
||||
onNewProjectFromUmbauSample,
|
||||
onNewProjectFromTemplate,
|
||||
onOpenProject,
|
||||
onSaveProject,
|
||||
@@ -119,6 +120,7 @@ export function useNativeMenu(opts: {
|
||||
onNewProjectFromSample,
|
||||
onNewProjectFromComplexSample,
|
||||
onNewProjectFromWettbewerbSample,
|
||||
onNewProjectFromUmbauSample,
|
||||
onNewProjectFromTemplate,
|
||||
onOpenProject,
|
||||
onSaveProject,
|
||||
|
||||
@@ -50,6 +50,7 @@ import { emptyProject, sampleProject } from "../model/sampleProject";
|
||||
import { withNewProjectNames } from "../model/newProjectNames";
|
||||
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
|
||||
import { buildWettbewerbSampleProject } from "../model/sampleProjectWettbewerb";
|
||||
import { buildUmbauSampleProject } from "../model/sampleProjectUmbau";
|
||||
import { withStandards } from "../model/standards";
|
||||
import type { Project } from "../model/types";
|
||||
import type { PlanViewHandle } from "../views/plan/PlanView";
|
||||
@@ -570,6 +571,13 @@ export function useProjectFileActions(
|
||||
getState().loadProject(next);
|
||||
lastSavedProjectRef.current = next;
|
||||
});
|
||||
// [271] „Neu aus Vorlage: Beispiel Umbau" — Demo-Haus mit Abbruch, zugemauertem und neuem Fenster, Anbau in zwei Etappen.
|
||||
const onNewProjectFromUmbauSample = () => guardDiscard(() => {
|
||||
releaseCurrentProjectLock();
|
||||
const next = buildUmbauSampleProject();
|
||||
getState().loadProject(next);
|
||||
lastSavedProjectRef.current = next;
|
||||
});
|
||||
// „Neu aus Vorlage: Datei wählen…" — native `.obpt`-Dialog unter Tauri, sonst
|
||||
// das versteckte `<input type=file>` (projectTemplateFileInputRef).
|
||||
const onNewProjectFromTemplate = () => {
|
||||
@@ -914,6 +922,7 @@ export function useProjectFileActions(
|
||||
onNewProjectFromSample,
|
||||
onNewProjectFromComplexSample,
|
||||
onNewProjectFromWettbewerbSample,
|
||||
onNewProjectFromUmbauSample,
|
||||
onNewProjectFromTemplate,
|
||||
onProjectTemplateFileChosen,
|
||||
releaseCurrentProjectLock,
|
||||
|
||||
@@ -18,6 +18,7 @@ import type { useProjectActions } from "./useProjectActions";
|
||||
import type { useTopBarState } from "./useTopBarState";
|
||||
import { useViewTemplateHandlers } from "./useViewTemplateHandlers";
|
||||
import { modelViewHandlers } from "./useModelViewHandlers";
|
||||
import { setField, setPhasesOps } from "../core";
|
||||
|
||||
type TopBar = ReturnType<typeof useTopBarState>;
|
||||
type Dialogs = ReturnType<typeof useDialogState>;
|
||||
@@ -135,6 +136,15 @@ export function useResourceHandlers(opts: {
|
||||
...viewTemplateHandlers,
|
||||
// [173] Modelldarstellung (neue Stufe über dem Detailgrad der Anzeige).
|
||||
...modelViewHandlers(applyChange, () => detail),
|
||||
// [271] Umbau: Etappen und Farben (Ressourcen-Tab „Umbau“).
|
||||
onSetRenovationPhases: (phases) => applyChange((p) => setPhasesOps(p, phases)),
|
||||
onSetRenovationStyles: (styles) =>
|
||||
applyChange((p) => {
|
||||
const next = { ...(p.renovation ?? {}) };
|
||||
if (styles) next.styles = styles;
|
||||
else delete next.styles;
|
||||
return [setField("renovation", Object.keys(next).length ? next : undefined)];
|
||||
}),
|
||||
onPatchComponent: patchComponent,
|
||||
onPatchWallType: patchWallType,
|
||||
onAddWallType: addWallType,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import type { DetailLevel, RenderMode, View3d, ViewType } from "../model/viewTypes";
|
||||
import type { TraceReference } from "../model/types";
|
||||
import type { TraceReference, RenovationStatus } from "../model/types";
|
||||
import type { DisplayMode } from "../panels/types";
|
||||
import { DEFAULT_MARQUEE_COLOR, DEFAULT_SNAP_COLOR } from "../theme/accents";
|
||||
import type { StoreApi } from "./store";
|
||||
@@ -21,6 +21,12 @@ const DEFAULT_DISPLAY_MODE: DisplayMode = "all";
|
||||
export interface ViewSlice {
|
||||
// Aktive Zeichnungsebene (Geschoss/Schnitt/Zeichnung).
|
||||
activeLevelId: string;
|
||||
/**
|
||||
* [271] Aktueller Zeichen-Status (Umbau): neue Bauteile der Zeichenbefehle tragen ihn (Vorgabe Bestand, Wunsch
|
||||
* Maintainer); mit Etappe. Zustand der Sitzung, kein Undo-Schritt.
|
||||
*/
|
||||
drawRenovation: { status: RenovationStatus; phase?: string };
|
||||
setDrawRenovation: (status: RenovationStatus, phase?: string) => void;
|
||||
// Ansichtstyp (Grundriss / Perspektive).
|
||||
viewType: ViewType;
|
||||
// Zuletzt gewählter Ansichtstyp je Zeichnungsebene — jeder Tab merkt sich
|
||||
@@ -92,6 +98,8 @@ export function createViewSlice(api: StoreApi<ViewSlice>): ViewSlice {
|
||||
const { set, get } = api;
|
||||
return {
|
||||
activeLevelId: sampleProject.drawingLevels[0].id,
|
||||
drawRenovation: { status: "existing" },
|
||||
setDrawRenovation: (status, phase) => set({ drawRenovation: phase ? { status, phase } : { status } }),
|
||||
viewType: "grundriss",
|
||||
viewTypeByLevel: {},
|
||||
detail: "mittel",
|
||||
|
||||
@@ -1289,6 +1289,39 @@ body {
|
||||
gap: 6px;
|
||||
padding: 6px 12px 2px;
|
||||
}
|
||||
/* [271] Umbau: Zeichen-Status als Farbpunkt (SIA: Bestand grau, Abbruch gelb, Neu rot), Filter im Popover. */
|
||||
.sb-renovation-popover {
|
||||
min-width: 240px;
|
||||
}
|
||||
.sb-renovation-popover select {
|
||||
max-width: 130px;
|
||||
}
|
||||
.sb-snap-head {
|
||||
font-weight: 600;
|
||||
opacity: 0.7;
|
||||
padding-top: 4px;
|
||||
}
|
||||
.sb-renovation-dot {
|
||||
display: inline-block;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
margin-right: 5px;
|
||||
border-radius: 50%;
|
||||
border: 1px solid rgba(0, 0, 0, 0.35);
|
||||
vertical-align: baseline;
|
||||
}
|
||||
.sb-renovation-existing {
|
||||
background: #a6a6a6;
|
||||
}
|
||||
.sb-renovation-demolish {
|
||||
background: #ffd800;
|
||||
}
|
||||
.sb-renovation-new {
|
||||
background: #e3001b;
|
||||
}
|
||||
.sb-toggle.sb-renovation-on {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* ── Command-Line (Rhino-artig) — über der Statusleiste ──────────────────────
|
||||
Dunkle, ruhige Leiste mit Prompt links, klickbaren Inline-Optionen und einer
|
||||
|
||||
@@ -25,6 +25,7 @@ export interface AppMenuBarProps {
|
||||
onNewProjectFromSample: () => void;
|
||||
onNewProjectFromComplexSample: () => void;
|
||||
onNewProjectFromWettbewerbSample: () => void;
|
||||
onNewProjectFromUmbauSample?: () => void;
|
||||
onNewProjectFromTemplate: () => void;
|
||||
onOpenProject: () => void;
|
||||
onSaveProject: () => void;
|
||||
@@ -75,6 +76,7 @@ export const AppMenuBar = memo(function AppMenuBar({
|
||||
onNewProjectFromSample,
|
||||
onNewProjectFromComplexSample,
|
||||
onNewProjectFromWettbewerbSample,
|
||||
onNewProjectFromUmbauSample,
|
||||
onNewProjectFromTemplate,
|
||||
onOpenProject,
|
||||
onSaveProject,
|
||||
@@ -111,6 +113,7 @@ export const AppMenuBar = memo(function AppMenuBar({
|
||||
{ label: t("file.newFromSample"), onSelect: onNewProjectFromSample },
|
||||
{ label: t("file.newFromComplexSample"), onSelect: onNewProjectFromComplexSample },
|
||||
{ label: t("file.newFromWettbewerbSample"), onSelect: onNewProjectFromWettbewerbSample },
|
||||
...(onNewProjectFromUmbauSample ? [{ label: t("file.newFromUmbauSample"), onSelect: onNewProjectFromUmbauSample }] : []),
|
||||
{ label: t("file.newFromTemplateFile"), onSelect: onNewProjectFromTemplate },
|
||||
{ divider: true },
|
||||
{ label: t("file.open"), onSelect: onOpenProject },
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
// [271] Umbau in der Statusleiste: zeigt den aktuellen Zeichen-Status (neue Bauteile tragen ihn) und den Umbaufilter der
|
||||
// aktiven Ansicht; das Popover stellt beides ein (Status und Etappe zum Zeichnen; Filter und Etappe der Ebene — wie die
|
||||
// Modelldarstellung ein Feld der Ebene, darum je Reiter/Ausschnitt eigen und mit Undo). Bei wenig Platz wandert es
|
||||
// mit der Pausfolie in „⋯“ ([263]).
|
||||
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { t } from "../i18n";
|
||||
import type { TranslationKey } from "../i18n";
|
||||
import { useStore } from "../state/appStore";
|
||||
import { BUILTIN_RENOVATION_FILTERS, patchItem, renovationPhases, RENOVATION_STATUSES } from "../core";
|
||||
import type { RenovationStatus } from "../model/types";
|
||||
|
||||
/** Anzeigename eines Filters (eingebaut übersetzt, eigene mit ihrem Namen). */
|
||||
export function renovationFilterLabel(id: string, own: readonly { id: string; name: string }[]): string {
|
||||
if ((BUILTIN_RENOVATION_FILTERS as readonly string[]).includes(id)) return t(`renovation.filter.${id}` as TranslationKey);
|
||||
return own.find((f) => f.id === id)?.name ?? id;
|
||||
}
|
||||
|
||||
export function RenovationControl() {
|
||||
const project = useStore((s) => s.project);
|
||||
const activeLevelId = useStore((s) => s.activeLevelId);
|
||||
const draw = useStore((s) => s.drawRenovation);
|
||||
const setDraw = useStore((s) => s.setDrawRenovation);
|
||||
const applyChange = useStore((s) => s.applyChange);
|
||||
const [open, setOpen] = useState(false);
|
||||
const wrapRef = useRef<HTMLSpanElement | null>(null);
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
const onDown = (e: MouseEvent) => {
|
||||
if (wrapRef.current && !wrapRef.current.contains(e.target as Node)) setOpen(false);
|
||||
};
|
||||
const onKey = (e: KeyboardEvent) => e.key === "Escape" && setOpen(false);
|
||||
document.addEventListener("mousedown", onDown);
|
||||
document.addEventListener("keydown", onKey);
|
||||
return () => {
|
||||
document.removeEventListener("mousedown", onDown);
|
||||
document.removeEventListener("keydown", onKey);
|
||||
};
|
||||
}, [open]);
|
||||
const level = project.drawingLevels.find((l) => l.id === activeLevelId);
|
||||
const phases = renovationPhases(project);
|
||||
const own = useMemo(() => project.renovation?.filters ?? [], [project.renovation?.filters]);
|
||||
const filter = level?.renovationFilter ?? "";
|
||||
const levelEditable = !!level && (level.kind === "floor" || level.kind === "section" || level.kind === "elevation" || level.kind === "ceiling");
|
||||
const setLevel = (patch: { renovationFilter?: string; renovationPhase?: string }) => {
|
||||
if (!level) return;
|
||||
applyChange((p) =>
|
||||
patchItem(p, "drawingLevels", level.id, (l) => {
|
||||
const next = { ...l, ...patch };
|
||||
if (!next.renovationFilter) delete next.renovationFilter;
|
||||
if (!next.renovationPhase || !next.renovationFilter) delete next.renovationPhase;
|
||||
return next;
|
||||
}),
|
||||
);
|
||||
};
|
||||
const statusLabel = t(`renovation.status.${draw.status}` as TranslationKey);
|
||||
const filterLabel = filter ? renovationFilterLabel(filter, own) : t("renovation.filter.none");
|
||||
return (
|
||||
<span className="sb-snap-wrap" ref={wrapRef}>
|
||||
<button
|
||||
type="button"
|
||||
className={`sb-toggle${open ? " active" : ""}${filter ? " sb-renovation-on" : ""}`}
|
||||
data-testid="renovation-toggle"
|
||||
aria-haspopup="true"
|
||||
aria-expanded={open}
|
||||
title={t("renovation.status.hint", { status: statusLabel, filter: filterLabel })}
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
>
|
||||
<span className={`sb-renovation-dot sb-renovation-${draw.status}`} aria-hidden="true" />
|
||||
{t("renovation.short", { status: statusLabel })}
|
||||
</button>
|
||||
{open && (
|
||||
<div className="sb-snap-popover sb-renovation-popover" role="dialog" aria-label={t("renovation.title")} data-testid="renovation-panel">
|
||||
<div className="sb-snap-row sb-snap-head">{t("renovation.drawStatus")}</div>
|
||||
<label className="sb-snap-row sb-snap-row-num">
|
||||
<span>{t("renovation.label")}</span>
|
||||
<select
|
||||
value={draw.status}
|
||||
aria-label={t("renovation.drawStatus")}
|
||||
data-testid="renovation-draw-status"
|
||||
onChange={(e) => setDraw(e.target.value as RenovationStatus, draw.phase)}
|
||||
>
|
||||
{RENOVATION_STATUSES.map((s) => (
|
||||
<option key={s} value={s}>
|
||||
{t(`renovation.status.${s}` as TranslationKey)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
{phases.length > 0 && (
|
||||
<label className="sb-snap-row sb-snap-row-num">
|
||||
<span>{t("renovation.phase")}</span>
|
||||
<select value={draw.phase ?? ""} aria-label={t("renovation.phase")} onChange={(e) => setDraw(draw.status, e.target.value || undefined)}>
|
||||
<option value="">{t("renovation.phase.none")}</option>
|
||||
{phases.map((p) => (
|
||||
<option key={p.id} value={p.id}>
|
||||
{p.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
<div className="sb-snap-row sb-snap-head">{t("renovation.filter")}</div>
|
||||
<label className="sb-snap-row sb-snap-row-num">
|
||||
<span>{t("renovation.filter")}</span>
|
||||
<select
|
||||
value={filter}
|
||||
disabled={!levelEditable}
|
||||
aria-label={t("renovation.filter")}
|
||||
data-testid="renovation-filter"
|
||||
onChange={(e) => setLevel({ renovationFilter: e.target.value || undefined, renovationPhase: level?.renovationPhase })}
|
||||
>
|
||||
<option value="">{t("renovation.filter.none")}</option>
|
||||
{BUILTIN_RENOVATION_FILTERS.map((id) => (
|
||||
<option key={id} value={id}>
|
||||
{t(`renovation.filter.${id}` as TranslationKey)}
|
||||
</option>
|
||||
))}
|
||||
{own.map((f) => (
|
||||
<option key={f.id} value={f.id}>
|
||||
{f.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
{phases.length > 0 && filter && (
|
||||
<label className="sb-snap-row sb-snap-row-num">
|
||||
<span>{t("renovation.filterPhase")}</span>
|
||||
<select
|
||||
value={level?.renovationPhase ?? ""}
|
||||
aria-label={t("renovation.filterPhase")}
|
||||
onChange={(e) => setLevel({ renovationFilter: filter, renovationPhase: e.target.value || undefined })}
|
||||
>
|
||||
<option value="">{t("renovation.phase.all")}</option>
|
||||
{phases.map((p) => (
|
||||
<option key={p.id} value={p.id}>
|
||||
{p.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -46,6 +46,8 @@ import { ViewTemplatesTab } from "./resourceManager/ViewTemplatesTab";
|
||||
import type { ViewTemplateHandlers } from "./resourceManager/ViewTemplatesTab";
|
||||
import { ModelViewsTab } from "./resourceManager/ModelViewsTab";
|
||||
import type { ModelViewHandlers } from "./resourceManager/ModelViewsTab";
|
||||
import { RenovationTab } from "./resourceManager/RenovationTab";
|
||||
import type { RenovationHandlers } from "./resourceManager/RenovationTab";
|
||||
import { PenSetsTab } from "./resourceManager/PenSetsTab";
|
||||
import { PalettesTab } from "./resourceManager/PalettesTab";
|
||||
import { TextStylesTab } from "./resourceManager/TextStylesTab";
|
||||
@@ -69,6 +71,7 @@ export type TabId =
|
||||
| "overrides"
|
||||
| "viewTemplates"
|
||||
| "modelViews"
|
||||
| "renovation"
|
||||
| "pens"
|
||||
| "palettes";
|
||||
|
||||
@@ -89,10 +92,11 @@ const TABS: { id: TabId; labelKey: string }[] = [
|
||||
{ id: "overrides", labelKey: "resources.tab.overrides" },
|
||||
{ id: "viewTemplates", labelKey: "resources.tab.viewTemplates" },
|
||||
{ id: "modelViews", labelKey: "resources.tab.modelViews" },
|
||||
{ id: "renovation", labelKey: "resources.tab.renovation" },
|
||||
];
|
||||
|
||||
/** Bündel der immutablen Mutationen (von App über setProject bereitgestellt). */
|
||||
export interface ResourceManagerHandlers extends ViewTemplateHandlers, ModelViewHandlers {
|
||||
export interface ResourceManagerHandlers extends ViewTemplateHandlers, ModelViewHandlers, RenovationHandlers {
|
||||
onPatchComponent: (id: string, patch: Partial<Component>) => void;
|
||||
onAddComponent: () => void;
|
||||
onDeleteComponent: (id: string) => void;
|
||||
@@ -491,6 +495,7 @@ export function ResourceManager({
|
||||
{tab === "materials" && <MaterialsTab />}
|
||||
{tab === "viewTemplates" && <ViewTemplatesTab project={project} handlers={handlers} />}
|
||||
{tab === "modelViews" && <ModelViewsTab project={project} handlers={handlers} />}
|
||||
{tab === "renovation" && <RenovationTab project={project} handlers={handlers} />}
|
||||
{tab === "overrides" && (
|
||||
<OverridesTab
|
||||
project={project}
|
||||
|
||||
@@ -15,6 +15,7 @@ import { useEffect, useLayoutEffect, useRef, useState, memo } from "react";
|
||||
import type { SnapSettings } from "../tools/types";
|
||||
import { t } from "../i18n";
|
||||
import { TraceControl } from "./TraceControl";
|
||||
import { RenovationControl } from "./RenovationControl";
|
||||
import { BUILD_INFO, formatBuildShort } from "../update/buildInfo";
|
||||
|
||||
export interface StatusBarProps {
|
||||
@@ -424,7 +425,7 @@ export const StatusBar = memo(function StatusBar({
|
||||
const pickHint = usePickHint();
|
||||
// [263] Schriftbreite ist nicht planbar (Ersatzschriften je System): passt der Cluster nicht, wird er nach Priorität
|
||||
// gekürzt — nie abgeschnitten. Stufe 1: Beschriftungen weg (nur Werte, Tooltip bleibt) · 2: Einheit und Build weg ·
|
||||
// 3: Linien-Darstellung nach „⋯“ · 4: Pausfolie nach „⋯“ · 5: Fang und Referenzlinien nach „⋯“.
|
||||
// 3: Linien-Darstellung nach „⋯“ · 4: Pausfolie und Umbau ([271]) nach „⋯“ · 5: Fang und Referenzlinien nach „⋯“.
|
||||
const footerRef = useRef<HTMLElement | null>(null);
|
||||
const clusterRef = useRef<HTMLDivElement | null>(null);
|
||||
const innerRef = useRef<HTMLSpanElement | null>(null);
|
||||
@@ -486,6 +487,7 @@ export const StatusBar = memo(function StatusBar({
|
||||
<LineModeToggle lineMode={lineMode} onLineModeChange={onLineModeChange} lineModeEnabled={lineModeEnabled} />
|
||||
);
|
||||
const traceEl = <TraceControl enabled={!!traceEnabled} onRunCommand={onRunCommand} />;
|
||||
const renovationEl = <RenovationControl />;
|
||||
const snapEl = <SnapControl snap={snap} onSnapChange={onSnapChange} />;
|
||||
const refEl = (
|
||||
<button
|
||||
@@ -502,7 +504,7 @@ export const StatusBar = memo(function StatusBar({
|
||||
// Was in „⋯“ wandert (Reihenfolge = Wegfall-Priorität von oben nach unten).
|
||||
const inMore: React.ReactNode[] = [];
|
||||
if (level >= 3) inMore.push(<span key="lm">{lineModeEl}</span>);
|
||||
if (level >= 4) inMore.push(<span key="tr">{traceEl}</span>);
|
||||
if (level >= 4) inMore.push(<span key="tr">{traceEl}</span>, <span key="ren">{renovationEl}</span>);
|
||||
if (level >= 5) {
|
||||
inMore.push(<span key="sn">{snapEl}</span>, <span key="rf">{refEl}</span>);
|
||||
}
|
||||
@@ -531,6 +533,8 @@ export const StatusBar = memo(function StatusBar({
|
||||
<>
|
||||
{traceEl}
|
||||
<Sep />
|
||||
{renovationEl}
|
||||
<Sep />
|
||||
</>
|
||||
)}
|
||||
{level < 5 && (
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
// [271] Ressourcen-Tab „Umbau“: Etappen (Name, Reihenfolge, hinzufügen/entfernen) und Umbau-Farben je Status
|
||||
// (Füllung, Linie, gestrichelt; Vorgabe SIA 400: Bestand grau, Abbruch gelb gestrichelt, Neu rot).
|
||||
// Reine Darstellung über Handler (wie die anderen Tabs, auch im macOS-Nebenfenster).
|
||||
|
||||
import { t } from "../../i18n";
|
||||
import type { TranslationKey } from "../../i18n";
|
||||
import type { Project, RenovationPhase, RenovationStatus, RenovationStyle, RenovationStyles } from "../../model/types";
|
||||
import { DEFAULT_RENOVATION_STYLES, newPhaseId, RENOVATION_STATUSES, renovationPhases } from "../../core";
|
||||
|
||||
export interface RenovationHandlers {
|
||||
/** Etappen-Liste ersetzen (Elemente einer entfernten Etappe verlieren sie). */
|
||||
onSetRenovationPhases?: (phases: RenovationPhase[]) => void;
|
||||
/** Umbau-Farben ersetzen (`undefined` = SIA-Vorgabe). */
|
||||
onSetRenovationStyles?: (styles: RenovationStyles | undefined) => void;
|
||||
}
|
||||
|
||||
export function RenovationTab({ project, handlers }: { project: Project; handlers: RenovationHandlers }) {
|
||||
const phases = renovationPhases(project);
|
||||
const styles = project.renovation?.styles ?? {};
|
||||
const setPhases = handlers.onSetRenovationPhases;
|
||||
const setStyles = handlers.onSetRenovationStyles;
|
||||
const move = (i: number, d: number) => {
|
||||
const j = i + d;
|
||||
if (!setPhases || j < 0 || j >= phases.length) return;
|
||||
const next = [...phases];
|
||||
[next[i], next[j]] = [next[j], next[i]];
|
||||
setPhases(next);
|
||||
};
|
||||
const patchStyle = (s: RenovationStatus, patch: Partial<RenovationStyle> | null) => {
|
||||
if (!setStyles) return;
|
||||
const next: RenovationStyles = { ...styles };
|
||||
if (patch === null) delete next[s];
|
||||
else next[s] = { ...(styles[s] ?? {}), ...patch };
|
||||
setStyles(Object.keys(next).length ? next : undefined);
|
||||
};
|
||||
return (
|
||||
<div className="rm-renovation" data-testid="rm-renovation">
|
||||
<h4 className="rm-subhead">{t("renovation.phases.title")}</h4>
|
||||
<p className="rm-hint">{t("renovation.phases.hint")}</p>
|
||||
{phases.length === 0 && <div className="rm-empty">{t("renovation.phases.empty")}</div>}
|
||||
{phases.map((ph, i) => (
|
||||
<div className="rm-row" key={ph.id} data-testid="rm-renovation-phase">
|
||||
<input
|
||||
type="text"
|
||||
value={ph.name}
|
||||
aria-label={t("renovation.phase")}
|
||||
disabled={!setPhases}
|
||||
onChange={(e) => setPhases?.(phases.map((x) => (x.id === ph.id ? { ...x, name: e.target.value } : x)))}
|
||||
/>
|
||||
<button type="button" className="rm-icon-btn" disabled={!setPhases || i === 0} title={t("renovation.phases.up")} aria-label={t("renovation.phases.up")} onClick={() => move(i, -1)}>
|
||||
▲
|
||||
</button>
|
||||
<button type="button" className="rm-icon-btn" disabled={!setPhases || i === phases.length - 1} title={t("renovation.phases.down")} aria-label={t("renovation.phases.down")} onClick={() => move(i, 1)}>
|
||||
▼
|
||||
</button>
|
||||
<button type="button" className="rm-icon-btn" disabled={!setPhases} title={t("renovation.phases.remove")} aria-label={t("renovation.phases.remove")} onClick={() => setPhases?.(phases.filter((x) => x.id !== ph.id))}>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
<button
|
||||
type="button"
|
||||
className="rm-add-btn"
|
||||
disabled={!setPhases}
|
||||
data-testid="rm-renovation-add-phase"
|
||||
onClick={() => setPhases?.([...phases, { id: newPhaseId(project), name: t("renovation.phases.defaultName", { n: String(phases.length + 1) }) }])}
|
||||
>
|
||||
{t("renovation.phases.add")}
|
||||
</button>
|
||||
|
||||
<h4 className="rm-subhead">{t("renovation.styles.title")}</h4>
|
||||
<p className="rm-hint">{t("renovation.styles.hint")}</p>
|
||||
{RENOVATION_STATUSES.map((s) => {
|
||||
const d = DEFAULT_RENOVATION_STYLES[s];
|
||||
const own = styles[s] ?? {};
|
||||
return (
|
||||
<div className="rm-row" key={s} data-testid={`rm-renovation-style-${s}`}>
|
||||
<span className="rm-label">{t(`renovation.status.${s}` as TranslationKey)}</span>
|
||||
<label className="rm-inline">
|
||||
{t("renovation.styles.fill")}
|
||||
<input type="color" value={own.fill ?? d.fill} disabled={!setStyles} onChange={(e) => patchStyle(s, { fill: e.target.value })} />
|
||||
</label>
|
||||
<label className="rm-inline">
|
||||
{t("renovation.styles.line")}
|
||||
<input type="color" value={own.line ?? d.line ?? "#000000"} disabled={!setStyles} onChange={(e) => patchStyle(s, { line: e.target.value })} />
|
||||
</label>
|
||||
<label className="rm-inline">
|
||||
<input type="checkbox" checked={own.dashed ?? d.dashed} disabled={!setStyles} onChange={(e) => patchStyle(s, { dashed: e.target.checked })} />
|
||||
{t("renovation.styles.dashed")}
|
||||
</label>
|
||||
<button type="button" className="rm-icon-btn" disabled={!setStyles || !styles[s]} title={t("renovation.styles.reset")} aria-label={t("renovation.styles.reset")} onClick={() => patchStyle(s, null)}>
|
||||
↺
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -30,6 +30,7 @@ export type TopBarEvents = Required<
|
||||
| "onNewProjectFromSample"
|
||||
| "onNewProjectFromComplexSample"
|
||||
| "onNewProjectFromWettbewerbSample"
|
||||
| "onNewProjectFromUmbauSample"
|
||||
| "onNewProjectFromTemplate"
|
||||
| "onOpenProject"
|
||||
| "onSaveProject"
|
||||
@@ -133,6 +134,7 @@ export function useTopBarElements(opts: {
|
||||
onNewProjectFromSample={ev.onNewProjectFromSample}
|
||||
onNewProjectFromComplexSample={ev.onNewProjectFromComplexSample}
|
||||
onNewProjectFromWettbewerbSample={ev.onNewProjectFromWettbewerbSample}
|
||||
onNewProjectFromUmbauSample={ev.onNewProjectFromUmbauSample}
|
||||
onNewProjectFromTemplate={ev.onNewProjectFromTemplate}
|
||||
onOpenProject={ev.onOpenProject}
|
||||
onSaveProject={ev.onSaveProject}
|
||||
|
||||
@@ -621,15 +621,22 @@ export function Wasm3DViewport({
|
||||
const greyKey = (greyCodes ?? []).join("\u0001");
|
||||
const greyFloorsKey = (greyFloors ?? []).join("\u0001");
|
||||
const lockKey = (lockedCodes ?? []).join("\u0001");
|
||||
// [271] Umbaufilter der aktiven Ebene (wie im Grundriss): Ausgeblendetes fehlt, Bauteile in der Umbau-Farbe.
|
||||
const renKey = useStore((s) => {
|
||||
const l = s.project.drawingLevels.find((x) => x.id === s.activeLevelId);
|
||||
return l?.renovationFilter ? `${l.renovationFilter}\u0001${l.renovationPhase ?? ""}` : "";
|
||||
});
|
||||
const hide = useMemo<Hide3d>(() => {
|
||||
const split = (k: string) => (k ? k.split("\u0001") : []);
|
||||
const codes = split(hiddenKey);
|
||||
const floors = split(floorsKey);
|
||||
const dim = { grey: split(greyKey), lock: split(lockKey), greyFloors: split(greyFloorsKey) };
|
||||
return onlyIds || hiddenIds.length || floors.length || dim.grey.length || dim.lock.length || dim.greyFloors.length
|
||||
? toFilter3d({ only: onlyIds, hidden: hiddenIds }, codes, floors, dim)
|
||||
const [renovation, renovationPhase] = split(renKey);
|
||||
const ren = renovation ? { renovation, ...(renovationPhase ? { renovationPhase } : {}) } : {};
|
||||
return onlyIds || hiddenIds.length || floors.length || dim.grey.length || dim.lock.length || dim.greyFloors.length || renovation
|
||||
? { ...toFilter3d({ only: onlyIds, hidden: hiddenIds }, codes, floors, dim), ...ren }
|
||||
: codes;
|
||||
}, [hiddenKey, floorsKey, greyKey, greyFloorsKey, lockKey, onlyIds, hiddenIds]);
|
||||
}, [hiddenKey, floorsKey, greyKey, greyFloorsKey, lockKey, onlyIds, hiddenIds, renKey]);
|
||||
const hideRef = useRef(hide);
|
||||
hideRef.current = hide;
|
||||
// Versatz je Geschoss ([65]) für Griffe und gezogene Höhen (Modell bleibt unversetzt).
|
||||
|
||||
Reference in new issue
Block a user