[GRASS-SVN] r64303 - in grass/trunk: gui/wxpython/nviz include lib/ogsf

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jan 24 12:00:45 PST 2015


Author: annakrat
Date: 2015-01-24 12:00:44 -0800 (Sat, 24 Jan 2015)
New Revision: 64303

Modified:
   grass/trunk/gui/wxpython/nviz/mapwindow.py
   grass/trunk/gui/wxpython/nviz/tools.py
   grass/trunk/gui/wxpython/nviz/wxnviz.py
   grass/trunk/include/ogsf.h
   grass/trunk/lib/ogsf/gv.c
   grass/trunk/lib/ogsf/gv2.c
   grass/trunk/lib/ogsf/gvd.c
Log:
libogsf/wxGUI: fix selecting if render 3d lines as draped or as 3D

Modified: grass/trunk/gui/wxpython/nviz/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/mapwindow.py	2015-01-24 17:58:13 UTC (rev 64302)
+++ grass/trunk/gui/wxpython/nviz/mapwindow.py	2015-01-24 20:00:44 UTC (rev 64303)
@@ -2089,15 +2089,15 @@
                 'update' in data['mode']:
             width = data['width']['value']
             color = data['color']['value']
-            if data['mode']['type'] ==  'flat':
-                flat = True
+            if data['mode']['type'] ==  '3d':
+                use_3D = True
                 if 'surface' in data['mode']:
                     data['mode'].pop('surface')
             else:
-                flat = False
+                use_3D = False
             
             self._display.SetVectorLineMode(id, color,
-                                            width, flat)
+                                            width, use_3D)
             
             if 'update' in data['color']:
                 data['color'].pop('update')

Modified: grass/trunk/gui/wxpython/nviz/tools.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/tools.py	2015-01-24 17:58:13 UTC (rev 64302)
+++ grass/trunk/gui/wxpython/nviz/tools.py	2015-01-24 20:00:44 UTC (rev 64303)
@@ -1298,8 +1298,8 @@
         
         display = wx.Choice (parent = panel, id = wx.ID_ANY, size = (-1, -1),
                              choices = [_("on surface(s):"),
-                                        _("flat")])
-        self.win['vector']['lines']['flat'] = display.GetId()
+                                        _("as 3D")])
+        self.win['vector']['lines']['3d'] = display.GetId()
         display.Bind(wx.EVT_CHOICE, self.OnVectorLinesMode)
         
         gridSizer.Add(item = display, flag = wx.ALIGN_CENTER_VERTICAL | 
@@ -3435,12 +3435,12 @@
         event.Skip()
     
     def OnVectorLinesMode(self, event):
-        """Display vector lines on surface/flat"""
+        """Display vector lines on surface/3d"""
         rasters = self.mapWindow.GetLayerNames('raster')
         if event.GetSelection() == 0: # surface
             if len(rasters) < 1:
                 self.FindWindowById(self.win['vector']['lines']['surface']).Enable(False)
-                self.FindWindowById(self.win['vector']['lines']['flat']).SetSelection(1)
+                self.FindWindowById(self.win['vector']['lines']['3d']).SetSelection(1)
                 return
             
             self.FindWindowById(self.win['vector']['lines']['surface']).Enable(True)
@@ -3449,7 +3449,7 @@
             data['vector']['lines']['mode']['surface'] = rasters[0]
             self.FindWindowById(self.win['vector']['lines']['surface']).SetStringSelection( \
                 rasters[0])
-        else: # flat
+        else: # 3D
             self.FindWindowById(self.win['vector']['lines']['surface']).Enable(False)
         
         self.OnVectorLines(event)
@@ -3462,7 +3462,7 @@
         width = self.FindWindowById(self.win['vector']['lines']['width']).GetValue()
         
         mode = {}
-        if self.FindWindowById(self.win['vector']['lines']['flat']).GetSelection() == 0:
+        if self.FindWindowById(self.win['vector']['lines']['3d']).GetSelection() == 0:
             mode['type'] = 'surface'
             mode['surface'] = {}
             checklist = self.FindWindowById(self.win['vector']['lines']['surface'])
@@ -3475,7 +3475,7 @@
             mode['surface']['value'] = value
             mode['surface']['show'] = checked
         else:
-            mode['type'] = 'flat'
+            mode['type'] = '3d'
         
         for attrb in ('width', 'mode'):
             data['vector']['lines'][attrb]['update'] = None
@@ -3503,7 +3503,7 @@
         if event.GetSelection() == 0: # surface
             if len(rasters) < 1:
                 self.FindWindowById(self.win['vector']['points']['surface']).Enable(False)
-                self.FindWindowById(self.win['vector']['points']['flat']).SetSelection(1)
+                self.FindWindowById(self.win['vector']['points']['3d']).SetSelection(1)
                 return
 
             self.FindWindowById(self.win['vector']['points']['surface']).Enable(True)
@@ -4762,7 +4762,7 @@
             self.FindWindowById(self.win['vector']['map']).SetValue(layer.name)
         self.FindWindowById(self.win['vector']['desc']).SetLabel(desc)
         
-        self.FindWindowById(self.win['vector']['lines']['flat']).Enable(enable)
+        self.FindWindowById(self.win['vector']['lines']['3d']).Enable(enable)
         for v in ('lines', 'points'):
             self.FindWindowById(self.win['vector'][v]['surface']).Enable(enable)
             self.FindWindowById(self.win['vector'][v]['height']['slider']).Enable(enable)
@@ -4801,8 +4801,13 @@
         
         for vtype in ('lines', 'points'):
             if vtype == 'lines':
-                display = self.FindWindowById(self.win['vector']['lines']['flat'])
-                if data[vtype]['mode']['type'] == 'flat':
+                display = self.FindWindowById(self.win['vector']['lines']['3d'])
+                if vInfo['map3d']:
+                    items = [_("on surface(s):"), _("as 3D")]
+                else:
+                    items = [_("on surface")]
+                display.SetItems(items)               
+                if data[vtype]['mode']['type'] == '3d':
                     display.SetSelection(1)
                 else:
                     display.SetSelection(0)

Modified: grass/trunk/gui/wxpython/nviz/wxnviz.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/wxnviz.py	2015-01-24 17:58:13 UTC (rev 64302)
+++ grass/trunk/gui/wxpython/nviz/wxnviz.py	2015-01-24 20:00:44 UTC (rev 64303)
@@ -845,13 +845,13 @@
         
         return 1
 
-    def SetVectorLineMode(self, id, color_str, width, flat):
+    def SetVectorLineMode(self, id, color_str, width, use_z):
         """Set mode of vector line overlay
         
         :param id: vector id
         :param color_str: color string
         :param width: line width
-        :param flat: display flat or on surface
+        :param use_z: display 3d or on surface
         
         :return: -1 vector set not found
         :return: -2 on failure
@@ -860,13 +860,13 @@
         if not GV_vect_exists(id):
             return -1
         
-        Debug.msg(3, "Nviz::SetVectorMode(): id=%d, color=%s, width=%d, flat=%d",
-                  id, color_str, width, flat)
+        Debug.msg(3, "Nviz::SetVectorMode(): id=%d, color=%s, width=%d, use_z=%d",
+                  id, color_str, width, use_z)
         
         color = Nviz_color_from_str(color_str)
         
         # use memory by default
-        if GV_set_style(id, 1, color, width, flat) < 0:
+        if GV_set_style(id, 1, color, width, use_z) < 0:
             return -2
         
         return 1

Modified: grass/trunk/include/ogsf.h
===================================================================
--- grass/trunk/include/ogsf.h	2015-01-24 17:58:13 UTC (rev 64302)
+++ grass/trunk/include/ogsf.h	2015-01-24 20:00:44 UTC (rev 64303)
@@ -332,7 +332,7 @@
     int gvect_id;
     int use_mem, n_lines;
     int drape_surf_id[MAX_SURFS];	/* if you want 'em flat, define the surface */
-    int flat_val;
+    int use_z;
     int n_surfs;
     char *filename;
     float x_trans, y_trans, z_trans;

Modified: grass/trunk/lib/ogsf/gv.c
===================================================================
--- grass/trunk/lib/ogsf/gv.c	2015-01-24 17:58:13 UTC (rev 64302)
+++ grass/trunk/lib/ogsf/gv.c	2015-01-24 20:00:44 UTC (rev 64303)
@@ -195,7 +195,7 @@
     gv->x_trans = gv->y_trans = gv->z_trans = 0.0;
     gv->lines = NULL;
     gv->fastlines = NULL;
-    gv->flat_val = 0;
+    gv->use_z = 0;
     gv->style->color = 0xF0F0F0;
     gv->style->width = 1;
     gv->style->next = NULL;

Modified: grass/trunk/lib/ogsf/gv2.c
===================================================================
--- grass/trunk/lib/ogsf/gv2.c	2015-01-24 17:58:13 UTC (rev 64302)
+++ grass/trunk/lib/ogsf/gv2.c	2015-01-24 20:00:44 UTC (rev 64303)
@@ -220,12 +220,12 @@
    \param mem non-zero for use memory
    \param color color value
    \param width line width
-   \param flat non-zero for flat mode
+   \param use_z non-zero for 3d mode
 
    \return -1 on error (invalid vector set id)
    \return 1 on success
  */
-int GV_set_style(int id, int mem, int color, int width, int flat)
+int GV_set_style(int id, int mem, int color, int width, int use_z)
 {
     geovect *gv;
 
@@ -234,7 +234,7 @@
     }
 
     gv->use_mem = mem;
-    gv->flat_val = flat;
+    gv->use_z = use_z;
     gv->style->color = color;
     gv->style->width = width;
 
@@ -249,12 +249,12 @@
    \param[out] mem non-zero for use memory
    \param[out] color color value
    \param[out] width line width
-   \param[out] flat non-zero for flat mode
+   \param[out] use_z non-zero for 3d mode
 
    \return -1 on error (invalid vector set id)
    \return 1 on success
  */
-int GV_get_style(int id, int *mem, int *color, int *width, int *flat)
+int GV_get_style(int id, int *mem, int *color, int *width, int *use_z)
 {
     geovect *gv;
 
@@ -265,7 +265,7 @@
     *mem = gv->use_mem;
     *color = gv->style->color;
     *width = gv->style->width;
-    *flat = gv->flat_val;
+    *use_z = gv->use_z;
 
     return 1;
 }

Modified: grass/trunk/lib/ogsf/gvd.c
===================================================================
--- grass/trunk/lib/ogsf/gvd.c	2015-01-24 17:58:13 UTC (rev 64302)
+++ grass/trunk/lib/ogsf/gvd.c	2015-01-24 20:00:44 UTC (rev 64303)
@@ -160,13 +160,22 @@
 	/* line */
 	if (gln->type == OGSF_LINE) {	
 	    /* 2D line */
-	    if (gln->dims == 2) {	
+	    if (gln->dims == 2 || !gv->use_z) {
 		G_debug(5, "gvd_vect(): 2D vector line");
 		for (k = 0; k < gln->npts - 1; k++) {
-		    bgn[X] = gln->p2[k][X] + gv->x_trans - gs->ox;
-		    bgn[Y] = gln->p2[k][Y] + gv->y_trans - gs->oy;
-		    end[X] = gln->p2[k + 1][X] + gv->x_trans - gs->ox;
-		    end[Y] = gln->p2[k + 1][Y] + gv->y_trans - gs->oy;
+		    if (gln->dims == 3)
+		    {
+			bgn[X] = gln->p3[k][X] + gv->x_trans - gs->ox;
+			bgn[Y] = gln->p3[k][Y] + gv->y_trans - gs->oy;
+			end[X] = gln->p3[k + 1][X] + gv->x_trans - gs->ox;
+			end[Y] = gln->p3[k + 1][Y] + gv->y_trans - gs->oy;
+		    }
+		    else {
+			bgn[X] = gln->p2[k][X] + gv->x_trans - gs->ox;
+			bgn[Y] = gln->p2[k][Y] + gv->y_trans - gs->oy;
+			end[X] = gln->p2[k + 1][X] + gv->x_trans - gs->ox;
+			end[Y] = gln->p2[k + 1][Y] + gv->y_trans - gs->oy;
+		    }
 
 		    if (src == MAP_ATT) {
 			points = gsdrape_get_segments(gs, bgn, end, &npts);



More information about the grass-commit mailing list