[GRASS-SVN] r61306 - grass/trunk/gui/wxpython/web_services
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jul 21 20:46:34 PDT 2014
Author: annakrat
Date: 2014-07-21 20:46:34 -0700 (Mon, 21 Jul 2014)
New Revision: 61306
Modified:
grass/trunk/gui/wxpython/web_services/dialogs.py
Log:
wxGUI/wms: implement saving layer based on display geometry, small dialog changes
Modified: grass/trunk/gui/wxpython/web_services/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/web_services/dialogs.py 2014-07-22 03:03:17 UTC (rev 61305)
+++ grass/trunk/gui/wxpython/web_services/dialogs.py 2014-07-22 03:46:34 UTC (rev 61306)
@@ -796,13 +796,21 @@
size = globalvar.DIALOG_GSELECT_SIZE)
self.regionStBoxLabel = wx.StaticBox(parent = self, id = wx.ID_ANY,
- label = _("Region"))
+ label = " %s " % _("Export region"))
- self.region_types_order = ['comp', 'named']
+ self.region_types_order = ['display', 'comp', 'named']
self.region_types = {}
- #self.region_types['map_display'] = wx.RadioButton(parent = self, id = wx.ID_ANY, label = 'Map display', style = wx.RB_GROUP )
- self.region_types['comp'] = wx.RadioButton(parent = self, id = wx.ID_ANY, label = 'Computational region')
- self.region_types['named'] = wx.RadioButton(parent = self, id = wx.ID_ANY, label = 'Named region')
+ self.region_types['display'] = wx.RadioButton(parent=self, label=_("Map display"),
+ style=wx.RB_GROUP)
+ self.region_types['comp'] = wx.RadioButton(parent=self, label=_("Computational region"))
+ self.region_types['named'] = wx.RadioButton(parent=self, label=_("Named region"))
+ self.region_types['display'].SetToolTipString(_("Extent and resolution"
+ " are based on Map Display geometry."))
+ self.region_types['comp'].SetToolTipString(_("Extent and resolution"
+ " are based on computational region."))
+ self.region_types['named'].SetToolTipString(_("Extent and resolution"
+ " are based on named region."))
+ self.region_types['display'].SetValue(True) # set default as map display
self.overwrite = wx.CheckBox(parent = self, id = wx.ID_ANY,
label = _("Overwrite existing raster map"))
@@ -817,10 +825,10 @@
# buttons
self.btn_close = wx.Button(parent = self, id = wx.ID_CLOSE)
self.btn_close.SetToolTipString(_("Close dialog"))
-
- self.btn_ok = wx.Button(parent = self, id = wx.ID_ANY, label = _("&Save layer"))
- self.btn_ok.SetToolTipString(_("Save web service layer as raster map"))
+ self.btn_ok = wx.Button(parent=self, id=wx.ID_OK, label=_("&Save layer"))
+ self.btn_ok.SetToolTipString(_("Save web service layer as raster map"))
+
# statusbar
self.statusbar = wx.StatusBar(parent = self, id = wx.ID_ANY)
@@ -828,7 +836,7 @@
def _layout(self):
- border = wx.BoxSizer(wx.VERTICAL)
+ self._border = wx.BoxSizer(wx.VERTICAL)
dialogSizer = wx.BoxSizer(wx.VERTICAL)
regionSizer = wx.BoxSizer(wx.HORIZONTAL)
@@ -836,13 +844,11 @@
dialogSizer.Add(item = self._addSelectSizer(title = self.labels['output'],
sel = self.params['output']))
- dialogSizer.Add(item = self.overwrite)
-
regionSizer = wx.StaticBoxSizer(self.regionStBoxLabel, wx.VERTICAL)
regionTypeSizer = wx.BoxSizer(wx.HORIZONTAL)
for r_type in self.region_types_order:
- regionTypeSizer.Add(item = self.region_types[r_type])
+ regionTypeSizer.Add(item=self.region_types[r_type], flag=wx.RIGHT, border=8)
regionSizer.Add(item = regionTypeSizer)
@@ -853,6 +859,8 @@
dialogSizer.Add(item = regionSizer, flag = wx.EXPAND)
+ dialogSizer.Add(item=self.overwrite, flag=wx.TOP, border=10)
+
# buttons
self.btnsizer = wx.BoxSizer(orient = wx.HORIZONTAL)
@@ -867,12 +875,12 @@
dialogSizer.Add(item = self.btnsizer, proportion = 0,
flag = wx.ALIGN_CENTER)
- border.Add(item = dialogSizer, proportion = 0,
- flag = wx.ALL, border = 5)
+ self._border.Add(item=dialogSizer, proportion=0,
+ flag=wx.ALL, border=5)
- border.Add(item = self.statusbar, proportion = 0)
+ self._border.Add(item=self.statusbar, proportion=0)
- self.SetSizer(border)
+ self.SetSizer(self._border)
self.Layout()
self.Fit()
@@ -912,14 +920,13 @@
event.Skip()
def OnRegionType(self, event):
-
selected = event.GetEventObject()
if selected == self.region_types['named']:
self.named_reg_panel.Show()
else:
self.named_reg_panel.Hide()
- self.Layout()
+ self._border.Layout()
self.Fit()
def OnSave(self, event):
@@ -960,13 +967,12 @@
if len(reg_spl) > 1:
reg_mapset = reg_spl[1]
- if self.region_types['comp'].GetValue() == 1:
- pass
- elif grass.find_file(reg_spl[0], 'region', reg_mapset)['fullname']:
- msg = _('Region <%s> does not exists.' % self.params['region'].GetValue())
- GWarning(parent = self,
- message = msg)
- return
+ if self.region_types['named'].GetValue():
+ if not grass.find_file(reg_spl[0], 'region', reg_mapset)['fullname']:
+ msg = _('Region <%s> does not exist.' % self.params['region'].GetValue())
+ GWarning(parent=self,
+ message=msg)
+ return
# create r.in.wms command
cmd = ('r.in.wms', deepcopy(self.cmd[1]))
@@ -979,13 +985,17 @@
if self.overwrite.IsChecked():
cmd[1]['overwrite'] = True
- if self.region_types['named'].GetValue() == 1:
+ env = os.environ.copy()
+ if self.region_types['named'].GetValue():
cmd[1]['region'] = region
+ elif self.region_types['display'].GetValue():
+ region = self._giface.GetMapWindow().GetMap().SetRegion()
+ env['GRASS_REGION'] = region
cmdList = CmdTupleToList(cmd)
self.currentPid = self.thread.GetId()
- self.thread.RunCmd(cmdList, stderr = self.cmdStdErr)
+ self.thread.RunCmd(cmdList, env=env, stderr=self.cmdStdErr)
self.statusbar.SetStatusText(_("Downloading data..."))
More information about the grass-commit
mailing list