From 3d4c4985a9c3850b9e41897a365ca57484067a47 Mon Sep 17 00:00:00 2001 From: Karim Date: Sat, 4 Jul 2026 00:02:50 +0200 Subject: [PATCH] Zoom-Prozent relativ zum angewandten Massstab statt zur Einpassung MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Die Zoom-Anzeige band 100% bisher an die eingepasste Default-Ansicht, nicht an den angewandten Papier-Massstab — der Wert driftete willkürlich. Er wird jetzt in App.tsx aus angewandtem Nenner und Live-Nenner abgeleitet (scaleDenominator / liveScale * 100): im angewandten Massstab exakt 100%, hineinzoomen >100%, herauszoomen <100%. Die fit-basierte onZoom-Meldekette aus PlanView entfällt (Single Source). --- src/App.tsx | 23 +++++++++-------------- src/plan/PlanView.tsx | 12 ------------ 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 5a693e3..f5a652d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -274,8 +274,15 @@ export default function App() { const [liveScale, setLiveScale] = useState(null); // Cursor in Modell-Metern (aus der Plan-Ansicht) bzw. null (nicht über Plan). const [cursor, setCursor] = useState(null); - // Live-Zoom der Plan-Ansicht in Prozent (eingepasst = 100 %). - const [zoomPercent, setZoomPercent] = useState(100); + // Live-Zoom in Prozent RELATIV zum angewandten Papier-Massstab: 100 % = + // Live-Ansicht steht exakt im angewandten Massstab (liveScale == scaleDenominator). + // Reinzoomen > 100 %, Rauszoomen < 100 %. Einzige Quelle: angewandter Nenner + // (scaleDenominator) / Live-Nenner (liveScale). Ohne Live-Massstab (keine + // Plan-Ansicht) Fallback 100 %. + const zoomPercent = + liveScale != null && liveScale > 0 + ? (scaleDenominator / liveScale) * 100 + : 100; // ── Zeichenwerkzeuge (transienter View-State; bleibt lokal) ─────────────── // Aktives Werkzeug, Werkzeug-Parameter (Wandtyp/Kategorie/Linienstil), Snap- @@ -2822,7 +2829,6 @@ export default function App() { displayKey={displayKey} planViewRef={planViewRef} onCursor={setCursor} - onZoom={setZoomPercent} onScale={setLiveScale} selectedWallIds={selectedWallIds} selectedCeilingIds={selectedCeilingIds} @@ -3762,7 +3768,6 @@ function Content({ displayKey, planViewRef, onCursor, - onZoom, onScale, selectedWallIds, selectedCeilingIds, @@ -3824,7 +3829,6 @@ function Content({ displayKey: string; planViewRef: React.RefObject; onCursor: (model: Vec2 | null) => void; - onZoom: (percent: number) => void; onScale: (n: number) => void; selectedWallIds: string[]; selectedCeilingIds: string[]; @@ -3893,7 +3897,6 @@ function Content({ mono={mono} planViewRef={planViewRef} onCursor={onCursor} - onZoom={onZoom} onScale={onScale} selectedWallIds={selectedWallIds} selectedCeilingIds={selectedCeilingIds} @@ -3943,7 +3946,6 @@ function Content({ mono={mono} planViewRef={planViewRef} onCursor={onCursor} - onZoom={onZoom} onScale={onScale} selectedWallIds={selectedWallIds} selectedCeilingIds={selectedCeilingIds} @@ -4024,7 +4026,6 @@ function Content({ mono={mono} planViewRef={planViewRef} onCursor={onCursor} - onZoom={onZoom} onScale={onScale} selectedWallIds={selectedWallIds} selectedCeilingIds={selectedCeilingIds} @@ -4064,7 +4065,6 @@ function LevelPlanView({ mono, planViewRef, onCursor, - onZoom, onScale, selectedWallIds, selectedCeilingIds, @@ -4097,7 +4097,6 @@ function LevelPlanView({ mono: boolean; planViewRef: React.RefObject; onCursor: (model: Vec2 | null) => void; - onZoom: (percent: number) => void; onScale: (n: number) => void; selectedWallIds: string[]; selectedCeilingIds: string[]; @@ -4171,7 +4170,6 @@ function LevelPlanView({ plan={plan} resetKey={level.id} onCursor={onCursor} - onZoom={onZoom} onScale={onScale} selectedWallIds={selectedWallIds} selectedCeilingIds={selectedCeilingIds} @@ -4217,7 +4215,6 @@ function SectionPlanView({ mono, planViewRef, onCursor, - onZoom, onScale, selectedWallIds, selectedCeilingIds, @@ -4246,7 +4243,6 @@ function SectionPlanView({ mono: boolean; planViewRef: React.RefObject; onCursor: (model: Vec2 | null) => void; - onZoom: (percent: number) => void; onScale: (n: number) => void; selectedWallIds: string[]; selectedCeilingIds: string[]; @@ -4330,7 +4326,6 @@ function SectionPlanView({ plan={plan} resetKey={level.id} onCursor={onCursor} - onZoom={onZoom} onScale={onScale} selectedWallIds={selectedWallIds} selectedCeilingIds={selectedCeilingIds} diff --git a/src/plan/PlanView.tsx b/src/plan/PlanView.tsx index c986d00..cb17308 100644 --- a/src/plan/PlanView.tsx +++ b/src/plan/PlanView.tsx @@ -210,11 +210,6 @@ export interface PlanViewProps { * verhält sich die Ansicht wie zuvor. */ onCursor?: (model: Vec2 | null) => void; - /** - * Meldet den aktuellen Zoom in Prozent relativ zur eingepassten Ansicht - * (100 % = eingepasst). Optional. - */ - onZoom?: (percent: number) => void; /** * Meldet den LIVE Papier-Massstab als Nenner N (1:N), berechnet aus dem * aktuellen Ausschnitt + Canvas-Größe + dpi (docs/design/plans-output.md §3). @@ -351,7 +346,6 @@ export const PlanView = forwardRef( plan, resetKey, onCursor, - onZoom, onScale, onSelect, onMarquee, @@ -554,12 +548,6 @@ export const PlanView = forwardRef( }; }, []); - // Zoom in Prozent (eingepasst = 100 %) nach oben melden: kleinere viewBox- - // Breite = stärker hineingezoomt. Reiner Bericht; ändert die Ansicht nicht. - useEffect(() => { - onZoom?.((defaultView.w / view.w) * 100); - }, [onZoom, defaultView.w, view.w]); - // LIVE Papier-Massstab (1:N) nach oben melden. Berechnung aus der effektiven // meet-Skala (Bildschirm-px je viewBox-Einheit) → px je Meter → mm je Meter, // verglichen mit der Papier-Abbildung. Aktualisiert bei Ausschnitts-/Größen-