[GRASS-SVN] r38321 -
grass/branches/develbranch_6/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jul 8 15:25:27 EDT 2009
Author: martinl
Date: 2009-07-08 15:25:26 -0400 (Wed, 08 Jul 2009)
New Revision: 38321
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
Log:
wxGUI: save named region - clean up
(merge from trunk, r38320)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py 2009-07-08 19:22:00 UTC (rev 38320)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py 2009-07-08 19:25:26 UTC (rev 38321)
@@ -211,66 +211,61 @@
return (None, dlg.addbox.IsChecked())
class SavedRegion(wx.Dialog):
- def __init__(self, parent, id, title="", pos=wx.DefaultPosition, size=wx.DefaultSize,
- style=wx.DEFAULT_DIALOG_STYLE,
- loadsave='load'):
+ def __init__(self, parent, id = wx.ID_ANY, title="", loadsave='load',
+ **kwargs):
+ """!Loading and saving of display extents to saved region file
+
+ @param loadsave load or save region?
"""
- Loading and saving of display extents to saved region file
- """
- wx.Dialog.__init__(self, parent, id, title, pos, size, style)
+ wx.Dialog.__init__(self, parent, id, title, **kwargs)
self.loadsave = loadsave
self.wind = ''
-
+
sizer = wx.BoxSizer(wx.VERTICAL)
-
+
box = wx.BoxSizer(wx.HORIZONTAL)
+ label = wx.StaticText(parent=self, id=wx.ID_ANY)
+ box.Add(item=label, proportion=0, flag=wx.ALIGN_CENTRE | wx.ALL, border=5)
if loadsave == 'load':
- label = wx.StaticText(parent=self, id=wx.ID_ANY, label=_("Load region:"))
- 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)
-
+ label.SetLabel(_("Load region:"))
+ selection = gselect.Select(parent=self, id=wx.ID_ANY, size=globalvar.DIALOG_GSELECT_SIZE,
+ type='windows')
elif loadsave == 'save':
- label = wx.StaticText(parent=self, id=wx.ID_ANY, label=_("Save region:"))
- 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)
-
+ label.SetLabel(_("Save region:"))
+ selection = gselect.Select(parent=self, id=wx.ID_ANY, size=globalvar.DIALOG_GSELECT_SIZE,
+ type='windows', mapsets = [grass.gisenv()['MAPSET']])
+
+ box.Add(item=selection, proportion=0, flag=wx.ALIGN_CENTRE | wx.ALL, border=5)
+ selection.SetFocus()
+ selection.Bind(wx.EVT_TEXT, self.OnRegion)
+
sizer.Add(item=box, proportion=0, flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL,
border=5)
-
+
line = wx.StaticLine(parent=self, id=wx.ID_ANY, size=(20, -1), style=wx.LI_HORIZONTAL)
sizer.Add(item=line, proportion=0,
flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, border=5)
-
+
btnsizer = wx.StdDialogButtonSizer()
-
- btn = wx.Button(self, wx.ID_OK)
+
+ btn = wx.Button(parent = self, id = wx.ID_OK)
btn.SetDefault()
btnsizer.AddButton(btn)
-
- btn = wx.Button(self, wx.ID_CANCEL)
+
+ btn = wx.Button(parent = self, id = wx.ID_CANCEL)
btnsizer.AddButton(btn)
btnsizer.Realize()
-
+
sizer.Add(item=btnsizer, proportion=0, flag=wx.ALIGN_RIGHT | wx.ALL, border=5)
-
+
self.SetSizer(sizer)
sizer.Fit(self)
-
- def OnSelection(self, event):
+ self.Layout()
+
+ def OnRegion(self, event):
self.wind = event.GetString()
-
- def OnText(self, event):
- self.wind = event.GetString()
-
+
class DecorationDialog(wx.Dialog):
"""
Controls setting options and displaying/hiding map overlay decorations
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py 2009-07-08 19:22:00 UTC (rev 38320)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py 2009-07-08 19:25:26 UTC (rev 38321)
@@ -2620,19 +2620,22 @@
"""!Set display geometry to match extents in
saved region file
"""
- dlg = gdialogs.SavedRegion(parent = self, id = wx.ID_ANY,
+ dlg = gdialogs.SavedRegion(parent = self,
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:
+ if dlg.ShowModal() == wx.ID_CANCEL or not dlg.wind:
dlg.Destroy()
return
- wind = dlg.wind
+ if not grass.find_file(name = dlg.wind, element = 'windows')['name']:
+ wx.MessageBox(parent = self,
+ message = _("Region <%s> not found. Operation canceled.") % dlg.wind,
+ caption = _("Error"), style = wx.ICON_ERROR | wx.OK | wx.CENTRE)
+ dlg.Destroy()
+ return
- self.Map.GetRegion(regionName = wind,
+ self.Map.GetRegion(regionName = dlg.wind,
update = True)
dlg.Destroy()
@@ -2649,50 +2652,34 @@
Save display extents to named region file.
"""
- dlg = gdialogs.SavedRegion(self, wx.ID_ANY, "Save display extents to region file",
- pos=wx.DefaultPosition, size=wx.DefaultSize,
- style=wx.DEFAULT_DIALOG_STYLE,
+ dlg = gdialogs.SavedRegion(parent = self,
+ title = _("Save display extents to region file"),
loadsave='save')
- if dlg.ShowModal() == wx.ID_CANCEL:
+
+ if dlg.ShowModal() == wx.ID_CANCEL or not dlg.wind:
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)
-
- 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)
+ if grass.find_file(name = dlg.wind, element = 'windows')['name']:
+ overwrite = wx.MessageBox(parent = self,
+ message = _("Region file <%s> already exists. "
+ "Do you want to overwrite it?") % (dlg.wind),
+ caption = _("Warning"), style = wx.YES_NO | wx.CENTRE)
if (overwrite == wx.YES):
- self.SaveRegion(wind)
+ self.SaveRegion(dlg.wind)
else:
- pass
-
+ self.SaveRegion(dlg.wind)
+
dlg.Destroy()
def SaveRegion(self, wind):
- """!
- Save region settings
+ """!Save region settings
+
+ @param wind region name
"""
- new = self.Map.AlignResolution()
+ new = self.Map.GetCurrentRegion()
- cmdRegion = ["g.region",
- "-u",
- "n=%f" % new['n'],
- "s=%f" % new['s'],
- "e=%f" % new['e'],
- "w=%f" % new['w'],
- "rows=%d" % new['rows'],
- "cols=%d" % new['cols'],
- "save=%s" % wind,
- "--o"]
-
tmpreg = os.getenv("GRASS_REGION")
if tmpreg:
del os.environ["GRASS_REGION"]
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py 2009-07-08 19:22:00 UTC (rev 38320)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py 2009-07-08 19:25:26 UTC (rev 38321)
@@ -665,10 +665,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 ret.splitlines():
key, val = reg.split("=", 1)
More information about the grass-commit
mailing list