[GRASS-SVN] r38318 - grass/branches/releasebranch_6_4/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jul 8 13:59:26 EDT 2009


Author: martinl
Date: 2009-07-08 13:59:26 -0400 (Wed, 08 Jul 2009)
New Revision: 38318

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gdialogs.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/render.py
Log:
wrong coordinates after zoom to named region (trac #678)


Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gdialogs.py	2009-07-08 16:43:44 UTC (rev 38317)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gdialogs.py	2009-07-08 17:59:26 UTC (rev 38318)
@@ -227,6 +227,7 @@
             box.Add(item=label, proportion=0, flag=wx.ALIGN_CENTRE | wx.ALL, border=5)
             self.selection = gselect.Select(parent=self, id=wx.ID_ANY, size=globalvar.DIALOG_GSELECT_SIZE,
                                             type='windows')
+            self.selection.SetFocus()
             box.Add(item=self.selection, proportion=0, flag=wx.ALIGN_CENTRE | wx.ALL, border=5)
             self.selection.Bind(wx.EVT_TEXT, self.OnSelection)
 
@@ -235,6 +236,7 @@
             box.Add(item=label, proportion=0, flag=wx.ALIGN_CENTRE | wx.ALL, border=5)
             self.textentry = wx.TextCtrl(parent=self, id=wx.ID_ANY, value="",
                                          size=globalvar.DIALOG_TEXTCTRL_SIZE)
+            self.textentry.SetFocus()
             box.Add(item=self.textentry, proportion=0, flag=wx.ALIGN_CENTRE | wx.ALL, border=5)
             self.textentry.Bind(wx.EVT_TEXT, self.OnText)
 

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py	2009-07-08 16:43:44 UTC (rev 38317)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py	2009-07-08 17:59:26 UTC (rev 38318)
@@ -2438,66 +2438,59 @@
             os.environ["GRASS_REGION"] = tmpreg
 
     def ZoomToSaved(self, event):
-        """
-        Set display geometry to match extents in
+        """!Set display geometry to match extents in
         saved region file
         """
-
-        zoomreg = {}
-
-        dlg = gdialogs.SavedRegion(self, wx.ID_ANY, _("Zoom to saved region extents"),
+        dlg = gdialogs.SavedRegion(parent = self, id = wx.ID_ANY,
+                                   title = _("Zoom to saved region extents"),
                                    pos=wx.DefaultPosition, size=wx.DefaultSize,
                                    style=wx.DEFAULT_DIALOG_STYLE,
                                    loadsave='load')
-
+        
         if dlg.ShowModal() == wx.ID_CANCEL:
             dlg.Destroy()
             return
-
+        
         wind = dlg.wind
-
-        p = gcmd.Command (["g.region", "-ugp", "region=%s" % wind])
-
-        if p.returncode == 0:
-            output = p.ReadStdOutput()
-            for line in output:
-                line = line.strip()
-                if '=' in line: key,val = line.split('=')
-                zoomreg[key] = float(val)
-            self.Map.region['n'] = zoomreg['n']
-            self.Map.region['s'] = zoomreg['s']
-            self.Map.region['e'] = zoomreg['e']
-            self.Map.region['w'] = zoomreg['w']
-            self.ZoomHistory(self.Map.region['n'],self.Map.region['s'],self.Map.region['e'],self.Map.region['w'])
-            self.UpdateMap()
-
+        
+        self.Map.GetRegion(regionName = wind,
+                           update = True)
+        
         dlg.Destroy()
-
+        
+        self.ZoomHistory(self.Map.region['n'],
+                         self.Map.region['s'],
+                         self.Map.region['e'],
+                         self.Map.region['w'])
+        
+        self.UpdateMap()
+    
     def SaveDisplayRegion(self, event):
         """
         Save display extents to named region file.
         """
 
-        dlg = gdialogs.SavedRegion(self, wx.ID_ANY, "Save display extents to region file",
+        dlg = gdialogs.SavedRegion(parent = self, id = wx.ID_ANY,
+                                   title = _("Save display extents to region file"),
                                    pos=wx.DefaultPosition, size=wx.DefaultSize,
                                    style=wx.DEFAULT_DIALOG_STYLE,
                                    loadsave='save')
         if dlg.ShowModal() == wx.ID_CANCEL:
             dlg.Destroy()
             return
-
+        
         wind = dlg.wind
-
+        
         # test to see if it already exists and ask permission to overwrite
         windpath = os.path.join(self.Map.env["GISDBASE"], self.Map.env["LOCATION_NAME"],
-                                self.Map.env["MAPSET"],"windows",wind)
-
+                                self.Map.env["MAPSET"], "windows", wind)
+        
         if windpath and not os.path.exists(windpath):
             self.SaveRegion(wind)
         elif windpath and os.path.exists(windpath):
             overwrite = wx.MessageBox(_("Region file <%s> already exists. "
                                         "Do you want to overwrite it?") % (wind),
-                                      _("Warning"), wx.YES_NO)
+                                      _("Warning"), wx.YES_NO | wx.CENTRE)
             if (overwrite == wx.YES):
                 self.SaveRegion(wind)
         else:
@@ -2509,8 +2502,9 @@
         """
         Save region settings
         """
-        new = self.Map.AlignResolution()
-
+        ### new = self.Map.AlignResolution()
+        new = self.Map.GetCurrentRegion()
+        
         cmdRegion = ["g.region",
                      "-u",
                      "n=%f" % new['n'],

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/render.py	2009-07-08 16:43:44 UTC (rev 38317)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/render.py	2009-07-08 17:59:26 UTC (rev 38318)
@@ -583,17 +583,17 @@
             self.height = 480
             return False
 
-    def GetRegion(self, rast = [], zoom = False, vect = [],
+    def GetRegion(self, rast = [], zoom = False, vect = [], regionName = None,
                   n = None, s = None, e = None, w = None, default = False,
                   update = False):
-        """
-        Get region settings (g.region -upgc)
+        """!Get region settings (g.region -upgc)
 
         Optionally extent, raster or vector map layer can be given.
-
-        @param rast raster name or None
-        @param vect vector name or None
-        @param zoom zoom to raster (ignore NULLs)
+        
+        @param rast list of raster maps
+        @param zoom zoom to raster map (ignore NULLs)
+        @param vect list of vector maps
+        @param regionName  named region or None
         @param n,s,e,w force extent
         @param default force default region settings
         @param update if True update current display region settings
@@ -601,7 +601,6 @@
         @return region settings as directory, e.g. {
         'n':'4928010', 's':'4913700', 'w':'589980',...}
         """
-
         region = {}
 
         tmpreg = os.getenv("GRASS_REGION")
@@ -618,7 +617,10 @@
 
         if default:
             cmdList.append('-d')
-            
+        
+        if regionName:
+            cmdList.append('region=%s' % regionName)
+        
         if n:
             cmdList.append('n=%s' % n)
         if s:
@@ -651,10 +653,7 @@
                               "Force quiting wxGUI. Please run manually g.region to "
                               "fix the problem.")
             e.Show()
-            if not rast and not vect:
-                sys.exit(1)
-            else:
-                return self.region
+            return self.region
 
         for reg in cmdRegion.ReadStdOutput():
             key, val = reg.split("=", 1)



More information about the grass-commit mailing list