[GRASS-SVN] r41969 - grass/branches/develbranch_6/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Apr 22 04:37:07 EDT 2010


Author: martinl
Date: 2010-04-22 04:36:47 -0400 (Thu, 22 Apr 2010)
New Revision: 41969

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
Log:
wxGUI: add layer when import is finished
(merge r41964, r41966 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py	2010-04-22 08:34:47 UTC (rev 41968)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py	2010-04-22 08:36:47 UTC (rev 41969)
@@ -714,7 +714,7 @@
         wx.Dialog.__init__(self, parent=parent, id=wx.ID_ANY, title=title, style=style)
 
         self.parent = parent # GMFrame
-
+        
         #
         # dialog body
         #
@@ -934,8 +934,10 @@
 
         self.parent = parent # GMFrame 
         self.importType = type
-        self.link = link     # Link or import data (only for GDAL/OGR)
+        self.link = link     # Link or import data (only for GDAL/OGR) 
         
+        self.commandId = -1  # id of running command
+       
         wx.Dialog.__init__(self, parent, id, title, style=style)
 
         self.panel = wx.Panel(parent=self, id=wx.ID_ANY)
@@ -1378,35 +1380,42 @@
                 cmd.append('--overwrite')
             
             # run in Layer Manager
-            self.parent.goutput.RunCmd(cmd, switchPage=True)
-
-        if self.add.IsChecked():
-            maptree = self.parent.curr_page.maptree
-            for layer, output in data:
-                if '@' not in output:
-                    name = output + '@' + grass.gisenv()['MAPSET']
-                else:
-                    name = output
-                # add imported layers into layer tree
-                if self.importType == 'gdal':
-                    cmd = ['d.rast',
-                           'map=%s' % name]
-                    if UserSettings.Get(group='cmd', key='rasterOverlay', subkey='enabled'):
-                        cmd.append('-o')
-
-                    maptree.AddLayer(ltype='raster',
-                                     lname=name,
-                                     lcmd=cmd)
-                else:
-                    maptree.AddLayer(ltype='vector',
-                                     lname=name,
-                                     lcmd=['d.vect',
-                                           'map=%s' % name])
+            self.parent.goutput.RunCmd(cmd, switchPage=True,
+                                       onDone = self._addLayers)
         
-        ### wx.CallAfter(self.parent.notebook.SetSelection, 0)
-        
         self.OnCancel()
         
+    def _addLayers(self, returncode):
+        """!Add imported/linked layers into layer tree"""
+        self.commandId += 1
+        
+        if not self.add.IsChecked():
+            return
+        
+        maptree = self.parent.curr_page.maptree
+        
+        layer, output = self.list.GetLayers()[self.commandId]
+        
+        if '@' not in output:
+            name = output + '@' + grass.gisenv()['MAPSET']
+        else:
+            name = output
+        # add imported layers into layer tree
+        if self.importType == 'gdal':
+            cmd = ['d.rast',
+                   'map=%s' % name]
+            if UserSettings.Get(group='cmd', key='rasterOpaque', subkey='enabled'):
+                cmd.append('-n')
+                
+            maptree.AddLayer(ltype='raster',
+                             lname=name,
+                             lcmd=cmd)
+        else:
+            maptree.AddLayer(ltype='vector',
+                             lname=name,
+                             lcmd=['d.vect',
+                                   'map=%s' % name])
+        
     def OnAbort(self, event):
         """!Abort running import
 



More information about the grass-commit mailing list