[GRASS-SVN] r38058 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jun 24 10:33:34 EDT 2009


Author: martinl
Date: 2009-06-24 10:33:33 -0400 (Wed, 24 Jun 2009)
New Revision: 38058

Modified:
   grass/trunk/gui/wxpython/gui_modules/gselect.py
Log:
fix filtering GIS elements
    (merge from devbr6, r38057)


Modified: grass/trunk/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gselect.py	2009-06-24 14:23:15 UTC (rev 38057)
+++ grass/trunk/gui/wxpython/gui_modules/gselect.py	2009-06-24 14:33:33 UTC (rev 38058)
@@ -84,31 +84,18 @@
         self.ftype = ftype
         
         # remove vector maps which do not contain given feature type
-        self.tcp.SetFilter(self.__filterElements)
+        self.tcp.SetFilter(self.__isElement)
         
-    def __filterElements(self, parentItem):
-        """!Filter vector maps in given mapset"""
-        root = self.tcp.seltree.GetRootItem()
-        item, cookie = self.tcp.seltree.GetFirstChild(parentItem)
-        while item:
-            if self.tcp.seltree.GetItemParent(item) != root:
-                # skip Mapset items
-                vectorName = self.tcp.seltree.GetItemText(item)
-                try:
-                    if int(grass.vector_info_topo(vectorName)[self.ftype]) < 1:
-                        self.tcp.seltree.Delete(item)
-                except KeyError:
-                    self.tcp.seltree.Delete(item)
-                
-                if not item:
-                    item, cookie = self.tcp.seltree.GetNextChild(parentItem, cookie)
-                    continue
-                
-            if self.tcp.seltree.ItemHasChildren(item):
-                item = self.__filterElements(item)
-            
-            item, cookie = self.tcp.seltree.GetNextChild(parentItem, cookie)
+    def __isElement(self, vectorName):
+        """!Check if element should be filtered out"""
+        try:
+            if int(grass.vector_info_topo(vectorName)[self.ftype]) < 1:
+                return False
+        except KeyError:
+            return False
         
+        return True
+
 class TreeCtrlComboPopup(wx.combo.ComboPopup):
     """!Create a tree ComboBox for selecting maps and other GIS elements
     in accessible mapsets within the current location
@@ -184,8 +171,6 @@
         # update list
         self.seltree.DeleteAllItems()
         self._getElementList(self.type, self.mapsets, self.exclude)
-        if self.filterElements:
-            self.filterElements(self.seltree.GetRootItem())
         
         if len(self.value) > 0:
             root = self.seltree.GetRootItem()
@@ -303,7 +288,12 @@
                         fullqElem = elem + '@' + dir
                         if len(exclude) > 0 and fullqElem in exclude:
                             continue
-                        self.AddItem(fullqElem, parent=dir_node)
+
+                        if self.filterElements:
+                            if self.filterElements(fullqElem):
+                                self.AddItem(fullqElem, parent=dir_node)
+                        else:
+                            self.AddItem(fullqElem, parent=dir_node)
             except:
                 continue
 



More information about the grass-commit mailing list