[278] Nutzungseinheiten und Wohnungsspiegel: Project.units, Room.unitId/roomCount, Kern-Abfrage mit Zimmerzahl und SIA-416-Flächen, Panel, Objekt-Info, Blatt-Tabelle, CSV/PDF, CLI, Beispiel Wettbewerb
This commit is contained in:
38 files changed
+1445
-54
No files matched your search
@@ -10,7 +10,7 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `*
|
||||
stehen im Archiv („Bewusst nicht übernommen“).
|
||||
- **Grösse** (eine Person mit Agenten): S ≤ 1 Tag · M ≤ 1 Woche · L ≤ 1 Monat · XL > 1 Monat.
|
||||
Steht keine Grösse im Archiv, ist sie hier geschätzt.
|
||||
- **IDs sind stabil.** Neue ID = nächste freie Zahl nach der höchsten im Archiv und hier (aktuell 277);
|
||||
- **IDs sind stabil.** Neue ID = nächste freie Zahl nach der höchsten im Archiv und hier (aktuell 278);
|
||||
nie eine ID wiederverwenden oder umnummerieren. Präfix-IDs (`[K]`, `[G]`, `[T]`, `[B]`, `[C]`) bleiben.
|
||||
- **Pro Punkt:** was fehlt · wo im Code · Grösse. Höchstens ein bis drei Sätze je Punkt;
|
||||
Messwerte und Befunde gehören in den Commit.
|
||||
@@ -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
|
||||
- ◐ **[278]** Nutzungseinheiten und Wohnungsspiegel (17.11.; Lücke 6 in `doc/VERGLEICH-1.0.md`; Chromium/Linux, nicht in der Tauri-App/auf dem Mac geprüft): `Project.units` (`Unit`: Nummer, Typ, Nutzung Wohnen/Gewerbe/Büro/Andere, Farbe, Bemerkung), `Room.unitId`, `Room.roomCount`. Kern `unit_schedule.rs` (Annahmen im Modulkopf): je Einheit Geschoss(e), Typ (eingegeben oder „n-Zi-Whg“), Zimmerzahl, HNF/NNF/NF nach SIA 416, Aussenraum = Räume der Flächenart AGF, Summen je Typ und je Geschoss, Räume ohne Einheit getrennt. **Zimmerzahl (Annahme, nicht aus dem Namen geraten):** nur bei Wohnnutzung; Beitrag je Raum `roomCount`, sonst aus der Raumnutzung: Wohnen, Schlafen, Essen, Büro = 1, alles andere 0, nur bei Flächenart HNF; Wohnküche von Hand 0.5 (oder Wohnen/Essen 1.5). Maisonetten zählen in jedem Geschoss mit ihren Flächen. Abfrage `unitSchedule`, Blatt-Tabelle Quelle `unitSchedule`, Bericht/CSV/PDF (`buildAreaReport` mit `units`; der Nachweis-Export enthält ihn, eigene Knöpfe „Spiegel CSV/PDF“), CLI `kennzahlen --wohnungsspiegel` (ohne Option im JSON, sobald Einheiten da sind). Oberfläche: Panel Flächenbilanz „Nutzungseinheiten“ (`UnitsSection.tsx`: Liste, neue Einheit leer/aus Auswahl, Auswahl zuordnen, löschen), Objekt-Info Raum: Felder „Einheit“ (Auswahl, „Neue Einheit …“) und „Zimmer-Zählung“, Mehrfachauswahl = ein Undo-Schritt. Beispiel Wettbewerb: 6 Wohnungen (2-Zi und 2.5-Zi), Layout „Wohnungsspiegel“. Tests: Rust `unit_schedule::tests`, `sheet_table::wohnungsspiegel_tabelle`, `robustness`; vitest `unitSchedule.test.ts`; e2e `units278.spec.ts`. Bilder: `doc/review-278/`. **Offen:** Einheiten im Grundriss als farbige Fläche/Stempel auf eigener Klasse ([180]) fehlt (`Unit.color` ist schon da); Summen je Typ/Geschoss nicht als eigene Blatt-Tabelle; Mindestfläche für Zimmer und Wohnungs-Nettowohnfläche (NWF) nach kantonaler Definition nicht abgebildet; Einheit nicht in IFC/DXF-Export; im schmalen Dock wird der Spiegel als Karten gezeigt (wie die Flächentabelle) · M.
|
||||
- ◐ **[276]** Schnitt-/Ansichtslinie im Plan einstellbar (Wunsch Maintainer 17.11., „wie Archicad“; 17.11.). **Archicad** (Hilfe „Section/Elevation Marker“, Marker- und Marker-Head-Bereich der Schnitt-Einstellungen, Modellansicht-Option „Show Section and Elevation Markers“, [Quellen nur über die Suche gelesen, Feldnamen nicht je Version geprüft]): Marke an Anfang, Ende oder beiden Enden bzw. eine in der Mitte, Markentyp und Symbol, Linientyp und Stift der Linie, Beschriftung. **Übernommen (schlank):** je Schnitt- und Ansichtslinie `lineMode` (full | ends | none), `endLengthMm`, `lineStyleId` (Linientyp), `linePenId` (Stift des aktiven Stiftsatzes: Farbe + Stärke), `marker` (arrow | lAngle | triangle | none; Ansicht: triangle | arrow | none), `markerAt` (both | start | end, nur Schnitt), `markerLabel`; Vorgabe getrennt für Schnitte (`sectionMarks`) und Ansichten (`elevationMarks`) in der Modelldarstellung (Ebene > Modelldarstellung des gezeigten Plans > Basis), dort ohne Linientyp/Stift (Auswahl nur feste Werte). `markerStyle`/`sectionMarks.style` gehen darin auf; Basis = heutiges Bild (Goldens unverändert): Schnitt = dünne Strichpunktlinie mit kräftigen Endstücken + Pfeile + Beschriftung, Ansicht = nur Dreieck + Beschriftung. Ansichtslinie wird jetzt auf Wunsch gezeichnet und ist dann anwählbar. Der frühere L (`lAngle`) heisst jetzt `lineMode: ends` + `marker: lAngle`. Kern: `plan/misc.rs` (`SectionLook`, `section_polyline_look`, `view_symbol`, `view_line_parts`), `plan/model_view.rs::mark_look`, `plan/context.rs` (Linientyp/Stift, Beschriftung nur an markierten Enden, Ausweichen [270] und Knicke [176] unverändert). Oberfläche: `SectionLookFields.tsx` in der Objekt-Info (Symbol-Knöpfe mit Vorschau; Mehrfachauswahl ändert alle gewählten Linien in einem Undo-Schritt), Ressourcen > Modelldarstellung (Schnitt- und Ansichtsmarken). Tests: Rust `misc::darstellung_varianten`, `ansicht_zeichen_und_linie`, `context::schnittlinie_varianten_im_grundriss`, `schnittlinie_linientyp_und_stift`, `ansichtslinie_varianten`; vitest `SectionLookFields.test.ts`; e2e `sectionLook276.spec.ts`. Bilder: `doc/review-276/`. **Offen:** nicht in der Tauri-App/auf dem Mac geprüft (nur CLI-SVG in Chromium und Browser-Build); Linientyp/Stift in der Modelldarstellung wählbar machen (dynamische Werte); Marke „Kreis mit Pfeil“ für Ansichten; Marken-Versatz wie bei Archicad (Symbol unabhängig von der Schnittlinie verschieben) · S.
|
||||
- ◐ **[271]** Umbaufilter wie Archicad (Wunsch Maintainer 17.11.). **Modell:** `renovation: {status: existing|demolish|new, phase?}` an Wand, Öffnung (ohne eigenen Status folgt sie der Wand), Decke, Dach, Treppe, Stütze, Körper und Raum (Raum nur Sichtbarkeit/Flächen, keine Farbe — kein Bauteil); `Project.renovation` (Etappen, Farben, eigene Filter); `DrawingLevel`/`ViewTemplate`/`ViewSnapshot.renovationFilter`+`renovationPhase` (der Filter gehört zur Ebene wie die Modelldarstellung [173], damit je Reiter/Ausschnitt/Vorlage). **Kern** `renovation.rs` (ein Ort, `doc/ARCHITEKTUR.md` 3.8): Vorgaben Bestand/Abbruch/Neubau/Umbauplan/Endzustand, SIA-400-Farben (Bestand grau, Abbruch gelb gestrichelt, Neu rot, anpassbar), Etappen „bis n“ (Neues früherer Etappen = Bestand, Abbruch früherer weg, spätere Neue fehlen), Öffnung neu in Bestandswand = Abbruch-Stück bzw. zugemauerte Öffnung = Ausfachung (Wand zu, wo die Öffnung ausgeblendet ist). Umbau-Farben bleiben auch in Tusche (Schwarz-Weiss, `extras::KeepColors`); gefüllt werden nur Schnittflächen (Wand, Stütze), Symbole (Fenster, Türflügel, Tritte) nur in Linienfarbe. Angebunden: Grundriss, Schnitt, Ansicht, Vektor-Axo, 3D-Fenster (Filter der aktiven Ebene) und `model3d`, Kennzahlen/Flächen (Zustand Bestand/Endzustand im Panel), DXF (Layer `<Klasse>_Abbruch`/`_Neu`), IFC (`Status` NEW/EXISTING/DEMOLISH im `Pset_*Common`, Etappe in `Dossier_Umbau`). **Bedienung:** Objekt-Info/Objekteinstellungen „Umbau“ + „Etappe“ (Mehrfachauswahl, ein Undo-Schritt), Statusleiste „Umbau: …“ (Zeichen-Status neuer Bauteile, Vorgabe Bestand, Kern `commands::stamp_renovation`; Umbaufilter und Etappe der Ansicht; mit der Pausfolie im Überlauf „⋯“), Befehl `umbau` (B/A/N; die Befehlszeile nimmt getippte Options-Kürzel jetzt auch mit Enter an, `engine.ts`), Ressourcen-Tab „Umbau“ (Etappen, Farben), Vorlage „Beispiel Umbau“ (`model/sampleProjectUmbau.ts`, CLI `:umbau`), CLI `--renovation`/`--phase` (plan, section, elevation, axo, model3d, kennzahlen). Tests: Kern `renovation_tests.rs` (19), Robustheit, vitest `model/renovation.test.ts`, `commands/cmds/renovation.test.ts`, e2e `renovation271.spec.ts` (2× grün, Port 5195; dazu `uxReview263`, `objectSettings`, `modelViews`, `release10`, `editing` grün); Bilder `doc/review-271/` (CLI-SVG `--hatch` in Chromium, App-Screenshot). **Offen:** 3D-Fenster nur im Code angebunden (Kern-Teile per Test geprüft, Bild nicht angesehen: kein render3d unter Linux); Blender-Paket ohne Umbau-Farben (nur Ausblenden); Ansichtsleiste/Werkzeugleiste ohne eigene Filter-Wahl (Statusleiste und Panel Umbau); eigene Filter nur im Modell (keine Bearbeitung in der Oberfläche); Tauri/Mac nicht geprüft (Prüfschritt `doc/RELEASE-1.0.md` 13.37). **Nachtrag 17.11. (Panel):** eigenes Dock-Panel „Umbau“ (`panels/RenovationPanel.tsx`, Reiter rechts oben neben Objekt-Info/Flächenbilanz, Layout v16): Zeichen-Status Bestand/Abbruch/Neu mit SIA-Farbmuster + Etappe, Umbaufilter der aktiven Ansicht als Liste mit Vorschau je Status (wie gezeichnet/ausgeblendet/Umbau-Farbe) + „bis Etappe“, Status der Auswahl (gemischt-Marke) mit Setzen und Etappe (ein Undo-Schritt), „Nach Status wählen“ (Geschoss), Etappenliste (anlegen, umbenennen, Reihenfolge, Löschen mit Rückfrage über `ui/ConfirmDialog`, Verweis auf die Farben in den Ressourcen). Statusleisten-Popover und Objekt-Info teilen Zustand und Aktionen mit dem Panel (`state/renovationHook.ts`, keine Doppelspur) und lesen nur schmale Teile des Projekts: behebt die 45 Renders je Wand-Änderung in `renderCount.spec.ts` (jetzt 42, Grenze unverändert; `RenovationField` ist `memo`). Filter-Vorschau der eingebauten Filter spiegelt `renovation::builtin` in `model/renovation.ts` (vitest prüft gegen den Plan des Kerns; sauberer wäre, die Anteile in `filter_list` mitzuliefern). Tests: vitest `model/renovation.test.ts` (+3), e2e `renovationPanel271.spec.ts` (Port 5193); Bild `doc/review-271/05-panel-umbau.png`. Nicht geprüft: Tauri/Mac. **Offen:** Panel-Bild nur hell/1280×800 angesehen (dunkel ebenfalls ok, schmale Leiste nicht eigens). **Nachtrag 17.11. (Exporte und Rendering folgen der Ansicht, mit [272]):** neue gemeinsame Ansicht `export/exportView.ts` (`levelExportView` = Umbaufilter, Etappe und Variantenkombination der aktiven Ebene; `exportViewText` = Text der Kern-Abfragen, `renovation::view_from_text`), die EIN Weg für IFC (`exportIfcSpf({view})`), OBJ/STL/glTF (`MeshOptions.view`), STEP (`exportProjectStep(…, view)`), Blender-Paket (`RenderOptions.view`) und Cycles-Szene ist. Ausgeblendetes fehlt dort; die Cycles-Szene malt Umbau-Farben nur auf Wunsch (Option `renovationColors`, `cycles_scene_styled`; Vorgabe Materialfarben). App: Export-Dialog (IFC, OBJ, STL, glTF, STEP) und Rendering-Dialog zeigen die Ansicht der aktiven Ebene („Umbau: …“, „Variante: …“) und lassen „Hauptvarianten/kein Filter“ wählen; Rendering mit Cycles hat das HäkchenLine truncated
|
||||
- ◐ **[274]** Umbau je Schicht: Sanierung mehrschichtiger Bauteile (Feedback Maintainer 17.11., typbasiert nach Rückfrage). **Modell:** `WallType.renovationTarget` (Sanierungstyp), `renovationSide` (Bezugsseite innen/aussen), `renovationOld`/`renovationNew` (manuelle Zuordnung je Schicht, Vorgabe „auto“); Wand `renovation.renovated` (nutzt den Sanierungstyp ihres Typs) bzw. `renovation.newTypeId` (Ausnahme); wirkt nur beim Status Bestand, Etappe = `renovation.phase`; ohne Umbaufilter gilt der Bestandstyp. **Kern** `renovation::build_up` (ein Ort, `doc/ARCHITEKTUR.md` 3.8): Zuordnung von der Bezugsseite her (gleicher Baustoff + Dicke + Lage = Bestand, nur alt = Abbruch, nur neu = Neu; manuell überschreibbar, weil z. B. ein ersetzter Baustoff gleicher Dicke sonst als Bestand gälte; das automatisch gepaarte Gegenstück folgt), gezeigter Aufbau je Filter (Abbruch sichtbar ⇒ alt, Neu sichtbar ⇒ neu, beide ⇒ überlagert in Teilschichten), Ersatzwand mit Ersatztyp und Achsversatz (Bezugsseite bleibt stehen, Achse bleibt) für Grundriss, Schnitt, Ansicht, Axo, 3D, Kennzahlen/GF, IFC-Schichten; Farben je Schicht (Grundriss über die Schicht-Aktionen [33], Kanten der Abbruch-Schichten gestrichelt, im Umbauplan Abbruch als gelbe gestrichelte Kontur über der roten Füllung; Schnitt je Schnittfläche; Ansicht/Axo/3D Farbe der äussersten Schicht); Öffnungsleibungen folgen dem gezeigten Aufbau. Abfragen `renovationPair`/`renovationPairs`. **Bedienung:** Objekt-Info/Objekteinstellungen „Neuer Aufbau (Sanierung)“ (keiner / wie Typ / anderer Wandtyp; Mehrfachauswahl ein Undo-Schritt) mit Streifen Alt/Neu/Ergebnis in SIA-Farben (`ui/RenovationStrip.tsx`); Umbau-Panel Abschnitt „Sanierung“ (`panels/RenovationSanierung.tsx`): Zähler „Sanierte Bauteile“, Typ-Paare mit „x von n Wänden saniert“, „Alle Wände vom Typ sanieren“ (ein Undo-Schritt), „Sanierungstyp anlegen …“ (Kopie des Bestandstyps), Typ-Paar-Editor (Alt/Neu nebeneinander, Zuordnung je Schicht, Bezugsseite, Ergebnis-Streifen). Status/Etappe setzen und Etappe löschen behalten die Sanierung. Beispiel Umbau: Südwand W1 Beton 20 + Dämmung 10 + Putz → Dämmung 20 + Putz (Etappe 1), neuer Schnitt C durch die Wand. Tests: Kern `renovation_layers_tests.rs` (11: Zuordnung inkl. gleicher Baustoff andere Dicke, vertauscht, Bezugsseite aussen, manuell, NaN/leer/fehlender Typ; Grundriss und Schnitt je Filter; Kennzahlen je Zustand; Öffnung; 3D/Ansicht; Umstellen idempotent; Abfragen), vitest `model/renovationLayers.test.ts`, e2e `renovation274.spec.ts` (2× grün, Port 5195; dazu `renovation271`, `renovationPanel271`, `objectSettings`, `renderCount` 2× grün, Renders je Wand-Änderung 43 bei unveränderter Grenze); Bilder `doc/review-274/` (CLI-SVG `--hatch` Grundriss 1:50/1:100 und Schnitt C in allen fünf Filtern, Chromium; App-Screenshots Feld und Panel). **Offen:** Decken und Dächer ohne Sanierung je Schicht (Modell-Felder nur am Wandtyp); Bogenwände ohne gestrichelte Abbruch-Kanten (Füllung je Schicht ja); im Schnitt Abbruch-Kontur schwarz gestrichelt statt gelb, Aussenkante der Abbruch-Schicht unter der schweren Schnittkante durchgezogen (wie [271]); 3D/Ansicht nur Farbe der äussersten Schicht (Teile je Schicht im 3D wären möglich), 3D-Bild nicht angesehen; IFC: Endzustand-Aufbau als Materialschichten über die Ersatzwand (Weg wie Kennzahlen, nicht eigens geprüft), kein Status je Schicht als Eigenschaft; DXF: Schichten nicht auf eigenen Umbau-Layern (Wand-Layer nach Wand-Status); Instanz-Schichtliste (eigene Schichten je Wand) bewusst nicht, nur anderer Typ als Ausnahme; Achse auf der bewegten Seite bei dünnerem neuem Aufbau bleibt in der Wand (Bezugsseite verschiebt sich dann); Tauri/Mac nicht geprüft (Prüfschritt `doc/RELEASE-1.0.md` 13.39). **Zusammenführung mit [271]-Rest (17.11.):** sanierte Wände zeigen auch die Projektionslinien des Schnitts in der Farbe ihrer äussersten Schicht (`CutRules::edge` über `Resolved::faces`); die Ersatzstücke der Öffnungen in Schnitt und Ansicht rechnen aus dem Projekt mit allem, aber mit dem gezeigten Aufbau (`renovation::apply` ohne Ausgeblendetes); Beispiel `:umbau` vereint Südwand W1/Schnitt C mit Möbeln, Bäumen und Ansicht West. · M
|
||||
|
||||
@@ -128,6 +128,16 @@ Auf der Kommandozeile: `node dist-cli/dossier-cli.mjs :wettbewerb kennzahlen --n
|
||||
über ±0.00 (Näherung), die Grünfläche gilt nur, wenn du sie eingibst. Die **Kostenschätzung grob** (eBKP-H, CHF/m³ GV oder CHF/m² GF) steht im
|
||||
selben Panel und lässt sich als Tabelle auf ein Blatt legen.
|
||||
|
||||
**Nutzungseinheiten und Wohnungsspiegel.** Im Panel **Flächenbilanz** steht unter dem Nachweis der Abschnitt „Nutzungseinheiten und
|
||||
Wohnungsspiegel“. Räume wählen und **Neue Einheit aus Auswahl** legt eine Wohnung an (oder in der Objekt-Info des Raums das Feld
|
||||
**Einheit**, bei Mehrfachauswahl für alle gewählten Räume in einem Undo-Schritt). Nummer (z. B. 2.1), Typ und Nutzung (Wohnen, Gewerbe, Büro)
|
||||
trägst du in der Liste ein; die Zimmerzahl rechnet Dossier nach Schweizer Zählweise: Wohnen, Schlafen, Essen und Büro zählen 1, Küche,
|
||||
Bad, Diele, Abstellraum 0, je Raum einstellbar (**Zimmer-Zählung** in der Objekt-Info, z. B. 0.5 für eine Wohnküche); ohne eigenen Typ
|
||||
heisst die Wohnung z. B. 3.5-Zi-Whg. Der Spiegel zeigt je Einheit Geschoss, Typ, Zimmer, HNF, NNF, NF und Aussenraum (Räume der Flächenart AGF,
|
||||
Balkon/Loggia), dazu die Summe je Typ und je Geschoss; „Spiegel CSV“ und „Spiegel PDF“ und die Blatt-Tabelle „Wohnungsspiegel“ geben dasselbe aus,
|
||||
der Nachweis-Export enthält ihn ebenfalls. Auf der Kommandozeile: `dossier-cli :wettbewerb kennzahlen --wohnungsspiegel` (auch mit
|
||||
`--format csv|pdf|svg`; die Kennzahlen ohne Option nennen ihn, sobald das Projekt Einheiten hat).
|
||||
|
||||
## 7. Pläne 1:200
|
||||
|
||||
In der Kopfleiste den **Massstab** wählen (Papier-Massstab 1:N anwenden), z. B. 1:200 für den Wettbewerb und 1:100
|
||||
|
||||
@@ -58,7 +58,7 @@ Grösse: S ≤ 1 Tag · M ≤ 1 Woche · L ≤ 1 Monat. IDs aus `TODO.md`; **neu
|
||||
|
||||
| # | Lücke | Wo / ID | Grösse |
|
||||
|---|---|---|---|
|
||||
| 6 | **Wohnungsspiegel / Nutzungseinheiten**: Räume lassen sich keiner Wohnung zuordnen; kein Spiegel (Zimmerzahl, NWF je Wohnung) — im Mehrfamilienhaus-WBW üblich. **neu** | `Room` (nur `usage`, `siaCategory`), `flaechen.rs`, `RoomBookSection` | M |
|
||||
| 6 | **Wohnungsspiegel / Nutzungseinheiten**: Räume lassen sich keiner Wohnung zuordnen; kein Spiegel (Zimmerzahl, NWF je Wohnung) — im Mehrfamilienhaus-WBW üblich. **erledigt 17.11. ([278], Rest: Grundriss-Darstellung der Einheiten)** | `unit_schedule.rs`, `UnitsSection` | M |
|
||||
| 7 | **Geländer als eigenes Bauteil** (Balkon/Loggia/Absturzsicherung in Plan, Schnitt, Ansicht, 3D); heute nur Wand-/2D-Behelf. **neu** | Modell `Stair.railProfile`/`stairs3d::RailSpec` als Ausgangspunkt, `cmds/` | M |
|
||||
| 8 | **Geneigte Decke / Rampe** (Tiefgarage, Terrassen mit Gefälle): `Ceiling` hat nur Ober-/Unterkante, keine Neigung; Behelf Pultdach/Körper. **neu** | `Ceiling`, `ceiling_item` (`cmd_create.rs`), `plan/section` | M |
|
||||
| 9 | **Träger/Unterzug/Fassadenträger**: kein Element (Behelf Körper/Wand), Deckenspiegel mit Unterzügen fehlt. **neu**, [100] nennt die Lücke | `columns` als Muster | M |
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 231 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 239 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 142 KiB |
@@ -0,0 +1,54 @@
|
||||
// [278] Nutzungseinheiten und Wohnungsspiegel: Beispiel Wettbewerb öffnen, Liste und Spiegel im Panel Flächenbilanz,
|
||||
// Räume einer Einheit zuordnen (Objekt-Info, Mehrfachauswahl = ein Undo), Spiegel als Tabelle auf dem Layout.
|
||||
// Geprüft über UI-Text und Zahlen, nicht über Pixel; Screenshots für die Sichtprüfung in `test-results/`.
|
||||
import { discardIfAsked, expect, fileMenu, openTab, test } from "./app";
|
||||
|
||||
test("Wohnungsspiegel: Liste, Zuordnen mit Undo, Objekt-Info, Tabelle auf dem Layout ([278])", 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: Wettbewerb$/);
|
||||
await discardIfAsked(page);
|
||||
await expect(page.locator(".project-name")).toContainText("Wettbewerb");
|
||||
|
||||
// Panel Flächenbilanz: sechs Einheiten, Spiegel mit Typen und Summen.
|
||||
await openTab(page, "Flächenbilanz");
|
||||
const units = page.getByTestId("units-section");
|
||||
await expect(units).toBeVisible();
|
||||
await expect(units.getByTestId("unit-row")).toHaveCount(6);
|
||||
await expect(units.locator(".area-table").first()).toContainText("2.5-Zi-Whg");
|
||||
await expect(units.locator(".area-table").first()).toContainText("1. Obergeschoss");
|
||||
await units.evaluate((el) => el.scrollIntoView({ block: "start" }));
|
||||
await page.screenshot({ path: "test-results/units278-spiegel.png" });
|
||||
await units.locator(".area-block").first().evaluate((el) => el.scrollIntoView({ block: "start" }));
|
||||
await page.screenshot({ path: "test-results/units278-spiegel-tabelle.png" });
|
||||
|
||||
// Zwei Räume wählen → „Neue Einheit aus Auswahl“: eine Einheit mehr, ein Undo-Schritt.
|
||||
await page.evaluate(() => window.__dossierTest!.select({ rooms: ["raum-E.09", "raum-1.09"] }));
|
||||
await units.getByRole("button", { name: "Neue Einheit aus Auswahl" }).click();
|
||||
await expect(units.getByTestId("unit-row")).toHaveCount(7);
|
||||
await page.keyboard.press("ControlOrMeta+z");
|
||||
await expect(units.getByTestId("unit-row")).toHaveCount(6);
|
||||
|
||||
// Objekt-Info eines Raums: Feld „Einheit“ zeigt die Wohnung, Wechsel auf „Neue Einheit …“.
|
||||
await page.evaluate(() => window.__dossierTest!.select({ rooms: ["raum-E.01"] }));
|
||||
await openTab(page, "Objekt-Info");
|
||||
const info = page.locator(".objinfo-panel");
|
||||
await expect(info.getByText("Nutzungseinheiten und Wohnungsspiegel")).toBeVisible();
|
||||
const field = info.locator(".objinfo-field").filter({ hasText: /^Einheit/ });
|
||||
await expect(field).toContainText("0.1");
|
||||
await field.scrollIntoViewIfNeeded();
|
||||
await info.screenshot({ path: "test-results/units278-objektinfo.png" });
|
||||
await field.getByRole("button").first().click();
|
||||
await page.getByRole("option", { name: "Neue Einheit …" }).click();
|
||||
await expect(field).toContainText("Whg 7");
|
||||
await page.keyboard.press("ControlOrMeta+z");
|
||||
await expect(field).toContainText("0.1");
|
||||
|
||||
// Layout „Wohnungsspiegel“ (Mappe): Tabelle folgt dem Modell.
|
||||
await openTab(page, "Mappe");
|
||||
await page.locator(".nav-row", { hasText: "Wohnungsspiegel" }).first().dblclick();
|
||||
await expect(page.locator(".layout-sheet-pane")).toBeVisible();
|
||||
await expect(page.locator(".layout-sheet-pane")).toContainText("2.5-Zi-Whg");
|
||||
await page.screenshot({ path: "test-results/units278-layout.png" });
|
||||
});
|
||||
@@ -103,6 +103,7 @@ Neues Modul: `<modul>.rs` und `mod` in `lib.rs`, Bindungen in `web/<modul>.rs` u
|
||||
| `kennzahlen.rs`, `flaechen.rs`, `area_report.rs` | Kennzahlen und Flächennachweise nach SIA 416 |
|
||||
| `kosten.rs` | Kostenschätzung grob nach Kennwerten je eBKP-H-Hauptgruppe, Mengen aus `flaechen.rs` ([209]) |
|
||||
| `room_program.rs`, `room_book.rs` | Raumprogramm (Soll/Ist), Raumbuch |
|
||||
| `unit_schedule.rs` | Wohnungsspiegel: Nutzungseinheiten (`Project.units`, `Room.unitId`) mit Geschoss, Typ, Zimmerzahl, Flächen SIA 416, Summen je Typ/Geschoss ([278]) |
|
||||
| `u_value.rs`, `clash_broad.rs` | U-Wert aus dem Schichtaufbau; Vorstufe der Kollisionsprüfung |
|
||||
|
||||
## Import und Export
|
||||
|
||||
@@ -8,6 +8,7 @@ pub mod competition;
|
||||
pub mod export_schedule;
|
||||
pub mod opening_schedule;
|
||||
pub mod room_book;
|
||||
pub mod unit_schedule;
|
||||
pub mod u_value;
|
||||
pub mod sheet_table;
|
||||
pub mod terrain;
|
||||
|
||||
@@ -4904,6 +4904,62 @@ pub struct Room {
|
||||
#[serde(rename = "designOption", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub design_option: Option<DesignOptionRef>,
|
||||
/// [278] Nutzungseinheit (`Project.units`, Id), zu der der Raum gehört (Wohnung, Gewerbeeinheit). Fehlt oder
|
||||
/// unbekannt ⇒ keiner Einheit zugeordnet (Gemeinschaftsfläche).
|
||||
#[serde(rename = "unitId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub unit_id: Option<String>,
|
||||
/// [278] Zimmerzahl-Beitrag dieses Raums für den Wohnungsspiegel (CH-Konvention: Zimmer 1, Wohnküche/halbes Zimmer 0.5,
|
||||
/// Nebenraum 0). Fehlt ⇒ Vorgabe aus der Nutzung (`unit_schedule::default_room_count`).
|
||||
#[serde(rename = "roomCount", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub room_count: Option<f64>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// [278] Nutzung einer Nutzungseinheit.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
|
||||
pub enum UnitUsage {
|
||||
#[default]
|
||||
#[serde(rename = "living")]
|
||||
Living,
|
||||
#[serde(rename = "commercial")]
|
||||
Commercial,
|
||||
#[serde(rename = "office")]
|
||||
Office,
|
||||
#[serde(rename = "other")]
|
||||
Other,
|
||||
#[serde(other)]
|
||||
#[ts(skip)]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// [278] Nutzungseinheit (Wohnung, Gewerbe-, Büroeinheit): fasst Räume für den Wohnungsspiegel zusammen. Die Räume
|
||||
/// verweisen mit `Room.unitId` auf sie; Fläche, Geschoss und Zimmerzahl rechnet der Kern aus den Räumen.
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct Unit {
|
||||
pub id: String,
|
||||
/// Nummer/Bezeichnung, z. B. „2.1“.
|
||||
pub name: String,
|
||||
/// Typ, z. B. „3.5-Zi-Whg“. Fehlt er, leitet der Spiegel bei Wohnungen „n-Zi-Whg“ aus der Zimmerzahl ab.
|
||||
#[serde(rename = "unitType", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub unit_type: Option<String>,
|
||||
/// Nutzung (Fehlt ⇒ Wohnen).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub usage: Option<UnitUsage>,
|
||||
/// Farbe der Einheit (hex) für Darstellungen.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub color: Option<String>,
|
||||
/// Bemerkung (reiner Text).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub note: Option<String>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -6197,6 +6253,9 @@ pub enum LayoutTableSource {
|
||||
/// [272] Variantenvergleich: Kennzahlen und Kosten je gespeicherte Variantenkombination.
|
||||
#[serde(rename = "designOptionCompare")]
|
||||
DesignOptionCompare,
|
||||
/// [278] Wohnungsspiegel (Nutzungseinheiten mit Geschoss, Typ, Zimmer, Flächen).
|
||||
#[serde(rename = "unitSchedule")]
|
||||
UnitSchedule,
|
||||
#[serde(other)]
|
||||
#[ts(skip)]
|
||||
Unknown,
|
||||
@@ -7068,6 +7127,10 @@ pub struct Project {
|
||||
#[serde(rename = "designOptionCombinations", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub design_option_combinations: Option<Vec<DesignOptionCombination>>,
|
||||
/// [278] Nutzungseinheiten (Wohnungen, Gewerbe) für den Wohnungsspiegel; Räume verweisen mit `unitId` darauf.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub units: Option<Vec<Unit>>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -7965,6 +8028,12 @@ impl Project {
|
||||
None => Default::default(),
|
||||
};
|
||||
}
|
||||
"units" => {
|
||||
self.units = match v {
|
||||
Some(v) => <Option<Vec<Unit>>>::deserialize(v).map_err(|e| e.to_string())?,
|
||||
None => Default::default(),
|
||||
};
|
||||
}
|
||||
other => match v {
|
||||
Some(v) => {
|
||||
self.extra.0.insert(other.to_owned(), v.clone());
|
||||
|
||||
@@ -28,6 +28,7 @@ pub const NOT_FOR_DRAWINGS: &[&str] = &[
|
||||
"roofs",
|
||||
"stairs",
|
||||
"rooms",
|
||||
"units",
|
||||
"columns",
|
||||
"trees",
|
||||
"cameras",
|
||||
|
||||
@@ -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; 62] = [
|
||||
const KNOWN_KEYS: [&str; 63] = [
|
||||
"formatVersion", "id", "name", "lineStyles", "textStyles", "hatches", "components", "wallTypes",
|
||||
"ceilingTypes", "roofTypes", "blockDefs", "doorTypes", "windowTypes", "stairTypes", "pens",
|
||||
"penSets", "activePenSetId", "customPalettes", "builtinPaletteBanks", "drawingLevels", "layers",
|
||||
@@ -29,6 +29,7 @@ const KNOWN_KEYS: [&str; 62] = [
|
||||
"renovation",
|
||||
"designOptionSets",
|
||||
"designOptionCombinations",
|
||||
"units",
|
||||
];
|
||||
|
||||
/// Ergebnis des Einlesens.
|
||||
|
||||
@@ -89,6 +89,15 @@ pub fn run(p: &Project, name: &str, args: &[f64], text: &str) -> Result<String,
|
||||
// [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))),
|
||||
// [278] Wohnungsspiegel (Nutzungseinheiten); mit `text` = `{"head": [...]}` als CSV.
|
||||
("unitSchedule", _) => {
|
||||
let v: serde_json::Value = serde_json::from_str(text).unwrap_or_default();
|
||||
let sched = crate::unit_schedule::unit_schedule(&options_state(p, text));
|
||||
match v.get("head").and_then(|h| h.as_array()) {
|
||||
Some(h) => json(&crate::unit_schedule::schedule_csv(&sched, &h.iter().filter_map(|x| x.as_str().map(String::from)).collect::<Vec<_>>())),
|
||||
None => json(&sched),
|
||||
}
|
||||
}
|
||||
// [271] Umbaufilter (eingebaute und eigene) für die Oberfläche.
|
||||
("renovationFilters", _) => json(&crate::renovation::filter_list(p)),
|
||||
// [275] Aufgelöste Umbau-Farben (Vorgabe, Projekt, Etappen) für Muster in der Oberfläche.
|
||||
|
||||
@@ -444,7 +444,7 @@ pub struct RoomBook {
|
||||
}
|
||||
|
||||
/// Raumnummern natürlich vergleichen („1.2" vor „1.10").
|
||||
fn natural_cmp(a: &str, b: &str) -> std::cmp::Ordering {
|
||||
pub(crate) fn natural_cmp(a: &str, b: &str) -> std::cmp::Ordering {
|
||||
let split = |s: &str| -> Vec<(bool, String)> {
|
||||
let mut out: Vec<(bool, String)> = Vec::new();
|
||||
for ch in s.chars() {
|
||||
|
||||
@@ -158,6 +158,21 @@ const DESIGN_OPTION_COMPARE: &[Col] = &[
|
||||
c("cost", "designOption.compare.cost", 1.9, true, true),
|
||||
];
|
||||
|
||||
/// [278] Wohnungsspiegel: eine Zeile je Nutzungseinheit, Summenzeile am Ende.
|
||||
const UNITS: &[Col] = &[
|
||||
c("name", "units.col.name", 1.1, false, true),
|
||||
c("floor", "openings.col.floor", 1.8, false, true),
|
||||
c("type", "units.col.type", 2.0, false, true),
|
||||
c("usage", "units.col.usage", 1.6, false, false),
|
||||
c("rooms", "units.col.rooms", 1.1, true, true),
|
||||
c("hnf", "sheetTable.col.hnf", 1.2, true, true),
|
||||
c("nnf", "sheetTable.col.nnf", 1.2, true, false),
|
||||
c("nf", "sheetTable.col.nf", 1.2, true, true),
|
||||
c("outdoor", "units.col.outdoor", 1.4, true, true),
|
||||
c("roomCount", "sheetTable.col.roomCount", 1.1, true, false),
|
||||
c("note", "units.col.note", 2.4, false, false),
|
||||
];
|
||||
|
||||
/// [158] Raumbuch-Spalten, die nur erscheinen, wenn ein Raum eine Dachschräge hat.
|
||||
const SLOPE_COLS: &[&str] = &["heightMin", "heightMean", "areaUnder1", "area1To15"];
|
||||
|
||||
@@ -192,6 +207,10 @@ pub const VALUE_KEYS: &[&str] = &[
|
||||
"roomBook.usage.office",
|
||||
"roomBook.usage.other",
|
||||
"roomBook.wet",
|
||||
"units.usage.living",
|
||||
"units.usage.commercial",
|
||||
"units.usage.office",
|
||||
"units.usage.other",
|
||||
"costs.group.B",
|
||||
"costs.group.C",
|
||||
"costs.group.D",
|
||||
@@ -233,6 +252,7 @@ pub fn catalog(source: LayoutTableSource) -> &'static [Col] {
|
||||
LayoutTableSource::Costs => COSTS,
|
||||
LayoutTableSource::SiteProof => SITE_PROOF,
|
||||
LayoutTableSource::DesignOptionCompare => DESIGN_OPTION_COMPARE,
|
||||
LayoutTableSource::UnitSchedule => UNITS,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,7 +260,7 @@ pub fn catalog(source: LayoutTableSource) -> &'static [Col] {
|
||||
pub fn catalog_json() -> Value {
|
||||
let one = |s: &[Col]| s.iter().map(|k| json!({"id": k.id, "key": k.key, "numeric": k.numeric, "default": k.default})).collect::<Vec<_>>();
|
||||
json!({
|
||||
"sources": {"openings": one(OPENINGS), "areas": one(AREAS), "rooms": one(ROOMS), "elements": one(ELEMENTS), "earthworks": one(EARTHWORKS), "roomBook": one(ROOM_BOOK), "costs": one(COSTS), "siteProof": one(SITE_PROOF), "designOptionCompare": one(DESIGN_OPTION_COMPARE)},
|
||||
"sources": {"openings": one(OPENINGS), "areas": one(AREAS), "rooms": one(ROOMS), "elements": one(ELEMENTS), "earthworks": one(EARTHWORKS), "roomBook": one(ROOM_BOOK), "costs": one(COSTS), "siteProof": one(SITE_PROOF), "designOptionCompare": one(DESIGN_OPTION_COMPARE), "unitSchedule": one(UNITS)},
|
||||
"valueKeys": VALUE_KEYS,
|
||||
})
|
||||
}
|
||||
@@ -379,6 +399,7 @@ fn data_of(p: &Project, t: &LayoutTable, lb: &Labels) -> Data {
|
||||
LayoutTableSource::Costs => costs_data(p, lb),
|
||||
LayoutTableSource::SiteProof => site_proof_data(p, lb),
|
||||
LayoutTableSource::DesignOptionCompare => design_option_compare_data(p),
|
||||
LayoutTableSource::UnitSchedule => unit_schedule_data(p, lb),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,6 +462,38 @@ fn costs_data(p: &Project, lb: &Labels) -> Data {
|
||||
Data { rows, sloped: false, total_last: true }
|
||||
}
|
||||
|
||||
/// [278] Wohnungsspiegel: eine Zeile je Nutzungseinheit (Nummer, Geschoss, Typ, Nutzung, Zimmer, HNF, NNF, NF, Aussenraum,
|
||||
/// Zimmerzahl-Spalte „roomCount“ = Zahl der Räume), Summenzeile mit Zahl der Einheiten im Typ-Feld. Ohne Einheiten leer.
|
||||
fn unit_schedule_data(p: &Project, lb: &Labels) -> Data {
|
||||
let s = crate::unit_schedule::unit_schedule(p);
|
||||
if s.units.is_empty() {
|
||||
return Data { rows: vec![], sloped: false, total_last: false };
|
||||
}
|
||||
let dash = || txt("–");
|
||||
let mut rows: Vec<Vec<Cell>> = s
|
||||
.units
|
||||
.iter()
|
||||
.map(|u| {
|
||||
vec![
|
||||
txt(u.name.clone()),
|
||||
txt(u.floors.join(", ")),
|
||||
txt(u.type_label.clone()),
|
||||
txt(lb.get(&format!("units.usage.{}", u.usage))),
|
||||
if u.usage == "living" { num(u.room_count, 1) } else { dash() },
|
||||
num(u.areas.hnf, 2),
|
||||
num(u.areas.nnf, 2),
|
||||
num(u.areas.nf, 2),
|
||||
num(u.areas.agf, 2),
|
||||
num(u.rooms as f64, 0),
|
||||
txt(u.note.clone()),
|
||||
]
|
||||
})
|
||||
.collect();
|
||||
let t = &s.total;
|
||||
rows.push(vec![txt(lb.get("sheetTable.v.total")), txt(""), txt(format!("{}", t.count)), txt(""), num(t.room_count, 1), num(t.areas.hnf, 2), num(t.areas.nnf, 2), num(t.areas.nf, 2), num(t.areas.agf, 2), num(s.units.iter().map(|u| u.rooms as f64).sum(), 0), txt("")]);
|
||||
Data { rows, sloped: false, total_last: true }
|
||||
}
|
||||
|
||||
/// [272] Variantenvergleich: Kennzahlen und Kosten je gespeicherte Kombination (Name als Zeilentitel), ohne gespeicherte
|
||||
/// Kombination je Kombination der Sätze; ohne Variantensätze leer.
|
||||
fn design_option_compare_data(p: &Project) -> Data {
|
||||
@@ -894,6 +947,25 @@ mod tests {
|
||||
assert!(catalog_json()["sources"]["elements"].as_array().unwrap().len() >= 6);
|
||||
}
|
||||
|
||||
/// [278] Wohnungsspiegel als Blatt-Tabelle: eine Zeile je Einheit plus Summe; ohne Einheiten leer.
|
||||
#[test]
|
||||
fn wohnungsspiegel_tabelle() {
|
||||
let mut t = table("u", None);
|
||||
t.source = LayoutTableSource::UnitSchedule;
|
||||
let mut p = project(0, vec![t]);
|
||||
assert_eq!(serde_json::to_value(LayoutTableSource::UnitSchedule).unwrap(), "unitSchedule");
|
||||
assert_eq!(catalog_json()["sources"]["unitSchedule"].as_array().unwrap().len(), 11);
|
||||
assert_eq!(render(&p, &p.layouts.as_ref().unwrap()[0], &lb())[0].total, 0);
|
||||
let lvl = p.drawing_levels[0].id.clone();
|
||||
let sq = |s: f64| vec![Vec2 { x: 0.0, y: 0.0 }, Vec2 { x: s, y: 0.0 }, Vec2 { x: s, y: s }, Vec2 { x: 0.0, y: s }];
|
||||
p.units = Some(vec![Unit { id: "a".into(), name: "1.1".into(), ..Default::default() }]);
|
||||
p.rooms = Some(vec![Room { id: "r".into(), floor_id: lvl, usage: Some(RoomUsage::Living), unit_id: Some("a".into()), boundary: sq(4.0), ..Default::default() }]);
|
||||
let r = render(&p, &p.layouts.as_ref().unwrap()[0], &lb());
|
||||
assert_eq!(r[0].total, 2, "Einheit + Summe");
|
||||
let tx = texts(&r[0]);
|
||||
assert!(tx.contains(&"1-Zi-Whg".to_string()) && tx.contains(&"16.00".to_string()), "{tx:?}");
|
||||
}
|
||||
|
||||
/// [209] Kostenschätzung als Blatt-Tabelle: Gruppen beschriftet, Franken mit Apostroph, Total als Summenzeile.
|
||||
#[test]
|
||||
fn kosten_tabelle() {
|
||||
|
||||
@@ -0,0 +1,436 @@
|
||||
//! [278] Wohnungsspiegel: Nutzungseinheiten (`Project.units`, Räume verweisen mit `Room.unitId` darauf) mit
|
||||
//! Geschoss, Typ, Zimmerzahl und Flächen nach SIA 416, dazu Summen je Typ und je Geschoss.
|
||||
//!
|
||||
//! # Annahmen (Schweizer Praxis, vor Abgabe gegen die Vorgaben des Wettbewerbs prüfen)
|
||||
//!
|
||||
//! • **Flächen:** je Raum die Raumfläche nach `Room::area()` (lichter Umriss, wie [`crate::flaechen`]), gruppiert nach
|
||||
//! Flächenart `siaCategory`: HNF, NNF, VF, FF; `AGF` (Aussengeschossfläche) gilt als **Aussenraum** (Balkon, Loggia,
|
||||
//! gedeckter Sitzplatz) und steht in eigener Spalte, nicht in der NF. NF = HNF + NNF (SIA 416). Konstruktionsflächen
|
||||
//! (KGF-Räume) zählen nicht. Die Wände zwischen den Räumen sind nicht Teil der Einheit (wie in der Flächentabelle: KF).
|
||||
//! • **Zimmerzahl** nur bei Wohnnutzung (Fehlt `usage` an der Einheit ⇒ Wohnen): Summe der Beiträge der Räume.
|
||||
//! Beitrag je Raum: `Room.roomCount` (einstellbar, z. B. 0.5 für eine Wohnküche oder ein kleines Zimmer), sonst die
|
||||
//! Vorgabe aus der Raumnutzung ([`default_room_count`]): Wohnen, Schlafen, Essen, Büro/Arbeiten = 1, alles andere
|
||||
//! (Küche, Bad, WC, Diele/Verkehr, Abstellraum, Technik, ohne Nutzung) = 0 — und nur bei Räumen der Flächenart HNF. Eine
|
||||
//! Wohnküche ist von Hand zu setzen (Küche 0.5 oder Wohnen/Essen 1.5); es wird nichts aus dem Raumnamen erraten.
|
||||
//! • **Typ:** `Unit.unitType`, sonst bei Wohnungen mit Zimmern „n-Zi-Whg“ (n = Zimmerzahl, 3.5 → „3.5-Zi-Whg“).
|
||||
//! • **Geschoss:** Namen der Geschosse, in denen die Einheit Räume hat (von unten nach oben, „EG, 1. OG“ bei Maisonette).
|
||||
//! • **Summen je Geschoss:** eine Einheit zählt in jedem Geschoss, in dem sie Räume hat (mit den dort liegenden Flächen).
|
||||
//! • **Räume ohne (gültige) Einheit:** Gemeinschaftsflächen (Treppenhaus, Keller …), in `unassigned` ausgewiesen.
|
||||
//! • Einheiten ohne Räume stehen mit Nullen in der Liste.
|
||||
//!
|
||||
//! Gerechnet wird aus dem Dokument; Tabelle im Panel, CSV/PDF und Blatt-Tabelle formatieren dieselben Zeilen.
|
||||
|
||||
use crate::flaechen::floors_sorted;
|
||||
use crate::jsnum::or_zero as finite;
|
||||
use crate::model::*;
|
||||
use serde::Serialize;
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Vorgabe des Zimmerzahl-Beitrags eines Raums aus seiner Nutzung (siehe Moduldoku).
|
||||
pub fn default_room_count(r: &Room) -> f64 {
|
||||
if r.sia_category != SiaCategory::HNF {
|
||||
return 0.0;
|
||||
}
|
||||
match r.usage {
|
||||
Some(RoomUsage::Living | RoomUsage::Sleeping | RoomUsage::Dining | RoomUsage::Office) => 1.0,
|
||||
_ => 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
/// Zimmerzahl-Beitrag eines Raums: eingestellte Zahl (≥ 0, auf Halbe gerundet), sonst die Vorgabe.
|
||||
pub fn room_count(r: &Room) -> f64 {
|
||||
match r.room_count {
|
||||
Some(c) if c.is_finite() => (c.max(0.0) * 2.0).round() / 2.0,
|
||||
_ => default_room_count(r),
|
||||
}
|
||||
}
|
||||
|
||||
impl UnitUsage {
|
||||
/// Kennung wie im JSON.
|
||||
pub fn key(self) -> &'static str {
|
||||
match self {
|
||||
UnitUsage::Living | UnitUsage::Unknown => "living",
|
||||
UnitUsage::Commercial => "commercial",
|
||||
UnitUsage::Office => "office",
|
||||
UnitUsage::Other => "other",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Flächen einer Einheit (m²).
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Serialize)]
|
||||
pub struct UnitAreas {
|
||||
pub hnf: f64,
|
||||
pub nnf: f64,
|
||||
/// NF = HNF + NNF.
|
||||
pub nf: f64,
|
||||
pub vf: f64,
|
||||
pub ff: f64,
|
||||
/// Aussenraum (Balkon, Loggia): Flächenart AGF.
|
||||
pub agf: f64,
|
||||
}
|
||||
|
||||
impl UnitAreas {
|
||||
fn add_room(&mut self, cat: SiaCategory, a: f64) {
|
||||
match cat {
|
||||
SiaCategory::HNF => self.hnf += a,
|
||||
SiaCategory::NNF => self.nnf += a,
|
||||
SiaCategory::VF => self.vf += a,
|
||||
SiaCategory::FF => self.ff += a,
|
||||
SiaCategory::AGF => self.agf += a,
|
||||
SiaCategory::KGF | SiaCategory::Unknown => {}
|
||||
}
|
||||
self.nf = self.hnf + self.nnf;
|
||||
}
|
||||
fn add(&mut self, o: &UnitAreas) {
|
||||
self.hnf += o.hnf;
|
||||
self.nnf += o.nnf;
|
||||
self.nf += o.nf;
|
||||
self.vf += o.vf;
|
||||
self.ff += o.ff;
|
||||
self.agf += o.agf;
|
||||
}
|
||||
}
|
||||
|
||||
/// Eine Zeile des Spiegels: eine Nutzungseinheit.
|
||||
#[derive(Debug, Clone, Default, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UnitRow {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
/// Typ (eingegeben oder aus der Zimmerzahl abgeleitet; leer, wenn keins von beidem).
|
||||
pub type_label: String,
|
||||
/// `living`, `commercial`, `office`, `other`.
|
||||
pub usage: String,
|
||||
/// Namen der Geschosse (unten → oben).
|
||||
pub floors: Vec<String>,
|
||||
pub floor_ids: Vec<String>,
|
||||
pub rooms: usize,
|
||||
/// Zimmerzahl (nur Wohnnutzung, sonst 0).
|
||||
pub room_count: f64,
|
||||
#[serde(flatten)]
|
||||
pub areas: UnitAreas,
|
||||
pub color: Option<String>,
|
||||
pub note: String,
|
||||
}
|
||||
|
||||
/// Summe je Typ.
|
||||
#[derive(Debug, Clone, Default, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UnitTypeSum {
|
||||
pub type_label: String,
|
||||
pub count: usize,
|
||||
/// Summe der Zimmer aller Einheiten dieses Typs.
|
||||
pub room_count: f64,
|
||||
#[serde(flatten)]
|
||||
pub areas: UnitAreas,
|
||||
/// Mittlere HNF je Einheit.
|
||||
pub avg_hnf: f64,
|
||||
}
|
||||
|
||||
/// Summe je Geschoss.
|
||||
#[derive(Debug, Clone, Default, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UnitLevelSum {
|
||||
pub level_id: String,
|
||||
pub name: String,
|
||||
/// Einheiten mit Räumen in diesem Geschoss.
|
||||
pub count: usize,
|
||||
#[serde(flatten)]
|
||||
pub areas: UnitAreas,
|
||||
}
|
||||
|
||||
/// Räume ohne gültige Einheit.
|
||||
#[derive(Debug, Clone, Default, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UnitUnassigned {
|
||||
pub rooms: usize,
|
||||
#[serde(flatten)]
|
||||
pub areas: UnitAreas,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UnitSchedule {
|
||||
pub units: Vec<UnitRow>,
|
||||
pub by_type: Vec<UnitTypeSum>,
|
||||
pub by_level: Vec<UnitLevelSum>,
|
||||
/// Summe über alle Einheiten (`count` = Zahl der Einheiten, `room_count` = Summe der Zimmer).
|
||||
pub total: UnitTypeSum,
|
||||
pub unassigned: UnitUnassigned,
|
||||
}
|
||||
|
||||
fn auto_type(rooms: f64) -> String {
|
||||
format!("{}-Zi-Whg", rooms)
|
||||
}
|
||||
|
||||
/// Wohnungsspiegel des Projekts.
|
||||
pub fn unit_schedule(p: &Project) -> UnitSchedule {
|
||||
let floors = floors_sorted(p);
|
||||
let floor_idx: HashMap<&str, usize> = floors.iter().enumerate().map(|(i, l)| (l.id.as_str(), i)).collect();
|
||||
let units: &[Unit] = p.units.as_deref().unwrap_or(&[]);
|
||||
let mut by_id: HashMap<&str, usize> = HashMap::new();
|
||||
for (i, u) in units.iter().enumerate() {
|
||||
by_id.entry(u.id.as_str()).or_insert(i);
|
||||
}
|
||||
// Je Einheit und Geschoss die Flächen.
|
||||
let mut per: Vec<HashMap<usize, UnitAreas>> = vec![HashMap::new(); units.len()];
|
||||
let mut counts = vec![0.0_f64; units.len()];
|
||||
let mut n_rooms = vec![0usize; units.len()];
|
||||
let mut unassigned = UnitUnassigned::default();
|
||||
for r in p.rooms.as_deref().unwrap_or(&[]) {
|
||||
let Some(&fi) = floor_idx.get(r.floor_id.as_str()) else { continue };
|
||||
let a = finite(r.area());
|
||||
match r.unit_id.as_deref().and_then(|id| by_id.get(id)) {
|
||||
Some(&ui) => {
|
||||
per[ui].entry(fi).or_default().add_room(r.sia_category, a);
|
||||
counts[ui] += room_count(r);
|
||||
n_rooms[ui] += 1;
|
||||
}
|
||||
None => {
|
||||
unassigned.areas.add_room(r.sia_category, a);
|
||||
unassigned.rooms += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut rows: Vec<UnitRow> = Vec::with_capacity(units.len());
|
||||
for (ui, u) in units.iter().enumerate() {
|
||||
let usage = u.usage.unwrap_or_default();
|
||||
let living = usage.key() == "living";
|
||||
let mut areas = UnitAreas::default();
|
||||
let mut fl: Vec<usize> = per[ui].keys().copied().collect();
|
||||
fl.sort_unstable();
|
||||
for a in per[ui].values() {
|
||||
areas.add(a);
|
||||
}
|
||||
let rc = if living { counts[ui] } else { 0.0 };
|
||||
let explicit = u.unit_type.as_deref().map(str::trim).filter(|s| !s.is_empty());
|
||||
let type_label = match explicit {
|
||||
Some(s) => s.to_string(),
|
||||
None if living && rc > 0.0 => auto_type(rc),
|
||||
None => String::new(),
|
||||
};
|
||||
rows.push(UnitRow {
|
||||
id: u.id.clone(),
|
||||
name: u.name.clone(),
|
||||
type_label,
|
||||
usage: usage.key().to_string(),
|
||||
floors: fl.iter().map(|&i| floors[i].name.clone()).collect(),
|
||||
floor_ids: fl.iter().map(|&i| floors[i].id.clone()).collect(),
|
||||
rooms: n_rooms[ui],
|
||||
room_count: rc,
|
||||
areas,
|
||||
color: u.color.clone(),
|
||||
note: u.note.clone().unwrap_or_default(),
|
||||
});
|
||||
}
|
||||
// Natürliche Reihenfolge nach Nummer („1.2“ vor „1.10“).
|
||||
rows.sort_by(|a, b| crate::room_book::natural_cmp(&a.name, &b.name).then_with(|| a.id.cmp(&b.id)));
|
||||
|
||||
// Summen je Typ (Reihenfolge: erstes Auftreten in der sortierten Liste).
|
||||
let mut by_type: Vec<UnitTypeSum> = Vec::new();
|
||||
for r in &rows {
|
||||
let i = match by_type.iter().position(|t| t.type_label == r.type_label) {
|
||||
Some(i) => i,
|
||||
None => {
|
||||
by_type.push(UnitTypeSum { type_label: r.type_label.clone(), ..Default::default() });
|
||||
by_type.len() - 1
|
||||
}
|
||||
};
|
||||
let t = &mut by_type[i];
|
||||
t.count += 1;
|
||||
t.room_count += r.room_count;
|
||||
t.areas.add(&r.areas);
|
||||
}
|
||||
for t in &mut by_type {
|
||||
t.avg_hnf = if t.count > 0 { t.areas.hnf / t.count as f64 } else { 0.0 };
|
||||
}
|
||||
let mut total = UnitTypeSum::default();
|
||||
for t in &by_type {
|
||||
total.count += t.count;
|
||||
total.room_count += t.room_count;
|
||||
total.areas.add(&t.areas);
|
||||
}
|
||||
total.avg_hnf = if total.count > 0 { total.areas.hnf / total.count as f64 } else { 0.0 };
|
||||
|
||||
// Summen je Geschoss (nur Geschosse mit Einheiten).
|
||||
let mut by_level: Vec<UnitLevelSum> = Vec::new();
|
||||
for (fi, l) in floors.iter().enumerate() {
|
||||
let mut s = UnitLevelSum { level_id: l.id.clone(), name: l.name.clone(), ..Default::default() };
|
||||
for m in &per {
|
||||
if let Some(a) = m.get(&fi) {
|
||||
s.count += 1;
|
||||
s.areas.add(a);
|
||||
}
|
||||
}
|
||||
if s.count > 0 {
|
||||
by_level.push(s);
|
||||
}
|
||||
}
|
||||
UnitSchedule { units: rows, by_type, by_level, total, unassigned }
|
||||
}
|
||||
|
||||
/// CSV des Spiegels (Trenner „;“, Punkt als Dezimaltrenner) mit den übergebenen Spaltenköpfen:
|
||||
/// Nummer, Geschoss, Typ, Nutzung, Zimmer, HNF, NNF, NF, Aussenraum.
|
||||
pub fn schedule_csv(s: &UnitSchedule, head: &[String]) -> String {
|
||||
let q = |x: &str| if x.contains(';') || x.contains('"') || x.contains('\n') { format!("\"{}\"", x.replace('"', "\"\"")) } else { x.to_string() };
|
||||
let mut out = head.iter().map(|h| q(h)).collect::<Vec<_>>().join(";");
|
||||
out.push('\n');
|
||||
for u in &s.units {
|
||||
let cells = [q(&u.name), q(&u.floors.join(", ")), q(&u.type_label), q(&u.usage), format!("{}", u.room_count), format!("{:.2}", u.areas.hnf), format!("{:.2}", u.areas.nnf), format!("{:.2}", u.areas.nf), format!("{:.2}", u.areas.agf)];
|
||||
out.push_str(&cells.join(";"));
|
||||
out.push('\n');
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn v(x: f64, y: f64) -> Vec2 {
|
||||
Vec2 { x, y }
|
||||
}
|
||||
/// Rechteck `w` × `h` m (Fläche w·h) im Geschoss `fl`.
|
||||
fn room(id: &str, fl: &str, w: f64, h: f64, cat: SiaCategory, usage: Option<RoomUsage>, unit: Option<&str>) -> Room {
|
||||
Room { id: id.into(), floor_id: fl.into(), name: id.into(), sia_category: cat, usage, unit_id: unit.map(String::from), boundary: vec![v(0.0, 0.0), v(w, 0.0), v(w, h), v(0.0, h)], ..Default::default() }
|
||||
}
|
||||
fn unit(id: &str, name: &str) -> Unit {
|
||||
Unit { id: id.into(), name: name.into(), ..Default::default() }
|
||||
}
|
||||
fn project() -> Project {
|
||||
use RoomUsage::*;
|
||||
use SiaCategory::*;
|
||||
Project {
|
||||
drawing_levels: vec![
|
||||
DrawingLevel { id: "og".into(), name: "1. OG".into(), base_elevation: Some(3.0), floor_height: Some(3.0), ..Default::default() },
|
||||
DrawingLevel { id: "eg".into(), name: "EG".into(), base_elevation: Some(0.0), floor_height: Some(3.0), ..Default::default() },
|
||||
],
|
||||
units: Some(vec![unit("u10", "1.10"), unit("u2", "1.2"), unit("g", "G.1"), unit("leer", "9.9")]),
|
||||
rooms: Some(vec![
|
||||
// 1.2: EG, 2 Zimmer + Küche + Bad + Balkon -> 2-Zi-Whg
|
||||
room("w", "eg", 5.0, 4.0, HNF, Some(Living), Some("u2")),
|
||||
room("z", "eg", 4.0, 3.0, HNF, Some(Sleeping), Some("u2")),
|
||||
room("k", "eg", 3.0, 2.0, HNF, Some(Kitchen), Some("u2")),
|
||||
room("b", "eg", 2.0, 2.0, NNF, Some(Bath), Some("u2")),
|
||||
room("bal", "eg", 3.0, 1.0, AGF, None, Some("u2")),
|
||||
// 1.10: Maisonette EG/OG, Wohnküche 0.5 -> 3.5
|
||||
room("w2", "eg", 6.0, 4.0, HNF, Some(Living), Some("u10")),
|
||||
Room { room_count: Some(0.5), ..room("k2", "eg", 2.0, 2.0, HNF, Some(Kitchen), Some("u10")) },
|
||||
room("s1", "og", 4.0, 3.0, HNF, Some(Sleeping), Some("u10")),
|
||||
room("s2", "og", 3.0, 3.0, HNF, Some(Sleeping), Some("u10")),
|
||||
room("b2", "og", 2.0, 2.0, NNF, Some(Bath), Some("u10")),
|
||||
// Gewerbe
|
||||
room("l", "eg", 10.0, 5.0, HNF, Some(Office), Some("g")),
|
||||
// Treppenhaus ohne Einheit, Raum mit unbekannter Einheit
|
||||
room("th", "eg", 3.0, 3.0, VF, Some(Circulation), None),
|
||||
room("x", "og", 2.0, 1.0, HNF, Some(Living), Some("gibtsnicht")),
|
||||
]),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn spiegel_zimmer_flaechen_typ() {
|
||||
let mut p = project();
|
||||
p.units.as_mut().unwrap()[2].usage = Some(UnitUsage::Commercial);
|
||||
let s = unit_schedule(&p);
|
||||
let names: Vec<&str> = s.units.iter().map(|u| u.name.as_str()).collect();
|
||||
assert_eq!(names, ["1.2", "1.10", "9.9", "G.1"], "natürliche Reihenfolge");
|
||||
let u2 = &s.units[0];
|
||||
assert_eq!(u2.room_count, 2.0);
|
||||
assert_eq!(u2.type_label, "2-Zi-Whg");
|
||||
assert_eq!(u2.floors, ["EG"]);
|
||||
assert!((u2.areas.hnf - (20.0 + 12.0 + 6.0)).abs() < 1e-9, "Küche ist HNF, zählt aber 0 Zimmer");
|
||||
assert!((u2.areas.nnf - 4.0).abs() < 1e-9);
|
||||
assert!((u2.areas.nf - 42.0).abs() < 1e-9);
|
||||
assert!((u2.areas.agf - 3.0).abs() < 1e-9, "Balkon = Aussenraum, nicht in NF");
|
||||
let u10 = &s.units[1];
|
||||
assert_eq!(u10.room_count, 3.5, "Wohnen 1 + Wohnküche 0.5 + 2 × Schlafen");
|
||||
assert_eq!(u10.type_label, "3.5-Zi-Whg");
|
||||
assert_eq!(u10.floors, ["EG", "1. OG"], "Maisonette");
|
||||
assert_eq!(u10.floor_ids, ["eg", "og"]);
|
||||
assert_eq!(u10.rooms, 5);
|
||||
let leer = &s.units[2];
|
||||
assert_eq!((leer.rooms, leer.type_label.as_str(), leer.areas.nf), (0, "", 0.0));
|
||||
let g = &s.units[3];
|
||||
assert_eq!(g.usage, "commercial");
|
||||
assert_eq!(g.room_count, 0.0, "Gewerbe zählt keine Zimmer");
|
||||
assert_eq!(g.type_label, "");
|
||||
// Nicht zugeordnet: Treppenhaus (VF 9) und Raum mit unbekannter Einheit (HNF 2)
|
||||
assert_eq!(s.unassigned.rooms, 2);
|
||||
assert!((s.unassigned.areas.vf - 9.0).abs() < 1e-9);
|
||||
assert!((s.unassigned.areas.hnf - 2.0).abs() < 1e-9);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn summen_je_typ_und_geschoss() {
|
||||
let s = unit_schedule(&project());
|
||||
let t: Vec<(&str, usize)> = s.by_type.iter().map(|t| (t.type_label.as_str(), t.count)).collect();
|
||||
// „9.9“ (leer) und „G.1“ (hier ohne Nutzung = Wohnen, ein Büro-Raum zählt als Zimmer) kommen als Wohnungen.
|
||||
assert_eq!(t[0], ("2-Zi-Whg", 1));
|
||||
assert_eq!(t[1], ("3.5-Zi-Whg", 1));
|
||||
assert_eq!(s.total.count, 4);
|
||||
let hnf: f64 = s.units.iter().map(|u| u.areas.hnf).sum();
|
||||
assert!((s.total.areas.hnf - hnf).abs() < 1e-9);
|
||||
assert!((s.by_type[0].avg_hnf - s.by_type[0].areas.hnf).abs() < 1e-9);
|
||||
// Geschosse unten → oben; die Maisonette zählt in beiden.
|
||||
let l: Vec<(&str, usize)> = s.by_level.iter().map(|l| (l.name.as_str(), l.count)).collect();
|
||||
assert_eq!(l, [("EG", 3), ("1. OG", 1)]);
|
||||
// 1. OG: nur die Einheit 1.10 (12 + 9 HNF, 4 NNF)
|
||||
assert!((s.by_level[1].areas.hnf - 21.0).abs() < 1e-9);
|
||||
assert!((s.by_level[1].areas.nnf - 4.0).abs() < 1e-9);
|
||||
// Summe je Geschoss = Summe der Einheiten.
|
||||
let sum: f64 = s.by_level.iter().map(|l| l.areas.hnf).sum();
|
||||
assert!((sum - hnf).abs() < 1e-9);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eingegebener_typ_geht_vor_und_zimmerzahl_wird_geklemmt() {
|
||||
let mut p = project();
|
||||
p.units.as_mut().unwrap()[0].unit_type = Some(" Maisonette ".into());
|
||||
let s = unit_schedule(&p);
|
||||
assert_eq!(s.units[1].type_label, "Maisonette");
|
||||
assert_eq!(s.units[1].room_count, 3.5, "Zimmerzahl bleibt gerechnet");
|
||||
let r = Room { room_count: Some(1.3), ..Default::default() };
|
||||
assert_eq!(room_count(&r), 1.5);
|
||||
assert_eq!(room_count(&Room { room_count: Some(-2.0), ..Default::default() }), 0.0);
|
||||
assert_eq!(room_count(&Room { room_count: Some(f64::NAN), usage: Some(RoomUsage::Living), ..Default::default() }), 1.0, "NaN: Vorgabe");
|
||||
// Nur HNF zählt in der Vorgabe: ein Wohnraum als NNF ergibt 0.
|
||||
assert_eq!(default_room_count(&Room { sia_category: SiaCategory::NNF, usage: Some(RoomUsage::Living), ..Default::default() }), 0.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ohne_einheiten_und_unsinn() {
|
||||
let mut p = project();
|
||||
p.units = None;
|
||||
let s = unit_schedule(&p);
|
||||
assert!(s.units.is_empty() && s.by_type.is_empty() && s.by_level.is_empty());
|
||||
assert_eq!(s.unassigned.rooms, 13);
|
||||
// Raum mit NaN-Umriss und Raum in unbekanntem Geschoss.
|
||||
let mut p = project();
|
||||
p.rooms.as_mut().unwrap().push(room("n", "eg", f64::NAN, 1.0, SiaCategory::HNF, None, Some("u2")));
|
||||
p.rooms.as_mut().unwrap().push(room("f", "weg", 1.0, 1.0, SiaCategory::HNF, None, Some("u2")));
|
||||
let s = unit_schedule(&p);
|
||||
assert!(s.units[0].areas.hnf.is_finite());
|
||||
assert_eq!(s.units[0].rooms, 6, "NaN-Raum zählt als Raum mit Fläche 0, unbekanntes Geschoss gar nicht");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn csv_hat_kopf_und_eine_zeile_je_einheit() {
|
||||
let s = unit_schedule(&project());
|
||||
let csv = schedule_csv(&s, &["Nr".into(), "Geschoss".into(), "Typ".into(), "Nutzung".into(), "Zimmer".into(), "HNF".into(), "NNF".into(), "NF".into(), "Aussen".into()]);
|
||||
let lines: Vec<&str> = csv.lines().collect();
|
||||
assert_eq!(lines.len(), 5);
|
||||
assert_eq!(lines[1], "1.2;EG;2-Zi-Whg;living;2;38.00;4.00;42.00;3.00");
|
||||
assert!(lines[2].starts_with("1.10;EG, 1. OG;3.5-Zi-Whg;"), "{}", lines[2]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn json_hat_flache_flaechen() {
|
||||
let s = unit_schedule(&project());
|
||||
let j = serde_json::to_value(&s).unwrap();
|
||||
assert!(j["units"][0]["hnf"].is_number() && j["units"][0]["typeLabel"].is_string());
|
||||
assert!(j["byType"][0]["avgHnf"].is_number() && j["total"]["count"] == 4 && j["unassigned"]["rooms"] == 2);
|
||||
}
|
||||
}
|
||||
@@ -334,6 +334,9 @@ fn derive_all(d: &mut Document, tag: &str, depth: Depth, fails: &mut Fails) {
|
||||
("renovationFilters", vec![], ""),
|
||||
// [272] Varianten: Info, Vergleich (mit Unsinn), Kombination in Kennzahlen/3D/IFC.
|
||||
("designOptionInfo", vec![], ""),
|
||||
// [278] Wohnungsspiegel (auch mit Unsinn im Text).
|
||||
("unitSchedule", vec![], ""),
|
||||
("unitSchedule", vec![], "{\"head\": [1, null], \"renovation\": 3}"),
|
||||
("designOptionCompare", vec![], "{\"renovation\": 3, \"head\": [1]}"),
|
||||
("kennzahlen", vec![], "{\"designOptions\": \"a=b\"}"),
|
||||
("model3dParts", vec![0.0, f64::NAN, 0.0, 1.0], "{\"designOptions\": {\"s\": null}}"),
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
// [278] Wohnungsspiegel: Fassade über den Kern, Ops der Oberfläche (ein Undo-Schritt), Bericht/CSV, Blatt-Tabelle, Beispielprojekt.
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import { withDocument } from "../core/document";
|
||||
import { getState } from "../state/appStore";
|
||||
import { buildWettbewerbSampleProject } from "../model/sampleProjectWettbewerb";
|
||||
import type { Project } from "../model/types";
|
||||
import { computeUnitSchedule, unitScheduleCsv } from "./unitSchedule";
|
||||
import { buildAreaReport, areaReportToCsv, hasUnits } from "../export/areaReport";
|
||||
import { sheetTables } from "../export/sheetTable";
|
||||
import { patchItem } from "../core/opsBuild";
|
||||
import { addUnitOps, assignRoomsOps, deleteUnitOps, draftUnit, patchUnitOps } from "../panels/unitOps";
|
||||
|
||||
const st = () => getState();
|
||||
let wb: Project;
|
||||
|
||||
beforeEach(() => {
|
||||
st().loadProject(buildWettbewerbSampleProject());
|
||||
st().clearHistory();
|
||||
wb = st().project;
|
||||
});
|
||||
|
||||
describe("Wohnungsspiegel (Beispiel Wettbewerb)", () => {
|
||||
it("sechs Wohnungen: Typ, Zimmerzahl, Fläche je Einheit; Treppenhaus/Abstellraum ohne Einheit", () => {
|
||||
const s = computeUnitSchedule(wb);
|
||||
expect(s.units.map((u) => u.name)).toEqual(["0.1", "0.2", "1.1", "1.2", "2.1", "2.2"]);
|
||||
expect(s.units.map((u) => u.typeLabel)).toEqual(["2-Zi-Whg", "2.5-Zi-Whg", "2-Zi-Whg", "2.5-Zi-Whg", "2-Zi-Whg", "2.5-Zi-Whg"]);
|
||||
expect(s.units.map((u) => u.rooms)).toEqual([4, 4, 4, 4, 4, 4]);
|
||||
expect(s.units.map((u) => u.floors)).toEqual([["Erdgeschoss"], ["Erdgeschoss"], ["1. Obergeschoss"], ["1. Obergeschoss"], ["2. Obergeschoss"], ["2. Obergeschoss"]]);
|
||||
// HNF = Wohnen/Essen + Zimmer + Diele, NNF = Bad; NF = HNF + NNF (Handrechnung gegen die Raumliste).
|
||||
const area = (id: string) => computeUnitSchedule(wb).units.find((u) => u.id === id)!;
|
||||
const u = area("whg-eg-w");
|
||||
expect(u.hnf).toBeGreaterThan(40);
|
||||
expect(u.nnf).toBeGreaterThan(3);
|
||||
expect(u.nf).toBeCloseTo(u.hnf + u.nnf, 9);
|
||||
expect(u.agf).toBe(0);
|
||||
// Typ-Summen: je 3 Wohnungen.
|
||||
expect(s.byType.map((t) => [t.typeLabel, t.count, t.roomCount])).toEqual([["2-Zi-Whg", 3, 6], ["2.5-Zi-Whg", 3, 7.5]]);
|
||||
expect(s.total.count).toBe(6);
|
||||
expect(s.total.roomCount).toBeCloseTo(13.5, 9);
|
||||
// Geschoss-Summen: drei Geschosse mit je zwei Wohnungen.
|
||||
expect(s.byLevel.map((l) => l.count)).toEqual([2, 2, 2]);
|
||||
expect(s.byLevel.reduce((a, l) => a + l.hnf, 0)).toBeCloseTo(s.total.hnf, 9);
|
||||
// Gemeinschaftsflächen: je Geschoss Treppenhaus + Abstellraum/Eingang.
|
||||
expect(s.unassigned.rooms).toBe(6);
|
||||
expect(s.unassigned.vf).toBeGreaterThan(10);
|
||||
});
|
||||
|
||||
it("CSV: Kopf und je Einheit eine Zeile; Bericht hat Spiegel, Typ- und Geschoss-Summen", () => {
|
||||
const csv = unitScheduleCsv(wb, ["Nr", "Geschoss", "Typ", "Nutzung", "Zimmer", "HNF", "NNF", "NF", "Aussen"]);
|
||||
expect(csv.trim().split("\n").length).toBe(7);
|
||||
expect(csv.split("\n")[1]).toMatch(/^0\.1;Erdgeschoss;2-Zi-Whg;living;2;\d+\.\d\d;/);
|
||||
expect(hasUnits(wb)).toBe(true);
|
||||
const r = buildAreaReport(wb, { areas: false, units: true });
|
||||
expect(r.sections.length).toBe(3);
|
||||
expect(r.sections[0].rows.length).toBe(7);
|
||||
expect(r.sections[0].rows.at(-1)!.total).toBe(true);
|
||||
expect(areaReportToCsv(r)).toContain("2.5-Zi-Whg");
|
||||
// Ohne Einheiten kein Abschnitt.
|
||||
const none: Project = { ...wb, units: undefined };
|
||||
expect(withDocument(none, () => buildAreaReport(none, { areas: false, units: true })).sections.length).toBe(0);
|
||||
});
|
||||
|
||||
it("Blatt-Tabelle: Layout „Wohnungsspiegel“ rechnet mit dem Modell mit", () => {
|
||||
const lay = wb.layouts!.find((l) => l.id === "lay-wohnungsspiegel")!;
|
||||
const [t] = sheetTables(wb, lay.id);
|
||||
expect(t.total).toBe(7);
|
||||
const texts = t.prims.filter((p) => p.k === "text").map((p) => (p as { s: string }).s);
|
||||
expect(texts).toContain("2.5-Zi-Whg");
|
||||
expect(texts).toContain("1. Obergeschoss");
|
||||
// Eine Wohnung mehr im Modell: die Tabelle hat eine Zeile mehr.
|
||||
const more: Project = { ...wb, units: [...wb.units!, { id: "neu", name: "3.1", unitType: "Atelier" }] };
|
||||
const [t2] = withDocument(more, () => sheetTables(more, lay.id));
|
||||
expect(t2.total).toBe(8);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Ops der Oberfläche: eine Aktion = ein Undo-Schritt", () => {
|
||||
it("neue Einheit aus Auswahl, Zuordnen, Ändern, Löschen", () => {
|
||||
const p0 = st().project;
|
||||
const ids = ["raum-E.10", "raum-1.10"];
|
||||
const unit = draftUnit(p0, "Whg");
|
||||
expect(unit.name).toBe("Whg 7");
|
||||
st().applyChange((p: Project) => addUnitOps(p, unit, ids));
|
||||
expect(st().undoDepth).toBe(1);
|
||||
expect(st().project.units!.length).toBe(7);
|
||||
expect(st().project.rooms!.filter((r) => r.unitId === unit.id).map((r) => r.id)).toEqual(ids);
|
||||
st().undo();
|
||||
expect(st().project.units!.length).toBe(6);
|
||||
expect(st().project.rooms!.find((r) => r.id === "raum-E.10")!.unitId).toBeUndefined();
|
||||
|
||||
st().applyChange((p: Project) => assignRoomsOps(p, ["raum-E.09", "raum-1.09"], "whg-eg-w"));
|
||||
expect(st().project.rooms!.find((r) => r.id === "raum-1.09")!.unitId).toBe("whg-eg-w");
|
||||
expect(computeUnitSchedule(st().project).units.find((u) => u.id === "whg-eg-w")!.floors).toEqual(["Erdgeschoss", "1. Obergeschoss"]);
|
||||
|
||||
st().applyChange((p: Project) => patchUnitOps(p, "whg-eg-w", { unitType: "Maisonette" }), "unit:whg-eg-w:type");
|
||||
expect(computeUnitSchedule(st().project).units.find((u) => u.id === "whg-eg-w")!.typeLabel).toBe("Maisonette");
|
||||
|
||||
const before = st().undoDepth;
|
||||
st().applyChange((p: Project) => deleteUnitOps(p, "whg-eg-w"));
|
||||
expect(st().undoDepth).toBe(before + 1);
|
||||
expect(st().project.units!.some((u) => u.id === "whg-eg-w")).toBe(false);
|
||||
expect(st().project.rooms!.some((r) => r.unitId === "whg-eg-w")).toBe(false);
|
||||
st().undo();
|
||||
expect(st().project.rooms!.filter((r) => r.unitId === "whg-eg-w").length).toBe(6);
|
||||
});
|
||||
|
||||
it("alle Einheiten gelöscht: Feld verschwindet; Zimmer-Zählung eines Raums ändert den Typ", () => {
|
||||
for (const u of structuredClone(st().project.units!)) st().applyChange((p: Project) => deleteUnitOps(p, u.id));
|
||||
expect(st().project.units).toBeUndefined();
|
||||
expect(computeUnitSchedule(st().project).units).toEqual([]);
|
||||
st().clearHistory();
|
||||
st().loadProject(buildWettbewerbSampleProject());
|
||||
st().applyChange((p: Project) => patchItem(p, "rooms", "raum-E.01", { roomCount: 1.5 }));
|
||||
expect(computeUnitSchedule(st().project).units.find((u) => u.id === "whg-eg-w")!.typeLabel).toBe("2.5-Zi-Whg");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,88 @@
|
||||
// Wohnungsspiegel ([278]): Nutzungseinheiten mit Geschoss, Typ, Zimmerzahl und Flächen nach SIA 416.
|
||||
// Rechnet der Kern auf dem Projekt-Dokument (`src-tauri/core/src/unit_schedule.rs`; Annahmen stehen im Modulkopf).
|
||||
// Diese Datei ist nur die typisierte Fassade plus kleine Helfer der Oberfläche.
|
||||
|
||||
import type { Project, Unit, UnitUsage } from "../model/types";
|
||||
import { documentFor } from "../core/document";
|
||||
|
||||
/** Flächen einer Einheit (m²). */
|
||||
export interface UnitAreas {
|
||||
hnf: number;
|
||||
nnf: number;
|
||||
/** NF = HNF + NNF. */
|
||||
nf: number;
|
||||
vf: number;
|
||||
ff: number;
|
||||
/** Aussenraum (Balkon, Loggia): Flächenart AGF. */
|
||||
agf: number;
|
||||
}
|
||||
|
||||
export interface UnitRow extends UnitAreas {
|
||||
id: string;
|
||||
name: string;
|
||||
/** Typ (eingegeben oder aus der Zimmerzahl abgeleitet, z. B. „3.5-Zi-Whg“; leer ohne beides). */
|
||||
typeLabel: string;
|
||||
usage: UnitUsage;
|
||||
/** Namen der Geschosse (unten → oben). */
|
||||
floors: string[];
|
||||
floorIds: string[];
|
||||
/** Zahl der Räume. */
|
||||
rooms: number;
|
||||
/** Zimmerzahl (nur Wohnnutzung). */
|
||||
roomCount: number;
|
||||
color: string | null;
|
||||
note: string;
|
||||
}
|
||||
|
||||
export interface UnitTypeSum extends UnitAreas {
|
||||
typeLabel: string;
|
||||
count: number;
|
||||
roomCount: number;
|
||||
avgHnf: number;
|
||||
}
|
||||
|
||||
export interface UnitLevelSum extends UnitAreas {
|
||||
levelId: string;
|
||||
name: string;
|
||||
count: number;
|
||||
}
|
||||
|
||||
export interface UnitSchedule {
|
||||
units: UnitRow[];
|
||||
byType: UnitTypeSum[];
|
||||
byLevel: UnitLevelSum[];
|
||||
total: UnitTypeSum;
|
||||
/** Räume ohne (gültige) Einheit. */
|
||||
unassigned: UnitAreas & { rooms: number };
|
||||
}
|
||||
|
||||
/** Nutzungen einer Einheit in der Reihenfolge der Auswahl. */
|
||||
export const UNIT_USAGES: readonly UnitUsage[] = ["living", "commercial", "office", "other"];
|
||||
|
||||
/** Wohnungsspiegel des Projekts (`renovation`: Umbau-Zustand, leer = alle Bauteile). */
|
||||
export function computeUnitSchedule(project: Project, renovation = ""): UnitSchedule {
|
||||
return documentFor(project).query<UnitSchedule>("unitSchedule", [], renovation);
|
||||
}
|
||||
|
||||
/** CSV des Spiegels (Trenner „;“); `head` = Spaltenköpfe (Nr., Geschoss, Typ, Nutzung, Zimmer, HNF, NNF, NF, Aussenraum). */
|
||||
export function unitScheduleCsv(project: Project, head: string[]): string {
|
||||
return documentFor(project).query<string>("unitSchedule", [], JSON.stringify({ head }));
|
||||
}
|
||||
|
||||
/** Vorschlag für den Namen einer neuen Einheit: Präfix + erste freie Zahl („Whg 3“). */
|
||||
export function nextUnitName(units: readonly Unit[], prefix: string): string {
|
||||
const taken = new Set(units.map((u) => u.name));
|
||||
for (let n = units.length + 1; ; n++) {
|
||||
const name = `${prefix} ${n}`;
|
||||
if (!taken.has(name)) return name;
|
||||
}
|
||||
}
|
||||
|
||||
/** Neue, noch unbenutzte Einheiten-Id. */
|
||||
export function newUnitId(units: readonly Unit[]): string {
|
||||
const taken = new Set(units.map((u) => u.id));
|
||||
for (let n = units.length + 1; ; n++) {
|
||||
const id = `unit-${n}`;
|
||||
if (!taken.has(id)) return id;
|
||||
}
|
||||
}
|
||||
+9
-5
@@ -37,7 +37,7 @@
|
||||
// (Linienzeichnung, Silhouette kräftig, Flächen nach Lage grau; ohne GPU)
|
||||
// dossier-cli <projekt.obp> ifc [--ebkph] [--ebenen] [--kontext] (IFC mit eBKP-H-Hauptgruppen bzw. Modell-Ebenen als Klassifikation; --kontext: Gelände/Nachbarn mitgeben)
|
||||
// --schema 4|2x3: IFC4 (Standard) oder IFC2x3 (Coordination View 2.0)
|
||||
// dossier-cli <projekt.obp> dxf [--binary] [--scale 100] [--dim-unit cm] [--layout]|dwg|ifc|step|obj [--no-mtl]|stl|glb|gltf|schedule [--openings|--elements|--rooms] [--format json|csv|svg|pdf]|kennzahlen [--sia416] [--ivhb] [--nachweis] [--format json|csv|svg|pdf] [--agsf m2] [--gruenflaeche m2] [--agf-basis gf|ngf|nf] [--untergeschosse]|raumprogramm [--import tabelle] [--sheet name|nr] [--mode replace|append] [--tolerance %] [--generate] [--format json|csv|svg|pdf] [--save projekt.obp]|sun [--level EG] [--out datei]
|
||||
// dossier-cli <projekt.obp> dxf [--binary] [--scale 100] [--dim-unit cm] [--layout]|dwg|ifc|step|obj [--no-mtl]|stl|glb|gltf|schedule [--openings|--elements|--rooms] [--format json|csv|svg|pdf]|kennzahlen [--sia416] [--ivhb] [--nachweis] [--wohnungsspiegel] [--format json|csv|svg|pdf] [--agsf m2] [--gruenflaeche m2] [--agf-basis gf|ngf|nf] [--untergeschosse]|raumprogramm [--import tabelle] [--sheet name|nr] [--mode replace|append] [--tolerance %] [--generate] [--format json|csv|svg|pdf] [--save projekt.obp]|sun [--level EG] [--out datei]
|
||||
// glb/gltf = glTF 2.0 (Y-up, Meter, Geschoss als Eltern; --flat ohne Geschoss-Knoten)
|
||||
// dossier-cli convert <eingabe> <ausgabe> [--cmd "befehl"]… Format nach Endung: dxf/dwg/ifc/obp → obp-Import,
|
||||
// obp → dxf/dwg/ifc/obj/stl/glb/gltf/step; --cmd: weitere Befehle
|
||||
@@ -107,6 +107,7 @@ import {
|
||||
exportScheduleCsv,
|
||||
computeKennzahlen,
|
||||
computeAreaTable,
|
||||
computeUnitSchedule,
|
||||
computeIvhb,
|
||||
computeSiteProof,
|
||||
buildAreaReport,
|
||||
@@ -1365,7 +1366,7 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
return 0;
|
||||
case "kennzahlen": {
|
||||
// --sia416 / --ivhb: Flächentabelle bzw. IVHB-Kennziffern [70]; --format json|csv|svg|pdf (Default json).
|
||||
if (args.flags.has("sia416") || args.flags.has("ivhb") || args.flags.has("nachweis")) {
|
||||
if (args.flags.has("sia416") || args.flags.has("ivhb") || args.flags.has("nachweis") || args.flags.has("wohnungsspiegel")) {
|
||||
const num = (k: string): number | undefined => {
|
||||
const v = args.flags.get(k);
|
||||
if (v === undefined) return undefined;
|
||||
@@ -1379,14 +1380,15 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
const wantAreas = args.flags.has("sia416");
|
||||
const wantIvhb = args.flags.has("ivhb");
|
||||
const wantProof = args.flags.has("nachweis");
|
||||
const wantUnits = args.flags.has("wohnungsspiegel");
|
||||
const format = args.flags.get("format") ?? "json";
|
||||
const stem = `${exportProjectName(project) || "projekt"}-flaechen`;
|
||||
if (format === "json") {
|
||||
const json = { ...(wantAreas ? { flaechentabelle: computeAreaTable(project) } : {}), ...(wantIvhb ? { ivhb: computeIvhb(project, ivhbOptions) } : {}), ...(wantProof ? { baurechtNachweis: computeSiteProof(project, ivhbOptions) } : {}) };
|
||||
const json = { ...(wantAreas ? { flaechentabelle: computeAreaTable(project) } : {}), ...(wantIvhb ? { ivhb: computeIvhb(project, ivhbOptions) } : {}), ...(wantProof ? { baurechtNachweis: computeSiteProof(project, ivhbOptions) } : {}), ...(wantUnits ? { wohnungsspiegel: computeUnitSchedule(project) } : {}) };
|
||||
out(args, JSON.stringify(json, null, 2), `${stem}.json`);
|
||||
return 0;
|
||||
}
|
||||
const report = buildAreaReport(project, { areas: wantAreas, ivhb: wantIvhb, siteProof: wantProof, ivhbOptions });
|
||||
const report = buildAreaReport(project, { areas: wantAreas, ivhb: wantIvhb, siteProof: wantProof, units: wantUnits, ivhbOptions });
|
||||
if (format === "csv") out(args, areaReportToCsv(report), `${stem}.csv`);
|
||||
else if (format === "svg") out(args, areaReportToSvg(report), `${stem}.svg`);
|
||||
else if (format === "pdf") out(args, new Uint8Array((await buildAreaReportPdf(report)).output("arraybuffer")), `${stem}.pdf`);
|
||||
@@ -1399,7 +1401,9 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
const baurecht = checkSiteRules(project);
|
||||
// [68] Erdarbeiten je Baugrube (Abtrag/Auftrag/Hinterfüllung, m³).
|
||||
const erdarbeiten = excavationQuantities(project);
|
||||
out(args, JSON.stringify({ kennzahlen: k, raumprogramm: prog, baurecht, erdarbeiten }, null, 2), `${exportProjectName(project) || "projekt"}-kennzahlen.json`);
|
||||
// [278] Wohnungsspiegel, sobald das Projekt Nutzungseinheiten hat.
|
||||
const wohnungsspiegel = (project.units ?? []).length > 0 ? computeUnitSchedule(project) : undefined;
|
||||
out(args, JSON.stringify({ kennzahlen: k, raumprogramm: prog, baurecht, erdarbeiten, ...(wohnungsspiegel ? { wohnungsspiegel } : {}) }, null, 2), `${exportProjectName(project) || "projekt"}-kennzahlen.json`);
|
||||
return 0;
|
||||
}
|
||||
case "designoptions": {
|
||||
|
||||
@@ -183,6 +183,7 @@ export type QueryName =
|
||||
| "presentationSheet"
|
||||
| "kennzahlen"
|
||||
| "areaTable"
|
||||
| "unitSchedule"
|
||||
| "renovationFilters"
|
||||
| "renovationStyles"
|
||||
| "renovationPair"
|
||||
|
||||
+3
-1
@@ -45,6 +45,8 @@ export type { RoomBook, RoomBookRow, FinishQty, WallSide } from "../export/roomB
|
||||
export { sheetTables, createTable, drawTablesPdf, tableCatalog, tableLabels, tableSourceLabel, TABLE_SOURCES } from "../export/sheetTable";
|
||||
export type { TableOut, TablePrim, TableColumn } from "../export/sheetTable";
|
||||
export { computeAreaTable, computeIvhb } from "../analysis/areaTable";
|
||||
export { computeUnitSchedule, unitScheduleCsv, nextUnitName, newUnitId, UNIT_USAGES } from "../analysis/unitSchedule";
|
||||
export type { UnitSchedule, UnitRow, UnitTypeSum, UnitLevelSum, UnitAreas } from "../analysis/unitSchedule";
|
||||
export type { AreaTable, AreaRow, Ivhb, IvhbOptions, AgfBasis } from "../analysis/areaTable";
|
||||
export { computeSiteProof } from "../analysis/siteProof";
|
||||
export type { SiteProof, ProofRow, ProofBasis } from "../analysis/siteProof";
|
||||
@@ -52,7 +54,7 @@ export { exportProjectName, competitionIdentity, isAnonymous, competitionKeyword
|
||||
export type { CompetitionIdentity } from "../export/competitionIdentity";
|
||||
export { anonymityFindings } from "../export/competitionCheck";
|
||||
export type { AnonymityFinding, AnonymityKind } from "../export/competitionCheck";
|
||||
export { isAreaReportEmpty, buildAreaReport, areaReportToCsv, parseAreaReportCsv, areaReportToSvg, buildAreaReportPdf } from "../export/areaReport";
|
||||
export { isAreaReportEmpty, hasUnits, buildAreaReport, areaReportToCsv, parseAreaReportCsv, areaReportToSvg, buildAreaReportPdf } from "../export/areaReport";
|
||||
export { setPdfFontLoader } from "../export/pdfFonts";
|
||||
export type { AreaReport, AreaReportOptions } from "../export/areaReport";
|
||||
export { sunPosition, shadowPolygons, shadowOfPrism, projectLatLon } from "../analysis/sun";
|
||||
|
||||
@@ -19,6 +19,7 @@ import { ensurePdfFonts, hasPdfFont, PDF_DEFAULT_FONT, setPdfFont } from "./pdfF
|
||||
import { computeAreaTable, computeIvhb } from "../analysis/areaTable";
|
||||
import type { AreaRow, IvhbOptions } from "../analysis/areaTable";
|
||||
import { computeSiteProof } from "../analysis/siteProof";
|
||||
import { computeUnitSchedule } from "../analysis/unitSchedule";
|
||||
|
||||
/** Zelle: Text oder Zahl (`d` Nachkommastellen, `null` = nicht berechenbar). */
|
||||
export type Cell = string | { n: number | null; d: number; g?: boolean };
|
||||
@@ -55,6 +56,8 @@ export interface AreaReportOptions {
|
||||
ivhbOptions?: IvhbOptions;
|
||||
/** Baurecht-Nachweis ([255]): Vorgaben der Parzelle gegen Kennzahlen, mit Grundlagen (Default nein). */
|
||||
siteProof?: boolean;
|
||||
/** Wohnungsspiegel ([278]): Nutzungseinheiten, Summe je Typ und je Geschoss (Default nein; ohne Einheiten kein Abschnitt). */
|
||||
units?: boolean;
|
||||
}
|
||||
|
||||
const num = (n: number | null | undefined, d: number): Cell => ({ n: n === undefined || n === null || !Number.isFinite(n) ? null : n, d });
|
||||
@@ -71,6 +74,44 @@ export function isAreaReportEmpty(project: Project): boolean {
|
||||
return [total.hnf, total.nnf, total.vf, total.ff, total.kf, total.gf, total.agf, total.rooms, gv].every((v) => !(Math.abs(v) > 0));
|
||||
}
|
||||
|
||||
/** [278] Hat das Projekt Nutzungseinheiten (sonst wäre der Wohnungsspiegel leer)? */
|
||||
export function hasUnits(project: Project): boolean {
|
||||
return (project.units ?? []).length > 0;
|
||||
}
|
||||
|
||||
/** [278] Wohnungsspiegel als Abschnitte: Einheiten mit Summe, je Typ, je Geschoss (samt Räumen ohne Einheit). */
|
||||
function addUnitSections(project: Project, sections: ReportSection[], notes: string[]): void {
|
||||
if (!hasUnits(project)) return;
|
||||
const u = computeUnitSchedule(project);
|
||||
const dash = "–";
|
||||
sections.push({
|
||||
heading: t("units.table"),
|
||||
columns: [t("units.col.name"), t("units.col.floor"), t("units.col.type"), t("units.col.rooms"), "HNF", "NNF", "NF", t("units.col.outdoor")],
|
||||
widths: [1.4, 3, 2.6, 1.4, 1.6, 1.6, 1.6, 2],
|
||||
rows: [
|
||||
...u.units.map((r): ReportRow => ({ cells: [r.name, r.floors.join(", "), r.typeLabel, r.usage === "living" ? num(r.roomCount, 1) : dash, num(r.hnf, 2), num(r.nnf, 2), num(r.nf, 2), num(r.agf, 2)] })),
|
||||
{ total: true, cells: [t("areas.total"), "", String(u.total.count), num(u.total.roomCount, 1), num(u.total.hnf, 2), num(u.total.nnf, 2), num(u.total.nf, 2), num(u.total.agf, 2)] },
|
||||
],
|
||||
});
|
||||
sections.push({
|
||||
heading: t("units.byType"),
|
||||
columns: [t("units.col.type"), t("units.col.count"), t("units.col.rooms"), t("units.col.avgHnf"), "HNF", "NF", t("units.col.outdoor")],
|
||||
widths: [3, 1.4, 1.6, 1.8, 1.8, 1.8, 2],
|
||||
rows: u.byType.map((r): ReportRow => ({ cells: [r.typeLabel || t("units.noType"), String(r.count), num(r.roomCount, 1), num(r.avgHnf, 2), num(r.hnf, 2), num(r.nf, 2), num(r.agf, 2)] })),
|
||||
});
|
||||
sections.push({
|
||||
heading: t("units.byLevel"),
|
||||
columns: [t("units.col.floor"), t("units.col.count"), "HNF", "NNF", "NF", t("units.col.outdoor")],
|
||||
widths: [3, 1.4, 1.8, 1.8, 1.8, 2],
|
||||
rows: [
|
||||
...u.byLevel.map((r): ReportRow => ({ cells: [r.name, String(r.count), num(r.hnf, 2), num(r.nnf, 2), num(r.nf, 2), num(r.agf, 2)] })),
|
||||
...(u.unassigned.rooms > 0 ? [{ cells: [t("units.unassigned"), "", num(u.unassigned.hnf, 2), num(u.unassigned.nnf, 2), num(u.unassigned.nf, 2), num(u.unassigned.agf, 2)] } as ReportRow] : []),
|
||||
],
|
||||
});
|
||||
const foot = t("units.foot");
|
||||
if (!notes.includes(foot)) notes.push(foot);
|
||||
}
|
||||
|
||||
/** Baut den Bericht aus dem Projekt. */
|
||||
export function buildAreaReport(project: Project, opts: AreaReportOptions = {}): AreaReport {
|
||||
const sections: ReportSection[] = [];
|
||||
@@ -149,6 +190,7 @@ export function buildAreaReport(project: Project, opts: AreaReportOptions = {}):
|
||||
if (!notes.includes(text)) notes.push(text);
|
||||
}
|
||||
}
|
||||
if (opts.units) addUnitSections(project, sections, notes);
|
||||
return { title: t("areas.title"), ...reportHead(project), sections, notes };
|
||||
}
|
||||
|
||||
|
||||
@@ -55,10 +55,10 @@ describe("Tabellen auf dem Blatt ([111])", () => {
|
||||
|
||||
it("alle Quellen liefern Primitive; Katalog nennt die Spalten", () => {
|
||||
const cat = tableCatalog(sampleProject);
|
||||
expect(Object.keys(cat.sources).sort()).toEqual(["areas", "costs", "designOptionCompare", "earthworks", "elements", "openings", "roomBook", "rooms", "siteProof"]);
|
||||
const p = withTables((["openings", "areas", "rooms", "elements", "earthworks", "roomBook", "costs", "siteProof", "designOptionCompare"] as const).map((source) => table({ id: source, source })));
|
||||
expect(Object.keys(cat.sources).sort()).toEqual(["areas", "costs", "designOptionCompare", "earthworks", "elements", "openings", "roomBook", "rooms", "siteProof", "unitSchedule"]);
|
||||
const p = withTables((["openings", "areas", "rooms", "elements", "earthworks", "roomBook", "costs", "siteProof", "designOptionCompare", "unitSchedule"] as const).map((source) => table({ id: source, source })));
|
||||
const out = sheetTables(p, "L1");
|
||||
expect(out.map((o) => o.id)).toEqual(["openings", "areas", "rooms", "elements", "earthworks", "roomBook", "costs", "siteProof", "designOptionCompare"]);
|
||||
expect(out.map((o) => o.id)).toEqual(["openings", "areas", "rooms", "elements", "earthworks", "roomBook", "costs", "siteProof", "designOptionCompare", "unitSchedule"]);
|
||||
for (const o of out) expect(o.prims.some((x) => x.k === "text")).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ interface Catalog {
|
||||
valueKeys: string[];
|
||||
}
|
||||
|
||||
export const TABLE_SOURCES: readonly LayoutTableSource[] = ["openings", "areas", "rooms", "elements", "earthworks", "roomBook", "costs", "siteProof", "designOptionCompare"];
|
||||
export const TABLE_SOURCES: readonly LayoutTableSource[] = ["openings", "areas", "rooms", "elements", "earthworks", "roomBook", "costs", "siteProof", "designOptionCompare", "unitSchedule"];
|
||||
|
||||
export function tableSourceLabel(s: LayoutTableSource): string {
|
||||
return t(`sheetTable.source.${s}`);
|
||||
|
||||
@@ -4919,6 +4919,57 @@ export const de = {
|
||||
"cmd.designOptionCopy.prompt": "Kopieren in Variante (z. B. Dachform=B, Variantenname oder Nummer; H = Hauptmodell)",
|
||||
"cmd.designOption.needsSelection": "Zuerst Elemente wählen, dann die Variante wählen.",
|
||||
"cmd.designOption.needsSet": "Das Projekt hat noch keinen Variantensatz (Ressourcen › Varianten).",
|
||||
"sheetTable.source.unitSchedule": "Wohnungsspiegel",
|
||||
"units.title": "Nutzungseinheiten und Wohnungsspiegel",
|
||||
"units.col.name": "Nr.",
|
||||
"units.col.type": "Typ",
|
||||
"units.col.usage": "Nutzung",
|
||||
"units.col.rooms": "Zimmer",
|
||||
"units.col.outdoor": "Aussenraum m²",
|
||||
"units.col.note": "Bemerkung",
|
||||
"units.col.count": "Anzahl",
|
||||
"units.col.avgHnf": "Ø HNF m²",
|
||||
"units.col.floor": "Geschoss",
|
||||
"units.col.roomsCount": "Räume",
|
||||
"units.usage.living": "Wohnen",
|
||||
"units.usage.commercial": "Gewerbe",
|
||||
"units.usage.office": "Büro",
|
||||
"units.usage.other": "Andere",
|
||||
"units.add": "Neue Einheit",
|
||||
"units.addFromSelection": "Neue Einheit aus Auswahl",
|
||||
"units.assign": "Auswahl zuordnen",
|
||||
"units.assignTo": "Ausgewählte Räume zuordnen zu …",
|
||||
"units.delete": "Einheit löschen (Räume bleiben, ohne Einheit)",
|
||||
"units.empty": "Noch keine Nutzungseinheiten. Räume wählen und „Neue Einheit aus Auswahl“ — oder im Raum unter Einheit „Neue Einheit …“.",
|
||||
"units.nameDefault": "Whg",
|
||||
"units.autoType": "automatisch",
|
||||
"units.typeHint": "Typ, z. B. 3.5-Zi-Whg (leer: aus der Zimmerzahl)",
|
||||
"units.nameHint": "Nummer, z. B. 2.1",
|
||||
"units.color": "Farbe der Einheit",
|
||||
"units.rooms": "{n} Räume",
|
||||
"units.table": "Wohnungsspiegel [m²]",
|
||||
"units.byType": "Summe je Typ",
|
||||
"units.byLevel": "Summe je Geschoss",
|
||||
"units.unassigned": "Räume ohne Einheit (Gemeinschaftsflächen)",
|
||||
"units.noType": "ohne Typ",
|
||||
"units.exportCsv": "Spiegel CSV",
|
||||
"units.exportPdf": "Spiegel PDF",
|
||||
"units.export.empty": "Noch keine Nutzungseinheiten — der Spiegel wäre leer. Es wurde nichts exportiert.",
|
||||
"units.exportPdf.fail": "PDF-Export des Wohnungsspiegels fehlgeschlagen.",
|
||||
"units.foot": "Wohnungsspiegel: Flächen je Raum nach SIA 416 (NF = HNF + NNF), Aussenraum = Aussengeschossfläche (Balkon, Loggia); Zimmerzahl nur Wohnnutzung: Wohnen, Schlafen, Essen, Büro = 1, sonst 0, je Raum einstellbar (Wohnküche 0.5). Maisonetten zählen in jedem Geschoss.",
|
||||
"units.field": "Einheit",
|
||||
"units.field.none": "– keine –",
|
||||
"units.field.new": "Neue Einheit …",
|
||||
"units.roomCount": "Zimmer-Zählung",
|
||||
"units.roomCount.auto": "automatisch (aus Nutzung)",
|
||||
"units.roomCount.hint": "Beitrag zur Zimmerzahl der Einheit: 1 = Zimmer, 0.5 = halbes Zimmer/Wohnküche, 0 = zählt nicht",
|
||||
"units.roomCount.0": "0 (zählt nicht)",
|
||||
"units.roomCount.05": "0.5",
|
||||
"units.roomCount.1": "1",
|
||||
"units.roomCount.15": "1.5",
|
||||
"units.roomCount.2": "2",
|
||||
"units.zi": "{n} Zi",
|
||||
"units.plan.layer": "Nutzungseinheiten",
|
||||
} as const;
|
||||
|
||||
export type TranslationKey = keyof typeof de;
|
||||
@@ -4905,4 +4905,55 @@ export const en: Record<TranslationKey, string> = {
|
||||
"cmd.designOptionCopy.prompt": "Copy into option (e.g. Roof=B, option name or number; H = main model)",
|
||||
"cmd.designOption.needsSelection": "Select elements first, then choose the option.",
|
||||
"cmd.designOption.needsSet": "The project has no option set yet (Resources › Design options).",
|
||||
"sheetTable.source.unitSchedule": "Unit schedule",
|
||||
"units.title": "Units and unit schedule",
|
||||
"units.col.name": "No.",
|
||||
"units.col.type": "Type",
|
||||
"units.col.usage": "Use",
|
||||
"units.col.rooms": "Rooms",
|
||||
"units.col.outdoor": "Outdoor m²",
|
||||
"units.col.note": "Note",
|
||||
"units.col.count": "Count",
|
||||
"units.col.avgHnf": "Avg. HNF m²",
|
||||
"units.col.floor": "Floor",
|
||||
"units.col.roomsCount": "Spaces",
|
||||
"units.usage.living": "Residential",
|
||||
"units.usage.commercial": "Commercial",
|
||||
"units.usage.office": "Office",
|
||||
"units.usage.other": "Other",
|
||||
"units.add": "New unit",
|
||||
"units.addFromSelection": "New unit from selection",
|
||||
"units.assign": "Assign selection",
|
||||
"units.assignTo": "Assign selected rooms to …",
|
||||
"units.delete": "Delete unit (rooms stay, without unit)",
|
||||
"units.empty": "No units yet. Select rooms and use “New unit from selection”, or choose “New unit …” in the room's Unit field.",
|
||||
"units.nameDefault": "Apt",
|
||||
"units.autoType": "automatic",
|
||||
"units.typeHint": "Type, e.g. 3.5-room apartment (empty: from room count)",
|
||||
"units.nameHint": "Number, e.g. 2.1",
|
||||
"units.color": "Unit color",
|
||||
"units.rooms": "{n} spaces",
|
||||
"units.table": "Unit schedule [m²]",
|
||||
"units.byType": "Totals by type",
|
||||
"units.byLevel": "Totals by floor",
|
||||
"units.unassigned": "Spaces without unit (common areas)",
|
||||
"units.noType": "no type",
|
||||
"units.exportCsv": "Schedule CSV",
|
||||
"units.exportPdf": "Schedule PDF",
|
||||
"units.export.empty": "No units yet — the schedule would be empty. Nothing was exported.",
|
||||
"units.exportPdf.fail": "PDF export of the unit schedule failed.",
|
||||
"units.foot": "Unit schedule: areas per room to SIA 416 (NF = HNF + NNF), outdoor = external floor area (balcony, loggia); room count for residential use only: living, sleeping, dining, office = 1, else 0, adjustable per room (open kitchen 0.5). Maisonettes count on each floor.",
|
||||
"units.field": "Unit",
|
||||
"units.field.none": "– none –",
|
||||
"units.field.new": "New unit …",
|
||||
"units.roomCount": "Room count",
|
||||
"units.roomCount.auto": "automatic (from use)",
|
||||
"units.roomCount.hint": "Contribution to the unit's room count: 1 = room, 0.5 = half room/open kitchen, 0 = not counted",
|
||||
"units.roomCount.0": "0 (not counted)",
|
||||
"units.roomCount.05": "0.5",
|
||||
"units.roomCount.1": "1",
|
||||
"units.roomCount.15": "1.5",
|
||||
"units.roomCount.2": "2",
|
||||
"units.zi": "{n} rm",
|
||||
"units.plan.layer": "Units",
|
||||
};
|
||||
@@ -20,6 +20,8 @@ import type {
|
||||
Project,
|
||||
Room,
|
||||
RoomStamp,
|
||||
RoomUsage,
|
||||
Unit,
|
||||
RoofType,
|
||||
SiaCategory,
|
||||
Vec2,
|
||||
@@ -223,6 +225,21 @@ const ROOMS_PER_FLOOR: RoomDef[] = [
|
||||
[P(10, 9.5), "10", "Abstellraum", "NNF"],
|
||||
];
|
||||
|
||||
/** Nutzung je Raumname (Raumbuch, Zimmerzahl im Wohnungsspiegel [278]). */
|
||||
const USAGE: Record<string, RoomUsage> = { "Wohnen/Essen": "living", Zimmer: "sleeping", Diele: "circulation", Bad: "bath", Treppenhaus: "circulation", Eingang: "circulation", Abstellraum: "storage" };
|
||||
/** [278] Nutzungseinheiten: je Geschoss eine West- (Räume 01–04) und eine Ost-Wohnung (05–08); Nummer „Geschoss.Seite“ (EG = 0). */
|
||||
const UNIT_NR = { eg: "0", og1: "1", og2: "2" } as const;
|
||||
const unitOf = (floor: keyof typeof UNIT_NR, key: string): string | undefined => {
|
||||
const n = Number(key);
|
||||
return n >= 1 && n <= 4 ? `whg-${floor}-w` : n >= 5 && n <= 8 ? `whg-${floor}-o` : undefined;
|
||||
};
|
||||
function units(): Unit[] {
|
||||
return FLOORS.flatMap((f) => [
|
||||
{ id: `whg-${f.id}-w`, name: `${UNIT_NR[f.id]}.1`, usage: "living" as const, color: "#4f8fc0" },
|
||||
{ id: `whg-${f.id}-o`, name: `${UNIT_NR[f.id]}.2`, usage: "living" as const, color: "#c0874f" },
|
||||
]);
|
||||
}
|
||||
|
||||
function addRooms(p: Project): Project {
|
||||
const prefix = { eg: "E", og1: "1", og2: "2" } as const;
|
||||
for (const f of FLOORS) {
|
||||
@@ -235,7 +252,10 @@ function addRooms(p: Project): Project {
|
||||
const made = ops.find((o) => o.kind === "add" && o.collection === "rooms");
|
||||
if (!made || made.kind !== "add") throw new Error(`Wettbewerb: Raum ${nr} nicht erkannt`);
|
||||
const stamp: RoomStamp = { number: nr, name, showFloorArea: true, showUsage: false, roundingStep: 0.1 };
|
||||
const room = { ...(made.items[0] as unknown as Room), id: `raum-${nr}`, name, siaCategory: cat, stamp };
|
||||
const unitId = unitOf(f.id, key);
|
||||
// Ost-Wohnungen: Wohnen/Essen mit offener Küche zählt 1.5 Zimmer (2.5-Zi-Whg), West: 2-Zi-Whg nach der Vorgabe aus der Nutzung.
|
||||
const roomCount = unitId?.endsWith("-o") && baseName === "Wohnen/Essen" ? 1.5 : undefined;
|
||||
const room = { ...(made.items[0] as unknown as Room), id: `raum-${nr}`, name, siaCategory: cat, stamp, usage: USAGE[name], ...(unitId ? { unitId } : {}), ...(roomCount !== undefined ? { roomCount } : {}) };
|
||||
p = applyOps(p, [{ kind: "add", collection: "rooms", items: [room as unknown as { id: string }] } as CoreOp]);
|
||||
}
|
||||
}
|
||||
@@ -274,6 +294,7 @@ export function buildWettbewerbSampleProject(): Project {
|
||||
roofs,
|
||||
stairs,
|
||||
rooms: [],
|
||||
units: units(),
|
||||
drawings2d: cadastre(),
|
||||
context: [neighbours()],
|
||||
// Raumprogramm des Wettbewerbs (Soll); die Räume im Modell liefern das Ist.
|
||||
@@ -322,6 +343,8 @@ export function buildWettbewerbSampleProject(): Project {
|
||||
],
|
||||
layouts: [
|
||||
{ id: "lay-situation", name: "Situation 1:500", paper: "a3", orientation: "landscape", planNumber: "001", viewports: [{ id: "vp-situation", snapshotId: "vs-situation", xMm: 20, yMm: 20, widthMm: 380, heightMm: 260, scaleDenominator: 500 }] },
|
||||
// [278] Wohnungsspiegel als lebendige Tabelle (folgt dem Modell).
|
||||
{ id: "lay-wohnungsspiegel", name: "Wohnungsspiegel", paper: "a4", orientation: "landscape", planNumber: "002", viewports: [], tables: [{ id: "tab-wohnungsspiegel", source: "unitSchedule", xMm: 20, yMm: 20, widthMm: 257 }] },
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
@@ -2213,7 +2213,8 @@ export type LayoutTableSource =
|
||||
| "roomBook"
|
||||
| "costs"
|
||||
| "siteProof"
|
||||
| "designOptionCompare";
|
||||
| "designOptionCompare"
|
||||
| "unitSchedule";
|
||||
|
||||
/**
|
||||
* Einfache Textfelder des Titelblocks (Master). Alle optional — leere Felder
|
||||
@@ -3376,6 +3377,10 @@ export type Project = {
|
||||
* [272] Benannte Variantenkombinationen (Archicad „Design Option Combinations“): je Satz genau eine Variante.
|
||||
*/
|
||||
designOptionCombinations?: Array<DesignOptionCombination>;
|
||||
/**
|
||||
* [278] Nutzungseinheiten (Wohnungen, Gewerbe) für den Wohnungsspiegel; Räume verweisen mit `unitId` darauf.
|
||||
*/
|
||||
units?: Array<Unit>;
|
||||
};
|
||||
|
||||
/** Protokolleintrag einer Publikation ([79]): Datum, Blätter mit Revision, erzeugte Dateien. */
|
||||
@@ -3770,6 +3775,16 @@ export type Room = {
|
||||
* [272] Variante, zu der das Element gehört (`Project.designOptionSets`). Fehlt ⇒ Hauptmodell (immer sichtbar).
|
||||
*/
|
||||
designOption?: DesignOptionRef;
|
||||
/**
|
||||
* [278] Nutzungseinheit (`Project.units`, Id), zu der der Raum gehört (Wohnung, Gewerbeeinheit). Fehlt oder
|
||||
* unbekannt ⇒ keiner Einheit zugeordnet (Gemeinschaftsfläche).
|
||||
*/
|
||||
unitId?: string;
|
||||
/**
|
||||
* [278] Zimmerzahl-Beitrag dieses Raums für den Wohnungsspiegel (CH-Konvention: Zimmer 1, Wohnküche/halbes Zimmer 0.5,
|
||||
* Nebenraum 0). Fehlt ⇒ Vorgabe aus der Nutzung (`unit_schedule::default_room_count`).
|
||||
*/
|
||||
roomCount?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -4445,6 +4460,29 @@ export type UiViewTabs = {
|
||||
activeId: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* [278] Nutzungseinheit (Wohnung, Gewerbe-, Büroeinheit): fasst Räume für den Wohnungsspiegel zusammen. Die Räume
|
||||
* verweisen mit `Room.unitId` auf sie; Fläche, Geschoss und Zimmerzahl rechnet der Kern aus den Räumen.
|
||||
*/
|
||||
export type Unit = {
|
||||
id: string;
|
||||
/** Nummer/Bezeichnung, z. B. „2.1“. */
|
||||
name: string;
|
||||
/**
|
||||
* Typ, z. B. „3.5-Zi-Whg“. Fehlt er, leitet der Spiegel bei Wohnungen „n-Zi-Whg“ aus der Zimmerzahl ab.
|
||||
*/
|
||||
unitType?: string;
|
||||
/** Nutzung (Fehlt ⇒ Wohnen). */
|
||||
usage?: UnitUsage;
|
||||
/** Farbe der Einheit (hex) für Darstellungen. */
|
||||
color?: string;
|
||||
/** Bemerkung (reiner Text). */
|
||||
note?: string;
|
||||
};
|
||||
|
||||
/** [278] Nutzung einer Nutzungseinheit. */
|
||||
export type UnitUsage = "living" | "commercial" | "office" | "other";
|
||||
|
||||
export type Vec2 = { x: number; y: number };
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,7 @@ import { exportProjectName, areaReportToCsv, buildAreaReport, buildAreaReportPdf
|
||||
import type { AgfBasis } from "../core";
|
||||
import { DEFAULT_AREA_INPUTS, ivhbOptionsOf, type AreaInputs } from "./areaInputs";
|
||||
import { downloadCsv } from "./downloadFile";
|
||||
import { ReportTable } from "./ReportTable";
|
||||
import { runWithAnonymityGate } from "../state/anonymityGate";
|
||||
import { useStore } from "../state/appStore";
|
||||
|
||||
@@ -26,6 +27,8 @@ export function AreaTableSection() {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[project, inputs],
|
||||
);
|
||||
// [278] CSV/PDF enthalten zusätzlich den Wohnungsspiegel (die Anzeige hat ihn im Abschnitt „Nutzungseinheiten“).
|
||||
const buildExport = () => buildAreaReport(project, { areas: true, ivhb: true, siteProof: true, units: true, ivhbOptions: ivhbOptionsOf(inputs) });
|
||||
const set = (patch: Partial<AreaInputs>) => setInputs((i) => ({ ...i, ...patch }));
|
||||
const stem = `${exportProjectName(project) || "projekt"}-flaechen`;
|
||||
|
||||
@@ -37,13 +40,13 @@ export function AreaTableSection() {
|
||||
};
|
||||
const exportCsv = () => {
|
||||
if (emptyHint()) return;
|
||||
runWithAnonymityGate(project, [`${stem}.csv`], () => downloadCsv(`${stem}.csv`, areaReportToCsv(report)));
|
||||
runWithAnonymityGate(project, [`${stem}.csv`], () => downloadCsv(`${stem}.csv`, areaReportToCsv(buildExport())));
|
||||
};
|
||||
const exportPdf = () => {
|
||||
if (emptyHint()) return;
|
||||
runWithAnonymityGate(project, [`${stem}.pdf`], async () => {
|
||||
try {
|
||||
(await buildAreaReportPdf(report)).save(`${stem}.pdf`);
|
||||
(await buildAreaReportPdf(buildExport())).save(`${stem}.pdf`);
|
||||
} catch {
|
||||
notify(t("areas.exportPdf.fail"));
|
||||
}
|
||||
@@ -65,40 +68,7 @@ export function AreaTableSection() {
|
||||
</div>
|
||||
|
||||
{report.sections.map((s, si) => (
|
||||
<div key={si} className="area-block">
|
||||
<div className="area-heading">{s.heading}</div>
|
||||
<div className="area-scroll">
|
||||
<table className={s.columns.length > 6 ? "area-table wide" : "area-table"}>
|
||||
<thead>
|
||||
<tr>
|
||||
{s.columns.map((c, i) => (
|
||||
<th key={i} className={i === 0 ? "" : "num"}>
|
||||
{c}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{s.rows.map((r, ri) => (
|
||||
<tr key={ri} className={r.total ? "total" : ""}>
|
||||
{r.cells.map((c, ci) =>
|
||||
typeof c === "string" ? (
|
||||
// Kurze Textzellen in Zahlenspalten (Strich, ja/nein) stehen wie die Zahlen rechts.
|
||||
<td key={ci} data-label={ci > 0 ? s.columns[ci] : undefined} className={ci > 0 && c.length <= 4 ? "num" : undefined}>
|
||||
{c}
|
||||
</td>
|
||||
) : (
|
||||
<td key={ci} data-label={ci > 0 ? s.columns[ci] : undefined} className="num">
|
||||
{c.n === null ? "–" : c.n.toFixed(c.d)}
|
||||
</td>
|
||||
),
|
||||
)}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<ReportTable key={si} section={s} />
|
||||
))}
|
||||
|
||||
<div className="area-inputs">
|
||||
|
||||
@@ -24,7 +24,7 @@ Kern; hier stehen Eingabe und Darstellung. Zustand über den Store (`src/state`)
|
||||
| `objectInfo/*.tsx` | Abschnitte je Element-Art (`WallSection`, `CeilingSection`, `RoofSections`, `OpeningSections`, `StairSection`, `RoomSection`, `RoomStampSection` (Raumstempel samt Schrift, [218]), `SolidSections`, `SectionLineSection`, `RefSections`, `TreeSection`), gemeinsame Felder (`fields.tsx`) und Info-Blöcke (`InfoBlocks.tsx`); `ObjectInfoPanel` zeigt sie als einklappbare Gruppen (`InfoGroups.tsx`, `InfoGroup.tsx`, Zustand `infoGroupState.ts`); `groups.ts` hält die Zuordnung (Attribute = nur Gestaltung, Objekt-Info = Bauteil/BIM) und das Ziel der Taste T (`[189]`) |
|
||||
| `DrawingLevelsPanel.tsx`, `LayersPanel.tsx`, `ElementTreePanel.tsx` | Zeichnungsebenen, Ebenen, Baum Geschoss → Bauteilklasse → Element |
|
||||
| `LayoutsPanel.tsx`, `PublishSection.tsx`, `ViewSnapshotsPanel.tsx` | Layouts als Baum, Publikationssätze (`[79]`), gespeicherte Ansichten |
|
||||
| `RoomBalancePanel.tsx` | Flächenbilanz mit den Abschnitten `AreaTableSection.tsx`, `KennzahlenSection.tsx`, `ProgramCompareSection.tsx`, `ElementScheduleSection.tsx`, `OpeningScheduleSection.tsx`, `RoomBookSection.tsx` |
|
||||
| `RoomBalancePanel.tsx` | Flächenbilanz mit den Abschnitten `AreaTableSection.tsx`, `KennzahlenSection.tsx`, `ProgramCompareSection.tsx`, `ElementScheduleSection.tsx`, `OpeningScheduleSection.tsx`, `RoomBookSection.tsx`, `UnitsSection.tsx` (Nutzungseinheiten und Wohnungsspiegel [278]; Ops in `unitOps.ts`, Tabelle `ReportTable.tsx`) |
|
||||
| `SitePanel.tsx` | Aktionen zu Gelände und Lage (Import, Gelände erzeugen, Baugrube; keine Import-Liste, [181]), mit `SiteRulesSection.tsx` (Baurecht), `SunStudySection.tsx` (Schatten) und `PointCloudSection.tsx` |
|
||||
| `BcfPanel.tsx`, `ClashPanel.tsx` | BCF-Themen und Kollisionsliste; Sitzungszustand in `bcfSession.ts` und `clashSession.ts` |
|
||||
| `HistoryPanel.tsx` | Undo-Verlauf mit Sprung auf einen Schritt |
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// Ein Abschnitt des Berichtsmodells (`ReportSection` aus `export/areaReport.ts`) als Tabelle im Panel. Gemeinsam für die
|
||||
// Flächentabelle (`AreaTableSection`) und den Wohnungsspiegel (`UnitsSection`): was hier steht, steht auch im Export.
|
||||
|
||||
import type { ReportSection } from "../export/areaReport";
|
||||
|
||||
export function ReportTable({ section: s }: { section: ReportSection }) {
|
||||
return (
|
||||
<div className="area-block">
|
||||
<div className="area-heading">{s.heading}</div>
|
||||
<div className="area-scroll">
|
||||
<table className={s.columns.length > 6 ? "area-table wide" : "area-table"}>
|
||||
<thead>
|
||||
<tr>
|
||||
{s.columns.map((c, i) => (
|
||||
<th key={i} className={i === 0 ? "" : "num"}>
|
||||
{c}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{s.rows.map((r, ri) => (
|
||||
<tr key={ri} className={r.total ? "total" : ""}>
|
||||
{r.cells.map((c, ci) =>
|
||||
typeof c === "string" ? (
|
||||
// Kurze Textzellen in Zahlenspalten (Strich, ja/nein) stehen wie die Zahlen rechts.
|
||||
<td key={ci} data-label={ci > 0 ? s.columns[ci] : undefined} className={ci > 0 && c.length <= 4 ? "num" : undefined}>
|
||||
{c}
|
||||
</td>
|
||||
) : (
|
||||
<td key={ci} data-label={ci > 0 ? s.columns[ci] : undefined} className="num">
|
||||
{c.n === null ? "–" : c.n.toFixed(c.d)}
|
||||
</td>
|
||||
),
|
||||
)}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import type { Room } from "../model/types";
|
||||
import { roomDisplayName } from "../model/roomStamp";
|
||||
import { KennzahlenSection } from "./KennzahlenSection";
|
||||
import { AreaTableSection } from "./AreaTableSection";
|
||||
import { UnitsSection } from "./UnitsSection";
|
||||
import { CostEstimateSection } from "./CostEstimateSection";
|
||||
import { OpeningScheduleSection } from "./OpeningScheduleSection";
|
||||
import { ElementScheduleSection } from "./ElementScheduleSection";
|
||||
@@ -85,6 +86,9 @@ export function RoomBalancePanel() {
|
||||
{/* Flächentabelle und IVHB-Kennziffern. */}
|
||||
<AreaTableSection />
|
||||
|
||||
{/* Nutzungseinheiten und Wohnungsspiegel ([278]). */}
|
||||
<UnitsSection />
|
||||
|
||||
{/* Kostenschätzung grob ([209]). */}
|
||||
<CostEstimateSection />
|
||||
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
// Nutzungseinheiten und Wohnungsspiegel im Flächenbilanz-Panel ([278]).
|
||||
//
|
||||
// • Liste der Einheiten (Nummer, Typ, Nutzung, Farbe) bearbeiten, neue Einheit anlegen (leer oder aus der Raum-Auswahl),
|
||||
// Auswahl einer Einheit zuordnen, Einheit löschen (die Räume bleiben, ohne Einheit).
|
||||
// • Wohnungsspiegel (Einheiten mit Zimmerzahl und Flächen, Summe je Typ und je Geschoss) aus demselben Berichtsmodell wie
|
||||
// CSV/PDF (`buildAreaReport` mit `units`); gerechnet im Kern (`unit_schedule.rs`).
|
||||
// Alle Änderungen laufen über `applyChange` (Ops), eine Aktion = ein Undo-Schritt; Tippen verschmilzt über den coalesceKey.
|
||||
|
||||
import { useMemo } from "react";
|
||||
import { t } from "../i18n";
|
||||
import { useStore } from "../state/appStore";
|
||||
import { UNIT_USAGES, buildAreaReport, computeUnitSchedule, exportProjectName, areaReportToCsv, buildAreaReportPdf } from "../core";
|
||||
import type { Project, UnitUsage } from "../model/types";
|
||||
import { ReportTable } from "./ReportTable";
|
||||
import { downloadCsv } from "./downloadFile";
|
||||
import { runWithAnonymityGate } from "../state/anonymityGate";
|
||||
import { addUnitOps, assignRoomsOps, deleteUnitOps, draftUnit, patchUnitOps } from "./unitOps";
|
||||
|
||||
/** Auswahlwert „keine Einheit“ (leer ist der Platzhalter). */
|
||||
const NONE = "-";
|
||||
|
||||
export function UnitsSection() {
|
||||
const project = useStore((s) => s.project);
|
||||
const applyChange = useStore((s) => s.applyChange);
|
||||
const notify = useStore((s) => s.notify);
|
||||
const selectedRooms = useStore((s) => s.selection.rooms);
|
||||
const units = project.units ?? [];
|
||||
const sched = useMemo(() => computeUnitSchedule(project), [project]);
|
||||
const rowOf = new Map(sched.units.map((r) => [r.id, r]));
|
||||
// Reihenfolge der Liste wie im Spiegel (nach Nummer natürlich sortiert).
|
||||
const ordered = sched.units.map((r) => units.find((u) => u.id === r.id)).filter((u): u is NonNullable<typeof u> => !!u);
|
||||
const report = useMemo(() => buildAreaReport(project, { areas: false, units: true }), [project]);
|
||||
const stem = `${exportProjectName(project) || "projekt"}-wohnungsspiegel`;
|
||||
|
||||
const add = (fromSelection: boolean) =>
|
||||
applyChange((p: Project) => addUnitOps(p, draftUnit(p, t("units.nameDefault")), fromSelection ? selectedRooms : []));
|
||||
const patch = (id: string, field: string, v: Parameters<typeof patchUnitOps>[2]) => applyChange((p: Project) => patchUnitOps(p, id, v), `unit:${id}:${field}`);
|
||||
const assign = (unitId: string) => {
|
||||
if (selectedRooms.length === 0 || unitId === "") return;
|
||||
applyChange((p: Project) => assignRoomsOps(p, selectedRooms, unitId === NONE ? undefined : unitId));
|
||||
};
|
||||
|
||||
const exportCsv = () => {
|
||||
if (!units.length) return notify(t("units.export.empty"));
|
||||
runWithAnonymityGate(project, [`${stem}.csv`], () => downloadCsv(`${stem}.csv`, areaReportToCsv(report)));
|
||||
};
|
||||
const exportPdf = () => {
|
||||
if (!units.length) return notify(t("units.export.empty"));
|
||||
runWithAnonymityGate(project, [`${stem}.pdf`], async () => {
|
||||
try {
|
||||
(await buildAreaReportPdf(report)).save(`${stem}.pdf`);
|
||||
} catch {
|
||||
notify(t("units.exportPdf.fail"));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="area-section units-section" data-testid="units-section">
|
||||
<div className="balance-head">
|
||||
<span className="balance-section-label">{t("units.title")}</span>
|
||||
<span className="area-actions">
|
||||
<button type="button" className="balance-export" onClick={exportCsv}>
|
||||
{t("units.exportCsv")}
|
||||
</button>
|
||||
<button type="button" className="balance-export" onClick={exportPdf}>
|
||||
{t("units.exportPdf")}
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{units.length === 0 && <div className="balance-empty">{t("units.empty")}</div>}
|
||||
|
||||
{ordered.length > 0 && (
|
||||
<div className="units-list">
|
||||
{ordered.map((u) => {
|
||||
const r = rowOf.get(u.id);
|
||||
return (
|
||||
<div key={u.id} className="units-row" data-testid="unit-row">
|
||||
<input
|
||||
type="text"
|
||||
className="kz-input units-name"
|
||||
value={u.name}
|
||||
title={t("units.nameHint")}
|
||||
placeholder={t("units.nameHint")}
|
||||
onChange={(e) => patch(u.id, "name", { name: e.target.value })}
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
className="kz-input units-type"
|
||||
value={u.unitType ?? ""}
|
||||
title={t("units.typeHint")}
|
||||
placeholder={r?.typeLabel || t("units.autoType")}
|
||||
onChange={(e) => patch(u.id, "type", { unitType: e.target.value === "" ? undefined : e.target.value })}
|
||||
/>
|
||||
<button type="button" className="site-remove" title={t("units.delete")} aria-label={t("units.delete")} onClick={() => applyChange((p: Project) => deleteUnitOps(p, u.id))}>
|
||||
×
|
||||
</button>
|
||||
<select
|
||||
className="kz-input units-usage"
|
||||
value={u.usage ?? "living"}
|
||||
aria-label={t("units.col.usage")}
|
||||
title={t("units.col.usage")}
|
||||
onChange={(e) => patch(u.id, "usage", { usage: e.target.value as UnitUsage })}
|
||||
>
|
||||
{UNIT_USAGES.map((x) => (
|
||||
<option key={x} value={x}>
|
||||
{t(`units.usage.${x}`)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<input
|
||||
type="color"
|
||||
className="units-color"
|
||||
value={u.color ?? "#9aa4b2"}
|
||||
title={t("units.color")}
|
||||
aria-label={t("units.color")}
|
||||
onChange={(e) => patch(u.id, "color", { color: e.target.value })}
|
||||
/>
|
||||
<span className="units-facts" title={r ? t("units.rooms", { n: r.rooms }) : undefined}>
|
||||
{r ? `${r.usage === "living" ? t("units.zi", { n: r.roomCount }) + " · " : ""}${r.hnf.toFixed(1)} m²` : ""}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="kz-program-actions">
|
||||
<button type="button" className="kz-add" onClick={() => add(false)}>
|
||||
{t("units.add")}
|
||||
</button>
|
||||
<button type="button" className="kz-add" disabled={selectedRooms.length === 0} onClick={() => add(true)}>
|
||||
{t("units.addFromSelection")}
|
||||
</button>
|
||||
{units.length > 0 && (
|
||||
<select className="kz-input" value="" disabled={selectedRooms.length === 0} aria-label={t("units.assignTo")} title={t("units.assignTo")} onChange={(e) => assign(e.target.value)}>
|
||||
<option value="">{t("units.assign")}</option>
|
||||
<option value={NONE}>{t("units.field.none")}</option>
|
||||
{ordered.map((u) => (
|
||||
<option key={u.id} value={u.id}>
|
||||
{u.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{report.sections.map((s, si) => (
|
||||
<ReportTable key={si} section={s} />
|
||||
))}
|
||||
{report.sections.length > 0 && (
|
||||
<ul className="area-notes">
|
||||
{report.notes.map((n, i) => (
|
||||
<li key={i}>{n}</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import { t } from "../../i18n";
|
||||
import { Dropdown } from "../../ui/Dropdown";
|
||||
import type { SiaCategory, Project, Room } from "../../model/types";
|
||||
import { SIA_CATEGORIES, siaLabelFull, patchItems, roomBook, ROOM_USAGES, usageLabel } from "../../core";
|
||||
import { addUnitOps, assignRoomsOps, draftUnit } from "../unitOps";
|
||||
import { formatM } from "../../model/types";
|
||||
import { useStore } from "../../state/appStore";
|
||||
import type { TranslationKey } from "../../i18n";
|
||||
@@ -82,6 +83,78 @@ export function RoomSection({
|
||||
|
||||
{/* [158] Raumbuch: Nutzung und Oberflächen. */}
|
||||
<RoomFinishFields roomId={roomId} />
|
||||
|
||||
{/* [278] Nutzungseinheit und Zimmer-Zählung (Wohnungsspiegel). */}
|
||||
<RoomUnitFields roomId={roomId} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
const UNIT_NONE = "";
|
||||
const UNIT_NEW = "__new";
|
||||
const UNIT_MIXED = "__mixed";
|
||||
/** Zimmer-Zählung: automatisch (aus der Nutzung) oder fest 0 / 0.5 / 1 / 1.5 / 2. */
|
||||
const ROOM_COUNTS = [0, 0.5, 1, 1.5, 2] as const;
|
||||
const COUNT_KEY = { 0: "units.roomCount.0", 0.5: "units.roomCount.05", 1: "units.roomCount.1", 1.5: "units.roomCount.15", 2: "units.roomCount.2" } as const satisfies Record<(typeof ROOM_COUNTS)[number], TranslationKey>;
|
||||
|
||||
/** [278] Einheit des Raums (Auswahl, „Neue Einheit …“) und Beitrag zur Zimmerzahl. Bei Mehrfachauswahl gilt die Wahl für alle
|
||||
* gewählten Räume in einem Undo-Schritt; unterschiedliche Werte zeigt die Auswahl als „gemischt“. */
|
||||
function RoomUnitFields({ roomId }: { roomId: string }) {
|
||||
const project = useStore((st) => st.project);
|
||||
const applyChange = useStore((s) => s.applyChange);
|
||||
const selectedRooms = useStore((s) => s.selection.rooms);
|
||||
const room = (project.rooms ?? []).find((r) => r.id === roomId);
|
||||
if (!room) return null;
|
||||
const ids = selectedRooms.length > 1 && selectedRooms.includes(roomId) ? [...selectedRooms] : [roomId];
|
||||
const group = ids.map((id) => (project.rooms ?? []).find((r) => r.id === id)).filter((r): r is Room => !!r);
|
||||
const unitIds = new Set(group.map((r) => r.unitId ?? UNIT_NONE));
|
||||
const counts = new Set(group.map((r) => (r.roomCount === undefined ? "auto" : String(r.roomCount))));
|
||||
const units = project.units ?? [];
|
||||
const known = new Set(units.map((u) => u.id));
|
||||
const unitValue = unitIds.size > 1 ? UNIT_MIXED : known.has(room.unitId ?? "") ? (room.unitId as string) : UNIT_NONE;
|
||||
const countValue = counts.size > 1 ? UNIT_MIXED : room.roomCount === undefined ? "auto" : String(room.roomCount);
|
||||
const onUnit = (v: string) => {
|
||||
if (v === UNIT_MIXED) return;
|
||||
if (v === UNIT_NEW) applyChange((p: Project) => addUnitOps(p, draftUnit(p, t("units.nameDefault")), ids), "unit:new");
|
||||
else applyChange((p: Project) => assignRoomsOps(p, ids, v === UNIT_NONE ? undefined : v), `room:${roomId}:unit`);
|
||||
};
|
||||
const onCount = (v: string) => {
|
||||
if (v === UNIT_MIXED) return;
|
||||
applyChange((p: Project) => patchItems(p, "rooms", ids, (r) => ({ ...r, roomCount: v === "auto" ? undefined : Number(v) }) as Room), `room:${roomId}:roomCount`);
|
||||
};
|
||||
const mixed = { value: UNIT_MIXED, label: t("objsettings.mixed"), disabled: true };
|
||||
return (
|
||||
<>
|
||||
<div className="objinfo-section-label">{t("units.title")}</div>
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("units.field")}</span>
|
||||
<Dropdown
|
||||
value={unitValue}
|
||||
onChange={onUnit}
|
||||
options={[
|
||||
...(unitValue === UNIT_MIXED ? [mixed] : []),
|
||||
{ value: UNIT_NONE, label: t("units.field.none") },
|
||||
...units.map((u) => ({ value: u.id, label: u.unitType ? `${u.name} · ${u.unitType}` : u.name })),
|
||||
{ value: UNIT_NEW, label: t("units.field.new") },
|
||||
]}
|
||||
title={t("units.field")}
|
||||
width={170}
|
||||
/>
|
||||
</div>
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("units.roomCount")}</span>
|
||||
<Dropdown
|
||||
value={countValue}
|
||||
onChange={onCount}
|
||||
options={[
|
||||
...(countValue === UNIT_MIXED ? [mixed] : []),
|
||||
{ value: "auto", label: t("units.roomCount.auto") },
|
||||
...ROOM_COUNTS.map((c) => ({ value: String(c), label: t(COUNT_KEY[c]) })),
|
||||
]}
|
||||
title={t("units.roomCount.hint")}
|
||||
width={170}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// Ops der Nutzungseinheiten ([278]): Einheit anlegen, Räumen zuordnen, löschen. Jede Funktion liefert alle Ops einer
|
||||
// Benutzeraktion (Projekt-Feld `units` und `unitId` der Räume), damit `applyChange` sie zu EINEM Undo-Schritt macht.
|
||||
|
||||
import type { Project, Room, Unit } from "../model/types";
|
||||
import { setField, patchItems, nextUnitName, newUnitId } from "../core";
|
||||
import type { CoreOp } from "../core";
|
||||
|
||||
/** Räume `roomIds` der Einheit `unitId` zuordnen (`undefined` = keiner Einheit). */
|
||||
export function assignRoomsOps(p: Project, roomIds: readonly string[], unitId: string | undefined): CoreOp[] {
|
||||
return patchItems(p, "rooms", roomIds, (r) => ({ ...r, unitId }) as Room);
|
||||
}
|
||||
|
||||
/** Neue Einheit anlegen und (optional) `roomIds` ihr zuordnen. `id` kommt vom Aufrufer, damit er sie danach kennt. */
|
||||
export function addUnitOps(p: Project, unit: Unit, roomIds: readonly string[] = []): CoreOp[] {
|
||||
return [setField("units", [...(p.units ?? []), unit]), ...assignRoomsOps(p, roomIds, unit.id)];
|
||||
}
|
||||
|
||||
/** Vorschlag einer neuen Einheit (Name „Whg n“, frische id). */
|
||||
export function draftUnit(p: Project, namePrefix: string): Unit {
|
||||
const units = p.units ?? [];
|
||||
return { id: newUnitId(units), name: nextUnitName(units, namePrefix) };
|
||||
}
|
||||
|
||||
/** Einheit ändern. */
|
||||
export function patchUnitOps(p: Project, id: string, patch: Partial<Unit>): CoreOp[] {
|
||||
const units = p.units ?? [];
|
||||
return [setField("units", units.map((u) => (u.id === id ? { ...u, ...patch } : u)))];
|
||||
}
|
||||
|
||||
/** Einheit löschen; ihre Räume bleiben, ohne Einheit. */
|
||||
export function deleteUnitOps(p: Project, id: string): CoreOp[] {
|
||||
const next = (p.units ?? []).filter((u) => u.id !== id);
|
||||
return [setField("units", next.length > 0 ? next : undefined), ...patchItems(p, "rooms", (r) => r.unitId === id, (r) => ({ ...r, unitId: undefined }) as Room)];
|
||||
}
|
||||
@@ -10494,3 +10494,35 @@ body {
|
||||
.look-icon {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* [278] Nutzungseinheiten: je Einheit drei Zeilen (Nummer · Typ · ×, Nutzung · Farbe, Kennwerte) in der schmalen Dock-Spalte. */
|
||||
.units-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
.units-row {
|
||||
display: grid;
|
||||
grid-template-columns: 4.5em minmax(0, 1fr) 2.2em;
|
||||
gap: 4px;
|
||||
align-items: center;
|
||||
padding-bottom: 6px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.units-row .units-usage {
|
||||
grid-column: 1 / 3;
|
||||
}
|
||||
.units-row .units-color {
|
||||
width: 100%;
|
||||
height: 24px;
|
||||
padding: 0;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 4px;
|
||||
background: transparent;
|
||||
}
|
||||
.units-row .units-facts {
|
||||
grid-column: 1 / -1;
|
||||
font-size: 11px;
|
||||
color: var(--ink-2);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
Reference in new issue
Block a user