[GRASS-SVN] r57717 - grass/trunk/display/d.barscale
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Sep 16 21:52:55 PDT 2013
Author: hamish
Date: 2013-09-16 21:52:55 -0700 (Mon, 16 Sep 2013)
New Revision: 57717
Removed:
grass/trunk/display/d.barscale/draw_n_arrow.c
Modified:
grass/trunk/display/d.barscale/d.barscale.html
grass/trunk/display/d.barscale/main.c
grass/trunk/display/d.barscale/options.h
Log:
remove north arrow code (now in d.northarrow), bugfix font size scanning to allow sub-integer sizes
Modified: grass/trunk/display/d.barscale/d.barscale.html
===================================================================
--- grass/trunk/display/d.barscale/d.barscale.html 2013-09-17 04:44:05 UTC (rev 57716)
+++ grass/trunk/display/d.barscale/d.barscale.html 2013-09-17 04:52:55 UTC (rev 57717)
@@ -2,17 +2,12 @@
<em>d.barscale</em> displays a barscale on the graphics monitor at the
given screen coordinates. If no coordinates are given it will draw the
-barscale in the bottom left of the display. It can draw the scale or
-north arrow in a number of styles (see
-the <a href="http://grasswiki.osgeo.org/wiki/Cartography#Display_monitors">wiki
+barscale in the bottom left of the display. It can draw the scale in a
+number of styles (see the
+ <a href="http://grasswiki.osgeo.org/wiki/Cartography#Display_monitors">wiki
page</a> for details).
-<p>
-If the <b>-n</b> flag is given, <em>d.barscale</em> draws a north arrow
-instead of a barscale. The style of north arrow can be controlled using
-the <b>north_arrow</b> parameter.
-
<h2>NOTE</h2>
<em>d.barscale</em> will not work in Lat/Lon locations as the horizontal
@@ -26,9 +21,11 @@
<a href="d.graph.html">d.graph</a>,
<a href="d.grid.html">d.grid</a>,
<a href="d.legend.html">d.legend</a>,
+<a href="d.northarrow.html">d.northarrow</a>,
<a href="g.region.html">g.region</a>
</em>
+
<h2>AUTHOR</h2>
unknown, but from USACE/CERL.<br>
Deleted: grass/trunk/display/d.barscale/draw_n_arrow.c
===================================================================
--- grass/trunk/display/d.barscale/draw_n_arrow.c 2013-09-17 04:44:05 UTC (rev 57716)
+++ grass/trunk/display/d.barscale/draw_n_arrow.c 2013-09-17 04:52:55 UTC (rev 57717)
@@ -1,144 +0,0 @@
-/*
- * draw_n_arrow() places a north arrow somewhere in the display frame
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <grass/gis.h>
-#include <grass/display.h>
-#include <grass/symbol.h>
-#include <grass/colors.h>
-#include <grass/glocale.h>
-#include "options.h"
-
-int draw_n_arrow(double east, double north, double fontsize, char *n_arrow_num)
-{
- double x_pos, y_pos;
- double t, b, l, r;
- double tt, tb, tl, tr; /* text box*/
-
- SYMBOL *Symb;
- RGBA_Color *line_color, *fill_color;
- int R, G, B;
- double x0, y0;
- char icon[64];
- double symbol_size;
-
-
- /* Establish text size */
- if (fontsize > 0)
- D_text_size(fontsize, fontsize);
-
- D_setup_unity(0);
- D_get_src(&t, &b, &l, &r);
-
- x_pos = east * (r - l) / 100.;
- y_pos = (100. - north) * (b - t) / 100.;
-
- if (fontsize > 0) {
- /* draw the "N" */
- D_get_text_box("N", &tt, &tb, &tl, &tr);
- D_use_color(fg_color);
-
- /* positions manually tuned */
- switch (n_arrow_num[0]) {
- case '1':
- D_pos_abs(x_pos - (tr + tl) / 2, y_pos - 45);
- D_text("N");
- break;
- case '3':
- D_pos_abs(x_pos - (tr + tl) / 2, y_pos - 60);
- D_text("N");
- break;
- case '4':
- D_pos_abs(x_pos - (tr + tl) / 2, y_pos - 45);
- D_text("N");
- break;
- case '7':
- D_pos_abs(x_pos - (tr + tl) / 2, y_pos - 70);
- D_text("N");
- break;
- case '9':
- D_pos_abs(x_pos - (tr + tl) / 2, y_pos - 55);
- D_text("N");
- case '2':
- case '5':
- case '6':
- case '8':
- break;
- default:
- G_fatal_error(_("Could not parse symbol"));
- }
- }
-
- /* display the north arrow symbol */
- line_color = G_malloc(sizeof(RGBA_Color));
- fill_color = G_malloc(sizeof(RGBA_Color));
-
- if (D_color_number_to_RGB(fg_color, &R, &G, &B) == 0)
- /* fall back to black on failure */
- G_str_to_color(DEFAULT_FG_COLOR, &R, &G, &B);
- line_color->r = (unsigned char)R;
- line_color->g = (unsigned char)G;
- line_color->b = (unsigned char)B;
- line_color->a = RGBA_COLOR_OPAQUE;
-
- if (D_color_number_to_RGB(fg_color, &R, &G, &B) == 0)
- /* fall back to black on failure */
- G_str_to_color(DEFAULT_FG_COLOR, &R, &G, &B);
- fill_color->r = (unsigned char)R;
- fill_color->g = (unsigned char)G;
- fill_color->b = (unsigned char)B;
- fill_color->a = RGBA_COLOR_OPAQUE;
-
- if (n_arrow_num[0] == '2' || n_arrow_num[0] == '9')
- fill_color->a = RGBA_COLOR_TRANSPARENT;
-
- /* sizes manually tuned */
- switch (n_arrow_num[0]) {
- case '1':
- symbol_size = 35.;
- break;
- case '2':
- symbol_size = 19.;
- break;
- case '3':
- symbol_size = 20.;
- break;
- case '4':
- symbol_size = 15.;
- break;
- case '5':
- case '6':
- symbol_size = 14.;
- break;
- case '7':
- symbol_size = 23.;
- break;
- case '8':
- case '9':
- symbol_size = 17.;
- break;
- default:
- G_fatal_error(_("Could not parse symbol"));
- }
-
- x0 = D_d_to_u_col(x_pos);
- y0 = D_d_to_u_row(y_pos);
-
- strcpy(icon, "n_arrows/n_arrow");
- strncat(icon, n_arrow_num, 32);
- Symb = S_read(icon);
-
- if(!Symb)
- G_fatal_error(_("Could not read symbol \"%s\""), icon);
-
- S_stroke(Symb, symbol_size, 0.0, 0);
- D_symbol(Symb, x0, y0, line_color, fill_color);
-
- G_free(Symb);
- G_free(line_color);
- G_free(fill_color);
-
- return 0;
-}
Modified: grass/trunk/display/d.barscale/main.c
===================================================================
--- grass/trunk/display/d.barscale/main.c 2013-09-17 04:44:05 UTC (rev 57716)
+++ grass/trunk/display/d.barscale/main.c 2013-09-17 04:52:55 UTC (rev 57717)
@@ -13,7 +13,7 @@
* Jan-Oliver Wagner <jan intevation.de>
* Major rewrite for GRASS 7 by Hamish Bowman, June 2013
*
- * PURPOSE: Displays a barscale or north arrow on graphics monitor
+ * PURPOSE: Displays a barscale on graphics monitor
*
* COPYRIGHT: (C) 1999-2013 by the GRASS Development Team
*
@@ -40,8 +40,8 @@
{
struct GModule *module;
struct Option *bg_color_opt, *fg_color_opt, *coords, *fsize,
- *barstyle, *text_placement, *n_arrow;
- struct Flag *feet, *northarrow, *no_text;
+ *barstyle, *text_placement;
+ struct Flag *feet, *no_text;
struct Cell_head W;
double east, north;
double fontsize;
@@ -53,17 +53,12 @@
module = G_define_module();
G_add_keyword(_("display"));
G_add_keyword(_("cartography"));
- module->description = _("Displays a barscale or north arrow on the graphics monitor.");
+ module->description = _("Displays a barscale on the graphics monitor.");
feet = G_define_flag();
feet->key = 'f';
feet->description = _("Use feet/miles instead of meters");
- northarrow = G_define_flag();
- northarrow->key = 'n';
- northarrow->description = _("Draw a north arrow only");
- northarrow->guisection = _("Style");
-
no_text = G_define_flag();
no_text->key = 't';
no_text->description = _("Draw the scale bar without text");
@@ -89,7 +84,7 @@
coords->description = _("(0,0) is lower-left of the display frame");
fg_color_opt = G_define_standard_option(G_OPT_C_FG);
- fg_color_opt->label = _("Bar scale, text, and north arrow color");
+ fg_color_opt->label = _("Bar scale and text color");
fg_color_opt->guisection = _("Colors");
bg_color_opt = G_define_standard_option(G_OPT_C_BG);
@@ -112,19 +107,12 @@
fsize->description = _("Font size");
fsize->guisection = _("Text");
- n_arrow = G_define_option();
- n_arrow->key = "north_arrow";
- n_arrow->description = _("North arrow style (used only with the -n flag)");
- n_arrow->options = "1a,1b,2,3,4,5,6,7a,7b,8a,8b,9";
- n_arrow->answer = "1a";
- n_arrow->guisection = _("Style");
-
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
G_get_window(&W);
- if (W.proj == PROJECTION_LL && !northarrow->answer)
+ if (W.proj == PROJECTION_LL)
G_fatal_error(_("%s does not work with a latitude-longitude location"),
argv[0]);
@@ -171,10 +159,6 @@
G_fatal_error(_("Programmer error"));
}
- if (northarrow->answer)
- bar_style = STYLE_NONE;
-
-
switch (text_placement->answer[0]) {
case 'u':
text_position = TEXT_UNDER;
@@ -195,7 +179,7 @@
sscanf(coords->answers[0], "%lf", &east);
sscanf(coords->answers[1], "%lf", &north);
- fontsize = atoi(fsize->answer);
+ fontsize = atof(fsize->answer);
if (no_text->answer)
fontsize = -1;
@@ -214,10 +198,7 @@
D_setup(0);
- if (bar_style == STYLE_NONE)
- draw_n_arrow(east, north, fontsize, n_arrow->answer);
- else
- draw_scale(east, north, bar_style, text_position, fontsize);
+ draw_scale(east, north, bar_style, text_position, fontsize);
D_save_command(G_recreate_command());
Modified: grass/trunk/display/d.barscale/options.h
===================================================================
--- grass/trunk/display/d.barscale/options.h 2013-09-17 04:44:05 UTC (rev 57716)
+++ grass/trunk/display/d.barscale/options.h 2013-09-17 04:52:55 UTC (rev 57717)
@@ -28,6 +28,3 @@
/* draw_scale.c */
int draw_scale(double, double, int, int, double);
-
-/* draw_n_arrow.c */
-int draw_n_arrow(double, double, double, char *);
More information about the grass-commit
mailing list