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

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Nov 13 20:30:55 PST 2016


Author: annakrat
Date: 2016-11-13 20:30:55 -0800 (Sun, 13 Nov 2016)
New Revision: 69822

Modified:
   grass/trunk/gui/wxpython/lmgr/layertree.py
Log:
wxGUI/nviz: fix loading vector layers during 3D view

Modified: grass/trunk/gui/wxpython/lmgr/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/layertree.py	2016-11-14 03:17:02 UTC (rev 69821)
+++ grass/trunk/gui/wxpython/lmgr/layertree.py	2016-11-14 04:30:55 UTC (rev 69822)
@@ -1964,11 +1964,6 @@
                          message=_("Map <%s> not found.") % mapName)
                 return
 
-            if not mapLayer.IsActive():
-                self.forceCheck = True
-                self.CheckItem(layer, True)
-                mapLayer.SetActive(True)
-
         # update layer data
         if params:
             self.SetPyData(layer, (self.GetLayerInfo(layer), params))
@@ -1992,40 +1987,50 @@
             self.first = False  # first layer has been already added to
             # the layer tree
 
-        # update nviz session
-        if self.mapdisplay.IsPaneShown('3d') and dcmd:
-            mapLayer = self.GetLayerInfo(layer, key='maplayer')
-            mapWin = self.mapdisplay.MapWindow
-            if len(mapLayer.GetCmd()) > 0:
-                if mapLayer.type == 'raster':
-                    if mapWin.IsLoaded(layer):
-                        mapWin.UnloadRaster(layer)
+        if dcmd:
+            if not mapLayer.IsActive():
+                self.forceCheck = True
+                self.CheckItem(layer, True)
+                mapLayer.SetActive(True)
+                # no need to update nviz here, already done by OnLayerChecked
 
-                    mapWin.LoadRaster(layer)
+            # update nviz session
+            elif self.mapdisplay.IsPaneShown('3d'):
+                mapLayer = self.GetLayerInfo(layer, key='maplayer')
+                mapWin = self.mapdisplay.MapWindow
+                if len(mapLayer.GetCmd()) > 0:
+                    if mapLayer.type == 'raster':
+                        if mapWin.IsLoaded(layer):
+                            mapWin.UnloadRaster(layer)
+    
+                        mapWin.LoadRaster(layer)
+    
+                    elif mapLayer.type == 'raster_3d':
+                        if mapWin.IsLoaded(layer):
+                            mapWin.UnloadRaster3d(layer)
+    
+                        mapWin.LoadRaster3d(layer)
+    
+                    elif mapLayer.type == 'vector':
+                        if mapWin.IsLoaded(layer):
+                            mapWin.UnloadVector(layer)
+                        vInfo = gvector.vector_info_topo(mapLayer.GetName())
+                        if (vInfo['points'] + vInfo['centroids']) > 0:
+                            mapWin.LoadVector(layer, points=True)
+                        if (vInfo['lines'] + vInfo['boundaries']) > 0:
+                            mapWin.LoadVector(layer, points=False)
+    
+                    # reset view when first layer loaded
+                    nlayers = len(
+                        mapWin.Map.GetListOfLayers(
+                            ltype=(
+                                'raster',
+                                'raster_3d',
+                                'vector'),
+                            active=True))
+                    if nlayers < 2:
+                        mapWin.ResetView()
 
-                elif mapLayer.type == 'raster_3d':
-                    if mapWin.IsLoaded(layer):
-                        mapWin.UnloadRaster3d(layer)
-
-                    mapWin.LoadRaster3d(layer)
-
-                elif mapLayer.type == 'vector':
-                    if mapWin.IsLoaded(layer):
-                        mapWin.UnloadVector(layer)
-
-                    mapWin.LoadVector(layer)
-
-                # reset view when first layer loaded
-                nlayers = len(
-                    mapWin.Map.GetListOfLayers(
-                        ltype=(
-                            'raster',
-                            'raster_3d',
-                            'vector'),
-                        active=True))
-                if nlayers < 2:
-                    mapWin.ResetView()
-
     def GetVisibleLayers(self, skipDigitized=False):
         # make a list of visible layers
         layers = []



More information about the grass-commit mailing list