[GRASS-SVN] r35627 - grass/branches/develbranch_6/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jan 25 16:02:24 EST 2009


Author: martinl
Date: 2009-01-25 16:02:24 -0500 (Sun, 25 Jan 2009)
New Revision: 35627

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
Log:
Go to implemented
   (merge from trunk,  r35626)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py	2009-01-25 21:00:16 UTC (rev 35626)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py	2009-01-25 21:02:24 UTC (rev 35627)
@@ -97,7 +97,8 @@
                               _("Show comp. extent"),
                               _("Display mode"),
                               _("Display geometry"),
-                              _("Map scale")]
+                              _("Map scale"),
+                              _("Go to")]
 
 """File name extension binaries/scripts"""
 if subprocess.mswindows:

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2009-01-25 21:00:16 UTC (rev 35626)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2009-01-25 21:02:24 UTC (rev 35627)
@@ -194,6 +194,15 @@
                                     size=(150, -1))
         self.mapScale.Hide()
         self.statusbar.Bind(wx.EVT_TEXT_ENTER, self.OnChangeMapScale, self.mapScale)
+
+        # go to
+        self.goTo = wx.TextCtrl(parent=self.statusbar, id=wx.ID_ANY,
+                                value="", style=wx.TE_PROCESS_ENTER,
+                                size=(200, -1))
+        self.goTo.Hide()
+        self.statusbar.Bind(wx.EVT_TEXT_ENTER, self.OnGoTo, self.goTo)
+
+
         # on-render gauge
         self.onRenderGauge = wx.Gauge(parent=self.statusbar, id=wx.ID_ANY,
                                       range=0, style=wx.GA_HORIZONTAL)
@@ -739,12 +748,45 @@
         self.MapWindow.UpdateMap()
         self.mapScale.SetFocus()
         
+    def OnGoTo(self, event):
+        """
+        Go to position
+        """
+        try:
+            e, n = map(float, self.goTo.GetValue().split(','))
+        except ValueError:
+            region = self.Map.GetCurrentRegion()
+            self.goTo.SetValue("%.2f, %.2f" % (region['center_northing'],
+                                               region['center_easting']))
+            return
+
+        region = self.Map.GetCurrentRegion()
+        region['center_northing'] = n
+        region['center_easting'] = e
+        dn = (region['nsres'] * region['rows']) / 2.
+        region['n'] = region['center_northing'] + dn
+        region['s'] = region['center_northing'] - dn
+        de = (region['ewres'] * region['cols']) / 2.
+        region['e'] = region['center_easting'] + de
+        region['w'] = region['center_easting'] - de
+        
+        self.Map.AdjustRegion()
+
+        # add to zoom history
+        self.MapWindow.ZoomHistory(region['n'], region['s'],
+                                   region['e'], region['w'])
+        
+        # redraw a map
+        self.MapWindow.UpdateMap()
+        self.goTo.SetFocus()
+        
     def StatusbarUpdate(self):
         """Update statusbar content"""
 
         self.showRegion.Hide()
         self.compResolution.Hide()
         self.mapScale.Hide()
+        self.goTo.Hide()
         self.mapScaleValue = self.ppm = None
 
         if self.toggleStatus.GetSelection() == 0: # Coordinates
@@ -836,6 +878,16 @@
             # disable long help
             self.StatusbarEnableLongHelp(False)
 
+        elif self.toggleStatus.GetSelection() == 7: # go to
+            self.statusbar.SetStatusText("")
+            region = self.Map.GetCurrentRegion()
+            self.goTo.SetValue("%.2f, %.2f" % (region['center_northing'],
+                                              region['center_easting']))
+            self.goTo.Show()
+
+            # disable long help
+            self.StatusbarEnableLongHelp(False)
+        
         else:
             self.statusbar.SetStatusText("", 1)
 



More information about the grass-commit mailing list