[GRASS-SVN] r47063 - grass/trunk/visualization/nviz2/cmd
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Jul 8 10:27:22 EDT 2011
Author: annakrat
Date: 2011-07-08 07:27:22 -0700 (Fri, 08 Jul 2011)
New Revision: 47063
Modified:
grass/trunk/visualization/nviz2/cmd/args.c
grass/trunk/visualization/nviz2/cmd/local_proto.h
grass/trunk/visualization/nviz2/cmd/main.c
Log:
nviz_cmd: north arrow added
Modified: grass/trunk/visualization/nviz2/cmd/args.c
===================================================================
--- grass/trunk/visualization/nviz2/cmd/args.c 2011-07-08 13:34:04 UTC (rev 47062)
+++ grass/trunk/visualization/nviz2/cmd/args.c 2011-07-08 14:27:22 UTC (rev 47063)
@@ -32,6 +32,7 @@
static void args_lighting(struct GParams *);
static void args_fringe(struct GParams *);
static void args_cplane(struct GParams *);
+static void args_arrow(struct GParams *);
/*!
\brief Parse command
@@ -76,7 +77,10 @@
args_fringe(params);
/*** cutting plane ***/
- args_cplane(params);
+ args_cplane(params);
+
+ /*** north arrow ***/
+ args_arrow(params);
/*** output image ***/
/* output */
@@ -783,6 +787,35 @@
params->fringe_elev->answer = "55";
}
+void args_arrow(struct GParams *params)
+{
+ params->north_arrow = G_define_option();
+ params->north_arrow->key = "arow_position";
+ params->north_arrow->key_desc = "x,y";
+ params->north_arrow->type = TYPE_INTEGER;
+ params->north_arrow->required = NO;
+ params->north_arrow->multiple = NO;
+ params->north_arrow->description = _("Place north arrow at given position \
+ (in screen coordinates from bottom left corner)");
+ params->north_arrow->guisection = _("Decoration");
+
+ params->north_arrow_size = G_define_option();
+ params->north_arrow_size->key = "arow_size";
+ params->north_arrow_size->key_desc = "value";
+ params->north_arrow_size->type = TYPE_DOUBLE;
+ params->north_arrow_size->required = NO;
+ params->north_arrow_size->multiple = NO;
+ params->north_arrow_size->description = _("North arrow size (in map units)");
+ params->north_arrow_size->guisection = _("Decoration");
+
+ params->north_arrow_color = G_define_standard_option(G_OPT_C_FG);
+ params->north_arrow_color->key = "arow_color";
+ params->north_arrow_color->required = NO;
+ params->north_arrow_color->multiple = NO;
+ params->north_arrow_color->label = _("North arrow color");
+ params->north_arrow_color->guisection = _("Decoration");
+ params->north_arrow_color->answer = "black";
+}
/*!
\brief Get number of answers of given option
Modified: grass/trunk/visualization/nviz2/cmd/local_proto.h
===================================================================
--- grass/trunk/visualization/nviz2/cmd/local_proto.h 2011-07-08 13:34:04 UTC (rev 47062)
+++ grass/trunk/visualization/nviz2/cmd/local_proto.h 2011-07-08 14:27:22 UTC (rev 47063)
@@ -27,7 +27,7 @@
/* misc */
*exag, *bgcolor,
/* cutting planes */
- *cplane, *cplane_pos, *cplane_rot, *cplane_tilt, *cplane_shading,
+ *cplane, *cplane_pos, *cplane_rot, *cplane_tilt, *cplane_shading,
/* viewpoint */
*pos, *height, *persp, *twist, *focus,
/* output */
@@ -35,7 +35,9 @@
/* lighting */
*light_pos, *light_color, *light_bright, *light_ambient,
/* fringe */
- *fringe, *fringe_color, *fringe_elev;
+ *fringe, *fringe_color, *fringe_elev,
+ /* north arrow */
+ *north_arrow, *north_arrow_size, *north_arrow_color;
};
/* args.c */
Modified: grass/trunk/visualization/nviz2/cmd/main.c
===================================================================
--- grass/trunk/visualization/nviz2/cmd/main.c 2011-07-08 13:34:04 UTC (rev 47062)
+++ grass/trunk/visualization/nviz2/cmd/main.c 2011-07-08 14:27:22 UTC (rev 47063)
@@ -33,7 +33,8 @@
struct GParams *params;
int i, ret;
- int red, grn, blu;
+ int red, grn, blu, sx, sy;
+ float size;
double vp_height, z_exag; /* calculated viewpoint height, z-exag */
int width, height; /* output image size */
char *output_name;
@@ -191,7 +192,21 @@
Nviz_new_fringe(&data, -1, Nviz_color_from_str(params->fringe_color->answer),
atof(params->fringe_elev->answer), nw, ne, sw, se);
}
-
+
+ /* draw north arrow */
+ if (params->north_arrow->answer) {
+
+ if (!params->north_arrow_size->answer)
+ size = Nviz_get_longdim(&data) / 8.;
+ else
+ size = atof(params->north_arrow_size->answer);
+
+ Nviz_set_arrow(&data, atoi(params->north_arrow->answers[0]),
+ atoi(params->north_arrow->answers[1]),
+ size, Nviz_color_from_str(params->north_arrow_color->answer));
+ Nviz_draw_arrow(&data);
+ }
+
GS_clear(data.bgcolor);
/* cutting planes */
More information about the grass-commit
mailing list