[137] Klick-Zyklus auch auf Griffen/Körper des Gewählten, Gruppen ohne Mitglieds-Griffe; e2e Situation-Zyklus, Massstabsbalken und Schriftfeld
This commit is contained in:
4 files changed
+186
-12
No files matched your search
+39
-11
@@ -1222,7 +1222,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
// folgt dem Cursor beim Schweben weiter — wie beim Zeichnen (Klick → Punkt
|
||||
// setzen, Maus bewegt sich frei, Wert tippbar, nächster Klick/Enter bestätigt,
|
||||
// Escape verwirft zur ursprünglichen Position `origin` zurück).
|
||||
const gripDrag = useRef<{ pointerId: number; index: number; origin: Vec2 } | null>(
|
||||
const gripDrag = useRef<{ pointerId: number; index: number; origin: Vec2; startX?: number; startY?: number } | null>(
|
||||
null,
|
||||
);
|
||||
// Transiente Kanten-Griff-Zieh-Daten (linke Taste auf einem Dreieck-Anfasser).
|
||||
@@ -1231,7 +1231,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
// onEdgeMove. Dasselbe „bewaffnet"-Verhalten wie gripDrag oben: Loslassen
|
||||
// beendet die Bearbeitung NICHT, erst ein weiterer Klick/Enter (bestätigt)
|
||||
// oder Escape (verwirft zurück auf `edge.mid`).
|
||||
const edgeDrag = useRef<{ pointerId: number; edge: EdgeGrip } | null>(null);
|
||||
const edgeDrag = useRef<{ pointerId: number; edge: EdgeGrip; startX?: number; startY?: number } | null>(null);
|
||||
// Transiente „Körper verschieben"-Daten: letzter Modellpunkt, gegen den das
|
||||
// inkrementelle Delta gebildet wird (parallel-Verschiebung des Elements).
|
||||
const moveDrag = useRef<{
|
||||
@@ -1790,7 +1790,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
// KEIN Pointer-Capture: der Griff bleibt nach dem Loslassen bewaffnet
|
||||
// und folgt via normalem Hover-onPointerMove weiter dem Cursor (s.
|
||||
// Kommentar an der gripDrag-Deklaration).
|
||||
gripDrag.current = { pointerId: e.pointerId, index: gi, origin: grips![gi] };
|
||||
gripDrag.current = { pointerId: e.pointerId, index: gi, origin: grips![gi], startX: e.clientX, startY: e.clientY };
|
||||
return;
|
||||
}
|
||||
// Linke Taste auf einem Kanten-Anfasser (Dreieck): Seite ziehen. KEIN
|
||||
@@ -1800,7 +1800,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
const eg = edgeGripAt(e.clientX, e.clientY);
|
||||
if (eg) {
|
||||
e.preventDefault();
|
||||
edgeDrag.current = { pointerId: e.pointerId, edge: eg };
|
||||
edgeDrag.current = { pointerId: e.pointerId, edge: eg, startX: e.clientX, startY: e.clientY };
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -2218,6 +2218,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
// Liste/Zyklus verwerfen, sobald sich Ausschnitt oder Plan ändern.
|
||||
// [137] Einfacher Klick-Zyklus: Kandidaten des letzten einfachen Klicks (s. pickCycle.ts).
|
||||
const plainCycleRef = useRef<PlainCycle<PickCandidate> | null>(null);
|
||||
const plainCyclePlan = useRef<Plan | null>(null);
|
||||
// Auswahl anderswo geändert (Escape, Panel): Zyklus und Hinweis verwerfen.
|
||||
useEffect(() => {
|
||||
const pc = plainCycleRef.current;
|
||||
@@ -2230,10 +2231,14 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
useEffect(() => {
|
||||
setPickList(null);
|
||||
cycleRef.current = null;
|
||||
}, [view, planRaw]);
|
||||
// Der Klick-Zyklus überlebt neu erzeugte Pläne (Greifen des Gewählten baut den Plan neu auf): Kandidaten
|
||||
// sind Ids; nur Ausschnitt oder Ebene verwerfen ihn.
|
||||
useEffect(() => {
|
||||
plainCycleRef.current = null;
|
||||
onPickHint?.(null);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [view, planRaw]);
|
||||
}, [view, resetKey]);
|
||||
useEffect(() => {
|
||||
if (!pickList) return;
|
||||
const onKey = (ev: KeyboardEvent) => {
|
||||
@@ -2439,16 +2444,26 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
return true;
|
||||
};
|
||||
|
||||
/** [137] Loslassen ohne Bewegung (ohne Shift), und der Klick setzt den Klick-Zyklus fort? */
|
||||
const clickCycles = (e: React.PointerEvent, startX: number | undefined, startY: number | undefined): boolean =>
|
||||
startX !== undefined &&
|
||||
startY !== undefined &&
|
||||
!e.shiftKey &&
|
||||
Math.hypot(e.clientX - startX, e.clientY - startY) < MARQUEE_THRESHOLD_PX &&
|
||||
plainCycleNext(plainCycleRef.current, { x: e.clientX, y: e.clientY, t: Date.now(), planKey: resetKey ?? null }, selection) !== null;
|
||||
|
||||
/** [137] Einfacher Klick an der Stelle des letzten Klicks: nächsten Kandidaten wählen. true = behandelt. */
|
||||
const plainCycleStep = (clientX: number, clientY: number): boolean => {
|
||||
const pc = plainCycleRef.current;
|
||||
const now = Date.now();
|
||||
const next = onSelect ? plainCycleNext(pc, { x: clientX, y: clientY, t: now, planKey: plan }, selection) : null;
|
||||
const next = onSelect ? plainCycleNext(pc, { x: clientX, y: clientY, t: now, planKey: resetKey ?? null }, selection) : null;
|
||||
if (next === null || !pc) return false;
|
||||
pc.idx = next;
|
||||
pc.t = now;
|
||||
const v = clientToView(clientX, clientY, view);
|
||||
applyCandidate(pc.items[next], viewToModel(v.x, v.y), false);
|
||||
// Polygon-Index nur aus demselben Plan (sonst zeigt die lokale Hervorhebung auf ein fremdes Primitiv).
|
||||
const c = pc.items[next];
|
||||
applyCandidate(plainCyclePlan.current === plan ? c : { ...c, hitIndex: null }, viewToModel(v.x, v.y), false);
|
||||
onPickHint?.(cycleHint(pc.items.length, next));
|
||||
return true;
|
||||
};
|
||||
@@ -2461,6 +2476,20 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
cancelAnimationFrame(dragMoveRaf.current);
|
||||
dragMoveRaf.current = null;
|
||||
}
|
||||
// [137] Klick ohne Bewegung auf einen Griff an der Stelle des letzten Klicks: nächstes Objekt statt Griff
|
||||
// bewaffnen (bei kleinem Massstab liegen die Griffe dicht, z. B. Bemassungsketten 1:500). Nichts wurde
|
||||
// gezogen — Griff ohne Änderung abschliessen.
|
||||
const gd0 = gripDrag.current?.pointerId === e.pointerId ? gripDrag.current : null;
|
||||
const ed0 = edgeDrag.current?.pointerId === e.pointerId ? edgeDrag.current : null;
|
||||
if ((gd0 || ed0) && clickCycles(e, (gd0 ?? ed0)!.startX, (gd0 ?? ed0)!.startY)) {
|
||||
gripDrag.current = null;
|
||||
edgeDrag.current = null;
|
||||
dragMovePending.current = null;
|
||||
if (gd0) gripHandlers?.onGripEnd();
|
||||
else gripHandlers?.onEdgeEnd();
|
||||
plainCycleStep(e.clientX, e.clientY);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
(edgeDrag.current && edgeDrag.current.pointerId === e.pointerId) ||
|
||||
(gripDrag.current && gripDrag.current.pointerId === e.pointerId) ||
|
||||
@@ -2512,9 +2541,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
moveDrag.current = null;
|
||||
gripHandlers!.onGripEnd();
|
||||
// [137] Ohne Bewegung war es ein Klick auf das Gewählte: an derselben Stelle zum nächsten Objekt wechseln.
|
||||
if (md.startX !== undefined && Math.hypot(e.clientX - md.startX, e.clientY - (md.startY ?? 0)) < MARQUEE_THRESHOLD_PX && !e.shiftKey) {
|
||||
plainCycleStep(e.clientX, e.clientY);
|
||||
}
|
||||
if (clickCycles(e, md.startX, md.startY)) plainCycleStep(e.clientX, e.clientY);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2584,7 +2611,8 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
onSelect({ model: viewToModel(v.x, v.y), ...dp, shift: e.shiftKey });
|
||||
// [137] Kandidaten an dieser Stelle merken: ein erneuter Klick hier wählt das nächste Objekt.
|
||||
const items = e.shiftKey ? [] : collectCandidates(e.clientX, e.clientY, dp);
|
||||
plainCycleRef.current = items.length > 1 ? { x: e.clientX, y: e.clientY, t: Date.now(), planKey: plan, items, idx: 0 } : null;
|
||||
plainCycleRef.current = items.length > 1 ? { x: e.clientX, y: e.clientY, t: Date.now(), planKey: resetKey ?? null, items, idx: 0 } : null;
|
||||
plainCyclePlan.current = plan;
|
||||
onPickHint?.(cycleHint(items.length, 0));
|
||||
}
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user