Hello,
Sorry forget the attachmend.
-------- Original-Nachricht --------
Betreff: Re: ZoomToPoint Patch for Floatcanvas
Datum: Fri, 22 Mar 2013 22:07:09 +0100
Von: Ralf Werner <[email protected]>
An: Chris Barker - NOAA Federal <[email protected]>
Kopie (CC): Mailing List for the wxPython Float Canvas.
<[email protected]>
Hello
Am 22.03.2013 01:34, schrieb Chris Barker - NOAA Federal:
OK -- done. rather than a new method, I"ve added a flag to the Zoom method.
I reviewed youre changes in the repository. You dont use the flag in the
code.
I will post a slightly different method that corrects the problem (also
as patch attached):
def Zoom(self, factor, center = None, centerCoords="world",
keepPointInPlace=False):
"""
Zoom(factor, center) changes the amount of zoom of the image by
factor.
If factor is greater than one, the image gets larger.
If factor is less than one, the image gets smaller.
:param factor: amount to zoom in or out If factor is greater
than one,
the image gets larger. If factor is less than
one, the
image gets smaller.
:param center: a tuple of (x,y) coordinates of the center of
the viewport,
after zooming. If center is not given, the
center will stay the same.
:param centerCoords: flag indicating whether the center given
is in pixel or world
coords. Options are: "world" or "pixel"
:param keepPointInPlace: boolean flag. If False, the center
point is what's given.
If True, the image is shifted so that
the given center point
is kept in the same pixel space. This
facilitates keeping the
same point under the mouse when
zooming with the scroll wheel.
"""
if center is None:
center = self.ViewPortCenter
centerCoords = 'world' #override input if they don't give a
center point.
if centerCoords == "pixel":
oldpoint = self.PixelToWorld( center )
else:
oldpoint = N.array(center, N.float)
self.Scale = self.Scale*factor
if keepPointInPlace:
self.SetToNewScale(False)
if centerCoords == "pixel":
newpoint = self.PixelToWorld( center )
else:
newpoint = N.array(center, N.float)
delta = (newpoint - oldpoint)
self.MoveImage(-delta, 'world')
else:
self.ViewPortCenter = oldpoint
self.SetToNewScale()
I do notice that the image still drifts a bit as you zoom in and out
-- maybe some error introduced by converting back and forth between
world and pixel coordinates?
Im saw this error to. But im not searched for it further. Later i will
search for it.
>From 67102f299b1d83381968a00f907146102f1cd45b Mon Sep 17 00:00:00 2001
From: Ralf Werner <[email protected]>
Date: Fri, 22 Mar 2013 21:32:49 +0100
Subject: [PATCH] correct zoom from svn r73696
Signed-off-by: Ralf Werner <[email protected]>
---
3rdParty/FloatCanvas/floatcanvas/FloatCanvas.py | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/3rdParty/FloatCanvas/floatcanvas/FloatCanvas.py b/3rdParty/FloatCanvas/floatcanvas/FloatCanvas.py
index fc2f5f4..bb2514a 100755
--- a/3rdParty/FloatCanvas/floatcanvas/FloatCanvas.py
+++ b/3rdParty/FloatCanvas/floatcanvas/FloatCanvas.py
@@ -2962,14 +2962,18 @@ class FloatCanvas(wx.Panel):
oldpoint = N.array(center, N.float)
self.Scale = self.Scale*factor
- self.SetToNewScale(False)
-
- if centerCoords == "pixel":
- newpoint = self.PixelToWorld( center )
+ if keepPointInPlace:
+ self.SetToNewScale(False)
+
+ if centerCoords == "pixel":
+ newpoint = self.PixelToWorld( center )
+ else:
+ newpoint = N.array(center, N.float)
+ delta = (newpoint - oldpoint)
+ self.MoveImage(-delta, 'world')
else:
- newpoint = N.array(center, N.float)
- delta = (newpoint - oldpoint)
- self.MoveImage(-delta, 'world')
+ self.ViewPortCenter = oldpoint
+ self.SetToNewScale()
def ZoomToBB(self, NewBB=None, DrawFlag=True):
--
1.7.10.4
_______________________________________________
FloatCanvas mailing list
[email protected]
http://paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas