[GRASS-SVN] r38337 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jul 9 16:18:55 EDT 2009


Author: martinl
Date: 2009-07-09 16:18:54 -0400 (Thu, 09 Jul 2009)
New Revision: 38337

Modified:
   grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
   grass/trunk/gui/wxpython/gui_modules/toolbars.py
Log:
wxGUI: cleanup zoomback, enable/disable tool


Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py	2009-07-09 18:34:48 UTC (rev 38336)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py	2009-07-09 20:18:54 UTC (rev 38337)
@@ -2459,28 +2459,25 @@
         """!
         Zoom to previous extents in zoomhistory list
         """
-
-        zoom = []
+        zoom = list()
+        
         if len(self.zoomhistory) > 1:
             self.zoomhistory.pop()
-            zoom = self.zoomhistory[len(self.zoomhistory)-1]
-            # (n, s, e, w)
-        if zoom:
-            # zoom to selected region
-            self.Map.region['center_easting'] = zoom[3] + \
-                (zoom[2] - zoom[3]) / 2
-            self.Map.region['center_northing'] = zoom[1] + \
-                (zoom[0] - zoom[1]) / 2
-            self.Map.region["ewres"] = (zoom[2] - zoom[3]) / self.Map.width
-            self.Map.region["nsres"] = (zoom[0] - zoom[1]) / self.Map.height
-            self.Map.AlignExtentFromDisplay()
+            zoom = self.zoomhistory[-1]
+        
+        if len(self.zoomhistory) < 2: # disable tool
+            self.parent.toolbars['map'].Enable('zoomback', enable = False)
+        
+        # zoom to selected region
+        self.Map.GetRegion(n = zoom[0], s = zoom[1],
+                           e = zoom[2], w = zoom[3],
+                           update = True)
+        # update map
+        self.UpdateMap()
+        
+        # update statusbar
+        self.parent.StatusbarUpdate()
 
-            # update map
-            self.UpdateMap()
-
-            # update statusbar
-            self.parent.StatusbarUpdate()
-
     def ZoomHistory(self, n, s, e, w):
         """!
         Manages a list of last 10 zoom extents
@@ -2499,7 +2496,10 @@
         else:
             Debug.msg(4, "BufferedWindow.ZoomHistory(): hist=%s" %
                       (self.zoomhistory))
-
+        
+        if len(self.zoomhistory) > 1:
+            self.parent.toolbars['map'].Enable('zoomback')
+        
         return removed
 
     def OnZoomToMap(self, event):

Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py	2009-07-09 18:34:48 UTC (rev 38336)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py	2009-07-09 20:18:54 UTC (rev 38337)
@@ -180,6 +180,8 @@
                                'bind' : self.mapdisplay.OnPointer }
         self.OnTool(None)
         
+        self.toolbar.EnableTool(self.zoomback, False)
+        
         self.FixSize(width = 90)
         
     def ToolbarData(self):
@@ -290,6 +292,19 @@
                      self.printmap):
             self.toolbar.EnableTool(tool, enabled)
 
+    def Enable(self, tool, enable = True):
+        """!Enable defined tool
+
+        @param tool name
+        @param enable True to enable otherwise disable tool
+        """
+        try:
+            id = getattr(self, tool)
+        except AttributeError:
+            return
+        
+        self.toolbar.EnableTool(self.zoomback, enable)
+
 class GRToolbar(AbstractToolbar):
     """
     Georectification Display toolbar



More information about the grass-commit mailing list