[GRASS-SVN] r49759 - grass/trunk/gui/wxpython/modules

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Dec 14 18:32:21 EST 2011


Author: martinl
Date: 2011-12-14 15:32:21 -0800 (Wed, 14 Dec 2011)
New Revision: 49759

Modified:
   grass/trunk/gui/wxpython/modules/colorrules.py
Log:
wxGUI/colorrules: - redraw preview on apply
                 - error message when color column is not defined
                 - various minor fixes
		 (merge r49756 from devbr6)


Modified: grass/trunk/gui/wxpython/modules/colorrules.py
===================================================================
--- grass/trunk/gui/wxpython/modules/colorrules.py	2011-12-14 23:31:17 UTC (rev 49758)
+++ grass/trunk/gui/wxpython/modules/colorrules.py	2011-12-14 23:32:21 UTC (rev 49759)
@@ -36,7 +36,7 @@
 
 from core             import globalvar
 from core             import utils
-from core.gcmd        import GMessage, RunCommand
+from core.gcmd        import GMessage, RunCommand, GError
 from gui_core.gselect import Select, LayerSelect, ColumnSelect, VectorDBInfo
 from core.render      import Map
 from gui_core.forms   import GUI
@@ -529,8 +529,9 @@
         ret = self.CreateColorTable()
         if not ret:
             GMessage(parent = self, message = _("No valid color rules given."))
-        
-        if ret:
+        else:
+            # re-render preview and current map window
+            self.OnPreview(None)
             display = self.parent.GetLayerTree().GetMapDisplay()
             if display and display.IsAutoRendered():
                 display.GetWindow().UpdateMap(render = True)
@@ -685,12 +686,12 @@
             output.write(rulestxt)
         finally:
             output.close()
-                
-        cmd = ['%s.colors' % self.mapType[0],#r.colors/v.colors
+        
+        cmd = ['%s.colors' % self.mapType[0], #r.colors/v.colors
                 'map=%s' % self.inmap,
                 'rules=%s' % gtemp]
-        if self.mapType == 'vector' and self.properties['sourceColumn']\
-                                    and self.properties['sourceColumn'] != 'cat':
+        if self.mapType == 'vector' and self.properties['sourceColumn'] \
+                and self.properties['sourceColumn'] != 'cat':
             cmd.append('column=%s' % self.properties['sourceColumn'])
         cmd = utils.CmdToTuple(cmd)
         ret = RunCommand(cmd[0], **cmd[1])               
@@ -1214,9 +1215,9 @@
     
     def AddTemporaryColumn(self, type):
         """!Add temporary column to not overwrite the original values,
-            need to be deleted when closing dialog and unloading map
-            
-            @param type type of column (e.g. vachar(11))"""
+        need to be deleted when closing dialog and unloading map
+        
+        @param type type of column (e.g. vachar(11))"""
         if not self.CheckMapset():
             return
         # because more than one dialog with the same map can be opened we must test column name and
@@ -1573,6 +1574,7 @@
                 ret = self.UpdateColorColumn(tmp)
             else:
                 ret = True
+        
         return ret
         
     def UpdateColorColumn(self, tmp):
@@ -1592,8 +1594,9 @@
             else:
                 rgb_col = self.properties['storeColumn']
                 if not self.properties['storeColumn']:
-                    GMessage(self.parent, message = _("Please select column to save values to."))
-                    
+                    GMessage(parent = self.parent,
+                             message = _("Please select column to save values to."))
+            
             rulestxt += "UPDATE %s SET %s='%s' WHERE %s ;\n" % (self.properties['table'],
                                                                 rgb_col,
                                                                 rule[self.attributeType],
@@ -1627,6 +1630,11 @@
         if self.colorTable:
             self.UseAttrColumn(False)
         else:
+            if not self.properties['storeColumn']:
+                GError(_("No color column defined. Operation canceled."),
+                       parent = self)
+                return
+            
             self.UseAttrColumn(True)
         
         return ColorTable.OnApply(self, event)



More information about the grass-commit mailing list