Merge branch 'worktree-agent-acb10b8907cc6ed92' into claude/practical-noether-1hb2s1
# Conflicts: # TODO.md # src/i18n/de.ts # src/i18n/en.ts # src/state/keyboardShortcuts.ts # src/state/useSelectionCommands.ts
This commit is contained in:
12 files changed
+229
-24
No files matched your search
@@ -781,3 +781,5 @@ exakte Durchdringung, [61] Zuordnung per Hand, [63] Profil je Kante, [70] Fläch
|
|||||||
(Netze bit-gleich). Offen: Profil am Treppentyp (nur am Element), Profil nur für Handlauf/Pfosten, Stäbe der
|
(Netze bit-gleich). Offen: Profil am Treppentyp (nur am Element), Profil nur für Handlauf/Pfosten, Stäbe der
|
||||||
Absturzsicherung bleiben rund; in der App nicht geklickt
|
Absturzsicherung bleiben rund; in der App nicht geklickt
|
||||||
- **[189]** Panels neu ordnen + Einstellungsdialog (12.11.): Attribute-Panel nur noch Gestaltung (Stift, Linienenden, Bemassungs-Darstellung, Füllung); Typ/Aufbau/Masse/Raum/Dach/Treppe/Verweise, Achsraster, Schnittlinie und „Neues Bauteil" (Wandtyp des Werkzeugs) in der Objekt-Info als einklappbare Gruppen (`panels/objectInfo/groups.ts`, `InfoGroup.tsx`; Zustand in localStorage); die doppelte Maß-Anzeige (Ausdehnung X/Y) im Attribute-Panel entfällt. Taste T (rebindbar, `objectSettings`): Fenster/Tür → Öffnungs-Dialog, sonst Abschnitt der Objekt-Info aufgeklappt und fokussiert, ohne Auswahl bei Wand-/Decken-Werkzeug „Neues Bauteil"; macOS-Menü „Bearbeiten > Objekteinstellungen…" ohne Kürzel (ein nacktes T würde das Tippen abfangen). Wand/Decke/Dach/Treppe haben keinen eigenen Typ-Dialog (nur Objekt-Info). Offen: Menüpunkt in der Browser-Menüleiste; nicht in der Tauri-App geprüft. 12.11.
|
- **[189]** Panels neu ordnen + Einstellungsdialog (12.11.): Attribute-Panel nur noch Gestaltung (Stift, Linienenden, Bemassungs-Darstellung, Füllung); Typ/Aufbau/Masse/Raum/Dach/Treppe/Verweise, Achsraster, Schnittlinie und „Neues Bauteil" (Wandtyp des Werkzeugs) in der Objekt-Info als einklappbare Gruppen (`panels/objectInfo/groups.ts`, `InfoGroup.tsx`; Zustand in localStorage); die doppelte Maß-Anzeige (Ausdehnung X/Y) im Attribute-Panel entfällt. Taste T (rebindbar, `objectSettings`): Fenster/Tür → Öffnungs-Dialog, sonst Abschnitt der Objekt-Info aufgeklappt und fokussiert, ohne Auswahl bei Wand-/Decken-Werkzeug „Neues Bauteil"; macOS-Menü „Bearbeiten > Objekteinstellungen…" ohne Kürzel (ein nacktes T würde das Tippen abfangen). Wand/Decke/Dach/Treppe haben keinen eigenen Typ-Dialog (nur Objekt-Info). Offen: Menüpunkt in der Browser-Menüleiste; nicht in der Tauri-App geprüft. 12.11.
|
||||||
|
|
||||||
|
- **[192]** Ebenen schnell schalten (11.11.): Rechtsklick auf eine Zeile im Ebenen-Panel „Nur diese Ebene anzeigen“ / „Diese Ebene ausblenden“ / „Alle Ebenen einblenden“; im Kontextmenü von Objekt und leerer Fläche (Plan, Schnitt, Ansicht, 3D) „Ebene des Objekts isolieren/ausblenden“ und „Alle Ebenen einblenden“. Sichtbarkeit bleibt `layers[].visible` über Ops (`state/layerIsolate.ts`, ein Undo-Schritt je Aktion); Isolieren lässt Elternklassen an; „Alle einblenden“ stellt den Zustand vor dem ersten Isolieren wieder her (gemerkt je Sitzung/Projekt-Epoche), sonst alles an. Kürzel (umbelegbar): Cmd/Ctrl+Shift+L Ebene der Auswahl isolieren (Cmd+Shift+I ist Boolean-Schnitt), Cmd/Ctrl+Shift+E alle Ebenen einblenden. Test: vitest `layerIsolate.test.ts`, e2e `layerIsolate.spec.ts` (Linux-Chromium; nicht in der Tauri-App geprüft; das native Menü hat keinen Eintrag).
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
// [192] Ebenen schnell schalten (Musterhaus komplex): Rechtsklick auf eine Ebene im Panel bzw. auf ein Objekt im
|
||||||
|
// Plan → isolieren; „Alle Ebenen einblenden" stellt den Zustand davor wieder her. Zahlen über die Test-Naht
|
||||||
|
// `?dossierTest` (`layerView`).
|
||||||
|
import { discardIfAsked, expect, fileMenu, openTab, test } from "./app";
|
||||||
|
import type {} from "../src/state/testHooks"; // Typ von window.__dossierTest
|
||||||
|
|
||||||
|
test("Ebenen isolieren und wieder einblenden", async ({ page }) => {
|
||||||
|
test.setTimeout(120_000);
|
||||||
|
await page.goto("/?dossierTest");
|
||||||
|
await page.getByRole("button", { name: /Neues Projekt/ }).first().click();
|
||||||
|
await fileMenu(page, /Musterhaus \(komplex\)/);
|
||||||
|
await discardIfAsked(page);
|
||||||
|
await expect(page.locator(".project-name")).toHaveText("Musterhaus komplex", { timeout: 30_000 });
|
||||||
|
await openTab(page, "Ebenen");
|
||||||
|
const view = () => page.evaluate(() => window.__dossierTest!.layerView());
|
||||||
|
const before = await view();
|
||||||
|
expect(before.visible.length).toBeGreaterThan(3);
|
||||||
|
|
||||||
|
// Ebenen-Panel: Rechtsklick auf die Zeile → „Nur diese Ebene anzeigen".
|
||||||
|
const row = page.locator(".cat-row").first();
|
||||||
|
const code = (await row.locator(".cat-code").textContent())!.trim();
|
||||||
|
await row.click({ button: "right" });
|
||||||
|
await page.getByRole("menuitem", { name: "Nur diese Ebene anzeigen" }).click();
|
||||||
|
await expect.poll(async () => (await view()).visible).toContain(code);
|
||||||
|
expect((await view()).visible.length).toBeLessThan(before.visible.length);
|
||||||
|
await row.click({ button: "right" });
|
||||||
|
await page.getByRole("menuitem", { name: "Alle Ebenen einblenden" }).click();
|
||||||
|
await expect.poll(async () => (await view()).visible).toEqual(before.visible);
|
||||||
|
|
||||||
|
// Plan: Wand gewählt, Rechtsklick → Ebene des Objekts isolieren → nur noch deren Ebene.
|
||||||
|
await page.evaluate((id) => window.__dossierTest!.select({ walls: [id] }), before.wallId);
|
||||||
|
const plan = page.locator("svg.plan-svg").first();
|
||||||
|
await plan.click({ button: "right", position: { x: 5, y: 5 } });
|
||||||
|
await page.getByRole("menuitem", { name: /Ebene des Objekts isolieren/ }).click();
|
||||||
|
const iso = await view();
|
||||||
|
expect(iso.visible.length).toBeLessThan(before.visible.length);
|
||||||
|
expect(iso.wallPrims).toBeGreaterThan(0);
|
||||||
|
expect(iso.prims).toBeLessThan(before.prims);
|
||||||
|
await plan.click({ button: "right", position: { x: 5, y: 5 } });
|
||||||
|
await page.getByRole("menuitem", { name: "Alle Ebenen einblenden" }).click();
|
||||||
|
await expect.poll(async () => (await view()).visible).toEqual(before.visible);
|
||||||
|
expect((await view()).prims).toBe(before.prims);
|
||||||
|
});
|
||||||
+5
-1
@@ -1057,8 +1057,11 @@ export const de = {
|
|||||||
"ctx.pasteProps": "Eigenschaften einfügen",
|
"ctx.pasteProps": "Eigenschaften einfügen",
|
||||||
"ctx.pasteProps.disabled": "Zwischenablage leer — zuerst „Eigenschaften kopieren“.",
|
"ctx.pasteProps.disabled": "Zwischenablage leer — zuerst „Eigenschaften kopieren“.",
|
||||||
"ctx.hideLayer": "Ebene ausblenden: {name}",
|
"ctx.hideLayer": "Ebene ausblenden: {name}",
|
||||||
|
"ctx.layer.isolate": "Nur diese Ebene anzeigen",
|
||||||
|
"ctx.layer.hide": "Diese Ebene ausblenden",
|
||||||
|
"ctx.layer.showAll": "Alle Ebenen einblenden",
|
||||||
"ctx.hideLayer.n": "{n} Ebenen ausblenden",
|
"ctx.hideLayer.n": "{n} Ebenen ausblenden",
|
||||||
"ctx.isolateLayer": "Nur Ebene zeigen: {name}",
|
"ctx.isolateLayer": "Ebene des Objekts isolieren: {name}",
|
||||||
"ctx.isolateLayer.n": "Nur diese {n} Ebenen zeigen",
|
"ctx.isolateLayer.n": "Nur diese {n} Ebenen zeigen",
|
||||||
"ctx.lock": "Sperren",
|
"ctx.lock": "Sperren",
|
||||||
"ctx.unlock": "Entsperren",
|
"ctx.unlock": "Entsperren",
|
||||||
@@ -3087,6 +3090,7 @@ export const de = {
|
|||||||
"shortcut.showAllLayers": "Alle Ebenen einblenden",
|
"shortcut.showAllLayers": "Alle Ebenen einblenden",
|
||||||
"shortcut.fitAll": "Alles einpassen",
|
"shortcut.fitAll": "Alles einpassen",
|
||||||
"shortcut.fitSelection": "Auf Auswahl einpassen",
|
"shortcut.fitSelection": "Auf Auswahl einpassen",
|
||||||
|
"shortcut.isolateLayer": "Ebene der Auswahl isolieren",
|
||||||
|
|
||||||
"settings.section.update": "Update",
|
"settings.section.update": "Update",
|
||||||
"settings.update.autoCheck": "Automatisch nach Updates suchen",
|
"settings.update.autoCheck": "Automatisch nach Updates suchen",
|
||||||
|
|||||||
@@ -1051,6 +1051,9 @@ export const en: Record<TranslationKey, string> = {
|
|||||||
"ctx.copyProps": "Copy properties",
|
"ctx.copyProps": "Copy properties",
|
||||||
"ctx.pasteProps": "Paste properties",
|
"ctx.pasteProps": "Paste properties",
|
||||||
"ctx.pasteProps.disabled": "Clipboard empty — first use “Copy properties”.",
|
"ctx.pasteProps.disabled": "Clipboard empty — first use “Copy properties”.",
|
||||||
|
"ctx.layer.isolate": "Show only this layer",
|
||||||
|
"ctx.layer.hide": "Hide this layer",
|
||||||
|
"ctx.layer.showAll": "Show all layers",
|
||||||
"ctx.hideLayer": "Hide layer: {name}",
|
"ctx.hideLayer": "Hide layer: {name}",
|
||||||
"ctx.hideLayer.n": "Hide {n} layers",
|
"ctx.hideLayer.n": "Hide {n} layers",
|
||||||
"ctx.isolateLayer": "Show only layer: {name}",
|
"ctx.isolateLayer": "Show only layer: {name}",
|
||||||
@@ -3074,6 +3077,7 @@ export const en: Record<TranslationKey, string> = {
|
|||||||
"shortcut.showAllLayers": "Show all layers",
|
"shortcut.showAllLayers": "Show all layers",
|
||||||
"shortcut.fitAll": "Fit all",
|
"shortcut.fitAll": "Fit all",
|
||||||
"shortcut.fitSelection": "Fit to selection",
|
"shortcut.fitSelection": "Fit to selection",
|
||||||
|
"shortcut.isolateLayer": "Isolate layer of selection",
|
||||||
|
|
||||||
"settings.section.update": "Update",
|
"settings.section.update": "Update",
|
||||||
"settings.update.autoCheck": "Check for updates automatically",
|
"settings.update.autoCheck": "Check for updates automatically",
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import type { PlanViewHandle } from "../views/plan/PlanView";
|
|||||||
import { countClosedAreas, differenceDrawings, intersectionDrawings, unionDrawings } from "../editors/booleanOps";
|
import { countClosedAreas, differenceDrawings, intersectionDrawings, unionDrawings } from "../editors/booleanOps";
|
||||||
import { categoryNames } from "../state/selectionLayers";
|
import { categoryNames } from "../state/selectionLayers";
|
||||||
import type { useProjectActions } from "../state/useProjectActions";
|
import type { useProjectActions } from "../state/useProjectActions";
|
||||||
|
import { hideLayerCodes, isolateLayerCodes, showAllLayerCodes } from "../state/layerIsolate";
|
||||||
import { selectionMenuState, type useSelectionCommands } from "../state/useSelectionCommands";
|
import { selectionMenuState, type useSelectionCommands } from "../state/useSelectionCommands";
|
||||||
import type { useSelectionState } from "../state/useSelectionState";
|
import type { useSelectionState } from "../state/useSelectionState";
|
||||||
import { buildMenuItems, menuTitle, type MenuState } from "./contextMenu";
|
import { buildMenuItems, menuTitle, type MenuState } from "./contextMenu";
|
||||||
@@ -125,6 +126,9 @@ export function AppContextMenu(props: {
|
|||||||
selectionLayerNames: categoryNames(project.layers, selectionLayerCodes),
|
selectionLayerNames: categoryNames(project.layers, selectionLayerCodes),
|
||||||
hideSelectionLayers,
|
hideSelectionLayers,
|
||||||
isolateSelectionLayers,
|
isolateSelectionLayers,
|
||||||
|
isolateLayer: (code) => isolateLayerCodes([code]),
|
||||||
|
hideLayer: (code) => hideLayerCodes([code]),
|
||||||
|
showAllLayers: showAllLayerCodes,
|
||||||
selectionAllNoPrint: !!selectionAllNoPrint,
|
selectionAllNoPrint: !!selectionAllNoPrint,
|
||||||
toggleSelectionNoPrint,
|
toggleSelectionNoPrint,
|
||||||
attachedDimensionCount: attachedDimensionIds.length,
|
attachedDimensionCount: attachedDimensionIds.length,
|
||||||
|
|||||||
@@ -116,6 +116,11 @@ export interface MenuActions {
|
|||||||
hideSelectionLayers: () => void;
|
hideSelectionLayers: () => void;
|
||||||
/** Zeigt NUR die Ebene(n) der aktuellen Auswahl, alle übrigen werden ausgeblendet. */
|
/** Zeigt NUR die Ebene(n) der aktuellen Auswahl, alle übrigen werden ausgeblendet. */
|
||||||
isolateSelectionLayers: () => void;
|
isolateSelectionLayers: () => void;
|
||||||
|
/** [192] Ebenen-Menü im Panel: genau diese Ebene zeigen / ausblenden. */
|
||||||
|
isolateLayer: (code: string) => void;
|
||||||
|
hideLayer: (code: string) => void;
|
||||||
|
/** [192] Alle Ebenen einblenden (stellt den Zustand vor dem Isolieren wieder her). */
|
||||||
|
showAllLayers: () => void;
|
||||||
/**
|
/**
|
||||||
* Sind ALLE aktuell gewählten 2D-Zeichnungen bereits `noPrint`? Bestimmt
|
* Sind ALLE aktuell gewählten 2D-Zeichnungen bereits `noPrint`? Bestimmt
|
||||||
* Label/Icon von „Nicht drucken"/„Drucken" — nur `Drawing2D` kennt das
|
* Label/Icon von „Nicht drucken"/„Drucken" — nur `Drawing2D` kennt das
|
||||||
@@ -166,6 +171,22 @@ function layerMenuItems(code: string, a: MenuActions): ContextMenuItem[] {
|
|||||||
onClick: () => a.openLayerEditor(code),
|
onClick: () => a.openLayerEditor(code),
|
||||||
},
|
},
|
||||||
{ divider: true },
|
{ divider: true },
|
||||||
|
{
|
||||||
|
label: t("ctx.layer.isolate"),
|
||||||
|
icon: <MenuIcon name="filter_alt" />,
|
||||||
|
onClick: () => a.isolateLayer(code),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t("ctx.layer.hide"),
|
||||||
|
icon: <MenuIcon name="visibility_off" />,
|
||||||
|
onClick: () => a.hideLayer(code),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t("ctx.layer.showAll"),
|
||||||
|
icon: <MenuIcon name="visibility" />,
|
||||||
|
onClick: a.showAllLayers,
|
||||||
|
},
|
||||||
|
{ divider: true },
|
||||||
{
|
{
|
||||||
label: t("ctx.addSubLayer"),
|
label: t("ctx.addSubLayer"),
|
||||||
icon: <MenuIcon name="add" />,
|
icon: <MenuIcon name="add" />,
|
||||||
@@ -407,6 +428,11 @@ function planMenuItems(
|
|||||||
a.selectionLayerNames.length === 1
|
a.selectionLayerNames.length === 1
|
||||||
? t(key, { name: a.selectionLayerNames[0] })
|
? t(key, { name: a.selectionLayerNames[0] })
|
||||||
: t(`${key}.n` as "ctx.hideLayer.n", { n: a.selectionLayerNames.length });
|
: t(`${key}.n` as "ctx.hideLayer.n", { n: a.selectionLayerNames.length });
|
||||||
|
const showAllItem: ContextMenuItem = {
|
||||||
|
label: t("ctx.layer.showAll"),
|
||||||
|
icon: <MenuIcon name="visibility" />,
|
||||||
|
onClick: a.showAllLayers,
|
||||||
|
};
|
||||||
const layerItems: ContextMenuItem[] =
|
const layerItems: ContextMenuItem[] =
|
||||||
a.selectionLayerNames.length >= 1
|
a.selectionLayerNames.length >= 1
|
||||||
? [
|
? [
|
||||||
@@ -420,8 +446,9 @@ function planMenuItems(
|
|||||||
icon: <MenuIcon name="filter_alt" />,
|
icon: <MenuIcon name="filter_alt" />,
|
||||||
onClick: a.isolateSelectionLayers,
|
onClick: a.isolateSelectionLayers,
|
||||||
},
|
},
|
||||||
|
showAllItem,
|
||||||
]
|
]
|
||||||
: [];
|
: [showAllItem];
|
||||||
|
|
||||||
// Nicht drucken/Drucken — nur für die 2D-Auswahl (`Drawing2D.noPrint`).
|
// Nicht drucken/Drucken — nur für die 2D-Auswahl (`Drawing2D.noPrint`).
|
||||||
const noPrintItems: ContextMenuItem[] =
|
const noPrintItems: ContextMenuItem[] =
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ export type ShortcutId =
|
|||||||
| "hideSelectionLayers"
|
| "hideSelectionLayers"
|
||||||
| "showAllLayers"
|
| "showAllLayers"
|
||||||
| "fitAll"
|
| "fitAll"
|
||||||
| "fitSelection";
|
| "fitSelection"
|
||||||
|
| "isolateLayer";
|
||||||
|
|
||||||
export type ShortcutCategory =
|
export type ShortcutCategory =
|
||||||
| "general"
|
| "general"
|
||||||
@@ -230,6 +231,8 @@ export const SHORTCUT_DEFS: ShortcutDef[] = [
|
|||||||
{ id: "showAllLayers", category: "navigation", labelKey: "shortcut.showAllLayers", defaultCombo: "mod+shift+a" },
|
{ id: "showAllLayers", category: "navigation", labelKey: "shortcut.showAllLayers", defaultCombo: "mod+shift+a" },
|
||||||
{ id: "fitAll", category: "navigation", labelKey: "shortcut.fitAll", defaultCombo: "mod+0" },
|
{ id: "fitAll", category: "navigation", labelKey: "shortcut.fitAll", defaultCombo: "mod+0" },
|
||||||
{ id: "fitSelection", category: "navigation", labelKey: "shortcut.fitSelection", defaultCombo: "mod+shift+f" },
|
{ id: "fitSelection", category: "navigation", labelKey: "shortcut.fitSelection", defaultCombo: "mod+shift+f" },
|
||||||
|
// [192] Ebenen schnell schalten (Cmd/Ctrl+Shift+I ist der Boolean-Schnitt, daher L = Layer).
|
||||||
|
{ id: "isolateLayer", category: "navigation", labelKey: "shortcut.isolateLayer", defaultCombo: "mod+shift+l" },
|
||||||
];
|
];
|
||||||
|
|
||||||
const DEFS_BY_ID = new Map<ShortcutId, ShortcutDef>(SHORTCUT_DEFS.map((d) => [d.id, d]));
|
const DEFS_BY_ID = new Map<ShortcutId, ShortcutDef>(SHORTCUT_DEFS.map((d) => [d.id, d]));
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { describe, it, expect } from "vitest";
|
||||||
|
import type { LayerCategory } from "../model/types";
|
||||||
|
import { isolateKeepingParents, showAllLayers, visibilityOf, withAncestors } from "./layerIsolate";
|
||||||
|
|
||||||
|
const cat = (code: string, visible = true, children?: LayerCategory[]): LayerCategory => ({
|
||||||
|
code, name: code, color: "#000", lw: 0.2, visible, locked: false, children,
|
||||||
|
});
|
||||||
|
const layers = [cat("20"), cat("05", true, [cat("100"), cat("101", true, [cat("1010")])])];
|
||||||
|
|
||||||
|
describe("Ebenen isolieren [192]", () => {
|
||||||
|
it("nimmt Elternklassen mit", () => {
|
||||||
|
expect([...withAncestors(layers, ["1010"])].sort()).toEqual(["05", "101", "1010"]);
|
||||||
|
});
|
||||||
|
it("isoliert, Eltern bleiben an", () => {
|
||||||
|
expect(visibilityOf(isolateKeepingParents(layers, ["101"]))).toEqual({ "20": false, "05": true, "100": false, "101": true, "1010": false });
|
||||||
|
});
|
||||||
|
it("Alle einblenden stellt den gemerkten Zustand wieder her", () => {
|
||||||
|
const before = [cat("20"), cat("05", false, [cat("100"), cat("101")])];
|
||||||
|
const iso = isolateKeepingParents(before, ["20"]);
|
||||||
|
expect(visibilityOf(showAllLayers(iso, visibilityOf(before)))).toEqual(visibilityOf(before));
|
||||||
|
});
|
||||||
|
it("ohne Gedächtnis (oder wirkungslos) wird alles eingeblendet", () => {
|
||||||
|
const hidden = [cat("20", false), cat("05", false, [cat("100", false)])];
|
||||||
|
expect(Object.values(visibilityOf(showAllLayers(hidden, null))).every(Boolean)).toBe(true);
|
||||||
|
expect(Object.values(visibilityOf(showAllLayers(hidden, visibilityOf(hidden)))).every(Boolean)).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
// [192] Ebenen schnell schalten: „Nur diese Ebene zeigen", „Ebene ausblenden", „Alle einblenden".
|
||||||
|
// Die Sichtbarkeit ist ein Projektfeld (`layers[].visible`) und ändert sich wie jede Änderung über Ops:
|
||||||
|
// jede Aktion ist EIN Undo-Schritt. Der Zustand VOR dem ersten Isolieren wird gemerkt (nur diese Sitzung,
|
||||||
|
// an die Projekt-Epoche gebunden); „Alle einblenden" stellt ihn wieder her, sonst wird alles eingeblendet.
|
||||||
|
// Reine Funktionen oben (getestet in `layerIsolate.test.ts`), Store-Anbindung unten.
|
||||||
|
|
||||||
|
import { fieldOps } from "../core";
|
||||||
|
import type { LayerCategory } from "../model/types";
|
||||||
|
import { flattenCategories } from "../model/types";
|
||||||
|
import { applyVisibilityByCode, isolateCategories, selectionCategoryCodes, setCategoriesVisible } from "../model/layers";
|
||||||
|
import { toMembership } from "./selection";
|
||||||
|
import { getState } from "./appStore";
|
||||||
|
|
||||||
|
/** Codes samt aller Elternklassen (damit eine isolierte Unterklasse sichtbar bleibt). */
|
||||||
|
export function withAncestors(layers: LayerCategory[], codes: readonly string[]): Set<string> {
|
||||||
|
const out = new Set(codes);
|
||||||
|
const walk = (cats: LayerCategory[], path: string[]): void => {
|
||||||
|
for (const c of cats) {
|
||||||
|
if (out.has(c.code)) path.forEach((p) => out.add(p));
|
||||||
|
if (c.children?.length) walk(c.children, [...path, c.code]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
walk(layers, []);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Nur `codes` (und ihre Elternklassen) sichtbar, alle übrigen aus. */
|
||||||
|
export function isolateKeepingParents(layers: LayerCategory[], codes: readonly string[]): LayerCategory[] {
|
||||||
|
return isolateCategories(layers, withAncestors(layers, codes));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sichtbarkeits-Abbild je Code. */
|
||||||
|
export function visibilityOf(layers: LayerCategory[]): Record<string, boolean> {
|
||||||
|
return Object.fromEntries(flattenCategories(layers).map((c) => [c.code, c.visible]));
|
||||||
|
}
|
||||||
|
|
||||||
|
const sameVisibility = (a: Record<string, boolean>, b: Record<string, boolean>): boolean =>
|
||||||
|
Object.keys(a).length === Object.keys(b).length && Object.keys(a).every((k) => a[k] === b[k]);
|
||||||
|
|
||||||
|
/** „Alle einblenden": gemerkter Zustand, falls vorhanden und wirksam, sonst alles an. */
|
||||||
|
export function showAllLayers(layers: LayerCategory[], memory: Record<string, boolean> | null): LayerCategory[] {
|
||||||
|
if (memory) {
|
||||||
|
const restored = applyVisibilityByCode(layers, memory);
|
||||||
|
if (!sameVisibility(visibilityOf(restored), visibilityOf(layers))) return restored;
|
||||||
|
}
|
||||||
|
return setCategoriesVisible(layers, new Set(flattenCategories(layers).map((c) => c.code)), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Store-Anbindung ─────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
let memory: { epoch: number; vis: Record<string, boolean> } | null = null;
|
||||||
|
|
||||||
|
const memoryNow = (): Record<string, boolean> | null =>
|
||||||
|
memory && memory.epoch === getState().projectEpoch ? memory.vis : null;
|
||||||
|
|
||||||
|
/** Isoliert die Ebenen `codes` (Elternklassen bleiben an); merkt beim ersten Mal den Zustand davor. */
|
||||||
|
export function isolateLayerCodes(codes: readonly string[]): void {
|
||||||
|
if (codes.length === 0) return;
|
||||||
|
const st = getState();
|
||||||
|
if (!memoryNow()) memory = { epoch: st.projectEpoch, vis: visibilityOf(st.project.layers) };
|
||||||
|
st.applyChange((p) => fieldOps(p, "layers", isolateKeepingParents(p.layers, codes)));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function hideLayerCodes(codes: readonly string[]): void {
|
||||||
|
if (codes.length === 0) return;
|
||||||
|
getState().applyChange((p) => fieldOps(p, "layers", setCategoriesVisible(p.layers, new Set(codes), false)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Alle Ebenen einblenden bzw. den Zustand vor dem Isolieren wiederherstellen. */
|
||||||
|
export function showAllLayerCodes(): void {
|
||||||
|
const mem = memoryNow();
|
||||||
|
memory = null;
|
||||||
|
getState().applyChange((p) => fieldOps(p, "layers", showAllLayers(p.layers, mem)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Ebenen-Codes der aktuellen Auswahl. */
|
||||||
|
export function selectionLayerCodes(): string[] {
|
||||||
|
const st = getState();
|
||||||
|
return selectionCategoryCodes(st.project, toMembership(st.selection));
|
||||||
|
}
|
||||||
|
|
||||||
|
export const isolateSelectionLayerCodes = (): void => isolateLayerCodes(selectionLayerCodes());
|
||||||
@@ -41,6 +41,8 @@ declare global {
|
|||||||
sectionWalls: () => Promise<{ n: number; area: number }>;
|
sectionWalls: () => Promise<{ n: number; area: number }>;
|
||||||
/** [185] Darstellungszustand der Plan-Ansicht: aktive Ebene, Bildmitte (Modell-m), Zoom (px/m), Massstab. */
|
/** [185] Darstellungszustand der Plan-Ansicht: aktive Ebene, Bildmitte (Modell-m), Zoom (px/m), Massstab. */
|
||||||
viewCamera: () => { levelId: string; center: { x: number; y: number } | null; pxPerMeter: number | null; scale: number };
|
viewCamera: () => { levelId: string; center: { x: number; y: number } | null; pxPerMeter: number | null; scale: number };
|
||||||
|
/** [192] Sichtbare Ebenen-Codes und Zahl der Plan-Primitive (gesamt / mit Wand-Bezug) der aktiven Ebene. */
|
||||||
|
layerView: () => { wallId: string; visible: string[]; prims: number; wallPrims: number };
|
||||||
/** [185] 3D-Element-Filter (Store) und die Wand-ids des 3D-Modells bzw. der Pick-Geometrie mit ihm. */
|
/** [185] 3D-Element-Filter (Store) und die Wand-ids des 3D-Modells bzw. der Pick-Geometrie mit ihm. */
|
||||||
view3d: () => { only: string[] | null; hidden: string[]; walls: string[]; pickWalls: string[] };
|
view3d: () => { only: string[] | null; hidden: string[]; walls: string[]; pickWalls: string[] };
|
||||||
};
|
};
|
||||||
@@ -117,6 +119,19 @@ export function installTestHooks(): void {
|
|||||||
pickWalls: uniq(pickGeometry(p, 0, hide).walls.map((w) => w.wallId)),
|
pickWalls: uniq(pickGeometry(p, 0, hide).walls.map((w) => w.wallId)),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
layerView: () => {
|
||||||
|
const s = getState();
|
||||||
|
const vis: string[] = [];
|
||||||
|
const walk = (cs: { code: string; visible: boolean; children?: unknown[] }[]): void => {
|
||||||
|
for (const c of cs) {
|
||||||
|
if (c.visible) vis.push(c.code);
|
||||||
|
walk((c.children ?? []) as { code: string; visible: boolean; children?: unknown[] }[]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
walk(s.project.layers);
|
||||||
|
const prims = generatePlan(s.project, s.activeLevelId, new Set(vis), undefined, s.detail, false, false, true, 50).primitives;
|
||||||
|
return { wallId: s.project.walls.find((w) => w.floorId === s.activeLevelId)?.id ?? s.project.walls[0]?.id ?? "", visible: vis.sort(), prims: prims.length, wallPrims: prims.filter((q) => !!(q as { wallId?: string }).wallId).length };
|
||||||
|
},
|
||||||
selected: () => ({ drawings: [...getState().selection.drawings], groups: [...getState().selection.groups], all: JSON.stringify(getState().selection) }),
|
selected: () => ({ drawings: [...getState().selection.drawings], groups: [...getState().selection.groups], all: JSON.stringify(getState().selection) }),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -32,6 +32,7 @@ import {
|
|||||||
import type { ElementClipboard, ElementSelectionIds, PastedIds } from "../editors/elementClipboard";
|
import type { ElementClipboard, ElementSelectionIds, PastedIds } from "../editors/elementClipboard";
|
||||||
import { parseClipboardText, serializeClipboardText } from "../editors/elementClipboardSerialize";
|
import { parseClipboardText, serializeClipboardText } from "../editors/elementClipboardSerialize";
|
||||||
import { matchesShortcut, type ShortcutId, type ShortcutOverrides } from "./keyboardShortcuts";
|
import { matchesShortcut, type ShortcutId, type ShortcutOverrides } from "./keyboardShortcuts";
|
||||||
|
import { isolateSelectionLayerCodes, showAllLayerCodes } from "./layerIsolate";
|
||||||
import { hideSelectionIn3d, showSelectionIn3d, stepActiveFloor } from "./tabNavigation";
|
import { hideSelectionIn3d, showSelectionIn3d, stepActiveFloor } from "./tabNavigation";
|
||||||
|
|
||||||
const isEditableTarget = (e: KeyboardEvent): boolean => {
|
const isEditableTarget = (e: KeyboardEvent): boolean => {
|
||||||
@@ -665,7 +666,11 @@ export function useViewNavigationShortcuts(overrides: ShortcutOverrides): void {
|
|||||||
? showSelectionIn3d
|
? showSelectionIn3d
|
||||||
: matchesShortcut(e, "hideSelection3d", overrides)
|
: matchesShortcut(e, "hideSelection3d", overrides)
|
||||||
? hideSelectionIn3d
|
? hideSelectionIn3d
|
||||||
: null;
|
: matchesShortcut(e, "isolateLayer", overrides)
|
||||||
|
? isolateSelectionLayerCodes
|
||||||
|
: matchesShortcut(e, "showAllLayers", overrides)
|
||||||
|
? showAllLayerCodes
|
||||||
|
: null;
|
||||||
if (!fn) return;
|
if (!fn) return;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
fn();
|
fn();
|
||||||
@@ -722,9 +727,7 @@ export function useSelectionActionShortcuts(
|
|||||||
? ref.current.toggleLock
|
? ref.current.toggleLock
|
||||||
: matchesShortcut(e, "hideSelectionLayers", overrides)
|
: matchesShortcut(e, "hideSelectionLayers", overrides)
|
||||||
? ref.current.hideLayers
|
? ref.current.hideLayers
|
||||||
: matchesShortcut(e, "showAllLayers", overrides)
|
: null; // „Alle Ebenen einblenden" ([192]) läuft über useViewNavigationShortcuts
|
||||||
? ref.current.showAllLayers
|
|
||||||
: null;
|
|
||||||
if (!fn) return;
|
if (!fn) return;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
fn();
|
fn();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import type { Drawing2D, DrawingLevel, Project, Vec2 } from "../model/types";
|
import type { Drawing2D, DrawingLevel, Project, Vec2 } from "../model/types";
|
||||||
import type { Selection } from "./selection";
|
import type { Selection } from "./selection";
|
||||||
import { addItems, cmdMutation, fieldOps, opsMutation, patchItems, removeItems } from "../core";
|
import { addItems, cmdMutation, opsMutation, patchItems, removeItems } from "../core";
|
||||||
import type { ToolId } from "../tools/types";
|
import type { ToolId } from "../tools/types";
|
||||||
import type { DrawingStyle } from "../editors/matchProps";
|
import type { DrawingStyle } from "../editors/matchProps";
|
||||||
import { applyDrawingStyleOps, readDrawingStyle } from "../editors/matchProps";
|
import { applyDrawingStyleOps, readDrawingStyle } from "../editors/matchProps";
|
||||||
@@ -25,7 +25,8 @@ import { addedIds, type PastedIds } from "../editors/elementClipboard";
|
|||||||
import { containingGroupId, EMPTY_MEMBERSHIP } from "./groupActions";
|
import { containingGroupId, EMPTY_MEMBERSHIP } from "./groupActions";
|
||||||
import type { GroupMembership, MemberKind } from "./groupActions";
|
import type { GroupMembership, MemberKind } from "./groupActions";
|
||||||
import { isLocked, lockMembersOps } from "./objectLock";
|
import { isLocked, lockMembersOps } from "./objectLock";
|
||||||
import { isolateCategories, selectionCategoryCodes, setCategoriesVisible } from "./selectionLayers";
|
import { selectionCategoryCodes } from "./selectionLayers";
|
||||||
|
import { hideLayerCodes, isolateLayerCodes, showAllLayerCodes } from "./layerIsolate";
|
||||||
import type { ShortcutOverrides } from "./keyboardShortcuts";
|
import type { ShortcutOverrides } from "./keyboardShortcuts";
|
||||||
import {
|
import {
|
||||||
useBooleanOpsShortcut,
|
useBooleanOpsShortcut,
|
||||||
@@ -256,15 +257,11 @@ export function useSelectionCommands(opts: {
|
|||||||
// Ebene(n) der Auswahl ausblenden / isolieren (Kontextmenü). Die Codes rechnet das offene Menü
|
// Ebene(n) der Auswahl ausblenden / isolieren (Kontextmenü). Die Codes rechnet das offene Menü
|
||||||
// (`selectionMenuState`) bzw. der Handler beim Aufruf — bei Kataster-Importen (~10^5 Zeichnungen)
|
// (`selectionMenuState`) bzw. der Handler beim Aufruf — bei Kataster-Importen (~10^5 Zeichnungen)
|
||||||
// nicht bei jedem Render.
|
// nicht bei jedem Render.
|
||||||
const hideSelectionLayers = () => {
|
// [192] Gemerkter Zustand für „Alle einblenden" und Elternklassen: `layerIsolate.ts`.
|
||||||
const { selectionLayerCodes } = menuState(true);
|
const hideSelectionLayers = () => hideLayerCodes(menuState(true).selectionLayerCodes);
|
||||||
if (selectionLayerCodes.length === 0) return;
|
const isolateSelectionLayers = () => isolateLayerCodes(menuState(true).selectionLayerCodes);
|
||||||
const codes = new Set(selectionLayerCodes);
|
// [190]/[192] Alle Ebenen einblenden (stellt den Zustand vor dem Isolieren wieder her).
|
||||||
applyChange((p) => fieldOps(p, "layers", setCategoriesVisible(p.layers, codes, false)));
|
const showAllLayers = showAllLayerCodes;
|
||||||
};
|
|
||||||
// [190] Alle Ebenen wieder einblenden (Cmd/Ctrl+Shift+A, Gegenstück zu „Ebenen der Auswahl ausblenden").
|
|
||||||
const showAllLayers = () =>
|
|
||||||
applyChange((p) => fieldOps(p, "layers", setCategoriesVisible(p.layers, new Set(p.layers.map((l) => l.code)), true)));
|
|
||||||
// [190] Cmd/Ctrl+D: gewählte Elemente duplizieren — Kopie mit Versatz (0.5 m rechts/unten), die Kopie ist danach gewählt.
|
// [190] Cmd/Ctrl+D: gewählte Elemente duplizieren — Kopie mit Versatz (0.5 m rechts/unten), die Kopie ist danach gewählt.
|
||||||
const duplicateSelection = () => {
|
const duplicateSelection = () => {
|
||||||
if (!hasTransformable(selection)) return;
|
if (!hasTransformable(selection)) return;
|
||||||
@@ -276,12 +273,6 @@ export function useSelectionCommands(opts: {
|
|||||||
});
|
});
|
||||||
if (out.ids) setSelection(fromIdLists(out.ids));
|
if (out.ids) setSelection(fromIdLists(out.ids));
|
||||||
};
|
};
|
||||||
const isolateSelectionLayers = () => {
|
|
||||||
const { selectionLayerCodes } = menuState(true);
|
|
||||||
if (selectionLayerCodes.length === 0) return;
|
|
||||||
const codes = new Set(selectionLayerCodes);
|
|
||||||
applyChange((p) => fieldOps(p, "layers", isolateCategories(p.layers, codes)));
|
|
||||||
};
|
|
||||||
|
|
||||||
// „Nicht drucken"/„Drucken" (Kontextmenü) — nur `Drawing2D` kennt
|
// „Nicht drucken"/„Drucken" (Kontextmenü) — nur `Drawing2D` kennt
|
||||||
// `noPrint` (Nutzer-Wunsch „Kein 'nicht druckend'-Flag im Modell"), daher
|
// `noPrint` (Nutzer-Wunsch „Kein 'nicht druckend'-Flag im Modell"), daher
|
||||||
|
|||||||
Reference in new issue
Block a user