[GRASS-SVN] r29846 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Jan 26 12:05:35 EST 2008
Author: martinl
Date: 2008-01-26 12:05:35 -0500 (Sat, 26 Jan 2008)
New Revision: 29846
Modified:
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
Log:
wxGUI: zoom in/out also with a simple click with the mouse, #24. Zooming is activated by dragging a box with the mouse on the map, simple click or scrolling mouse wheel.
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-01-26 16:13:42 UTC (rev 29845)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-01-26 17:05:35 UTC (rev 29846)
@@ -783,11 +783,13 @@
wheel = event.GetWheelRotation()
# zoom with mouse wheel
if wheel != 0:
+ current = event.GetPositionTuple()[:]
Debug.msg (5, "BufferedWindow.MouseAction(): wheel=%d" % wheel)
- # zoom 1/2 of the screen
- begin = (self.Map.width / 4, self.Map.height / 4)
- end = (self.Map.width - self.Map.width / 4,
- self.Map.height - self.Map.height / 4)
+ # zoom 1/2 of the screen, centered to current mouse position (TODO: settings)
+ begin = (current[0] - self.Map.width / 4,
+ current[1] - self.Map.height / 4)
+ end = (current[0] + self.Map.width / 4,
+ current[1] + self.Map.height / 4)
if wheel > 0:
zoomtype = 1
@@ -1067,8 +1069,20 @@
if self.mouse['use'] in ["zoom", "pan"]:
# set region in zoom or pan
- self.Zoom(self.mouse['begin'], self.mouse['end'], self.zoomtype)
+ begin = self.mouse['begin']
+ end = self.mouse['end']
+ if self.mouse['use'] == 'zoom':
+ # set region for click (zero-width box)
+ if begin[0] - end[0] == 0 or \
+ begin[1] - end[1] == 0:
+ # zoom 1/2 of the screen (TODO: settings)
+ begin = (end[0] - self.Map.width / 4,
+ end[1] - self.Map.height / 4)
+ end = (end[0] + self.Map.width / 4,
+ end[1] + self.Map.height / 4)
+ self.Zoom(begin, end, self.zoomtype)
+
# redraw map
self.UpdateMap(render=True)
More information about the grass-commit
mailing list