[GRASS-SVN] r42393 - grass/branches/develbranch_6/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sun May 30 07:36:45 EDT 2010


Author: martinl
Date: 2010-05-30 07:36:45 -0400 (Sun, 30 May 2010)
New Revision: 42393

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
Log:
wxGUI/d.vect: avoid repetitive running of the same commands


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py	2010-05-30 11:31:53 UTC (rev 42392)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py	2010-05-30 11:36:45 UTC (rev 42393)
@@ -652,7 +652,7 @@
         if vector:
             self.InsertColumns(vector, layer)
     
-    def InsertColumns(self, vector, layer, excludeKey = False, type = None):
+    def InsertColumns(self, vector, layer, excludeKey = False, type = None, dbInfo = None):
         """!Insert columns for a vector attribute table into the columns combobox
 
         @param vector vector name
@@ -660,7 +660,8 @@
         @param excludeKey exclude key column from the list?
         @param type only columns of given type (given as list)
         """
-        dbInfo = VectorDBInfo(vector)
+        if not dbInfo:
+            dbInfo = VectorDBInfo(vector)
         
         try:
             table = dbInfo.GetTable(int(layer))

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2010-05-30 11:31:53 UTC (rev 42392)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2010-05-30 11:36:45 UTC (rev 42393)
@@ -207,6 +207,11 @@
             map = pMap.get('value', '')
         else:
             map = None
+
+        # avoid running db.describe several times
+        cparams = dict()
+        cparams[map] = { 'dbInfo' : None,
+                         'layers' : None, }
         
         # update reference widgets
         for uid in p['wxId-bind']:
@@ -214,8 +219,10 @@
             name = win.GetName()
             
             if name == 'LayerSelect':
-                self.data[win.InsertLayers] = { 'vector' : map }
-                
+                if not cparams[map]['layers']:
+                    win.InsertLayers(vector = map)
+                    cparams[map]['layers'] = win.GetItems()
+            
             elif name == 'TableSelect':
                 pDriver = self.task.get_param('dbdriver', element='prompt', raiseError=False)
                 driver = db = None
@@ -239,7 +246,10 @@
                     layer = 1
                 
                 if map:
-                    self.data[win.InsertColumns] = { 'vector' : map, 'layer' : layer }
+                    if not cparams[map]['dbInfo']:
+                        cparams[map]['dbInfo'] = gselect.VectorDBInfo(map)
+                    self.data[win.InsertColumns] = { 'vector' : map, 'layer' : layer,
+                                                     'dbInfo' : cparams[map]['dbInfo'] }
                 else: # table
                     driver = db = None
                     pDriver = self.task.get_param('dbdriver', element='prompt', raiseError=False)

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py	2010-05-30 11:31:53 UTC (rev 42392)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py	2010-05-30 11:36:45 UTC (rev 42393)
@@ -282,20 +282,16 @@
 
 def GetVectorNumberOfLayers(vector):
     """!Get list of vector layers"""
-    cmdlist = ['v.category',
-               'input=%s' % vector,
-               'option=report']
+    layers = []
     if not vector:
         return layers
     
-    layers = []
-    
     ret = gcmd.RunCommand('v.category',
                           flags = 'g',
                           read = True,
                           input = vector,
                           option = 'report')
-
+    
     if not ret:
         return layers
     



More information about the grass-commit mailing list