[GRASS-SVN] r70365 - grass/trunk/gui/wxpython/lmgr
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Jan 13 12:01:38 PST 2017
Author: martinl
Date: 2017-01-13 12:01:38 -0800 (Fri, 13 Jan 2017)
New Revision: 70365
Modified:
grass/trunk/gui/wxpython/lmgr/layertree.py
Log:
wxGUI: 'Align computation region to selected map' add to the layer menu
partly reverts r70276
see discussion at https://lists.osgeo.org/pipermail/grass-dev/2017-January/083867.html
Modified: grass/trunk/gui/wxpython/lmgr/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/layertree.py 2017-01-13 15:13:30 UTC (rev 70364)
+++ grass/trunk/gui/wxpython/lmgr/layertree.py 2017-01-13 20:01:38 UTC (rev 70365)
@@ -424,7 +424,7 @@
if not hasattr(self, "popupID"):
self.popupID = dict()
for key in (
- 'remove', 'rename', 'opacity', 'nviz', 'zoom', 'region',
+ 'remove', 'rename', 'opacity', 'nviz', 'zoom', 'region', 'align',
'export', 'attr', 'edit', 'save_ws', 'bgmap', 'topo', 'meta',
'null', 'zoom1', 'color', 'colori', 'hist', 'univar', 'prof',
'properties', 'sql', 'copy', 'report', 'export-pg',
@@ -535,27 +535,19 @@
wx.EVT_MENU,
self.OnSetCompRegFromMap,
id=self.popupID['region'])
- elif not same:
- align = True
- nrast = 0
- for layer in selected:
- if self.GetLayerInfo(layer, key='type') == 'raster':
- nrast += 1
- if self.GetLayerInfo(layer, key='type') not in ('raster', 'vector'):
- align = False
- break
-
- if align and nrast == 1:
+
+ # raster align
+ if ltype and ltype == "raster" and len(selected) == 1:
item = wx.MenuItem(
self.popupMenu,
- id=self.popupID['region'],
- text=_("Set computational region from selected vector(s) align to raster"))
+ id=self.popupID['align'],
+ text=_("Align computational region to selected map"))
item.SetBitmap(MetaIcon(img='region').GetBitmap(self.bmpsize))
self.popupMenu.AppendItem(item)
self.Bind(
wx.EVT_MENU,
- self.OnSetCompRegFromMap,
- id=self.popupID['region'])
+ self.OnAlignCompRegToRaster,
+ id=self.popupID['align'])
# vector layers (specific items)
if ltype and ltype == "vector" and numSelected == 1:
@@ -922,7 +914,7 @@
self._giface.RunCmd(cmd)
def OnSetCompRegFromMap(self, event):
- """Set computational region from selected raster/vector map
+ """Set computational region from selected raster/vector map(s)
"""
rast = []
vect = []
@@ -942,16 +934,13 @@
rast.append(rname)
kwargs = {}
- if vect and len(rast) == 1:
- kwargs['align'] = ','.join(rast)
- elif rast:
+ if rast:
kwargs['raster'] = ','.join(rast)
if vect:
kwargs['vector'] = ','.join(vect)
if rast3d:
kwargs['raster_3d'] = ','.join(rast3d)
- # print output to command log area
if kwargs:
if UserSettings.Get(group='general',
key='region', subkey=['resAlign', 'enabled']):
@@ -964,6 +953,29 @@
# re-render map display
self._giface.GetMapWindow().UpdateMap(render=False)
+ def OnAlignCompRegToRaster(self, event):
+ """Align computational region to selected raster map
+ """
+ selected = self.GetSelections()
+ if len(selected) != 1 or \
+ self.GetLayerInfo(selected[0], key='type') != 'raster':
+ return
+
+ kwargs = {'align': self.GetLayerInfo(selected[0],
+ key='maplayer').GetName()
+ }
+
+ if UserSettings.Get(group='general',
+ key='region', subkey=['resAlign', 'enabled']):
+ kwargs['flags'] = 'a'
+ # command must run in main thread otherwise it can be
+ # launched after rendering is done (region extent will
+ # remain untouched)
+ RunCommand('g.region', **kwargs)
+
+ # re-render map display
+ self._giface.GetMapWindow().UpdateMap(render=False)
+
def OnProfile(self, event):
"""Plot profile of given raster map layer"""
mapLayer = self.GetLayerInfo(self.layer_selected, key='maplayer')
More information about the grass-commit
mailing list