Hi Chris,
As part of my GUI interface I am emulating some of the functionality of
visio. That is to say…
Shift + wheel operation --> pan left/right
Wheel operation --> Pan up/down
Control + wheel operation --> Zoom.
To do this I have coded…..
-----------------------------------------------------------
def OnKeyDown(self,event):
self.controlDown = event.ControlDown()
self.altDown = event.AltDown()
self.shiftDown = event.ShiftDown()
--------------------------------------------------------------
def OnMouseWheel(self,event):
xy = self.CanvasCentre
# self.CanvasCentre is initialised using GetCanvasCentre
(see below)
# just after the canvas has been initialised. Thereafter,
it keeps track of itself
if not self.controlDown and not self.shiftDown:
# Pan Up Down
if self.Pan.StartMove <> None:
xy[1] = xy[1] + float(1.0*event.m_wheelRotation / 6)
self.Pan.MoveImage(event, xy)
print 'Up/Down ---- ',xy
else:
self.Pan.StartMove = N.array(xy)
self.Pan.PrevMoveXY = (0,0)
if self.controlDown:
# Zoom
zratio = 1 + 1.0*event.m_wheelRotation / 1200
self.Canvas.Zoom(zratio,xy)
print 'Zoom ---- ',xy
elif self.shiftDown:
# Pan Left Right
if self.Pan.StartMove <> None:
xy[0] = xy[0] + float(1.0*event.m_wheelRotation / 6)
self.Pan.MoveImage(event, xy)
print 'Left/Right ---- ',xy
else:
self.Pan.StartMove = N.array(xy)
self.Pan.PrevMoveXY = (0,0)
-----------------------------------------------------------------
def GetCanvasCentre(self):
"""
Function to return the centre of the screen in World Coordinates.
"""
size = self.Canvas.GetClientSize()
XY = (size[0]/2,size[1]/2)
WorldXY = self.Canvas.PixelToWorld(XY)
return WorldXY
----------------------------------------------------------------
Where...
self.Pan = GUIMove(self.Canvas)
I have modified the MoveImage event of GuiMove to allow the datum xy to be
ntered rather than Have it calculated from the event xy location. The
datum xy is the world coordinates at centre screen.
What I find is ……
Zoom works OK if we don’t pan. After a pan, zoom operates but it jumps
before it does the zoom. When I pan after a zoom I get a further jump.
The reason for the jump will be that the xy value passed into the two
different routines will be providing different internal datum points. So my
question is, how do I synchronise the two routines. Should I be using a
different datum – say top left rather than the centre?
Thanks in advance.
- David
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.17.8/1195 - Release Date: 24/12/2007
11:19
_______________________________________________
FloatCanvas mailing list
[email protected]
http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas