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

svn_grass at osgeo.org svn_grass at osgeo.org
Sun May 30 07:31:54 EDT 2010


Author: martinl
Date: 2010-05-30 07:31:53 -0400 (Sun, 30 May 2010)
New Revision: 42392

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


Modified: grass/trunk/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gselect.py	2010-05-30 11:19:16 UTC (rev 42391)
+++ grass/trunk/gui/wxpython/gui_modules/gselect.py	2010-05-30 11:31:53 UTC (rev 42392)
@@ -693,7 +693,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
@@ -701,7 +701,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/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-05-30 11:19:16 UTC (rev 42391)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-05-30 11:31:53 UTC (rev 42392)
@@ -206,6 +206,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']:
@@ -261,7 +266,9 @@
                         table = pTable.get('value', '')
                 
             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 == 'LayerNameSelect':
                 # determine format
@@ -284,7 +291,10 @@
                 
             elif name == 'ColumnSelect':
                 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
                     if driver and db:
                         self.data[win.InsertTableColumns] = { 'table' : pTable.get('value'),



More information about the grass-commit mailing list