[GRASS-SVN] r31864 - grass-addons/visualization/nviz2/wxpython

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jun 27 17:33:17 EDT 2008


Author: martinl
Date: 2008-06-27 17:33:16 -0400 (Fri, 27 Jun 2008)
New Revision: 31864

Modified:
   grass-addons/visualization/nviz2/wxpython/mapdisp.py
   grass-addons/visualization/nviz2/wxpython/nviz.py
Log:
nviz2: wxGUI-related fixes (r31863)


Modified: grass-addons/visualization/nviz2/wxpython/mapdisp.py
===================================================================
--- grass-addons/visualization/nviz2/wxpython/mapdisp.py	2008-06-27 21:31:43 UTC (rev 31863)
+++ grass-addons/visualization/nviz2/wxpython/mapdisp.py	2008-06-27 21:33:16 UTC (rev 31864)
@@ -160,7 +160,7 @@
     def ZoomToMap(self, event):
         pass
 
-    def GetSelectedLayer(self, nviz=False):
+    def GetSelectedLayer(self, nviz=False, index=False):
         """Get selected layer from layer tree
 
         @param nviz get nviz properties instead

Modified: grass-addons/visualization/nviz2/wxpython/nviz.py
===================================================================
--- grass-addons/visualization/nviz2/wxpython/nviz.py	2008-06-27 21:31:43 UTC (rev 31863)
+++ grass-addons/visualization/nviz2/wxpython/nviz.py	2008-06-27 21:33:16 UTC (rev 31864)
@@ -106,6 +106,7 @@
         #
         self.view = UserSettings.Get(group='nviz', key='view') # reference
         self.update = [] # update view/controls
+        self.object = {} # loaded data objects (layer index / gsurf id)
 
         self.size = None
         self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
@@ -279,7 +280,8 @@
         @todo volumes
         """
         for raster in self.Map.GetListOfLayers(l_type='raster', l_active=True):
-            self.nvizClass.LoadRaster(str(raster.name), None, None)
+            id = self.nvizClass.LoadRaster(str(raster.name), None, None)
+            self.object[self.Map.GetLayerIndex(raster)] = id
 
     def Reset(self):
         """Reset (unload data)"""
@@ -315,6 +317,19 @@
         self.update.append('view')
         self.update.append('z-exag')
 
+    def GetMapObjId(self, layer):
+        """Get map object id of given map layer (2D)
+
+        @param layer MapLayer instance
+        """
+        index = self.Map.GetLayerIndex(layer)
+
+        try:
+            return self.object[index]
+        except:
+            return -1
+
+
 class NvizToolWindow(wx.Frame):
     """Experimental window for Nviz tools
 
@@ -535,17 +550,23 @@
                                  # size=globalvar.DIALOG_GSELECT_SIZE,
                                  size=(200, -1),
                                  type="raster")
-            self.win['surface'][code]['map'] = map.GetId()
+            self.win['surface'][code]['map'] = map.GetId() - 1 # FIXME ! 
             map.Bind(wx.EVT_TEXT, self.OnSurfaceMap)
             gridSizer.Add(item=map, flag=wx.ALIGN_CENTER_VERTICAL,
                           pos=(row, 2))
 
-            value = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
-                                initial=0,
-                                min=0,
-                                max=100)
+            if code == 'color':
+                value = csel.ColourSelect(panel, id=wx.ID_ANY)
+                value.Bind(wx.EVT_TEXT, self.OnSurfaceMap)
+            else:
+                value = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
+                                    initial=0,
+                                    min=0,
+                                    max=100)
+                value.Bind(wx.EVT_TEXT, self.OnSurfaceMap)
             self.win['surface'][code]['constant'] = value.GetId()
             value.Enable(False)
+
             gridSizer.Add(item=value, flag=wx.ALIGN_CENTER_VERTICAL,
                           pos=(row, 3))
 
@@ -872,15 +893,26 @@
 
     def OnSurfaceMap(self, event):
         """Set surface attribute -- map"""
-        attrName = 'topo'
-        win = self.FindWindowById(self.win['surface'][attrName]['map'])
-        # print win.GetId(), win.tcp.seltree.GetId(), event.GetId()
+        if not self.mapWindow.init:
+            return
 
+        attrName = self.__GetWindowName(self.win['surface'], event.GetId())
         if not attrName:
             return
 
-        if attrName == 'topo':
-            print 'x'
+        if self.FindWindowById(self.win['surface'][attrName]['use']).GetSelection() == 0:
+            value = self.FindWindowById(self.win['surface'][attrName]['map']).GetValue()
+            map = True
+        else:
+            value = self.FindWindowById(self.win['surface'][attrName]['constant']).GetValue()
+            print value
+            map = False
+
+        layer = self.mapWindow.GetSelectedLayer()
+        id = self.mapWindow.GetMapObjId(layer)
+
+        if attrName == 'color':
+            self.mapWindow.nvizClass.SetSurfaceColor(id, map, str(value)) 
         
     def OnSurfaceMode(self, event):
         pass



More information about the grass-commit mailing list