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

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Nov 3 15:35:35 EDT 2011


Author: annakrat
Date: 2011-11-03 12:35:35 -0700 (Thu, 03 Nov 2011)
New Revision: 49082

Modified:
   grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
   grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
Log:
wxNviz: thematic mapping - use GRASSRGB if available without opening thematic dialog

Modified: grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py	2011-11-03 18:12:15 UTC (rev 49081)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py	2011-11-03 19:35:35 UTC (rev 49082)
@@ -1957,7 +1957,8 @@
             if data['thematic']['usecolor'] or data['thematic']['usewidth']:
                 if data['thematic']['usecolor']:
                     color = data['thematic']['rgbcolumn']
-                    colorTable = True
+                    if self._display.CheckColorTable(id = id, type = 'lines'):
+                        colorTable = True
                 if data['thematic']['usewidth']:
                     width = data['thematic']['sizecolumn']
                 self._display.SetLinesStyleThematic(id = id, layer = data['thematic']['layer'],
@@ -2020,7 +2021,8 @@
             if data['thematic']['usecolor'] or data['thematic']['usesize']:
                 if data['thematic']['usecolor']:
                     color = data['thematic']['rgbcolumn']
-                    colorTable = True
+                    if self._display.CheckColorTable(id = id, type = 'points'):
+                        colorTable = True
                 if data['thematic']['usesize']:
                     size = data['thematic']['sizecolumn']
                 self._display.SetPointsStyleThematic(id = id, layer = data['thematic']['layer'],

Modified: grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_tools.py	2011-11-03 18:12:15 UTC (rev 49081)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_tools.py	2011-11-03 19:35:35 UTC (rev 49082)
@@ -48,6 +48,8 @@
 import gcmd
 import colorrules
 from preferences import globalSettings as UserSettings
+from gselect import VectorDBInfo
+
 try:
     from nviz_mapdisp import wxUpdateView, wxUpdateLight, wxUpdateProperties,\
                             wxUpdateCPlane
@@ -3292,6 +3294,21 @@
             self.FindWindowById(button).Enable(checked)
             
             data = self.GetLayerData('vector')
+            
+            # decide if use GRASSRGB column
+            if attrType == 'color':
+                name = self.FindWindowById(self.win['vector']['map']).GetValue()
+                if not data['vector'][vtype]['thematic']['rgbcolumn']:
+                    try:
+                        id =  data['vector'][vtype]['object']['id']
+                    
+                        # if GRASSRGB exists and color table doesn't, use GRGB
+                        if self.HasGRASSRGB(name)  and \
+                            not self._display.CheckColorTable(id = id, type = vtype):
+                            data['vector'][vtype]['thematic']['rgbcolumn'] = 'GRASSRGB'
+                    except KeyError:
+                        pass
+                        
             data['vector'][vtype]['thematic']['use' + attrType] = checked
             data['vector'][vtype]['thematic']['update'] = None
         
@@ -3302,6 +3319,18 @@
         if self.mapDisplay.IsAutoRendered():
             self.mapWindow.Refresh(False)
             
+    def HasGRASSRGB(self, name):
+        """!Check if GRASSRGB column exist."""
+        column = False
+        
+        dbInfo = VectorDBInfo(name)
+        if len(dbInfo.layers):
+            table = dbInfo.layers[1]['table']
+            if 'GRASSRGB' in dbInfo.GetTableDesc(table):
+                column = True
+                
+        return column
+        
     def OnSetThematic(self, event):
         """!Set options for thematic points"""
         if event.GetId() in self.win['vector']['points']['thematic'].values():



More information about the grass-commit mailing list