瀏覽代碼

wxGUI/nviz: error pressing "All" button (trac https://trac.osgeo.org/grass/ticket/300)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@35314 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 16 年之前
父節點
當前提交
c841e01cf9

+ 2 - 1
gui/wxpython/gui_modules/mapdisp.py

@@ -522,7 +522,8 @@ class MapFrame(wx.Frame):
             self.Map.DeleteLayer(layer)
 
         # delete tmp lines
-        if self.MapWindow.mouse["use"] in ["measure", "profile"]:
+        if self.MapWindow.mouse["use"] in ("measure",
+                                           "profile"):
             self.MapWindow.polycoords = []
             self.MapWindow.ClearLines()
         

+ 11 - 14
gui/wxpython/gui_modules/mapdisp_window.py

@@ -44,6 +44,17 @@ class MapWindow(object):
                  style=wx.NO_FULL_REPAINT_ON_RESIZE,
                  Map=None, tree=None, gismgr=None):
         self.parent = parent # MapFrame
+ 
+        #
+        # mouse attributes -- position on the screen, begin and end of
+        # dragging, and type of drawing
+        #
+        self.mouse = {
+            'begin': [0, 0], # screen coordinates
+            'end'  : [0, 0],
+            'use'  : "pointer",
+            'box'  : "point"
+            }
         
     def EraseMap(self):
         """
@@ -176,20 +187,6 @@ class BufferedWindow(MapWindow, wx.Window):
         self.zoomhistory = [] # list of past zoom extents
         self.currzoom = 0 # current set of extents in zoom history being used
 
-        #
-        # mouse attributes like currently pressed buttons, position on
-        # the screen, begin and end of dragging, and type of drawing
-        #
-        self.mouse = {
-            'l'    : False,
-            'r'    : False,
-            'm'    : False,
-            'begin': [0, 0], # screen coordinates
-            'end'  : [0, 0],
-            'use'  : "pointer",
-            'box'  : "point"
-            }
-
         self.zoomtype = 1   # 1 zoom in, 0 no zoom, -1 zoom out
         self.hitradius = 10 # distance for selecting map decorations
         self.dialogOffset = 5 # offset for dialog (e.g. DisplayAttributesDialog)

+ 12 - 0
gui/wxpython/gui_modules/nviz_mapdisp.py

@@ -1221,6 +1221,18 @@ class GLWindow(MapWindow, glcanvas.GLCanvas):
         
         return layerName
     
+    def GetLayerData(self, type, name):
+        """Return layer item data
+
+        @return {} if no layer item found
+        """
+        for item in self.layers:
+            mapLayer = self.tree.GetPyData(item)[0]['maplayer'].GetName()
+            if mapLayer == name:
+                return self.tree.GetPyData(item)[0]['nviz']
+        
+        return {}
+    
     def GetLayerId(self, type, name):
         """Get layer object id or -1"""
         if len(name) < 1:

+ 26 - 7
gui/wxpython/gui_modules/nviz_tools.py

@@ -418,9 +418,8 @@ class NvizToolWindow(wx.Frame):
                       flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
                       border=5)
 
-        all = wx.Button(panel, id=wx.ID_ANY, label=_("All"))
-        all.SetToolTipString(_("Use for all loaded surfaces"))
-        # self.win['reset'] = reset.GetId()
+        all = wx.Button(panel, id=wx.ID_ANY, label=_("Set to all"))
+        all.SetToolTipString(_("Use draw settings for all loaded surfaces"))
         all.Bind(wx.EVT_BUTTON, self.OnSurfaceModeAll)
         gridSizer.Add(item=all, flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
                       pos=(2, 4))
@@ -1720,10 +1719,30 @@ class NvizToolWindow(wx.Frame):
 
     def OnSurfaceModeAll(self, event):
         """Set draw mode (including wire color) for all loaded surfaces"""
-        self.SetSurfaceMode(all=True)
-        self.SetSurfaceResolution(all=True)
-        ### color = self.FindWindowById(self.win['surface']['draw']['wire-color']).GetColour()
-
+        value, desc = self.SetSurfaceMode()
+        coarse = self.FindWindowById(self.win['surface']['draw']['res-coarse']).GetValue()
+        fine = self.FindWindowById(self.win['surface']['draw']['res-fine']).GetValue()
+        color = self.FindWindowById(self.win['surface']['draw']['wire-color']).GetColour()
+        cvalue = self._getColorString(color)
+        
+        for name in self.mapWindow.GetLayerNames(type='raster'):
+            data = self.mapWindow.GetLayerData(type='raster', name=name)
+            if not data:
+                continue # shouldy no happen
+            
+            data['surface']['draw']['mode'] = { 'value' : value,
+                                                'desc' : desc,
+                                                'update' : None, }
+            data['surface']['draw']['resolution'] = { 'coarse' : coarse,
+                                                      'fine' : fine,
+                                                      'update' : None, }
+            data['surface']['draw']['wire-color'] = { 'value' : cvalue,
+                                                      'update' : None }
+            
+            # update properties
+            event = wxUpdateProperties(data=data)
+            wx.PostEvent(self.mapWindow, event)
+            
         if apply and self.parent.autoRender.IsChecked():
             self.mapWindow.Refresh(False)