Skip to content

Commit

Permalink
Merge pull request wxWidgets#1754 from DKWoods/master
Browse files Browse the repository at this point in the history
Address issue wxWidgets#1753, fix FloatCanvas GUIMode GUIZoomIn and GUIZoomOut…
  • Loading branch information
RobinD42 authored Aug 1, 2020
2 parents a915c8f + b87a4d6 commit 8b67017
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
16 changes: 9 additions & 7 deletions wx/lib/floatcanvas/FloatCanvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,11 +704,11 @@ def MoveImage(self, shift, CoordType, ReDraw=True):
"""
shift = N.asarray(shift,N.float)
if CoordType == 'Panel':# convert from panel coordinates
if CoordType.lower() == 'panel':# convert from panel coordinates
shift = shift * N.array((-1,1),N.float) *self.PanelSize/self.TransformVector
elif CoordType == 'Pixel': # convert from pixel coordinates
elif CoordType.lower() == 'pixel': # convert from pixel coordinates
shift = shift/self.TransformVector
elif CoordType == 'World': # No conversion
elif CoordType.lower() == 'world': # No conversion
pass
else:
raise FloatCanvasError('CoordType must be either "Panel", "Pixel", or "World"')
Expand All @@ -732,7 +732,7 @@ def Zoom(self, factor, center = None, centerCoords="World", keepPointInPlace=Fal
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"
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
Expand All @@ -742,16 +742,18 @@ def Zoom(self, factor, center = None, centerCoords="World", keepPointInPlace=Fal
center = self.ViewPortCenter
centerCoords = 'World' #override input if they don't give a center point.

if centerCoords == "Pixel":
if centerCoords.lower() == "pixel":
oldpoint = self.PixelToWorld( center )
else:
elif centerCoords.lower() == 'world':
oldpoint = N.array(center, N.float)
else:
raise FloatCanvasError('centerCoords must be either "World" or "Pixel"')

self.Scale = self.Scale*factor
if keepPointInPlace:
self.SetToNewScale(False)

if centerCoords == "Pixel":
if centerCoords.lower() == "pixel":
newpoint = self.PixelToWorld( center )
else:
newpoint = N.array(center, N.float)
Expand Down
10 changes: 5 additions & 5 deletions wx/lib/floatcanvas/GUIMode.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ class ZoomWithMouseWheel():
def OnWheel(self, event):
point = event.Position
if event.GetWheelRotation() < 0:
self.Canvas.Zoom(0.9, point, centerCoords = "pixel", keepPointInPlace=True)
self.Canvas.Zoom(0.9, point, centerCoords = "Pixel", keepPointInPlace=True)
else:
self.Canvas.Zoom(1.1, point, centerCoords = "pixel", keepPointInPlace=True)
self.Canvas.Zoom(1.1, point, centerCoords = "Pixel", keepPointInPlace=True)


class GUIMouse(GUIBase):
Expand Down Expand Up @@ -374,7 +374,7 @@ def UpdateScreen(self):
dc.DrawRectangle(*self.PrevRBBox)

def OnRightDown(self, event):
self.Canvas.Zoom(1/1.5, event.GetPosition(), centerCoords="pixel")
self.Canvas.Zoom(1/1.5, event.GetPosition(), centerCoords="Pixel")


class GUIZoomOut(ZoomWithMouseWheel, GUIBase):
Expand All @@ -386,10 +386,10 @@ def __init__(self, Canvas=None):
self.Cursor = self.Cursors.MagMinusCursor

def OnLeftDown(self, event):
self.Canvas.Zoom(1/1.5, event.GetPosition(), centerCoords="pixel")
self.Canvas.Zoom(1/1.5, event.GetPosition(), centerCoords="Pixel")

def OnRightDown(self, event):
self.Canvas.Zoom(1.5, event.GetPosition(), centerCoords="pixel")
self.Canvas.Zoom(1.5, event.GetPosition(), centerCoords="Pixel")

def OnMove(self, event):
# Always raise the Move event.
Expand Down

0 comments on commit 8b67017

Please sign in to comment.