[GRASS-SVN] r46868 - grass/trunk/visualization/nviz2/cmd

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jun 30 09:43:24 EDT 2011


Author: annakrat
Date: 2011-06-30 06:43:24 -0700 (Thu, 30 Jun 2011)
New Revision: 46868

Modified:
   grass/trunk/visualization/nviz2/cmd/args.c
   grass/trunk/visualization/nviz2/cmd/main.c
   grass/trunk/visualization/nviz2/cmd/surface.c
Log:
nviz_cmd: enable to use _map and _value surface commands concurrently for more surfaces

Modified: grass/trunk/visualization/nviz2/cmd/args.c
===================================================================
--- grass/trunk/visualization/nviz2/cmd/args.c	2011-06-30 12:23:09 UTC (rev 46867)
+++ grass/trunk/visualization/nviz2/cmd/args.c	2011-06-30 13:43:24 UTC (rev 46868)
@@ -528,7 +528,7 @@
     /* focus */
     params->focus = G_define_option();
     params->focus->key = "focus";
-    params->focus->key_desc = "x,y";
+    params->focus->key_desc = "x,y,z";
     params->focus->type = TYPE_DOUBLE;
     params->focus->required = NO;
     params->focus->multiple = NO;
@@ -918,7 +918,7 @@
 		 const char *elev_map, const char *elev_const,
 		 const char *map_name, const char *const_name)
 {
-    if ((nmaps > 0 && nelevs != nmaps) || (nconsts > 0 && nelevs != nconsts))
+    if ((nmaps + nconsts > 0) && (nelevs != nmaps + nconsts))
 	G_fatal_error(_("Inconsistent number of attributes (<%s/%s> %d: <%s> %d, <%s> %d"),
 		      elev_map, elev_const, nelevs, map_name, nmaps,
 		      const_name, nconsts);

Modified: grass/trunk/visualization/nviz2/cmd/main.c
===================================================================
--- grass/trunk/visualization/nviz2/cmd/main.c	2011-06-30 12:23:09 UTC (rev 46867)
+++ grass/trunk/visualization/nviz2/cmd/main.c	2011-06-30 13:43:24 UTC (rev 46868)
@@ -152,7 +152,8 @@
     Nviz_set_viewpoint_persp(atoi(params->persp->answer));
     if (params->focus->answer) {
     Nviz_set_focus(&data, atof(params->focus->answers[0]),
-                          atof(params->focus->answers[1]), 0);
+                          atof(params->focus->answers[1]), 
+                          atof(params->focus->answers[2]));
     }
 
     /* set lights */

Modified: grass/trunk/visualization/nviz2/cmd/surface.c
===================================================================
--- grass/trunk/visualization/nviz2/cmd/surface.c	2011-06-30 12:23:09 UTC (rev 46867)
+++ grass/trunk/visualization/nviz2/cmd/surface.c	2011-06-30 13:43:24 UTC (rev 46868)
@@ -40,11 +40,7 @@
     nelev_map = opt_get_num_answers(params->elev_map);
     nelev_const = opt_get_num_answers(params->elev_const);
 
-    if (nelev_map > 0)
-	nelevs = nelev_map;
-    else
-	nelevs = nelev_const;
-
+    nelevs = nelev_const + nelev_map;
     /* topography (required) */
     for (i = 0; i < nelevs; i++) {
 	/* check maps */
@@ -61,10 +57,10 @@
 				  0.0, data);
 	}
 	else {
-	    if (i < nelev_const && strcmp(params->elev_const->answers[i], "")) {
+	    if (i-nelev_map < nelev_const && strcmp(params->elev_const->answers[i-nelev_map], "")) {
 		id = Nviz_new_map_obj(MAP_OBJ_SURF,
 				      NULL,
-				      atof(params->elev_const->answers[i]),
+				      atof(params->elev_const->answers[i-nelev_map]),
 				      data);
 	    }
 	    else {
@@ -118,19 +114,25 @@
 			  data);
 	}
 	/* check for color value */
-	else if (i < ncolor_const &&
-		 strcmp(params->color_const->answers[i], "")) {
+	else if (i-ncolor_map < ncolor_const &&
+		 strcmp(params->color_const->answers[i-ncolor_map], "")) {
 	    Nviz_set_attr(id, MAP_OBJ_SURF, ATT_COLOR, CONST_ATT, NULL,
 			  Nviz_color_from_str(params->color_const->
-					      answers[i]), data);
+					      answers[i-ncolor_map]), data);
 	}
 	else {			/* use by default elevation map for coloring */
-	    Nviz_set_attr(id, MAP_OBJ_SURF, ATT_COLOR, MAP_ATT,
-			  G_fully_qualified_name(params->elev_map->answers[i],
-						 mapset), -1.0, data);
-	    G_verbose_message(_("Color attribute not defined, using default <%s>"),
-			      G_fully_qualified_name(params->elev_map->
-						     answers[i], mapset));
+        if (nelev_map > 0){
+            Nviz_set_attr(id, MAP_OBJ_SURF, ATT_COLOR, MAP_ATT,
+                G_fully_qualified_name(params->elev_map->answers[i],
+                            mapset), -1.0, data);
+            G_verbose_message(_("Color attribute not defined, using default <%s>"),
+                G_fully_qualified_name(params->elev_map->
+                                 answers[i], mapset));
+        }
+        else{
+            G_fatal_error(_("Missing color attribute for surface %d"),
+			      i + 1);
+        }
 	}
 	/* mask */
 	if (i < nmask_map && strcmp(params->mask_map->answers[i], "")) {
@@ -146,10 +148,10 @@
 						 answers[i], mapset), -1.0,
 			  data);
 	}
-	else if (i < ntransp_const &&
-		 strcmp(params->transp_const->answers[i], "")) {
+	else if (i-ntransp_map < ntransp_const &&
+		 strcmp(params->transp_const->answers[i-ntransp_map], "")) {
 	    Nviz_set_attr(id, MAP_OBJ_SURF, ATT_TRANSP, CONST_ATT, NULL,
-			  atof(params->transp_const->answers[i]), data);
+			  atof(params->transp_const->answers[i-ntransp_map]), data);
 	}
 
 	/* shininess */
@@ -159,10 +161,10 @@
 						 answers[i], mapset), -1.0,
 			  data);
 	}
-	else if (i < nshine_const &&
-		 strcmp(params->shine_const->answers[i], "")) {
+	else if (i-nshine_map < nshine_const &&
+		 strcmp(params->shine_const->answers[i-nshine_map], "")) {
 	    Nviz_set_attr(id, MAP_OBJ_SURF, ATT_SHINE, CONST_ATT, NULL,
-			  atof(params->shine_const->answers[i]), data);
+			  atof(params->shine_const->answers[i-nshine_map]), data);
 	}
 
 	/* emission */
@@ -171,10 +173,10 @@
 			  G_fully_qualified_name(params->emit_map->answers[i],
 						 mapset), -1.0, data);
 	}
-	else if (i < nemit_const &&
-		 strcmp(params->emit_const->answers[i], "")) {
+	else if (i-nemit_map < nemit_const &&
+		 strcmp(params->emit_const->answers[i-nemit_map], "")) {
 	    Nviz_set_attr(id, MAP_OBJ_SURF, ATT_EMIT, CONST_ATT, NULL,
-			  atof(params->emit_const->answers[i]), data);
+			  atof(params->emit_const->answers[i-nemit_map]), data);
 	}
 
 	/*



More information about the grass-commit mailing list