[GRASS-SVN] r57966 - in grass/trunk/gui/wxpython: gcp mapdisp mapwin
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Oct 9 11:38:42 PDT 2013
Author: martinl
Date: 2013-10-09 11:38:41 -0700 (Wed, 09 Oct 2013)
New Revision: 57966
Modified:
grass/trunk/gui/wxpython/gcp/mapdisplay.py
grass/trunk/gui/wxpython/mapdisp/frame.py
grass/trunk/gui/wxpython/mapwin/buffered.py
Log:
wxGUI/mapdisp: add 'set computational region from saved region' to the zoom menu
Modified: grass/trunk/gui/wxpython/gcp/mapdisplay.py
===================================================================
--- grass/trunk/gui/wxpython/gcp/mapdisplay.py 2013-10-09 09:25:01 UTC (rev 57965)
+++ grass/trunk/gui/wxpython/gcp/mapdisplay.py 2013-10-09 18:38:41 UTC (rev 57966)
@@ -436,7 +436,7 @@
"""!Set display geometry to match extents in
saved region file
"""
- self.MapWindow.ZoomToSaved()
+ self.MapWindow.SetRegion(zoomOnly=True)
def OnDisplayToWind(self, event):
"""!Set computational region (WIND file) to match display
Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py 2013-10-09 09:25:01 UTC (rev 57965)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py 2013-10-09 18:38:41 UTC (rev 57966)
@@ -1117,13 +1117,19 @@
"""!Set display geometry to match extents in
saved region file
"""
- self.MapWindow.ZoomToSaved()
+ self.MapWindow.SetRegion(zoomOnly=True)
- def OnDisplayToWind(self, event):
+ def OnSetDisplayToWind(self, event):
"""!Set computational region (WIND file) to match display
extents
"""
self.MapWindow.DisplayToWind()
+
+ def OnSetWindToRegion(self, event):
+ """!Set computational region (WIND file) from named region
+ file
+ """
+ self.MapWindow.SetRegion(zoomOnly=False)
def OnSaveDisplayRegion(self, event):
"""!Save display extents to named region file.
@@ -1143,13 +1149,19 @@
for label, handler in ((_('Zoom to computational region'), self.OnZoomToWind),
(_('Zoom to default region'), self.OnZoomToDefault),
(_('Zoom to saved region'), self.OnZoomToSaved),
- (_('Set computational region from display extent'), self.OnDisplayToWind),
+ (None, None),
+ (_('Set computational region from display extent'), self.OnSetDisplayToWind),
+ (_('Set computational region from named region'), self.OnSetWindToRegion),
+ (None, None),
(_('Save display geometry to named region'), self.OnSaveDisplayRegion),
(_('Save computational region to named region'), self.OnSaveWindRegion)):
- mid = wx.MenuItem(zoommenu, wx.ID_ANY, label)
- zoommenu.AppendItem(mid)
- self.Bind(wx.EVT_MENU, handler, mid)
-
+ if label:
+ mid = wx.MenuItem(zoommenu, wx.ID_ANY, label)
+ zoommenu.AppendItem(mid)
+ self.Bind(wx.EVT_MENU, handler, mid)
+ else:
+ zoommenu.AppendSeparator()
+
# Popup the menu. If an item is selected then its handler will
# be called before PopupMenu returns.
self.PopupMenu(zoommenu)
Modified: grass/trunk/gui/wxpython/mapwin/buffered.py
===================================================================
--- grass/trunk/gui/wxpython/mapwin/buffered.py 2013-10-09 09:25:01 UTC (rev 57965)
+++ grass/trunk/gui/wxpython/mapwin/buffered.py 2013-10-09 18:38:41 UTC (rev 57966)
@@ -1659,37 +1659,49 @@
if tmpreg:
os.environ["GRASS_REGION"] = tmpreg
- def ZoomToSaved(self):
- """!Set display geometry to match extents in
- saved region file
+ def SetRegion(self, zoomOnly=True):
+ """!Set display extents/compulational region from named region
+ file.
+
+ @param zoomOnly zoom to named region only (computational region is not saved)
"""
+ if zoomOnly:
+ label = _('Zoom to saved region extents')
+ else:
+ label = _('Set compulational region from named region')
dlg = SavedRegion(parent = self,
- title = _("Zoom to saved region extents"),
+ title = label,
loadsave = 'load')
if dlg.ShowModal() == wx.ID_CANCEL or not dlg.GetName():
dlg.Destroy()
return
- if not grass.find_file(name = dlg.GetName(), element = 'windows')['name']:
- wx.MessageBox(parent = self,
- message = _("Region <%s> not found. Operation canceled.") % dlg.GetName(),
- caption = _("Error"), style = wx.ICON_ERROR | wx.OK | wx.CENTRE)
+ region = dlg.GetName()
+ if not grass.find_file(name = region, element = 'windows')['name']:
+ GError(parent = self,
+ message = _("Region <%s> not found. Operation canceled.") % region)
dlg.Destroy()
return
- self.Map.GetRegion(regionName = dlg.GetName(),
- update = True)
-
dlg.Destroy()
- self.ZoomHistory(self.Map.region['n'],
- self.Map.region['s'],
- self.Map.region['e'],
- self.Map.region['w'])
+ if zoomOnly:
+ self.Map.GetRegion(regionName = region,
+ update = True)
+
+ self.ZoomHistory(self.Map.region['n'],
+ self.Map.region['s'],
+ self.Map.region['e'],
+ self.Map.region['w'])
+ else:
+ # set computation region from named region file
+ RunCommand('g.region',
+ parent = self,
+ region = region)
self.UpdateMap()
-
+
def SaveRegion(self, display = True):
"""!Save display extents/compulational region to named region
file.
More information about the grass-commit
mailing list