[GRASS-SVN] r42639 - in grass/trunk: gui/wxpython/gui_modules include lib/nviz

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jun 23 04:44:27 EDT 2010


Author: martinl
Date: 2010-06-23 08:44:27 +0000 (Wed, 23 Jun 2010)
New Revision: 42639

Modified:
   grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
   grass/trunk/gui/wxpython/gui_modules/wxnviz.py
   grass/trunk/include/nviz.h
   grass/trunk/lib/nviz/nviz.c
Log:
wxGUI/nviz: set fringe color/elevation


Modified: grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_tools.py	2010-06-22 23:15:56 UTC (rev 42638)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_tools.py	2010-06-23 08:44:27 UTC (rev 42639)
@@ -1254,6 +1254,7 @@
             chkbox = wx.CheckBox(parent = panel,
                                  label = edge[0],
                                  name = edge[1])
+            self.win['fringe'][edge[1]] = chkbox.GetId()
             eboxSizer.Add(item = chkbox, proportion = 0,
                          flag = wx.ADJUST_MINSIZE | wx.LEFT | wx.RIGHT, border = 5)
             chkbox.Bind(wx.EVT_CHECKBOX, self.OnFringe)
@@ -1275,6 +1276,7 @@
         spin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
                            size = (65, -1), min = -1e6, max = 1e6)
         spin.SetValue(UserSettings.Get(group = 'nviz', key = 'fringe', subkey = 'elev'))
+        spin.Bind(wx.EVT_SPINCTRL, self.OnFringe)
         self.win['fringe']['elev'] = spin.GetId()
         gridSizer.Add(item = spin, pos = (0, 1))
         
@@ -1287,6 +1289,7 @@
                                   size = globalvar.DIALOG_COLOR_SIZE)
         color.SetColour(UserSettings.Get(group = 'nviz', key = 'fringe',
                                          subkey = 'color'))
+        color.Bind(csel.EVT_COLOURSELECT, self.OnFringe)
         self.win['fringe']['color'] = color.GetId()
         gridSizer.Add(item = color, pos = (1, 1))
         
@@ -1304,13 +1307,17 @@
         """!Show/hide fringe"""
         enabled = event.IsChecked()
         win = self.FindWindowById(event.GetId())
-        print win.GetName()
+        
         data = self.mapWindow.GetSelectedLayer(type = 'nviz')['surface']
         sid = data['object']['id']
         elev = self.FindWindowById(self.win['fringe']['elev']).GetValue()
         color = self.FindWindowById(self.win['fringe']['color']).GetValue()
         
-        self._display.SetFringe(sid, color, elev, True, True, True, True)
+        self._display.SetFringe(sid, color, elev,
+                                self.FindWindowById(self.win['fringe']['nw']).IsChecked(),
+                                self.FindWindowById(self.win['fringe']['ne']).IsChecked(),
+                                self.FindWindowById(self.win['fringe']['sw']).IsChecked(),
+                                self.FindWindowById(self.win['fringe']['se']).IsChecked())
         self.mapWindow.Refresh(False)
         
     def OnScroll(self, event, win, data):

Modified: grass/trunk/gui/wxpython/gui_modules/wxnviz.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxnviz.py	2010-06-22 23:15:56 UTC (rev 42638)
+++ grass/trunk/gui/wxpython/gui_modules/wxnviz.py	2010-06-23 08:44:27 UTC (rev 42639)
@@ -1129,7 +1129,7 @@
         @param nw,ne,sw,se fringe edges (turn on/off)
         """
         scolor = str(color[0]) + ':' + str(color[1]) + ':' + str(color[2])
-        Nviz_new_fringe(self.data,
+
+        Nviz_set_fringe(self.data,
                         sid, Nviz_color_from_str(scolor),
                         elev, int(nw), int(ne), int(sw), int(se))
-

Modified: grass/trunk/include/nviz.h
===================================================================
--- grass/trunk/include/nviz.h	2010-06-22 23:15:56 UTC (rev 42638)
+++ grass/trunk/include/nviz.h	2010-06-23 08:44:27 UTC (rev 42639)
@@ -174,6 +174,8 @@
 int Nviz_color_from_str(const char *);
 struct fringe_data *Nviz_new_fringe(nv_data *, int, unsigned long,
 				    double, int, int, int, int);
+struct fringe_data *Nviz_set_fringe(nv_data *, int, unsigned long,
+				    double, int, int, int, int);
 
 /* position.c */
 void Nviz_init_view(nv_data *);

Modified: grass/trunk/lib/nviz/nviz.c
===================================================================
--- grass/trunk/lib/nviz/nviz.c	2010-06-22 23:15:56 UTC (rev 42638)
+++ grass/trunk/lib/nviz/nviz.c	2010-06-23 08:44:27 UTC (rev 42639)
@@ -141,3 +141,51 @@
     
     return f;
 }
+
+/*! Set fringe
+
+  \param data nviz data
+  \param id surface id
+  \param color color
+  \param elev fringe elevation
+  \param nw,ne,sw,se 1 (turn on) 0 (turn off)
+
+  \return pointer to allocated fringe_data structure
+  \return NULL on error
+*/
+struct fringe_data *Nviz_set_fringe(nv_data *data,
+				    int id, unsigned long color,
+				    double elev, int nw, int ne, int sw, int se)
+{
+    int i, num;
+    int *surf;
+    struct fringe_data *f;
+
+    if (!GS_surf_exists(id)) {
+	/* select first surface from the list */
+	surf = GS_get_surf_list(&num);
+	if (num < 1)
+	    return NULL;
+	id = surf[0];
+    }
+    
+    for (i = 0; i < data->num_fringes; i++) {
+	f = data->fringe[i];
+	if (f->id == id) {
+	    f->color = color;
+	    f->elev  = elev;
+	    f->where[0] = nw;
+	    f->where[1] = ne;
+	    f->where[2] = sw;
+	    f->where[3] = se;
+	    
+	    return f;
+	}
+    }
+
+    f = Nviz_new_fringe(data,
+			id, color,
+			elev, nw, ne, sw, se);
+    
+    return f;
+}



More information about the grass-commit mailing list