[GRASS-SVN] r46208 - in grass/trunk: gui/wxpython/gui_modules lib/ogsf

svn_grass at osgeo.org svn_grass at osgeo.org
Sun May 8 16:31:07 EDT 2011


Author: martinl
Date: 2011-05-08 13:31:07 -0700 (Sun, 08 May 2011)
New Revision: 46208

Modified:
   grass/trunk/gui/wxpython/gui_modules/layertree.py
   grass/trunk/gui/wxpython/gui_modules/mapdisp.py
   grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
   grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
   grass/trunk/lib/ogsf/GS2.c
Log:
annakrat: fix some wxnviz known issues (http://grass.osgeo.org/wiki/WxNviz#Known_issues) - # 5
	  fix reloading data (check / uncheck data layer)


Modified: grass/trunk/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/layertree.py	2011-05-08 19:58:37 UTC (rev 46207)
+++ grass/trunk/gui/wxpython/gui_modules/layertree.py	2011-05-08 20:31:07 UTC (rev 46208)
@@ -231,7 +231,8 @@
         if self.rerender:
             if self.mapdisplay.statusbarWin['render'].GetValue():
                 self.mapdisplay.MapWindow.UpdateMap(render = True)
-
+            self.rerender = False
+        
         event.Skip()
         
     def OnKeyUp(self, event):
@@ -1108,11 +1109,13 @@
                 elif mapLayer.type == '3d-raster':
                     self.mapdisplay.MapWindow.LoadRaster3d(item)
                 elif mapLayer.type == 'vector':
-                    self.mapdisplay.MapWindow.LoadVector(item)
+                    npoints, nlines, nfeatures, mapIs3D = self.lmgr.nviz.VectorInfo(mapLayer)
+                    if npoints > 0:
+                        self.mapdisplay.MapWindow.LoadVector(item, points = True)
+                    if nlines > 0:
+                        self.mapdisplay.MapWindow.LoadVector(item, points = False)
 
             else: # disable
-                data = self.GetPyData(item)[0]['nviz']
-
                 if mapLayer.type == 'raster':
                     self.mapdisplay.MapWindow.UnloadRaster(item)
                 elif mapLayer.type == '3d-raster':

Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2011-05-08 19:58:37 UTC (rev 46207)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2011-05-08 20:31:07 UTC (rev 46208)
@@ -399,6 +399,8 @@
             self.MapWindow = self.MapWindow3D
             # add Nviz notebookpage
             self._layerManager.AddNviz()
+            self._layerManager.nviz.UpdatePage('view')
+            self._layerManager.nviz.UpdatePage('light')
         
         # switch from MapWindow to MapWindowGL
         # add nviz toolbar

Modified: grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py	2011-05-08 19:58:37 UTC (rev 46207)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py	2011-05-08 20:31:07 UTC (rev 46208)
@@ -117,6 +117,9 @@
         
         self.img = wx.Image(self.Map.mapfile, wx.BITMAP_TYPE_ANY)
         
+        # size of MapWindow, to avoid resizing if size is the same
+        self.size = (0,0)
+        
         #
         # default values
         #
@@ -148,13 +151,14 @@
     
     def OnSize(self, event):
         size = self.GetClientSize()
-        if self.GetContext():
+        if self.size != size \
+            and self.GetContext():
             Debug.msg(3, "GLCanvas.OnSize(): w = %d, h = %d" % \
                       (size.width, size.height))
             self.SetCurrent()
             self._display.ResizeWindow(size.width,
                                        size.height)
-        
+        self.size = size
         event.Skip()
         
     def OnPaint(self, event):
@@ -315,7 +319,7 @@
         """!Change light settings"""
         data = self.light
         self._display.SetLight(x = data['position']['x'], y = data['position']['y'],
-                               z = data['position']['z'], color = data['color'],
+                               z = data['position']['z'] / 100., color = data['color'],
                                bright = data['bright'] / 100.,
                                ambient = data['ambient'] / 100.)
         self._display.DrawLightingModel()
@@ -473,12 +477,6 @@
                     elif ltype ==  '3d-raster':
                         self.UnloadRaster3d(layer) 
                     elif ltype ==  'vector':
-                        data = self.tree.GetPyData(layer)[0]['nviz']
-                        vecType = []
-                        if data and 'vector' in data:
-                            for v in ('lines', 'points'):
-                                if data['vector'][v]:
-                                    vecType.append(v)
                         self.UnloadVector(layer, True)
                         self.UnloadVector(layer, False)
                     
@@ -950,6 +948,7 @@
             z = data['position']['z']
             self._display.SetSurfacePosition(id, x, y, z)
             data['position'].pop('update')
+        data['draw']['all'] = False
         
     def UpdateVolumeProperties(self, id, data, isosurfId = None):
         """!Update volume (isosurface/slice) map object properties"""

Modified: grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_tools.py	2011-05-08 19:58:37 UTC (rev 46207)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_tools.py	2011-05-08 20:31:07 UTC (rev 46208)
@@ -1192,6 +1192,7 @@
                                   colour = UserSettings.Get(group = 'nviz', key = 'light',
                                                             subkey = 'color'),
                                   size = globalvar.DIALOG_COLOR_SIZE)
+        self.win['light']['color'] = color.GetId()
         color.Bind(csel.EVT_COLOURSELECT, self.OnLightColor)
         gridSizer.Add(item = color, pos = (0, 2))
 
@@ -1461,7 +1462,7 @@
             return
         
         val = event.GetInt()
-        self.mapWindow.light['position']['z'] = val / 100.
+        self.mapWindow.light['position']['z'] = val
         for win in self.win['light'][winName].itervalues():
             self.FindWindowById(win).SetValue(val)
         
@@ -1492,6 +1493,7 @@
     def OnBgColor(self, event):
         """!Background color changed"""
         color = event.GetValue()
+        self.mapWindow.view['background']['color'] = event.GetValue()
         color = str(color[0]) + ':' + str(color[1]) + ':' + str(color[2])
         
         self._display.SetBgColor(str(color))
@@ -1799,7 +1801,7 @@
         """!Draw resolution changed"""
         self.SetSurfaceResolution()
         
-        if apply and self.mapDisplay.statusbarWin['render'].IsChecked():
+        if self.mapDisplay.statusbarWin['render'].IsChecked():
             self.mapWindow.Refresh(False)
         
     def SetSurfaceResolution(self):
@@ -1817,10 +1819,7 @@
         wx.PostEvent(self.mapWindow, event)
         
     def SetSurfaceMode(self):
-        """!Set draw mode
-
-        @param apply allow auto-rendering
-        """
+        """!Set draw mode"""
         mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
         if mode == 0: # coarse
             self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
@@ -1853,7 +1852,7 @@
         event = wxUpdateProperties(data = data)
         wx.PostEvent(self.mapWindow, event)
         
-        if apply and self.mapDisplay.statusbarWin['render'].IsChecked():
+        if self.mapDisplay.statusbarWin['render'].IsChecked():
             self.mapWindow.Refresh(False)
 
     def OnSurfaceModeAll(self, event):
@@ -1865,10 +1864,12 @@
         cvalue = self._getColorString(color)
         
         for name in self.mapWindow.GetLayerNames(type = 'raster'):
-            data = self.GetLayerData('surface')
+            
+            data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')
             if not data:
                 continue # shouldy no happen
             
+            data['surface']['draw']['all'] = True
             data['surface']['draw']['mode'] = { 'value' : value,
                                                 'desc' : desc,
                                                 'update' : None }
@@ -1882,7 +1883,7 @@
             event = wxUpdateProperties(data = data)
             wx.PostEvent(self.mapWindow, event)
             
-        if apply and self.mapDisplay.statusbarWin['render'].IsChecked():
+        if self.mapDisplay.statusbarWin['render'].IsChecked():
             self.mapWindow.Refresh(False)
         
     def _getColorString(self, color):
@@ -2480,6 +2481,9 @@
                                                                                   zmax)
                 self.FindWindowById(self.win['view']['z-exag'][control]).SetValue(zval)                                      
         
+            self.FindWindowById(self.win['view']['bgcolor']).SetColour(\
+                            self.mapWindow.view['background']['color'])
+            
         elif pageId in ('surface', 'vector', 'volume'):
             name = self.FindWindowById(self.win[pageId]['map']).GetValue()
             data = self.GetLayerData(pageId)
@@ -2501,6 +2505,7 @@
                 self.FindWindowById(self.win['light']['z'][control]).SetValue(zval)
                 self.FindWindowById(self.win['light']['bright'][control]).SetValue(bval)
                 self.FindWindowById(self.win['light']['ambient'][control]).SetValue(aval)
+            self.FindWindowById(self.win['light']['color']).SetColour(self.mapWindow.light['color'])
         elif pageId == 'fringe':
             win = self.FindWindowById(self.win['fringe']['map'])
             win.SetValue(self.FindWindowById(self.win['surface']['map']).GetValue())
@@ -2593,8 +2598,7 @@
             else:
                 win.SetValue(value)
         # enable/disable res widget + set draw mode
-        self.SetSurfaceMode()
-        color = self.FindWindowById(self.win['surface']['draw']['wire-color'])
+        self.OnSurfaceMode(event = None)
 
     def VectorInfo(self, layer):
         """!Get number of points/lines

Modified: grass/trunk/lib/ogsf/GS2.c
===================================================================
--- grass/trunk/lib/ogsf/GS2.c	2011-05-08 19:58:37 UTC (rev 46207)
+++ grass/trunk/lib/ogsf/GS2.c	2011-05-08 20:31:07 UTC (rev 46208)
@@ -1599,15 +1599,16 @@
     unsigned int atty;
     const char *mapset;
     struct Cell_head rast_head;
-    int reuse = 0, begin, hdata, ret, neg = 0, has_null = 0;
+    int reuse, begin, hdata, ret, neg, has_null;
     typbuff *tbuff;
 
     G_debug(3, "GS_load_att_map(): map=%s", filename);
 
+    reuse = ret = neg = has_null = 0;
     gs = gs_get_surf(id);
 
     if (NULL == gs) {
-	return (-1);
+	return -1;
     }
 
     gs->mask_needupdate = (ATT_MASK == att || ATT_TOPO == att ||
@@ -1647,8 +1648,7 @@
 
 	if (0 < (hdata = gsds_findh(filename, &changed, &atty, begin))) {
 
-	    G_debug(3,
-		    "GS_load_att_map(): %s already has data handle %d.CF=%x",
+	    G_debug(3, "GS_load_att_map(): %s already has data handle %d.CF=%x",
 		    filename, hdata, changed);
 
 	    /* handle found */
@@ -1688,8 +1688,7 @@
 		filename, hdata);
     }
     else {
-	G_debug(3,
-		"GS_load_att_map(): %s not loaded in correct form - loading now",
+	G_debug(3, "GS_load_att_map(): %s not loaded in correct form - loading now",
 		filename);
 
 	/* not loaded - need to get new dataset handle */
@@ -1769,7 +1768,7 @@
 
 	if (ret == -1) {
 	    gsds_free_data_buff(gs->att[att].hdata, ATTY_NULL);
-	    return (-1);
+	    return -1;
 	}
 
 	G_debug(4, "  has_null=%d", has_null);
@@ -1841,7 +1840,7 @@
 	G_warning(_("Error finding range"));
     }
 
-    return (ret);
+    return ret;
 }
 
 /*!



More information about the grass-commit mailing list