Browse Source

wxNviz: thematic mapping - use GRASSRGB if available without opening thematic dialog

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@49082 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 13 years ago
parent
commit
410b0d97d1
2 changed files with 33 additions and 2 deletions
  1. 4 2
      gui/wxpython/gui_modules/nviz_mapdisp.py
  2. 29 0
      gui/wxpython/gui_modules/nviz_tools.py

+ 4 - 2
gui/wxpython/gui_modules/nviz_mapdisp.py

@@ -1957,7 +1957,8 @@ class GLWindow(MapWindow, glcanvas.GLCanvas):
             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 @@ class GLWindow(MapWindow, glcanvas.GLCanvas):
             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'],

+ 29 - 0
gui/wxpython/gui_modules/nviz_tools.py

@@ -48,6 +48,8 @@ import gselect
 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 @@ class NvizToolWindow(FN.FlatNotebook):
             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 @@ class NvizToolWindow(FN.FlatNotebook):
         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():