瀏覽代碼

wxGUI/dbm: fix extract selected features
(merge https://trac.osgeo.org/grass/changeset/39588 from devbr6)


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@39589 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 15 年之前
父節點
當前提交
d3d6242b45
共有 2 個文件被更改,包括 22 次插入11 次删除
  1. 16 7
      gui/wxpython/gui_modules/dbm.py
  2. 6 4
      gui/wxpython/gui_modules/gdialogs.py

+ 16 - 7
gui/wxpython/gui_modules/dbm.py

@@ -1931,7 +1931,7 @@ class AttributeManager(wx.Frame):
         event.Skip()
 
     def OnExtractSelected(self, event):
-        """
+        """!
         Extract vector objects selected in attribute browse window
         to new vector map
         """
@@ -1945,12 +1945,21 @@ class AttributeManager(wx.Frame):
             return
         else:
             # dialog to get file name
-            gdialogs.CreateNewVector(parent = self, title = _('Extract selected features'),
-                                     log = self.cmdLog,
-                                     cmd = (('v.extract',
-                                             { 'input' : self.vectorName,
-                                               'list' : utils.ListOfCatsToRange(cats) },
-                                             'output')))
+            name, add = gdialogs.CreateNewVector(parent = self, title = _('Extract selected features'),
+                                                 log = self.cmdLog,
+                                                 cmd = (('v.extract',
+                                                         { 'input' : self.vectorName,
+                                                           'list' : utils.ListOfCatsToRange(cats) },
+                                                         'output')),
+                                                 disableTable = True)
+            if name and add:
+                # add layer to map layer tree
+                self.parent.curr_page.maptree.AddLayer(ltype='vector',
+                                                       lname=name,
+                                                       lchecked=True,
+                                                       lopacity=1.0,
+                                                       lcmd=['d.vect', 'map=%s' % name])
+            
     def OnDeleteSelected(self, event):
         """
         Delete vector objects selected in attribute browse window

+ 6 - 4
gui/wxpython/gui_modules/gdialogs.py

@@ -183,7 +183,7 @@ class MapsetDialog(ElementDialog):
     
 class NewVectorDialog(ElementDialog):
     """!Dialog for creating new vector map"""
-    def __init__(self, parent, id, title, disableAdd=False, 
+    def __init__(self, parent, id, title, disableAdd=False, disableTable=False,
                  style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
         
         ElementDialog.__init__(self, parent, title, label = _("Name for new vector map:"))
@@ -194,6 +194,8 @@ class NewVectorDialog(ElementDialog):
         self.table = wx.CheckBox(parent = self.panel, id = wx.ID_ANY,
                                  label = _("Create attribute table"))
         self.table.SetValue(True)
+        if disableTable:
+            self.table.Enable(False)
         
         self.addbox = wx.CheckBox(parent = self.panel,
                                   label = _('Add created map into layer tree'), style = wx.NO_BORDER)
@@ -233,7 +235,7 @@ class NewVectorDialog(ElementDialog):
         return self.GetElement().split('@', 1)[0]
             
 def CreateNewVector(parent, cmd, title=_('Create new vector map'),
-                    exceptMap=None, log=None, disableAdd=False):
+                    exceptMap=None, log=None, disableAdd=False, disableTable=False):
     """!Create new vector map layer
 
     @cmd cmd (prog, **kwargs)
@@ -242,7 +244,7 @@ def CreateNewVector(parent, cmd, title=_('Create new vector map'),
     @return None of failure
     """
     dlg = NewVectorDialog(parent, wx.ID_ANY, title,
-                          disableAdd)
+                          disableAdd, disableTable)
     if dlg.ShowModal() == wx.ID_OK:
         outmap = dlg.GetName()
         if outmap == exceptMap:
@@ -290,7 +292,7 @@ def CreateNewVector(parent, cmd, title=_('Create new vector map'),
         #
         # create attribute table
         #
-        if dlg.table.IsChecked():
+        if dlg.table.IsEnabled() and dlg.table.IsChecked():
             key = UserSettings.Get(group='atm', key='keycolumn', subkey='value')
             sql = 'CREATE TABLE %s (%s INTEGER)' % (outmap, key)