[GRASS-SVN] r70276 - grass/trunk/gui/wxpython/lmgr

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jan 6 09:20:00 PST 2017


Author: martinl
Date: 2017-01-06 09:19:59 -0800 (Fri, 06 Jan 2017)
New Revision: 70276

Modified:
   grass/trunk/gui/wxpython/lmgr/layertree.py
Log:
wxGUI/lmgr: Set computational region from selected vector(s) align to raster

Modified: grass/trunk/gui/wxpython/lmgr/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/layertree.py	2017-01-06 17:04:53 UTC (rev 70275)
+++ grass/trunk/gui/wxpython/lmgr/layertree.py	2017-01-06 17:19:59 UTC (rev 70276)
@@ -535,7 +535,28 @@
                     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:
+                    item = wx.MenuItem(
+                        self.popupMenu,
+                        id=self.popupID['region'],
+                        text=_("Set computational region from selected vector(s) align to raster"))
+                    item.SetBitmap(MetaIcon(img='region').GetBitmap(self.bmpsize))
+                    self.popupMenu.AppendItem(item)
+                    self.Bind(
+                        wx.EVT_MENU,
+                        self.OnSetCompRegFromMap,
+                        id=self.popupID['region'])
+
         # vector layers (specific items)
         if ltype and ltype == "vector" and numSelected == 1:
             self.popupMenu.AppendSeparator()
@@ -920,7 +941,9 @@
                     rast.append(rname)
 
         kwargs = {}
-        if rast:
+        if vect and len(rast) == 1:
+            kwargs['align'] = ','.join(rast)
+        elif rast:
             kwargs['raster'] = ','.join(rast)
         if vect:
             kwargs['vector'] = ','.join(vect)



More information about the grass-commit mailing list