[GRASS-SVN] r54190 - grass-addons/grass6/display/d.barb
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Dec 4 20:58:58 PST 2012
Author: hamish
Date: 2012-12-04 20:58:58 -0800 (Tue, 04 Dec 2012)
New Revision: 54190
Modified:
grass-addons/grass6/display/d.barb/draw.c
grass-addons/grass6/display/d.barb/grid.c
grass-addons/grass6/display/d.barb/legend.c
grass-addons/grass6/display/d.barb/local_proto.h
grass-addons/grass6/display/d.barb/main.c
grass-addons/grass6/display/d.barb/points.c
Log:
implement smaller barbs
Modified: grass-addons/grass6/display/d.barb/draw.c
===================================================================
--- grass-addons/grass6/display/d.barb/draw.c 2012-12-04 19:43:50 UTC (rev 54189)
+++ grass-addons/grass6/display/d.barb/draw.c 2012-12-05 04:58:58 UTC (rev 54190)
@@ -11,6 +11,7 @@
void draw_barb(double easting, double northing, double velocity,
double compass_deg, int color, double scale, int style)
{
+ double radius;
G_debug(3, "in draw_barb()");
//dbg: unknown_(594578,4920392);
@@ -20,7 +21,7 @@
R_move_abs((int)(D_u_to_d_col(easting) + 0.5),
(int)(D_u_to_d_row(northing) + 0.5));
- if (style != TYPE_BARB) {
+ if (style == TYPE_ARROW || style == TYPE_STRAW) {
if (velocity == velocity) /* ie not NaN */
arrow_mag(easting, northing, compass_deg, velocity, style);
else
@@ -31,14 +32,18 @@
/* calc barb parameters */
//dbg: compass_deg=0;
/* draw barb bits */
- draw_circle(easting, northing, 10.0, FALSE);
- draw_feather(easting, northing, 10.0 /*radius */ , velocity,
+ if (style == TYPE_SMLBARB)
+ radius = 5.0;
+ else
+ radius = 10.0;
+
+ draw_circle(easting, northing, radius, FALSE);
+ draw_feather(easting, northing, radius, velocity,
compass_deg);
//dbg: int i;
// for (i=0; i < 360; i+=20)
// draw_feather(easting, northing, 20.0 /*radius*/, velocity, i);
-
}
return;
Modified: grass-addons/grass6/display/d.barb/grid.c
===================================================================
--- grass-addons/grass6/display/d.barb/grid.c 2012-12-04 19:43:50 UTC (rev 54189)
+++ grass-addons/grass6/display/d.barb/grid.c 2012-12-05 04:58:58 UTC (rev 54190)
@@ -32,7 +32,7 @@
G_fatal_error(_("Problem reading range file"));
G_get_fp_range_min_max(&range, &mag_min, &mag_max);
- if (style != TYPE_BARB) {
+ if (style == TYPE_ARROW || style == TYPE_STRAW) {
scale *= 1.5 / fabs(mag_max);
}
G_debug(3, "scaling=%.2f rast_max=%.2f", scale, mag_max);
Modified: grass-addons/grass6/display/d.barb/legend.c
===================================================================
--- grass-addons/grass6/display/d.barb/legend.c 2012-12-04 19:43:50 UTC (rev 54189)
+++ grass-addons/grass6/display/d.barb/legend.c 2012-12-05 04:58:58 UTC (rev 54190)
@@ -17,7 +17,7 @@
G_debug(1, "Doing legend ... (%d entries)", num_velos);
- if (style == TYPE_BARB)
+ if (style == TYPE_BARB || style == TYPE_SMLBARB)
angle = -90;
else
angle = 90;
@@ -55,7 +55,7 @@
/* X: right justify the text + 10px buffer (a wee bit more for wind barbs) */
/* text width is 0.81 of text height? so even though we set width
to txsiz with R_text_size(), we still have to reduce.. hmmm */
- if (style == TYPE_BARB)
+ if (style == TYPE_BARB || style == TYPE_SMLBARB)
R_move_rel(-20 - (strlen(buff) * key_fontsize * 0.81), 0);
else
R_move_rel(-10 - (strlen(buff) * key_fontsize * 0.81), 0);
Modified: grass-addons/grass6/display/d.barb/local_proto.h
===================================================================
--- grass-addons/grass6/display/d.barb/local_proto.h 2012-12-04 19:43:50 UTC (rev 54189)
+++ grass-addons/grass6/display/d.barb/local_proto.h 2012-12-05 04:58:58 UTC (rev 54190)
@@ -8,7 +8,8 @@
/* barb flavours */
#define TYPE_STRAW 0
#define TYPE_BARB 1
-#define TYPE_ARROW 2
+#define TYPE_SMLBARB 2
+#define TYPE_ARROW 3
#define RpD ((2 * M_PI) / 360.) /* radians/degree */
#define D2R(d) (double)(d * RpD) /* degrees->radians */
Modified: grass-addons/grass6/display/d.barb/main.c
===================================================================
--- grass-addons/grass6/display/d.barb/main.c 2012-12-04 19:43:50 UTC (rev 54189)
+++ grass-addons/grass6/display/d.barb/main.c 2012-12-05 04:58:58 UTC (rev 54190)
@@ -7,7 +7,7 @@
* AUTHORS: Hamish Bowman, Dunedin, New Zealand
* Grid code derived from d.rast.arrow
*
- * COPYRIGHT: (c) 2008-2011 by Hamish Bowman, and The GRASS Development Team
+ * COPYRIGHT: (c) 2008-2012 by Hamish Bowman, and The GRASS Development Team
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
* for details.
@@ -86,7 +86,7 @@
style_opt->key = "style";
style_opt->type = TYPE_STRING;
style_opt->answer = "arrow";
- style_opt->options = "arrow,barb,straw";
+ style_opt->options = "arrow,barb,small_barb,straw";
style_opt->description = _("Style");
color_opt = G_define_standard_option(G_OPT_C_FG);
@@ -206,6 +206,8 @@
style = TYPE_ARROW;
else if (G_strcasecmp(style_opt->answer, "barb") == 0)
style = TYPE_BARB;
+ else if (G_strcasecmp(style_opt->answer, "small_barb") == 0)
+ style = TYPE_SMLBARB;
else if (G_strcasecmp(style_opt->answer, "straw") == 0)
style = TYPE_STRAW;
else
Modified: grass-addons/grass6/display/d.barb/points.c
===================================================================
--- grass-addons/grass6/display/d.barb/points.c 2012-12-04 19:43:50 UTC (rev 54189)
+++ grass-addons/grass6/display/d.barb/points.c 2012-12-05 04:58:58 UTC (rev 54190)
@@ -78,10 +78,11 @@
peak = max_magnitude(magn, num_pts);
G_debug(2, " peak = %.2f", peak);
- if (style == TYPE_BARB && peak > 150)
- G_warning(_("Maximum wind barb displayed is 150 knots"));
+ if (style == TYPE_BARB || style == TYPE_SMLBARB) {
+ if(peak > 150)
+ G_warning(_("Maximum wind barb displayed is 150 knots"));
+ }
-
peak = 1.; // TODO: window width * 0.20
scale_fact = (peak) * scale;
More information about the grass-commit
mailing list