Przeglądaj źródła

wxGUI: fix colorrules preview including restoring original color table (no backport needed)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@66929 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 9 lat temu
rodzic
commit
79af5c224b
1 zmienionych plików z 20 dodań i 14 usunięć
  1. 20 14
      gui/wxpython/modules/colorrules.py

+ 20 - 14
gui/wxpython/modules/colorrules.py

@@ -740,6 +740,7 @@ class ColorTable(wx.Frame):
         if self.mapType == 'vector' and self.properties['sourceColumn'] \
                 and self.properties['sourceColumn'] != 'cat':
             cmd.append('column=%s' % self.properties['sourceColumn'])
+        
         cmd = cmdlist_to_tuple(cmd)
         ret = RunCommand(cmd[0], **cmd[1])               
         if ret != 0:
@@ -799,7 +800,8 @@ class RasterColorTable(ColorTable):
                             title = _('Create new color table for raster map'), **kwargs)
         
         self._initLayer()
-        
+        self.Map.GetRenderMgr().renderDone.connect(self._restoreColorTable)
+            
         # self.SetMinSize(self.GetSize()) 
         self.SetMinSize((650, 700))
                 
@@ -906,29 +908,33 @@ class RasterColorTable(ColorTable):
             mapset = grass.find_file(self.inmap, element = 'cell')['mapset']
             if not mapset:
                 return
-        old_colrtable = None
+        self._tmp = tmp
+        self._old_colrtable = None
         if mapset == grass.gisenv()['MAPSET']:
-            old_colrtable = grass.find_file(name = name, element = 'colr')['file']
+            self._old_colrtable = grass.find_file(name = name, element = 'colr')['file']
         else:
-            old_colrtable = grass.find_file(name = name, element = 'colr2/' + mapset)['file']
+            self._old_colrtable = grass.find_file(name = name, element = 'colr2/' + mapset)['file']
         
-        if old_colrtable:
-            colrtemp = utils.GetTempfile()
-            shutil.copyfile(old_colrtable, colrtemp)
+        if self._old_colrtable:
+            self._colrtemp = utils.GetTempfile()
+            shutil.copyfile(self._old_colrtable, self._colrtemp)
             
-        ColorTable.DoPreview(self, ltype, cmdlist)  
-        
+        ColorTable.DoPreview(self, ltype, cmdlist)
+
+    def _restoreColorTable(self):
         # restore previous color table
-        if tmp:
-            if old_colrtable:
-                shutil.copyfile(colrtemp, old_colrtable)
-                os.remove(colrtemp)
+        if self._tmp:
+            if self._old_colrtable:
+                shutil.copyfile(self._colrtemp, self._old_colrtable)
+                os.remove(self._colrtemp)
+                del self._colrtemp, self._old_colrtable
             else:
                 RunCommand('r.colors',
                            parent = self,
                            flags = 'r',
                            map = self.inmap)
-        
+            del self._tmp
+            
     def OnHelp(self, event):
         """Show GRASS manual page"""
         cmd = 'r.colors'