[195] Objekteinstellungen-Fenster: Taste T öffnet schwebendes Fenster mit Bereichen Objekt/Darstellung
Neues Panel `object-settings` (schwebend, verschiebbar, folgt der Auswahl, „Keine Auswahl" bei leerer): Bereich Objekt = Objekt-Info samt Abschnitten, Bereich Darstellung = Attribute (dieselben Komponenten, keine Doppelspur). Taste T / Menü ersetzt den Öffnungs-Dialog als Ziel (der Detaildialog bleibt über das Zahnrad im Abschnitt Öffnung). Mehrfachauswahl: Strichstärke und Farbe gelten für alle gewählten Wände/Decken/2D-Elemente (ein Undo-Schritt je Auswahl und Feld), abweichende Werte erscheinen leer. Tests: areas.test.ts, mixedValues.test.ts, e2e objectSettings/objectSettingsWindow. Natives macOS- Nebenfenster offen (TODO.md), nicht in der Tauri-App geprüft.
This commit is contained in:
23 files changed
+491
-51
No files matched your search
+1
-1
@@ -48,7 +48,7 @@ in `ProjectSync`.
|
||||
| `useDormerNotice.ts` | Gauben-Hinweis (in `ProjectSync`, abonniert nur Dächer und Projekt-Id) |
|
||||
| `useMouseSelectionHandlers.ts` | Auswahl und Kontextmenü aus Grundriss und 3D |
|
||||
| `useKeyboardShortcuts.ts`, `keyboardShortcuts.ts`, `commandKeys.ts` | Tastenkürzel, Esc/Enter laufender Befehle |
|
||||
| `objectSettings.ts` | Taste T / Menü „Objekteinstellungen…" ([189]): Öffnungs-Dialog oder Abschnitt der Objekt-Info |
|
||||
| `objectSettings.ts` | Taste T / Menü „Objekteinstellungen…" ([195]): öffnet das schwebende Fenster `object-settings` und klappt den passenden Abschnitt der Objekt-Info auf; `mixedValues.ts`: gemeinsamer Wert über die Mehrfachauswahl (abweichend = leer) |
|
||||
| `useDisplayResolvers.ts` | sichtbar, gedimmt, gesperrt je Ebene und Kategorie |
|
||||
| `useTextTarget.ts`, `useSectionLineState.ts`, `useStatusBarInfo.ts` | Text-Ziel der Formatierleiste; Schnittlinie, 3D-Live-Schnitt; Status-Leiste (je mit schmalen Selektoren) |
|
||||
| `usePanelHostBase.ts`, `panelHost/` | Host-Wert für die Panels: Zusammenbau aus Teil-Bauern je Bereich (`toolsHost`, `selectionStyleHost`, `elementAttributesHost`, `siteHost`, `viewSnapshotsHost` + `viewState`, `layoutsHost`); `stableHost.ts` hält die Identität fest (Handler als Trampoline), solange sich kein Wert-Feld ändert. Projekt und Objekt-Info kommen beim Bau aus dem Store; die Fassung hinter den Trampolinen wird bei geändertem Projekt/Auswahl erst beim Aufruf neu gebaut |
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// [195] Mehrfach-Werte: gleiche Werte → ein Wert, abweichende → leer (gemischt).
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
|
||||
import { commonValue, selectionAppearance, selectedCount } from "./mixedValues";
|
||||
import { EMPTY_SELECTION, mergeSelection } from "./selection";
|
||||
|
||||
describe("commonValue [195]", () => {
|
||||
it("gleich → Wert, abweichend → gemischt, leer → weder noch", () => {
|
||||
expect(commonValue([0.25, 0.25])).toEqual({ value: 0.25, mixed: false });
|
||||
expect(commonValue([0.25, 0.5])).toEqual({ value: undefined, mixed: true });
|
||||
expect(commonValue([])).toEqual({ value: undefined, mixed: false });
|
||||
expect(commonValue(["#000"])).toEqual({ value: "#000", mixed: false });
|
||||
});
|
||||
});
|
||||
|
||||
describe("selectionAppearance [195]", () => {
|
||||
const p = buildComplexSampleProject();
|
||||
const w = p.walls.slice(0, 2).map((x) => x.id);
|
||||
|
||||
it("zwei Wände mit gleicher Strichstärke → ein Wert", () => {
|
||||
const sel = mergeSelection(EMPTY_SELECTION, { walls: [w[0], w[0]] });
|
||||
const a = selectionAppearance(p, sel);
|
||||
expect(a.weightMm.mixed).toBe(false);
|
||||
expect(typeof a.weightMm.value).toBe("number");
|
||||
});
|
||||
|
||||
it("abweichende Strichstärke → gemischt", () => {
|
||||
const q = { ...p, walls: p.walls.map((x) => (x.id === w[1] ? { ...x, strokeWeight: 1.7 } : x)) };
|
||||
const sel = mergeSelection(EMPTY_SELECTION, { walls: w });
|
||||
const a = selectionAppearance(q, sel);
|
||||
expect(a.count).toBe(2);
|
||||
expect(a.weightMm).toEqual({ value: undefined, mixed: true });
|
||||
});
|
||||
|
||||
it("Zählung ohne Gruppen und Lage-Marker", () => {
|
||||
const sel = mergeSelection(EMPTY_SELECTION, { walls: [w[0]], groups: ["g"], site: ["sunStudy"] });
|
||||
expect(selectedCount(sel)).toBe(1);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,53 @@
|
||||
// [195] Mehrfachauswahl im Objekteinstellungs-Fenster: gemeinsamer Wert einer Eigenschaft über alle gewählten
|
||||
// Elemente. Weichen die Werte ab, zeigt das Feld nichts („gemischt"); eine Änderung gilt für alle.
|
||||
|
||||
import type { Project } from "../model/types";
|
||||
import { ELEMENT_KINDS, type Selection, type SelectionKind } from "./selection";
|
||||
import { deriveSelection } from "./selectionInfo";
|
||||
|
||||
/** Gemeinsamer Wert (`value`) oder `mixed`, wenn die Werte abweichen. Leere Liste: weder Wert noch gemischt. */
|
||||
export interface Common<T> {
|
||||
value: T | undefined;
|
||||
mixed: boolean;
|
||||
}
|
||||
|
||||
export function commonValue<T>(values: readonly T[]): Common<T> {
|
||||
if (values.length === 0) return { value: undefined, mixed: false };
|
||||
const first = values[0];
|
||||
return values.every((v) => v === first) ? { value: first, mixed: false } : { value: undefined, mixed: true };
|
||||
}
|
||||
|
||||
/** Arten, deren Stift (Farbe, Strichstärke) das Fenster für alle gewählten Elemente setzt. */
|
||||
export const STYLE_KINDS: readonly SelectionKind[] = ["walls", "ceilings", "drawings"];
|
||||
|
||||
/** Obergrenze, damit eine riesige Auswahl das Fenster nicht ausbremst (je Element eine Kern-Abfrage). */
|
||||
const MAX_COMPARED = 200;
|
||||
|
||||
export interface SelectionAppearance {
|
||||
/** Anzahl gewählter Elemente (ohne gemeinsame Gruppen/Lage-Marker). */
|
||||
count: number;
|
||||
weightMm: Common<number>;
|
||||
color: Common<string>;
|
||||
}
|
||||
|
||||
/** Zahl der gewählten Elemente (ohne Gruppen, Schnittlinien, Lage-Darstellung, Bäume). */
|
||||
export function selectedCount(sel: Selection): number {
|
||||
return ELEMENT_KINDS.filter((k) => k !== "sectionLines" && k !== "site" && k !== "trees").reduce((n, k) => n + sel[k].length, 0);
|
||||
}
|
||||
|
||||
/** Effektive Strichstärke und Farbe über die gewählten Wände/Decken/2D-Elemente. */
|
||||
export function selectionAppearance(project: Project, sel: Selection): SelectionAppearance {
|
||||
const weights: number[] = [];
|
||||
const colors: string[] = [];
|
||||
let n = 0;
|
||||
for (const kind of STYLE_KINDS) {
|
||||
for (const id of sel[kind]) {
|
||||
if (n++ >= MAX_COMPARED) break;
|
||||
const info = deriveSelection(project, { [kind]: [id] });
|
||||
if (!info) continue;
|
||||
weights.push(info.weightMm);
|
||||
colors.push(info.color);
|
||||
}
|
||||
}
|
||||
return { count: selectedCount(sel), weightMm: commonValue(weights), color: commonValue(colors) };
|
||||
}
|
||||
+10
-13
@@ -1,9 +1,10 @@
|
||||
// [189] Taste T (wie Archicad Cmd+T): Einstellungen des gewählten Objekts öffnen. Fenster/Tür → der Öffnungs-
|
||||
// Dialog; alles andere → die Objekt-Info (Panel zeigen, passenden Abschnitt aufklappen und fokussieren);
|
||||
// ohne Auswahl die Voreinstellung des aktiven Werkzeugs (Wand/Decke: Typ des neuen Bauteils), sonst nichts.
|
||||
// Die Zuordnung Auswahl → Ziel ist rein (`panels/objectInfo/groups.ts::objectSettingsTarget`).
|
||||
// [195] Taste T (wie Archicad Cmd+T): das Fenster „Objekteinstellungen" öffnen (schwebendes Panel `object-settings`,
|
||||
// folgt der Auswahl; Bereiche Objekt + Darstellung). Der passende Abschnitt des Bereichs Objekt wird aufgeklappt
|
||||
// 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 } from "../panels/objectInfo/groups";
|
||||
import { setSettingsArea } from "../panels/objectSettings/areaState";
|
||||
import { expandAndFocusInfoGroup } from "../panels/objectInfo/infoGroupState";
|
||||
import { getState } from "./appStore";
|
||||
import { selectionInfoFor } from "./useSelectionInfo";
|
||||
@@ -11,9 +12,8 @@ import { selectionInfoFor } from "./useSelectionInfo";
|
||||
export interface ObjectSettingsDeps {
|
||||
/** Aktives Werkzeug (React-State der App). */
|
||||
activeTool: string;
|
||||
openOpeningEditor: (openingId: string) => void;
|
||||
/** Objekt-Info-Panel sichtbar machen (Dock-Tab, schwebendes Fenster …). */
|
||||
revealObjectInfo: () => void;
|
||||
/** Fenster Objekteinstellungen sichtbar machen (schwebend öffnen bzw. nach vorne holen). */
|
||||
revealObjectSettings: () => void;
|
||||
}
|
||||
|
||||
/** Öffnet die Einstellungen; `false`, wenn es nichts zu öffnen gibt. */
|
||||
@@ -23,15 +23,12 @@ export function openObjectSettings(deps: ObjectSettingsDeps): boolean {
|
||||
let target = objectSettingsTarget(sel, deps.activeTool, isGridDrawing(sel?.kind === "drawing2d" ? sel.id : undefined));
|
||||
// Baum, Lage-Darstellung und Schnittlinie sind keine `SelectionInfo`, haben aber ihre Felder in der Objekt-Info.
|
||||
if (!target && (selection.trees.length > 0 || selection.site.length > 0 || selection.sectionLines.length > 0)) {
|
||||
target = { kind: "info", group: selection.sectionLines.length > 0 ? "sectionLine" : null };
|
||||
target = { group: selection.sectionLines.length > 0 ? "sectionLine" : null };
|
||||
}
|
||||
if (!target) return false;
|
||||
if (target.kind === "opening") {
|
||||
deps.openOpeningEditor(target.id);
|
||||
return true;
|
||||
}
|
||||
setSettingsArea("object");
|
||||
if (target.group) expandAndFocusInfoGroup(target.group);
|
||||
deps.revealObjectInfo();
|
||||
deps.revealObjectSettings();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
// der gewählten Elemente und die Geometrie-Felder freier 2D-Elemente (Linie, Kreis, Bogen, Text).
|
||||
|
||||
import { applyFillMode } from "../fillMode";
|
||||
import { cmdMutation, opsMutation, patchItem } from "../../core";
|
||||
import { cmdMutation, opsMutation, patchItem, patchItems } from "../../core";
|
||||
import { getState } from "../appStore";
|
||||
import { STYLE_KINDS } from "../mixedValues";
|
||||
import { resolvePenColor } from "../../model/penSets";
|
||||
import type { TransformSelection } from "../../tools/transform";
|
||||
import type { FlatHostOpts, HostPart } from "./types";
|
||||
@@ -34,11 +36,28 @@ function singleTransformSel(kind: string, id: string): TransformSelection | null
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Mindestens ein Element der Arten mit Stift (Wand, Decke, 2D) gewählt ([195]: ein Pfad für eines und mehrere). */
|
||||
function multiStyle(): boolean {
|
||||
const s = getState().selection;
|
||||
return STYLE_KINDS.reduce((n, k) => n + s[k].length, 0) > 0;
|
||||
}
|
||||
|
||||
/** coalesceKey je Auswahl: Tippen in einem Feld = ein Undo-Schritt, ein Wechsel der Auswahl beginnt einen neuen. */
|
||||
function styleKey(s: { walls: string[]; ceilings: string[]; drawings: string[] }): string {
|
||||
return [...s.walls, ...s.ceilings, ...s.drawings].join(",");
|
||||
}
|
||||
|
||||
export function buildSelectionStyleHost(c: FlatHostOpts) {
|
||||
const { addColorToCustomPalette, applyChange, commitTransformOn, project, resizeElement, selection, setElementBackground, setElementColor, setElementFill, setElementFillColor, setElementForeground, setElementWeight, setProject, updateCeiling, updateDrawing2D, updateOpening, updateRoof, updateRoom, updateStair, updateWall } = c;
|
||||
return {
|
||||
onSetSelectionColor: (color) => {
|
||||
if (!selection) return;
|
||||
// [195] Farbe für alle gewählten Wände/Decken/2D-Elemente, ein Undo-Schritt.
|
||||
if (multiStyle()) {
|
||||
const s = getState().selection;
|
||||
applyChange((p) => [...patchItems(p, "walls", s.walls, (e) => ({ ...e, color })), ...patchItems(p, "ceilings", s.ceilings, (e) => ({ ...e, color })), ...patchItems(p, "drawings2d", s.drawings, (e) => ({ ...e, color }))], `sel-color:${styleKey(s)}`);
|
||||
return;
|
||||
}
|
||||
if (selection.kind === "wall" || selection.kind === "drawing2d")
|
||||
setElementColor(selection.kind, selection.id, color);
|
||||
else if (selection.kind === "ceiling")
|
||||
@@ -66,6 +85,12 @@ export function buildSelectionStyleHost(c: FlatHostOpts) {
|
||||
else if (selection.kind === "room") updateRoom(selection.id, patch);
|
||||
},
|
||||
onSetSelectionWeight: (weightMm) => {
|
||||
// [195] Für alle gewählten Wände/Decken/2D-Elemente; Tippen = ein Undo-Schritt (coalesceKey).
|
||||
if (multiStyle()) {
|
||||
const s = getState().selection;
|
||||
applyChange((p) => [...patchItems(p, "walls", s.walls, (e) => ({ ...e, strokeWeight: weightMm })), ...patchItems(p, "ceilings", s.ceilings, (e) => ({ ...e, strokeWeight: weightMm })), ...patchItems(p, "drawings2d", s.drawings, (e) => ({ ...e, weightMm }))], `sel-weight:${styleKey(s)}`);
|
||||
return;
|
||||
}
|
||||
// Strichstärke-Override: Wand/Decke (`strokeWeight`) oder Drawing2D (`weightMm`).
|
||||
if (selection?.kind === "wall") updateWall(selection.id, { strokeWeight: weightMm });
|
||||
else if (selection?.kind === "ceiling")
|
||||
|
||||
@@ -56,6 +56,8 @@ declare global {
|
||||
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 };
|
||||
/** [195] Strichstärke-Override der Wände (id → mm), nur gesetzte. */
|
||||
wallWeights: () => Record<string, number>;
|
||||
/** [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[] };
|
||||
};
|
||||
@@ -93,6 +95,7 @@ export function installTestHooks(): void {
|
||||
openings: (p.openings ?? []).map((o) => ({ id: o.id, sillHeight: o.sillHeight, height: o.height })),
|
||||
};
|
||||
},
|
||||
wallWeights: () => Object.fromEntries(getState().project.walls.flatMap((w) => (w.strokeWeight === undefined ? [] : [[w.id, w.strokeWeight]]))),
|
||||
select: (patch) => getState().setSelection(patch),
|
||||
dimPts: (id) => {
|
||||
const g = getState().project.drawings2d.find((d) => d.id === id)?.geom;
|
||||
|
||||
Reference in new issue
Block a user