[GRASS-SVN] r56495 - grass/trunk/gui/wxpython/nviz

svn_grass at osgeo.org svn_grass at osgeo.org
Wed May 29 14:15:45 PDT 2013


Author: annakrat
Date: 2013-05-29 14:15:45 -0700 (Wed, 29 May 2013)
New Revision: 56495

Modified:
   grass/trunk/gui/wxpython/nviz/mapwindow.py
   grass/trunk/gui/wxpython/nviz/tools.py
Log:
wxNviz: load areas as boundaries and centroids

Modified: grass/trunk/gui/wxpython/nviz/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/mapwindow.py	2013-05-29 19:57:13 UTC (rev 56494)
+++ grass/trunk/gui/wxpython/nviz/mapwindow.py	2013-05-29 21:15:45 UTC (rev 56495)
@@ -1318,17 +1318,12 @@
                 elif type ==  '3d-raster':
                     self.LoadRaster3d(item)
                 elif type ==  'vector':
-                    # data = self.tree.GetLayerInfo(item, key = 'nviz')
-                    # vecType = []
-                    # if data and 'vector' in data:
-                    #     for v in ('lines', 'points'):
-                    #         if data['vector'][v]:
-                    #             vecType.append(v)
                     layer = self.tree.GetLayerInfo(item, key = 'maplayer')
-                    npoints, nlines, nfeatures, mapIs3D = self.lmgr.nviz.VectorInfo(layer)
-                    if npoints > 0:
+                    vInfo = grass.vector_info_topo(layer.GetName())
+                    if (vInfo['points']) > 0:
+                        # include vInfo['centroids'] to initially load centroids 
                         self.LoadVector(item, points = True)
-                    if nlines > 0 or mapIs3D:
+                    if (vInfo['lines'] + vInfo['boundaries']) > 0 or vInfo['map3d']:
                         self.LoadVector(item, points = False)
                     
             except GException, e:
@@ -1367,10 +1362,10 @@
                     self.UnloadRaster3d(layer) 
                 elif ltype ==  'vector':
                     maplayer = self.tree.GetLayerInfo(layer, key = 'maplayer')
-                    npoints, nlines, nfeatures, mapIs3D = self.lmgr.nviz.VectorInfo(maplayer)
-                    if npoints > 0:
+                    vInfo = grass.vector_info_topo(maplayer.GetName())
+                    if (vInfo['points'] + vInfo['centroids']) > 0:
                         self.UnloadVector(layer, points = True)
-                    if nlines > 0:
+                    if (vInfo['lines'] + vInfo['boundaries']) > 0 or vInfo['map3d']:
                         self.UnloadVector(layer, points = False)
                         
             except GException, e:
@@ -2240,10 +2235,10 @@
             if type == 'raster':
                 self.nvizDefault.SetSurfaceDefaultProp(data['surface'])
             if type == 'vector':
-                npoints, nlines, nfeatures, mapIs3D = self.lmgr.nviz.VectorInfo(layer)
-                if npoints > 0:
+                vInfo = grass.vector_info_topo(layer.GetName())
+                if (vInfo['points'] + vInfo['centroids']) > 0:
                     self.nvizDefault.SetVectorPointsDefaultProp(data['vector']['points'])
-                if nlines > 0:
+                if (vInfo['lines'] + vInfo['boundaries']) > 0:
                     self.nvizDefault.SetVectorLinesDefaultProp(data['vector']['lines'])
             
     def NvizCmdCommand(self):
@@ -2362,17 +2357,17 @@
             markers = ['x', 'box', 'sphere', 'cube', 'diamond',
                        'dec_tree', 'con_tree', 'aster', 'gyro', 'histogram']
             for vector in vectors:
-                npoints, nlines, nfeatures, mapIs3D = self.lmgr.nviz.VectorInfo(
-                                                      self.tree.GetLayerInfo(vector, key = 'maplayer'))
+                layerName = self.tree.GetLayerInfo(vector, key = 'maplayer').GetName()
+                vInfo = grass.vector_info_topo(layerName)
                 nvizData = self.tree.GetLayerInfo(vector, key = 'nviz')['vector']
-                if nlines > 0:
+                if (vInfo['lines'] + vInfo['boundaries']) > 0:
                     cmdLines += "%s," % self.tree.GetLayerInfo(vector, key = 'maplayer').GetName()
                     cmdLWidth += "%d," % nvizData['lines']['width']['value']
                     cmdLHeight += "%d," % nvizData['lines']['height']['value']
                     cmdLColor += "%s," % nvizData['lines']['color']['value']
                     cmdLMode += "%s," % nvizData['lines']['mode']['type']
                     cmdLPos += "0,0,%d," % nvizData['lines']['height']['value']
-                if npoints > 0:    
+                if (vInfo['points'] + vInfo['centroids']) > 0:    
                     cmdPoints += "%s," % self.tree.GetLayerInfo(vector, key = 'maplayer').GetName()
                     cmdPWidth += "%d," % nvizData['points']['width']['value']
                     cmdPSize += "%d," % nvizData['points']['size']['value']

Modified: grass/trunk/gui/wxpython/nviz/tools.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/tools.py	2013-05-29 19:57:13 UTC (rev 56494)
+++ grass/trunk/gui/wxpython/nviz/tools.py	2013-05-29 21:15:45 UTC (rev 56495)
@@ -4694,43 +4694,20 @@
 
         # enable/disable res widget + set draw mode
         self.OnSurfaceMode(event = None)
-
-    def VectorInfo(self, layer):
-        """!Get number of points/lines
         
-        @param layer MapLayer instance
-        
-        @return num of points/features (expect of points)
-        @return None
-        """
-        vInfo = grass.vector_info_topo(layer.GetName())
-        
-        if not vInfo:
-            return None
-        
-        nprimitives = 0
-        for key, value in vInfo.iteritems():
-            if key in ('points',
-                       'lines',
-                       'boundaries',
-                       'centroids',
-                       'faces',
-                       'kernels'):
-                nprimitives += value
-        
-        return (vInfo['points'], vInfo['lines'], nprimitives, vInfo['map3d'])
-        
     def UpdateVectorPage(self, layer, data, updateName = True):
         """!Update vector page"""
-        npoints, nlines, nfeatures, mapIs3D = self.VectorInfo(layer)
-        if mapIs3D:
+        vInfo = grass.vector_info_topo(layer.GetName())
+        if not vInfo:
+            return
+        if vInfo['map3d']:
             desc = _("Vector map is 3D")
             enable = False
         else:
             desc = _("Vector map is 2D")
             enable = True
         desc += " - " + _("%(features)d features (%(points)d points)") % \
-            { 'features' : nfeatures, 'points' : npoints }
+            { 'features' : vInfo['primitives'], 'points' : vInfo['points']}
         
         if updateName:
             self.FindWindowById(self.win['vector']['map']).SetValue(layer.name)
@@ -4760,13 +4737,12 @@
             showLines.SetValue(True)
         else:
             showLines.SetValue(False)
-            if nlines > 0:
-                showLines.Enable(True)
-            else:
-                showLines.Enable(False)
+        if (vInfo['lines'] + vInfo['boundaries']) > 0:
+            showLines.Enable(True)
+        else:
+            showLines.Enable(False)
         
-        self.UpdateVectorShow('lines',
-                              showLines.IsChecked())
+        self.UpdateVectorShow('lines', showLines.IsChecked())
         
         width = self.FindWindowById(self.win['vector']['lines']['width'])
         width.SetValue(data['lines']['width']['value'])
@@ -4807,13 +4783,12 @@
             showPoints.SetValue(True)
         else:
             showPoints.SetValue(False)
-            if npoints > 0:
-                showPoints.Enable(True)
-            else:
-                showPoints.Enable(False)
+        if (vInfo['points'] + vInfo['centroids']) > 0:
+            showPoints.Enable(True)
+        else:
+            showPoints.Enable(False)
         
-        self.UpdateVectorShow('points',
-                              showPoints.IsChecked())
+        self.UpdateVectorShow('points', showPoints.IsChecked())
         # size, width, marker, color
         for prop in ('size', 'marker', 'color'):
             win = self.FindWindowById(self.win['vector']['points'][prop])



More information about the grass-commit mailing list