[GRASS-SVN] r53058 - grass/branches/releasebranch_6_4/gui/wxpython/mapdisp
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Sep 2 11:46:39 PDT 2012
Author: annakrat
Date: 2012-09-02 11:46:39 -0700 (Sun, 02 Sep 2012)
New Revision: 53058
Modified:
grass/branches/releasebranch_6_4/gui/wxpython/mapdisp/mapwindow.py
Log:
wxGUI: fix zooming out by one click (not box), merge from trunk - r52745
Modified: grass/branches/releasebranch_6_4/gui/wxpython/mapdisp/mapwindow.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/mapdisp/mapwindow.py 2012-09-02 18:45:30 UTC (rev 53057)
+++ grass/branches/releasebranch_6_4/gui/wxpython/mapdisp/mapwindow.py 2012-09-02 18:46:39 UTC (rev 53058)
@@ -895,6 +895,25 @@
return self.lineid
+ def _computeZoomToPointAndRecenter(self, position, zoomtype):
+ """!Computes zoom parameters for recenter mode.
+
+ Computes begin and end parameters for Zoom() method.
+ Used for zooming by single click (not box)
+ and mouse wheel zooming (zoom and recenter mode).
+ """
+ if zoomtype > 0:
+ begin = (position[0] - self.Map.width / 4,
+ position[1] - self.Map.height / 4)
+ end = (position[0] + self.Map.width / 4,
+ position[1] + self.Map.height / 4)
+ else:
+ begin = ((self.Map.width - position[0]) / 2,
+ (self.Map.height - position[1]) / 2)
+ end = (begin[0] + self.Map.width / 2,
+ begin[1] + self.Map.height / 2)
+ return begin, end
+
def MouseActions(self, event):
"""!Mouse motion and button click notifier
"""
@@ -968,16 +987,8 @@
zoomtype *= -1
# zoom 1/2 of the screen (TODO: settings)
if zoomBehaviour == 0: # zoom and recenter
- if zoomtype > 0:
- 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)
- else:
- begin = ((self.Map.width - current[0]) / 2,
- (self.Map.height - current[1]) / 2)
- end = (begin[0] + self.Map.width / 2,
- begin[1] + self.Map.height / 2)
+ begin, end = self._computeZoomToPointAndRecenter(position = current, zoomtype = zoomtype)
+
elif zoomBehaviour == 1: # zoom to current cursor position
begin = (current[0]/2, current[1]/2)
end = ((self.Map.width - current[0])/2 + current[0],
@@ -1094,12 +1105,7 @@
# 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)
-
+ begin, end = self._computeZoomToPointAndRecenter(position = end, zoomtype = self.zoomtype)
self.Zoom(begin, end, self.zoomtype)
# redraw map
More information about the grass-commit
mailing list