Browse Source

wxGUI/lmgr: Set computational region from selected vector(s) align to raster

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@70276 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 8 years ago
parent
commit
2ae5cb3e23
1 changed files with 24 additions and 1 deletions
  1. 24 1
      gui/wxpython/lmgr/layertree.py

+ 24 - 1
gui/wxpython/lmgr/layertree.py

@@ -535,6 +535,27 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
                     wx.EVT_MENU,
                     wx.EVT_MENU,
                     self.OnSetCompRegFromMap,
                     self.OnSetCompRegFromMap,
                     id=self.popupID['region'])
                     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)
         # vector layers (specific items)
         if ltype and ltype == "vector" and numSelected == 1:
         if ltype and ltype == "vector" and numSelected == 1:
@@ -920,7 +941,9 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
                     rast.append(rname)
                     rast.append(rname)
 
 
         kwargs = {}
         kwargs = {}
-        if rast:
+        if vect and len(rast) == 1:
+            kwargs['align'] = ','.join(rast)
+        elif rast:
             kwargs['raster'] = ','.join(rast)
             kwargs['raster'] = ','.join(rast)
         if vect:
         if vect:
             kwargs['vector'] = ','.join(vect)
             kwargs['vector'] = ','.join(vect)