[GRASS-SVN] r46210 - in grass/branches/releasebranch_6_4: gui/wxpython/gui_modules lib/ogsf

svn_grass at osgeo.org svn_grass at osgeo.org
Sun May 8 16:39:53 EDT 2011


Author: martinl
Date: 2011-05-08 13:39:53 -0700 (Sun, 08 May 2011)
New Revision: 46210

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/layertree.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/nviz_mapdisp.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/nviz_tools.py
   grass/branches/releasebranch_6_4/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)
    (merge 46209 from trunk)


Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/layertree.py	2011-05-08 20:36:00 UTC (rev 46209)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/layertree.py	2011-05-08 20:39:53 UTC (rev 46210)
@@ -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):
@@ -1071,11 +1072,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/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py	2011-05-08 20:36:00 UTC (rev 46209)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py	2011-05-08 20:39:53 UTC (rev 46210)
@@ -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/branches/releasebranch_6_4/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/nviz_mapdisp.py	2011-05-08 20:36:00 UTC (rev 46209)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/nviz_mapdisp.py	2011-05-08 20:39:53 UTC (rev 46210)
@@ -116,6 +116,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
         #
@@ -147,13 +150,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):
@@ -311,7 +315,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()
@@ -469,12 +473,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)
                     
@@ -946,6 +944,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/branches/releasebranch_6_4/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/nviz_tools.py	2011-05-08 20:36:00 UTC (rev 46209)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/nviz_tools.py	2011-05-08 20:39:53 UTC (rev 46210)
@@ -1193,6 +1193,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))
 
@@ -1462,7 +1463,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)
         
@@ -1493,6 +1494,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))
@@ -1800,7 +1802,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):
@@ -1818,10 +1820,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)
@@ -1854,7 +1853,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):
@@ -1866,10 +1865,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 }
@@ -1883,7 +1884,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):
@@ -2481,6 +2482,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)
@@ -2502,6 +2506,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())
@@ -2594,8 +2599,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/branches/releasebranch_6_4/lib/ogsf/GS2.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/ogsf/GS2.c	2011-05-08 20:36:00 UTC (rev 46209)
+++ grass/branches/releasebranch_6_4/lib/ogsf/GS2.c	2011-05-08 20:39:53 UTC (rev 46210)
@@ -1594,15 +1594,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 ||
@@ -1762,7 +1763,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);
@@ -1834,7 +1835,7 @@
 	G_warning(_("Error finding range"));
     }
 
-    return (ret);
+    return ret;
 }
 
 /*!



More information about the grass-commit mailing list