[GRASS-SVN] r31876 - in grass-addons/visualization/nviz2: lib wxpython wxpython/nviz

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jun 28 18:19:55 EDT 2008


Author: martinl
Date: 2008-06-28 18:19:55 -0400 (Sat, 28 Jun 2008)
New Revision: 31876

Modified:
   grass-addons/visualization/nviz2/lib/map_obj.c
   grass-addons/visualization/nviz2/wxpython/nviz.py
   grass-addons/visualization/nviz2/wxpython/nviz/surface.cpp
Log:
nviz2/wxGUI: surface color fix (map/constant)
OnApply -> update map + render
auto-rendering -> surface attribute changed -> OnApply


Modified: grass-addons/visualization/nviz2/lib/map_obj.c
===================================================================
--- grass-addons/visualization/nviz2/lib/map_obj.c	2008-06-28 17:56:20 UTC (rev 31875)
+++ grass-addons/visualization/nviz2/lib/map_obj.c	2008-06-28 22:19:55 UTC (rev 31876)
@@ -28,22 +28,18 @@
 /*!
   \brief Create a new map object which can be one of surf, vect, vol or site.
 
-  This routine creates the object
-  internally in the gsf library and links a new tcl/tk
-  command to the general object command parser below.
-  Optionally, a logical name may be specified for the new map
-  object.  If no name is specified, a logical name is assigned to
-  the new object automatically.  Note that maintaining unique
-  logical names is not the responsibility of the library (currently).
+  This routine creates the object internally in the gsf libraryb.
+  Optionally, a logical name may be specified for the new map object.
+  If no name is specified, a logical name is assigned to the new
+  object automatically.  Note that maintaining unique logical names is
+  not the responsibility of the library (currently).
   
-  Initially map objects contain no data, use the
-  attribute commands to set attributes such as topology,
-  color, etc.
+  Initially map objects contain no data, use the attribute commands to
+  set attributes such as topology, color, etc.
 
-  \param data
-  \param interp
-  \param argc
-  \param argv
+  \param type map object type
+  \param name map name
+  \param data nviz data
 
   \return map object id
   \return -1 on error
@@ -56,16 +52,13 @@
 
     nv_clientdata *client_data;
 
-/*
- * For each type of map obj do the following --
- *   1) Verify we havn't maxed out the number of
- *      allowed objects.
- *   2) Call the internal library to generate a new
- *      map object of the specified type.
- *   3) Create a new tcl/tk command with the new object
- *      id number and link it to the Nmap_obj_cmd routine
- *      below.
- */
+    /*
+     * For each type of map obj do the following --
+     *   1) Verify we havn't maxed out the number of
+     *      allowed objects.
+     *   2) Call the internal library to generate a new
+     *      map object of the specified type.
+     */
     /* raster -> surface */
     if (type == MAP_OBJ_SURF) {
 	if (GS_num_surfs() >= MAX_SURFS) {

Modified: grass-addons/visualization/nviz2/wxpython/nviz/surface.cpp
===================================================================
--- grass-addons/visualization/nviz2/wxpython/nviz/surface.cpp	2008-06-28 17:56:20 UTC (rev 31875)
+++ grass-addons/visualization/nviz2/wxpython/nviz/surface.cpp	2008-06-28 22:19:55 UTC (rev 31876)
@@ -27,7 +27,7 @@
     }
     else {
 	float val;
-	val = atof(value);
+	val = Nviz_color_from_str(value);
 	Nviz_set_attr(id, MAP_OBJ_SURF, ATT_COLOR, CONST_ATT,
 		      NULL, val,
 		      data);

Modified: grass-addons/visualization/nviz2/wxpython/nviz.py
===================================================================
--- grass-addons/visualization/nviz2/wxpython/nviz.py	2008-06-28 17:56:20 UTC (rev 31875)
+++ grass-addons/visualization/nviz2/wxpython/nviz.py	2008-06-28 22:19:55 UTC (rev 31876)
@@ -105,7 +105,7 @@
         # default values
         #
         self.view = UserSettings.Get(group='nviz', key='view') # reference
-        self.update = [] # update view/controls
+        self.update = {} # update view/controls
         self.object = {} # loaded data objects (layer index / gsurf id)
 
         self.size = None
@@ -229,16 +229,16 @@
                 self.parent.onRenderTimer.Start(100)
             self.parent.onRenderCounter = 0
 
-        if 'view' in self.update:
+        if 'view' in self.update.keys():
             self.nvizClass.SetView(self.view['pos']['x'], self.view['pos']['y'],
                                    self.view['height']['value'],
                                    self.view['persp']['value'],
                                    self.view['twist']['value'])
-            self.update.remove('view')
+            del self.update['view']
 
-        if 'z-exag' in self.update:
+        if 'z-exag' in self.update.keys():
             self.nvizClass.SetZExag(self.view['z-exag']['value'])
-            self.update.remove('z-exag')
+            del self.update['z-exag']
 
         if render is True:
             self.nvizClass.Draw(False)
@@ -314,8 +314,8 @@
         self.view['twist']['value'] = wxnviz.VIEW_DEFAULT_TWIST
         self.view['z-exag']['value'] = wxnviz.VIEW_DEFAULT_ZEXAG
 
-        self.update.append('view')
-        self.update.append('z-exag')
+        self.update['view'] = None
+        self.update['z-exag'] = None
 
     def GetMapObjId(self, layer):
         """Get map object id of given map layer (2D)
@@ -557,7 +557,7 @@
 
             if code == 'color':
                 value = csel.ColourSelect(panel, id=wx.ID_ANY)
-                value.Bind(wx.EVT_TEXT, self.OnSurfaceMap)
+                value.Bind(csel.EVT_COLOURSELECT, self.OnSurfaceMap)
             else:
                 value = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
                                     initial=0,
@@ -799,9 +799,9 @@
             self.FindWindowById(win).SetValue(self.settings[winName]['value'])
 
         if winName in ('pos', 'height', 'twist', 'persp'):
-            self.mapWindow.update.append('view')
+            self.mapWindow.update['view'] = None
         else:
-            self.mapWindow.update.append(winName)
+            self.mapWindow.update[winName] = None
 
         self.mapWindow.Refresh(False)
 
@@ -842,7 +842,7 @@
             self.settings['pos']['x'] = 0.0
             self.settings['pos']['y'] = 1.0
 
-        self.mapWindow.update.append('view')
+        self.mapWindow.update['view'] = None
         self.UpdateSettings()
         self.mapWindow.Refresh(False)
 
@@ -858,8 +858,16 @@
         
         Update map (don't save settings)
         """
-        pass
+        layer = self.mapWindow.GetSelectedLayer()
+        id = self.mapWindow.GetMapObjId(layer)
 
+        if self.mapWindow.update.has_key('color'):
+            map, value = self.mapWindow.update['color']
+            self.mapWindow.nvizClass.SetSurfaceColor(id, map, str(value)) 
+            del self.mapWindow.update['color']
+
+        self.mapWindow.Refresh(False)
+
     def OnClose(self, event):
         """Close button pressed
         
@@ -876,11 +884,15 @@
 
         if event.GetSelection() == 0:
             useMap = True
+            value = self.win['surface'][attrName]['map']
         else:
             useMap = False
+            value = self.win['surface'][attrName]['constant']
 
         self.SetSurfaceUseMap(attrName, useMap)
 
+        self.mapWindow.update[attrName] = (useMap, str(value))
+
     def SetSurfaceUseMap(self, attrName, map=True):
         if map: # map
             self.FindWindowById(self.win['surface'][attrName]['map']).Enable(True)
@@ -892,7 +904,7 @@
             self.FindWindowById(self.win['surface'][attrName]['use']).SetSelection(1)
 
     def OnSurfaceMap(self, event):
-        """Set surface attribute -- map"""
+        """Set surface attribute"""
         if not self.mapWindow.init:
             return
 
@@ -905,15 +917,14 @@
             map = True
         else:
             value = self.FindWindowById(self.win['surface'][attrName]['constant']).GetValue()
-            print value
+            value = str(value[0]) + ':' + str(value[1]) + ':' + str(value[2])
             map = False
 
-        layer = self.mapWindow.GetSelectedLayer()
-        id = self.mapWindow.GetMapObjId(layer)
+        self.mapWindow.update[attrName] = (map, str(value))
 
-        if attrName == 'color':
-            self.mapWindow.nvizClass.SetSurfaceColor(id, map, str(value)) 
-        
+        if self.parent.autoRender.IsChecked():
+            self.OnApply(None)
+
     def OnSurfaceMode(self, event):
         pass
 
@@ -997,7 +1008,7 @@
             y = float(y) / h
             self.settings['pos']['x'] = x
             self.settings['pos']['y'] = y
-            self.mapWindow.update.append('view')
+            self.mapWindow.update['view'] = None
 
             self.mapWindow.Refresh(eraseBackground=False)
             # self.mapWindow.UpdateMap()



More information about the grass-commit mailing list