[GRASS-SVN] r58292 - grass/trunk/gui/wxpython/lmgr

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Nov 24 10:01:26 PST 2013


Author: martinl
Date: 2013-11-24 10:01:26 -0800 (Sun, 24 Nov 2013)
New Revision: 58292

Modified:
   grass/trunk/gui/wxpython/lmgr/layertree.py
Log:
wxGUI: fix auto-zooming when first layer is added to the layer tree

Modified: grass/trunk/gui/wxpython/lmgr/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/layertree.py	2013-11-24 17:18:25 UTC (rev 58291)
+++ grass/trunk/gui/wxpython/lmgr/layertree.py	2013-11-24 18:01:26 UTC (rev 58292)
@@ -131,6 +131,7 @@
         self.optpage = {}                    # dictionary of notebook option pages for each map layer
         self.saveitem = {}                   # dictionary to preserve layer attributes for drag and drop
         self.first = True                    # indicates if a layer is just added or not
+        self.firstNewLayer = True            # indicates if first layer has been newly added to the layer tree
         self.flag = ''                       # flag for drag and drop hittest
         # layer change requires a rerendering
         # (used to request rendering only when layer changes are finished)
@@ -1290,7 +1291,10 @@
 
         # redraw map if auto-rendering is enabled
         self.rerender = True
-        self.Map.SetLayers(self.GetVisibleLayers())
+        nlayers = self.GetVisibleLayers()
+        if not nlayers:
+            self.firstNewLayer = True # layer tree is empty
+        self.Map.SetLayers(nlayers)
         
         if self.mapdisplay.GetToolbar('vdigit'):
             self.mapdisplay.toolbars['vdigit'].UpdateListOfLayers (updateTool = True)
@@ -1650,13 +1654,17 @@
         
         # set region if auto-zooming is enabled or layer tree contains
         # only one map layer
-        if dcmd and (len(self.GetVisibleLayers()) < 2 or \
-                         UserSettings.Get(group = 'display', key = 'autoZooming', subkey = 'enabled')):
-            mapLayer = self.GetLayerInfo(layer, key = 'maplayer')
-            if mapLayer.GetType() in ('raster', 'vector'):
-                render = UserSettings.Get(group = 'display', key = 'autoRendering', subkey = 'enabled')
-                self.mapdisplay.MapWindow.ZoomToMap(layers = [mapLayer,],
-                                                    render = render)
+        if dcmd:
+            if self.firstNewLayer or \
+                    UserSettings.Get(group = 'display', key = 'autoZooming', subkey = 'enabled'):
+                mapLayer = self.GetLayerInfo(layer, key = 'maplayer')
+                if mapLayer.GetType() in ('raster', 'vector'):
+                    render = UserSettings.Get(group = 'display', key = 'autoRendering', subkey = 'enabled')
+                    self.mapdisplay.MapWindow.ZoomToMap(layers = [mapLayer,],
+                                                        render = render)
+            
+            self.firstNewLayer = False # first layer has been already
+                                       # added to the layer tree
         
         # update nviz session        
         if self.lmgr.IsPaneShown('toolbarNviz') and dcmd:



More information about the grass-commit mailing list