Archived
Plan: Cmd+Shift-Klick-Durchschalten waehlt nur das aktuelle Objekt dazu (Zwischenstationen werden zurueckgenommen)
This commit is contained in:
1 parent
287fe0274d
commit
cf45dbf497
2 files changed
+79
-82
No files matched your search
+30
-4
@@ -225,7 +225,7 @@ export interface PickCandidate {
|
||||
}
|
||||
|
||||
/** Ids einer Auswahl OHNE Klickposition/Shift — Ergebnis von `defaultPick`. */
|
||||
type PickIds = Omit<PlanSelection, "model" | "shift">;
|
||||
type PickIds = Omit<PlanSelection, "model" | "shift" | "replaces">;
|
||||
|
||||
const EMPTY_PICK: PickIds = {
|
||||
hitIndex: null,
|
||||
@@ -320,6 +320,12 @@ export interface PlanSelection {
|
||||
* ersetzen. Bei Leerraum-Klick mit Shift bleibt die Auswahl erhalten.
|
||||
*/
|
||||
shift: boolean;
|
||||
/**
|
||||
* Nur bei Shift + Durchschalten (Cmd/Strg+Shift-Klick wiederholt an derselben
|
||||
* Stelle): das im vorigen Schritt dazugewählte Objekt wird zuerst wieder
|
||||
* entfernt, damit nicht jede Zwischenstation in der Auswahl landet.
|
||||
*/
|
||||
replaces?: { kind: PickKind; id: string };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2313,6 +2319,8 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
items: PickCandidate[];
|
||||
idx: number;
|
||||
model: Vec2;
|
||||
/** Zuletzt per Shift dazugewähltes Objekt (für Shift-Durchschalten). */
|
||||
applied?: PickCandidate;
|
||||
} | null>(null);
|
||||
// Liste/Zyklus verwerfen, sobald sich Ausschnitt oder Plan ändern.
|
||||
useEffect(() => {
|
||||
@@ -2461,12 +2469,18 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
return [...first, ...ordered];
|
||||
};
|
||||
|
||||
const applyCandidate = (c: PickCandidate, model: Vec2, shift: boolean) => {
|
||||
const applyCandidate = (
|
||||
c: PickCandidate,
|
||||
model: Vec2,
|
||||
shift: boolean,
|
||||
replaces?: { kind: PickKind; id: string },
|
||||
) => {
|
||||
if (!onSelect) return;
|
||||
setSelected(c.hitIndex);
|
||||
onSelect({
|
||||
...EMPTY_PICK,
|
||||
model,
|
||||
replaces,
|
||||
hitIndex: c.hitIndex,
|
||||
shift,
|
||||
wallId: c.kind === "wall" ? c.id : null,
|
||||
@@ -2507,8 +2521,20 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
const v = clientToView(e.clientX, e.clientY, view);
|
||||
model = viewToModel(v.x, v.y);
|
||||
}
|
||||
cycleRef.current = { x: e.clientX, y: e.clientY, prims: plan.primitives, items, idx, model };
|
||||
applyCandidate(items[idx], model, e.shiftKey);
|
||||
const replaces =
|
||||
e.shiftKey && same && prev?.applied && prev.applied.id !== items[idx].id
|
||||
? { kind: prev.applied.kind, id: prev.applied.id }
|
||||
: undefined;
|
||||
cycleRef.current = {
|
||||
x: e.clientX,
|
||||
y: e.clientY,
|
||||
prims: plan.primitives,
|
||||
items,
|
||||
idx,
|
||||
model,
|
||||
applied: e.shiftKey ? items[idx] : undefined,
|
||||
};
|
||||
applyCandidate(items[idx], model, e.shiftKey, replaces);
|
||||
const rect = svgRef.current?.getBoundingClientRect();
|
||||
setPickList({
|
||||
x: e.clientX - (rect?.left ?? 0) + 14,
|
||||
|
||||
@@ -267,84 +267,55 @@ export function useMouseSelectionHandlers(opts: {
|
||||
// Rest behalten (Wände und 2D-Zeichnungen unabhängig, gemischte Auswahl
|
||||
// erlaubt). Leerraum-Klick mit Shift lässt die Auswahl unverändert.
|
||||
if (sel.shift) {
|
||||
if (sel.sectionLineId) {
|
||||
const id = sel.sectionLineId;
|
||||
setSelectedSectionLineIds(
|
||||
selectedSectionLineIds.includes(id)
|
||||
? selectedSectionLineIds.filter((s) => s !== id)
|
||||
: [...selectedSectionLineIds, id],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (sel.wallId) {
|
||||
const id = sel.wallId;
|
||||
setSelectedWallIds(
|
||||
selectedWallIds.includes(id)
|
||||
? selectedWallIds.filter((w) => w !== id)
|
||||
: [...selectedWallIds, id],
|
||||
);
|
||||
} else if (sel.drawingId) {
|
||||
const id = sel.drawingId;
|
||||
setSelectedDrawingIds(
|
||||
selectedDrawingIds.includes(id)
|
||||
? selectedDrawingIds.filter((d) => d !== id)
|
||||
: [...selectedDrawingIds, id],
|
||||
);
|
||||
} else if (sel.ceilingId) {
|
||||
const id = sel.ceilingId;
|
||||
setSelectedCeilingIds(
|
||||
selectedCeilingIds.includes(id)
|
||||
? selectedCeilingIds.filter((c) => c !== id)
|
||||
: [...selectedCeilingIds, id],
|
||||
);
|
||||
} else if (sel.openingId) {
|
||||
const id = sel.openingId;
|
||||
setSelectedOpeningIds(
|
||||
selectedOpeningIds.includes(id)
|
||||
? selectedOpeningIds.filter((o) => o !== id)
|
||||
: [...selectedOpeningIds, id],
|
||||
);
|
||||
} else if (sel.stairId) {
|
||||
const id = sel.stairId;
|
||||
setSelectedStairIds(
|
||||
selectedStairIds.includes(id)
|
||||
? selectedStairIds.filter((s) => s !== id)
|
||||
: [...selectedStairIds, id],
|
||||
);
|
||||
} else if (sel.roomId) {
|
||||
const id = sel.roomId;
|
||||
setSelectedRoomIds(
|
||||
selectedRoomIds.includes(id)
|
||||
? selectedRoomIds.filter((r) => r !== id)
|
||||
: [...selectedRoomIds, id],
|
||||
);
|
||||
} else if (sel.extrudedSolidId) {
|
||||
const id = sel.extrudedSolidId;
|
||||
setSelectedExtrudedSolidIds(
|
||||
selectedExtrudedSolidIds.includes(id)
|
||||
? selectedExtrudedSolidIds.filter((x) => x !== id)
|
||||
: [...selectedExtrudedSolidIds, id],
|
||||
);
|
||||
} else if (sel.columnId) {
|
||||
const id = sel.columnId;
|
||||
setSelectedColumnIds(
|
||||
selectedColumnIds.includes(id)
|
||||
? selectedColumnIds.filter((x) => x !== id)
|
||||
: [...selectedColumnIds, id],
|
||||
);
|
||||
} else if (sel.roofId) {
|
||||
const id = sel.roofId;
|
||||
setSelectedRoofIds(
|
||||
selectedRoofIds.includes(id)
|
||||
? selectedRoofIds.filter((x) => x !== id)
|
||||
: [...selectedRoofIds, id],
|
||||
);
|
||||
} else if (sel.contextObjectId) {
|
||||
const id = sel.contextObjectId;
|
||||
setSelectedContextObjectIds(
|
||||
selectedContextObjectIds.includes(id)
|
||||
? selectedContextObjectIds.filter((x) => x !== id)
|
||||
: [...selectedContextObjectIds, id],
|
||||
// Je Art: Auswahl-Liste + Setter. `replaces` (Shift-Durchschalten) entfernt
|
||||
// zuerst das vorige Zwischenergebnis, bevor das neue Objekt umgeschaltet wird.
|
||||
const channels = {
|
||||
section: [selectedSectionLineIds, setSelectedSectionLineIds],
|
||||
wall: [selectedWallIds, setSelectedWallIds],
|
||||
drawing: [selectedDrawingIds, setSelectedDrawingIds],
|
||||
ceiling: [selectedCeilingIds, setSelectedCeilingIds],
|
||||
opening: [selectedOpeningIds, setSelectedOpeningIds],
|
||||
stair: [selectedStairIds, setSelectedStairIds],
|
||||
room: [selectedRoomIds, setSelectedRoomIds],
|
||||
solid: [selectedExtrudedSolidIds, setSelectedExtrudedSolidIds],
|
||||
column: [selectedColumnIds, setSelectedColumnIds],
|
||||
roof: [selectedRoofIds, setSelectedRoofIds],
|
||||
context: [selectedContextObjectIds, setSelectedContextObjectIds],
|
||||
} as const;
|
||||
type Kind = keyof typeof channels;
|
||||
const target: { kind: Kind; id: string } | null = sel.sectionLineId
|
||||
? { kind: "section", id: sel.sectionLineId }
|
||||
: sel.wallId
|
||||
? { kind: "wall", id: sel.wallId }
|
||||
: sel.drawingId
|
||||
? { kind: "drawing", id: sel.drawingId }
|
||||
: sel.ceilingId
|
||||
? { kind: "ceiling", id: sel.ceilingId }
|
||||
: sel.openingId
|
||||
? { kind: "opening", id: sel.openingId }
|
||||
: sel.stairId
|
||||
? { kind: "stair", id: sel.stairId }
|
||||
: sel.roomId
|
||||
? { kind: "room", id: sel.roomId }
|
||||
: sel.extrudedSolidId
|
||||
? { kind: "solid", id: sel.extrudedSolidId }
|
||||
: sel.columnId
|
||||
? { kind: "column", id: sel.columnId }
|
||||
: sel.roofId
|
||||
? { kind: "roof", id: sel.roofId }
|
||||
: sel.contextObjectId
|
||||
? { kind: "context", id: sel.contextObjectId }
|
||||
: null;
|
||||
const rep = sel.replaces;
|
||||
const base = (kind: Kind): string[] => {
|
||||
const list = channels[kind][0] as readonly string[];
|
||||
return rep && rep.kind === kind ? list.filter((x) => x !== rep.id) : [...list];
|
||||
};
|
||||
if (rep && (!target || rep.kind !== target.kind)) channels[rep.kind][1](base(rep.kind));
|
||||
if (target) {
|
||||
const list = base(target.kind);
|
||||
channels[target.kind][1](
|
||||
list.includes(target.id) ? list.filter((x) => x !== target.id) : [...list, target.id],
|
||||
);
|
||||
}
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user