[GRASS-SVN] r68960 - grass/trunk/display/d.legend
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jul 14 11:39:21 PDT 2016
Author: annakrat
Date: 2016-07-14 11:39:21 -0700 (Thu, 14 Jul 2016)
New Revision: 68960
Modified:
grass/trunk/display/d.legend/draw.c
grass/trunk/display/d.legend/histogram.c
grass/trunk/display/d.legend/local_proto.h
grass/trunk/display/d.legend/main.c
Log:
fix problems from #3098 (by Adam Laza)
Modified: grass/trunk/display/d.legend/draw.c
===================================================================
--- grass/trunk/display/d.legend/draw.c 2016-07-14 18:18:24 UTC (rev 68959)
+++ grass/trunk/display/d.legend/draw.c 2016-07-14 18:39:21 UTC (rev 68960)
@@ -28,9 +28,8 @@
double tit_fontsize, const char *title, double *tick_values,
double t_step, int colorb, int colorbg, struct Option *opt_use,
struct Option *opt_at, struct Option *opt_fontsize,
- struct Option *opt_ticks, struct Option *opt_tstep,
- struct Option *opt_range, struct Flag *histo, struct Flag *hidestr,
- int log_sc, int draw, int digits)
+ struct Option *opt_tstep, struct Option *opt_range, struct Flag *histo,
+ struct Flag *hidestr, int log_sc, int draw, int digits)
{
char buff[512];
int black, white;
@@ -395,12 +394,10 @@
else{
if (!fp) {
if (!flip)
- tcell =
- min_ind + k * (double)(1 + max_ind -
- min_ind) / lleg;
+ tcell = min_ind + k * (double)(1 + max_ind - min_ind) / lleg;
else
- D_box_abs(x0, y0 + k, x0 - (dx ? -dx : 1),
- y0 + k + (dy ? -dy : 1));
+ tcell = (max_ind + 1) - k * (double)(1 + max_ind - min_ind) / lleg;
+ D_color((CELL) tcell, &colors);
}
else {
if (!flip)
@@ -424,8 +421,6 @@
if (!fp) { /* cut down labelnum so they don't repeat */
if (do_cats < steps)
steps = do_cats;
- if ((steps < 2))
- steps = 2; /* ward off the ppl floating point exception */
}
/* Draw text and ticks */
@@ -586,12 +581,18 @@
} /* for */
}
+ if (!fp) {
+ dmin = min_ind;
+ dmax = max_ind;
+ sprintf(DispFormat, "%s", "%.0f");
+ }
+
/* LABEL_VALUE OPTION */
if (ticksCount > 0) {
for (i = 0; i < ticksCount; i++) {
if ((tick_values[i] < dmin) || (tick_values[i] > dmax)) {
- G_fatal_error(_("tick_value=%s out of range [%.3f, %.3f]"),
- opt_ticks->answers[i], dmin, dmax);
+ G_fatal_error(_("tick_value=%.3f out of range [%.3f, %.3f]"),
+ tick_values[i], dmin, dmax);
}
sprintf(buff, DispFormat, tick_values[i]);
@@ -722,7 +723,7 @@
if (!flip) {
if (!horiz)
- while (t_start < dmax) {
+ while (t_start <= dmax) {
sprintf(buff, DispFormat, t_start);
D_text_size(txsiz, txsiz);
D_get_text_box(buff,&bb,&bt, &bl, &br);
@@ -746,7 +747,7 @@
t_start += t_step;
}
else
- while (t_start < dmax) {
+ while (t_start <= dmax) {
sprintf(buff, DispFormat, t_start);
D_text_size(txsiz, txsiz);
D_get_text_box(buff,&bb,&bt, &bl, &br);
@@ -774,7 +775,7 @@
}
else {
if (!horiz)
- while (t_start < dmax) {
+ while (t_start <= dmax) {
sprintf(buff, DispFormat, t_start);
D_text_size(txsiz, txsiz);
D_get_text_box(buff,&bb,&bt, &bl, &br);
@@ -799,7 +800,7 @@
t_start += t_step;
}
else
- while (t_start < dmax) {
+ while (t_start <= dmax) {
sprintf(buff, DispFormat, t_start);
D_text_size(txsiz, txsiz);
D_get_text_box(buff,&bb,&bt, &bl, &br);
@@ -964,8 +965,10 @@
y0bg = y0 - titsiz - max_hist;
}
- D_use_color(colorbg);
- D_box_abs(x0bg, y0bg, x1bg, y1bg);
+ if (colorbg != 0) {
+ D_use_color(colorbg);
+ D_box_abs(x0bg, y0bg, x1bg, y1bg);
+ }
D_use_color(colorb);
D_begin();
Modified: grass/trunk/display/d.legend/histogram.c
===================================================================
--- grass/trunk/display/d.legend/histogram.c 2016-07-14 18:18:24 UTC (rev 68959)
+++ grass/trunk/display/d.legend/histogram.c 2016-07-14 18:39:21 UTC (rev 68960)
@@ -232,27 +232,27 @@
if (horiz) {
if (flip)
- D_box_abs(x0 + width + y0_adjust + ((i - 1) * dy),
+ D_box_abs(x0 + width + y0_adjust + ((i - 2) * dy),
y0 - 1,
- x0 + width + y0_adjust + 1 + (i * dy),
+ x0 + width + y0_adjust + 1 + ((i - 1) * dy),
y0 - 1 - dx);
else
- D_box_abs(x0 + y0_adjust + ((i - 1) * dy),
+ D_box_abs(x0 + y0_adjust + ((i - 2) * dy),
y0 - 1,
- x0 - 1 + y0_adjust + (i * dy), y0 - 1 - dx);
+ x0 - 1 + y0_adjust + ((i - 1) * dy), y0 - 1 - dx);
}
else { /* vertical */
if (flip)
/* GRASS_EPSILON fudge around D_box_abs() weirdness + PNG driver */
D_box_abs(x0 - 1 - GRASS_EPSILON * 10,
- y0 + height + y0_adjust + ((i - 1) * dy),
+ y0 + height + y0_adjust + ((i - 2) * dy),
x0 - 1 - dx,
- y0 + height + y0_adjust + 1 + (i * dy));
+ y0 + height + y0_adjust + 1 + ((i - 1) * dy));
else
D_box_abs(x0 - 1 - GRASS_EPSILON * 10,
- y0 + y0_adjust + ((i - 1) * dy),
- x0 - 1 - dx, y0 + y0_adjust - 1 + (i * dy));
+ y0 + y0_adjust + ((i - 2) * dy),
+ x0 - 1 - dx, y0 + y0_adjust - 1 + ((i - 1) * dy));
}
}
}
Modified: grass/trunk/display/d.legend/local_proto.h
===================================================================
--- grass/trunk/display/d.legend/local_proto.h 2016-07-14 18:18:24 UTC (rev 68959)
+++ grass/trunk/display/d.legend/local_proto.h 2016-07-14 18:39:21 UTC (rev 68960)
@@ -42,4 +42,4 @@
double, int, int, double, double, double *, int, int, int, double,
double, const char *, double *, double, int, int, struct Option *,
struct Option *, struct Option *, struct Option *, struct Option *,
- struct Option *, struct Flag *, struct Flag *, int, int, int);
+ struct Flag *, struct Flag *, int, int, int);
Modified: grass/trunk/display/d.legend/main.c
===================================================================
--- grass/trunk/display/d.legend/main.c 2016-07-14 18:18:24 UTC (rev 68959)
+++ grass/trunk/display/d.legend/main.c 2016-07-14 18:39:21 UTC (rev 68960)
@@ -460,7 +460,7 @@
cats, colors, X0, X1, Y0, Y1, flip, UserRange, UserRangeMin,
UserRangeMax, catlist, catlistCount, use_catlist, ticksCount,
fontsize, tit_fontsize, title, tick_values, t_step, colorb,
- colorbg, opt_use, opt_at, opt_fontsize, opt_ticks, opt_tstep,
+ colorbg, opt_use, opt_at, opt_fontsize, opt_tstep,
opt_range, histo, hidestr, log_scale, 0, digits);
draw(map_name, maptype, color, thin, lines, steps, fp, label_indent,
@@ -468,7 +468,7 @@
colors, X0, X1, Y0, Y1, flip, UserRange, UserRangeMin, UserRangeMax,
catlist, catlistCount, use_catlist, ticksCount, fontsize,
tit_fontsize, title, tick_values, t_step, colorb, colorbg, opt_use,
- opt_at, opt_fontsize, opt_ticks, opt_tstep, opt_range, histo,
+ opt_at, opt_fontsize, opt_tstep, opt_range, histo,
hidestr, log_scale, 1, digits);
D_close_driver();
More information about the grass-commit
mailing list