[218] Raumstempel: Abschnitt in den Objekteinstellungen statt Dialog, Schrift je Zeile, Bezugspunkt/Masse nur im Panel
- Doppelklick auf Raumstempel öffnet das Fenster Objekteinstellungen mit fokussiertem Abschnitt „Raumstempel“ (RoomStampSection, openObjectSettings(deps, "roomStamp")); Overlay-Dialog RoomStampEditor(Host) und TextEditorDialog entfernt. - Modell RoomStampFont (Familie, Grösse, fett, kursiv, Farbe) am Stempel und je Zeile; Kern löst Zeile > Stempel > Vorgabe auf, Zusatzzeilen tragen StampLine.marks; stamp_block*, Anzeige-Szene (gemessene Grundlinien), SVG, Druck-SVG, DXF und HTML-Block lesen sie. Eigene Grössen gehen vor Überdeckung (fit_room_stamp_with). - Mehrfachauswahl: „gemischt“, ein Undo-Schritt für alle gewählten Räume (state/roomStampEdit.ts). - Bezugspunkt und Masse nur im Objekt-Info-Panel, nicht im Fenster (ObjectInfoPanel showPlacement=false). - Tests: Rust (Schrift/Fallback/Überdeckung/Szene), vitest (Abschnitt, gemischt, Undo, Fenster ohne Platzierung, Doppelklick-Ziel), e2e roomStamp218.
This commit is contained in:
49 files changed
+1073
-757
No files matched your search
@@ -67,6 +67,20 @@ Kennwort, anonym) als PDF; Austausch mit Fachplanern über DXF/IFC.
|
||||
Parzelle, Strassen, Nordpfeil, Massstabsbalken; als Ansichtsvorlage „Situation WBW“. · M
|
||||
- ○ **[208]** Wettbewerbs-Layouts: Plakat-Vorlagen A0/A1 hoch/quer mit Raster, Kennwort-Feld (Anonymität: kein Büroname,
|
||||
Metadaten im PDF leer), Planköpfe; Publikationssatz „WBW-Abgabe“ → PDF. · M
|
||||
- ◐ **[218]** Raumstempel bearbeiten im Objekteinstellungsfenster (13.11., Wunsch Maintainer): **Stand 13.11.:** Der Overlay-Dialog
|
||||
(„Fenster im Fenster“, `RoomStampEditor`/`RoomStampEditorHost`, samt Alt-Rich-Text-Dialog `TextEditorDialog`) ist weg. Doppelklick auf einen
|
||||
Raumstempel (oder den Raum) wählt den Raum und öffnet die Objekteinstellungen mit dem neuen Abschnitt „Raumstempel“
|
||||
(`panels/objectInfo/RoomStampSection.tsx`, Fokus-Abschnitt wie bei T, `openObjectSettings(deps, "roomStamp")`); unter Tauri im nativen
|
||||
Nebenfenster über die bestehende Spiegelung ([195b], Abschnitt schreibt über Store-Ops). Schrift wählbar: Modell `RoomStampFont`
|
||||
(Familie aus den gebündelten Schriften, Grösse pt, fett, kursiv, Farbe) am Stempel (`font`, ganzer Stempel) und je Zeile (`nameFont`,
|
||||
`line2Font`, `numberFont`, `areaFont`, `usageFont`); Auflösung im Kern `plan/domains.rs::stamp_line_marks`: Zeile > Stempel > bisherige
|
||||
Vorgabe (Name 12 pt fett, Zeile 2 9 pt kursiv, Nummer 9 pt, Zusatzzeilen 0.8 × Grundschrift); Zusatzzeilen tragen `StampLine.marks`
|
||||
(Grösse bezogen auf Grundschrift 10 pt, folgt dem Massstab 7/10 und dem Einpassen), `text_layout::stamp_block*` und alle Ausgaben
|
||||
(Anzeige-Szene `plan/text.rs` mit den gemessenen Grundlinien, SVG, Druck-SVG/PDF, DXF, HTML-Block) lesen sie. Mehrfachauswahl: gemischte
|
||||
Werte „gemischt“, Änderung für alle gewählten Räume in EINEM Undo-Schritt (`state/roomStampEdit.ts`); Nummer/Namen bleiben je Raum. Bezugspunkt und Masse
|
||||
(Breite/Höhe/Drehen, bei allen Elementarten) erscheinen nur noch im Objekt-Info-Panel, nicht im Fenster (`ObjectInfoPanel showPlacement=false`).
|
||||
**Offen:** Die Schriftfamilie zeigt der GPU-Glyphen-Pass (WebGPU/Metal, `render2d/glyph.rs`) noch nicht — er kennt nur das eingebettete Inter
|
||||
(Grösse, fett, kursiv, Farbe wirken); Familie sichtbar in SVG/PDF/DXF/HTML; Mac-Nebenfenster nicht geprüft (nur Linux-Container). · M
|
||||
- [61] Raumprogramm gegen Modell und Flächennachweis SIA 416 als Tabelle/Layout-Element ([70]); Kennzahlen (GF, GV, HNF/GF, Fassadenanteil).
|
||||
- 3D-Bilder für die Abgabe: hochaufgelöster PNG-Export (Perspektive, Axonometrie, Schatten), Sonnenstand; [205] Pausfolie.
|
||||
- [199]/[204] Plan- und App-Review-Reste im Darstellungsbereich 1:500/1:200 schliessen.
|
||||
@@ -290,7 +304,7 @@ Punktwolken/BCF-Ausbau, Windows-Paket, [C5]/[C7]/[15] Kern-Umbauten — ausser s
|
||||
nicht mehr im Stempel (Attribut des Raums; nur mit „SIA-Kategorie anzeigen“ = `showUsage`, neue Stempel Vorgabe aus), neue
|
||||
Option `showDivider` (Trennlinie unter dem Namen); Ausrichtung je Zeile bleibt wählbar. Bestehende Stempel mit
|
||||
`showUsage: true` behalten die Zeile, fehlende Ausrichtungen gelten jetzt als links. Offen: Mac-Gegenprobe (Metal/native
|
||||
Ansicht) (Kern `plan/domains.rs`, `src/panels/RoomStampEditor.tsx`). · S
|
||||
Ansicht) (Kern `plan/domains.rs`, Bearbeiten: `src/panels/objectInfo/RoomStampSection.tsx`, [218]). · S
|
||||
|
||||
- ◐ **[141]** Wandecken. 9.11.: Wand und Stütze überlappen nicht mehr — runde Stütze an der Kontur, Wand durch
|
||||
bzw. breiter als die Stütze, Stütze kürzer als die Wand (3D: `model3d::carve_at_columns`, Streifen an den
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
// [218] Raumstempel bearbeiten ist kein Dialog im Fenster mehr: Doppelklick auf einen Stempel öffnet die
|
||||
// Objekteinstellungen mit dem Abschnitt „Raumstempel“; Schrift (Familie, Grösse, fett, kursiv, Farbe) je Zeile;
|
||||
// Bezugspunkt und Masse stehen nur im Objekt-Info-Panel. Mit SHOT_DIR=<ordner> entstehen Screenshots.
|
||||
import type { Page } from "@playwright/test";
|
||||
import { blurFocus, discardIfAsked, expect, fileMenu, test } from "./app";
|
||||
import type {} from "../src/state/testHooks"; // Typ von window.__dossierTest
|
||||
|
||||
async function openComplex(page: Page): Promise<void> {
|
||||
await page.goto("/?dossierTest");
|
||||
await page.getByRole("button", { name: /Neues Projekt/ }).first().click();
|
||||
await expect(page.getByRole("group", { name: "Befehlszeile" })).toBeVisible();
|
||||
await fileMenu(page, /Musterhaus \(komplex\)/);
|
||||
await discardIfAsked(page);
|
||||
await expect(page.locator(".project-name")).toHaveText("Musterhaus komplex", { timeout: 30_000 });
|
||||
await expect(page.locator("svg.plan-svg").first()).toBeVisible({ timeout: 30_000 });
|
||||
}
|
||||
|
||||
/** Bildschirmlage eines Modellpunkts (Bildmitte + Zoom aus dem Test-Hook; Modell-y zeigt nach oben). */
|
||||
async function screenOf(page: Page, x: number, y: number): Promise<{ x: number; y: number }> {
|
||||
const cam = await page.evaluate(() => window.__dossierTest!.viewCamera());
|
||||
const box = (await page.locator("svg.plan-svg").first().boundingBox())!;
|
||||
return { x: box.x + box.width / 2 + (x - cam.center!.x) * cam.pxPerMeter!, y: box.y + box.height / 2 - (y - cam.center!.y) * cam.pxPerMeter! };
|
||||
}
|
||||
|
||||
test("Doppelklick auf Raumstempel: Objekteinstellungen mit Abschnitt Raumstempel, Schrift ändern, Undo ([218])", async ({ page }) => {
|
||||
test.setTimeout(150_000);
|
||||
await openComplex(page);
|
||||
await page.waitForTimeout(1500);
|
||||
const shots = process.env.SHOT_DIR;
|
||||
const rooms = await page.evaluate(() => window.__dossierTest!.roomCenters());
|
||||
expect(rooms.length).toBeGreaterThan(2);
|
||||
// Ein Raum, dessen Stempel im Plan steht (Wohnen o. Ä.): der grösste Name.
|
||||
let target = rooms[0];
|
||||
for (const r of rooms) {
|
||||
const st = await page.evaluate((id) => window.__dossierTest!.roomStamp(id), r.id);
|
||||
if (st) {
|
||||
target = r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const before = await page.evaluate((id) => window.__dossierTest!.roomStamp(id), target.id);
|
||||
expect(before?.name.sizePt).toBe(12);
|
||||
if (shots) await page.screenshot({ path: `${shots}/stempel-vorher.png` });
|
||||
|
||||
// Kein Fenster im Fenster: weder Overlay-Dialog noch Objekteinstellungen vor dem Doppelklick.
|
||||
await expect(page.locator(".objset-panel")).toHaveCount(0);
|
||||
const at = await screenOf(page, target.x, target.y);
|
||||
await page.mouse.dblclick(at.x, at.y);
|
||||
|
||||
const win = page.locator(".objset-panel");
|
||||
await expect(win).toBeVisible();
|
||||
await expect(page.locator(".texteditor-overlay")).toHaveCount(0);
|
||||
const group = win.locator('[data-group="roomStamp"]');
|
||||
await expect(group.locator(".objinfo-group-head")).toHaveAttribute("aria-expanded", "true");
|
||||
await expect(group.locator(".objinfo-group-head")).toBeFocused();
|
||||
// Bezugspunkt und Masse nur im Panel, nicht im Fenster.
|
||||
await expect(win.locator(".objinfo-cube")).toHaveCount(0);
|
||||
await expect(win.getByText("Bezugspunkt", { exact: true })).toHaveCount(0);
|
||||
|
||||
// Schrift der Namenszeile: 24 pt, Jost, kursiv.
|
||||
const size = group.getByTestId("roomstamp-nameFont-size");
|
||||
await size.fill("24");
|
||||
await expect.poll(async () => (await page.evaluate((id) => window.__dossierTest!.roomStamp(id), target.id))?.name.sizePt).toBeGreaterThan(11);
|
||||
await group.getByTestId("roomstamp-nameFont-italic").click();
|
||||
const nameRow = group.getByTestId("roomstamp-font-nameFont");
|
||||
await nameRow.locator(".tb-dd-trigger").click();
|
||||
await page.getByRole("option", { name: "Jost", exact: true }).click();
|
||||
await expect.poll(async () => (await page.evaluate((id) => window.__dossierTest!.roomStamp(id), target.id))?.name.font).toBe("Jost");
|
||||
const after = await page.evaluate((id) => window.__dossierTest!.roomStamp(id), target.id);
|
||||
expect(after?.name.sizePt === 24 || (after?.name.sizePt ?? 0) > 12).toBe(true);
|
||||
// Zeile Fläche: grössere Schrift.
|
||||
await group.getByTestId("roomstamp-areaFont-size").fill("14");
|
||||
await expect.poll(async () => (await page.evaluate((id) => window.__dossierTest!.roomStamp(id), target.id))?.extra[0]?.marks?.sizePt).toBe(14);
|
||||
await page.waitForTimeout(2000);
|
||||
if (shots) {
|
||||
await page.screenshot({ path: `${shots}/stempel-nachher.png` });
|
||||
await group.locator(".objinfo-group-head").scrollIntoViewIfNeeded();
|
||||
await win.screenshot({ path: `${shots}/objekteinstellungen-raumstempel.png` });
|
||||
}
|
||||
|
||||
// Undo (drei Schritte: Grösse + Schrift + Kursiv gehören zu getrennten Eingaben) → zurück auf die Vorgabe.
|
||||
await blurFocus(page);
|
||||
for (let i = 0; i < 6; i++) {
|
||||
await page.keyboard.press("Control+z");
|
||||
const cur = await page.evaluate((id) => window.__dossierTest!.roomStamp(id), target.id);
|
||||
if (cur?.name.sizePt === 12 && !cur.name.font && !cur.extra[0]?.marks) break;
|
||||
}
|
||||
const undone = await page.evaluate((id) => window.__dossierTest!.roomStamp(id), target.id);
|
||||
expect(undone?.name.sizePt).toBe(12);
|
||||
expect(undone?.name.font).toBeUndefined();
|
||||
});
|
||||
@@ -4142,6 +4142,35 @@ pub struct RichTextDoc {
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// [218] Schrift einer Zeile des Raumstempels; fehlende Werte gelten als „wie die Vorgabe" (Stempelschrift, dann
|
||||
/// die eingebauten Werte der Zeile). Grösse in typografischen Punkt auf dem Papier bei der Grundschrift 10 pt
|
||||
/// (kleinere Massstäbe verkleinern sie im Verhältnis).
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct RoomStampFont {
|
||||
/// Schriftfamilie (eine der gebündelten Schriften, z. B. "Work Sans").
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub family: Option<String>,
|
||||
/// Schriftgrösse in pt.
|
||||
#[serde(rename = "sizePt", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub size_pt: Option<f64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub bold: Option<bool>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub italic: Option<bool>,
|
||||
/// Farbe als "#rrggbb".
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub color: Option<String>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// Feldmodell des Raum-Stempels. Ersetzt den freien Text durch benannte Felder;
|
||||
/// daraus baut roomStamp.ts sowohl das gerenderte Rich-Text-Dokument als auch die
|
||||
/// Live-Zeilen. Minimal gehalten (MVP).
|
||||
@@ -4209,6 +4238,30 @@ pub struct RoomStamp {
|
||||
#[serde(rename = "showDivider", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub show_divider: Option<bool>,
|
||||
/// [218] Schrift des ganzen Stempels (Vorgabe für alle Zeilen ohne eigene Angabe).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub font: Option<RoomStampFont>,
|
||||
/// [218] Schrift der Namenszeile (Vorgabe: Stempelschrift, sonst 12 pt fett).
|
||||
#[serde(rename = "nameFont", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub name_font: Option<RoomStampFont>,
|
||||
/// [218] Schrift der zweiten Namenszeile (Vorgabe: Stempelschrift, sonst 9 pt kursiv).
|
||||
#[serde(rename = "line2Font", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub line2_font: Option<RoomStampFont>,
|
||||
/// [218] Schrift der Raumnummer (Vorgabe: Stempelschrift, sonst 9 pt).
|
||||
#[serde(rename = "numberFont", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub number_font: Option<RoomStampFont>,
|
||||
/// [218] Schrift der Bodenflächen-Zeile (Vorgabe: Stempelschrift, sonst 0.8 × Grundschrift).
|
||||
#[serde(rename = "areaFont", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub area_font: Option<RoomStampFont>,
|
||||
/// [218] Schrift der Nutzungs-Zeile (Vorgabe: Stempelschrift, sonst 0.8 × Grundschrift).
|
||||
#[serde(rename = "usageFont", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub usage_font: Option<RoomStampFont>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
|
||||
@@ -2354,7 +2354,7 @@ pub(crate) mod tests {
|
||||
Primitive::Text {
|
||||
at: v(2.0, 2.0),
|
||||
doc: RichTextDoc::default(),
|
||||
extra_lines: vec![StampLine { text: "17.01 m²".into(), align: Default::default() }],
|
||||
extra_lines: vec![StampLine::plain("17.01 m²".into(), Default::default())],
|
||||
base_pt: 10.0,
|
||||
color: "#6b7280".into(),
|
||||
room_id: Some("R1".into()),
|
||||
|
||||
@@ -357,10 +357,10 @@ fn room_labels(c: &Ctx, soffits: &[Soffit], roofs: &[RoofUnder], out: &mut Vec<P
|
||||
let mut lines = Vec::new();
|
||||
let kote = super::drawings::kote_label;
|
||||
if z.is_finite() {
|
||||
lines.push(super::prim::StampLine { text: format!("UK {}", kote(z)), align: Align::Center });
|
||||
lines.push(super::prim::StampLine::plain(format!("UK {}", kote(z)), Align::Center));
|
||||
} else if let Some((lo, hi)) = roof_range(&pts, roofs) {
|
||||
let text = if hi - lo < 0.005 { format!("UK {}", kote(lo)) } else { format!("UK {} … {}", kote(lo), kote(hi)) };
|
||||
lines.push(super::prim::StampLine { text, align: Align::Center });
|
||||
lines.push(super::prim::StampLine::plain(text, Align::Center));
|
||||
}
|
||||
out.push(Primitive::Text { at, doc: super::domains::doc_from_text(&room.name), extra_lines: lines, base_pt: LABEL_PT, color: POCHE_STROKE.into(), room_id: Some(room.id.clone()), greyed: Some(c.greyed(&room.category_code)), opacity: None });
|
||||
}
|
||||
|
||||
@@ -934,17 +934,56 @@ pub fn doc_from_text(text: &str) -> RichTextDoc {
|
||||
}
|
||||
}
|
||||
|
||||
/// [218] Gültige Farbe der Stempelschrift ("#rrggbb").
|
||||
fn valid_hex(c: &str) -> bool {
|
||||
let b = c.as_bytes();
|
||||
b.len() == 7 && b[0] == b'#' && b[1..].iter().all(|c| c.is_ascii_hexdigit())
|
||||
}
|
||||
|
||||
/// [218] Schrift einer Stempelzeile: Zeilenschrift > Stempelschrift (`all`) > eingebaute Werte der Zeile
|
||||
/// (`builtin`). Unsinn (leere Familie, Grösse ≤ 0 oder NaN, keine Hex-Farbe) zählt als nicht gesetzt.
|
||||
pub fn stamp_line_marks(line: Option<&RoomStampFont>, all: Option<&RoomStampFont>, builtin: Marks) -> Marks {
|
||||
let pick = |f: fn(&RoomStampFont) -> Option<&String>| line.and_then(f).or_else(|| all.and_then(f));
|
||||
let family = pick(|f| f.family.as_ref()).filter(|v| !v.trim().is_empty());
|
||||
let color = pick(|f| f.color.as_ref()).filter(|v| valid_hex(v));
|
||||
let size = [line, all].into_iter().flatten().find_map(|f| f.size_pt).filter(|v| v.is_finite() && *v > 0.0);
|
||||
let flag = |f: fn(&RoomStampFont) -> Option<bool>| [line, all].into_iter().flatten().find_map(f);
|
||||
Marks {
|
||||
bold: flag(|f| f.bold).or(builtin.bold),
|
||||
italic: flag(|f| f.italic).or(builtin.italic),
|
||||
font: family.cloned().or(builtin.font),
|
||||
size_pt: size.or(builtin.size_pt),
|
||||
color: color.cloned().or(builtin.color),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// [218] Trägt der Stempel eigene Schriftgrössen (am ganzen Stempel oder einer Zeile)?
|
||||
fn stamp_has_sizes(s: &RoomStamp) -> bool {
|
||||
[&s.font, &s.name_font, &s.line2_font, &s.number_font, &s.area_font, &s.usage_font].into_iter().flatten().any(|f| f.size_pt.is_some_and(|v| v.is_finite() && v > 0.0))
|
||||
}
|
||||
|
||||
/// [218] Schrift einer Zusatzzeile; `None`, wenn weder die Zeile noch der Stempel etwas festlegen (dann gilt
|
||||
/// 0.8 × Grundschrift wie bisher).
|
||||
pub fn stamp_extra_marks(line: Option<&RoomStampFont>, all: Option<&RoomStampFont>) -> Option<Marks> {
|
||||
let m = stamp_line_marks(line, all, Marks::default());
|
||||
(m != Marks::default()).then_some(m)
|
||||
}
|
||||
|
||||
/// `roomStampToDoc` ([177], Archicad-Zonenstempel): Zeile 1 = Name (gross, fett), optional Zeile 2 (kursiv),
|
||||
/// darunter die Raumnummer (klein). Ausrichtung je Absatz (Vorgabe links).
|
||||
/// darunter die Raumnummer (klein). Ausrichtung je Absatz (Vorgabe links). [218] Schrift je Zeile
|
||||
/// (`name_font` …) und für den ganzen Stempel (`font`).
|
||||
pub fn room_stamp_to_doc(s: &RoomStamp) -> RichTextDoc {
|
||||
let mut paragraphs = vec![Paragraph { runs: vec![run(s.name.clone(), Marks { bold: Some(true), size_pt: Some(NAME_PT), ..Default::default() })], align: s.name_align, ..Default::default() }];
|
||||
let all = s.font.as_ref();
|
||||
let m = |f: Option<&RoomStampFont>, builtin: Marks| stamp_line_marks(f, all, builtin);
|
||||
let mut paragraphs = vec![Paragraph { runs: vec![run(s.name.clone(), m(s.name_font.as_ref(), Marks { bold: Some(true), size_pt: Some(NAME_PT), ..Default::default() }))], align: s.name_align, ..Default::default() }];
|
||||
let line2 = js_trim(s.name_line2.as_deref().unwrap_or(""));
|
||||
if !line2.is_empty() {
|
||||
paragraphs.push(Paragraph { runs: vec![run(line2.into(), Marks { italic: Some(true), size_pt: Some(LINE2_PT), ..Default::default() })], align: s.line2_align, ..Default::default() });
|
||||
paragraphs.push(Paragraph { runs: vec![run(line2.into(), m(s.line2_font.as_ref(), Marks { italic: Some(true), size_pt: Some(LINE2_PT), ..Default::default() }))], align: s.line2_align, ..Default::default() });
|
||||
}
|
||||
let number = js_trim(s.number.as_deref().unwrap_or(""));
|
||||
if !number.is_empty() {
|
||||
paragraphs.push(Paragraph { runs: vec![run(number.into(), Marks { size_pt: Some(NUMBER_PT), ..Default::default() })], align: s.name_align, ..Default::default() });
|
||||
paragraphs.push(Paragraph { runs: vec![run(number.into(), m(s.number_font.as_ref(), Marks { size_pt: Some(NUMBER_PT), ..Default::default() }))], align: s.name_align, ..Default::default() });
|
||||
}
|
||||
RichTextDoc { version: 1.0, paragraphs, ..Default::default() }
|
||||
}
|
||||
@@ -978,13 +1017,13 @@ pub fn room_stamp_extra_lines_mv(s: &RoomStamp, net_area: f64, sia: SiaCategory,
|
||||
let mut lines = Vec::new();
|
||||
if StampOpts::line(s.show_floor_area, st.area, true) {
|
||||
let prefix = s.floor_area_prefix.as_deref().unwrap_or("");
|
||||
lines.push(StampLine { text: format!("{prefix}{} m²", format_stamp_area(net_area, s.rounding_step)), align: s.floor_area_align.unwrap_or(Align::Left) });
|
||||
lines.push(StampLine { text: format!("{prefix}{} m²", format_stamp_area(net_area, s.rounding_step)), align: s.floor_area_align.unwrap_or(Align::Left), marks: stamp_extra_marks(s.area_font.as_ref(), s.font.as_ref()) });
|
||||
}
|
||||
if StampOpts::line(s.show_usage, st.usage, false) {
|
||||
lines.push(StampLine { text: format!("{} · {}", sia_key(sia), sia_label(sia)), align: s.usage_align.unwrap_or(Align::Left) });
|
||||
lines.push(StampLine { text: format!("{} · {}", sia_key(sia), sia_label(sia)), align: s.usage_align.unwrap_or(Align::Left), marks: stamp_extra_marks(s.usage_font.as_ref(), s.font.as_ref()) });
|
||||
}
|
||||
if let Some(o) = s.occupancy {
|
||||
lines.push(StampLine { text: format!("{} Pers.", js_number(o)), align: Align::Left });
|
||||
lines.push(StampLine { text: format!("{} Pers.", js_number(o)), align: Align::Left, marks: stamp_extra_marks(None, s.font.as_ref()) });
|
||||
}
|
||||
lines
|
||||
}
|
||||
@@ -1022,7 +1061,7 @@ const STAMP_PAD_MM: f64 = 0.5;
|
||||
/// [140] Ausmass des Stempels in Metern bei 1:`scale` (echte Schriftmetrik, `text_layout::stamp_block_size`)
|
||||
/// samt Rand.
|
||||
pub(super) fn stamp_size_m(doc: &RichTextDoc, extra: &[StampLine], pt: f64, scale: f64) -> (f64, f64) {
|
||||
let rows: Vec<(&str, crate::text_layout::LineAlign)> = extra.iter().map(|l| (l.text.as_str(), crate::text_layout::LineAlign::of(Some(l.align)))).collect();
|
||||
let rows: Vec<crate::text_layout::ExtraRow> = extra.iter().map(|l| l.row()).collect();
|
||||
let (w, h) = crate::text_layout::stamp_block_size(doc, &rows, pt, PT_MM * scale / 1000.0);
|
||||
let pad = 2.0 * STAMP_PAD_MM * scale / 1000.0;
|
||||
(w * STAMP_MARGIN + pad, h * STAMP_MARGIN + pad)
|
||||
@@ -1043,7 +1082,15 @@ pub(super) fn stamp_size_m(doc: &RichTextDoc, extra: &[StampLine], pt: f64, scal
|
||||
/// `place(breite, höhe, frei)`: mit `frei` nur Lagen ohne Überdeckung anderen Planinhalts ([140] Teil 6).
|
||||
/// Zuerst sucht die ganze Reihenfolge (ohne Nummer/Kürzen) eine freie Lage — weniger Zeilen und kleinere
|
||||
/// Schrift gehen vor Überdeckung; erst wenn keine Stufe frei liegt, dieselbe Reihenfolge mit Überdeckung.
|
||||
#[cfg(test)]
|
||||
fn fit_room_stamp(doc: &RichTextDoc, number: Option<&str>, extra: Vec<StampLine>, pt: f64, scale: f64, place: &dyn Fn(f64, f64, bool) -> Option<Vec2>) -> (Vec<StampLine>, f64, Option<RichTextDoc>, Option<Vec2>) {
|
||||
fit_room_stamp_with(doc, number, extra, pt, scale, false, place)
|
||||
}
|
||||
|
||||
/// [218] Wie [`fit_room_stamp`]; `styled` = der Stempel trägt eigene Schriftgrössen. Die Grössen gehen dann vor
|
||||
/// Überdeckung: erst mit dem Namen in der gewählten Schrift (frei, dann mit Überdeckung), erst danach die
|
||||
/// Ersatzvarianten ohne eigene Grössen.
|
||||
fn fit_room_stamp_with(doc: &RichTextDoc, number: Option<&str>, extra: Vec<StampLine>, pt: f64, scale: f64, styled: bool, place: &dyn Fn(f64, f64, bool) -> Option<Vec2>) -> (Vec<StampLine>, f64, Option<RichTextDoc>, Option<Vec2>) {
|
||||
if !(scale > 0.0) || !scale.is_finite() {
|
||||
return (extra, pt, None, None);
|
||||
}
|
||||
@@ -1054,9 +1101,20 @@ fn fit_room_stamp(doc: &RichTextDoc, number: Option<&str>, extra: Vec<StampLine>
|
||||
let text = crate::text_layout::plain_text(doc);
|
||||
// Name mit eigenen Schriftgrössen (Stempel: Name 12 pt fett) schrumpft nicht mit `pt`: dann ohne
|
||||
// Auszeichnungen in der Grundschrift (Ersatz `Some`).
|
||||
let plain = doc_from_text(&text);
|
||||
// [218] Familie und Farbe des Namens bleiben auch ohne die eigenen Grössen.
|
||||
let look = doc.paragraphs.first().and_then(|q| q.runs.first()).map(|r| (r.marks.font.clone(), r.marks.color.clone()));
|
||||
let restyle = |mut d: RichTextDoc| {
|
||||
if let Some((font, color)) = &look {
|
||||
for r in d.paragraphs.iter_mut().flat_map(|q| q.runs.iter_mut()) {
|
||||
r.marks.font = font.clone();
|
||||
r.marks.color = color.clone();
|
||||
}
|
||||
}
|
||||
d
|
||||
};
|
||||
let plain = restyle(doc_from_text(&text));
|
||||
// Umbrüche, schmalste Teilung zuerst.
|
||||
let mut wraps: Vec<RichTextDoc> = wrap_variants(&text).iter().map(|t| doc_from_text(t)).collect();
|
||||
let mut wraps: Vec<RichTextDoc> = wrap_variants(&text).iter().map(|t| restyle(doc_from_text(t))).collect();
|
||||
let width = |d: &RichTextDoc| stamp_size_m(d, &[], ROOM_STAMP_MIN_PT, scale).0;
|
||||
wraps.sort_by(|a, b| width(a).total_cmp(&width(b)));
|
||||
let wrapped: Vec<Option<&RichTextDoc>> = wraps.iter().map(Some).collect();
|
||||
@@ -1090,6 +1148,12 @@ fn fit_room_stamp(doc: &RichTextDoc, number: Option<&str>, extra: Vec<StampLine>
|
||||
// [199] Anderer Planinhalt allein verkleinert die Schrift nur bis `ROOM_STAMP_KEEP` der Grundschrift: ein Stempel
|
||||
// in Schriftgrösse über Linien (mit Freistellung, `stamp_knockout`) liest sich besser als einer in 2 mm. Erst
|
||||
// wenn der Raum auch das nicht fasst, geht es wie bisher bis auf 2 mm hinunter.
|
||||
if styled {
|
||||
let own: Vec<(Vec<Option<&RichTextDoc>>, f64)> = steps_to(ROOM_STAMP_MIN_PT).into_iter().map(|(v, p)| (v.into_iter().filter(Option::is_none).collect(), p)).collect();
|
||||
if let Some((e, pt, v, q)) = search(&own, &[(true, false), (false, false)]) {
|
||||
return (e, pt, v, Some(q));
|
||||
}
|
||||
}
|
||||
let keep = (pt * ROOM_STAMP_KEEP).max(ROOM_STAMP_MIN_PT);
|
||||
if keep > ROOM_STAMP_MIN_PT {
|
||||
if let Some((e, pt, v, q)) = search(&steps_to(keep), &[(true, false), (false, false)]) {
|
||||
@@ -1383,10 +1447,10 @@ fn rooms(c: &Ctx, out: &mut Vec<Primitive>, top: &mut Vec<Primitive>, bounds: &m
|
||||
// [173] Fläche und SIA-Kategorie nach der Stufe (Basis: Fläche ja, Kategorie nein).
|
||||
let mut lines = Vec::new();
|
||||
if StampOpts::line(None, st.area, true) {
|
||||
lines.push(StampLine { text: format!("{} m²", to_fixed(res.net, 2)), align: Align::Left });
|
||||
lines.push(StampLine::plain(format!("{} m²", to_fixed(res.net, 2)), Align::Left));
|
||||
}
|
||||
if StampOpts::line(None, st.usage, false) {
|
||||
lines.push(StampLine { text: format!("{} · {}", sia_key(room.sia_category), sia_label(room.sia_category)), align: Align::Left });
|
||||
lines.push(StampLine::plain(format!("{} · {}", sia_key(room.sia_category), sia_label(room.sia_category)), Align::Left));
|
||||
}
|
||||
(room.stamp_doc.clone().unwrap_or_else(|| doc_from_text(&room.name)), lines)
|
||||
}
|
||||
@@ -1398,7 +1462,7 @@ fn rooms(c: &Ctx, out: &mut Vec<Primitive>, top: &mut Vec<Primitive>, bounds: &m
|
||||
let mut extra_lines = extra_lines;
|
||||
// [173] Lichte Höhe nach der Stufe (Basis nein; auch ab 1:200, wenn die Stufe sie verlangt).
|
||||
if !overview && StampOpts::line(None, st.height, false) {
|
||||
extra_lines.push(StampLine { text: format!("LH {} m", to_fixed(crate::room_book::clear_height(c.p, room), 2)), align: Align::Left });
|
||||
extra_lines.push(StampLine { text: format!("LH {} m", to_fixed(crate::room_book::clear_height(c.p, room), 2)), align: Align::Left, marks: stamp_extra_marks(None, room.stamp.as_ref().and_then(|s| s.font.as_ref())) });
|
||||
}
|
||||
// Belag: Stempel (nicht ab 1:200) > Stufe > nein.
|
||||
let finish = match room.stamp.as_ref().and_then(|s| s.show_finish) {
|
||||
@@ -1408,7 +1472,7 @@ fn rooms(c: &Ctx, out: &mut Vec<Primitive>, top: &mut Vec<Primitive>, bounds: &m
|
||||
if !overview && finish {
|
||||
let label = crate::room_book::finish_label(c.p, room.floor_finish.as_deref());
|
||||
if !label.is_empty() {
|
||||
extra_lines.push(StampLine { text: label, align: Align::Left });
|
||||
extra_lines.push(StampLine { text: label, align: Align::Left, marks: stamp_extra_marks(None, room.stamp.as_ref().and_then(|s| s.font.as_ref())) });
|
||||
}
|
||||
}
|
||||
let candidates = if room.stamp_anchor.is_some() { vec![at] } else { stamp_candidates(&pts, pole) };
|
||||
@@ -1417,7 +1481,7 @@ fn rooms(c: &Ctx, out: &mut Vec<Primitive>, top: &mut Vec<Primitive>, bounds: &m
|
||||
let clear = STAMP_CLEAR_MM * c.a.scale / 1000.0;
|
||||
let place = |w: f64, h: f64, free: bool| place_stamp(&pts, &candidates, &obst, clear, w, h, free);
|
||||
let number = stamp.as_deref().and_then(|s| s.number.clone());
|
||||
let (extra_lines, base_pt, name, placed) = fit_room_stamp(&doc, number.as_deref(), extra_lines, if small { ROOM_STAMP_SMALL_PT } else { ROOM_STAMP_PT }, c.a.scale, &place);
|
||||
let (extra_lines, base_pt, name, placed) = fit_room_stamp_with(&doc, number.as_deref(), extra_lines, if small { ROOM_STAMP_SMALL_PT } else { ROOM_STAMP_PT }, c.a.scale, stamp.as_deref().is_some_and(stamp_has_sizes), &place);
|
||||
let at = placed.unwrap_or(at);
|
||||
let name_replaced = name.clone();
|
||||
let doc = name.unwrap_or(doc);
|
||||
@@ -1434,7 +1498,7 @@ fn rooms(c: &Ctx, out: &mut Vec<Primitive>, top: &mut Vec<Primitive>, bounds: &m
|
||||
// [177] Trennlinie unter dem Namen (Einstellung am Stempel, Vorgabe aus), nur im unveränderten Block.
|
||||
if let (Some(s), None, false, false) = (stamp.as_deref(), &name_replaced, overview, small) {
|
||||
if StampOpts::line(s.show_divider, st.divider, false) {
|
||||
let rows: Vec<(&str, crate::text_layout::LineAlign)> = extra_lines.iter().map(|l| (l.text.as_str(), crate::text_layout::LineAlign::of(Some(l.align)))).collect();
|
||||
let rows: Vec<crate::text_layout::ExtraRow> = extra_lines.iter().map(|l| l.row()).collect();
|
||||
let placed = crate::text_layout::stamp_block(&doc, &rows, base_pt, PT_MM, "#000000", 0.0);
|
||||
let np = room_stamp_name_paragraphs(s);
|
||||
if placed.len() > np {
|
||||
@@ -2164,6 +2228,94 @@ mod tests {
|
||||
assert!(ly < at.y + 0.353 && ly > at.y - 0.106, "{ly} {}", at.y);
|
||||
}
|
||||
|
||||
/// [218] Schrift im Stempel: Grösse und Fett ändern die Textmasse, fehlende Werte gelten als bisherige Vorgabe.
|
||||
#[test]
|
||||
fn raumstempel_schrift_aendert_masse() {
|
||||
let base = RoomStamp { name: "Wohnen".into(), name_line2: Some("Essen".into()), number: Some("E.03".into()), ..Default::default() };
|
||||
let first = |d: &RichTextDoc| d.paragraphs[0].runs[0].marks.clone();
|
||||
// Ohne Angaben: wie bisher (Name 12 pt fett, Zeile 2 kursiv 9 pt, Nummer 9 pt).
|
||||
let d0 = room_stamp_to_doc(&base);
|
||||
assert_eq!((first(&d0).size_pt, first(&d0).bold, first(&d0).font.clone()), (Some(NAME_PT), Some(true), None));
|
||||
assert_eq!(d0.paragraphs[1].runs[0].marks.italic, Some(true));
|
||||
assert_eq!(d0.paragraphs[2].runs[0].marks.size_pt, Some(NUMBER_PT));
|
||||
let (w0, h0) = stamp_size_m(&d0, &[], ROOM_STAMP_PT, 100.0);
|
||||
// Grösserer Name: Block breiter und höher.
|
||||
let big = RoomStamp { name_font: Some(RoomStampFont { size_pt: Some(24.0), ..Default::default() }), ..base.clone() };
|
||||
let (w1, h1) = stamp_size_m(&room_stamp_to_doc(&big), &[], ROOM_STAMP_PT, 100.0);
|
||||
assert!(w1 > w0 * 1.5 && h1 > h0, "{w0}x{h0} -> {w1}x{h1}");
|
||||
// Fett aus: schmaler.
|
||||
let thin = RoomStamp { name_font: Some(RoomStampFont { bold: Some(false), ..Default::default() }), ..base.clone() };
|
||||
let dt = room_stamp_to_doc(&thin);
|
||||
assert_eq!(first(&dt).bold, Some(false));
|
||||
assert!(stamp_size_m(&dt, &[], ROOM_STAMP_PT, 100.0).0 < w0);
|
||||
// Stempelschrift gilt für alle Zeilen, die Zeilenschrift geht vor.
|
||||
let all = RoomStamp { font: Some(RoomStampFont { family: Some("Work Sans".into()), color: Some("#336699".into()), ..Default::default() }), number_font: Some(RoomStampFont { family: Some("Jost".into()), ..Default::default() }), ..base.clone() };
|
||||
let da = room_stamp_to_doc(&all);
|
||||
let fam = |i: usize| da.paragraphs[i].runs[0].marks.font.clone();
|
||||
assert_eq!((fam(0), fam(1), fam(2)), (Some("Work Sans".into()), Some("Work Sans".into()), Some("Jost".into())));
|
||||
assert_eq!(da.paragraphs[2].runs[0].marks.color.as_deref(), Some("#336699"));
|
||||
// Unsinn zählt als nicht gesetzt.
|
||||
let bad = RoomStamp { font: Some(RoomStampFont { family: Some(" ".into()), size_pt: Some(f64::NAN), color: Some("rot".into()), ..Default::default() }), ..base.clone() };
|
||||
assert_eq!(room_stamp_to_doc(&bad), d0);
|
||||
// Zusatzzeilen: Fläche gross und fett, Nutzung bleibt Vorgabe; ohne Angaben keine Auszeichnung.
|
||||
let s = RoomStamp { show_floor_area: Some(true), show_usage: Some(true), area_font: Some(RoomStampFont { size_pt: Some(16.0), bold: Some(true), ..Default::default() }), ..base.clone() };
|
||||
let lines = room_stamp_extra_lines(&s, 20.0, SiaCategory::HNF);
|
||||
assert_eq!(lines.len(), 2);
|
||||
assert_eq!(lines[0].marks.as_ref().map(|m| (m.size_pt, m.bold)), Some((Some(16.0), Some(true))));
|
||||
assert!(lines[1].marks.is_none());
|
||||
let plain_lines = room_stamp_extra_lines(&RoomStamp { show_floor_area: Some(true), ..base.clone() }, 20.0, SiaCategory::HNF);
|
||||
let (_, hp) = stamp_size_m(&d0, &plain_lines, ROOM_STAMP_PT, 100.0);
|
||||
let (wb, hb) = stamp_size_m(&d0, &lines[..1], ROOM_STAMP_PT, 100.0);
|
||||
assert!(hb > hp, "grössere Flächenzeile macht den Block höher: {hp} -> {hb}");
|
||||
// Die Grösse folgt der Grundschrift (7 pt ab 1:200): 16 pt × 7/10.
|
||||
let rows: Vec<crate::text_layout::ExtraRow> = lines.iter().map(|l| l.row()).collect();
|
||||
let placed = crate::text_layout::stamp_block(&d0, &rows, ROOM_STAMP_SMALL_PT, PT_MM, "#000000", 0.0);
|
||||
let sz = placed[3].line.tspans[0].font_size / PT_MM;
|
||||
assert!((sz - 16.0 * 0.7).abs() < 0.01 && wb > 0.0, "{sz}");
|
||||
}
|
||||
|
||||
/// [218] Eigene Schriftgrössen gehen vor Überdeckung: findet sich nur eine Lage mit Überdeckung, bleibt der Name in
|
||||
/// der gewählten Schrift (statt der Ersatzvariante ohne eigene Grössen).
|
||||
#[test]
|
||||
fn raumstempel_eigene_grosse_geht_vor_ueberdeckung() {
|
||||
let s = RoomStamp { name: "Wohnen".into(), name_font: Some(RoomStampFont { size_pt: Some(24.0), ..Default::default() }), ..Default::default() };
|
||||
assert!(stamp_has_sizes(&s) && !stamp_has_sizes(&RoomStamp { name: "x".into(), ..Default::default() }));
|
||||
let doc = room_stamp_to_doc(&s);
|
||||
// Frei (ohne Überdeckung) gibt es keine Lage; mit Überdeckung überall.
|
||||
let place = |_: f64, _: f64, free: bool| (!free).then_some(Vec2 { x: 0.0, y: 0.0 });
|
||||
let (_, _, d, at) = fit_room_stamp_with(&doc, None, vec![], ROOM_STAMP_PT, 100.0, true, &place);
|
||||
assert!(d.is_none() && at.is_some(), "Name in 24 pt bleibt");
|
||||
// Ohne `styled` (Standard) bleibt das Verhalten: Ersatzvariante, wenn die Lage damit frei ist.
|
||||
let place2 = |w: f64, _: f64, free: bool| (!free || w < 2.0).then_some(Vec2 { x: 0.0, y: 0.0 });
|
||||
let (_, _, d2, _) = fit_room_stamp_with(&doc, None, vec![], ROOM_STAMP_PT, 100.0, false, &place2);
|
||||
assert!(d2.is_some(), "ohne eigene Grössen als Ersatz");
|
||||
let (_, _, d3, _) = fit_room_stamp_with(&doc, None, vec![], ROOM_STAMP_PT, 100.0, true, &place2);
|
||||
assert!(d3.is_none(), "mit eigenen Grössen: Überdeckung statt Ersatz");
|
||||
}
|
||||
|
||||
/// [218] Im Plan trägt der Stempel die gewählte Schrift (Primitiv `text`): Familie im Namen, Zeilenmarken.
|
||||
#[test]
|
||||
fn raumstempel_schrift_im_plan() {
|
||||
let mut p = sample();
|
||||
for r in p.rooms.as_mut().unwrap() {
|
||||
r.stamp = Some(RoomStamp {
|
||||
name: r.name.clone(),
|
||||
show_floor_area: Some(true),
|
||||
font: Some(RoomStampFont { family: Some("Jost".into()), ..Default::default() }),
|
||||
area_font: Some(RoomStampFont { size_pt: Some(9.0), italic: Some(true), ..Default::default() }),
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
let t = serde_json::json!({ "floor": "eg", "show": ["20", "60"], "grey": [], "scale": 100 }).to_string();
|
||||
let d = plan_domains(&p, &PlanArgs::parse(1.0, &t).unwrap()).unwrap();
|
||||
let (doc, extra) = d.rooms.iter().find_map(|q| match q { Primitive::Text { doc, extra_lines, .. } => Some((doc.clone(), extra_lines.clone())), _ => None }).unwrap();
|
||||
assert_eq!(doc.paragraphs[0].runs[0].marks.font.as_deref(), Some("Jost"));
|
||||
let m = extra[0].marks.as_ref().expect("Marken der Flächenzeile");
|
||||
assert_eq!((m.font.as_deref(), m.size_pt, m.italic), (Some("Jost"), Some(9.0), Some(true)));
|
||||
// Das Primitiv trägt die Marken auch im JSON (Anzeige, SVG, DXF lesen sie von dort).
|
||||
assert!(serde_json::to_string(&Primitive::Text { at: Vec2 { x: 0.0, y: 0.0 }, doc, extra_lines: extra, base_pt: 10.0, color: "#000".into(), room_id: None, greyed: None, opacity: None }).unwrap().contains("\"italic\":true"));
|
||||
}
|
||||
|
||||
/// [140] Raumstempel ab 1:200 kleiner (7 pt); bis 1:100 10 pt mit der Flächenzeile.
|
||||
#[test]
|
||||
fn raumstempel_je_massstab() {
|
||||
@@ -2221,7 +2373,7 @@ mod tests {
|
||||
/// Breite aus der Schriftmetrik (Inter), Platz aus dem Raumumriss um den Anker.
|
||||
#[test]
|
||||
fn raumstempel_passt_in_engen_raum() {
|
||||
let extra = || vec![StampLine { text: "4.6 m²".into(), align: Align::Center }, StampLine { text: "NNF · Nebennutzfläche".into(), align: Align::Center }];
|
||||
let extra = || vec![StampLine::plain("4.6 m²".into(), Align::Center), StampLine::plain("NNF · Nebennutzfläche".into(), Align::Center)];
|
||||
let name = doc_from_text("E.04 Bad");
|
||||
let room = |w: f64, h: f64| move |sw: f64, sh: f64, _free: bool| (sw <= w && sh <= h).then_some(Vec2 { x: 0.0, y: 0.0 });
|
||||
let (e, pt, d, _) = fit_room_stamp(&name, None, extra(), ROOM_STAMP_PT, 100.0, &room(6.0, 4.0));
|
||||
|
||||
@@ -117,6 +117,20 @@ pub struct HatchRender {
|
||||
pub struct StampLine {
|
||||
pub text: String,
|
||||
pub align: Align,
|
||||
/// [218] Schrift der Zeile (Familie, Grösse in pt bei Grundschrift 10, fett, kursiv, Farbe); fehlt: 0.8 × Grundschrift.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub marks: Option<Marks>,
|
||||
}
|
||||
|
||||
impl StampLine {
|
||||
/// Zeile in der Standardschrift.
|
||||
pub fn plain(text: String, align: Align) -> Self {
|
||||
Self { text, align, marks: None }
|
||||
}
|
||||
/// Zeile für den Stempel-Satz (`text_layout::stamp_block`).
|
||||
pub fn row(&self) -> crate::text_layout::ExtraRow<'_> {
|
||||
(self.text.as_str(), crate::text_layout::LineAlign::of(Some(self.align)), self.marks.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
/// `dash?: number[] | null`: fehlt (`None`), `null` (`Some(None)`) oder Muster.
|
||||
|
||||
@@ -28,7 +28,7 @@ use crate::plan::buf::{whole, Rec, View, F_COLOR, F_DASH_NULL, F_OPACITY, T_ARC,
|
||||
use crate::plan::parts::{greyed_of, Part};
|
||||
use crate::plan::arc_fit;
|
||||
use crate::plan::text::{SingleText, StampText};
|
||||
use crate::text_layout::{place_lines, stamp_block, stamp_line_offsets, wrap_doc_to_lines, Line, LayoutOpts, LineAlign, PT_TO_MM, TEXT_LINE_HEIGHT_MULT};
|
||||
use crate::text_layout::{place_lines, stamp_block, stamp_line_offsets, wrap_doc_to_lines, Line, LayoutOpts, PT_TO_MM, TEXT_LINE_HEIGHT_MULT};
|
||||
use std::f64::consts::PI;
|
||||
|
||||
/// Optionen: Massstab-Nenner, Blatt (mm) und Ausmass des Plans (`Plan.bounds`).
|
||||
@@ -686,7 +686,7 @@ fn line_node(out: &mut Out, line: &Line, content: &str, x: f64, y: f64) {
|
||||
/// ([`stamp_block`]), Grösse in Papier-pt (unabhängig vom Massstab).
|
||||
fn stamp_node(out: &mut Out, t: &StampText, m: Map, opacity: String) {
|
||||
let c = m.at(t.at.x, t.at.y);
|
||||
let extra: Vec<(&str, LineAlign)> = t.extra_lines.iter().map(|l| (l.text.as_str(), LineAlign::of(Some(l.align)))).collect();
|
||||
let extra: Vec<crate::text_layout::ExtraRow> = t.extra_lines.iter().map(|l| l.row()).collect();
|
||||
let placed = stamp_block(&t.doc, &extra, t.base_pt, PT_TO_MM, t.color.as_deref().unwrap_or("#000000"), c.y);
|
||||
if placed.is_empty() {
|
||||
return;
|
||||
|
||||
@@ -24,10 +24,10 @@ use std::f64::consts::PI;
|
||||
/// `x`/`y0` = Anker in SVG-Koordinaten, `mm_to_m` = Modell-Meter je Papier-mm.
|
||||
fn stamp_svg(v: &Value, x: f64, y0: f64, mm_to_m: f64) -> String {
|
||||
use crate::model::RichTextDoc;
|
||||
use crate::text_layout::{stamp_block, stamp_line_offsets, LineAlign, PT_TO_MM};
|
||||
use crate::text_layout::{stamp_block, stamp_line_offsets, PT_TO_MM};
|
||||
let doc: RichTextDoc = v.get("doc").and_then(|d| serde_json::from_value(d.clone()).ok()).unwrap_or_default();
|
||||
let extra: Vec<crate::plan::prim::StampLine> = v.get("extraLines").and_then(|d| serde_json::from_value(d.clone()).ok()).unwrap_or_default();
|
||||
let rows: Vec<(&str, LineAlign)> = extra.iter().map(|l| (l.text.as_str(), LineAlign::of(Some(l.align)))).collect();
|
||||
let rows: Vec<crate::text_layout::ExtraRow> = extra.iter().map(|l| l.row()).collect();
|
||||
let color = jstr(v, "color").unwrap_or("");
|
||||
let o = op_json(v);
|
||||
// In Papier-mm setzen (Schriftgrössen auf 1/1000 gerundet), dann in Modell-Meter umrechnen.
|
||||
@@ -596,7 +596,7 @@ mod tests {
|
||||
let doc = crate::text_layout::doc_from_text("Wohnen", &bold);
|
||||
let mut w = Writer::new(true);
|
||||
let g = w.begin_group();
|
||||
w.push(&Primitive::Text { at: Vec2 { x: 2.0, y: 2.0 }, doc, extra_lines: vec![StampLine { text: "20.00 m²".into(), align: Align::Center }], base_pt: 10.0, color: "#111111".into(), room_id: Some("r".into()), greyed: None, opacity: None });
|
||||
w.push(&Primitive::Text { at: Vec2 { x: 2.0, y: 2.0 }, doc, extra_lines: vec![StampLine::plain("20.00 m²".into(), Align::Center)], base_pt: 10.0, color: "#111111".into(), room_id: Some("r".into()), greyed: None, opacity: None });
|
||||
w.end_group(g);
|
||||
let bytes = w.finish();
|
||||
let view = View::parse(&bytes).unwrap();
|
||||
|
||||
@@ -13,7 +13,7 @@ use crate::plan::buf::{whole, T_DRAWING_TEXT, T_TEXT};
|
||||
use crate::plan::dxf::{StampLine as DxfLine, TextIn, TextStyleIn};
|
||||
use crate::plan::parts::{in_ranges, Part};
|
||||
use crate::plan::scene::{to_rgba, Rgba, SText, STYLE_BOLD, STYLE_ITALIC};
|
||||
use crate::text_layout::{doc_from_text, doc_to_lines, font_name_of, is_blank, plain_text, split_ws, stamp_block, stamp_line_offsets, wrap_doc_to_lines, LayoutOpts, LineAlign, Placed, PT_TO_MM, TEXT_LINE_HEIGHT_MULT};
|
||||
use crate::text_layout::{doc_from_text, font_name_of, is_blank, plain_text, split_ws, stamp_block, stamp_line_offsets, wrap_doc_to_lines, LayoutOpts, LineAlign, Placed, PT_TO_MM, TEXT_LINE_HEIGHT_MULT};
|
||||
use serde::{Deserialize, Deserializer};
|
||||
|
||||
fn num<'de, D: Deserializer<'de>>(d: D) -> Result<f64, D::Error> {
|
||||
@@ -178,32 +178,22 @@ fn stamp_scene(t: &StampText, forced: bool, mm_to_m: f64, out: &mut Vec<SText>)
|
||||
let greyed = t.greyed == Some(true) || forced;
|
||||
let color = t.color.as_deref();
|
||||
let def = greyed_color(to_rgba(color).unwrap_or(INK), greyed);
|
||||
let o = LayoutOpts { line_height: 0.0, unit_per_pt: PT_TO_MM, base_pt: t.base_pt, color: color.unwrap_or("#000000") };
|
||||
let base_mm = t.base_pt * PT_TO_MM;
|
||||
let mut flat: Vec<(String, f64, Rgba, LineAlign, u32)> = Vec::new();
|
||||
for line in doc_to_lines(&t.doc, &o) {
|
||||
let fill = line.tspans.first().map(|s| s.fill.as_str()).or(color);
|
||||
let c = greyed_color(to_rgba(fill).unwrap_or(def), greyed);
|
||||
flat.push((line.content(), line.max_size().unwrap_or(base_mm), c, line.align, line_style(&line)));
|
||||
}
|
||||
for l in &t.extra_lines {
|
||||
flat.push((l.text.clone(), base_mm * 0.8, def, LineAlign::of(Some(l.align)), 0));
|
||||
}
|
||||
if flat.is_empty() {
|
||||
return;
|
||||
}
|
||||
let base_h = base_mm * mm_to_m;
|
||||
let line_gap = base_h * 1.3;
|
||||
let total_h = base_h + (flat.len() - 1) as f64 * line_gap;
|
||||
// [140] Zeilen im gemessenen, um den Anker zentrierten Block (`stamp_line_offsets`, Papier-mm).
|
||||
let extra: Vec<(&str, LineAlign)> = t.extra_lines.iter().map(|l| (l.text.as_str(), LineAlign::of(Some(l.align)))).collect();
|
||||
let offsets = stamp_line_offsets(&stamp_block(&t.doc, &extra, t.base_pt, PT_TO_MM, "#000000", 0.0));
|
||||
for (k, (content, size, c, align, style)) in flat.into_iter().enumerate() {
|
||||
// [140] Zeilen im gemessenen, um den Anker zentrierten Block (`stamp_block`, Papier-mm): Grundlinien nach der
|
||||
// grössten Schrift der Zeile ([199]), Spalten nach der Ausrichtung (`stamp_line_offsets`). [218] Zusatzzeilen mit
|
||||
// eigener Grösse, Farbe und eigenem Schnitt.
|
||||
let extra: Vec<crate::text_layout::ExtraRow> = t.extra_lines.iter().map(|l| l.row()).collect();
|
||||
let placed = stamp_block(&t.doc, &extra, t.base_pt, PT_TO_MM, color.unwrap_or("#000000"), 0.0);
|
||||
let offsets = stamp_line_offsets(&placed);
|
||||
for (k, Placed { line, y }) in placed.iter().enumerate() {
|
||||
let content = line.content();
|
||||
if is_blank(&content) {
|
||||
continue;
|
||||
}
|
||||
let fill = line.tspans.first().map(|s| s.fill.as_str()).or(color);
|
||||
let c = greyed_color(to_rgba(fill).unwrap_or(def), greyed);
|
||||
let dx = offsets.get(k).copied().unwrap_or(0.0) * mm_to_m;
|
||||
push(out, t.at.x + dx, t.at.y + total_h / 2.0 - base_h * 0.8 - k as f64 * line_gap, content, size, c, align, style);
|
||||
push(out, t.at.x + dx, t.at.y - y * mm_to_m, content, line.max_size().unwrap_or(base_mm), c, line.align, line_style(line));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +267,7 @@ fn split_lines(s: &str) -> Vec<String> {
|
||||
/// den Anker zentriert ([`stamp_block`]), Höhen in Modell-Metern beim Massstab.
|
||||
fn stamp_lines(p: &StampText, scale: f64, family: &dyn Fn(Option<&str>) -> String) -> Vec<DxfLine> {
|
||||
let unit_per_pt = (0.0254 / 72.0) * scale;
|
||||
let extra: Vec<(&str, LineAlign)> = p.extra_lines.iter().map(|l| (l.text.as_str(), LineAlign::of(Some(l.align)))).collect();
|
||||
let extra: Vec<crate::text_layout::ExtraRow> = p.extra_lines.iter().map(|l| l.row()).collect();
|
||||
let mut out = Vec::new();
|
||||
let placed = stamp_block(&p.doc, &extra, p.base_pt, unit_per_pt, p.color.as_deref().unwrap_or("#000000"), 0.0);
|
||||
let offsets = stamp_line_offsets(&placed);
|
||||
@@ -325,7 +315,7 @@ mod tests {
|
||||
stamp_scene(&t, false, 0.1, &mut out);
|
||||
assert_eq!(out.len(), 2);
|
||||
let base_h = 10.0 * PT_TO_MM * 0.1;
|
||||
assert_eq!(out[0].pos.y, 3.0 + (base_h + 2.0 * base_h * 1.3) / 2.0 - base_h * 0.8);
|
||||
assert!((out[0].pos.y - (3.0 + (base_h + 2.0 * base_h * 1.3) / 2.0 - base_h * 0.8)).abs() < 1e-12);
|
||||
assert_eq!((out[0].align, out[1].align), (1, 2));
|
||||
// [194] Schnitt der Zeile (erster Lauf): Name fett, Live-Zeile normal.
|
||||
assert_eq!((out[0].style, out[1].style), (STYLE_BOLD, 0));
|
||||
@@ -334,6 +324,27 @@ mod tests {
|
||||
assert!(l[0].style.bold && l[0].style.family == "Arial");
|
||||
}
|
||||
|
||||
/// [218] Zusatzzeile mit eigener Schrift: Grösse, Farbe und Schnitt reisen in die Szene, der Block bleibt zentriert.
|
||||
#[test]
|
||||
fn raumstempel_zusatzzeile_mit_eigener_schrift() {
|
||||
let js = |marks: &str| format!(r##"{{"at":{{"x":0,"y":0}},"doc":{{"version":1,"paragraphs":[{{"runs":[{{"text":"Wohnen"}}]}}]}},"extraLines":[{{"text":"17.01 m²","align":"left"{marks}}}],"basePt":10,"color":"#333"}}"##);
|
||||
let run = |marks: &str| {
|
||||
let t: StampText = serde_json::from_str(&js(marks)).unwrap();
|
||||
let mut out = Vec::new();
|
||||
stamp_scene(&t, false, 0.1, &mut out);
|
||||
out
|
||||
};
|
||||
let plain = run("");
|
||||
let big = run(r##","marks":{"sizePt":20,"bold":true,"italic":true,"color":"#ff0000"}"##);
|
||||
assert_eq!((plain.len(), big.len()), (2, 2));
|
||||
assert!((plain[1].size_mm - 8.0 * PT_TO_MM).abs() < 1e-9 && plain[1].style == 0);
|
||||
assert!((big[1].size_mm - 20.0 * PT_TO_MM).abs() < 1e-3, "{}", big[1].size_mm);
|
||||
assert_eq!(big[1].style, STYLE_BOLD | STYLE_ITALIC);
|
||||
assert_eq!(big[1].color, [1.0, 0.0, 0.0, 1.0]);
|
||||
// Grössere Zeile: der Block wird höher, die erste Grundlinie rückt nach oben (Modell-y nach oben).
|
||||
assert!(big[0].pos.y > plain[0].pos.y);
|
||||
}
|
||||
|
||||
/// [194] Bildschirm-Szene: gedrehte Einzeltexte und der Text im Editor fehlen, Exporte behalten alle;
|
||||
/// Schnitt (fett/kursiv) reist mit.
|
||||
#[test]
|
||||
|
||||
@@ -389,12 +389,12 @@ pub struct Placed {
|
||||
/// Basisgrösse bzw. die Absatz-Zeilenhöhe), darunter die Live-Zeilen (`extra`: Text und
|
||||
/// Ausrichtung; Verweis-Absatz = Absatzzahl + Nummer), vertikal um `y0` zentriert; `y` wächst nach
|
||||
/// unten (Bildschirm) — im Modell ist es der Abstand nach unten.
|
||||
pub fn stamp_block_refs(doc: &RichTextDoc, extra: &[(&str, LineAlign)], base_pt: f64, unit_per_pt: f64, color: &str, y0: f64) -> Vec<(LineRef, f64)> {
|
||||
pub fn stamp_block_refs(doc: &RichTextDoc, extra: &[ExtraRow], base_pt: f64, unit_per_pt: f64, color: &str, y0: f64) -> Vec<(LineRef, f64)> {
|
||||
let base_fs = base_pt * unit_per_pt;
|
||||
let line_gap = base_fs * 1.3;
|
||||
let mut lines = layout_refs(doc, &LayoutOpts { line_height: line_gap, unit_per_pt, base_pt, color }, None);
|
||||
let n = doc.paragraphs.len();
|
||||
for (i, (text, align)) in extra.iter().enumerate() {
|
||||
for (i, (text, align, _)) in extra.iter().enumerate() {
|
||||
lines.push(LineRef { toks: vec![Tok { para: n + i, run: 0, b0: 0, b1: text.len(), u0: 0, u1: utf16_len(text) }], align: *align, line_height: line_gap });
|
||||
}
|
||||
if lines.is_empty() {
|
||||
@@ -409,7 +409,7 @@ pub fn stamp_block_refs(doc: &RichTextDoc, extra: &[(&str, LineAlign)], base_pt:
|
||||
.map(|l| {
|
||||
l.toks
|
||||
.iter()
|
||||
.map(|t| if t.para >= n { base_fs * 0.8 } else { doc.paragraphs[t.para].runs[t.run].marks.size_pt.filter(|v| v.is_finite() && *v > 0.0).map_or(base_fs, |pt| pt * unit_per_pt) })
|
||||
.map(|t| if t.para >= n { extra_size_pt(extra[t.para - n].2, base_pt) * unit_per_pt } else { doc.paragraphs[t.para].runs[t.run].marks.size_pt.filter(|v| v.is_finite() && *v > 0.0).map_or(base_fs, |pt| pt * unit_per_pt) })
|
||||
.fold(f64::NAN, f64::max)
|
||||
})
|
||||
.map(|f| if f.is_finite() { f } else { base_fs })
|
||||
@@ -435,13 +435,34 @@ pub fn stamp_block_refs(doc: &RichTextDoc, extra: &[(&str, LineAlign)], base_pt:
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// [218] Grundschrift des Raumstempels in pt (Bezug der Grössen in den Zeilen-`Marks`).
|
||||
pub const STAMP_REF_PT: f64 = 10.0;
|
||||
|
||||
/// Zusatzzeile eines Raumstempels: Text, Ausrichtung, eigene Schrift (`None`: 0.8 × Grundschrift).
|
||||
pub type ExtraRow<'a> = (&'a str, LineAlign, Option<&'a Marks>);
|
||||
|
||||
/// [218] Schriftgrösse (pt) einer Zusatzzeile: eigene Angabe (bezogen auf [`STAMP_REF_PT`], wächst und schrumpft
|
||||
/// mit der Grundschrift `base_pt`) oder 0.8 × Grundschrift.
|
||||
pub fn extra_size_pt(m: Option<&Marks>, base_pt: f64) -> f64 {
|
||||
m.and_then(|m| m.size_pt).filter(|v| v.is_finite() && *v > 0.0).map_or(base_pt * 0.8, |s| s * base_pt / STAMP_REF_PT)
|
||||
}
|
||||
|
||||
/// [218] Lauf einer Zusatzzeile: ohne eigene Schrift wie bisher ([`stamp_extra_tspan`]), sonst mit Familie, Schnitt,
|
||||
/// Farbe und Grösse der Zeile.
|
||||
pub fn stamp_extra_span(text: String, m: Option<&Marks>, base_pt: f64, unit_per_pt: f64, color: &str) -> Tspan {
|
||||
match m {
|
||||
None => stamp_extra_tspan(text, base_pt, unit_per_pt, color),
|
||||
Some(m) => tspan_of(text, &Marks { size_pt: Some(extra_size_pt(Some(m), base_pt)), ..m.clone() }, base_pt, unit_per_pt, color),
|
||||
}
|
||||
}
|
||||
|
||||
/// Stil der Live-Zeilen eines Raumstempels (0.8 × Basisgrösse, ungerundet, Farbe `color`).
|
||||
pub fn stamp_extra_tspan(text: String, base_pt: f64, unit_per_pt: f64, color: &str) -> Tspan {
|
||||
Tspan { text, font_size: base_pt * unit_per_pt * 0.8, fill: color.to_string(), bold: false, italic: false, font_family: None, text_decoration: None, baseline_shift: None }
|
||||
}
|
||||
|
||||
/// Raumstempel-Block ausgeschrieben ([`stamp_block_refs`]).
|
||||
pub fn stamp_block(doc: &RichTextDoc, extra: &[(&str, LineAlign)], base_pt: f64, unit_per_pt: f64, color: &str, y0: f64) -> Vec<Placed> {
|
||||
pub fn stamp_block(doc: &RichTextDoc, extra: &[ExtraRow], base_pt: f64, unit_per_pt: f64, color: &str, y0: f64) -> Vec<Placed> {
|
||||
let o = LayoutOpts { line_height: 0.0, unit_per_pt, base_pt, color };
|
||||
let n = doc.paragraphs.len();
|
||||
stamp_block_refs(doc, extra, base_pt, unit_per_pt, color, y0)
|
||||
@@ -452,7 +473,7 @@ pub fn stamp_block(doc: &RichTextDoc, extra: &[(&str, LineAlign)], base_pt: f64,
|
||||
.iter()
|
||||
.map(|t| {
|
||||
if t.para >= n {
|
||||
stamp_extra_tspan(extra[t.para - n].0.to_string(), base_pt, unit_per_pt, color)
|
||||
stamp_extra_span(extra[t.para - n].0.to_string(), extra[t.para - n].2, base_pt, unit_per_pt, color)
|
||||
} else {
|
||||
let r = &doc.paragraphs[t.para].runs[t.run];
|
||||
tspan_of(r.text[t.b0..t.b1].to_string(), &r.marks, o.base_pt, o.unit_per_pt, o.color)
|
||||
@@ -638,7 +659,7 @@ pub fn stamp_line_offsets(placed: &[Placed]) -> Vec<f64> {
|
||||
/// [140] Ausmass eines Raumstempels ([`stamp_block`]) in Einheiten von `unit_per_pt`: Breite der breitesten
|
||||
/// Zeile (Summe der Tspans mit echter Metrik, [`text_width_em`]) und Höhe des Blocks (erste Zeile plus
|
||||
/// Zeilenvorschübe, wie die Zentrierung in [`stamp_block_refs`]).
|
||||
pub fn stamp_block_size(doc: &RichTextDoc, extra: &[(&str, LineAlign)], base_pt: f64, unit_per_pt: f64) -> (f64, f64) {
|
||||
pub fn stamp_block_size(doc: &RichTextDoc, extra: &[ExtraRow], base_pt: f64, unit_per_pt: f64) -> (f64, f64) {
|
||||
let placed = stamp_block(doc, extra, base_pt, unit_per_pt, "#000000", 0.0);
|
||||
if placed.is_empty() {
|
||||
return (0.0, 0.0);
|
||||
@@ -792,16 +813,16 @@ mod tests {
|
||||
..Default::default()
|
||||
};
|
||||
let base = 5.67;
|
||||
let placed = stamp_block(&d, &[("35.2 m²", LineAlign::Left)], base, 1.0, "#000", 0.0);
|
||||
let placed = stamp_block(&d, &[("35.2 m²", LineAlign::Left, None)], base, 1.0, "#000", 0.0);
|
||||
let ys: Vec<f64> = placed.iter().map(|p| p.y).collect();
|
||||
// Grundlinie Name → Nummer: Unterlänge 12 pt + Oberlänge 9 pt passen (≥ 1.15 × 9).
|
||||
assert!(ys[1] - ys[0] >= 1.15 * 9.0 - 1e-9, "{ys:?}");
|
||||
assert!(ys[2] - ys[1] >= 0.3 * 9.0 + 0.8 * base * 0.8 - 1e-9, "{ys:?}");
|
||||
// Oberkante des Blocks (Grundlinie Name − 0.8 × 12) bis Grundlinie letzte Zeile: so hoch misst der Block.
|
||||
let (_, h) = stamp_block_size(&d, &[("35.2 m²", LineAlign::Left)], base, 1.0);
|
||||
let (_, h) = stamp_block_size(&d, &[("35.2 m²", LineAlign::Left, None)], base, 1.0);
|
||||
assert!((h - (12.0 + (ys[2] - ys[0]))).abs() < 1e-9, "{h}");
|
||||
// Normale Grundschrift (10 pt): Vorschub wie bisher 13 pt.
|
||||
let placed = stamp_block(&d, &[("35.2 m²", LineAlign::Left)], 10.0, 1.0, "#000", 0.0);
|
||||
let placed = stamp_block(&d, &[("35.2 m²", LineAlign::Left, None)], 10.0, 1.0, "#000", 0.0);
|
||||
assert!((placed[1].y - placed[0].y - 13.0).abs() < 1e-9 && (placed[2].y - placed[1].y - 13.0).abs() < 1e-9);
|
||||
}
|
||||
/// [140] Echte Metrik: „Bad" schmaler als „WWW", Leerzeichen schmal; Stempelblock misst Name und Zeilen.
|
||||
@@ -812,7 +833,7 @@ mod tests {
|
||||
assert!(text_width_em("m²", false) > text_width_em("m", false));
|
||||
assert!(text_width_em("Bad", true) > text_width_em("Bad", false));
|
||||
let d = doc_from_text("Bad", &Marks::default());
|
||||
let (w, h) = stamp_block_size(&d, &[("4.60 m²", LineAlign::Center)], 10.0, 1.0);
|
||||
let (w, h) = stamp_block_size(&d, &[("4.60 m²", LineAlign::Center, None)], 10.0, 1.0);
|
||||
// Zweite Zeile 8 pt: 4.60 m² ≈ 3.6 em · 8; Höhe 10 + 13.
|
||||
assert!((h - 23.0).abs() < 1e-9, "{h}");
|
||||
assert!((w - text_width_em("4.60 m²", false) * 8.0).abs() < 1e-9, "{w}");
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
//! sie schon; keine Texte über die Grenze zurück).
|
||||
|
||||
use crate::model::RichTextDoc;
|
||||
use crate::text_layout::{layout_refs, place_lines, tspan_of, stamp_block_refs, stamp_extra_tspan, text_frame_corners, wrap_plain, LayoutOpts, LineAlign, LineRef, Tok, Tspan};
|
||||
use crate::text_layout::{layout_refs, place_lines, tspan_of, stamp_block_refs, text_frame_corners, wrap_plain, LayoutOpts, LineRef, Tok, Tspan};
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
fn style_bits(t: &Tspan) -> f64 {
|
||||
@@ -105,7 +105,7 @@ pub fn text_frame(doc_json: &str, opts: &[f64]) -> Vec<f64> {
|
||||
#[wasm_bindgen]
|
||||
pub fn text_stamp_block(prim_json: &str, unit_per_pt: f64, x0: f64, y0: f64) -> Vec<f64> {
|
||||
let Ok(p) = serde_json::from_str::<crate::plan::text::StampText>(prim_json) else { return Vec::new() };
|
||||
let extra: Vec<(&str, LineAlign)> = p.extra_lines.iter().map(|l| (l.text.as_str(), LineAlign::of(Some(l.align)))).collect();
|
||||
let extra: Vec<crate::text_layout::ExtraRow> = p.extra_lines.iter().map(|l| l.row()).collect();
|
||||
let color = p.color.as_deref().unwrap_or("#000000");
|
||||
let placed = stamp_block_refs(&p.doc, &extra, p.base_pt, unit_per_pt, color, y0);
|
||||
// [140] Zeilen im gemessenen, um den Anker zentrierten Block (`stamp_line_offsets`).
|
||||
@@ -115,7 +115,7 @@ pub fn text_stamp_block(prim_json: &str, unit_per_pt: f64, x0: f64, y0: f64) ->
|
||||
let n = p.doc.paragraphs.len();
|
||||
encode_lines(&lines, &at, |t| {
|
||||
if t.para >= n {
|
||||
stamp_extra_tspan(String::new(), p.base_pt, unit_per_pt, color)
|
||||
crate::text_layout::stamp_extra_span(String::new(), p.extra_lines[t.para - n].marks.as_ref(), p.base_pt, unit_per_pt, color)
|
||||
} else {
|
||||
tspan_of(String::new(), &p.doc.paragraphs[t.para].runs[t.run].marks, p.base_pt, unit_per_pt, color)
|
||||
}
|
||||
|
||||
+14
-13
@@ -60,6 +60,7 @@ import { useCommandEngineHost } from "./state/useCommandEngineHost";
|
||||
import { TRANSFORM_COMMANDS, useToolInput } from "./state/useToolInput";
|
||||
import { useSelectionCommands } from "./state/useSelectionCommands";
|
||||
import { openObjectSettings } from "./state/objectSettings";
|
||||
import type { InfoGroupId } from "./panels/objectInfo/groups";
|
||||
import { openObjectSettingsWindowNative, useObjectSettingsWindowHost } from "./native/objectSettingsWindow";
|
||||
import { isTauriRuntime } from "./native/projectFile";
|
||||
import {
|
||||
@@ -183,7 +184,7 @@ export default function App() {
|
||||
// ── Kontextmenüs (transienter UI-State, bleibt lokal) ─────────────────────
|
||||
const {
|
||||
layerClipboard, setLayerClipboard, drawingStyleClipboard, setDrawingStyleClipboard, menu, setMenu, editor,
|
||||
setEditor, nativeLayerSettingsCode, setNativeLayerSettingsCode, stampEditorRoomId, setStampEditorRoomId,
|
||||
setEditor, nativeLayerSettingsCode, setNativeLayerSettingsCode,
|
||||
editTextId, setEditTextId, editTextMinHeightM, setEditTextMinHeightM,
|
||||
} = useContextMenuState();
|
||||
|
||||
@@ -504,14 +505,16 @@ export default function App() {
|
||||
|
||||
// [195] Taste T / Menü „Objekteinstellungen…" (state/objectSettings.ts): unter Tauri natives Nebenfenster ([195b]),
|
||||
// sonst schwebendes Panel.
|
||||
const openSettingsOfObject = () =>
|
||||
openObjectSettings({
|
||||
activeTool,
|
||||
revealObjectSettings: (group) =>
|
||||
isTauriRuntime()
|
||||
? void openObjectSettingsWindowNative(group)
|
||||
: setLayout((l) => revealPanel(l, "object-settings", { x: 96, y: 96, w: 360, h: 560 })),
|
||||
});
|
||||
const settingsDeps = () => ({
|
||||
activeTool,
|
||||
revealObjectSettings: (group: InfoGroupId | null) =>
|
||||
isTauriRuntime()
|
||||
? void openObjectSettingsWindowNative(group)
|
||||
: setLayout((l) => revealPanel(l, "object-settings", { x: 96, y: 96, w: 360, h: 560 })),
|
||||
});
|
||||
const openSettingsOfObject = () => openObjectSettings(settingsDeps());
|
||||
// [218] Doppelklick auf einen Raumstempel: dieselben Objekteinstellungen, Abschnitt „Raumstempel" fokussiert.
|
||||
const openRoomStampSettings = () => openObjectSettings(settingsDeps(), "roomStamp");
|
||||
useObjectSettingsShortcut(shortcutOverrides, engineRef, openSettingsOfObject);
|
||||
useCloseObjectSettingsOnEscape(activeTool !== "select" || commandActive);
|
||||
|
||||
@@ -606,7 +609,8 @@ export default function App() {
|
||||
categoryDisplay,
|
||||
floorDisplay,
|
||||
selectionState: { selection, setSelection, groupPath },
|
||||
contextMenuState: { setMenu, setStampEditorRoomId, editTextId, setEditTextId, setEditTextMinHeightM },
|
||||
contextMenuState: { setMenu, editTextId, setEditTextId, setEditTextMinHeightM },
|
||||
openRoomStampSettings,
|
||||
});
|
||||
|
||||
// „Bild einfügen" (Werkzeug „image") — siehe state/useImportHandling.ts.
|
||||
@@ -655,7 +659,6 @@ export default function App() {
|
||||
onToggleSection3dCut,
|
||||
openLayerSettings,
|
||||
openSettings,
|
||||
onOpenStampEditor,
|
||||
openResources,
|
||||
dxfInputRef,
|
||||
planViewRef,
|
||||
@@ -1034,8 +1037,6 @@ export default function App() {
|
||||
pendingCopyMode={pendingCopyMode}
|
||||
setPendingCopyMode={setPendingCopyMode}
|
||||
commitCopyCount={commitCopyCount}
|
||||
stampEditorRoomId={stampEditorRoomId}
|
||||
setStampEditorRoomId={setStampEditorRoomId}
|
||||
/>
|
||||
|
||||
{/* Aktives Kontextmenü (genau eines), verdrahtet in menus/AppContextMenu.tsx. */}
|
||||
|
||||
@@ -39,7 +39,7 @@ export interface RichTextEditorProps {
|
||||
autoFocus?: boolean;
|
||||
/**
|
||||
* "pt" (Default) — absolute Schriftgrösse, passend für ein schwebendes
|
||||
* Dialogfenster ohne Zoom-Bezug (TextEditorDialog). "em" — Grösse relativ
|
||||
* Dialogfenster ohne Zoom-Bezug. "em" — Grösse relativ
|
||||
* zur geerbten Schriftgrösse des `.rt-surface`-Containers: für die beiden
|
||||
* Inline-Editoren AUF der Zeichenfläche/dem Blatt (PlanView/LayoutSheet),
|
||||
* die die Basisgrösse selbst per CSS-Variable aus dem echten Zoom setzen —
|
||||
|
||||
+21
-10
@@ -961,7 +961,6 @@ export const de = {
|
||||
"objinfo.room.buildUp": "Aufbau",
|
||||
"objinfo.room.finishes": "Oberflächen (Raumbuch)",
|
||||
"objinfo.room.finishHint": "Material wählen oder Freitext eingeben",
|
||||
"objinfo.room.editStamp": "Stempel bearbeiten …",
|
||||
// ── Extrusions-Attribute (truck-Integration, Object-Info-Panel) ─────────
|
||||
"objinfo.sectionLine.section": "Schnittlinie",
|
||||
"objinfo.dimText.section": "Masszahl",
|
||||
@@ -3288,21 +3287,33 @@ export const de = {
|
||||
"text.editTitle": "Text bearbeiten",
|
||||
"text.apply": "Übernehmen",
|
||||
"text.cancel": "Abbrechen",
|
||||
"roomStamp.title": "Raumstempel bearbeiten",
|
||||
"roomStamp.title": "Raumstempel",
|
||||
"roomStamp.number": "Raumnummer",
|
||||
"roomStamp.name": "Raumname",
|
||||
"roomStamp.nameLine2": "Raumname Zeile 2",
|
||||
"roomStamp.showFloorArea": "Bodenfläche anzeigen",
|
||||
"roomStamp.floorAreaPrefix": "Präfix Bodenfläche",
|
||||
"roomStamp.name": "Name",
|
||||
"roomStamp.nameLine2": "Name Zeile 2",
|
||||
"roomStamp.showFloorArea": "Bodenfläche",
|
||||
"roomStamp.floorAreaPrefix": "Präfix",
|
||||
"roomStamp.asModelView": "Wie Modelldarstellung",
|
||||
"roomStamp.on": "An",
|
||||
"roomStamp.off": "Aus",
|
||||
"roomStamp.showUsage": "SIA-Kategorie anzeigen",
|
||||
"roomStamp.showDivider": "Trennlinie unter dem Namen",
|
||||
"roomStamp.showFinish": "Bodenbelag anzeigen",
|
||||
"roomStamp.roundingStep": "Flächen-Rundung",
|
||||
"roomStamp.showUsage": "SIA-Kategorie",
|
||||
"roomStamp.showDivider": "Trennlinie",
|
||||
"roomStamp.showFinish": "Bodenbelag",
|
||||
"roomStamp.roundingStep": "Rundung",
|
||||
"roomStamp.roundingStepDefault": "Standard (2 Nachkommastellen)",
|
||||
"roomStamp.occupancy": "Personenzahl",
|
||||
"roomStamp.font.section": "Schrift",
|
||||
"roomStamp.font.all": "Ganzer Stempel",
|
||||
"roomStamp.font.name": "Name",
|
||||
"roomStamp.font.line2": "Zeile 2",
|
||||
"roomStamp.font.number": "Nummer",
|
||||
"roomStamp.font.area": "Fläche",
|
||||
"roomStamp.font.usage": "Kategorie",
|
||||
"roomStamp.font.default": "Standard",
|
||||
"roomStamp.font.family": "Schriftart",
|
||||
"roomStamp.font.size": "Schriftgrösse (pt)",
|
||||
"roomStamp.font.color": "Schriftfarbe",
|
||||
"roomStamp.font.reset": "Auf Standard zurücksetzen",
|
||||
"text.selectedHint": "Formatierung wirkt auf den ausgewählten Text",
|
||||
|
||||
// ── Rich-Text-Editor ────────────────────────────────────────────────────────
|
||||
|
||||
+21
-10
@@ -957,7 +957,6 @@ export const en: Record<TranslationKey, string> = {
|
||||
"objinfo.room.buildUp": "Build-up",
|
||||
"objinfo.room.finishes": "Finishes (room book)",
|
||||
"objinfo.room.finishHint": "Choose a material or type free text",
|
||||
"objinfo.room.editStamp": "Edit stamp …",
|
||||
// ── Extruded solid attributes (truck integration, object info panel) ────
|
||||
"objinfo.sectionLine.section": "Section line",
|
||||
"objinfo.dimText.section": "Dimension text",
|
||||
@@ -3276,21 +3275,33 @@ export const en: Record<TranslationKey, string> = {
|
||||
"text.editTitle": "Edit text",
|
||||
"text.apply": "Apply",
|
||||
"text.cancel": "Cancel",
|
||||
"roomStamp.title": "Edit room stamp",
|
||||
"roomStamp.title": "Room stamp",
|
||||
"roomStamp.number": "Room number",
|
||||
"roomStamp.name": "Room name",
|
||||
"roomStamp.nameLine2": "Room name line 2",
|
||||
"roomStamp.showFloorArea": "Show floor area",
|
||||
"roomStamp.floorAreaPrefix": "Floor area prefix",
|
||||
"roomStamp.name": "Name",
|
||||
"roomStamp.nameLine2": "Name line 2",
|
||||
"roomStamp.showFloorArea": "Floor area",
|
||||
"roomStamp.floorAreaPrefix": "Prefix",
|
||||
"roomStamp.asModelView": "As model view",
|
||||
"roomStamp.on": "On",
|
||||
"roomStamp.off": "Off",
|
||||
"roomStamp.showUsage": "Show SIA category",
|
||||
"roomStamp.showDivider": "Divider line below the name",
|
||||
"roomStamp.showFinish": "Show floor finish",
|
||||
"roomStamp.roundingStep": "Area rounding",
|
||||
"roomStamp.showUsage": "SIA category",
|
||||
"roomStamp.showDivider": "Divider",
|
||||
"roomStamp.showFinish": "Floor finish",
|
||||
"roomStamp.roundingStep": "Rounding",
|
||||
"roomStamp.roundingStepDefault": "Default (2 decimal places)",
|
||||
"roomStamp.occupancy": "Occupancy",
|
||||
"roomStamp.font.section": "Font",
|
||||
"roomStamp.font.all": "Whole stamp",
|
||||
"roomStamp.font.name": "Name",
|
||||
"roomStamp.font.line2": "Line 2",
|
||||
"roomStamp.font.number": "Number",
|
||||
"roomStamp.font.area": "Area",
|
||||
"roomStamp.font.usage": "Category",
|
||||
"roomStamp.font.default": "Default",
|
||||
"roomStamp.font.family": "Font family",
|
||||
"roomStamp.font.size": "Font size (pt)",
|
||||
"roomStamp.font.color": "Font color",
|
||||
"roomStamp.font.reset": "Reset to default",
|
||||
"text.selectedHint": "Formatting applies to the selected text",
|
||||
|
||||
"rt.bold": "Bold",
|
||||
|
||||
@@ -30,8 +30,6 @@ export function useContextMenuState() {
|
||||
const [nativeLayerSettingsCode, setNativeLayerSettingsCode] = useState<string | null>(
|
||||
null,
|
||||
);
|
||||
// Offener Raum-Stempel-Editor (Rich-Text) — per Doppelklick/Button geöffnet.
|
||||
const [stampEditorRoomId, setStampEditorRoomId] = useState<string | null>(null);
|
||||
// Text-Inhalt-Editor: Id des per Doppelklick bearbeiteten Text-2D-Elements.
|
||||
const [editTextId, setEditTextId] = useState<string | null>(null);
|
||||
// Mindesthöhe (Meter) des Inline-Editors, wenn `editTextId` aus einem frisch
|
||||
@@ -51,8 +49,6 @@ export function useContextMenuState() {
|
||||
setEditor,
|
||||
nativeLayerSettingsCode,
|
||||
setNativeLayerSettingsCode,
|
||||
stampEditorRoomId,
|
||||
setStampEditorRoomId,
|
||||
editTextId,
|
||||
setEditTextId,
|
||||
editTextMinHeightM,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { defaultRoomStamp, roomDisplayName } from "./roomStamp";
|
||||
import { defaultRoomStamp, roomDisplayName, setStampFontAttr } from "./roomStamp";
|
||||
import type { Room } from "./types";
|
||||
|
||||
function makeRoom(over: Partial<Room> = {}): Room {
|
||||
@@ -50,3 +50,20 @@ describe("roomDisplayName", () => {
|
||||
expect(roomDisplayName(room)).toBe("Küche");
|
||||
});
|
||||
});
|
||||
|
||||
describe("setStampFontAttr [218]", () => {
|
||||
const base = { name: "Wohnen" };
|
||||
it("setzt und entfernt Eigenschaften je Zeile, eine leere Schrift entfällt", () => {
|
||||
const a = setStampFontAttr(base, "nameFont", "sizePt", 18);
|
||||
expect(a.nameFont).toEqual({ sizePt: 18 });
|
||||
const b = setStampFontAttr(a, "nameFont", "family", "Jost");
|
||||
expect(b.nameFont).toEqual({ sizePt: 18, family: "Jost" });
|
||||
const c = setStampFontAttr(setStampFontAttr(b, "nameFont", "sizePt", undefined), "nameFont", "family", "");
|
||||
expect("nameFont" in c).toBe(false);
|
||||
expect(a).toEqual({ name: "Wohnen", nameFont: { sizePt: 18 } }); // unverändert (rein)
|
||||
});
|
||||
it("Unsinn (Grösse <= 0) setzt nichts", () => {
|
||||
expect("font" in setStampFontAttr(base, "font", "sizePt", 0)).toBe(false);
|
||||
expect(setStampFontAttr(base, "areaFont", "bold", true).areaFont).toEqual({ bold: true });
|
||||
});
|
||||
});
|
||||
+34
-1
@@ -2,7 +2,7 @@
|
||||
// für Listen. Das Stempel-Dokument und die Live-Zeilen (Fläche, Nutzung, Personen) baut der Kern
|
||||
// beim Plan-Aufbau (`src-tauri/core/src/plan/domains.rs`, [K3d]).
|
||||
|
||||
import type { Room, RoomStamp } from "./types";
|
||||
import type { Marks, Room, RoomStamp, RoomStampFont } from "./types";
|
||||
import type { Align } from "../text/richText";
|
||||
|
||||
/**
|
||||
@@ -21,6 +21,8 @@ export function defaultRoomStamp(room: Room): RoomStamp {
|
||||
export interface RoomStampLine {
|
||||
text: string;
|
||||
align: Align;
|
||||
/** [218] Schrift der Zeile (Familie, Grösse in pt bei Grundschrift 10, fett, kursiv, Farbe); fehlt: 0.8 × Grundschrift. */
|
||||
marks?: Marks;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,3 +35,34 @@ export function roomDisplayName(room: Room): string {
|
||||
const line2 = (stamp.nameLine2 ?? "").trim();
|
||||
return line2 ? `${stamp.name} ${line2}` : stamp.name;
|
||||
}
|
||||
|
||||
// ── [218] Schrift des Stempels (Objekteinstellungen, Abschnitt „Raumstempel") ────────────────────────
|
||||
// Der Kern setzt sie beim Plan-Aufbau um (`plan/domains.rs::stamp_line_marks`): Zeilenschrift > Stempelschrift >
|
||||
// eingebaute Werte der Zeile.
|
||||
|
||||
/** Schrift-Schlüssel am Stempel: der ganze Stempel und je Zeile. */
|
||||
export type StampFontKey = "font" | "nameFont" | "line2Font" | "numberFont" | "areaFont" | "usageFont";
|
||||
|
||||
/** Eigenschaft einer Stempelschrift. */
|
||||
export type StampFontAttr = keyof RoomStampFont;
|
||||
|
||||
/** Zeilen mit eigener Schrift in Anzeige-Reihenfolge samt den eingebauten Werten (Anzeige, wenn nichts gesetzt ist). */
|
||||
export const STAMP_FONT_LINES: readonly { key: StampFontKey; labelKey: string; size: number; bold: boolean; italic: boolean }[] = [
|
||||
{ key: "font", labelKey: "roomStamp.font.all", size: 10, bold: false, italic: false },
|
||||
{ key: "nameFont", labelKey: "roomStamp.font.name", size: 12, bold: true, italic: false },
|
||||
{ key: "line2Font", labelKey: "roomStamp.font.line2", size: 9, bold: false, italic: true },
|
||||
{ key: "numberFont", labelKey: "roomStamp.font.number", size: 9, bold: false, italic: false },
|
||||
{ key: "areaFont", labelKey: "roomStamp.font.area", size: 8, bold: false, italic: false },
|
||||
{ key: "usageFont", labelKey: "roomStamp.font.usage", size: 8, bold: false, italic: false },
|
||||
];
|
||||
|
||||
/** Schrift einer Zeile setzen (`value` = `undefined`: Eigenschaft entfernen ⇒ Vorgabe); eine leere Schrift entfällt. */
|
||||
export function setStampFontAttr<K extends StampFontAttr>(stamp: RoomStamp, key: StampFontKey, attr: K, value: RoomStampFont[K] | undefined): RoomStamp {
|
||||
const font: RoomStampFont = { ...(stamp[key] ?? {}) };
|
||||
if (value === undefined || value === "" || (typeof value === "number" && !(value > 0))) delete font[attr];
|
||||
else font[attr] = value;
|
||||
const next: RoomStamp = { ...stamp };
|
||||
if (Object.keys(font).length === 0) delete next[key];
|
||||
else next[key] = font;
|
||||
return next;
|
||||
}
|
||||
@@ -3322,6 +3322,34 @@ export type RoomStamp = {
|
||||
showFinish?: boolean;
|
||||
/** [177] Trennlinie unter dem Namen anzeigen. Fehlt/false: keine Linie. */
|
||||
showDivider?: boolean;
|
||||
/** [218] Schrift des ganzen Stempels (Vorgabe für alle Zeilen ohne eigene Angabe). */
|
||||
font?: RoomStampFont;
|
||||
/** [218] Schrift der Namenszeile (Vorgabe: Stempelschrift, sonst 12 pt fett). */
|
||||
nameFont?: RoomStampFont;
|
||||
/** [218] Schrift der zweiten Namenszeile (Vorgabe: Stempelschrift, sonst 9 pt kursiv). */
|
||||
line2Font?: RoomStampFont;
|
||||
/** [218] Schrift der Raumnummer (Vorgabe: Stempelschrift, sonst 9 pt). */
|
||||
numberFont?: RoomStampFont;
|
||||
/** [218] Schrift der Bodenflächen-Zeile (Vorgabe: Stempelschrift, sonst 0.8 × Grundschrift). */
|
||||
areaFont?: RoomStampFont;
|
||||
/** [218] Schrift der Nutzungs-Zeile (Vorgabe: Stempelschrift, sonst 0.8 × Grundschrift). */
|
||||
usageFont?: RoomStampFont;
|
||||
};
|
||||
|
||||
/**
|
||||
* [218] Schrift einer Zeile des Raumstempels; fehlende Werte gelten als „wie die Vorgabe" (Stempelschrift, dann
|
||||
* die eingebauten Werte der Zeile). Grösse in typografischen Punkt auf dem Papier bei der Grundschrift 10 pt
|
||||
* (kleinere Massstäbe verkleinern sie im Verhältnis).
|
||||
*/
|
||||
export type RoomStampFont = {
|
||||
/** Schriftfamilie (eine der gebündelten Schriften, z. B. "Work Sans"). */
|
||||
family?: string;
|
||||
/** Schriftgrösse in pt. */
|
||||
sizePt?: number;
|
||||
bold?: boolean;
|
||||
italic?: boolean;
|
||||
/** Farbe als "#rrggbb". */
|
||||
color?: string;
|
||||
};
|
||||
|
||||
/** [158] Nutzung eines Raums (Raumbuch). Nassräume: Bad, WC, Dusche, Waschküche. */
|
||||
|
||||
@@ -54,7 +54,11 @@ function toDeg360(rad: number): number {
|
||||
}
|
||||
|
||||
|
||||
export function ObjectInfoPanel() {
|
||||
/**
|
||||
* `showPlacement` = false: ohne Bezugspunkt/Lage und Masse (Breite/Höhe/Drehen) — so zeigt sie das Fenster
|
||||
* Objekteinstellungen ([218], Wunsch Maintainer: Platzierung und Masse gehören nur ins Objekt-Info-Panel).
|
||||
*/
|
||||
export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: boolean } = {}) {
|
||||
const host = usePanelHost();
|
||||
const storeProject = useStore((st) => st.project);
|
||||
const sel = useSelectionInfo();
|
||||
@@ -183,10 +187,9 @@ export function ObjectInfoPanel() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="objinfo-sep" />
|
||||
|
||||
{(
|
||||
{showPlacement && (
|
||||
<>
|
||||
<div className="objinfo-sep" />
|
||||
{/* Bezugspunkt-Würfel (3×3, immer quadratisch) links, X/Y/Z als Spalte
|
||||
rechts daneben (Nutzer-Wunsch). */}
|
||||
<div className="objinfo-section-label">{t("objinfo.refpoint")}</div>
|
||||
|
||||
@@ -21,10 +21,10 @@ Kern; hier stehen Eingabe und Darstellung. Zustand über den Store (`src/state`)
|
||||
|---|---|
|
||||
| `ToolsPanel.tsx`, `AttributesPanel.tsx`, `ObjectInfoPanel.tsx` | Werkzeug-Palette, Attribute, Objekt-Info der Auswahl (`ContextObjectProps.tsx`, `UValueRow.tsx`, `SurfacePatternPlacement.tsx` sind Teile davon) |
|
||||
| `objectSettings/` | Fenster „Objekteinstellungen" ([195], Taste T): `ObjectSettingsPanel` (schwebendes Panel `object-settings`) zeigt Bereich Objekt = `ObjectInfoPanel` und Darstellung = `AttributesPanel` (dieselben Komponenten, keine Doppelspur); `areas.ts` = Bereichs-Zuordnung, `areaState.ts` = gewählter Bereich |
|
||||
| `objectInfo/*.tsx` | Abschnitte je Element-Art (`WallSection`, `CeilingSection`, `RoofSections`, `OpeningSections`, `StairSection`, `RoomSection`, `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]`) |
|
||||
| `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`; Stempel-Editor `RoomStampEditor.tsx` |
|
||||
| `RoomBalancePanel.tsx` | Flächenbilanz mit den Abschnitten `AreaTableSection.tsx`, `KennzahlenSection.tsx`, `ProgramCompareSection.tsx`, `ElementScheduleSection.tsx`, `OpeningScheduleSection.tsx`, `RoomBookSection.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 |
|
||||
|
||||
@@ -1,276 +0,0 @@
|
||||
// Schwebender Dialog zum Bearbeiten des strukturierten Raum-Stempels (Feldmodell):
|
||||
// Raumnummer, Raumname (+ Zeile 2), Bodenfläche (mit Präfix) und Nutzung. Jede
|
||||
// Zeile trägt zusätzlich eine eigene Ausrichtung (links/mitte/rechts). Ersetzt
|
||||
// für neue Räume den freien Text-Editor. Kontrolliert (value/onApply/onCancel);
|
||||
// arbeitet auf einem lokalen Entwurf, erst „Übernehmen" schreibt zurück.
|
||||
// Bezeichner englisch, UI-Text über t().
|
||||
//
|
||||
// Folge-Arbeit: Zeilen-Layout-Editor (welches Feld auf welche Zeile),
|
||||
// Per-Feld-Typografie, Fensterfläche.
|
||||
|
||||
import { useState } from "react";
|
||||
import { t } from "../i18n";
|
||||
import type { RoomStamp } from "../model/types";
|
||||
import type { Align } from "../text/richText";
|
||||
|
||||
export interface RoomStampEditorProps {
|
||||
/** Ausgangsstempel (wird beim Öffnen kopiert; Editor arbeitet lokal). */
|
||||
value: RoomStamp;
|
||||
/** „Übernehmen" — den bearbeiteten Stempel zurückschreiben. */
|
||||
onApply: (stamp: RoomStamp) => void;
|
||||
/** „Abbrechen"/Schliessen — ohne Übernahme. */
|
||||
onCancel: () => void;
|
||||
}
|
||||
|
||||
/** Die drei Ausrichtungen mit Icon und Beschriftung (für die Umschalter). */
|
||||
const ALIGN_CELLS: { align: Align; icon: string; titleKey: string }[] = [
|
||||
{ align: "left", icon: "format_align_left", titleKey: "text.align.left" },
|
||||
{ align: "center", icon: "format_align_center", titleKey: "text.align.center" },
|
||||
{ align: "right", icon: "format_align_right", titleKey: "text.align.right" },
|
||||
];
|
||||
|
||||
/**
|
||||
* Drei-Wege-Umschalter für die Zeilen-Ausrichtung. `value` ist der aktuelle Wert
|
||||
* (fehlt er, gilt `fallback`); `onChange` liefert die gewählte Ausrichtung.
|
||||
*/
|
||||
function AlignToggle({
|
||||
value,
|
||||
fallback,
|
||||
onChange,
|
||||
disabled,
|
||||
label,
|
||||
}: {
|
||||
value: Align | undefined;
|
||||
fallback: Align;
|
||||
onChange: (align: Align) => void;
|
||||
disabled?: boolean;
|
||||
label: string;
|
||||
}) {
|
||||
const current = value ?? fallback;
|
||||
return (
|
||||
<div className="roomstamp-align" role="group" aria-label={label}>
|
||||
{ALIGN_CELLS.map((cell) => (
|
||||
<button
|
||||
key={cell.align}
|
||||
type="button"
|
||||
className={`roomstamp-align-btn${current === cell.align ? " active" : ""}`}
|
||||
disabled={disabled}
|
||||
aria-pressed={current === cell.align}
|
||||
title={t(cell.titleKey)}
|
||||
aria-label={t(cell.titleKey)}
|
||||
onClick={() => onChange(cell.align)}
|
||||
>
|
||||
<span className="material-symbols-outlined" aria-hidden="true">
|
||||
{cell.icon}
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** [173] Dreifach-Wahl: fehlt = wie Modelldarstellung (Stufe), sonst an/aus am Stempel. */
|
||||
function TriState({ value, onChange }: { value: boolean | undefined; onChange: (v: boolean | undefined) => void }) {
|
||||
return (
|
||||
<select
|
||||
value={value === undefined ? "" : value ? "1" : "0"}
|
||||
onChange={(e) => onChange(e.target.value === "" ? undefined : e.target.value === "1")}
|
||||
>
|
||||
<option value="">{t("roomStamp.asModelView")}</option>
|
||||
<option value="1">{t("roomStamp.on")}</option>
|
||||
<option value="0">{t("roomStamp.off")}</option>
|
||||
</select>
|
||||
);
|
||||
}
|
||||
|
||||
export function RoomStampEditor({ value, onApply, onCancel }: RoomStampEditorProps) {
|
||||
const [draft, setDraft] = useState<RoomStamp>(value);
|
||||
|
||||
const patch = (p: Partial<RoomStamp>) => setDraft((d) => ({ ...d, ...p }));
|
||||
|
||||
const hasLine2 = (draft.nameLine2 ?? "").trim().length > 0;
|
||||
|
||||
return (
|
||||
<div
|
||||
className="texteditor-overlay"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label={t("roomStamp.title")}
|
||||
onMouseDown={(e) => {
|
||||
if (e.target === e.currentTarget) onCancel();
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Escape") onCancel();
|
||||
}}
|
||||
>
|
||||
<div className="texteditor-dialog roomstamp-dialog">
|
||||
<div className="texteditor-head">
|
||||
<span className="texteditor-title">{t("roomStamp.title")}</span>
|
||||
<button
|
||||
type="button"
|
||||
className="texteditor-x"
|
||||
onClick={onCancel}
|
||||
title={t("text.cancel")}
|
||||
aria-label={t("text.cancel")}
|
||||
>
|
||||
<span className="material-symbols-outlined" aria-hidden="true">
|
||||
close
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="texteditor-body roomstamp-body">
|
||||
<label className="roomstamp-field">
|
||||
<span className="roomstamp-label">{t("roomStamp.number")}</span>
|
||||
<input
|
||||
type="text"
|
||||
className="roomstamp-input"
|
||||
value={draft.number ?? ""}
|
||||
onChange={(e) => patch({ number: e.target.value })}
|
||||
autoFocus
|
||||
/>
|
||||
</label>
|
||||
|
||||
<div className="roomstamp-row">
|
||||
<label className="roomstamp-field">
|
||||
<span className="roomstamp-label">{t("roomStamp.name")}</span>
|
||||
<input
|
||||
type="text"
|
||||
className="roomstamp-input"
|
||||
value={draft.name}
|
||||
onChange={(e) => patch({ name: e.target.value })}
|
||||
/>
|
||||
</label>
|
||||
<AlignToggle
|
||||
value={draft.nameAlign}
|
||||
fallback="left"
|
||||
label={`${t("roomStamp.name")} — ${t("text.group")}`}
|
||||
onChange={(nameAlign) => patch({ nameAlign })}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="roomstamp-row">
|
||||
<label className="roomstamp-field">
|
||||
<span className="roomstamp-label">{t("roomStamp.nameLine2")}</span>
|
||||
<input
|
||||
type="text"
|
||||
className="roomstamp-input"
|
||||
value={draft.nameLine2 ?? ""}
|
||||
onChange={(e) => patch({ nameLine2: e.target.value })}
|
||||
/>
|
||||
</label>
|
||||
<AlignToggle
|
||||
value={draft.line2Align}
|
||||
fallback="left"
|
||||
disabled={!hasLine2}
|
||||
label={`${t("roomStamp.nameLine2")} — ${t("text.group")}`}
|
||||
onChange={(line2Align) => patch({ line2Align })}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="roomstamp-row">
|
||||
<label className="roomstamp-check">
|
||||
<span>{t("roomStamp.showFloorArea")}</span>
|
||||
<TriState value={draft.showFloorArea} onChange={(showFloorArea) => patch({ showFloorArea })} />
|
||||
</label>
|
||||
<AlignToggle
|
||||
value={draft.floorAreaAlign}
|
||||
fallback="left"
|
||||
disabled={draft.showFloorArea === false}
|
||||
label={`${t("roomStamp.showFloorArea")} — ${t("text.group")}`}
|
||||
onChange={(floorAreaAlign) => patch({ floorAreaAlign })}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<label className="roomstamp-field">
|
||||
<span className="roomstamp-label">{t("roomStamp.floorAreaPrefix")}</span>
|
||||
<input
|
||||
type="text"
|
||||
className="roomstamp-input"
|
||||
value={draft.floorAreaPrefix ?? ""}
|
||||
disabled={draft.showFloorArea === false}
|
||||
onChange={(e) => patch({ floorAreaPrefix: e.target.value })}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label className="roomstamp-field">
|
||||
<span className="roomstamp-label">{t("roomStamp.roundingStep")}</span>
|
||||
<select
|
||||
className="roomstamp-input"
|
||||
value={draft.roundingStep ?? ""}
|
||||
disabled={draft.showFloorArea === false}
|
||||
onChange={(e) => {
|
||||
const v = e.target.value;
|
||||
patch({ roundingStep: v === "" ? undefined : Number(v) });
|
||||
}}
|
||||
>
|
||||
<option value="">{t("roomStamp.roundingStepDefault")}</option>
|
||||
<option value="0.01">0.01 m²</option>
|
||||
<option value="0.1">0.1 m²</option>
|
||||
<option value="0.5">0.5 m²</option>
|
||||
<option value="1">1 m²</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<div className="roomstamp-row">
|
||||
<label className="roomstamp-check">
|
||||
<span>{t("roomStamp.showUsage")}</span>
|
||||
<TriState value={draft.showUsage} onChange={(showUsage) => patch({ showUsage })} />
|
||||
</label>
|
||||
<AlignToggle
|
||||
value={draft.usageAlign}
|
||||
fallback="left"
|
||||
disabled={draft.showUsage === false}
|
||||
label={`${t("roomStamp.showUsage")} — ${t("text.group")}`}
|
||||
onChange={(usageAlign) => patch({ usageAlign })}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="roomstamp-row">
|
||||
<label className="roomstamp-check">
|
||||
<input type="checkbox" checked={draft.showDivider === true} onChange={(e) => patch({ showDivider: e.target.checked ? true : undefined })} />
|
||||
<span>{t("roomStamp.showDivider")}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div className="roomstamp-row">
|
||||
<label className="roomstamp-check">
|
||||
<input type="checkbox" checked={draft.showFinish === true} onChange={(e) => patch({ showFinish: e.target.checked ? true : undefined })} />
|
||||
<span>{t("roomStamp.showFinish")}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<label className="roomstamp-field">
|
||||
<span className="roomstamp-label">{t("roomStamp.occupancy")}</span>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
step={1}
|
||||
className="roomstamp-input"
|
||||
value={draft.occupancy ?? ""}
|
||||
onChange={(e) => {
|
||||
const v = e.target.value;
|
||||
patch({ occupancy: v === "" ? undefined : Number(v) });
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div className="texteditor-foot">
|
||||
<button type="button" className="texteditor-btn" onClick={onCancel}>
|
||||
{t("text.cancel")}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="texteditor-btn texteditor-btn-primary"
|
||||
onClick={() => onApply(draft)}
|
||||
>
|
||||
{t("text.apply")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default RoomStampEditor;
|
||||
@@ -573,8 +573,6 @@ export interface PanelHostValue {
|
||||
onSetRoomName: (name: string) => void;
|
||||
/** Setzt die SIA-416-Blatt-Kategorie des Raums. */
|
||||
onSetRoomSia: (category: SiaCategory) => void;
|
||||
/** Öffnet den Rich-Text-Editor des Raum-Stempels (per ID). */
|
||||
onEditRoomStamp: (roomId: string) => void;
|
||||
|
||||
// ── Extrusions-Attribute (truck-Integration; nur der selektierte Körper) ──
|
||||
/** Setzt die Extrusionshöhe (Meter, > 0) — löst eine Re-Extrusion aus. */
|
||||
|
||||
@@ -15,6 +15,7 @@ import { OpeningSection } from "./OpeningSections";
|
||||
import { DetailRefSection, DimRefsSection, DimTextSection } from "./RefSections";
|
||||
import { RoofSection } from "./RoofSections";
|
||||
import { RoomSection } from "./RoomSection";
|
||||
import { RoomStampSection } from "./RoomStampSection";
|
||||
import { SectionLineSection } from "./SectionLineSection";
|
||||
import { ColumnSection, ExtrudedSolidSection } from "./SolidSections";
|
||||
import { StairSection } from "./StairSection";
|
||||
@@ -50,6 +51,7 @@ export function InfoGroups({ sel, drawing, host }: { sel: SelectionInfo | null;
|
||||
case "openingEditor": return sel?.opening ? <OpeningEditorSection openingId={sel.opening.id} host={host} /> : null;
|
||||
case "stair": return sel?.stair ? <StairSection stair={sel.stair} host={host} /> : null;
|
||||
case "room": return sel?.room ? <RoomSection room={sel.room} roomId={sel.id} host={host} /> : null;
|
||||
case "roomStamp": return sel?.room ? <RoomStampSection roomId={sel.id} /> : null;
|
||||
case "extrudedSolid": return sel?.extrudedSolid ? <ExtrudedSolidSection solid={sel.extrudedSolid} host={host} /> : null;
|
||||
case "column": return sel?.column ? <ColumnSection column={sel.column} host={host} /> : null;
|
||||
case "detailRef": return sel?.detailRef ? <DetailRefSection detailRef={sel.detailRef} drawingId={sel.id} host={host} /> : null;
|
||||
|
||||
@@ -16,8 +16,8 @@ import { useMulti } from "./useMulti";
|
||||
|
||||
// ── Raum-Attribut-Abschnitt ──────────────────────────────────────────────────
|
||||
// Editierbarer Name, SIA-416-Kategorie (5 Blatt-Kategorien), abgeleitete Fläche
|
||||
// + Umfang (read-only), Referenzgeschoss, sowie ein Button, der den Rich-Text-
|
||||
// Stempel-Editor öffnet. Alle Werte/Setter über den Host.
|
||||
// + Umfang (read-only), Referenzgeschoss. Alle Werte/Setter über den Host. Der Stempel hat seit [218] einen
|
||||
// eigenen Abschnitt (`RoomStampSection`).
|
||||
export function RoomSection({
|
||||
room,
|
||||
roomId,
|
||||
@@ -82,15 +82,6 @@ export function RoomSection({
|
||||
|
||||
{/* [158] Raumbuch: Nutzung und Oberflächen. */}
|
||||
<RoomFinishFields roomId={roomId} />
|
||||
|
||||
{/* Stempel bearbeiten (öffnet den Rich-Text-Editor). */}
|
||||
<button
|
||||
type="button"
|
||||
className="objinfo-btn"
|
||||
onClick={() => host.onEditRoomStamp(roomId)}
|
||||
>
|
||||
{t("objinfo.room.editStamp")}
|
||||
</button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
// [218] Raumstempel als Abschnitt der Objekteinstellungen (kein Dialog im Fenster): Abschnitt vorhanden, Schrift je Zeile,
|
||||
// „gemischt" bei Mehrfachauswahl, eine Änderung für alle Räume in einem Undo-Schritt; Bezugspunkt und Masse nur im
|
||||
// Objekt-Info-Panel, nicht im Fenster. Ohne DOM: Server-Render der Panels.
|
||||
import { createElement } from "react";
|
||||
import { renderToString } from "react-dom/server";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildComplexSampleProject } from "../../model/sampleProjectComplex";
|
||||
import { setStampFontAttr } from "../../model/roomStamp";
|
||||
import { editRoomStamps } from "../../state/roomStampEdit";
|
||||
import { getState, setState } from "../../state/appStore";
|
||||
import { EMPTY_SELECTION } from "../../state/selection";
|
||||
import { PanelHostProvider } from "../host";
|
||||
import type { PanelHost } from "../types";
|
||||
import { ObjectInfoPanel } from "../ObjectInfoPanel";
|
||||
import { ObjectSettingsPanel } from "../objectSettings/ObjectSettingsPanel";
|
||||
|
||||
const host = { activeTool: "select", sectionLine: null, displayMode: { mode: "all", setMode: () => {} } } as unknown as PanelHost;
|
||||
const wrap = (el: ReturnType<typeof createElement>) => renderToString(createElement(PanelHostProvider, { value: host }, el));
|
||||
const windowHtml = () => wrap(createElement(ObjectSettingsPanel));
|
||||
const panelHtml = () => wrap(createElement(ObjectInfoPanel));
|
||||
|
||||
function twoRooms() {
|
||||
getState().loadProject(buildComplexSampleProject());
|
||||
const rooms = getState().project.rooms!;
|
||||
return [rooms[0].id, rooms[1].id] as const;
|
||||
}
|
||||
|
||||
describe("Raumstempel in den Objekteinstellungen [218]", () => {
|
||||
it("Raum gewählt: Abschnitt „Raumstempel“ mit Schrift je Zeile, kein Overlay-Dialog", () => {
|
||||
const [a] = twoRooms();
|
||||
setState({ selection: { ...EMPTY_SELECTION, rooms: [a] } });
|
||||
const html = windowHtml();
|
||||
expect(html).toContain('data-group="roomStamp"');
|
||||
expect(html).toContain('data-testid="roomstamp-section"');
|
||||
for (const k of ["font", "nameFont", "line2Font", "numberFont", "areaFont", "usageFont"]) expect(html).toContain(`data-testid="roomstamp-font-${k}"`);
|
||||
expect(html).not.toContain("texteditor-overlay");
|
||||
expect(html).not.toContain('role="dialog"');
|
||||
});
|
||||
|
||||
it("Bezugspunkt und Masse nur im Objekt-Info-Panel, nicht im Fenster (Raum und Wand)", () => {
|
||||
const p = buildComplexSampleProject();
|
||||
getState().loadProject(p);
|
||||
for (const sel of [{ rooms: [p.rooms![0].id] }, { walls: [p.walls[0].id] }]) {
|
||||
setState({ selection: { ...EMPTY_SELECTION, ...sel } });
|
||||
const panel = panelHtml();
|
||||
expect(panel).toContain("objinfo-cube");
|
||||
expect(panel).toContain("objinfo-refrow");
|
||||
const win = windowHtml();
|
||||
expect(win).not.toContain("objinfo-cube");
|
||||
expect(win).not.toContain("objinfo-refrow");
|
||||
expect(win).not.toContain("objinfo-xyzcol");
|
||||
expect(win).not.toContain('data-testid="objinfo-dim"');
|
||||
}
|
||||
});
|
||||
|
||||
it("zwei Räume mit abweichender Namensschrift: „gemischt“, bei gleicher nicht", () => {
|
||||
const [a, b] = twoRooms();
|
||||
editRoomStamps([a], (st) => ({ ...st, nameFont: { sizePt: 20 } }), "k1");
|
||||
editRoomStamps([b], (st) => ({ ...st, nameFont: { sizePt: 14 } }), "k2");
|
||||
setState({ selection: { ...EMPTY_SELECTION, rooms: [a, b] } });
|
||||
expect(windowHtml()).toContain('data-mixed="font-nameFont"');
|
||||
// Nummer und Namen bleiben je Raum eigen: gesperrt.
|
||||
expect(windowHtml()).toMatch(/data-testid="roomstamp-number"[^>]*disabled/);
|
||||
setState({ selection: { ...EMPTY_SELECTION, rooms: [a] } });
|
||||
expect(windowHtml()).not.toContain('data-mixed="font-nameFont"');
|
||||
});
|
||||
|
||||
it("Schrift für alle gewählten Räume in EINEM Undo-Schritt", () => {
|
||||
const [a, b] = twoRooms();
|
||||
setState({ selection: { ...EMPTY_SELECTION, rooms: [a, b] } });
|
||||
const before = JSON.stringify(getState().project.rooms!.map((r) => r.stamp ?? null));
|
||||
editRoomStamps([a, b], (s) => setStampFontAttr(setStampFontAttr(s, "nameFont", "family", "Jost"), "nameFont", "sizePt", 18), "stamp:test");
|
||||
const sizes = () => getState().project.rooms!.filter((r) => r.id === a || r.id === b).map((r) => [r.stamp?.nameFont?.family, r.stamp?.nameFont?.sizePt]);
|
||||
expect(sizes()).toEqual([["Jost", 18], ["Jost", 18]]);
|
||||
getState().undo();
|
||||
expect(JSON.stringify(getState().project.rooms!.map((r) => r.stamp ?? null))).toBe(before);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,275 @@
|
||||
// [218] Abschnitt „Raumstempel" der Objekteinstellungen (Doppelklick auf einen Stempel öffnet das Fenster mit diesem
|
||||
// Abschnitt; vorher Overlay-Dialog „Fenster im Fenster"): Nummer, Namenszeilen mit Ausrichtung, Flächen-/Nutzungs-/
|
||||
// Belagszeile und die Schrift (Familie, Grösse, fett, kursiv, Farbe) für den ganzen Stempel und je Zeile.
|
||||
// Schreibt über die Ops des Stores (`applyChange`, wie die Oberflächenfelder des Raums), darum läuft der Abschnitt
|
||||
// im Nebenfenster unverändert über die Spiegelung. Mehrfachauswahl: gleiche Werte zeigen, abweichende „gemischt";
|
||||
// eine Änderung gilt für alle gewählten Räume in EINEM Undo-Schritt; Nummer und Namen bleiben je Raum eigen.
|
||||
|
||||
import { t } from "../../i18n";
|
||||
import type { TranslationKey } from "../../i18n";
|
||||
import { defaultRoomStamp, setStampFontAttr, STAMP_FONT_LINES, type StampFontAttr, type StampFontKey } from "../../model/roomStamp";
|
||||
import type { Room, RoomStamp, RoomStampFont } from "../../model/types";
|
||||
import { useStore } from "../../state/appStore";
|
||||
import { commonValue, type Common } from "../../state/mixedValues";
|
||||
import { editRoomStamps, stampTargetIds } from "../../state/roomStampEdit";
|
||||
import { TEXT_FONTS } from "../../text/fontList";
|
||||
import type { Align } from "../../text/richText";
|
||||
import { Dropdown } from "../../ui/Dropdown";
|
||||
import { MixedMark } from "./fields";
|
||||
|
||||
const NO_ROOMS: Room[] = [];
|
||||
type AlignKey = "nameAlign" | "line2Align" | "floorAreaAlign" | "usageAlign";
|
||||
const RESET_ICON = "restart_alt";
|
||||
const ALIGN_CELLS: { align: Align; icon: string; titleKey: TranslationKey }[] = [
|
||||
{ align: "left", icon: "format_align_left", titleKey: "text.align.left" },
|
||||
{ align: "center", icon: "format_align_center", titleKey: "text.align.center" },
|
||||
{ align: "right", icon: "format_align_right", titleKey: "text.align.right" },
|
||||
];
|
||||
|
||||
function AlignToggle({ value, mixed, disabled, label, onChange }: { value: Align | undefined; mixed?: boolean; disabled?: boolean; label: string; onChange: (a: Align) => void }) {
|
||||
const current = mixed ? undefined : (value ?? "left");
|
||||
return (
|
||||
<div className="roomstamp-align" role="group" aria-label={label}>
|
||||
{ALIGN_CELLS.map((cell) => (
|
||||
<button
|
||||
key={cell.align}
|
||||
type="button"
|
||||
className={`roomstamp-align-btn${current === cell.align ? " active" : ""}`}
|
||||
disabled={disabled}
|
||||
aria-pressed={current === cell.align}
|
||||
title={t(cell.titleKey)}
|
||||
aria-label={t(cell.titleKey)}
|
||||
onClick={() => onChange(cell.align)}
|
||||
>
|
||||
<span className="material-symbols-outlined" aria-hidden="true">{cell.icon}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Dreifach-Wahl: fehlt = wie Modelldarstellung (Stufe), sonst an/aus am Stempel. */
|
||||
function TriState({ value, mixed, onChange, testId }: { value: boolean | undefined; mixed?: boolean; onChange: (v: boolean | undefined) => void; testId?: string }) {
|
||||
return (
|
||||
<select
|
||||
className="objinfo-text"
|
||||
data-testid={testId}
|
||||
value={mixed ? "mixed" : value === undefined ? "" : value ? "1" : "0"}
|
||||
onChange={(e) => onChange(e.target.value === "" ? undefined : e.target.value === "1")}
|
||||
>
|
||||
{mixed && <option value="mixed" disabled>{t("objsettings.mixed")}</option>}
|
||||
<option value="">{t("roomStamp.asModelView")}</option>
|
||||
<option value="1">{t("roomStamp.on")}</option>
|
||||
<option value="0">{t("roomStamp.off")}</option>
|
||||
</select>
|
||||
);
|
||||
}
|
||||
|
||||
export function RoomStampSection({ roomId }: { roomId: string }) {
|
||||
const rooms = useStore((s) => s.project.rooms) ?? NO_ROOMS;
|
||||
const selected = useStore((s) => s.selection.rooms);
|
||||
const ids = stampTargetIds(selected, roomId);
|
||||
const multi = ids.length > 1;
|
||||
const targets = rooms.filter((r) => ids.includes(r.id));
|
||||
const stamps = targets.map((r) => r.stamp ?? defaultRoomStamp(r));
|
||||
|
||||
/** Gemeinsamer Wert eines Stempelfelds über die gewählten Räume. */
|
||||
const common = <T,>(pick: (s: RoomStamp) => T): Common<T> => commonValue(stamps.map(pick));
|
||||
/** Änderung am Stempel aller gewählten Räume (ein Undo-Schritt; gleicher Schlüssel = ein Schritt beim Tippen). */
|
||||
const edit = (fn: (s: RoomStamp) => RoomStamp, key: string) => editRoomStamps(ids, fn, `stamp:${roomId}:${key}`);
|
||||
/** Feld setzen; leer/`undefined` entfernt es (⇒ Vorgabe). */
|
||||
const setField = <K extends keyof RoomStamp>(key: K, value: RoomStamp[K] | undefined) =>
|
||||
edit((s) => {
|
||||
const next = { ...s };
|
||||
if (value === undefined || value === "") delete next[key];
|
||||
else next[key] = value as RoomStamp[K];
|
||||
return next;
|
||||
}, String(key));
|
||||
|
||||
if (targets.length === 0) return null;
|
||||
|
||||
const alignOf = (key: AlignKey, label: TranslationKey, disabled = false) => {
|
||||
const c = common((s) => s[key] ?? "left");
|
||||
return <AlignToggle value={c.value} mixed={c.mixed} disabled={disabled} label={t(label)} onChange={(a) => setField(key, a)} />;
|
||||
};
|
||||
const text = (label: TranslationKey, key: "number" | "name" | "nameLine2" | "floorAreaPrefix", perRoom: boolean, testId: string, align?: AlignKey) => {
|
||||
const c = common((s) => (s[key] as string | undefined) ?? "");
|
||||
const locked = perRoom && multi;
|
||||
return (
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel" title={t(label)}>{t(label)}</span>
|
||||
<input
|
||||
type="text"
|
||||
className="objinfo-text"
|
||||
data-testid={testId}
|
||||
value={locked ? "" : (c.value ?? "")}
|
||||
placeholder={c.mixed ? t("objsettings.mixed") : undefined}
|
||||
disabled={locked}
|
||||
onChange={(e) => setField(key, key === "name" ? e.target.value : e.target.value || undefined)}
|
||||
title={t(label)}
|
||||
/>
|
||||
{align && alignOf(align, label)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
const tri = (label: TranslationKey, key: "showFloorArea" | "showUsage", testId: string, align: AlignKey, off: boolean) => {
|
||||
const c = common((s) => s[key]);
|
||||
return (
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel" title={t(label)}>{t(label)}</span>
|
||||
<TriState testId={testId} value={c.value} mixed={c.mixed} onChange={(v) => setField(key, v)} />
|
||||
{alignOf(align, label, off)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
const check = (label: TranslationKey, key: "showDivider" | "showFinish") => {
|
||||
const c = common((s) => s[key] === true);
|
||||
return (
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t(label)}</span>
|
||||
<input type="checkbox" checked={c.value === true} ref={(el) => { if (el) el.indeterminate = c.mixed; }} onChange={(e) => setField(key, e.target.checked ? true : undefined)} />
|
||||
<MixedMark on={c.mixed} what={key} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
const floorOff = common((s) => s.showFloorArea === false).value === true;
|
||||
const usageOff = common((s) => s.showUsage === false).value === true;
|
||||
const rounding = common((s) => s.roundingStep);
|
||||
const occupancy = common((s) => s.occupancy);
|
||||
|
||||
return (
|
||||
<div data-testid="roomstamp-section">
|
||||
{text("roomStamp.number", "number", true, "roomstamp-number")}
|
||||
{text("roomStamp.name", "name", true, "roomstamp-name", "nameAlign")}
|
||||
{text("roomStamp.nameLine2", "nameLine2", true, "roomstamp-line2", "line2Align")}
|
||||
{tri("roomStamp.showFloorArea", "showFloorArea", "roomstamp-showFloorArea", "floorAreaAlign", floorOff)}
|
||||
{text("roomStamp.floorAreaPrefix", "floorAreaPrefix", false, "roomstamp-prefix")}
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("roomStamp.roundingStep")}</span>
|
||||
<select
|
||||
className="objinfo-text"
|
||||
value={rounding.mixed ? "mixed" : (rounding.value ?? "")}
|
||||
disabled={floorOff}
|
||||
onChange={(e) => setField("roundingStep", e.target.value === "" ? undefined : Number(e.target.value))}
|
||||
>
|
||||
{rounding.mixed && <option value="mixed" disabled>{t("objsettings.mixed")}</option>}
|
||||
<option value="">{t("roomStamp.roundingStepDefault")}</option>
|
||||
<option value="0.01">0.01 m²</option>
|
||||
<option value="0.1">0.1 m²</option>
|
||||
<option value="0.5">0.5 m²</option>
|
||||
<option value="1">1 m²</option>
|
||||
</select>
|
||||
</div>
|
||||
{tri("roomStamp.showUsage", "showUsage", "roomstamp-showUsage", "usageAlign", usageOff)}
|
||||
{check("roomStamp.showDivider", "showDivider")}
|
||||
{check("roomStamp.showFinish", "showFinish")}
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("roomStamp.occupancy")}</span>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
step={1}
|
||||
className="objinfo-text"
|
||||
value={occupancy.mixed ? "" : (occupancy.value ?? "")}
|
||||
placeholder={occupancy.mixed ? t("objsettings.mixed") : undefined}
|
||||
onChange={(e) => setField("occupancy", e.target.value === "" ? undefined : Number(e.target.value))}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="objinfo-section-label">{t("roomStamp.font.section")}</div>
|
||||
{STAMP_FONT_LINES.map((line) => (
|
||||
<FontRow key={line.key} line={line} stamps={stamps} edit={edit} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Eine Schriftzeile: Familie, Grösse (pt), fett, kursiv, Farbe, Zurücksetzen auf die Vorgabe. */
|
||||
function FontRow({
|
||||
line,
|
||||
stamps,
|
||||
edit,
|
||||
}: {
|
||||
line: (typeof STAMP_FONT_LINES)[number];
|
||||
stamps: readonly RoomStamp[];
|
||||
edit: (fn: (s: RoomStamp) => RoomStamp, key: string) => void;
|
||||
}) {
|
||||
const key: StampFontKey = line.key;
|
||||
const attr = <K extends StampFontAttr>(a: K): Common<RoomStampFont[K]> => commonValue(stamps.map((s) => s[key]?.[a]));
|
||||
const set = <K extends StampFontAttr>(a: K, v: RoomStampFont[K] | undefined) => edit((s) => setStampFontAttr(s, key, a, v), `${key}.${a}`);
|
||||
const family = attr("family");
|
||||
const size = attr("sizePt");
|
||||
const bold = attr("bold");
|
||||
const italic = attr("italic");
|
||||
const color = attr("color");
|
||||
const anySet = stamps.some((s) => s[key] !== undefined);
|
||||
const label = t(line.labelKey as TranslationKey);
|
||||
const toggle = (a: "bold" | "italic", c: Common<boolean | undefined>, builtin: boolean, icon: string) => {
|
||||
const on = c.mixed ? false : (c.value ?? builtin);
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className={`roomstamp-align-btn roomstamp-fontbtn${on ? " active" : ""}`}
|
||||
data-testid={`roomstamp-${key}-${a}`}
|
||||
aria-pressed={on}
|
||||
title={t(a === "bold" ? "text.bold" : "text.italic")}
|
||||
aria-label={t(a === "bold" ? "text.bold" : "text.italic")}
|
||||
onClick={() => set(a, !on)}
|
||||
>
|
||||
<span className="material-symbols-outlined" aria-hidden="true">{icon}</span>
|
||||
</button>
|
||||
);
|
||||
};
|
||||
return (
|
||||
<div className="roomstamp-fontrow" data-testid={`roomstamp-font-${key}`}>
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel" title={label}>{label}</span>
|
||||
<Dropdown
|
||||
value={family.mixed ? "" : (family.value ?? "")}
|
||||
onChange={(v) => set("family", v || undefined)}
|
||||
options={[{ value: "", label: family.mixed ? t("objsettings.mixed") : t("roomStamp.font.default") }, ...TEXT_FONTS.map((f) => ({ value: f, label: f }))]}
|
||||
title={`${label} — ${t("roomStamp.font.family")}`}
|
||||
width={150}
|
||||
/>
|
||||
</div>
|
||||
<div className="objinfo-field roomstamp-fontattrs">
|
||||
<input
|
||||
type="number"
|
||||
min={1}
|
||||
max={200}
|
||||
step={0.5}
|
||||
className="objinfo-text roomstamp-size"
|
||||
data-testid={`roomstamp-${key}-size`}
|
||||
value={size.mixed ? "" : (size.value ?? "")}
|
||||
placeholder={size.mixed ? t("objsettings.mixed") : String(line.size)}
|
||||
title={`${label} — ${t("roomStamp.font.size")}`}
|
||||
aria-label={`${label} — ${t("roomStamp.font.size")}`}
|
||||
onChange={(e) => set("sizePt", e.target.value === "" ? undefined : Number(e.target.value))}
|
||||
/>
|
||||
<span className="objinfo-muted">pt</span>
|
||||
{toggle("bold", bold, line.bold, "format_bold")}
|
||||
{toggle("italic", italic, line.italic, "format_italic")}
|
||||
<input
|
||||
type="color"
|
||||
className="roomstamp-color"
|
||||
data-testid={`roomstamp-${key}-color`}
|
||||
value={color.mixed ? "#000000" : (color.value ?? "#000000")}
|
||||
title={`${label} — ${t("roomStamp.font.color")}`}
|
||||
aria-label={`${label} — ${t("roomStamp.font.color")}`}
|
||||
onChange={(e) => set("color", e.target.value)}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
className="roomstamp-align-btn roomstamp-fontbtn"
|
||||
disabled={!anySet}
|
||||
title={t("roomStamp.font.reset")}
|
||||
aria-label={t("roomStamp.font.reset")}
|
||||
onClick={() => edit((s) => { const n = { ...s }; delete n[key]; return n; }, `${key}.reset`)}
|
||||
>
|
||||
<span className="material-symbols-outlined" aria-hidden="true">{RESET_ICON}</span>
|
||||
</button>
|
||||
<MixedMark on={family.mixed || size.mixed || bold.mixed || italic.mixed || color.mixed} what={`font-${key}`} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -50,7 +50,7 @@ describe("Panel-Zuordnung [189]", () => {
|
||||
});
|
||||
|
||||
it("jede Gruppe hat einen Titel", () => {
|
||||
const all: InfoGroupId[] = ["newComponent", "sectionLine", "wall", "ceiling", "roof", "surfacePattern", "opening", "openingEditor", "stair", "room", "extrudedSolid", "column", "detailRef", "dimRefs", "dimText", "grid"];
|
||||
const all: InfoGroupId[] = ["newComponent", "sectionLine", "wall", "ceiling", "roof", "surfacePattern", "opening", "openingEditor", "stair", "room", "roomStamp", "extrudedSolid", "column", "detailRef", "dimRefs", "dimText", "grid"];
|
||||
for (const g of all) expect(INFO_GROUP_TITLE[g]).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,6 +18,7 @@ export type InfoGroupId =
|
||||
| "openingEditor"
|
||||
| "stair"
|
||||
| "room"
|
||||
| "roomStamp"
|
||||
| "extrudedSolid"
|
||||
| "column"
|
||||
| "detailRef"
|
||||
@@ -36,6 +37,7 @@ export const INFO_GROUP_TITLE: Record<InfoGroupId, TranslationKey> = {
|
||||
openingEditor: "objinfo.openingEditor.section",
|
||||
stair: "objinfo.stair.section",
|
||||
room: "objinfo.room.section",
|
||||
roomStamp: "roomStamp.title",
|
||||
extrudedSolid: "objinfo.extrudedSolid.section",
|
||||
column: "objinfo.column.section",
|
||||
detailRef: "objinfo.detailRef.section",
|
||||
@@ -69,7 +71,7 @@ export function infoGroups(c: InfoGroupContext): InfoGroupId[] {
|
||||
if (sel.wall || sel.roof) out.push("surfacePattern");
|
||||
if (sel.opening) out.push("opening", "openingEditor");
|
||||
if (sel.stair) out.push("stair");
|
||||
if (sel.room) out.push("room");
|
||||
if (sel.room) out.push("room", "roomStamp");
|
||||
if (sel.extrudedSolid) out.push("extrudedSolid");
|
||||
if (sel.column) out.push("column");
|
||||
if (sel.detailRef) out.push("detailRef");
|
||||
|
||||
@@ -58,7 +58,7 @@ export function ObjectSettingsPanel() {
|
||||
</div>
|
||||
)}
|
||||
<div className="objset-body" role="tabpanel" aria-label={t(AREA_TITLE[area])}>
|
||||
{area === "object" ? <ObjectInfoPanel /> : <AttributesPanel />}
|
||||
{area === "object" ? <ObjectInfoPanel showPlacement={false} /> : <AttributesPanel />}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// [218] Doppelklick auf einen Raumstempel öffnet die Objekteinstellungen mit fokussiertem Abschnitt „Raumstempel"
|
||||
// (Taste T dagegen mit dem ersten Abschnitt der Auswahl).
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
|
||||
import { getInfoGroupState, resetInfoGroupsForTest } from "../panels/objectInfo/infoGroupState";
|
||||
import { getSettingsArea } from "../panels/objectSettings/areaState";
|
||||
import { getState, setState } from "./appStore";
|
||||
import { openObjectSettings } from "./objectSettings";
|
||||
import { EMPTY_SELECTION } from "./selection";
|
||||
|
||||
describe("openObjectSettings [218]", () => {
|
||||
let revealed: (string | null)[] = [];
|
||||
const deps = { activeTool: "select", revealObjectSettings: (g: string | null) => void revealed.push(g) };
|
||||
beforeEach(() => {
|
||||
revealed = [];
|
||||
resetInfoGroupsForTest();
|
||||
getState().loadProject(buildComplexSampleProject());
|
||||
});
|
||||
|
||||
it("Raum gewählt: T zeigt den Abschnitt „Raum“, der Doppelklick auf den Stempel „Raumstempel“", () => {
|
||||
setState({ selection: { ...EMPTY_SELECTION, rooms: [getState().project.rooms![0].id] } });
|
||||
expect(openObjectSettings(deps)).toBe(true);
|
||||
expect(revealed).toEqual(["room"]);
|
||||
expect(openObjectSettings(deps, "roomStamp")).toBe(true);
|
||||
expect(revealed).toEqual(["room", "roomStamp"]);
|
||||
expect(getInfoGroupState().focus?.id).toBe("roomStamp");
|
||||
expect(getSettingsArea()).toBe("object");
|
||||
});
|
||||
|
||||
it("ein Abschnitt, den die Auswahl nicht hat, wird nicht erzwungen", () => {
|
||||
setState({ selection: { ...EMPTY_SELECTION, walls: [getState().project.walls[0].id] } });
|
||||
openObjectSettings(deps, "roomStamp");
|
||||
expect(revealed).toEqual(["wall"]);
|
||||
});
|
||||
});
|
||||
@@ -4,7 +4,7 @@
|
||||
// und fokussiert; ohne Auswahl die Voreinstellung des aktiven Werkzeugs (Wand/Decke: Typ des neuen Bauteils), sonst
|
||||
// nichts. Die Zuordnung Auswahl → Abschnitt ist rein (`panels/objectInfo/groups.ts::objectSettingsTarget`).
|
||||
|
||||
import { objectSettingsTarget, type InfoGroupId } from "../panels/objectInfo/groups";
|
||||
import { infoGroups, objectSettingsTarget, type InfoGroupId } from "../panels/objectInfo/groups";
|
||||
import { setSettingsArea } from "../panels/objectSettings/areaState";
|
||||
import { expandAndFocusInfoGroup } from "../panels/objectInfo/infoGroupState";
|
||||
import { getState } from "./appStore";
|
||||
@@ -17,8 +17,11 @@ export interface ObjectSettingsDeps {
|
||||
revealObjectSettings: (group: InfoGroupId | null) => void;
|
||||
}
|
||||
|
||||
/** Öffnet die Einstellungen; `false`, wenn es nichts zu öffnen gibt. */
|
||||
export function openObjectSettings(deps: ObjectSettingsDeps): boolean {
|
||||
/**
|
||||
* Öffnet die Einstellungen; `false`, wenn es nichts zu öffnen gibt. `group` wählt den Abschnitt (statt des ersten der
|
||||
* Auswahl), z. B. „roomStamp" beim Doppelklick auf einen Raumstempel ([218]); er muss zur Auswahl gehören.
|
||||
*/
|
||||
export function openObjectSettings(deps: ObjectSettingsDeps, group?: InfoGroupId): boolean {
|
||||
const { project, selection } = getState();
|
||||
const sel = selectionInfoFor(project, selection);
|
||||
let target = objectSettingsTarget(sel, deps.activeTool, isGridDrawing(sel?.kind === "drawing2d" ? sel.id : undefined));
|
||||
@@ -27,6 +30,7 @@ export function openObjectSettings(deps: ObjectSettingsDeps): boolean {
|
||||
target = { group: selection.sectionLines.length > 0 ? "sectionLine" : null };
|
||||
}
|
||||
if (!target) return false;
|
||||
if (group && sel && infoGroups({ sel, isGrid: false, sectionLine: false, newComponentTool: false }).includes(group)) target = { group };
|
||||
setSettingsArea("object");
|
||||
if (target.group) expandAndFocusInfoGroup(target.group);
|
||||
deps.revealObjectSettings(target.group);
|
||||
|
||||
@@ -45,7 +45,7 @@ function targetIds(collection: MultiCollection, id: string): string[] {
|
||||
const ROOF_OWN_KEYS: ReadonlySet<string> = new Set(["outline", "holes", "outlineBulge", "holesBulge", "edgePitchDeg", "dormers"]);
|
||||
|
||||
export function buildElementAttributesHost(c: FlatHostOpts) {
|
||||
const { applyChange, onOpenStampEditor, onToggleSection3dCut, openResources, patchLevel, project, section3dCutId, sectionLine, selection, patchDoorType, patchWindowType, saveOpeningStyle, setCeilingThickness, setWallThickness, slideOpening, updateCeiling, updateOpening, updateRoof, updateRoom, updateStair, updateWall } = c;
|
||||
const { applyChange, onToggleSection3dCut, openResources, patchLevel, project, section3dCutId, sectionLine, selection, patchDoorType, patchWindowType, saveOpeningStyle, setCeilingThickness, setWallThickness, slideOpening, updateCeiling, updateOpening, updateRoof, updateRoom, updateStair, updateWall } = c;
|
||||
/** Wie {@link patchAll}, aber mit Änderungsfunktion je Element (z. B. Stützen-Profil). */
|
||||
function mapAll<K extends MultiCollection>(collection: K, id: string, fn: (e: EntityOf<(typeof PROJECT_LIST)[K]>) => EntityOf<(typeof PROJECT_LIST)[K]>, coalesceKey?: string): void {
|
||||
const ids = targetIds(collection, id);
|
||||
@@ -308,7 +308,6 @@ export function buildElementAttributesHost(c: FlatHostOpts) {
|
||||
onSetRoomSia: (category) => {
|
||||
if (selection?.kind === "room") patchAll("rooms", selection.id, { siaCategory: category });
|
||||
},
|
||||
onEditRoomStamp: (roomId) => onOpenStampEditor(roomId),
|
||||
// ── Extrusions-Attribute (truck-Integration; nur bei selektiertem Körper) ──
|
||||
onSetExtrudedSolidHeight: (height) => {
|
||||
if (selection?.kind !== "extrudedSolid" || !(height > 0)) return;
|
||||
|
||||
@@ -48,7 +48,6 @@ export type PanelHostOpts = {
|
||||
onToggleSection3dCut: (id: string) => void;
|
||||
openLayerSettings: (code: string, x: number, y: number) => void;
|
||||
openSettings: () => void;
|
||||
onOpenStampEditor: (roomId: string) => void;
|
||||
openResources: (tab?: ResourceTabId) => void;
|
||||
dxfInputRef: RefObject<HTMLInputElement | null>;
|
||||
planViewRef: RefObject<PlanViewHandle | null>;
|
||||
|
||||
@@ -497,11 +497,6 @@ export interface ProjectSlice {
|
||||
roomId: string,
|
||||
doc: import("../model/types").RichTextDoc,
|
||||
) => void;
|
||||
/** Setzt den strukturierten Raum-Stempel (Feldmodell). */
|
||||
setRoomStamp: (
|
||||
roomId: string,
|
||||
stamp: import("../model/types").RoomStamp,
|
||||
) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1412,9 +1407,6 @@ export function createProjectSlice(
|
||||
|
||||
setRoomStampDoc: (roomId, doc) =>
|
||||
applyChange((p) => mapRoom(p, roomId, (r) => ({ ...r, stampDoc: doc }))),
|
||||
|
||||
setRoomStamp: (roomId, stamp) =>
|
||||
applyChange((p) => mapRoom(p, roomId, (r) => ({ ...r, stamp }))),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// [218] Raumstempel mehrerer Räume in EINEM Undo-Schritt ändern (Abschnitt „Raumstempel" der Objekteinstellungen).
|
||||
// Fehlt einem Raum der Stempel, beginnt die Änderung beim Standard-Stempel des Raums. Gleicher `key` (Tippen,
|
||||
// Regler) fasst aufeinanderfolgende Änderungen zu einem Schritt zusammen.
|
||||
|
||||
import { patchItems } from "../core";
|
||||
import { defaultRoomStamp } from "../model/roomStamp";
|
||||
import type { Project, Room, RoomStamp } from "../model/types";
|
||||
import { getState } from "./appStore";
|
||||
|
||||
export function editRoomStamps(ids: readonly string[], fn: (stamp: RoomStamp) => RoomStamp, key: string): void {
|
||||
getState().applyChange((p: Project) => patchItems(p, "rooms", [...ids], (r) => ({ ...r, stamp: fn(r.stamp ?? defaultRoomStamp(r)) }) as Room), key);
|
||||
}
|
||||
|
||||
/** Räume, die eine Änderung trifft: bei Mehrfachauswahl alle gewählten (wenn `roomId` dazugehört), sonst nur `roomId`. */
|
||||
export function stampTargetIds(selected: readonly string[], roomId: string): string[] {
|
||||
return selected.length > 1 && selected.includes(roomId) ? [...selected] : [roomId];
|
||||
}
|
||||
@@ -79,6 +79,10 @@ declare global {
|
||||
stairHole: (stairId: string, ceilingId: string) => { start: { x: number; y: number }; center: { x: number; y: number } | null; hole0: { x: number; y: number } | null; lines: number };
|
||||
/** [203] Grundriss der aktiven Ebene wie in der Ansicht (Geschoss-Überlagerung nach Zeichnungsebenen-Modus): Raumstempel je Geschoss (gesamt/gedimmt) und Zahl der Achs-Beschriftungen `axis`. */
|
||||
planStamps: (axis: string) => { floors: Record<string, { n: number; greyed: number }>; axis: number };
|
||||
/** [218] Stempel des Raums `roomId` im Grundriss der aktiven Ebene (wie angezeigt): Lage, Schrift der Namenszeile und Zusatzzeilen; `null` ohne Stempel. */
|
||||
roomStamp: (roomId: string) => { at: { x: number; y: number }; basePt: number; name: { sizePt?: number; font?: string; bold?: boolean }; extra: { text: string; marks?: { sizePt?: number; font?: string; italic?: boolean } }[] } | null;
|
||||
/** [218] Räume der aktiven Ebene mit Mittelpunkt des Umrisses (Modell-m). */
|
||||
roomCenters: () => { id: string; name: string; x: number; y: number }[];
|
||||
/** [205] Pausfolie des Reiters (Store) und ihr Plan für die aktive Ebene: Zahl der Primitive, Linienfarben, Zahl mit Auswahl-Ids, Ausmass. */
|
||||
trace: () => { trace: unknown; n: number; colors: string[]; withIds: number; bounds: { minX: number; minY: number; maxX: number; maxY: number } | null; probe: { x: number; y: number } | null };
|
||||
};
|
||||
@@ -219,6 +223,23 @@ export function installTestHooks(): void {
|
||||
}
|
||||
return { floors, axis: n };
|
||||
},
|
||||
roomStamp: (roomId) => {
|
||||
const s = getState();
|
||||
const p = s.project;
|
||||
const mode = s.displayModes[BUILTIN_PANEL_IDS.drawingLevels] ?? "all";
|
||||
const display = (id: string) => itemDisplay(mode, id === s.activeLevelId, p.drawingLevels.find((l) => l.id === id)?.visible ?? false);
|
||||
const plan = materializeGreyed(materializeUnderlay(generateVisibleLevelsPlan(p, s.activeLevelId, collectVisibleCodes(p.layers), undefined, s.detail, false, false, display, s.scaleDenominator)), true);
|
||||
for (const q of plan.primitives) {
|
||||
if (q.kind !== "text" || q.roomId !== roomId) continue;
|
||||
const m = q.doc.paragraphs[0]?.runs[0]?.marks ?? {};
|
||||
return { at: q.at, basePt: q.basePt, name: { sizePt: m.sizePt, font: m.font, bold: m.bold }, extra: (q.extraLines ?? []).map((l) => ({ text: l.text, marks: l.marks })) };
|
||||
}
|
||||
return null;
|
||||
},
|
||||
roomCenters: () => {
|
||||
const s = getState();
|
||||
return (s.project.rooms ?? []).filter((r) => r.floorId === s.activeLevelId && r.boundary.length >= 3).map((r) => ({ id: r.id, name: r.name, x: r.boundary.reduce((a, v) => a + v.x, 0) / r.boundary.length, y: r.boundary.reduce((a, v) => a + v.y, 0) / r.boundary.length }));
|
||||
},
|
||||
trace: () => {
|
||||
const s = getState();
|
||||
const level = s.project.drawingLevels.find((l) => l.id === s.activeLevelId);
|
||||
|
||||
@@ -58,22 +58,24 @@ export function useMouseSelectionHandlers(opts: {
|
||||
selectionState: Pick<ReturnType<typeof useSelectionState>, "selection" | "setSelection" | "groupPath">;
|
||||
contextMenuState: Pick<
|
||||
ReturnType<typeof useContextMenuState>,
|
||||
"setMenu" | "setStampEditorRoomId" | "editTextId" | "setEditTextId" | "setEditTextMinHeightM"
|
||||
"setMenu" | "editTextId" | "setEditTextId" | "setEditTextMinHeightM"
|
||||
>;
|
||||
/** [218] Fenster Objekteinstellungen mit dem Abschnitt „Raumstempel" öffnen (Doppelklick auf einen Stempel). */
|
||||
openRoomStampSettings: () => void;
|
||||
}) {
|
||||
// [121] Das Projekt liest jeder Handler beim Aufruf aus dem Store (App abonniert es nicht mehr).
|
||||
const { setProject, activeLevelId, visibleCodes, categoryDisplay, floorDisplay, selectionState, contextMenuState } = opts;
|
||||
const { selection, setSelection, groupPath } = selectionState;
|
||||
const { setMenu, setStampEditorRoomId, editTextId, setEditTextId, setEditTextMinHeightM } = contextMenuState;
|
||||
const { setMenu, editTextId, setEditTextId, setEditTextMinHeightM } = contextMenuState;
|
||||
|
||||
// ── Maus-Schema: Auswahl + Kontextmenü aus Grundriss / 3D ─────────────────
|
||||
// Links-Klick im Grundriss: genau eine Wand wählen (Menge ersetzen) bzw.
|
||||
// Leerraum → Auswahl löschen.
|
||||
// Doppelklick auf einen Raum-Stempel: den Raum wählen + den Stempel-Editor
|
||||
// öffnen (Rich-Text-Popup).
|
||||
// Doppelklick auf einen Raum-Stempel: den Raum wählen + die Objekteinstellungen mit dem Abschnitt „Raumstempel"
|
||||
// öffnen ([218], kein Dialog im Fenster mehr). Gehört der Raum schon zur Auswahl, bleibt sie (Mehrfachwerte).
|
||||
const onOpenStampEditor = (roomId: string) => {
|
||||
setSelection({ ...clearKinds(), rooms: [roomId] });
|
||||
setStampEditorRoomId(roomId);
|
||||
if (!getState().selection.rooms.includes(roomId)) setSelection({ ...clearKinds(), rooms: [roomId] });
|
||||
opts.openRoomStampSettings();
|
||||
};
|
||||
// Doppelklick auf ein Text-2D-Element: selektieren + Inhalts-Editor öffnen.
|
||||
const onEditDrawingText = (drawingId: string) => {
|
||||
|
||||
@@ -398,7 +398,6 @@ export function useProjectActions(
|
||||
const moveRoomEdge = useStore((s) => s.moveRoomEdge);
|
||||
const moveRoomStamp = useStore((s) => s.moveRoomStamp);
|
||||
const setRoomStampDoc = useStore((s) => s.setRoomStampDoc);
|
||||
const setRoomStamp = useStore((s) => s.setRoomStamp);
|
||||
|
||||
return {
|
||||
toggleLevelVisible,
|
||||
@@ -523,6 +522,5 @@ export function useProjectActions(
|
||||
moveRoomEdge,
|
||||
moveRoomStamp,
|
||||
setRoomStampDoc,
|
||||
setRoomStamp,
|
||||
};
|
||||
}
|
||||
+22
-154
@@ -6981,169 +6981,37 @@ body {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
/* Schwebendes Dialog-Fenster zum Bearbeiten eines Rich-Text-Dokuments
|
||||
(Raum-Stempel / Textobjekt) — DOSSIER §4: zentriert, --shadow-3, radius 8,
|
||||
Titel „Text bearbeiten", Kopf mit Schliessen-✕, Fuss Abbrechen/Übernehmen. */
|
||||
.texteditor-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.28);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
/* [218] Abschnitt „Raumstempel" der Objekteinstellungen (früher Dialog). */
|
||||
.roomstamp-fontrow {
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.texteditor-dialog {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 560px;
|
||||
max-width: calc(100vw - 32px);
|
||||
height: 420px;
|
||||
max-height: calc(100vh - 32px);
|
||||
background: var(--panel);
|
||||
.roomstamp-fontrow .objinfo-field {
|
||||
border-bottom: none;
|
||||
}
|
||||
.roomstamp-fontattrs {
|
||||
gap: 4px;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.roomstamp-size {
|
||||
flex: 0 0 56px;
|
||||
width: 56px;
|
||||
min-width: 0;
|
||||
}
|
||||
.roomstamp-fontbtn {
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
box-shadow: var(--shadow-3);
|
||||
overflow: hidden;
|
||||
border-radius: 6px;
|
||||
min-width: 26px;
|
||||
height: 26px;
|
||||
}
|
||||
.texteditor-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.texteditor-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--ink);
|
||||
}
|
||||
.texteditor-x {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 26px;
|
||||
.roomstamp-color {
|
||||
width: 28px;
|
||||
height: 26px;
|
||||
padding: 0;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 999px;
|
||||
background: transparent;
|
||||
color: var(--muted);
|
||||
cursor: pointer;
|
||||
transition: background 0.14s, color 0.14s, border-color 0.14s;
|
||||
}
|
||||
.texteditor-x:hover {
|
||||
background: var(--accent-dim);
|
||||
border-color: var(--accent-border);
|
||||
color: var(--accent);
|
||||
}
|
||||
.texteditor-x .material-symbols-outlined {
|
||||
font-size: 18px;
|
||||
line-height: 1;
|
||||
}
|
||||
.texteditor-body {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
padding: 12px;
|
||||
overflow: auto;
|
||||
}
|
||||
.texteditor-body .rt-editor {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
}
|
||||
.texteditor-foot {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding: 10px 12px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
.texteditor-btn {
|
||||
border: 1px solid var(--border);
|
||||
background: var(--input);
|
||||
color: var(--ink);
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
padding: 5px 14px;
|
||||
border-radius: 999px;
|
||||
cursor: pointer;
|
||||
transition: background 0.14s, color 0.14s, border-color 0.14s;
|
||||
}
|
||||
.texteditor-btn:hover {
|
||||
border-color: var(--accent-border);
|
||||
background: var(--accent-dim);
|
||||
color: var(--accent);
|
||||
}
|
||||
.texteditor-btn-primary {
|
||||
background: var(--accent);
|
||||
border-color: var(--accent);
|
||||
color: #fff;
|
||||
}
|
||||
.texteditor-btn-primary:hover {
|
||||
background: var(--accent);
|
||||
border-color: var(--accent);
|
||||
color: #fff;
|
||||
filter: brightness(1.08);
|
||||
}
|
||||
|
||||
/* Strukturierter Raum-Stempel-Editor (Feldmodell). */
|
||||
.roomstamp-dialog {
|
||||
height: auto;
|
||||
}
|
||||
.roomstamp-body {
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
overflow: auto;
|
||||
}
|
||||
.roomstamp-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
.roomstamp-label {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: var(--muted);
|
||||
}
|
||||
.roomstamp-input {
|
||||
border: 1px solid var(--border);
|
||||
background: var(--input);
|
||||
color: var(--ink);
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
padding: 5px 8px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.roomstamp-input:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent-border);
|
||||
}
|
||||
.roomstamp-input:disabled {
|
||||
opacity: 0.5;
|
||||
}
|
||||
.roomstamp-check {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 13px;
|
||||
color: var(--ink);
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
/* Zeile mit Feld/Häkchen links und Ausrichtungs-Umschalter rechts. */
|
||||
.roomstamp-row {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
.roomstamp-row .roomstamp-field {
|
||||
flex: 1;
|
||||
}
|
||||
.roomstamp-row .roomstamp-check {
|
||||
flex: 1;
|
||||
}
|
||||
/* Drei-Wege-Umschalter (links/mitte/rechts) je Stempelzeile. */
|
||||
.roomstamp-align {
|
||||
display: inline-flex;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// Gebündelte Schriften (SIL Open Font License), die Textwerkzeug, Textstile und Raumstempel anbieten
|
||||
// ([218] aus `ui/TopBar.tsx` hierher, damit auch die Objekteinstellungen sie ohne Umweg über die Oberleiste nutzen).
|
||||
// Bezeichner englisch, Kommentare deutsch.
|
||||
|
||||
/**
|
||||
* Schriftauswahl der Text-Gruppe: 15 kuratierte, lokal gebuendelte
|
||||
* Open-Source-Schriften (SIL Open Font License, siehe `src/text/fonts.css`
|
||||
* und `public/fonts/<slug>/OFL.txt`). Bewusst KEINE Systemfonts mehr — die
|
||||
* Darstellung soll unabhaengig vom Betriebssystem und der PDF-Export
|
||||
* deterministisch sein. Ein spaeterer Einstellungen-Dialog kann weitere
|
||||
* Schriften nachladen; das hier ist die Standardliste.
|
||||
*/
|
||||
export const TEXT_FONTS: string[] = [
|
||||
"Inter",
|
||||
"Work Sans",
|
||||
"IBM Plex Sans",
|
||||
"IBM Plex Mono",
|
||||
"Source Sans 3",
|
||||
"Space Grotesk",
|
||||
"Manrope",
|
||||
"Outfit",
|
||||
"DM Sans",
|
||||
"Public Sans",
|
||||
"Karla",
|
||||
"Rubik",
|
||||
"Jost",
|
||||
"Archivo",
|
||||
"Source Serif 4",
|
||||
];
|
||||
|
||||
@@ -70,7 +70,7 @@ const SCRIPT_SCALE = 0.7;
|
||||
* `sizeUnit`:
|
||||
* • "pt" (Default) — ABSOLUTE CSS-`pt`-Grösse, unabhängig vom umgebenden
|
||||
* Kontext. Richtig für ein schwebendes Dialogfenster ohne "echten"
|
||||
* Massstab (TextEditorDialog).
|
||||
* Massstab.
|
||||
* • "em" — Grösse RELATIV zur geerbten Schriftgrösse des Containers
|
||||
* (`sizePt/basePt` als `em`). Nötig für die beiden Inline-Editoren AUF
|
||||
* der Zeichenfläche/dem Blatt (PlanView/LayoutSheet): die setzen die
|
||||
|
||||
+2
-20
@@ -18,7 +18,6 @@ import type { useProjectActions } from "../state/useProjectActions";
|
||||
import type { useProjectFileActions } from "../state/useProjectFileActions";
|
||||
import type { useSettingsHost } from "../state/useSettingsHost";
|
||||
import type { useTopBarState } from "../state/useTopBarState";
|
||||
import type { useContextMenuState } from "../menus/useContextMenuState";
|
||||
import { t } from "../i18n";
|
||||
import { AiActivityPanel } from "./AiActivityPanel";
|
||||
import { BusyOverlay } from "./BusyOverlay";
|
||||
@@ -32,14 +31,12 @@ import { PresentationDialogHost } from "./PresentationDialog";
|
||||
import { PromptDialog } from "./PromptDialog";
|
||||
import { RecoverAutosaveDialog } from "./RecoverAutosaveDialog";
|
||||
import { ResourceManager, type ResourceManagerHandlers } from "./ResourceManager";
|
||||
import { RoomStampEditorHost } from "./RoomStampEditorHost";
|
||||
import { SettingsDialog } from "./SettingsDialog";
|
||||
import { UnsavedChangesDialog } from "./UnsavedChangesDialog";
|
||||
|
||||
type TopBar = ReturnType<typeof useTopBarState>;
|
||||
type EngineHost = ReturnType<typeof useCommandEngineHost>;
|
||||
type ToolState = ReturnType<typeof useDrawingToolState>;
|
||||
type Menu = ReturnType<typeof useContextMenuState>;
|
||||
|
||||
export function AppDialogs(props: {
|
||||
applyChange: RootState["applyChange"];
|
||||
@@ -67,8 +64,6 @@ export function AppDialogs(props: {
|
||||
pendingCopyMode: ToolState["pendingCopyMode"];
|
||||
setPendingCopyMode: ToolState["setPendingCopyMode"];
|
||||
commitCopyCount: ToolState["commitCopyCount"];
|
||||
stampEditorRoomId: Menu["stampEditorRoomId"];
|
||||
setStampEditorRoomId: Menu["setStampEditorRoomId"];
|
||||
}) {
|
||||
const {
|
||||
applyChange,
|
||||
@@ -88,8 +83,6 @@ export function AppDialogs(props: {
|
||||
pendingCopyMode,
|
||||
setPendingCopyMode,
|
||||
commitCopyCount,
|
||||
stampEditorRoomId,
|
||||
setStampEditorRoomId,
|
||||
} = props;
|
||||
const {
|
||||
resourcesOpen,
|
||||
@@ -128,7 +121,6 @@ export function AppDialogs(props: {
|
||||
const { pendingIfc, setPendingIfc, ifcReport, setIfcReport, runIfcImport } = props.modelImport;
|
||||
const { themeMode, setThemeMode, offline, onOfflineChange, aiAccess, setScaleLineWeights, setLineEnds } = props.settings;
|
||||
const { exportContentMeters, onExportPdf, onExportSvg, onExportDxf } = props.planExport;
|
||||
const { setRoomStamp, setRoomStampDoc } = props.pa;
|
||||
// Das Projekt nur abonnieren, solange ein Dialog offen ist, der es zeigt ([121]): sonst rendert eine Op
|
||||
// am Modell hier nichts. `App` reicht es nicht mehr durch.
|
||||
const needsProject = resourcesOpen || !!importState || settingsOpen;
|
||||
@@ -332,18 +324,8 @@ export function AppDialogs(props: {
|
||||
`text`/`textbox` (sofort nach Platzieren, s. host.focusDrawing) oder
|
||||
Doppelklick auf ein bestehendes Element (onEditDrawingText). */}
|
||||
|
||||
{/* Text-Editor (schwebendes Fenster): Doppelklick auf einen Raumstempel bzw.
|
||||
Button in der Objekt-Info öffnet ihn. „Übernehmen" schreibt das
|
||||
bearbeitete Rich-Text-Dokument über setRoomStampDoc. Die Formatier-
|
||||
Leiste in der Oberleiste wirkt ebenfalls live auf den gewählten Raum. */}
|
||||
{stampEditorRoomId && (
|
||||
<RoomStampEditorHost
|
||||
roomId={stampEditorRoomId}
|
||||
onClose={() => setStampEditorRoomId(null)}
|
||||
setRoomStamp={setRoomStamp}
|
||||
setRoomStampDoc={setRoomStampDoc}
|
||||
/>
|
||||
)}
|
||||
{/* Raumstempel: kein Dialog mehr ([218]) — Doppelklick auf einen Stempel öffnet die Objekteinstellungen mit dem
|
||||
Abschnitt „Raumstempel". Die Formatier-Leiste in der Oberleiste wirkt weiter live auf den Alt-Text eines Raums. */}
|
||||
|
||||
{/* Dezenter Drop-Rahmen, solange eine Datei über die App gezogen wird. */}
|
||||
{dropActive && (
|
||||
|
||||
@@ -38,7 +38,6 @@ liegen in `src/panels`, Befehle in `src/commands`.
|
||||
| Datei | Inhalt |
|
||||
|---|---|
|
||||
| `LayoutSheet.tsx`, `layoutSheetMath.ts`, `LayoutCreateDialogs.tsx`, `SheetTableHud.tsx` | Layout-Blatt im Haupt-Viewport, Treffer- und Resize-Rechnung der Viewports, Erstell-Dialoge, Eigenschaften einer Blatt-Tabelle |
|
||||
| `TextEditorDialog.tsx`, `RoomStampEditorHost.tsx` | Rich-Text-Editor, Stempel-Editor eines Raums |
|
||||
| `OpeningDetailPanels.tsx`, `ElevationPreview.tsx` | Detail-Panels des Fenster-/Türeditors (der Editor selbst: `panels/objectInfo/OpeningEditor.tsx`), Ansichtsvorschau |
|
||||
|
||||
## Unterordner
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
// Stempel-Editor eines Raums als schwebendes Fenster ([121] aus App.tsx herausgelöst): Doppelklick
|
||||
// auf einen Raumstempel bzw. Button in der Objekt-Info öffnet ihn. Strukturierter Stempel für neue
|
||||
// Räume, freier Rich-Text nur noch als Fallback für Alt-Räume. Liest die Räume selbst aus dem Store.
|
||||
//
|
||||
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
|
||||
|
||||
import { defaultRoomStamp } from "../model/roomStamp";
|
||||
import type { Room } from "../model/types";
|
||||
import { RoomStampEditor } from "../panels/RoomStampEditor";
|
||||
import { useStore } from "../state/appStore";
|
||||
import { docFromText, type RichTextDoc } from "../text/richText";
|
||||
import { TextEditorDialog } from "./TextEditorDialog";
|
||||
|
||||
const NO_ROOMS: Room[] = [];
|
||||
|
||||
export function RoomStampEditorHost({
|
||||
roomId,
|
||||
onClose,
|
||||
setRoomStamp,
|
||||
setRoomStampDoc,
|
||||
}: {
|
||||
roomId: string;
|
||||
onClose: () => void;
|
||||
setRoomStamp: (id: string, stamp: NonNullable<Room["stamp"]>) => void;
|
||||
setRoomStampDoc: (id: string, doc: RichTextDoc) => void;
|
||||
}) {
|
||||
const rooms = useStore((s) => s.project.rooms) ?? NO_ROOMS;
|
||||
const room = rooms.find((r) => r.id === roomId);
|
||||
if (!room) return null;
|
||||
// Strukturierter Stempel für neue Räume (kein Alt-Rich-Text) bzw. sobald
|
||||
// einer gesetzt ist; freier Text nur noch als Fallback für Alt-Räume,
|
||||
// die einen stampDoc, aber keinen strukturierten Stempel tragen.
|
||||
const useStructured = Boolean(room.stamp) || !room.stampDoc;
|
||||
if (useStructured) {
|
||||
return (
|
||||
<RoomStampEditor
|
||||
value={room.stamp ?? defaultRoomStamp(room)}
|
||||
onApply={(edited) => {
|
||||
setRoomStamp(room.id, edited);
|
||||
onClose();
|
||||
}}
|
||||
onCancel={() => onClose()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
const doc = room.stampDoc ?? docFromText(room.name);
|
||||
return (
|
||||
<TextEditorDialog
|
||||
value={doc}
|
||||
onApply={(edited) => {
|
||||
setRoomStampDoc(room.id, edited);
|
||||
onClose();
|
||||
}}
|
||||
onCancel={() => onClose()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
// Schwebendes Dialog-Fenster zum Bearbeiten eines Rich-Text-Dokuments (Raum-
|
||||
// Stempel / Textobjekt). Doppelklick auf einen Stempel öffnet es (nicht den
|
||||
// Footer). Der Body ist der bestehende RichTextEditor (mit eigener Mini-Toolbar,
|
||||
// hier ok, weil eigenes Fenster). „Übernehmen" schreibt das bearbeitete Dokument
|
||||
// zurück, „Abbrechen" verwirft. Bezeichner englisch, UI-Text deutsch.
|
||||
|
||||
import { useState } from "react";
|
||||
import { t } from "../i18n";
|
||||
import { RichTextEditor } from "../editors/RichTextEditor";
|
||||
import type { RichTextDoc } from "../text/richText";
|
||||
|
||||
export interface TextEditorDialogProps {
|
||||
/** Ausgangsdokument (wird beim Öffnen kopiert; Editor arbeitet lokal). */
|
||||
value: RichTextDoc;
|
||||
/** „Übernehmen" — das bearbeitete Dokument zurückschreiben. */
|
||||
onApply: (doc: RichTextDoc) => void;
|
||||
/** „Abbrechen"/Schliessen — ohne Übernahme. */
|
||||
onCancel: () => void;
|
||||
}
|
||||
|
||||
export function TextEditorDialog({ value, onApply, onCancel }: TextEditorDialogProps) {
|
||||
// Lokaler Arbeitszustand — erst „Übernehmen" schreibt zurück (echtes
|
||||
// Abbrechen möglich). Start = übergebenes Dokument.
|
||||
const [draft, setDraft] = useState<RichTextDoc>(value);
|
||||
|
||||
return (
|
||||
<div
|
||||
className="texteditor-overlay"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label={t("text.editTitle")}
|
||||
onMouseDown={(e) => {
|
||||
if (e.target === e.currentTarget) onCancel();
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Escape") onCancel();
|
||||
}}
|
||||
>
|
||||
<div className="texteditor-dialog">
|
||||
<div className="texteditor-head">
|
||||
<span className="texteditor-title">{t("text.editTitle")}</span>
|
||||
<button
|
||||
type="button"
|
||||
className="texteditor-x"
|
||||
onClick={onCancel}
|
||||
title={t("text.cancel")}
|
||||
aria-label={t("text.cancel")}
|
||||
>
|
||||
<span className="material-symbols-outlined" aria-hidden="true">
|
||||
close
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div className="texteditor-body">
|
||||
<RichTextEditor value={draft} onChange={setDraft} autoFocus />
|
||||
</div>
|
||||
<div className="texteditor-foot">
|
||||
<button type="button" className="texteditor-btn" onClick={onCancel}>
|
||||
{t("text.cancel")}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="texteditor-btn texteditor-btn-primary"
|
||||
onClick={() => onApply(draft)}
|
||||
>
|
||||
{t("text.apply")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default TextEditorDialog;
|
||||
+1
-26
@@ -8,6 +8,7 @@
|
||||
// aus App, Aktionen melden sich über Callbacks zurück. Bezeichner englisch,
|
||||
// UI-Text/Kommentare deutsch (CONVENTIONS.md).
|
||||
|
||||
import { TEXT_FONTS } from "../text/fontList";
|
||||
import { t } from "../i18n";
|
||||
import { checkForUpdate } from "../update/checkForUpdate";
|
||||
import { getRunningVersion } from "../update/version";
|
||||
@@ -523,32 +524,6 @@ function Segment({
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schriftauswahl der Text-Gruppe: 15 kuratierte, lokal gebuendelte
|
||||
* Open-Source-Schriften (SIL Open Font License, siehe `src/text/fonts.css`
|
||||
* und `public/fonts/<slug>/OFL.txt`). Bewusst KEINE Systemfonts mehr — die
|
||||
* Darstellung soll unabhaengig vom Betriebssystem und der PDF-Export
|
||||
* deterministisch sein. Ein spaeterer Einstellungen-Dialog kann weitere
|
||||
* Schriften nachladen; das hier ist die Standardliste.
|
||||
*/
|
||||
export const TEXT_FONTS: string[] = [
|
||||
"Inter",
|
||||
"Work Sans",
|
||||
"IBM Plex Sans",
|
||||
"IBM Plex Mono",
|
||||
"Source Sans 3",
|
||||
"Space Grotesk",
|
||||
"Manrope",
|
||||
"Outfit",
|
||||
"DM Sans",
|
||||
"Public Sans",
|
||||
"Karla",
|
||||
"Rubik",
|
||||
"Jost",
|
||||
"Archivo",
|
||||
"Source Serif 4",
|
||||
];
|
||||
|
||||
/** Grössen-Presets (pt) der Text-Gruppe. */
|
||||
const TEXT_SIZES: number[] = [8, 9, 10, 11, 12, 14, 18, 24, 36, 48];
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import type { TextStylePreset } from "../../text/richText";
|
||||
import { TEXT_FONTS } from "../TopBar";
|
||||
import { TEXT_FONTS } from "../../text/fontList";
|
||||
import { t } from "../../i18n";
|
||||
import { ColorField, DeleteButton, FieldRow, NumberField, SelectField } from "./fields";
|
||||
|
||||
|
||||
Reference in new issue
Block a user