[139] Merge: Zauberstab-Kürzel, Speichern/Teilen-Tasten, Fensterliste-SVG
This commit is contained in:
21 files changed
+194
-28
No files matched your search
@@ -1191,6 +1191,7 @@ export default function App() {
|
||||
loadImportLayout,
|
||||
setImportPdfOptions,
|
||||
onSaveProject,
|
||||
onSaveProjectAs,
|
||||
onNewProject,
|
||||
onNewProjectFromSample,
|
||||
onNewProjectFromComplexSample,
|
||||
@@ -1373,6 +1374,7 @@ export default function App() {
|
||||
onNewProjectFromTemplate,
|
||||
onOpenProject,
|
||||
onSaveProject,
|
||||
onSaveProjectAs,
|
||||
onImport: () => dxfInputRef.current?.click(),
|
||||
onExportPdf: () => setExportOpen(true),
|
||||
onExportDxf: () => setExportDxfOpen(true),
|
||||
@@ -2003,6 +2005,7 @@ export default function App() {
|
||||
onNewProjectFromTemplate,
|
||||
onOpenProject,
|
||||
onSaveProject,
|
||||
onSaveProjectAs,
|
||||
onImport: () => dxfInputRef.current?.click(),
|
||||
onImportPointCloud: () => openPointCloudFileDialog(),
|
||||
onImportMesh: () => openMeshFileDialog(),
|
||||
@@ -2172,6 +2175,7 @@ export default function App() {
|
||||
onNewProjectFromTemplate={ev.onNewProjectFromTemplate}
|
||||
onOpenProject={ev.onOpenProject}
|
||||
onSaveProject={ev.onSaveProject}
|
||||
onSaveProjectAs={ev.onSaveProjectAs}
|
||||
onImport={ev.onImport}
|
||||
onImportPointCloud={ev.onImportPointCloud}
|
||||
onImportMesh={ev.onImportMesh}
|
||||
|
||||
@@ -22,7 +22,7 @@ const hatchOf = (s: WandState, ctx: CommandContext): string | undefined =>
|
||||
s.sticky.hatch === NONE ? undefined : (usable(ctx)[s.sticky.hatch] ?? usable(ctx)[0])?.id;
|
||||
|
||||
export const wandCommand: Command = {
|
||||
name: "wand",
|
||||
name: "zauberstab",
|
||||
labelKey: "cmd.wand.label",
|
||||
prompt: () => "cmd.wand.point",
|
||||
accepts: () => ["point", "option"],
|
||||
|
||||
@@ -71,4 +71,10 @@ describe("Körper-Befehle (truck)", () => {
|
||||
expect(resolveCommand("bool")?.name).toBe("solidbool");
|
||||
expect(resolveCommand("verschneiden")?.name).toBe("solidbool");
|
||||
});
|
||||
|
||||
it("wand startet die Wand, zauberstab/zs den Zauberstab", () => {
|
||||
expect(resolveCommand("wand")?.name).toBe("wall");
|
||||
expect(resolveCommand("zauberstab")?.name).toBe("zauberstab");
|
||||
expect(resolveCommand("zs")?.name).toBe("zauberstab");
|
||||
});
|
||||
});
|
||||
@@ -107,7 +107,7 @@ export const COMMANDS: Record<string, Command> = {
|
||||
scalebar: scalebarCommand,
|
||||
revcloud: revcloudCommand,
|
||||
pointmarker: pointmarkerCommand,
|
||||
wand: wandCommand,
|
||||
zauberstab: wandCommand,
|
||||
wipeout: wipeoutCommand,
|
||||
text: textCommand,
|
||||
leader: leaderCommand,
|
||||
@@ -223,8 +223,7 @@ export const ALIASES: Record<string, string> = {
|
||||
wolke: "revcloud",
|
||||
revisionswolke: "revcloud",
|
||||
pm: "pointmarker",
|
||||
zs: "wand",
|
||||
zauberstab: "wand",
|
||||
zs: "zauberstab",
|
||||
punkt: "pointmarker",
|
||||
knoten: "pointmarker",
|
||||
wo: "wipeout",
|
||||
|
||||
@@ -302,3 +302,29 @@ describe("scheduleRows — Dächer und Stützen (bisher fehlten sie in Liste/Ele
|
||||
expect(scheduleRows(proj).some((r) => r.id === "RM1")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Fenster- und Türliste als Blatt ([139])", () => {
|
||||
it("keine zwei Texte derselben Zeile überlappen (Musterhaus komplex)", async () => {
|
||||
const { buildComplexSampleProject } = await import("../model/sampleProjectComplex");
|
||||
const { buildOpeningReport } = await import("./openingSchedule");
|
||||
const { layoutAreaReport } = await import("./areaReport");
|
||||
const lay = layoutAreaReport(buildOpeningReport(buildComplexSampleProject()));
|
||||
let texts = 0;
|
||||
for (const page of lay.pages) {
|
||||
const rows = new Map<number, [number, number][]>();
|
||||
for (const p of page) {
|
||||
if (p.k !== "text") continue;
|
||||
texts++;
|
||||
const w = p.s.length * p.size * 0.3528 * 0.45; // untere Schätzung der Breite
|
||||
const box: [number, number] = p.align === "right" ? [p.x - w, p.x] : [p.x, p.x + w];
|
||||
const key = Math.round(p.y * 100);
|
||||
rows.set(key, [...(rows.get(key) ?? []), box]);
|
||||
}
|
||||
for (const boxes of rows.values()) {
|
||||
boxes.sort((a, b) => a[0] - b[0]);
|
||||
for (let i = 1; i < boxes.length; i++) expect(boxes[i - 1]![1]).toBeLessThanOrEqual(boxes[i]![0] + 1e-6);
|
||||
}
|
||||
}
|
||||
expect(texts).toBeGreaterThan(50);
|
||||
});
|
||||
});
|
||||
@@ -102,7 +102,7 @@ function withReveals(sec: ReportSection, rows: OpeningScheduleRow[]): ReportSect
|
||||
return {
|
||||
...sec,
|
||||
columns: [...sec.columns, ...keys.map((name) => t("openings.col.reveal", { name }))],
|
||||
widths: [...sec.widths, ...keys.map(() => 1.4)],
|
||||
widths: [...sec.widths, ...keys.map(() => 1.9)],
|
||||
rows: sec.rows.map((row, i) => ({ ...row, cells: [...row.cells, ...keys.map((k) => num(revealArea(rows[i]!, k), 2))] })),
|
||||
};
|
||||
}
|
||||
@@ -119,7 +119,7 @@ function windowBase(rows: OpeningScheduleRow[]): ReportSection {
|
||||
return {
|
||||
heading: t("openings.windows"),
|
||||
columns: [t("openings.col.mark"), t("openings.col.type"), t("openings.col.floor"), t("openings.col.rooms"), t("openings.col.width"), t("openings.col.height"), t("openings.col.sill"), t("openings.col.sound"), t("openings.col.u"), t("openings.col.rc"), t("openings.col.ext"), t("openings.col.notes")],
|
||||
widths: [1.4, 2.4, 1.4, 3.2, 1.2, 1.2, 1.2, 1.6, 1.1, 1.1, 1.4, 3],
|
||||
widths: [1.3, 3.4, 1.9, 3, 1.4, 1.4, 1.4, 1.5, 1.3, 1.3, 1.6, 2.6],
|
||||
rows: rows.map((r): ReportRow => ({ cells: [r.mark, r.typeName, r.floor, roomsText(r), num(r.width, 2), num(r.height, 2), num(r.sill, 2), r.soundClass, num(r.uValue, 2), r.burglaryClass, externalText(r.external), r.notes] })),
|
||||
};
|
||||
}
|
||||
@@ -128,7 +128,7 @@ function doorBase(rows: OpeningScheduleRow[]): ReportSection {
|
||||
return {
|
||||
heading: t("openings.doors"),
|
||||
columns: [t("openings.col.mark"), t("openings.col.type"), t("openings.col.floor"), t("openings.col.rooms"), t("openings.col.width"), t("openings.col.height"), t("openings.col.clearWidth"), t("openings.col.clearHeight"), t("openings.col.swing"), t("openings.col.fire"), t("openings.col.sound"), t("openings.col.u"), t("openings.col.rc"), t("openings.col.ext"), t("openings.col.notes")],
|
||||
widths: [1.4, 2.2, 1.3, 3, 1.1, 1.1, 1.2, 1.2, 2.6, 1.1, 1.5, 1, 1, 1.3, 2.6],
|
||||
widths: [1.3, 3, 1.9, 3, 1.3, 1.3, 1.4, 1.4, 2.6, 1.1, 1.5, 1.1, 1.3, 1.6, 2.4],
|
||||
rows: rows.map((r): ReportRow => ({ cells: [r.mark, r.typeName, r.floor, roomsText(r), num(r.width, 2), num(r.height, 2), num(r.clearWidth, 2), num(r.clearHeight, 2), swingText(r), r.fireRating, r.soundClass, num(r.uValue, 2), r.burglaryClass, externalText(r.external), r.notes] })),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -134,6 +134,7 @@ export const de = {
|
||||
"menu.native.newFromComplexSample": "Musterhaus (komplex)",
|
||||
"menu.native.newFromTemplateFile": "Vorlagendatei wählen …",
|
||||
"menu.native.open": "Öffnen …",
|
||||
"menu.native.save": "Speichern",
|
||||
"menu.native.saveAs": "Speichern unter …",
|
||||
"menu.native.import": "Importieren …",
|
||||
"menu.native.export": "Exportieren",
|
||||
|
||||
@@ -132,6 +132,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"menu.native.newFromComplexSample": "Sample House (Complex)",
|
||||
"menu.native.newFromTemplateFile": "Choose Template File…",
|
||||
"menu.native.open": "Open…",
|
||||
"menu.native.save": "Save",
|
||||
"menu.native.saveAs": "Save As…",
|
||||
"menu.native.import": "Import…",
|
||||
"menu.native.export": "Export",
|
||||
|
||||
@@ -26,6 +26,7 @@ export interface NativeAppMenuHandlers {
|
||||
onNewProjectFromTemplate: () => void;
|
||||
onOpenProject: () => void;
|
||||
onSaveProject: () => void;
|
||||
onSaveProjectAs: () => void;
|
||||
onImport: () => void;
|
||||
onExportPdf: () => void;
|
||||
onExportDxf: () => void;
|
||||
@@ -173,10 +174,15 @@ export function useNativeAppMenu(
|
||||
action: () => handlersRef.current.onOpenProject(),
|
||||
}),
|
||||
await MenuItem.new({
|
||||
text: t("menu.native.saveAs"),
|
||||
text: t("menu.native.save"),
|
||||
accelerator: "CmdOrCtrl+S",
|
||||
action: () => handlersRef.current.onSaveProject(),
|
||||
}),
|
||||
await MenuItem.new({
|
||||
text: t("menu.native.saveAs"),
|
||||
accelerator: "CmdOrCtrl+Shift+S",
|
||||
action: () => handlersRef.current.onSaveProjectAs(),
|
||||
}),
|
||||
await MenuItem.new({
|
||||
text: t("menu.native.import"),
|
||||
action: () => handlersRef.current.onImport(),
|
||||
|
||||
@@ -124,7 +124,15 @@ export async function saveProjectFile(
|
||||
json: string,
|
||||
projectName: string,
|
||||
onSavedPath?: (path: string) => void,
|
||||
knownPath?: string | null,
|
||||
): Promise<boolean> {
|
||||
// „Speichern" (Cmd/Ctrl+S): bekannter Pfad → ohne Dialog atomar überschreiben.
|
||||
if (knownPath && isTauriRuntime()) {
|
||||
const { writeFileAtomic } = await import("./saveFile");
|
||||
await writeFileAtomic(knownPath, json);
|
||||
onSavedPath?.(knownPath);
|
||||
return true;
|
||||
}
|
||||
const filename = `${projectName || "projekt"}.${PROJECT_EXT}`;
|
||||
return saveTextFile(json, filename, "application/json", PROJECT_DIALOG_FILTERS, onSavedPath, true);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,15 @@ function key(
|
||||
} as KeyboardEvent;
|
||||
}
|
||||
|
||||
describe("Speichern-Kürzel", () => {
|
||||
it("Mod+S und Mod+Shift+S sind für Speichern/Speichern unter frei (Teilen = Mod+Shift+J)", () => {
|
||||
const combos = SHORTCUT_DEFS.map((d) => d.defaultCombo);
|
||||
expect(combos).not.toContain("mod+s");
|
||||
expect(combos).not.toContain("mod+shift+s");
|
||||
expect(SHORTCUT_DEFS.find((d) => d.id === "split")?.defaultCombo).toBe("mod+shift+j");
|
||||
});
|
||||
});
|
||||
|
||||
describe("SHORTCUT_DEFS", () => {
|
||||
it("hat für jede Id eine eindeutige Default-Kombination (keine eingebaute Kollision)", () => {
|
||||
const seen = new Map<string, string>();
|
||||
|
||||
@@ -82,7 +82,7 @@ export const SHORTCUT_DEFS: ShortcutDef[] = [
|
||||
labelKey: "shortcut.deleteSelection",
|
||||
defaultCombo: "Delete",
|
||||
},
|
||||
{ id: "split", category: "edit", labelKey: "shortcut.split", defaultCombo: "mod+s" },
|
||||
{ id: "split", category: "edit", labelKey: "shortcut.split", defaultCombo: "mod+shift+j" },
|
||||
{ id: "join", category: "edit", labelKey: "shortcut.join", defaultCombo: "mod+j" },
|
||||
{ id: "copyElements", category: "edit", labelKey: "shortcut.copyElements", defaultCombo: "mod+c" },
|
||||
{ id: "pasteElements", category: "edit", labelKey: "shortcut.pasteElements", defaultCombo: "mod+v" },
|
||||
|
||||
@@ -392,7 +392,7 @@ export function useSelectAllAndDeleteShortcut(opts: {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ctrl/Cmd+S = Split, Ctrl/Cmd+J = Join der selektierten Drawing2D-Elemente.
|
||||
* Ctrl/Cmd+Shift+J = Split (Ctrl/Cmd+S ist Speichern), Ctrl/Cmd+J = Join der selektierten Drawing2D-Elemente.
|
||||
* Join läuft über DENSELBEN Engine-Befehl wie getipptes „join" (Sofort-
|
||||
* Befehl, autoRun). Split bleibt die direkte Aktion (`runSplit`, in App.tsx —
|
||||
* bleibt dort, da es auch für einen etwaigen Menü-Eintrag geteilt wird). Beide
|
||||
|
||||
@@ -104,6 +104,8 @@ export function useProjectFileActions(
|
||||
// Pfad + Lock-Status der aktuell offenen .obp/.json-Datei (nur Tauri; sonst
|
||||
// bleibt beides null/false — Browser-Blob-Pfad hat keinen echten Pfad).
|
||||
const openedProjectPathRef = useRef<string | null>(null);
|
||||
// Zielpfad für „Speichern" (Cmd/Ctrl+S): gesetzt beim Öffnen und nach „Speichern unter".
|
||||
const savePathRef = useRef<string | null>(null);
|
||||
const projectLockOwnedRef = useRef(false);
|
||||
// Konflikt-Zustand: Datei ist in einer anderen Instanz gesperrt → Dialog mit
|
||||
// „Schreibgeschützt öffnen"/„Trotzdem erzwingen"/„Abbrechen" (kein window.confirm!).
|
||||
@@ -371,11 +373,14 @@ export function useProjectFileActions(
|
||||
// Liefert `true`, wenn wirklich gespeichert wurde (nicht bei abgebrochenem
|
||||
// nativem Dialog) — `guardDiscard`-Aufrufer verlassen sich darauf, um NICHT
|
||||
// zu verwerfen, wenn der Nutzer den Speichern-Dialog abbricht.
|
||||
const onSaveProject = (): Promise<boolean> => {
|
||||
// Cmd/Ctrl+S „Speichern": bekannter Pfad → ohne Dialog; sonst wie „Speichern unter".
|
||||
// Cmd/Ctrl+Shift+S „Speichern unter" fragt immer nach dem Ziel.
|
||||
const saveProjectTo = (asNew: boolean): Promise<boolean> => {
|
||||
const json = serializeProject(project);
|
||||
return saveProjectFile(json, project.name, (path) =>
|
||||
addRecentProject(path, project.name || "modell"),
|
||||
).then(
|
||||
return saveProjectFile(json, project.name, (path) => {
|
||||
savePathRef.current = path;
|
||||
addRecentProject(path, project.name || "modell");
|
||||
}, asNew ? null : savePathRef.current).then(
|
||||
(saved) => {
|
||||
if (saved) {
|
||||
lastSavedProjectRef.current = project;
|
||||
@@ -392,6 +397,8 @@ export function useProjectFileActions(
|
||||
},
|
||||
);
|
||||
};
|
||||
const onSaveProject = (): Promise<boolean> => saveProjectTo(false);
|
||||
const onSaveProjectAs = (): Promise<boolean> => saveProjectTo(true);
|
||||
// „Neu" (Datei-Menü): leeres Projekt, wie am Startbildschirm — löst dabei
|
||||
// einen evtl. gehaltenen Datei-Lock der bisherigen Projektdatei und vergisst
|
||||
// deren Pfad (das leere Projekt ist noch NICHT gespeichert). Über
|
||||
@@ -467,6 +474,7 @@ export function useProjectFileActions(
|
||||
void releaseProjectLock(openedProjectPathRef.current);
|
||||
}
|
||||
openedProjectPathRef.current = null;
|
||||
savePathRef.current = null;
|
||||
projectLockOwnedRef.current = false;
|
||||
};
|
||||
// Übernimmt ein per Pfad geöffnetes Projekt (Tauri-Fluss): parst, prüft grob
|
||||
@@ -482,6 +490,7 @@ export function useProjectFileActions(
|
||||
releaseCurrentProjectLock();
|
||||
lastSavedProjectRef.current = loaded;
|
||||
openedProjectPathRef.current = path;
|
||||
savePathRef.current = path;
|
||||
projectLockOwnedRef.current = lockOwned;
|
||||
addRecentProject(path, loaded.name || "modell");
|
||||
offerRecovery(path);
|
||||
@@ -670,6 +679,7 @@ export function useProjectFileActions(
|
||||
setImportPdfOptions,
|
||||
loadImportLayout,
|
||||
onSaveProject,
|
||||
onSaveProjectAs,
|
||||
onNewProject,
|
||||
onNewProjectFromSample,
|
||||
onNewProjectFromComplexSample,
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ const TOOLS: Record<ToolId, ToolInfo> = {
|
||||
scalebar: { labelKey: "tool.scalebar", hintKey: "tool.scalebar.hint", command: "scalebar" },
|
||||
revcloud: { labelKey: "tool.revcloud", hintKey: "tool.revcloud.hint", command: "revcloud" },
|
||||
pointmarker: { labelKey: "tool.pointmarker", hintKey: "tool.pointmarker.hint", command: "pointmarker" },
|
||||
wand: { labelKey: "tool.wand", hintKey: "tool.wand.hint", command: "wand" },
|
||||
wand: { labelKey: "tool.wand", hintKey: "tool.wand.hint", command: "zauberstab" },
|
||||
grid: { labelKey: "tool.grid", hintKey: "tool.grid.hint", command: "grid" },
|
||||
wipeout: { labelKey: "tool.wipeout", hintKey: "tool.wipeout.hint", command: "wipeout" },
|
||||
text: { labelKey: "tool.text", hintKey: "tool.text.hint", command: "text" },
|
||||
|
||||
@@ -20,6 +20,7 @@ export interface AppMenuBarProps {
|
||||
onNewProjectFromTemplate: () => void;
|
||||
onOpenProject: () => void;
|
||||
onSaveProject: () => void;
|
||||
onSaveProjectAs: () => void;
|
||||
onImport: () => void;
|
||||
/** Datei: Punktwolke importieren ([27]). */
|
||||
onImportPointCloud?: () => void;
|
||||
@@ -65,6 +66,7 @@ export const AppMenuBar = memo(function AppMenuBar({
|
||||
onNewProjectFromTemplate,
|
||||
onOpenProject,
|
||||
onSaveProject,
|
||||
onSaveProjectAs,
|
||||
onImport,
|
||||
onImportPointCloud,
|
||||
onImportMesh,
|
||||
@@ -98,6 +100,7 @@ export const AppMenuBar = memo(function AppMenuBar({
|
||||
{ divider: true },
|
||||
{ label: t("file.open"), onSelect: onOpenProject },
|
||||
{ label: t("file.save"), onSelect: onSaveProject },
|
||||
{ label: t("menu.native.saveAs"), onSelect: onSaveProjectAs },
|
||||
{ divider: true },
|
||||
{ label: t("file.import"), onSelect: onImport },
|
||||
...(onImportPointCloud ? [{ label: t("menu.native.importPointCloud"), onSelect: onImportPointCloud }] : []),
|
||||
|
||||
Reference in new issue
Block a user