[GRASS-SVN] r44565 - grass-addons/postscript/ps.output
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Dec 8 18:19:08 EST 2010
Author: hamish
Date: 2010-12-08 15:19:08 -0800 (Wed, 08 Dec 2010)
New Revision: 44565
Modified:
grass-addons/postscript/ps.output/cat_val.c
grass-addons/postscript/ps.output/colors.c
grass-addons/postscript/ps.output/eps.c
grass-addons/postscript/ps.output/fonts.c
grass-addons/postscript/ps.output/format.c
grass-addons/postscript/ps.output/frames.c
grass-addons/postscript/ps.output/input.c
grass-addons/postscript/ps.output/legends.c
grass-addons/postscript/ps.output/load_raster.c
grass-addons/postscript/ps.output/local_proto.h
grass-addons/postscript/ps.output/main.c
grass-addons/postscript/ps.output/palettes.c
grass-addons/postscript/ps.output/palettes.h
grass-addons/postscript/ps.output/papers.c
grass-addons/postscript/ps.output/proj_geo.c
grass-addons/postscript/ps.output/ps3_map.c
grass-addons/postscript/ps.output/ps_info.h
grass-addons/postscript/ps.output/r_block.c
grass-addons/postscript/ps.output/r_draw.c
grass-addons/postscript/ps.output/r_font.c
grass-addons/postscript/ps.output/r_frame.c
grass-addons/postscript/ps.output/r_grid.c
grass-addons/postscript/ps.output/r_line.c
grass-addons/postscript/ps.output/r_maparea.c
grass-addons/postscript/ps.output/r_note.c
grass-addons/postscript/ps.output/r_palette.c
grass-addons/postscript/ps.output/r_paper.c
grass-addons/postscript/ps.output/r_raster.c
grass-addons/postscript/ps.output/r_rlegend.c
grass-addons/postscript/ps.output/r_scalebar.c
grass-addons/postscript/ps.output/r_vareas.c
grass-addons/postscript/ps.output/r_vlabels.c
grass-addons/postscript/ps.output/r_vlegend.c
grass-addons/postscript/ps.output/r_vlines.c
grass-addons/postscript/ps.output/r_vpoints.c
grass-addons/postscript/ps.output/raster.c
grass-addons/postscript/ps.output/scanners.c
grass-addons/postscript/ps.output/set_draw.c
grass-addons/postscript/ps.output/set_geogrid.c
grass-addons/postscript/ps.output/set_grid.c
grass-addons/postscript/ps.output/set_mask.c
grass-addons/postscript/ps.output/set_note.c
grass-addons/postscript/ps.output/set_outline.c
grass-addons/postscript/ps.output/set_ps.c
grass-addons/postscript/ps.output/set_raster.c
grass-addons/postscript/ps.output/set_rlegend.c
grass-addons/postscript/ps.output/set_scalebar.c
grass-addons/postscript/ps.output/set_vareas.c
grass-addons/postscript/ps.output/set_vector.c
grass-addons/postscript/ps.output/set_vlabels.c
grass-addons/postscript/ps.output/set_vlegend.c
grass-addons/postscript/ps.output/set_vlines.c
grass-addons/postscript/ps.output/set_vpoints.c
grass-addons/postscript/ps.output/start_map.c
grass-addons/postscript/ps.output/symbol.c
grass-addons/postscript/ps.output/val_list.c
grass-addons/postscript/ps.output/vector.c
grass-addons/postscript/ps.output/vpoints.h
Log:
run tools/grass_indent.sh
Modified: grass-addons/postscript/ps.output/cat_val.c
===================================================================
--- grass-addons/postscript/ps.output/cat_val.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/cat_val.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -16,25 +16,30 @@
static char catval_str[128];
/* LOAD CAT_VAL */
-int load_catval_array(VECTOR * vector, const char *colname, dbCatValArray * cvarr)
+int load_catval_array(VECTOR * vector, const char *colname,
+ dbCatValArray * cvarr)
{
int n_records;
+
struct field_info *Fi;
+
dbDriver *driver;
db_CatValArray_init(cvarr);
Fi = Vect_get_field(&(vector->Map), vector->layer);
- if (Fi == NULL)
- {
+ if (Fi == NULL) {
G_fatal_error(_("Unable to get layer info for vector map"));
}
driver = db_start_driver_open_database(Fi->driver, Fi->database);
if (driver == NULL)
- G_fatal_error(_("Unable to open database <%s> by driver <%s>"), Fi->database, Fi->driver);
+ G_fatal_error(_("Unable to open database <%s> by driver <%s>"),
+ Fi->database, Fi->driver);
- n_records = db_select_CatValArray(driver, Fi->table, Fi->key, colname, NULL, cvarr);
+ n_records =
+ db_select_CatValArray(driver, Fi->table, Fi->key, colname, NULL,
+ cvarr);
if (n_records < 0)
G_fatal_error(_("Unable to select data from table"));
@@ -51,33 +56,28 @@
void get_number(dbCatValArray * cvarr, int cat, double *d)
{
int ret, int_val;
+
dbCatVal *cv = NULL;
*d = -1.;
- if (cvarr->ctype == DB_C_TYPE_INT)
- {
+ if (cvarr->ctype == DB_C_TYPE_INT) {
ret = db_CatValArray_get_value_int(cvarr, cat, &int_val);
- if (ret != DB_OK)
- {
+ if (ret != DB_OK) {
G_warning(_("No record for category [%d]"), cat);
}
else
*d = (double)int_val;
}
- else if (cvarr->ctype == DB_C_TYPE_DOUBLE)
- {
+ else if (cvarr->ctype == DB_C_TYPE_DOUBLE) {
ret = db_CatValArray_get_value_double(cvarr, cat, d);
- if (ret != DB_OK)
- {
+ if (ret != DB_OK) {
G_warning(_("No record for category [%d]"), cat);
}
}
- else if (cvarr->ctype == DB_C_TYPE_STRING)
- {
+ else if (cvarr->ctype == DB_C_TYPE_STRING) {
ret = db_CatValArray_get_value(cvarr, cat, &cv);
- if (ret != DB_OK)
- {
+ if (ret != DB_OK) {
G_warning(_("No record for category [%d]"), cat);
}
else
@@ -89,42 +89,37 @@
char *get_string(dbCatValArray * cvarr, int cat, int dec)
{
int ret, int_val;
+
double double_val;
+
dbCatVal *cv = NULL;
+
char buf[10], *str = NULL;
- if (cvarr->ctype == DB_C_TYPE_STRING)
- {
+ if (cvarr->ctype == DB_C_TYPE_STRING) {
ret = db_CatValArray_get_value(cvarr, cat, &cv);
- if (ret != DB_OK)
- {
+ if (ret != DB_OK) {
G_warning(_("No record for category [%d]"), cat);
}
else
str = db_get_string(cv->val.s);
}
- else if (cvarr->ctype == DB_C_TYPE_INT)
- {
+ else if (cvarr->ctype == DB_C_TYPE_INT) {
ret = db_CatValArray_get_value_int(cvarr, cat, &int_val);
- if (ret != DB_OK)
- {
+ if (ret != DB_OK) {
G_warning(_("No record for category [%d]"), cat);
}
- else
- {
+ else {
sprintf(catval_str, "%d", int_val);
str = catval_str;
}
}
- else if (cvarr->ctype == DB_C_TYPE_DOUBLE)
- {
+ else if (cvarr->ctype == DB_C_TYPE_DOUBLE) {
ret = db_CatValArray_get_value_double(cvarr, cat, &double_val);
- if (ret != DB_OK)
- {
+ if (ret != DB_OK) {
G_warning(_("No record for category [%d]"), cat);
}
- else
- {
+ else {
sprintf(buf, "%%0.%df", dec);
sprintf(catval_str, buf, double_val);
str = catval_str;
Modified: grass-addons/postscript/ps.output/colors.c
===================================================================
--- grass-addons/postscript/ps.output/colors.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/colors.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -26,21 +26,18 @@
{
int R, G, B;
- if (*name == 0 || strcmp(name, "none") == 0)
- {
- unset_color(color);
- return 1;
+ if (*name == 0 || strcmp(name, "none") == 0) {
+ unset_color(color);
+ return 1;
}
/* standard GRASS colors */
- if (G_str_to_color(name, &R, &G, &B) == 1)
- {
- set_color_rgb(color, R, G, B);
- return 1;
+ if (G_str_to_color(name, &R, &G, &B) == 1) {
+ set_color_rgb(color, R, G, B);
+ return 1;
}
/* PS3 palette colors */
- if (PS_str_to_color(name, color) == 1)
- {
- return 1;
+ if (PS_str_to_color(name, color) == 1) {
+ return 1;
}
unset_color(color);
return 0;
@@ -91,8 +88,7 @@
int set_ps_color(PSCOLOR * color)
{
- if (!color->none)
- {
+ if (!color->none) {
fprintf(PS.fp, "%.3f %.3f %.3f C ", color->r, color->g, color->b);
if ((PS.flag & 1) && color->a > 0.)
@@ -103,8 +99,7 @@
int set_ps_grey(PSCOLOR * color)
{
- if (!color->none)
- {
+ if (!color->none) {
fprintf(PS.fp, "%.3f %.3f %.3f CG ", color->r, color->g, color->b);
if ((PS.flag & 1) && color->a > 0.)
Modified: grass-addons/postscript/ps.output/eps.c
===================================================================
--- grass-addons/postscript/ps.output/eps.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/eps.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -18,28 +18,28 @@
int eps_bbox(char *eps, double *llx, double *lly, double *urx, double *ury)
{
char buf[201];
+
FILE *fp;
+
int v1, v2, v3, v4;
/* test if file is realy eps and find bbox */
- if ((fp = fopen(eps, "r")) == NULL)
- {
+ if ((fp = fopen(eps, "r")) == NULL) {
fprintf(stderr, "can't open eps file <%s>\n", eps);
return (0);
}
/* test if first row contains '%!PS-Adobe-m.n EPSF-m.n' string */
fgets(buf, 200, fp);
- if (sscanf(buf, "%%!PS-Adobe-%d.%d EPSF-%d.%d", &v1, &v2, &v3, &v4) < 4)
- {
+ if (sscanf(buf, "%%!PS-Adobe-%d.%d EPSF-%d.%d", &v1, &v2, &v3, &v4) < 4) {
fprintf(stderr, "file <%s> is not in EPS format\n", eps);
fclose(fp);
return (0);
}
/* looking for bbox */
- while (fgets(buf, 200, fp) != NULL)
- {
- if (sscanf(buf, "%%%%BoundingBox: %lf %lf %lf %lf", llx, lly, urx, ury) == 4)
- {
+ while (fgets(buf, 200, fp) != NULL) {
+ if (sscanf
+ (buf, "%%%%BoundingBox: %lf %lf %lf %lf", llx, lly, urx,
+ ury) == 4) {
fclose(fp);
return (1);
}
@@ -53,7 +53,8 @@
* rotate is in degrees
*/
int eps_trans(double llx, double lly, double urx, double ury,
- double x, double y, double scale, double rotate, double *xt, double *yt)
+ double x, double y, double scale, double rotate, double *xt,
+ double *yt)
{
double xc, yc, angle;
@@ -71,6 +72,7 @@
int eps_save(FILE * fp, char *epsf, char *name)
{
char buf[1024];
+
FILE *epsfp;
if ((epsfp = fopen(epsf, "r")) == NULL)
@@ -86,7 +88,8 @@
}
/* draw EPS file saved by eps_save */
-int eps_draw_saved(FILE * fp, char *name, double x, double y, double scale, double rotate)
+int eps_draw_saved(FILE * fp, char *name, double x, double y, double scale,
+ double rotate)
{
fprintf(PS.fp, "\nBeginEPSF\n");
fprintf(PS.fp, "%.5f %.5f translate\n", x, y);
@@ -104,9 +107,11 @@
/* write EPS file into PS file */
-int eps_draw(FILE * fp, char *eps, double x, double y, double scale, double rotate)
+int eps_draw(FILE * fp, char *eps, double x, double y, double scale,
+ double rotate)
{
char buf[1024];
+
FILE *epsfp;
if ((epsfp = fopen(eps, "r")) == NULL)
@@ -133,15 +138,16 @@
int pat_save(FILE * fp, char *epsf, char *name)
{
char buf[1024];
+
FILE *epsfp;
if ((epsfp = fopen(epsf, "r")) == NULL)
return (0);
fprintf(fp, "\n/%s {\n", name);
- while (fgets(buf, 1024, epsfp) != NULL)
- {
- if (strncmp(buf, "%!PS-Adobe", 10) == 0 || strncmp(buf, "%%BoundingBox", 13) == 0)
+ while (fgets(buf, 1024, epsfp) != NULL) {
+ if (strncmp(buf, "%!PS-Adobe", 10) == 0 ||
+ strncmp(buf, "%%BoundingBox", 13) == 0)
continue;
fprintf(fp, "%s", buf);
}
Modified: grass-addons/postscript/ps.output/fonts.c
===================================================================
--- grass-addons/postscript/ps.output/fonts.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/fonts.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -16,13 +16,12 @@
double set_ps_font_nocolor(PSFONT * font)
{
- if (font->extend == 1. || font->extend <= 0.)
- {
+ if (font->extend == 1. || font->extend <= 0.) {
fprintf(PS.fp, "(%s) FN %.1f FS\n", font->name, font->size);
}
- else
- {
- fprintf(PS.fp, "(%s) FN %.1f %.2f FE\n", font->name, font->size, font->extend);
+ else {
+ fprintf(PS.fp, "(%s) FN %.1f %.2f FE\n", font->name, font->size,
+ font->extend);
}
return font->size;
}
Modified: grass-addons/postscript/ps.output/format.c
===================================================================
--- grass-addons/postscript/ps.output/format.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/format.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -17,32 +17,30 @@
void format_northing(double north, char *buf, int map_proj)
{
char h;
+
int d, m;
+
double s;
- if (map_proj == PROJECTION_LL)
- {
+ if (map_proj == PROJECTION_LL) {
G_lon_parts(north, &d, &m, &s, &h);
if (s < 0.1)
s = 0.0;
- if (s > 59.9)
- {
+ if (s > 59.9) {
s = 0.0;
++m;
}
if (s != 0.0)
sprintf(buf, "%dº%d'%.1f\"%c", d, m, s, h);
- else
- {
+ else {
if (m != 0)
sprintf(buf, "%dº%d'%c", d, m, h);
else
sprintf(buf, "%dº%c", d, h);
}
}
- else
- {
+ else {
sprintf(buf, "%0.8f", north);
G_trim_decimal(buf);
}
@@ -51,32 +49,30 @@
void format_easting(double east, char *buf, int map_proj)
{
char h;
+
int d, m;
+
double s;
- if (map_proj == PROJECTION_LL)
- {
+ if (map_proj == PROJECTION_LL) {
G_lat_parts(east, &d, &m, &s, &h);
if (s < 0.1)
s = 0.0;
- if (s > 59.9)
- {
+ if (s > 59.9) {
s = 0.0;
++m;
}
if (s != 0.0)
sprintf(buf, "%dº%d'%.1f\"%c", d, m, s, h);
- else
- {
+ else {
if (m != 0)
sprintf(buf, "%dº%d'%c", d, m, h);
else
sprintf(buf, "%dº%c", d, h);
}
}
- else
- {
+ else {
sprintf(buf, "%0.8f", east);
G_trim_decimal(buf);
}
@@ -86,16 +82,16 @@
void format_iho(double value, char *buf)
{
char h;
+
int d, m;
+
double s;
- if (PS.map.proj == PROJECTION_LL)
- {
+ if (PS.map.proj == PROJECTION_LL) {
G_lon_parts(value, &d, &m, &s, &h);
if (s < 0.1)
s = 0.0;
- if (s > 59.9)
- {
+ if (s > 59.9) {
s = 0.0;
++m;
}
@@ -103,16 +99,14 @@
if (s != 0.0)
// sprintf(buf, "%dº|%d'%.8f\"", d, m, s);
sprintf(buf, "%dº|%.1f'", d, (double)m + s / 60.);
- else
- {
+ else {
if (m != 0)
sprintf(buf, "%dº|%d'", d, m);
else
sprintf(buf, "%dº|", d);
}
}
- else
- {
+ else {
sprintf(buf, "%d|%03d", (int)(value / 1000), (int)value % 1000);
}
}
Modified: grass-addons/postscript/ps.output/frames.c
===================================================================
--- grass-addons/postscript/ps.output/frames.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/frames.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -18,8 +18,7 @@
{
double x, y;
- if (box->x <= 0.0)
- {
+ if (box->x <= 0.0) {
box->x = PS.map_x - PS.map_w * (box->x / 100.);
}
/*
@@ -27,12 +26,10 @@
box->x = 0 + box->x;
}
*/
- if (box->y <= 0.0)
- {
+ if (box->y <= 0.0) {
box->y = PS.map_y - PS.map_h * (box->y / 100.);
}
- else
- {
+ else {
box->y = PS.page.height - box->y;
}
}
@@ -46,15 +43,13 @@
fprintf(PS.fp, "/mg %.4f def\n", box->margin);
/* Height "hg" and content height "chg" */
- if (height > 0.)
- {
+ if (height > 0.) {
fprintf(PS.fp, "/hg %.4f def\n", height); /* height */
fprintf(PS.fp, "/chg hg mg 2 mul sub def\n"); /* content height */
}
/* Width "wd" and content width "cwd" */
- if (width > 0.)
- {
+ if (width > 0.) {
fprintf(PS.fp, "/wd %.4f def\n", width); /* width */
fprintf(PS.fp, "/cwd wd mg 2 mul sub def\n"); /* content width */
}
@@ -79,14 +74,12 @@
fprintf(PS.fp, "/yo %.4f def\n", box->y + box->yset);
/* Make color background, if set */
- if (!box->fcolor.none)
- {
+ if (!box->fcolor.none) {
set_ps_color(&(box->fcolor));
fprintf(PS.fp, "xo yo wd hg neg RF\n");
}
/* Draw the border, if set */
- if (box->border > 0.)
- {
+ if (box->border > 0.) {
set_ps_color(&(box->color));
fprintf(PS.fp, "%.4f LW xo yo wd hg neg RO\n", box->border);
}
@@ -109,7 +102,7 @@
/* Height "hg", content height "chg", and interline "dy" */
fprintf(PS.fp, "/dy %.4f def\n", factor * font->size); /* standard row sep */
- fprintf(PS.fp, "/chg dy neg ARh {add dy add} forall def\n"); /* content height */
+ fprintf(PS.fp, "/chg dy neg ARh {add dy add} forall def\n"); /* content height */
fprintf(PS.fp, "/hg chg mg 2 mul add def\n"); /* height */
/* Width "wd", content width "cwd", and intercolum "dx" */
@@ -122,28 +115,24 @@
/* Readjust the size of a box with new margins */
void set_inner_readjust(double left, double top, double width, double height)
{
- if (left > 0.)
- {
+ if (left > 0.) {
if (width >= 0.)
width += left;
else
width = left;
fprintf(PS.fp, "/mgx mg %.4f add def\n", left);
}
- if (top > 0.)
- {
+ if (top > 0.) {
if (height >= 0.)
height += top;
else
height = top;
fprintf(PS.fp, "/mgy mg %.4f add def\n", top);
}
- if (height > 0.)
- {
+ if (height > 0.) {
fprintf(PS.fp, "/hg hg %.4f add def\n", height);
}
- if (width > 0.)
- {
+ if (width > 0.) {
fprintf(PS.fp, "/wd wd %.4f add def\n", width);
}
}
Modified: grass-addons/postscript/ps.output/input.c
===================================================================
--- grass-addons/postscript/ps.output/input.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/input.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -19,28 +19,24 @@
int input(int level, char *buf)
{
int i;
+
char command[20], empty[3];
if (level && isatty(fileno(inputfd)))
fprintf(stdout, "enter 'end' when done, 'exit' to quit\n");
- do
- {
- if (level && isatty(fileno(inputfd)))
- {
+ do {
+ if (level && isatty(fileno(inputfd))) {
fprintf(stdout, "%s ", level == 1 ? ">" : ">>");
}
- if (!G_getl2(buf, 1024, inputfd))
- {
- if (inputfd != stdin)
- {
+ if (!G_getl2(buf, 1024, inputfd)) {
+ if (inputfd != stdin) {
fclose(inputfd);
inputfd = stdin;
}
return 0;
}
- if (sscanf(buf, "%5s %1s", command, empty) == 1)
- {
+ if (sscanf(buf, "%5s %1s", command, empty) == 1) {
if (strcmp(command, "end") == 0)
return 0;
if (strcmp(command, "exit") == 0)
@@ -61,8 +57,7 @@
while (*key && *key <= ' ')
key++;
- if (*key == 0)
- {
+ if (*key == 0) {
*k = *d = key;
return 0;
}
Modified: grass-addons/postscript/ps.output/legends.c
===================================================================
--- grass-addons/postscript/ps.output/legends.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/legends.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -29,31 +29,28 @@
/* Symbol width "syw" and adding to all width columns */
fprintf(PS.fp, "/syw %.5f def\n", legend->width); /* symbol width */
- fprintf(PS.fp, "0 1 ARw length -- {ARw exch dup ARw exch get syw add put} for\n");
+ fprintf(PS.fp,
+ "0 1 ARw length -- {ARw exch dup ARw exch get syw add put} for\n");
/* Height "hg", content height "chg", and interline "dy" */
- if (height > 0.)
- {
+ if (height > 0.) {
fprintf(PS.fp, "/hg %.5f def\n", height); /* height */
fprintf(PS.fp, "/chg hg mg 2 mul sub def\n"); /* content height */
fprintf(PS.fp, "/dy ARh length 1 eq {0} {chg ARh {sub} forall ARh length -- div} ifelse def\n"); /* rowsep */
}
- else
- {
+ else {
fprintf(PS.fp, "/dy %.5f def\n", .5 * legend->font.size); /* standard row sep */
fprintf(PS.fp, "/chg dy neg ARh {add dy add} forall def\n"); /* content height */
fprintf(PS.fp, "/hg chg mg 2 mul add def\n"); /* height */
}
/* Width "wd", content width "cwd", and colspan "dx" */
- if (legend->xspan < 0.)
- { /* auto-adjust */
+ if (legend->xspan < 0.) { /* auto-adjust */
fprintf(PS.fp, "/wd %.5f def ", -(PS.map_w * legend->xspan)); /* width */
fprintf(PS.fp, "/cwd wd mg 2 mul sub def\n"); /* content width */
fprintf(PS.fp, "/dx ARw length 1 eq {0} {cwd ARw {sub} forall ARw length -- div} ifelse def\n"); /* colspan */
}
- else
- {
+ else {
if (legend->xspan == 0.)
legend->xspan = legend->box.margin;
fprintf(PS.fp, "/dx %.4f def\n", legend->xspan); /* colspan */
Modified: grass-addons/postscript/ps.output/load_raster.c
===================================================================
--- grass-addons/postscript/ps.output/load_raster.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/load_raster.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -37,7 +37,9 @@
int load_group(char *name)
{
int i;
+
struct Ref ref;
+
char fullname[100];
/* close open rasters */
@@ -46,8 +48,7 @@
I_init_group_ref(&ref);
/* get group info */
- if (I_get_group_ref(PS.rst.title, &ref) == 0)
- {
+ if (I_get_group_ref(PS.rst.title, &ref) == 0) {
G_fatal_error(_("Can't get group information"));
}
@@ -63,10 +64,9 @@
PS.rst.mapset[2] = G_store(ref.file[ref.blu.n].mapset);
/* check load colors */
- for (i = 0; i < 3; i++)
- {
- if (G_read_colors(PS.rst.name[i], PS.rst.mapset[i], &(PS.rst.colors[i])) == -1)
- {
+ for (i = 0; i < 3; i++) {
+ if (G_read_colors
+ (PS.rst.name[i], PS.rst.mapset[i], &(PS.rst.colors[i])) == -1) {
sprintf(fullname, "%s in %s", PS.rst.name[i], PS.rst.mapset[i]);
error(fullname, "", "can't load color table");
return 0;
@@ -74,10 +74,9 @@
}
/* check open raster maps */
- for (i = 0; i < 3; i++)
- {
- if ((PS.rst.fd[i] = G_open_cell_old(PS.rst.name[i], PS.rst.mapset[i])) < 0)
- {
+ for (i = 0; i < 3; i++) {
+ if ((PS.rst.fd[i] =
+ G_open_cell_old(PS.rst.name[i], PS.rst.mapset[i])) < 0) {
sprintf(fullname, "%s in %s", PS.rst.name[i], PS.rst.mapset[i]);
error(fullname, "", "can't open raster map");
G_free_colors(&(PS.rst.colors[i]));
@@ -93,11 +92,11 @@
int load_cell(int slot, char *name)
{
char *mapset, *ptr;
+
char fullname[100];
/* close raster cell, if any */
- if (PS.rst.fd[slot] >= 0)
- {
+ if (PS.rst.fd[slot] >= 0) {
G_close_cell(PS.rst.fd[slot]);
G_free(PS.rst.name[slot]);
G_free(PS.rst.mapset[slot]);
@@ -107,16 +106,13 @@
/* get mapset */
ptr = strchr(name, '@');
- if (ptr)
- {
+ if (ptr) {
*ptr = '\0';
mapset = ptr + 1;
}
- else
- {
+ else {
mapset = G_find_file2("cell", name, "");
- if (!mapset)
- {
+ if (!mapset) {
error(name, "", "not found");
return 0;
}
@@ -130,16 +126,14 @@
G_message(_(" Reading raster map <%s> ..."), fullname);
/* load colors */
- if (G_read_colors(name, mapset, &PS.rst.colors[slot]) == -1)
- {
+ if (G_read_colors(name, mapset, &PS.rst.colors[slot]) == -1) {
error(fullname, "", "can't load color table");
return 0;
}
G_get_color_range(&(PS.rst.min), &(PS.rst.max), &(PS.rst.colors[slot]));
/* open raster map */
- if ((PS.rst.fd[slot] = G_open_cell_old(name, mapset)) < 0)
- {
+ if ((PS.rst.fd[slot] = G_open_cell_old(name, mapset)) < 0) {
error(fullname, "", "can't open raster map");
G_free_colors(&PS.rst.colors[slot]);
return 0;
Modified: grass-addons/postscript/ps.output/local_proto.h
===================================================================
--- grass-addons/postscript/ps.output/local_proto.h 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/local_proto.h 2010-12-08 23:19:08 UTC (rev 44565)
@@ -16,57 +16,80 @@
/* cat_val.c */
#ifdef GRASS_DBMI_H
int load_catval_array(VECTOR *, const char *, dbCatValArray *);
+
void get_number(dbCatValArray *, int, double *);
+
char *get_string(dbCatValArray *, int, int);
#endif
/* colors.c */
#ifdef _PSCOLOR_H_
int set_color_name(PSCOLOR *, char *);
+
void set_color_rgb(PSCOLOR *, int, int, int);
+
void set_color_pscolor(PSCOLOR *, PSCOLOR *);
+
void unset_color(PSCOLOR *);
+
int set_ps_color(PSCOLOR *);
+
int set_ps_grey(PSCOLOR *);
+
long color_to_long(PSCOLOR *);
+
int long_to_color(long, PSCOLOR *);
#endif
/* eps.c */
int eps_bbox(char *, double *, double *, double *, double *);
-int eps_trans(double, double, double, double, double, double, double, double, double *, double *);
+int eps_trans(double, double, double, double, double, double, double, double,
+ double *, double *);
+
#ifdef _STDIO_H
int eps_save(FILE *, char *, char *);
+
int eps_draw_saved(FILE *, char *, double, double, double, double);
+
int eps_draw(FILE *, char *, double, double, double, double);
+
int pat_save(FILE *, char *, char *);
#endif
/* fonts.c */
#ifdef _PSFONT_H_
double set_ps_font(PSFONT *);
+
double set_ps_font_nocolor(PSFONT *);
#endif
/* format.c */
void format_northing(double, char *, int);
+
void format_easting(double, char *, int);
+
void format_iho(double, char *);
/* frames.c */
#ifdef _PSFRAME_H_
void set_box_orig(PSFRAME *);
+
void set_box_size(PSFRAME *, double, double);
+
void set_box_draw(PSFRAME *);
+
void set_box_auto(PSFRAME *, PSFONT *, double);
#endif
void set_inner_readjust_title(const char *);
+
void set_inner_readjust(double, double, double, double);
/* input.c */
int input(int, char *);
+
int key_data(char *, char **, char **);
+
int error(char *, char *, char *);
/* legends.c */
@@ -77,21 +100,29 @@
/* lines.c */
#ifdef _PSLINE_H_
int set_ps_linewidth(double);
+
int set_ps_line(PSLINE *);
+
int set_ps_line_no_color(PSLINE *);
#endif
/* load_raster.c */
int load_group(char *);
+
int load_cell(int, char *);
+
int load_rgb(char *, char *, char *);
/* palettes.c */
#ifdef _PSCOLOR_H_
int analogous(char *, PSCOLOR *, int, double);
+
int complementary(char *, PSCOLOR *, int, double);
+
int diverging(char *, PSCOLOR *, PSCOLOR *, int);
+
int gradient(char *, PSCOLOR *, PSCOLOR *, int, int);
+
int PS_str_to_color(char *, PSCOLOR *);
#endif
int pure_color(char *, int);
@@ -105,7 +136,9 @@
/* proj_geo.c */
#ifdef _GPROJECTS_H
void init_proj(struct pj_info *, struct pj_info *);
-int find_limits(double *, double *, double *, double *, struct pj_info *, struct pj_info *);
+
+int find_limits(double *, double *, double *, double *, struct pj_info *,
+ struct pj_info *);
#endif
/* r_block.c */
@@ -119,12 +152,14 @@
#ifdef _PSFONT_H_
int default_font(PSFONT *);
+
int read_font(char *, PSFONT *);
#endif
/* r_frame.c */
#ifdef _PSFRAME_H_
int default_frame(PSFRAME *, int, int);
+
int read_frame(PSFRAME *);
#endif
@@ -136,6 +171,7 @@
/* r_line.c */
#ifdef _PSLINE_H_
int default_psline(PSLINE *);
+
int read_psline(char *, PSLINE *);
#endif
@@ -192,12 +228,19 @@
/* scanners.c */
int scan_easting(char *, double *);
+
int scan_northing(char *, double *);
+
int scan_resolution(char *, double *);
+
int scan_percent(char *, double *, double, double);
+
int scan_ref(char *, int *, int *);
+
int scan_yesno(char *, char *);
+
int scan_dimen(char *, double *);
+
int scan_second(char *, double *);
#ifdef _PSCOLOR_H_
@@ -206,33 +249,43 @@
/* set_draw.c */
int set_draw(char *, char *);
+
int set_on_paper(char *, char *, char *, char *);
/* set_geogrid.c */
int set_lines_geogrid(void);
+
int set_numbers_geogrid(void);
#ifdef _PSLINE_H_
int set_geogrid_lines(PSLINE *, int);
#endif
int set_geogrid_inner_numbers(void);
+
int set_geogrid_outer_numbers(void);
/* set_grid.c */
int set_lines_grid(void);
+
int set_numbers_grid(void);
#ifdef _PSLINE_H_
int set_grid_lines(char, PSLINE *, int);
#endif
int set_grid_inner_numbers(void);
+
int set_grid_outer_numbers(int);
+
int set_grid_iho_numbers(double, double);
+
int set_grid_can_numbers(double, double);
void set_grid_minordiv_border(int, double, double);
+
void set_grid_minor_border(double, double, double);
+
void set_grid_major_border(double, double);
+
void set_grid_corners(double, double);
/* set_mask.c */
@@ -240,6 +293,7 @@
/* set_note.c */
int note_int_file(char *);
+
int set_note(int);
/* set_outline.c */
@@ -247,10 +301,15 @@
/* set_ps.c */
void set_ps_rect(double, double, double, double);
+
void set_ps_brd(double);
+
void set_ps_brd2(double, double);
+
int set_ps_where(char, double, double);
+
int set_xy_where(char *, double, double, char *);
+
int set_ps_symbol_eps(int, char *);
#ifdef _VECTOR_H_
@@ -259,18 +318,25 @@
/* set_raster.c */
int set_raster(void);
+
int set_raster_cell(void);
+
int set_raster_rgb(void);
+
int set_raster_maskcell(void);
+
int set_raster_maskcolor(void);
/* set_rlegend.c */
int set_rlegend_cats(void);
+
int set_rlegend_gradient(void);
+
static double nice_step(double, int, int *);
/* set_scalebar.c */
char *strnumber(double);
+
int set_scalebar(void);
/* set_vector.c */
@@ -279,6 +345,7 @@
#ifdef GRASS_VECT_H
/* set_vareas.c */
int set_vareas(VECTOR *, VAREAS *);
+
int set_vareas_line(VECTOR *, VAREAS *);
/* set_vlabels.c */
@@ -286,19 +353,27 @@
/* set_vlegend.c */
int set_vlegend(void);
+
int set_vlegend_simple(int, const int *, int);
+
int set_vlegend_multi(int, VECTOR *);
+
void make_vareas(VECTOR *, int);
+
void make_vlines(VECTOR *, int);
+
void make_vpoints(VECTOR *, int);
+
void set_vlegend_ps(int, int, int);
/* set_vlines.c */
int set_vlines(VECTOR *, VLINES *, int);
+
int vector_line(struct line_pnts *);
/* set_vpoints.c */
int set_vpoints(VECTOR *, VPOINTS *);
+
int set_vpoints_line(VECTOR *, VPOINTS *);
#endif
@@ -308,6 +383,7 @@
/* symbol.c */
#if defined GRASS_SYMB_H
int draw_chain(SYMBCHAIN *, double);
+
#ifdef _VPOINTS_H_
int symbol_save(int, VPOINTS *, SYMBOL *);
#endif
@@ -316,20 +392,26 @@
/* val_list.c */
#ifdef GRASS_GIS_H
int parse_val_list(char *, DCELL **);
+
int sort_list(char *, int, CELL **);
#endif
/* vector.c */
int vector_new(void);
+
int default_vector(int);
#ifdef _VECTOR_H_
int vector_item_new(VECTOR *, double, long);
+
int vector_rule_find(VECTOR *, double);
+
int vector_rule_new(VECTOR *, char *, char *, double);
#endif
/* vlegend.c */
int vlegend_block_new(void);
+
void vlegend_block_adjust(int, const char *);
+
void vlegend_block_reload(int);
Modified: grass-addons/postscript/ps.output/main.c
===================================================================
--- grass-addons/postscript/ps.output/main.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/main.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -31,8 +31,11 @@
int main(int argc, char *argv[])
{
struct Option *input_file;
+
struct Option *output_file;
+
struct GModule *module;
+
struct Flag *draft, *eps, *ghost, *style;
G_gisinit(argv[0]);
@@ -58,19 +61,23 @@
draft = G_define_flag();
draft->key = 'd';
- draft->description = _("draft: Draw a 1x1 cm grid on paper to help the placement of the elements of the map");
+ draft->description =
+ _("draft: Draw a 1x1 cm grid on paper to help the placement of the elements of the map");
eps = G_define_flag();
eps->key = 'e';
- eps->description = _("eps: Create output as EPS file for embedding into another ps.out map");
+ eps->description =
+ _("eps: Create output as EPS file for embedding into another ps.out map");
ghost = G_define_flag();
ghost->key = 'g';
- ghost->description = _("ghostscript: Use the extended PostScript of Ghostscript (for transparent colors)");
+ ghost->description =
+ _("ghostscript: Use the extended PostScript of Ghostscript (for transparent colors)");
style = G_define_flag();
style->key = 's';
- style->description = _("special: Draw the small digit in the coordinate numbers to lower instead upper position");
+ style->description =
+ _("special: Draw the small digit in the coordinate numbers to lower instead upper position");
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
@@ -83,13 +90,12 @@
if (!isatty(0))
G_disable_interactive();
- if (output_file->answer)
- {
+ if (output_file->answer) {
if ((PS.fp = fopen(output_file->answer, "w")) == NULL)
- G_fatal_error("%s - %s: %s", G_program_name(), output_file->answer, strerror(errno));
+ G_fatal_error("%s - %s: %s", G_program_name(),
+ output_file->answer, strerror(errno));
}
- else
- {
+ else {
G_message(_("\nERROR: Required parameter <%s> not set:\n (%s).\n"),
output_file->key, output_file->description);
exit(EXIT_FAILURE);
@@ -137,57 +143,48 @@
/* process options */
char buf[1024];
+
double number;
- while (input(1, buf))
- {
+ while (input(1, buf)) {
char *key;
+
char *data;
- if (!key_data(buf, &key, &data))
- {
+ if (!key_data(buf, &key, &data)) {
continue;
}
/* General information */
- if (KEY("paper"))
- {
+ if (KEY("paper")) {
read_paper(data);
continue;
}
- if (KEY("palette"))
- {
+ if (KEY("palette")) {
read_palette();
continue;
}
- if (KEY("maparea"))
- {
+ if (KEY("maparea")) {
read_maparea();
continue;
}
- if (KEY("scale"))
- {
- if (sscanf(data, "1:%d", &(PS.scale)) != 1)
- {
+ if (KEY("scale")) {
+ if (sscanf(data, "1:%d", &(PS.scale)) != 1) {
error(key, data, "illegal scale request");
}
continue;
}
/* Raster map related information */
- if (KEY("cell") || KEY("rast") || KEY("raster") || KEY("rgb"))
- {
- if (PS.rst.files != 0)
- {
+ if (KEY("cell") || KEY("rast") || KEY("raster") || KEY("rgb")) {
+ if (PS.rst.files != 0) {
error(key, data, "only one raster command");
continue;
}
read_raster(data);
continue;
}
- if (KEY("rlegend"))
- {
- if (PS.do_rlegend != 0)
- {
+ if (KEY("rlegend")) {
+ if (PS.do_rlegend != 0) {
error(key, data, "only one rlegend command");
}
read_rlegend(data);
@@ -195,50 +192,40 @@
}
/* Vector map related information */
- if (KEY("vlines") || KEY("vline"))
- {
+ if (KEY("vlines") || KEY("vline")) {
G_strip(data);
- if (*data == 0)
- {
+ if (*data == 0) {
error(key, data, "vlines need vector map");
}
read_vlines(data);
continue;
}
- if (KEY("vareas") || KEY("varea"))
- {
+ if (KEY("vareas") || KEY("varea")) {
G_strip(data);
- if (*data == 0)
- {
+ if (*data == 0) {
error(key, data, "vareas need vector map");
}
read_vareas(data);
continue;
}
- if (KEY("vpoints") || KEY("vpoint"))
- {
+ if (KEY("vpoints") || KEY("vpoint")) {
G_strip(data);
- if (*data == 0)
- {
+ if (*data == 0) {
error(key, data, "vpoints need vector map");
}
read_vpoints(data);
continue;
}
- if (KEY("vlabels") || KEY("vlabel"))
- {
+ if (KEY("vlabels") || KEY("vlabel")) {
G_strip(data);
- if (*data == 0)
- {
+ if (*data == 0) {
error(key, data, "vlabels need vector map");
}
read_vlabels(data);
continue;
}
- if (KEY("vlegend"))
- {
- if (PS.do_vlegend != 0)
- {
+ if (KEY("vlegend")) {
+ if (PS.do_vlegend != 0) {
error(key, data, "only one vlegend command");
}
read_vlegend(data);
@@ -246,29 +233,25 @@
}
/* Grid and scalebar related */
- if (KEY("grid"))
- {
+ if (KEY("grid")) {
read_grid(&(PS.grid), 1);
continue;
}
- if (KEY("geogrid"))
- {
- if (G_projection() == PROJECTION_XY)
- {
- error(key, data, "geogrid is not available for XY projection");
+ if (KEY("geogrid")) {
+ if (G_projection() == PROJECTION_XY) {
+ error(key, data,
+ "geogrid is not available for XY projection");
}
- else if (G_projection() == PROJECTION_LL)
- {
+ else if (G_projection() == PROJECTION_LL) {
error(key, data, "grid just uses LL projection");
}
read_grid(&(PS.geogrid), 0);
continue;
}
- if (KEY("scalebar"))
- {
- if (G_projection() == PROJECTION_LL)
- {
- error(key, data, "scalebar is not appropriate for this projection");
+ if (KEY("scalebar")) {
+ if (G_projection() == PROJECTION_LL) {
+ error(key, data,
+ "scalebar is not appropriate for this projection");
}
if (sscanf(data, "%c", &(PS.sbar.type)) != 1)
PS.sbar.type = 'I'; /* default new style scalebar */
@@ -277,20 +260,16 @@
}
/* Addons related data */
- if (KEY("note"))
- {
- if (PS.n_notes >= MAX_NOTES)
- {
+ if (KEY("note")) {
+ if (PS.n_notes >= MAX_NOTES) {
G_warning("Only %d notes by map", MAX_NOTES);
continue;
}
read_note(data);
continue;
}
- if (KEY("draw"))
- {
- if (PS.n_draws >= MAX_DRAWS)
- {
+ if (KEY("draw")) {
+ if (PS.n_draws >= MAX_DRAWS) {
G_warning("Only %d draw commands by map", MAX_DRAWS);
continue;
}
@@ -303,8 +282,7 @@
}
/* last minute adjust */
- if (PS.grid.format >= 2)
- { /* IHO */
+ if (PS.grid.format >= 2) { /* IHO */
PS.brd.width = 2. * MM_TO_POINT; /* 12.7 */
}
Modified: grass-addons/postscript/ps.output/palettes.c
===================================================================
--- grass-addons/postscript/ps.output/palettes.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/palettes.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -17,6 +17,7 @@
#include "palettes.h"
void RGB_HSV(PSCOLOR *, PALETTE *);
+
void HSV_RGB(PALETTE *, PSCOLOR *);
@@ -34,33 +35,32 @@
{
int i;
- for (i = 0; i < ncolors; i++)
- {
- if (strcmp(Palette[i].name, name) == 0)
- {
- HSV_RGB(&(Palette[i]), color);
- color->none = 0;
- return 1;
- }
+ for (i = 0; i < ncolors; i++) {
+ if (strcmp(Palette[i].name, name) == 0) {
+ HSV_RGB(&(Palette[i]), color);
+ color->none = 0;
+ return 1;
+ }
}
color->none = 1;
return 0;
}
/*
-void PL_set_name(int k, char *name, int i)
-{
- if (Palette[k].h < 0.) Palette[k].h += 360.;
- if (Palette[k].h >= 360.) Palette[k].h -= 360.;
+ void PL_set_name(int k, char *name, int i)
+ {
+ if (Palette[k].h < 0.) Palette[k].h += 360.;
+ if (Palette[k].h >= 360.) Palette[k].h -= 360.;
- sprintf(Palette[k].name, "%s%d", name, i);
-}
-*/
+ sprintf(Palette[k].name, "%s%d", name, i);
+ }
+ */
/* pure colors: color-wheel */
int pure_color(char *name, int div)
{
int i, k;
+
double step;
/* alloc memory */
@@ -68,13 +68,12 @@
step = 360. / div;
- for (i = 0; i < div; i++, k++)
- {
- Palette[k].h = (double)i *step;
+ for (i = 0; i < div; i++, k++) {
+ Palette[k].h = (double)i *step;
- Palette[k].s = 1.;
- Palette[k].v = 1.;
- sprintf(Palette[k].name, "%s%d", name, i+1);
+ Palette[k].s = 1.;
+ Palette[k].v = 1.;
+ sprintf(Palette[k].name, "%s%d", name, i + 1);
}
return 1;
@@ -84,19 +83,19 @@
int gray(char *name, int div)
{
int i, k;
+
double step;
/* alloc memory */
k = palette_new(div);
step = (div > 1) ? (1. / (double)(div - 1)) : 0.;
- for (i = 0; i < div; i++, k++)
- {
- Palette[k].h = 0.;
- Palette[k].s = 0.;
- Palette[k].v = (double)i * step; /* ((double)i * step) ^ (1.5) */
+ for (i = 0; i < div; i++, k++) {
+ Palette[k].h = 0.;
+ Palette[k].s = 0.;
+ Palette[k].v = (double)i *step; /* ((double)i * step) ^ (1.5) */
- sprintf(Palette[k].name, "%s%d", name, i+1);
+ sprintf(Palette[k].name, "%s%d", name, i + 1);
}
return 1;
@@ -106,13 +105,14 @@
int monochrome(char *name, PSCOLOR * rgb, int div)
{
int i, k;
+
double step;
+
PALETTE hsv;
- if (rgb->r == rgb->g && rgb->g == rgb->b)
- {
- gray(name, div);
- return 1;
+ if (rgb->r == rgb->g && rgb->g == rgb->b) {
+ gray(name, div);
+ return 1;
}
RGB_HSV(rgb, &hsv);
@@ -121,13 +121,13 @@
k = palette_new(div);
step = (div > 1) ? (1. / (double)(div - 1)) : 0.;
- for (i = 0; i < div; i++, k++)
- {
- Palette[k].h = hsv.h;
- Palette[k].s = (double)i * step;
- Palette[k].v = 1. + (double)i * step * (hsv.v - 1.); /* if pure v = 1. */
+ for (i = 0; i < div; i++, k++) {
+ Palette[k].h = hsv.h;
+ Palette[k].s = (double)i *step;
- sprintf(Palette[k].name, "%s%d", name, i+1);
+ Palette[k].v = 1. + (double)i *step * (hsv.v - 1.); /* if pure v = 1. */
+
+ sprintf(Palette[k].name, "%s%d", name, i + 1);
}
return 1;
@@ -137,7 +137,9 @@
int complementary(char *name, PSCOLOR * rgb, int div, double sector)
{
int i, k;
+
double step;
+
PALETTE hsv;
RGB_HSV(rgb, &hsv);
@@ -148,17 +150,19 @@
hsv.h += 180.;
if (div > 1)
- hsv.h -= (sector/2.);
+ hsv.h -= (sector / 2.);
- for (i = 0; i < div; i++, k++)
- {
- Palette[k].h = hsv.h + (double)i * step;
- Palette[k].s = hsv.s;
- Palette[k].v = hsv.v;
+ for (i = 0; i < div; i++, k++) {
+ Palette[k].h = hsv.h + (double)i *step;
- if (Palette[k].h < 0.) Palette[k].h += 360.;
- if (Palette[k].h >= 360.) Palette[k].h -= 360.;
- sprintf(Palette[k].name, "%s%d", name, i+1);
+ Palette[k].s = hsv.s;
+ Palette[k].v = hsv.v;
+
+ if (Palette[k].h < 0.)
+ Palette[k].h += 360.;
+ if (Palette[k].h >= 360.)
+ Palette[k].h -= 360.;
+ sprintf(Palette[k].name, "%s%d", name, i + 1);
}
return 1;
@@ -168,7 +172,9 @@
int analogous(char *name, PSCOLOR * rgb, int div, double sector)
{
int i, k;
+
double step;
+
PALETTE hsv;
RGB_HSV(rgb, &hsv);
@@ -178,17 +184,19 @@
step = (div > 1) ? (sector / (double)(div - 1)) : 0.;
if (div > 1)
- hsv.h -= (sector/2.);
+ hsv.h -= (sector / 2.);
- for (i = 0; i < div; i++, k++)
- {
- Palette[k].h = hsv.h + (double)i *step;
- Palette[k].s = hsv.s;
- Palette[k].v = hsv.v;
+ for (i = 0; i < div; i++, k++) {
+ Palette[k].h = hsv.h + (double)i *step;
- if (Palette[k].h < 0.) Palette[k].h += 360.;
- if (Palette[k].h >= 360.) Palette[k].h -= 360.;
- sprintf(Palette[k].name, "%s%d", name, i+1);
+ Palette[k].s = hsv.s;
+ Palette[k].v = hsv.v;
+
+ if (Palette[k].h < 0.)
+ Palette[k].h += 360.;
+ if (Palette[k].h >= 360.)
+ Palette[k].h -= 360.;
+ sprintf(Palette[k].name, "%s%d", name, i + 1);
}
return 1;
@@ -198,34 +206,39 @@
int gradient(char *name, PSCOLOR * A, PSCOLOR * B, int div, int pure)
{
int i, k;
+
double h_step, s_step, v_step;
+
PALETTE pal_A, pal_B;
RGB_HSV(A, &pal_A);
RGB_HSV(B, &pal_B);
if (pal_A.h == pal_B.h || div < 2)
- return 0;
+ return 0;
/* alloc memory */
k = palette_new(div);
if (pal_A.h < pal_B.h)
- pal_A.h += 360;
+ pal_A.h += 360;
h_step = (pal_B.h - pal_A.h) / (div - 1.);
s_step = (pal_B.s - pal_A.s) / (div - 1.);
v_step = (pal_B.v - pal_A.v) / (div - 1.);
- for (i = 0; i < div; i++, k++)
- {
- Palette[k].h = pal_A.h + (double)i * h_step;
- Palette[k].s = pure ? 1. : pal_A.s + (double)i * s_step;
- Palette[k].v = pure ? 1. : pal_A.v + (double)i * v_step;
+ for (i = 0; i < div; i++, k++) {
+ Palette[k].h = pal_A.h + (double)i *h_step;
- if (Palette[k].h < 0.) Palette[k].h += 360.;
- if (Palette[k].h >= 360.) Palette[k].h -= 360.;
- sprintf(Palette[k].name, "%s%d", name, i+1);
+ Palette[k].s = pure ? 1. : pal_A.s + (double)i *s_step;
+
+ Palette[k].v = pure ? 1. : pal_A.v + (double)i *v_step;
+
+ if (Palette[k].h < 0.)
+ Palette[k].h += 360.;
+ if (Palette[k].h >= 360.)
+ Palette[k].h -= 360.;
+ sprintf(Palette[k].name, "%s%d", name, i + 1);
}
return 1;
@@ -235,35 +248,39 @@
int diverging(char *name, PSCOLOR * A, PSCOLOR * B, int div)
{
int i, k;
+
double h_step, v_step, tmp;
+
PALETTE pal_A, pal_B;
RGB_HSV(A, &pal_A);
RGB_HSV(B, &pal_B);
if (pal_A.h == pal_B.h || div < 2)
- return 0;
+ return 0;
/* alloc memory */
k = palette_new(div);
if (pal_A.h < pal_B.h)
- pal_A.h += 360;
+ pal_A.h += 360;
div -= 1;
h_step = (pal_B.h - pal_A.h) / div;
v_step = (pal_B.v - pal_A.v) / div;
- for (i = 0; i < (div+1); i++, k++)
- {
- tmp = (2. * i / div - 1.);
- Palette[k].h = pal_A.h + (double)i * h_step;
- Palette[k].s = tmp * tmp;
- Palette[k].v = pal_A.v + (double)i * v_step;
+ for (i = 0; i < (div + 1); i++, k++) {
+ tmp = (2. * i / div - 1.);
+ Palette[k].h = pal_A.h + (double)i *h_step;
- if (Palette[k].h < 0.) Palette[k].h += 360.;
- if (Palette[k].h >= 360.) Palette[k].h -= 360.;
- sprintf(Palette[k].name, "%s%d", name, i+1);
+ Palette[k].s = tmp * tmp;
+ Palette[k].v = pal_A.v + (double)i *v_step;
+
+ if (Palette[k].h < 0.)
+ Palette[k].h += 360.;
+ if (Palette[k].h >= 360.)
+ Palette[k].h -= 360.;
+ sprintf(Palette[k].name, "%s%d", name, i + 1);
}
return 1;
@@ -276,69 +293,59 @@
/* r, g, b values are from 0 to 1
h = [0,360], s = [0,1], v = [0,1]
-*/
+ */
void RGB_HSV(PSCOLOR * col, PALETTE * pal)
{
double min, max, delta;
+
int r_max = 1, b_max = 0;
min = max = col->r;
- if(min > col->g)
- {
- if(col->b < col->g)
- {
- min = col->b;
- }
- else
- {
- min = col->g;
- if(col->b > col->r)
- {
- max = col->b;
- b_max = 1;
- r_max = 0;
- }
- }
+ if (min > col->g) {
+ if (col->b < col->g) {
+ min = col->b;
+ }
+ else {
+ min = col->g;
+ if (col->b > col->r) {
+ max = col->b;
+ b_max = 1;
+ r_max = 0;
+ }
+ }
}
- else
- {
- if(col->b > col->g)
- {
- max = col->b;
- b_max = 1;
- r_max = 0;
- }
- else
- {
- max = col->g;
- r_max = 0;
- if(col->b < col->r)
- min = col->b;
- }
+ else {
+ if (col->b > col->g) {
+ max = col->b;
+ b_max = 1;
+ r_max = 0;
+ }
+ else {
+ max = col->g;
+ r_max = 0;
+ if (col->b < col->r)
+ min = col->b;
+ }
}
pal->v = max;
- if( max == 0 || (delta = max - min) == 0)
- {
- pal->s = pal->h = 0;
- return;
+ if (max == 0 || (delta = max - min) == 0) {
+ pal->s = pal->h = 0;
+ return;
}
pal->s = delta / max;
- if (r_max == 1)
- {
- pal->h = ( col->g - col->b ) / delta;
+ if (r_max == 1) {
+ pal->h = (col->g - col->b) / delta;
}
- else if (b_max == 1)
- {
- pal->h = 4 + ( col->r - col->g ) / delta;
+ else if (b_max == 1) {
+ pal->h = 4 + (col->r - col->g) / delta;
}
- else
- {
- pal->h = 2 + ( col->b - col->r ) / delta;
+ else {
+ pal->h = 2 + (col->b - col->r) / delta;
}
pal->h *= 60.;
if (pal->h < 0)
- pal->h += 360.;
+ pal->h += 360.;
return;
}
@@ -346,36 +353,59 @@
/* r, g, b values are from 0 to 1
h = [0,360], s = [0,1], v = [0,1]
-*/
+ */
void HSV_RGB(PALETTE * pal, PSCOLOR * col)
{
/* achromatic, gray */
- if (pal->s == 0)
- {
- col->r = col->g = col->b = pal->v;
- return;
+ if (pal->s == 0) {
+ col->r = col->g = col->b = pal->v;
+ return;
}
double f, p, q, t;
+
int i;
-// f = modf(pal->h * 60, &t);
-// i = ((int) t) % 60;
+ // f = modf(pal->h * 60, &t);
+ // i = ((int) t) % 60;
i = floor(pal->h / 60.);
f = pal->h / 60. - (double)i;
p = pal->v * (1. - pal->s);
q = pal->v * (1. - pal->s * f);
t = pal->v * (1. - pal->s * (1. - f));
- switch (i)
- {
- case 0: col->r = pal->v; col->g = t; col->b = p; break;
- case 1: col->r = q; col->g = pal->v; col->b = p; break;
- case 2: col->r = p; col->g = pal->v; col->b = t; break;
- case 3: col->r = p; col->g = q; col->b = pal->v; break;
- case 4: col->r = t; col->g = p; col->b = pal->v; break;
- case 5: col->r = pal->v; col->g = p; col->b = q; break;
+ switch (i) {
+ case 0:
+ col->r = pal->v;
+ col->g = t;
+ col->b = p;
+ break;
+ case 1:
+ col->r = q;
+ col->g = pal->v;
+ col->b = p;
+ break;
+ case 2:
+ col->r = p;
+ col->g = pal->v;
+ col->b = t;
+ break;
+ case 3:
+ col->r = p;
+ col->g = q;
+ col->b = pal->v;
+ break;
+ case 4:
+ col->r = t;
+ col->g = p;
+ col->b = pal->v;
+ break;
+ case 5:
+ col->r = pal->v;
+ col->g = p;
+ col->b = q;
+ break;
default:
- col->none = 1;
+ col->none = 1;
}
}
Modified: grass-addons/postscript/ps.output/palettes.h
===================================================================
--- grass-addons/postscript/ps.output/palettes.h 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/palettes.h 2010-12-08 23:19:08 UTC (rev 44565)
@@ -20,9 +20,11 @@
#ifdef MAIN
PALETTE *Palette;
+
int ncolors;
#else
extern PALETTE *Palette;
+
extern int ncolors;
#endif
Modified: grass-addons/postscript/ps.output/papers.c
===================================================================
--- grass-addons/postscript/ps.output/papers.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/papers.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -63,10 +63,8 @@
{
register int i;
- for (i = 0; papers[i].name != NULL; i++)
- {
- if (strcmp(papers[i].name, name) == 0)
- {
+ for (i = 0; papers[i].name != NULL; i++) {
+ if (strcmp(papers[i].name, name) == 0) {
PS.page.width = papers[i].width;
PS.page.height = papers[i].height;
PS.page.left = papers[i].left;
Modified: grass-addons/postscript/ps.output/proj_geo.c
===================================================================
--- grass-addons/postscript/ps.output/proj_geo.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/proj_geo.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -46,9 +46,11 @@
*
*/
int find_limits(double *north, double *south,
- double *east, double *west, struct pj_info *ll_proj, struct pj_info *xy_proj)
+ double *east, double *west, struct pj_info *ll_proj,
+ struct pj_info *xy_proj)
{
int x, y;
+
double d, z;
/* West */
Modified: grass-addons/postscript/ps.output/ps3_map.c
===================================================================
--- grass-addons/postscript/ps.output/ps3_map.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/ps3_map.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -23,28 +23,30 @@
int PS3_map(void)
{
int i, j;
+
double d;
/* PostScript header */
fprintf(PS.fp, "%%!PS-Adobe-3.0 %s\n", PS.level == 0 ? "EPS 1.2" : "");
- fprintf(PS.fp, "%%%%BoundingBox: 0 0 %d %d\n", (int)(PS.page.width), (int)(PS.page.height));
+ fprintf(PS.fp, "%%%%BoundingBox: 0 0 %d %d\n", (int)(PS.page.width),
+ (int)(PS.page.height));
fprintf(PS.fp,
- "%%%%Title: \n"
- "%%%%Creator: \n"
- "%%%%CreationDate: %s\n"
- "%%%%Programming: E. Jorge Tizado, Spain 2009\n"
- "%%%%EndComments\n\n", G_date());
+ "%%%%Title: \n" "%%%%Creator: \n" "%%%%CreationDate: %s\n"
+ "%%%%Programming: E. Jorge Tizado, Spain 2009\n"
+ "%%%%EndComments\n\n", G_date());
/* BEGIN NO EMBEBED EPS file */
- if (PS.level > 0)
- {
+ if (PS.level > 0) {
fprintf(PS.fp, "%%%%BeginProlog\n");
fprintf(PS.fp, "/D {bind def} bind def\n");
fprintf(PS.fp, "/XD {exch def} D\n");
fprintf(PS.fp, "/str 20 string def\n");
fprintf(PS.fp, "/i2s {str cvs} D\n");
- fprintf(PS.fp, "/c2s {/charcode exch def /thechar ( ) dup 0 charcode put def thechar} D\n");
- fprintf(PS.fp, "/adds { exch dup length 2 index length add string dup dup 4 2 roll copy length " "4 -1 roll putinterval} D\n");
fprintf(PS.fp,
+ "/c2s {/charcode exch def /thechar ( ) dup 0 charcode put def thechar} D\n");
+ fprintf(PS.fp,
+ "/adds { exch dup length 2 index length add string dup dup 4 2 roll copy length "
+ "4 -1 roll putinterval} D\n");
+ fprintf(PS.fp,
"/FN { % (FontName) FN -\n"
" dup (-ISOLatin1) adds dup /F0 exch cvn def exch cvn\n"
" currentdict F0 known {pop pop}\n"
@@ -52,15 +54,21 @@
" /Encoding ISOLatin1Encoding def\n"
" /FontName 0 index def\n"
" currentdict end definefont pop} ifelse} D\n");
- fprintf(PS.fp, "/FS {/FS0 exch def F0 findfont FS0 scalefont setfont} D\n");
- fprintf(PS.fp, "/FE {F0 findfont 3 1 roll 1 index dup /FS0 exch def mul 0 0 4 -1 roll 0 0 6 packedarray makefont setfont} D\n");
- fprintf(PS.fp, "/FA {currentfont [1 0 0 1.25 0 0] makefont setfont} D\n");
- fprintf(PS.fp, "/FR {currentfont [1 0 0 .707 0 %d] makefont setfont} D\n", ((PS.flag & 2) ? 0: 2));
+ fprintf(PS.fp,
+ "/FS {/FS0 exch def F0 findfont FS0 scalefont setfont} D\n");
+ fprintf(PS.fp,
+ "/FE {F0 findfont 3 1 roll 1 index dup /FS0 exch def mul 0 0 4 -1 roll 0 0 6 packedarray makefont setfont} D\n");
+ fprintf(PS.fp,
+ "/FA {currentfont [1 0 0 1.25 0 0] makefont setfont} D\n");
+ fprintf(PS.fp,
+ "/FR {currentfont [1 0 0 .707 0 %d] makefont setfont} D\n",
+ ((PS.flag & 2) ? 0 : 2));
fprintf(PS.fp, "/++ {1 add} D\n");
fprintf(PS.fp, "/-- {1 sub} D\n");
fprintf(PS.fp, "/mm {360 mul 127 div} D\n");
fprintf(PS.fp, "/inch {72 mul} D\n");
- fprintf(PS.fp, "/B {4 1 roll 2 copy 5 index 5 index 8 1 roll newpath moveto lineto lineto lineto closepath} D\n");
+ fprintf(PS.fp,
+ "/B {4 1 roll 2 copy 5 index 5 index 8 1 roll newpath moveto lineto lineto lineto closepath} D\n");
fprintf(PS.fp, "/C {setrgbcolor} D\n");
fprintf(PS.fp, "/cLW {currentlinewidth} D\n");
fprintf(PS.fp, "/cP {currentpoint} D\n");
@@ -69,7 +77,8 @@
fprintf(PS.fp, "/F {gsave fill grestore} D\n");
fprintf(PS.fp, "/G {setgray} D\n");
fprintf(PS.fp, "/GET {get aload pop} D\n");
- fprintf(PS.fp, "/CG {0.11 mul exch 0.59 mul add exch 0.30 mul add setgray} D\n");
+ fprintf(PS.fp,
+ "/CG {0.11 mul exch 0.59 mul add exch 0.30 mul add setgray} D\n");
fprintf(PS.fp, "/GS {gsave} D\n");
fprintf(PS.fp, "/GR {grestore} D\n");
fprintf(PS.fp, "/LC {setlinecap} D\n");
@@ -86,90 +95,107 @@
fprintf(PS.fp, "/MS {moveto show} D\n");
fprintf(PS.fp, "/NM {newpath moveto} D\n");
fprintf(PS.fp, "/NP {newpath} D\n");
- fprintf(PS.fp, "/O {%s} D\n", ((PS.flag & 1) ? ".setopacityalpha" : "pop"));
+ fprintf(PS.fp, "/O {%s} D\n",
+ ((PS.flag & 1) ? ".setopacityalpha" : "pop"));
fprintf(PS.fp, "/RE {rectstroke} D\n");
- fprintf(PS.fp, "/Re {currentpoint 4 2 roll rectstroke} D\n");
- fprintf(PS.fp, "/RES {gsave newpath false charpath flattenpath pathbbox grestore} D\n");
+ fprintf(PS.fp, "/Re {currentpoint 4 2 roll rectstroke} D\n");
+ fprintf(PS.fp,
+ "/RES {gsave newpath false charpath flattenpath pathbbox grestore} D\n");
fprintf(PS.fp, "/RF {rectfill} D\n");
- fprintf(PS.fp, "/Rf {currentpoint 4 2 roll rectfill} D\n");
+ fprintf(PS.fp, "/Rf {currentpoint 4 2 roll rectfill} D\n");
fprintf(PS.fp, "/RC {rectclip} D\n");
fprintf(PS.fp, "/ROT {rotate} D\n");
fprintf(PS.fp, "/S {stroke} D\n");
fprintf(PS.fp, "/SC {scale} D\n");
- fprintf(PS.fp, "/SW {stringwidth pop} D\n");
- fprintf(PS.fp, "/SWH {gsave newpath 0 0 moveto false charpath flattenpath pathbbox " "4 2 roll pop pop grestore} D\n");
+ fprintf(PS.fp, "/SW {stringwidth pop} D\n");
+ fprintf(PS.fp,
+ "/SWH {gsave newpath 0 0 moveto false charpath flattenpath pathbbox "
+ "4 2 roll pop pop grestore} D\n");
fprintf(PS.fp, "/SHL {show} D\n");
fprintf(PS.fp, "/SHR {dup SW neg 0 rmoveto show} D\n");
fprintf(PS.fp, "/SHC {dup SW -2 div 0 rmoveto show} D\n");
fprintf(PS.fp, "/SHLC {dup SWH -2 div 0 exch rmoveto pop show} D\n");
- fprintf(PS.fp, "/SHRC {dup SWH -2 div exch neg exch rmoveto show} D\n");
- fprintf(PS.fp, "/SHCC {dup SWH -2 div exch 2 div neg exch rmoveto show} D\n");
- fprintf(PS.fp, "/SHS {(:) anchorsearch {pop exch 0 rmoveto SHR} {(.) anchorsearch {pop exch 2 div 0 rmoveto SHC} {exch pop SHL} ifelse} ifelse} D\n");
- fprintf(PS.fp, "/COOR {(º) search {GS SHL SHL FR SHL GR} {dup length /n XD {c2s GS n 4 lt n 5 gt or {FR} if show cP GR M n -- /n XD} forall} ifelse} D\n");
+ fprintf(PS.fp,
+ "/SHRC {dup SWH -2 div exch neg exch rmoveto show} D\n");
+ fprintf(PS.fp,
+ "/SHCC {dup SWH -2 div exch 2 div neg exch rmoveto show} D\n");
+ fprintf(PS.fp,
+ "/SHS {(:) anchorsearch {pop exch 0 rmoveto SHR} {(.) anchorsearch {pop exch 2 div 0 rmoveto SHC} {exch pop SHL} ifelse} ifelse} D\n");
+ fprintf(PS.fp,
+ "/COOR {(º) search {GS SHL SHL FR SHL GR} {dup length /n XD {c2s GS n 4 lt n 5 gt or {FR} if show cP GR M n -- /n XD} forall} ifelse} D\n");
fprintf(PS.fp, "/SVC {{c2s GS SHC GR 0 FS0 neg MR} forall} D\n");
- fprintf(PS.fp, "/SWx {0 exch {SW 2 copy lt {exch} if pop} forall} D\n");
+ fprintf(PS.fp,
+ "/SWx {0 exch {SW 2 copy lt {exch} if pop} forall} D\n");
fprintf(PS.fp, "/TR {translate} D\n");
- fprintf(PS.fp, "/TSEL {(:) anchorsearch {pop SHR} {(.) anchorsearch {pop SHC} {SHL} ifelse} ifelse} D\n");
- fprintf(PS.fp, "/TXT {(|) search {GS TSEL GR pop 0 FS0 -1.2 mul rmoveto TXT} {TSEL} ifelse} D\n");
- fprintf(PS.fp, "/TCIR {SWH 2 copy gt {pop} {exch pop} ifelse 2 div 2 add cP 3 -1 roll 0 360 NP arc CP S} D\n");
- fprintf(PS.fp, "/RO {GS dup cLW exch 0 lt {neg} if add exch cLW add exch cLW -2 div dup 2 index 0 lt {neg} if TR RE GR} D\n");
- fprintf(PS.fp, "/RESET {/x xo mgx add def /y yo mgy sub def /col 0 def /row 0 def} def\n");
- fprintf(PS.fp, "/READJUST {SWH mg add dup hg add /hg XD mg add /mgy XD mgx 2 mul add dup wd gt {/wd XD} {pop} ifelse} def\n");
- fprintf(PS.fp, "/COL {/col XD xo mgx add 0 1 col -- {ARw exch get dx add add} for /x XD} def\n");
- fprintf(PS.fp, "/ROW {/row XD yo mgy sub 0 1 row -- {ARh exch get dy add sub} for /y XD} def\n");
+ fprintf(PS.fp,
+ "/TSEL {(:) anchorsearch {pop SHR} {(.) anchorsearch {pop SHC} {SHL} ifelse} ifelse} D\n");
+ fprintf(PS.fp,
+ "/TXT {(|) search {GS TSEL GR pop 0 FS0 -1.2 mul rmoveto TXT} {TSEL} ifelse} D\n");
+ fprintf(PS.fp,
+ "/TCIR {SWH 2 copy gt {pop} {exch pop} ifelse 2 div 2 add cP 3 -1 roll 0 360 NP arc CP S} D\n");
+ fprintf(PS.fp,
+ "/RO {GS dup cLW exch 0 lt {neg} if add exch cLW add exch cLW -2 div dup 2 index 0 lt {neg} if TR RE GR} D\n");
+ fprintf(PS.fp,
+ "/RESET {/x xo mgx add def /y yo mgy sub def /col 0 def /row 0 def} def\n");
+ fprintf(PS.fp,
+ "/READJUST {SWH mg add dup hg add /hg XD mg add /mgy XD mgx 2 mul add dup wd gt {/wd XD} {pop} ifelse} def\n");
+ fprintf(PS.fp,
+ "/COL {/col XD xo mgx add 0 1 col -- {ARw exch get dx add add} for /x XD} def\n");
+ fprintf(PS.fp,
+ "/ROW {/row XD yo mgy sub 0 1 row -- {ARh exch get dy add sub} for /y XD} def\n");
/* end */
fprintf(PS.fp, "%%%%EndProlog\n");
/* Page specifications */
- fprintf(PS.fp, "<< /PageSize [%d %d] >> setpagedevice\n", (int)(PS.page.width), (int)(PS.page.height));
+ fprintf(PS.fp, "<< /PageSize [%d %d] >> setpagedevice\n",
+ (int)(PS.page.width), (int)(PS.page.height));
}
/* END NO EPS file */
/* Prepare the map */
start_map();
- if (!PS.page.fcolor.none)
- {
+ if (!PS.page.fcolor.none) {
set_ps_color(&(PS.page.fcolor));
- fprintf(PS.fp, "0 0 %d %d RF\n", (int)(PS.page.width), (int)(PS.page.height));
+ fprintf(PS.fp, "0 0 %d %d RF\n", (int)(PS.page.width),
+ (int)(PS.page.height));
}
- if (PS.draft) /* print a reticule as watermark on page */
- {
- fprintf(PS.fp, "GS .5 LW 0.9 G /Helvetica findfont 7 scalefont setfont\n");
- fprintf(PS.fp, "0 0 10 mm %d {0 M GS 0.5 G 1 1 MR dup i2s show ++ GR 0 %d LRS} for pop\n",
+ if (PS.draft) { /* print a reticule as watermark on page */
+ fprintf(PS.fp,
+ "GS .5 LW 0.9 G /Helvetica findfont 7 scalefont setfont\n");
+ fprintf(PS.fp,
+ "0 0 10 mm %d {0 M GS 0.5 G 1 1 MR dup i2s show ++ GR 0 %d LRS} for pop\n",
(int)(PS.page.width), (int)(PS.page.height));
- fprintf(PS.fp, "0 %d -10 mm 0 {0 exch M GS 0.5 G 1 1 MR dup i2s show ++ GR %d 0 LRS} for pop\n",
+ fprintf(PS.fp,
+ "0 %d -10 mm 0 {0 exch M GS 0.5 G 1 1 MR dup i2s show ++ GR %d 0 LRS} for pop\n",
(int)(PS.page.height), (int)(PS.page.width));
fprintf(PS.fp, "[1 2] 0 LD \n");
- fprintf(PS.fp, "5 mm 10 mm %d {0 M 0 %d LRS} for\n",
- (int)(PS.page.width), (int)(PS.page.height));
- fprintf(PS.fp, "%d 5 mm sub -10 mm 0 {0 exch M %d 0 LRS} for\n",
- (int)(PS.page.height), (int)(PS.page.width));
+ fprintf(PS.fp, "5 mm 10 mm %d {0 M 0 %d LRS} for\n",
+ (int)(PS.page.width), (int)(PS.page.height));
+ fprintf(PS.fp, "%d 5 mm sub -10 mm 0 {0 exch M %d 0 LRS} for\n",
+ (int)(PS.page.height), (int)(PS.page.width));
fprintf(PS.fp, "GR\n");
}
/* PAPER CUSTOM DRAWS */
- if (PS.n_draws > 0)
- {
- for (i = 0; i < PS.n_draws; i++)
- {
+ if (PS.n_draws > 0) {
+ for (i = 0; i < PS.n_draws; i++) {
if (PS.draw.flag[i] == 2)
set_draw(PS.draw.key[i], PS.draw.data[i]);
}
}
/* CLIP to MAP AREA */
fprintf(PS.fp, "gsave 0 0 0 C ");
- fprintf(PS.fp, "%.4f %.4f %.4f %.4f rectclip\n", PS.map_x, PS.map_y, PS.map_w, PS.map_h);
- if (!PS.fcolor.none)
- {
+ fprintf(PS.fp, "%.4f %.4f %.4f %.4f rectclip\n", PS.map_x, PS.map_y,
+ PS.map_w, PS.map_h);
+ if (!PS.fcolor.none) {
set_ps_color(&(PS.fcolor));
- fprintf(PS.fp, "%.4f %.4f %.4f %.4f RF\n", PS.map_x, PS.map_y, PS.map_w, PS.map_h);
+ fprintf(PS.fp, "%.4f %.4f %.4f %.4f RF\n", PS.map_x, PS.map_y,
+ PS.map_w, PS.map_h);
}
/* needed by uncolored patterns */
fprintf(PS.fp, "[/Pattern /DeviceRGB] setcolorspace\n");
/* RASTER */
- if (PS.rst.files != 0)
- {
+ if (PS.rst.files != 0) {
set_raster();
/* outline, if requested */
- if (PS.rst.outline.width > 0.)
- {
+ if (PS.rst.outline.width > 0.) {
if (!G_raster_map_is_fp(PS.rst.name[0], PS.rst.mapset[0]))
set_outline();
else
@@ -177,109 +203,88 @@
}
}
/* VECTOR (masked) */
- if (PS.vct_files != 0)
- {
- set_vector(MASKED, AREAS);
- set_vector(MASKED, LINES);
- set_vector(MASKED, POINTS);
- set_vector(MASKED, LABELS);
+ if (PS.vct_files != 0) {
+ set_vector(MASKED, AREAS);
+ set_vector(MASKED, LINES);
+ set_vector(MASKED, POINTS);
+ set_vector(MASKED, LABELS);
}
/* RASTER MASK */
- if (PS.need_mask && PS.rst.do_mask)
- {
+ if (PS.need_mask && PS.rst.do_mask) {
set_mask();
}
/* VECTOR-LINES/AREAS under grids (unmasked) */
- if (PS.vct_files != 0)
- {
+ if (PS.vct_files != 0) {
set_vector(UNMASKED, AREAS);
set_vector(UNMASKED, LINES);
}
/* CLIPED CUSTOM DRAWS */
- if (PS.n_draws > 0)
- {
+ if (PS.n_draws > 0) {
/* fprintf(PS.fp, "0 0 0 C "); // default color */
- for (i = 0; i < PS.n_draws; i++)
- {
+ for (i = 0; i < PS.n_draws; i++) {
if (PS.draw.flag[i] == 0)
set_draw(PS.draw.key[i], PS.draw.data[i]);
}
}
/* GRIDS LINES INSIDE OF BORDER */
- if (PS.grid.sep > 0)
- {
+ if (PS.grid.sep > 0) {
set_lines_grid();
}
- if (PS.geogrid.sep > 0)
- {
+ if (PS.geogrid.sep > 0) {
set_lines_geogrid();
}
/* VECTOR-POINTS/LABELS on grids (unmasked) */
- if (PS.vct_files != 0)
- {
+ if (PS.vct_files != 0) {
set_vector(UNMASKED, POINTS);
set_vector(UNMASKED, LABELS);
}
/* CLIPED CUSTOM DRAWS ONTO ALL MAP ITEMS */
- if (PS.n_draws > 0)
- {
- /* fprintf(PS.fp, "0 0 0 C "); // default color */
- for (i = 0; i < PS.n_draws; i++)
- {
- if (PS.draw.flag[i] == 3)
- set_draw(PS.draw.key[i], PS.draw.data[i]);
- }
+ if (PS.n_draws > 0) {
+ /* fprintf(PS.fp, "0 0 0 C "); // default color */
+ for (i = 0; i < PS.n_draws; i++) {
+ if (PS.draw.flag[i] == 3)
+ set_draw(PS.draw.key[i], PS.draw.data[i]);
+ }
}
/* no more work in the map area */
/********************************/
fprintf(PS.fp, "grestore\n");
/* BORDER */
- if (PS.do_border && PS.brd.width > 0 && !PS.brd.color.none)
- {
+ if (PS.do_border && PS.brd.width > 0 && !PS.brd.color.none) {
set_ps_line(&(PS.brd));
set_ps_rect(PS.map_x, PS.map_y, PS.map_w, PS.map_h);
}
/* GRID NUMBER, OUTSIDE OF BORDER */
- if (PS.geogrid.sep > 0)
- {
+ if (PS.geogrid.sep > 0) {
set_numbers_geogrid();
}
- if (PS.grid.sep > 0)
- {
+ if (PS.grid.sep > 0) {
set_numbers_grid();
}
/* LEGENDS */
- if (PS.do_rlegend)
- {
- if (G_raster_map_is_fp(PS.rl.name, PS.rl.mapset) || PS.rl.do_gradient)
- {
+ if (PS.do_rlegend) {
+ if (G_raster_map_is_fp(PS.rl.name, PS.rl.mapset) || PS.rl.do_gradient) {
set_rlegend_gradient();
}
- else
- {
+ else {
set_rlegend_cats();
}
}
- if (PS.do_vlegend)
- {
+ if (PS.do_vlegend) {
set_vlegend();
}
/* NOTES */
- for (i = 0; i < PS.n_notes; i++)
- {
+ for (i = 0; i < PS.n_notes; i++) {
set_note(i);
}
/* SCALEBAR */
- if (PS.sbar.segments > 0 && PS.sbar.length > 0)
- {
+ if (PS.sbar.segments > 0 && PS.sbar.length > 0) {
set_scalebar();
}
/* FREE CUSTOM DRAWS */
- if (PS.n_draws > 0)
- {
- for (i = 0; i < PS.n_draws; i++)
- {
+ if (PS.n_draws > 0) {
+ for (i = 0; i < PS.n_draws; i++) {
if (PS.draw.flag[i] == 1)
set_draw(PS.draw.key[i], PS.draw.data[i]);
}
@@ -287,16 +292,14 @@
/* END */
/* BEGIN NO EPS file */
- if (PS.level > 0)
- {
+ if (PS.level > 0) {
fprintf(PS.fp, "showpage\n");
fprintf(PS.fp, "%%%%Trailer\n");
fprintf(PS.fp, "%%%%EOF\n");
fclose(PS.fp);
}
/* FREE ALLOCATED POINTERS */
- for (i = 0; i < PS.vct_files; i++)
- {
+ for (i = 0; i < PS.vct_files; i++) {
G_free(PS.vct[i].data);
G_free(PS.vct[i].item);
/*
Modified: grass-addons/postscript/ps.output/ps_info.h
===================================================================
--- grass-addons/postscript/ps.output/ps_info.h 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/ps_info.h 2010-12-08 23:19:08 UTC (rev 44565)
@@ -82,8 +82,10 @@
#ifdef MAIN
struct PS3_info PS;
+
int sec_draw; /* used in PS_plot */
#else
extern struct PS3_info PS;
+
extern int sec_draw;
#endif
Modified: grass-addons/postscript/ps.output/r_block.c
===================================================================
--- grass-addons/postscript/ps.output/r_block.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/r_block.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -20,47 +20,40 @@
int read_block(int i)
{
char buf[1024];
+
char *key, *data;
G_debug(1, "Reading legend settings ..");
/* process options */
- while (input(2, buf))
- {
- if (!key_data(buf, &key, &data))
- {
+ while (input(2, buf)) {
+ if (!key_data(buf, &key, &data)) {
continue;
}
- if (KEY("lpos"))
- {
- if (sscanf(data, "%d", &(PS.vct[i].lpos)) != 1)
- {
+ if (KEY("lpos")) {
+ if (sscanf(data, "%d", &(PS.vct[i].lpos)) != 1) {
error(key, data, "illegal lpos request (legend)");
}
continue;
}
- if (KEY("cols"))
- {
- int n = sscanf(data, "%d %lf", &(PS.vct[i].cols), &(PS.vct[i].xspan));
+ if (KEY("cols")) {
+ int n =
+ sscanf(data, "%d %lf", &(PS.vct[i].cols), &(PS.vct[i].xspan));
- if (n != 1 && n != 2)
- {
+ if (n != 1 && n != 2) {
error(key, data, "illegal cols/span request (legend)");
}
- else
- {
- if (PS.vct[i].cols <= 0)
+ else {
+ if (PS.vct[i].cols <= 0)
PS.vct[i].cols = 1;
if (n == 1)
PS.vct[i].xspan = -1.;
}
continue;
}
- if (KEY("interline") || KEY("dy"))
- {
- if (scan_dimen(data, &(PS.vct[i].yspan)) != 1)
- {
- PS.vct[i].yspan = -1.;
+ if (KEY("interline") || KEY("dy")) {
+ if (scan_dimen(data, &(PS.vct[i].yspan)) != 1) {
+ PS.vct[i].yspan = -1.;
error(key, data, "illegal interline request (legend)");
}
continue;
Modified: grass-addons/postscript/ps.output/r_draw.c
===================================================================
--- grass-addons/postscript/ps.output/r_draw.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/r_draw.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -22,25 +22,23 @@
int read_draw(char *name)
{
char buf[1024];
+
char *key, *data;
+
int type = 0;
G_debug(1, "Reading draw settings ..");
if (strcmp(name, "free") == 0)
type = 1;
- else
- if (strcmp(name, "paper") == 0)
- type = 2;
- else
- if (strcmp(name, "legend") == 0)
- type = 3;
+ else if (strcmp(name, "paper") == 0)
+ type = 2;
+ else if (strcmp(name, "legend") == 0)
+ type = 3;
/* process options */
- while (input(2, buf))
- {
- if (!key_data(buf, &key, &data))
- {
+ while (input(2, buf)) {
+ if (!key_data(buf, &key, &data)) {
continue;
}
Modified: grass-addons/postscript/ps.output/r_font.c
===================================================================
--- grass-addons/postscript/ps.output/r_font.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/r_font.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -31,10 +31,8 @@
dp = data;
if (*dp >= 'a' && *dp <= 'z')
*dp = *dp - 'a' + 'A';
- while (*dp)
- {
- if (*dp == ' ')
- {
+ while (*dp) {
+ if (*dp == ' ') {
*dp++ = '-';
if (*dp >= 'a' && *dp <= 'z')
*dp = *dp - 'a' + 'A';
@@ -57,6 +55,7 @@
int read_font(char *arg, PSFONT * font)
{
char buf[1024];
+
char *key, *data;
G_debug(1, "Reading font settings ..");
@@ -66,40 +65,31 @@
/* process options */
- while (input(3, buf))
- {
- if (!key_data(buf, &key, &data))
- {
+ while (input(3, buf)) {
+ if (!key_data(buf, &key, &data)) {
continue;
}
- if (KEY("name"))
- {
+ if (KEY("name")) {
get_font(data);
strcpy(font->name, data);
continue;
}
- if (KEY("size"))
- {
- if (scan_dimen(data, &(font->size)) != 1)
- {
+ if (KEY("size")) {
+ if (scan_dimen(data, &(font->size)) != 1) {
font->size = 10.;
error(key, data, "illegal size request (font)");
}
continue;
}
- if (KEY("extend"))
- {
- if (scan_dimen(data, &(font->extend)) != 1)
- {
+ if (KEY("extend")) {
+ if (scan_dimen(data, &(font->extend)) != 1) {
font->extend = 1.;
error(key, data, "illegal extent request (font)");
}
continue;
}
- if (KEY("color"))
- {
- if (!scan_color(data, &(font->color)))
- {
+ if (KEY("color")) {
+ if (!scan_color(data, &(font->color))) {
error(key, data, "illegal color request (font)");
}
continue;
Modified: grass-addons/postscript/ps.output/r_frame.c
===================================================================
--- grass-addons/postscript/ps.output/r_frame.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/r_frame.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -36,6 +36,7 @@
int read_frame(PSFRAME * box)
{
char buf[1024];
+
char *key, *data;
G_debug(1, "Reading frame settings ..");
@@ -45,22 +46,17 @@
/* process options */
- while (input(3, buf))
- {
- if (!key_data(buf, &key, &data))
- {
+ while (input(3, buf)) {
+ if (!key_data(buf, &key, &data)) {
continue;
}
- if (KEY("where"))
- {
+ if (KEY("where")) {
char xx[50], yy[50];
- if (sscanf(data, "%s %s", xx, yy) != 2)
- {
+ if (sscanf(data, "%s %s", xx, yy) != 2) {
error(key, data, "illegal box where request");
}
- else
- {
+ else {
if (scan_dimen(xx, &(box->x)) == 2)
box->x *= -1;
if (scan_dimen(yy, &(box->y)) == 2)
@@ -68,58 +64,44 @@
continue;
}
}
- if (KEY("offset"))
- {
- if (sscanf(data, "%lf %lf", &(box->xset), &(box->yset)) != 2)
- {
+ if (KEY("offset")) {
+ if (sscanf(data, "%lf %lf", &(box->xset), &(box->yset)) != 2) {
error(key, data, "illegal box offset request");
}
continue;
}
- if (KEY("ref"))
- {
- if (!scan_ref(data, &(box->xref), &(box->yref)))
- {
+ if (KEY("ref")) {
+ if (!scan_ref(data, &(box->xref), &(box->yref))) {
error(key, data, "illegal box ref request");
}
continue;
}
- if (KEY("border"))
- {
- if (scan_dimen(data, &(box->border)) != 1)
- {
+ if (KEY("border")) {
+ if (scan_dimen(data, &(box->border)) != 1) {
box->border = -1;
}
continue;
}
- if (KEY("color"))
- {
- if (!scan_color(data, &(box->color)))
- {
+ if (KEY("color")) {
+ if (!scan_color(data, &(box->color))) {
error(key, data, "illegal box color request");
}
continue;
}
- if (KEY("fcolor"))
- {
- if (!scan_color(data, &(box->fcolor)))
- {
+ if (KEY("fcolor")) {
+ if (!scan_color(data, &(box->fcolor))) {
error(key, data, "illegal box fcolor request");
}
continue;
}
- if (KEY("margin"))
- {
- if (scan_dimen(data, &(box->margin)) != 1)
- {
+ if (KEY("margin")) {
+ if (scan_dimen(data, &(box->margin)) != 1) {
error(key, data, "illegal box margin request");
}
continue;
}
- if (KEY("rotate"))
- {
- if (scan_dimen(data, &(box->rotate)) != 1)
- {
+ if (KEY("rotate")) {
+ if (scan_dimen(data, &(box->rotate)) != 1) {
error(key, data, "illegal box rotate request");
}
continue;
Modified: grass-addons/postscript/ps.output/r_grid.c
===================================================================
--- grass-addons/postscript/ps.output/r_grid.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/r_grid.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -21,6 +21,7 @@
int read_grid(GRID * grid, int type)
{
char buf[1024];
+
char *key, *data;
G_debug(1, "Reading grid settings ..");
@@ -39,115 +40,92 @@
grid->msubdiv = -1;
/* process options */
- while (input(2, buf))
- {
- if (!key_data(buf, &key, &data))
- {
+ while (input(2, buf)) {
+ if (!key_data(buf, &key, &data)) {
continue;
}
- if (KEY("major") || KEY("line"))
- {
+ if (KEY("major") || KEY("line")) {
char str[50];
- if (sscanf(data, "%s", str) != 1)
- {
+ if (sscanf(data, "%s", str) != 1) {
error(key, data, "illegal major request (grid)");
}
- if (G_projection() == PROJECTION_LL || type == 0)
- {
+ if (G_projection() == PROJECTION_LL || type == 0) {
double seconds;
scan_second(str, &seconds);
grid->sep = (int)seconds;
}
- else
- {
+ else {
grid->sep = atoi(str); /* units, usually meters */
}
- if (grid->sep <= 0)
- {
+ if (grid->sep <= 0) {
error(key, data, "illegal major request (grid)");
}
read_psline("", &(grid->line));
continue;
}
- if (KEY("minor"))
- {
+ if (KEY("minor")) {
char str[50];
- if (sscanf(data, "%s", str) != 1)
- {
+ if (sscanf(data, "%s", str) != 1) {
error(key, data, "illegal minor request (grid)");
}
- if (G_projection() == PROJECTION_LL || type == 0)
- {
+ if (G_projection() == PROJECTION_LL || type == 0) {
double seconds;
scan_second(str, &seconds);
grid->msep = (int)seconds;
}
- else
- {
+ else {
grid->msep = atoi(str); /* units, usually meters */
}
read_psline("", &(grid->mline));
continue;
}
- if (KEY("subminor"))
- {
+ if (KEY("subminor")) {
G_strip(data);
grid->msubdiv = atoi(data);
continue;
}
- if (KEY("format"))
- {
+ if (KEY("format")) {
G_strip(data);
- if (strncmp(data, "in", 2) == 0)
- {
+ if (strncmp(data, "in", 2) == 0) {
grid->format = 0;
}
- else if (strncmp(data, "out", 3) == 0)
- {
+ else if (strncmp(data, "out", 3) == 0) {
grid->format = 1;
}
- else if (strncmp(data, "+out", 4) == 0)
- {
+ else if (strncmp(data, "+out", 4) == 0) {
grid->format = 1;
grid->lsides = 4;
}
- else if (strcmp(data, "iho") == 0)
- {
+ else if (strcmp(data, "iho") == 0) {
grid->format = 2;
}
- else if (strcmp(data, "can") == 0)
- {
+ else if (strcmp(data, "can") == 0) {
grid->format = 3;
}
else
grid->format = atoi(data);
continue;
}
- if (KEY("trim"))
- {
+ if (KEY("trim")) {
G_strip(data);
grid->trim = atoi(data);
continue;
}
- if (KEY("font"))
- {
+ if (KEY("font")) {
read_font(data, &(grid->font));
continue;
}
- if (KEY("fcolor"))
- {
- if (!scan_color(data, &(grid->fcolor)))
- {
+ if (KEY("fcolor")) {
+ if (!scan_color(data, &(grid->fcolor))) {
error(key, data, "illegal fcolor request (grid)");
}
continue;
}
- if (KEY("cross"))
- {
+ if (KEY("cross")) {
grid->cross = atof(data);
continue;
}
@@ -155,8 +133,7 @@
}
/* swap major and minor if ... */
- if (grid->sep < grid->msep)
- {
+ if (grid->sep < grid->msep) {
int tmp;
tmp = grid->msep;
@@ -165,8 +142,7 @@
}
/* draw minor? .... */
- if (grid->mline.width <= 0. || grid->msep == 0)
- {
+ if (grid->mline.width <= 0. || grid->msep == 0) {
grid->msep = 0; /* dont draw minor grid */
}
Modified: grass-addons/postscript/ps.output/r_line.c
===================================================================
--- grass-addons/postscript/ps.output/r_line.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/r_line.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -31,7 +31,9 @@
int read_psline(char *arg, PSLINE * line)
{
char buf[1024];
+
char *key, *data;
+
char i, dash[31];
G_debug(1, "Reading line settings ..");
@@ -40,10 +42,8 @@
default_psline(line);
/* inline argument: width */
- if (arg[0] != 0)
- {
- if (scan_dimen(arg, &(line->width)) != 1)
- {
+ if (arg[0] != 0) {
+ if (scan_dimen(arg, &(line->width)) != 1) {
line->width = 1.;
error("ERROR:", arg, "illegal line width request");
}
@@ -51,37 +51,30 @@
}
/* process options */
- while (input(3, buf))
- {
- if (!key_data(buf, &key, &data))
- {
+ while (input(3, buf)) {
+ if (!key_data(buf, &key, &data)) {
continue;
}
- if (KEY("width"))
- {
- if (scan_dimen(data, &(line->width)) != 1)
- {
+ if (KEY("width")) {
+ if (scan_dimen(data, &(line->width)) != 1) {
line->width = -1.;
error(key, data, "illegal line width request");
}
continue;
}
- if (KEY("color"))
- {
- if (!scan_color(data, &(line->color)))
- {
+ if (KEY("color")) {
+ if (!scan_color(data, &(line->color))) {
error(key, data, "illegal line color request");
}
continue;
}
- if (KEY("style"))
- {
+ if (KEY("style")) {
char str[50];
+
int x, o;
x = sscanf(data, "%s %s", str, &o);
- if (x != 1 && x != 2)
- {
+ if (x != 1 && x != 2) {
error(key, data, "illegal line style request");
continue;
}
@@ -89,37 +82,31 @@
line->odash = o;
G_strip(str);
- if (strncmp(str, "solid", 5) == 0)
- {
+ if (strncmp(str, "solid", 5) == 0) {
line->dash = G_store("");
continue;
}
- else if (strncmp(str, "dashed", 5) == 0)
- {
+ else if (strncmp(str, "dashed", 5) == 0) {
line->dash = G_store("3 2");
continue;
}
- else if (strncmp(str, "dotted", 3) == 0)
- {
+ else if (strncmp(str, "dotted", 3) == 0) {
line->dash = G_store("1");
continue;
}
- else if (strncmp(str, "dashdotted", 5) == 0)
- {
+ else if (strncmp(str, "dashdotted", 5) == 0) {
line->dash = G_store("4 2 1 2");
continue;
}
char *dp;
- for (i = 0, dp = str; *dp && i < 20; dp++)
- {
+ for (i = 0, dp = str; *dp && i < 20; dp++) {
if (*dp < '0' || *dp > '9')
break;
dash[i++] = *dp;
dash[i++] = ' ';
}
- if (i == 0)
- {
+ if (i == 0) {
error(key, str, "illegal line style");
continue;
}
@@ -127,21 +114,17 @@
line->dash = G_store(dash);
continue;
}
- if (KEY("cap"))
- {
+ if (KEY("cap")) {
G_strip(data);
- if (strncmp(data, "butt", 2) == 0)
- {
+ if (strncmp(data, "butt", 2) == 0) {
line->cap = LINECAP_BUTT;
continue;
}
- else if (strncmp(data, "round", 2) == 0)
- {
+ else if (strncmp(data, "round", 2) == 0) {
line->cap = LINECAP_ROUND;
continue;
}
- else if (strncmp(data, "extended_butt", 2) == 0)
- {
+ else if (strncmp(data, "extended_butt", 2) == 0) {
line->cap = LINECAP_EXTBUTT;
continue;
}
Modified: grass-addons/postscript/ps.output/r_maparea.c
===================================================================
--- grass-addons/postscript/ps.output/r_maparea.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/r_maparea.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -21,7 +21,9 @@
int read_maparea(void)
{
char buf[1024];
+
char *key, *data;
+
double point;
G_debug(1, "Reading maparea settings ..");
@@ -30,70 +32,54 @@
default_psline(&(PS.brd));
/* process options */
- while (input(2, buf))
- {
- if (!key_data(buf, &key, &data))
- {
+ while (input(2, buf)) {
+ if (!key_data(buf, &key, &data)) {
continue;
}
- if (KEY("border"))
- {
- if (scan_dimen(data, &(point)) != 1)
- {
+ if (KEY("border")) {
+ if (scan_dimen(data, &(point)) != 1) {
error(key, data, "illegal border width request (maparea)");
}
PS.brd.width = point;
PS.do_border = 1;
continue;
}
- if (KEY("color"))
- {
- if (!scan_color(data, &(PS.brd.color)))
- {
+ if (KEY("color")) {
+ if (!scan_color(data, &(PS.brd.color))) {
error(key, data, "illegal border color request (maparea)");
}
continue;
}
- if (KEY("fcolor"))
- {
- if (!scan_color(data, &(PS.fcolor)))
- {
+ if (KEY("fcolor")) {
+ if (!scan_color(data, &(PS.fcolor))) {
error(key, data, "illegal fcolor request (maparea)");
}
continue;
}
- if (KEY("width"))
- {
- if (scan_dimen(data, &(point)) != 1)
- {
+ if (KEY("width")) {
+ if (scan_dimen(data, &(point)) != 1) {
error(key, data, "illegal map width request (maparea)");
}
PS.map_w = point;
continue;
}
- if (KEY("height"))
- {
- if (scan_dimen(data, &(point)) != 1)
- {
+ if (KEY("height")) {
+ if (scan_dimen(data, &(point)) != 1) {
error(key, data, "illegal map height request (maparea)");
}
PS.map_h = point;
continue;
}
- if (KEY("top"))
- {
- if (scan_dimen(data, &(point)) != 1)
- {
+ if (KEY("top")) {
+ if (scan_dimen(data, &(point)) != 1) {
error(key, data, "illegal map top request (maparea)");
}
PS.map_top = point;
continue;
continue;
}
- if (KEY("left"))
- {
- if (scan_dimen(data, &(point)) != 1)
- {
+ if (KEY("left")) {
+ if (scan_dimen(data, &(point)) != 1) {
error(key, data, "illegal map left request (maparea)");
}
PS.map_x = point;
Modified: grass-addons/postscript/ps.output/r_note.c
===================================================================
--- grass-addons/postscript/ps.output/r_note.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/r_note.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -22,6 +22,7 @@
int read_note(char *name)
{
char buf[1024];
+
char *key, *data;
G_debug(1, "Reading note settings ..");
@@ -34,56 +35,44 @@
default_frame(&(PS.note[PS.n_notes].box), LEFT, UPPER);
/* inline argument */
- if (*name != 0)
- {
+ if (*name != 0) {
strncpy(PS.note[PS.n_notes].text, name, 1024);
PS.note[PS.n_notes].text[1023] = 0;
}
/* process options */
- while (input(2, buf))
- {
- if (!key_data(buf, &key, &data))
- {
+ while (input(2, buf)) {
+ if (!key_data(buf, &key, &data)) {
continue;
}
- if (KEY("frame"))
- {
+ if (KEY("frame")) {
read_frame(&(PS.note[PS.n_notes].box));
continue;
}
- if (KEY("font"))
- {
+ if (KEY("font")) {
read_font(data, &(PS.note[PS.n_notes].font));
continue;
}
- if (KEY("text"))
- {
- if (sscanf(data, "%s", PS.note[PS.n_notes].text) != 1)
- {
+ if (KEY("text")) {
+ if (sscanf(data, "%s", PS.note[PS.n_notes].text) != 1) {
PS.note[PS.n_notes].text[0] = 0;
error(key, data, "illegal note sub-request");
}
- else
- {
+ else {
strncpy(PS.note[PS.n_notes].text, data, 1024);
PS.note[PS.n_notes].text[1023] = 0;
}
continue;
}
- if (KEY("width"))
- {
- if (scan_dimen(data, &(PS.note[PS.n_notes].width)) != 1)
- {
+ if (KEY("width")) {
+ if (scan_dimen(data, &(PS.note[PS.n_notes].width)) != 1) {
PS.note[PS.n_notes].width = 0.;
error(key, data, "illegal width sub-request");
}
continue;
}
- if (KEY("angle"))
- {
- if (sscanf(data, "%lf", &(PS.note[PS.n_notes].angle)) != 1)
- {
+ if (KEY("angle")) {
+ if (sscanf(data, "%lf", &(PS.note[PS.n_notes].angle)) != 1) {
PS.note[PS.n_notes].angle = 0.;
error(key, data, "illegal angle sub-request");
}
Modified: grass-addons/postscript/ps.output/r_palette.c
===================================================================
--- grass-addons/postscript/ps.output/r_palette.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/r_palette.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -26,119 +26,110 @@
int read_palette(void)
{
char buf[1024];
+
char *key, *data;
+
int i;
+
char name[50];
+
PSCOLOR color, colorb;
G_debug(1, "Reading palette settings ..");
/* process options */
- while (input(2, buf))
- {
- if (!key_data(buf, &key, &data))
- {
+ while (input(2, buf)) {
+ if (!key_data(buf, &key, &data)) {
continue;
}
- if (KEY("wheel", 2))
- {
- if (sscanf(data, "%d %s", &i, name) != 2 || i < 2)
- {
- error(key, data, "illegal wheel sub-request (palette)");
+ if (KEY("wheel", 2)) {
+ if (sscanf(data, "%d %s", &i, name) != 2 || i < 2) {
+ error(key, data, "illegal wheel sub-request (palette)");
}
pure_color(name, i);
continue;
}
- if (KEY("monochrome", 4))
- {
+ if (KEY("monochrome", 4)) {
char color_name[50];
- if (sscanf(data, "%s %d %s", color_name, &i, name) != 3)
- {
- error(key, data, "illegal monochrome sub-request (palette)");
+ if (sscanf(data, "%s %d %s", color_name, &i, name) != 3) {
+ error(key, data, "illegal monochrome sub-request (palette)");
}
- if (i < 1 || !scan_color(color_name, &color))
- {
- error(key, data, "illegal monochrome sub-request (palette)");
+ if (i < 1 || !scan_color(color_name, &color)) {
+ error(key, data, "illegal monochrome sub-request (palette)");
}
monochrome(name, &color, i);
continue;
}
- if (KEY("complementary", 4))
- {
+ if (KEY("complementary", 4)) {
char color_name[50];
- if (sscanf(data, "%s %d %s", color_name, &i, name) != 3)
- {
- error(key, data, "illegal complementary sub-request (palette)");
+ if (sscanf(data, "%s %d %s", color_name, &i, name) != 3) {
+ error(key, data,
+ "illegal complementary sub-request (palette)");
}
- if (i < 1 || !scan_color(color_name, &color))
- {
- error(key, data, "illegal complementary sub-request (palette)");
+ if (i < 1 || !scan_color(color_name, &color)) {
+ error(key, data,
+ "illegal complementary sub-request (palette)");
}
complementary(name, &color, i, 90.);
continue;
}
- if (KEY("analogous", 3))
- {
- char color_name[50];
+ if (KEY("analogous", 3)) {
+ char color_name[50];
- if (sscanf(data, "%s %d %s", color_name, &i, name) != 3)
- {
- error(key, data, "illegal analogous sub-request (palette)");
- }
- if (i < 1 || !scan_color(color_name, &color))
- {
- error(key, data, "illegal analogous sub-request (palette)");
- }
- analogous(name, &color, i, 90.);
- continue;
- }
- if (KEY("pure_gradient", 4))
- {
- char A_name[50], B_name[50];
+ if (sscanf(data, "%s %d %s", color_name, &i, name) != 3) {
+ error(key, data, "illegal analogous sub-request (palette)");
+ }
+ if (i < 1 || !scan_color(color_name, &color)) {
+ error(key, data, "illegal analogous sub-request (palette)");
+ }
+ analogous(name, &color, i, 90.);
+ continue;
+ }
+ if (KEY("pure_gradient", 4)) {
+ char A_name[50], B_name[50];
- if (sscanf(data, "%s %s %d %s", A_name, B_name, &i, name) != 4)
- {
- error(key, data, "illegal pure_gradient sub-request (palette)");
- }
- if (i < 3 || !scan_color(A_name, &color) || !scan_color(B_name, &colorb))
- {
- error(key, data, "illegal pure_gradient sub-request (palette)");
- }
- gradient(name, &color, &colorb, i, 1);
- continue;
- }
- if (KEY("gradient", 4))
- {
+ if (sscanf(data, "%s %s %d %s", A_name, B_name, &i, name) != 4) {
+ error(key, data,
+ "illegal pure_gradient sub-request (palette)");
+ }
+ if (i < 3 || !scan_color(A_name, &color) ||
+ !scan_color(B_name, &colorb)) {
+ error(key, data,
+ "illegal pure_gradient sub-request (palette)");
+ }
+ gradient(name, &color, &colorb, i, 1);
+ continue;
+ }
+ if (KEY("gradient", 4)) {
char A_name[50], B_name[50];
- if (sscanf(data, "%s %s %d %s", A_name, B_name, &i, name) != 4)
- {
- error(key, data, "illegal gradient sub-request (palette)");
+ if (sscanf(data, "%s %s %d %s", A_name, B_name, &i, name) != 4) {
+ error(key, data, "illegal gradient sub-request (palette)");
}
- if (i < 3 || !scan_color(A_name, &color) || !scan_color(B_name, &colorb))
- {
- error(key, data, "illegal gradient sub-request (palette)");
+ if (i < 3 || !scan_color(A_name, &color) ||
+ !scan_color(B_name, &colorb)) {
+ error(key, data, "illegal gradient sub-request (palette)");
}
gradient(name, &color, &colorb, i, 0);
continue;
}
- if (KEY("diverging", 4))
- {
- char A_name[50], B_name[50];
+ if (KEY("diverging", 4)) {
+ char A_name[50], B_name[50];
- if (sscanf(data, "%s %s %d %s", A_name, B_name, &i, name) != 4)
- {
- error(key, data, "illegal xxx diverging sub-request (palette)");
- }
- if (i < 3 || !scan_color(A_name, &color) || !scan_color(B_name, &colorb))
- {
- error(key, data, "illegal yyy diverging sub-request (palette)");
- }
- diverging(name, &color, &colorb, i);
- continue;
- }
+ if (sscanf(data, "%s %s %d %s", A_name, B_name, &i, name) != 4) {
+ error(key, data,
+ "illegal xxx diverging sub-request (palette)");
+ }
+ if (i < 3 || !scan_color(A_name, &color) ||
+ !scan_color(B_name, &colorb)) {
+ error(key, data,
+ "illegal yyy diverging sub-request (palette)");
+ }
+ diverging(name, &color, &colorb, i);
+ continue;
+ }
error(key, data, "illegal zzz palette sub-request");
}
Modified: grass-addons/postscript/ps.output/r_paper.c
===================================================================
--- grass-addons/postscript/ps.output/r_paper.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/r_paper.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -18,15 +18,17 @@
int read_paper(char *arg)
{
char buf[1024];
+
char *key, *data;
+
int do_landscape;
+
double point;
G_debug(1, "Reading paper settings ..");
/* default values */
- if (arg[0] != 0)
- {
+ if (arg[0] != 0) {
set_paper(arg);
}
do_landscape = 0;
@@ -34,94 +36,74 @@
/* init values */
unset_color(&(PS.page.fcolor)); /* no paper color */
- while (input(2, buf))
- {
- if (!key_data(buf, &key, &data))
- {
+ while (input(2, buf)) {
+ if (!key_data(buf, &key, &data)) {
continue;
}
- if (KEY("color"))
- {
- if (!scan_color(data, &(PS.page.fcolor)))
- {
+ if (KEY("color")) {
+ if (!scan_color(data, &(PS.page.fcolor))) {
error(key, data, "illegal line color request");
}
continue;
}
- if (KEY("width"))
- {
- if (scan_dimen(data, &(point)) != 1)
- {
+ if (KEY("width")) {
+ if (scan_dimen(data, &(point)) != 1) {
error(key, data, "illegal paper width request");
}
PS.page.width = (int)(point);
continue;
}
- if (KEY("height"))
- {
- if (scan_dimen(data, &(point)) != 1)
- {
+ if (KEY("height")) {
+ if (scan_dimen(data, &(point)) != 1) {
error(key, data, "illegal paper width request");
}
PS.page.height = (int)(point);
continue;
}
- if (KEY("left"))
- {
- if (scan_dimen(data, &(point)) != 1)
- {
+ if (KEY("left")) {
+ if (scan_dimen(data, &(point)) != 1) {
error(key, data, "illegal paper width request");
}
PS.page.left = point;
continue;
}
- if (KEY("right"))
- {
- if (scan_dimen(data, &(point)) != 1)
- {
+ if (KEY("right")) {
+ if (scan_dimen(data, &(point)) != 1) {
error(key, data, "illegal paper width request");
}
PS.page.right = point;
continue;
}
- if (KEY("top"))
- {
- if (scan_dimen(data, &(point)) != 1)
- {
+ if (KEY("top")) {
+ if (scan_dimen(data, &(point)) != 1) {
error(key, data, "illegal paper width request");
}
PS.page.top = point;
continue;
}
- if (KEY("bottom"))
- {
- if (scan_dimen(data, &(point)) != 1)
- {
+ if (KEY("bottom")) {
+ if (scan_dimen(data, &(point)) != 1) {
error(key, data, "illegal paper width request");
}
PS.page.bot = point;
continue;
}
- if (KEY("landscape"))
- {
+ if (KEY("landscape")) {
do_landscape = scan_yesno(key, data);
continue;
}
- if (KEY("font"))
- {
+ if (KEY("font")) {
read_font(data, &(PS.font));
continue;
}
- if (KEY("draw"))
- {
+ if (KEY("draw")) {
read_draw("paper");
continue;
}
error(key, data, "illegal paper sub-request");
}
- if (do_landscape != 0)
- {
+ if (do_landscape != 0) {
int tmp;
tmp = PS.page.width;
@@ -129,7 +111,8 @@
PS.page.height = tmp;
}
- G_debug(1, "Setting paper: %.1f %.1f : %d %d\n", PS.page.left, PS.page.top, PS.page.width, PS.page.height);
+ G_debug(1, "Setting paper: %.1f %.1f : %d %d\n", PS.page.left,
+ PS.page.top, PS.page.width, PS.page.height);
return 0;
}
Modified: grass-addons/postscript/ps.output/r_raster.c
===================================================================
--- grass-addons/postscript/ps.output/r_raster.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/r_raster.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -20,8 +20,11 @@
int read_raster(char *arg)
{
char buf[1024];
+
char *key, *data;
+
char name[3][100];
+
int ret;
G_debug(1, "Reading raster settings ..");
@@ -36,24 +39,19 @@
/* inline argument */
ret = sscanf(arg, "%s %s %s", name[0], name[1], name[2]);
- if (ret != 1 && ret != 3)
- {
+ if (ret != 1 && ret != 3) {
error(key, data, "illegal raster request");
}
- if (ret == 3)
- {
+ if (ret == 3) {
PS.rst.files = load_rgb(name[0], name[1], name[2]);
PS.rst.do_rgb = 1;
}
- else
- {
- if (name[0][0] == ':')
- {
+ else {
+ if (name[0][0] == ':') {
PS.rst.files = load_group(name[0] + 1);
PS.rst.do_rgb = 1;
}
- else
- {
+ else {
PS.rst.files = load_cell(0, name[0]);
PS.rst.fd[1] = PS.rst.fd[2] = -1;
PS.rst.do_rgb = 0;
@@ -61,34 +59,26 @@
}
/* process options */
- while (input(2, buf))
- {
- if (!key_data(buf, &key, &data))
- {
+ while (input(2, buf)) {
+ if (!key_data(buf, &key, &data)) {
continue;
}
- if (KEY("grey") || KEY("gray"))
- {
+ if (KEY("grey") || KEY("gray")) {
PS.rst.do_grey = scan_yesno(key, data);
continue;
}
- if (KEY("maskcolor"))
- {
- if (!scan_color(data, &(PS.rst.mask_color)))
- {
+ if (KEY("maskcolor")) {
+ if (!scan_color(data, &(PS.rst.mask_color))) {
error(key, data, "illegal raster mask color request");
}
continue;
}
- if (KEY("maskcell"))
- {
- if (PS.rst.do_rgb)
- {
+ if (KEY("maskcell")) {
+ if (PS.rst.do_rgb) {
error(key, data, "illegal maskcell with rgb/group raster");
}
ret = sscanf(data, "%s %s", name[1], name[2]);
- if (ret != 1 && ret != 2)
- {
+ if (ret != 1 && ret != 2) {
error(key, data, "illegal maskcell raster request");
}
PS.rst.do_mask = 1;
@@ -97,58 +87,52 @@
load_cell(2, name[2]); /* slot 2: background */
continue;
}
- if (KEY("outline"))
- {
- if (PS.rst.do_rgb)
- {
+ if (KEY("outline")) {
+ if (PS.rst.do_rgb) {
error(key, data, "illegal outline with rgb raster");
}
read_psline(data, &(PS.rst.outline));
continue;
}
- if (KEY("setcolor"))
- {
+ if (KEY("setcolor")) {
int i, count, R, G, B;
+
PSCOLOR color;
+
DCELL *val_list, dmin, dmax;
+
char colorbuf[100], catsbuf[100];
/* set color inline */
- if (PS.rst.fd[0] < 0 || PS.rst.do_rgb)
- {
+ if (PS.rst.fd[0] < 0 || PS.rst.do_rgb) {
error(key, data, "setcolor is not for RGB raster");
}
- if (sscanf(data, "%s %[^\n]", catsbuf, colorbuf) == 2)
- {
- if (!scan_color(colorbuf, &color))
- {
+ if (sscanf(data, "%s %[^\n]", catsbuf, colorbuf) == 2) {
+ if (!scan_color(colorbuf, &color)) {
error(key, data, "illegal setcolor request");
continue;
}
R = (int)(255. * color.r);
G = (int)(255. * color.g);
B = (int)(255. * color.b);
- if (strncmp(catsbuf, "null", 4) == 0)
- {
+ if (strncmp(catsbuf, "null", 4) == 0) {
G_set_null_value_color(R, G, B, &(PS.rst.colors[0]));
continue;
}
- if (strncmp(catsbuf, "default", 7) == 0)
- {
+ if (strncmp(catsbuf, "default", 7) == 0) {
G_set_default_color(R, G, B, &(PS.rst.colors[0]));
continue;
}
- if ((count = parse_val_list(catsbuf, &val_list)) < 0)
- {
+ if ((count = parse_val_list(catsbuf, &val_list)) < 0) {
/* G_free(val_list); */
error(key, data, "illegal value list");
continue;
}
- for (i = 0; i < count; i += 2)
- {
+ for (i = 0; i < count; i += 2) {
dmin = val_list[i];
dmax = val_list[i + 1];
- G_add_d_raster_color_rule(&dmin, R, G, B, &dmax, R, G, B, &(PS.rst.colors[0]));
+ G_add_d_raster_color_rule(&dmin, R, G, B, &dmax, R, G, B,
+ &(PS.rst.colors[0]));
}
G_free(val_list);
}
Modified: grass-addons/postscript/ps.output/r_rlegend.c
===================================================================
--- grass-addons/postscript/ps.output/r_rlegend.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/r_rlegend.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -20,7 +20,9 @@
int read_rlegend(char *arg)
{
char buf[1024];
+
char *key, *data, *mapset;
+
double dimen;
G_debug(1, "Reading rlegend settings ..");
@@ -45,45 +47,37 @@
strncpy(PS.rl.legend.title, arg, TITLE_LEN);
/* process options */
- while (input(2, buf))
- {
- if (!key_data(buf, &key, &data))
- {
+ while (input(2, buf)) {
+ if (!key_data(buf, &key, &data)) {
continue;
}
- if (KEY("title"))
- {
+ if (KEY("title")) {
G_strip(data);
read_font(data, &(PS.rl.legend.title_font));
continue;
}
- if (KEY("font"))
- {
+ if (KEY("font")) {
G_strip(data);
read_font(data, &(PS.rl.legend.font));
continue;
}
- if (KEY("frame"))
- {
+ if (KEY("frame")) {
read_frame(&(PS.rl.legend.box));
continue;
}
- if (KEY("swidth"))
- {
- if (scan_dimen(data, &(PS.rl.legend.width)) != 1)
- {
+ if (KEY("swidth")) {
+ if (scan_dimen(data, &(PS.rl.legend.width)) != 1) {
PS.rl.legend.width = -1.;
error(key, data, "illegal width request (rlegend)");
}
continue;
}
- if (KEY("cols"))
- {
+ if (KEY("cols")) {
int n;
- n = sscanf(data, "%d %lf", &(PS.rl.legend.cols), &(PS.rl.legend.xspan));
- if (n == 1 || n == 2)
- {
+ n = sscanf(data, "%d %lf", &(PS.rl.legend.cols),
+ &(PS.rl.legend.xspan));
+ if (n == 1 || n == 2) {
if (PS.rl.legend.cols < 0)
PS.rl.legend.cols = 1;
if (n == 1)
@@ -93,20 +87,16 @@
error(key, data, "illegal cols/span request (rlegend)");
continue;
}
- if (KEY("height"))
- {
- if (scan_dimen(data, &(PS.rl.height)) != 1)
- {
+ if (KEY("height")) {
+ if (scan_dimen(data, &(PS.rl.height)) != 1) {
error(key, data, "illegal height request (rlegend)");
}
continue;
}
- if (KEY("raster"))
- {
+ if (KEY("raster")) {
G_strip(data);
mapset = G_find_file("cell", data, "");
- if (PS.rl.mapset == NULL)
- {
+ if (PS.rl.mapset == NULL) {
PS.rl.name[0] = 0;
error(key, data, "illegal raster request (rlegend)");
}
@@ -114,20 +104,16 @@
strcpy(PS.rl.mapset, mapset);
continue;
}
- if (KEY("range"))
- {
- if (sscanf(data, "%lf %lf", &(PS.rl.min), &(PS.rl.max)) != 2)
- {
+ if (KEY("range")) {
+ if (sscanf(data, "%lf %lf", &(PS.rl.min), &(PS.rl.max)) != 2) {
PS.rl.custom_range = FALSE;
error(key, data, "illegal range request (rlegend)");
}
- else
- {
+ else {
double tmpD;
PS.rl.custom_range = TRUE;
- if (PS.rl.min > PS.rl.max)
- {
+ if (PS.rl.min > PS.rl.max) {
tmpD = PS.rl.min;
PS.rl.min = PS.rl.max;
PS.rl.max = tmpD;
@@ -135,36 +121,29 @@
continue;
}
}
- if (KEY("nodata"))
- {
+ if (KEY("nodata")) {
PS.rl.do_nodata = scan_yesno(key, data);
continue;
}
- if (KEY("gradient"))
- {
+ if (KEY("gradient")) {
PS.rl.do_gradient = scan_yesno(key, data);
continue;
}
- if (KEY("tick"))
- {
- if (scan_dimen(data, &dimen) != 1)
- {
+ if (KEY("tick")) {
+ if (scan_dimen(data, &dimen) != 1) {
error(key, data, "illegal tickbar request (rlegend)");
}
PS.rl.tickbar = (int)(dimen);
continue;
}
- if (KEY("whiteframe"))
- {
- if (scan_dimen(data, &dimen) != 1)
- {
+ if (KEY("whiteframe")) {
+ if (scan_dimen(data, &dimen) != 1) {
error(key, data, "illegal whiteframe request (rlegend)");
}
PS.rl.whiteframe = (int)(dimen);
continue;
}
- if (KEY("order"))
- {
+ if (KEY("order")) {
G_strip(data);
strncpy(PS.rl.cat_order, data, MAX_CATS);
// PS.rl.cat_order[510] = 0;
@@ -174,8 +153,7 @@
}
/* end check */
- if (!PS.rl.name)
- {
+ if (!PS.rl.name) {
PS.do_rlegend = 0;
error(key, data, "rlegend need 'raster' option sub-request");
}
Modified: grass-addons/postscript/ps.output/r_scalebar.c
===================================================================
--- grass-addons/postscript/ps.output/r_scalebar.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/r_scalebar.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -23,6 +23,7 @@
int read_scalebar(void)
{
char buf[1024];
+
char *key, *data;
G_debug(1, "Reading scalebar settings ..");
@@ -41,52 +42,40 @@
set_color_rgb(&(PS.sbar.fcolor), 255, 255, 255);
/* process options */
- while (input(2, buf))
- {
- if (!key_data(buf, &key, &data))
- {
+ while (input(2, buf)) {
+ if (!key_data(buf, &key, &data)) {
continue;
}
- if (KEY("frame"))
- {
+ if (KEY("frame")) {
read_frame(&(PS.sbar.box));
continue;
}
- if (KEY("font"))
- {
+ if (KEY("font")) {
read_font(data, &(PS.sbar.font));
continue;
}
- if (KEY("fcolor"))
- {
- if (!scan_color(data, &(PS.sbar.fcolor)))
- {
+ if (KEY("fcolor")) {
+ if (!scan_color(data, &(PS.sbar.fcolor))) {
error(key, data, "illegal fcolor request (scalebar)");
}
continue;
}
- if (KEY("height"))
- {
- if (scan_dimen(data, &(PS.sbar.height)) != 1)
- {
+ if (KEY("height")) {
+ if (scan_dimen(data, &(PS.sbar.height)) != 1) {
error(key, data, "illegal height request (scalebar)");
}
continue;
}
- if (KEY("length"))
- {
- if (scan_dimen(data, &(PS.sbar.length)) != 1)
- {
+ if (KEY("length")) {
+ if (scan_dimen(data, &(PS.sbar.length)) != 1) {
error(key, data, "illegal length request (scalebar)");
}
continue;
}
- if (KEY("major") || KEY("segments"))
- {
+ if (KEY("major") || KEY("segments")) {
int i, j;
- switch (sscanf(data, "%d %d", &i, &j))
- {
+ switch (sscanf(data, "%d %d", &i, &j)) {
case 1:
PS.sbar.segments = ABS(i);
PS.sbar.labels = 1;
@@ -101,12 +90,10 @@
}
continue;
}
- if (KEY("minor"))
- {
+ if (KEY("minor")) {
int i, j;
- switch (sscanf(data, "%d %d", &i, &j))
- {
+ switch (sscanf(data, "%d %d", &i, &j)) {
case 1:
PS.sbar.subsegs = ABS(i);
PS.sbar.sublabs = 1;
@@ -121,54 +108,48 @@
}
continue;
}
- if (KEY("units"))
- {
+ if (KEY("units")) {
int ret;
+
char stra[50], strb[50];
G_strip(data);
ret = sscanf(data, "%s %s", stra, strb);
- if (ret != 1 && ret != 2)
- {
+ if (ret != 1 && ret != 2) {
error(key, data, "illegal units request (scalebar)");
}
- if (strcmp(stra, "auto") == 0)
- {
+ if (strcmp(stra, "auto") == 0) {
PS.sbar.units[0] = 0;
PS.sbar.ucode = SB_UNITS_AUTO;
continue;
}
- else if (G_projection() == PROJECTION_XY)
- {
- error(key, data, "Earth units not available in simple XY location");
+ else if (G_projection() == PROJECTION_XY) {
+ error(key, data,
+ "Earth units not available in simple XY location");
}
- else if (strcmp(stra, "meters") == 0 || strcmp(stra, "m") == 0)
- {
+ else if (strcmp(stra, "meters") == 0 || strcmp(stra, "m") == 0) {
strcpy(PS.sbar.units, "meters");
PS.sbar.ucode = SB_UNITS_METERS;
}
- else if (strcmp(stra, "kilometers") == 0 || strcmp(stra, "km") == 0)
- {
+ else if (strcmp(stra, "kilometers") == 0 ||
+ strcmp(stra, "km") == 0) {
strcpy(PS.sbar.units, "kilometers");
PS.sbar.ucode = SB_UNITS_KM;
}
- else if (strcmp(stra, "feet") == 0 || strcmp(stra, "ft") == 0)
- {
+ else if (strcmp(stra, "feet") == 0 || strcmp(stra, "ft") == 0) {
strcpy(PS.sbar.units, "feet");
PS.sbar.ucode = SB_UNITS_FEET;
}
- else if (strcmp(stra, "miles") == 0 || strcmp(stra, "mil") == 0)
- {
+ else if (strcmp(stra, "miles") == 0 || strcmp(stra, "mil") == 0) {
strcpy(PS.sbar.units, "miles");
PS.sbar.ucode = SB_UNITS_MILES;
}
- else if (strcmp(stra, "nautmiles") == 0 || strcmp(stra, "nm") == 0)
- {
+ else if (strcmp(stra, "nautmiles") == 0 ||
+ strcmp(stra, "nm") == 0) {
strcpy(PS.sbar.units, "nautical miles");
PS.sbar.ucode = SB_UNITS_NMILES;
}
- else
- {
+ else {
error(key, data, "illegal units request (scalebar)");
}
if (ret == 2)
Modified: grass-addons/postscript/ps.output/r_vareas.c
===================================================================
--- grass-addons/postscript/ps.output/r_vareas.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/r_vareas.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -21,32 +21,32 @@
int read_vareas(char *name)
{
int i;
+
char buf[1024];
+
char *key, *data, *mapset;
- VAREAS * vector = NULL;
+ VAREAS *vector = NULL;
+
G_debug(1, "Reading vareas settings ..");
i = vector_new(); /* G_realloc */
default_vector(i);
/* inline argument */
- if (strcmp(name, "(none)") != 0)
- {
- mapset = G_find_vector(name, "");
- if (mapset == NULL)
- {
+ if (strcmp(name, "(none)") != 0) {
+ mapset = G_find_vector(name, "");
+ if (mapset == NULL) {
error("ERROR:", name, "Can't find vector map");
}
PS.vct[i].name = G_store(name);
PS.vct[i].mapset = G_store(mapset);
PS.vct[i].data = G_malloc(sizeof(VAREAS));
- Vect_set_open_level(2); /* level 2: topology */
+ Vect_set_open_level(2); /* level 2: topology */
Vect_set_fatal_error(GV_FATAL_PRINT);
- if (2 > Vect_open_old(&(PS.vct[i].Map), name, mapset))
- {
+ if (2 > Vect_open_old(&(PS.vct[i].Map), name, mapset)) {
sprintf(buf, "%s in %s", name, mapset);
error("ERROR:", buf, "can't open vector map");
return 0;
@@ -64,112 +64,97 @@
vector->sc_pat = 1.;
vector->island = 1;
vector->rgbcol = NULL;
- vector->idcol = NULL;
+ vector->idcol = NULL;
/* process options */
- while (input(2, buf))
- {
- if (!key_data(buf, &key, &data))
- {
+ while (input(2, buf)) {
+ if (!key_data(buf, &key, &data)) {
continue;
}
- if (KEY("lwidth"))
- {
+ if (KEY("lwidth")) {
G_strip(data);
- if (scan_dimen(data, &(vector->width)) != 1)
- error(key, data, "illegal 'lwidth' width (vareas)");
+ if (scan_dimen(data, &(vector->width)) != 1)
+ error(key, data, "illegal 'lwidth' width (vareas)");
continue;
}
- if (KEY("line"))
- {
+ if (KEY("line")) {
read_psline(data, &(vector->line));
continue;
}
- if (KEY("fcolor"))
- {
+ if (KEY("fcolor")) {
char stra[50], strb[50];
+
int ret = sscanf(data, "%s %[^\n]", stra, strb);
- if (ret == 1 || ret == 2)
- {
- if (!scan_color(stra, &(vector->fcolor)))
- {
- double alpha;
- if (ret == 2)
- vector->idcol = G_store(strb);
+ if (ret == 1 || ret == 2) {
+ if (!scan_color(stra, &(vector->fcolor))) {
+ double alpha;
- ret = sscanf(stra, "%[^$]$%lf", strb, &alpha);
- vector->rgbcol = G_store(strb);
- vector->fcolor.a = (ret == 2) ? alpha : 1.;
- G_message(" >>> Request fcolor from column '%s' (vareas)", vector->rgbcol);
- vector->type_pat = 2; /* uncolored pattern */
- }
- }
- else
- {
- error(key, data, "illegal data in 'fcolor' (vareas)");
- }
+ if (ret == 2)
+ vector->idcol = G_store(strb);
+
+ ret = sscanf(stra, "%[^$]$%lf", strb, &alpha);
+ vector->rgbcol = G_store(strb);
+ vector->fcolor.a = (ret == 2) ? alpha : 1.;
+ G_message(" >>> Request fcolor from column '%s' (vareas)",
+ vector->rgbcol);
+ vector->type_pat = 2; /* uncolored pattern */
+ }
+ }
+ else {
+ error(key, data, "illegal data in 'fcolor' (vareas)");
+ }
continue;
}
- if (KEY("pat"))
- {
+ if (KEY("pat")) {
G_chop(data);
vector->name_pat = G_store(data);
continue;
}
- if (KEY("pscale"))
- {
+ if (KEY("pscale")) {
G_chop(data);
vector->sc_pat = atof(data);
continue;
}
- if (KEY("pwidth"))
- {
+ if (KEY("pwidth")) {
if (scan_dimen(data, &(vector->lw_pat)) != 1)
error(key, data, "illegal pattern width (vareas)");
continue;
}
- if (KEY("island"))
- {
+ if (KEY("island")) {
vector->island = scan_yesno(key, data);
continue;
}
/* common options of all vectors */
- if (KEY("layer"))
- {
+ if (KEY("layer")) {
G_strip(data);
PS.vct[i].layer = atoi(data);
if (PS.vct[i].layer < 1)
PS.vct[i].layer = 1;
continue;
}
- if (KEY("cats") || KEY("cat"))
- {
+ if (KEY("cats") || KEY("cat")) {
G_strip(data);
PS.vct[i].cats = G_store(data);
continue;
}
- if (KEY("where"))
- {
+ if (KEY("where")) {
G_strip(data);
PS.vct[i].where = G_store(data);
continue;
}
- if (KEY("masked"))
- {
+ if (KEY("masked")) {
PS.vct[i].masked = scan_yesno(key, data);
if (PS.vct[i].masked)
PS.need_mask = 1;
continue;
}
- if (KEY("label"))
- {
+ if (KEY("label")) {
G_strip(data);
PS.vct[i].label = G_store(data);
continue;
}
- if (KEY("legend") || KEY("lpos"))
- {
+ if (KEY("legend") || KEY("lpos")) {
int k;
if (sscanf(data, "%d", &k) == 1)
@@ -178,37 +163,34 @@
read_block(i);
continue;
}
- if (KEY("setrule"))
- {
- double val;
- char str[128], catsbuf[128], labelbuf[128];
+ if (KEY("setrule")) {
+ double val;
- if (sscanf(data, "%s %[^\n]", str, labelbuf) > 0)
- {
- if (sscanf(str, "%[^:]:%lf", catsbuf, &val) == 1)
- val = 0.;
- vector_rule_new(&(PS.vct[i]), catsbuf, labelbuf, val);
- }
- else
- error(key, data, "illegal 'setrule' request (vareas)");
- continue;
+ char str[128], catsbuf[128], labelbuf[128];
+
+ if (sscanf(data, "%s %[^\n]", str, labelbuf) > 0) {
+ if (sscanf(str, "%[^:]:%lf", catsbuf, &val) == 1)
+ val = 0.;
+ vector_rule_new(&(PS.vct[i]), catsbuf, labelbuf, val);
+ }
+ else
+ error(key, data, "illegal 'setrule' request (vareas)");
+ continue;
}
error(key, "", "illegal request (vareas)");
}
/* default label */
- if (PS.vct[i].label == NULL)
- {
+ if (PS.vct[i].label == NULL) {
sprintf(buf, "%s (%s)", PS.vct[i].name, PS.vct[i].mapset);
PS.vct[i].label = G_store(buf);
}
- if (vector->rgbcol == NULL)
- {
- vector_item_new(&(PS.vct[i]), 0, color_to_long(&(vector->fcolor)));
+ if (vector->rgbcol == NULL) {
+ vector_item_new(&(PS.vct[i]), 0, color_to_long(&(vector->fcolor)));
}
-/*
+ /*
int x, y;
for (x = 0; x < PS.vct[i].n_rule; x++)
{
@@ -220,7 +202,7 @@
PS.vct[i].rule[x].value, PS.vct[i].rule[x].label);
}
}
-*/
+ */
return 1;
}
Modified: grass-addons/postscript/ps.output/r_vlabels.c
===================================================================
--- grass-addons/postscript/ps.output/r_vlabels.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/r_vlabels.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -21,8 +21,11 @@
int read_vlabels(char *name)
{
int i;
+
char buf[1024];
+
char *key, *data, *mapset;
+
VLABELS *vector;
@@ -31,11 +34,9 @@
i = vector_new(); /* G_realloc */
/* inline argument */
- if (strcmp(name, "(none)") != 0)
- {
- mapset = G_find_vector(name, "");
- if (mapset == NULL)
- {
+ if (strcmp(name, "(none)") != 0) {
+ mapset = G_find_vector(name, "");
+ if (mapset == NULL) {
error("ERROR:", name, "Can't find vector map");
}
PS.vct[i].name = G_store(name);
@@ -45,8 +46,7 @@
Vect_set_open_level(2); /* level 2: topology */
Vect_set_fatal_error(GV_FATAL_PRINT);
- if (2 > Vect_open_old(&(PS.vct[i].Map), name, mapset))
- {
+ if (2 > Vect_open_old(&(PS.vct[i].Map), name, mapset)) {
sprintf(buf, "%s in %s", name, mapset);
error("ERROR:", buf, "can't open vector map");
return 0;
@@ -66,84 +66,70 @@
vector->style = 0;
/* process options */
- while (input(2, buf))
- {
- if (!key_data(buf, &key, &data))
- {
+ while (input(2, buf)) {
+ if (!key_data(buf, &key, &data)) {
continue;
}
- if (KEY("font"))
- {
+ if (KEY("font")) {
read_font(data, &(vector->font));
continue;
}
- if (KEY("labelcol"))
- {
+ if (KEY("labelcol")) {
G_strip(data);
vector->labelcol = G_store(data);
- G_warning("Request label column from database '%s' (vlabel)", vector->labelcol);
+ G_warning("Request label column from database '%s' (vlabel)",
+ vector->labelcol);
continue;
}
- if (KEY("decimals"))
- {
+ if (KEY("decimals")) {
vector->decimals = atoi(data);
continue;
}
- if (KEY("circled"))
- {
- scan_dimen(data, &(vector->style));
+ if (KEY("circled")) {
+ scan_dimen(data, &(vector->style));
continue;
}
/* common options of all vectors */
- if (KEY("layer"))
- {
+ if (KEY("layer")) {
G_strip(data);
PS.vct[i].layer = atoi(data);
if (PS.vct[i].layer < 1)
PS.vct[i].layer = 1;
continue;
}
- if (KEY("cats") || KEY("cat"))
- {
+ if (KEY("cats") || KEY("cat")) {
G_strip(data);
PS.vct[i].cats = G_store(data);
continue;
}
- if (KEY("where"))
- {
+ if (KEY("where")) {
G_strip(data);
PS.vct[i].where = G_store(data);
continue;
}
- if (KEY("masked"))
- {
+ if (KEY("masked")) {
PS.vct[i].masked = scan_yesno(key, data);
if (PS.vct[i].masked)
PS.need_mask = 1;
continue;
}
- if (KEY("label"))
- {
+ if (KEY("label")) {
G_strip(data);
PS.vct[i].label = G_store(data);
continue;
}
- if (KEY("legend") || KEY("lpos"))
- {
+ if (KEY("legend") || KEY("lpos")) {
int k;
- if (sscanf(data, "%d", &k) == 1)
- {
+ if (sscanf(data, "%d", &k) == 1) {
PS.vct[i].lpos = k;
}
- else
- {
+ else {
read_block(i);
}
continue;
}
- if (KEY("setrule"))
- {
+ if (KEY("setrule")) {
char catsbuf[128], labelbuf[128];
sscanf(data, "%s %[^\n]", catsbuf, labelbuf);
@@ -154,13 +140,12 @@
}
/* default label */
- if (PS.vct[i].label == NULL)
- {
+ if (PS.vct[i].label == NULL) {
sprintf(buf, "%s (%s)", PS.vct[i].name, PS.vct[i].mapset);
PS.vct[i].label = G_store(buf);
}
- PS.vct[i].lpos = -1; /* Not in legends */
+ PS.vct[i].lpos = -1; /* Not in legends */
return 1;
}
Modified: grass-addons/postscript/ps.output/r_vlegend.c
===================================================================
--- grass-addons/postscript/ps.output/r_vlegend.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/r_vlegend.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -19,6 +19,7 @@
int read_vlegend(char *arg)
{
char buf[1024];
+
char *key, *data;
@@ -36,61 +37,50 @@
PS.vl.legend.yspan = -1;
/* process options */
- while (input(2, buf))
- {
- if (!key_data(buf, &key, &data))
- {
+ while (input(2, buf)) {
+ if (!key_data(buf, &key, &data)) {
continue;
}
- if (KEY("title") || KEY("title_font"))
- {
+ if (KEY("title") || KEY("title_font")) {
G_strip(data);
read_font(data, &(PS.vl.legend.title_font));
continue;
}
- if (KEY("font"))
- {
+ if (KEY("font")) {
read_font(data, &(PS.vl.legend.font));
continue;
}
- if (KEY("frame"))
- {
+ if (KEY("frame")) {
read_frame(&(PS.vl.legend.box));
continue;
}
- if (KEY("cols"))
- {
- int n = sscanf(data, "%d %lf",
- &(PS.vl.legend.cols), &(PS.vl.legend.xspan));
+ if (KEY("cols")) {
+ int n = sscanf(data, "%d %lf",
+ &(PS.vl.legend.cols), &(PS.vl.legend.xspan));
- if (n == 1 || n == 2)
- {
- if (PS.vl.legend.cols <= 0)
- PS.vl.legend.cols = 1;
- if (n == 1)
- PS.vl.legend.xspan = -1.;
- }
- else
- error(key, data, "illegal cols/xspan request (vlegend)");
- continue;
- }
- if (KEY("swidth"))
- {
- if (scan_dimen(data, &(PS.vl.legend.width)) != 1)
- {
- PS.vl.legend.width = -1.;
- error(key, data, "illegal swidth request (vlegend)");
- }
- continue;
- }
- if (KEY("interline") || KEY("dy"))
- {
- if (scan_dimen(data, &(PS.vl.legend.yspan)) != 1)
- {
- error(key, data, "illegal interline request (vlegend)");
- }
- continue;
- }
+ if (n == 1 || n == 2) {
+ if (PS.vl.legend.cols <= 0)
+ PS.vl.legend.cols = 1;
+ if (n == 1)
+ PS.vl.legend.xspan = -1.;
+ }
+ else
+ error(key, data, "illegal cols/xspan request (vlegend)");
+ continue;
+ }
+ if (KEY("swidth")) {
+ if (scan_dimen(data, &(PS.vl.legend.width)) != 1) {
+ PS.vl.legend.width = -1.;
+ error(key, data, "illegal swidth request (vlegend)");
+ }
+ continue;
+ }
+ if (KEY("interline") || KEY("dy")) {
+ if (scan_dimen(data, &(PS.vl.legend.yspan)) != 1) {
+ error(key, data, "illegal interline request (vlegend)");
+ }
+ continue;
+ }
error(key, data, "illegal vlegend sub-request");
}
Modified: grass-addons/postscript/ps.output/r_vlines.c
===================================================================
--- grass-addons/postscript/ps.output/r_vlines.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/r_vlines.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -21,8 +21,11 @@
int read_vlines(char *name)
{
int i;
+
char buf[1024];
+
char *key, *data, *mapset;
+
VLINES *vector;
@@ -31,11 +34,9 @@
i = vector_new(); /* G_realloc */
/* inline argument */
- if (strcmp(name, "(none)") != 0)
- {
- mapset = G_find_vector(name, "");
- if (mapset == NULL)
- {
+ if (strcmp(name, "(none)") != 0) {
+ mapset = G_find_vector(name, "");
+ if (mapset == NULL) {
error("ERROR:", name, "Can't find vector map");
}
PS.vct[i].name = G_store(name);
@@ -45,8 +46,7 @@
Vect_set_open_level(2); /* level 2: topology */
Vect_set_fatal_error(GV_FATAL_PRINT);
- if (2 > Vect_open_old(&(PS.vct[i].Map), name, mapset))
- {
+ if (2 > Vect_open_old(&(PS.vct[i].Map), name, mapset)) {
sprintf(buf, "%s in %s", name, mapset);
error("ERROR:", buf, "can't open vector map");
return 0;
@@ -68,14 +68,11 @@
/* process options */
- while (input(2, buf))
- {
- if (!key_data(buf, &key, &data))
- {
+ while (input(2, buf)) {
+ if (!key_data(buf, &key, &data)) {
continue;
}
- if (KEY("type"))
- {
+ if (KEY("type")) {
G_strip(data);
if (data[0] == 'b')
vector->type = GV_BOUNDARY;
@@ -83,120 +80,105 @@
vector->type = GV_LINE;
continue;
}
- if (KEY("line"))
- {
+ if (KEY("line")) {
read_psline(data, &(vector->line));
continue;
}
- if (KEY("rgbcol"))
- {
- double alpha;
+ if (KEY("rgbcol")) {
+ double alpha;
+
char stra[50], strb[50];
+
int ret = sscanf(data, "%s %[^\n]", stra, strb);
- if (ret != 1 && ret != 2)
- {
+ if (ret != 1 && ret != 2) {
error(key, data, "illegal fcolor (vlines)");
}
- if (ret == 2)
- {
+ if (ret == 2) {
vector->idcol = G_store(strb);
}
ret = sscanf(stra, "%[^$]$%lf", strb, &alpha);
vector->rgbcol = G_store(strb);
vector->line.color.a = (ret == 2) ? alpha : 1.;
- G_warning("Request rgbcol from '%s' database column (vlines)", vector->rgbcol);
+ G_warning("Request rgbcol from '%s' database column (vlines)",
+ vector->rgbcol);
continue;
}
- if (KEY("hline"))
- {
+ if (KEY("hline")) {
read_psline(data, &(vector->hline));
continue;
}
- if (KEY("offset"))
- {
- if (scan_dimen(data, &(vector->offset)) == 0)
- {
+ if (KEY("offset")) {
+ if (scan_dimen(data, &(vector->offset)) == 0) {
vector->offset = 0.;
}
continue;
}
/* common options of all vectors */
- if (KEY("layer"))
- {
+ if (KEY("layer")) {
G_strip(data);
PS.vct[i].layer = atoi(data);
if (PS.vct[i].layer < 1)
PS.vct[i].layer = 1;
continue;
}
- if (KEY("cats") || KEY("cat"))
- {
+ if (KEY("cats") || KEY("cat")) {
G_strip(data);
PS.vct[i].cats = G_store(data);
continue;
}
- if (KEY("where"))
- {
+ if (KEY("where")) {
G_strip(data);
PS.vct[i].where = G_store(data);
continue;
}
- if (KEY("masked"))
- {
+ if (KEY("masked")) {
PS.vct[i].masked = scan_yesno(key, data);
if (PS.vct[i].masked)
PS.need_mask = 1;
continue;
}
- if (KEY("label"))
- {
+ if (KEY("label")) {
G_strip(data);
PS.vct[i].label = G_store(data);
continue;
}
- if (KEY("legend") || KEY("lpos"))
- {
+ if (KEY("legend") || KEY("lpos")) {
int k;
- if (sscanf(data, "%d", &k) == 1)
- {
+ if (sscanf(data, "%d", &k) == 1) {
PS.vct[i].lpos = k;
}
- else
- {
+ else {
read_block(i);
}
continue;
}
- if (KEY("setrule"))
- {
+ if (KEY("setrule")) {
char catsbuf[128], labelbuf[128];
- if (sscanf(data, "%s %[^\n]", catsbuf, labelbuf) != 2)
- error(key, data, "illegal setrule request (vlines)");;
- vector_rule_new(&(PS.vct[i]), catsbuf, labelbuf, 0);
+ if (sscanf(data, "%s %[^\n]", catsbuf, labelbuf) != 2)
+ error(key, data, "illegal setrule request (vlines)");;
+ vector_rule_new(&(PS.vct[i]), catsbuf, labelbuf, 0);
continue;
}
error(key, "", "illegal request (vlines)");
}
/* final adjust of hline width */
- if (vector->hline.width > 0. && vector->offset == 0.)
- {
+ if (vector->hline.width > 0. && vector->offset == 0.) {
vector->hline.width = vector->line.width + 2. * vector->hline.width;
}
/* default label */
- if (PS.vct[i].label == NULL)
- {
+ if (PS.vct[i].label == NULL) {
sprintf(buf, "%s (%s)", PS.vct[i].name, PS.vct[i].mapset);
PS.vct[i].label = G_store(buf);
}
- if (vector->rgbcol == NULL)
- {
- vector_item_new(&(PS.vct[i]), 0, color_to_long(&(vector->line.color)));
+ if (vector->rgbcol == NULL) {
+ vector_item_new(&(PS.vct[i]), 0,
+ color_to_long(&(vector->line.color)));
}
return 1;
Modified: grass-addons/postscript/ps.output/r_vpoints.c
===================================================================
--- grass-addons/postscript/ps.output/r_vpoints.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/r_vpoints.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -21,8 +21,11 @@
int read_vpoints(char *name)
{
int i;
+
char buf[1024];
+
char *key, *data, *mapset;
+
VPOINTS *vector;
@@ -31,11 +34,9 @@
i = vector_new(); /* G_realloc */
/* inline argument */
- if (strcmp(name, "(none)") != 0)
- {
- mapset = G_find_vector(name, "");
- if (mapset == NULL)
- {
+ if (strcmp(name, "(none)") != 0) {
+ mapset = G_find_vector(name, "");
+ if (mapset == NULL) {
error("ERROR:", name, "Can't find vector map");
}
PS.vct[i].name = G_store(name);
@@ -45,8 +46,7 @@
Vect_set_open_level(2); /* level 2: topology */
Vect_set_fatal_error(GV_FATAL_PRINT);
- if (2 > Vect_open_old(&(PS.vct[i].Map), name, mapset))
- {
+ if (2 > Vect_open_old(&(PS.vct[i].Map), name, mapset)) {
sprintf(buf, "%s in %s", name, mapset);
error("ERROR:", buf, "can't open vector map");
return 0;
@@ -61,12 +61,12 @@
vector = (VPOINTS *) PS.vct[i].data;
vector->type = GV_POINT;
vector->symbol = G_store("basic/circle");
- vector->size = 1.0;
+ vector->size = 1.0;
vector->sizecol = NULL;
- vector->rotate = 0.0;
+ vector->rotate = 0.0;
vector->rotatecol = NULL;
vector->scale = 1.0;
- vector->bias = 0.0;
+ vector->bias = 0.0;
unset_color(&(vector->fcolor));
default_psline(&(vector->line));
vector->distance = 0.;
@@ -75,17 +75,13 @@
/* process options */
- while (input(2, buf))
- {
- if (!key_data(buf, &key, &data))
- {
+ while (input(2, buf)) {
+ if (!key_data(buf, &key, &data)) {
continue;
}
- if (KEY("type"))
- {
+ if (KEY("type")) {
G_strip(data);
- switch (data[0])
- {
+ switch (data[0]) {
case 'c':
vector->type = GV_CENTROID;
break;
@@ -101,177 +97,152 @@
}
continue;
}
- if (KEY("symbol"))
- {
+ if (KEY("symbol")) {
vector->symbol = G_store(data);
continue;
}
- if (KEY("line"))
- {
+ if (KEY("line")) {
read_psline(data, &(vector->line));
continue;
}
- if (KEY("fcolor"))
- {
- if (!scan_color(data, &(vector->fcolor)))
- {
+ if (KEY("fcolor")) {
+ if (!scan_color(data, &(vector->fcolor))) {
error(key, data, "illegal fcolor request (vpoints)");
}
continue;
}
- if (KEY("size"))
- {
+ if (KEY("size")) {
char stra[50], strb[50];
- switch (sscanf(data, "%s %s", stra, strb))
- {
+ switch (sscanf(data, "%s %s", stra, strb)) {
case 1:
- if (atof(stra) != 0.)
- vector->size = atof(stra);
- else
- vector->sizecol = G_store(stra);
- break;
+ if (atof(stra) != 0.)
+ vector->size = atof(stra);
+ else
+ vector->sizecol = G_store(stra);
+ break;
case 2:
- vector->sizecol = G_store(stra);
- vector->size = atof(strb);
- break;
+ vector->sizecol = G_store(stra);
+ vector->size = atof(strb);
+ break;
default:
- error(key, data, "illegal scale request (vpoints)");
+ error(key, data, "illegal scale request (vpoints)");
}
if (vector->sizecol != NULL)
- G_warning("Request size from '%s' column (vpoints)", vector->sizecol);
+ G_warning("Request size from '%s' column (vpoints)",
+ vector->sizecol);
continue;
}
- if (KEY("scale"))
- {
- char stra[50], strb[50];
+ if (KEY("scale")) {
+ char stra[50], strb[50];
- switch (sscanf(data, "%s %s", stra, strb))
- {
- case 1:
- scan_dimen(stra, &(vector->scale));
- vector->bias = 0.;
- break;
- case 2:
- scan_dimen(stra, &(vector->scale));
- scan_dimen(strb, &(vector->bias));
- break;
- default:
- error(key, data, "illegal scale [bias] request (vpoints)");
- break;
- }
+ switch (sscanf(data, "%s %s", stra, strb)) {
+ case 1:
+ scan_dimen(stra, &(vector->scale));
+ vector->bias = 0.;
+ break;
+ case 2:
+ scan_dimen(stra, &(vector->scale));
+ scan_dimen(strb, &(vector->bias));
+ break;
+ default:
+ error(key, data, "illegal scale [bias] request (vpoints)");
+ break;
+ }
continue;
}
- if (KEY("offset"))
- {
- if (scan_dimen(data, &(vector->voffset)) != 1)
- {
- error(key, data, "illegal voffset request (vpoints)");
- }
- continue;
- }
- if (KEY("rotate"))
- {
- if (atof(data) != 0.)
- {
+ if (KEY("offset")) {
+ if (scan_dimen(data, &(vector->voffset)) != 1) {
+ error(key, data, "illegal voffset request (vpoints)");
+ }
+ continue;
+ }
+ if (KEY("rotate")) {
+ if (atof(data) != 0.) {
vector->rotate = atof(data);
}
- else
- {
+ else {
vector->rotatecol = G_store(data);
- G_warning("Request rotate from '%s' column (vpoints)", vector->rotatecol);
+ G_warning("Request rotate from '%s' column (vpoints)",
+ vector->rotatecol);
}
continue;
}
- if (KEY("dist"))
- {
- if (scan_dimen(data, &(vector->distance)) != 1)
- {
+ if (KEY("dist")) {
+ if (scan_dimen(data, &(vector->distance)) != 1) {
error(key, data, "illegal dist request (vpoints)");
}
continue;
}
- if (KEY("cline"))
- {
+ if (KEY("cline")) {
read_psline(data, &(vector->cline));
continue;
}
/* common options of all vectors */
- if (KEY("layer"))
- {
+ if (KEY("layer")) {
G_strip(data);
PS.vct[i].layer = atoi(data);
if (PS.vct[i].layer < 1)
PS.vct[i].layer = 1;
continue;
}
- if (KEY("cats") || KEY("cat"))
- {
+ if (KEY("cats") || KEY("cat")) {
G_strip(data);
PS.vct[i].cats = G_store(data);
continue;
}
- if (KEY("where"))
- {
+ if (KEY("where")) {
G_strip(data);
PS.vct[i].where = G_store(data);
continue;
}
- if (KEY("masked"))
- {
+ if (KEY("masked")) {
PS.vct[i].masked = scan_yesno(key, data);
if (PS.vct[i].masked)
PS.need_mask = 1;
continue;
}
- if (KEY("label"))
- {
+ if (KEY("label")) {
G_strip(data);
PS.vct[i].label = G_store(data);
continue;
}
- if (KEY("legend") || KEY("lpos"))
- {
+ if (KEY("legend") || KEY("lpos")) {
int k;
- if (sscanf(data, "%d", &k) == 1)
- {
+ if (sscanf(data, "%d", &k) == 1) {
PS.vct[i].lpos = k;
}
- else
- {
+ else {
read_block(i);
}
continue;
}
- if (KEY("setrule"))
- {
+ if (KEY("setrule")) {
double val;
+
char str[128], catsbuf[128], labelbuf[128];
- if (sscanf(data, "%s %[^\n]", str, labelbuf) > 0)
- {
- if (sscanf(str, "%[^:]:%lf", catsbuf, &val) == 1)
- val = atof(catsbuf) * vector->scale;
- vector_rule_new(&(PS.vct[i]), catsbuf, labelbuf, val);
+ if (sscanf(data, "%s %[^\n]", str, labelbuf) > 0) {
+ if (sscanf(str, "%[^:]:%lf", catsbuf, &val) == 1)
+ val = atof(catsbuf) * vector->scale;
+ vector_rule_new(&(PS.vct[i]), catsbuf, labelbuf, val);
}
else
- error(key, data, "illegal setrule request (vpoints)");
+ error(key, data, "illegal setrule request (vpoints)");
continue;
}
error(key, "", "illegal request (vpoints)");
}
/* default label */
- if (PS.vct[i].label == NULL)
- {
+ if (PS.vct[i].label == NULL) {
sprintf(buf, "%s (%s)", PS.vct[i].name, PS.vct[i].mapset);
PS.vct[i].label = G_store(buf);
}
- if (vector->sizecol == NULL)
- {
- vector_item_new(&(PS.vct[i]), 0, (long)(vector->size * 1000.));
+ if (vector->sizecol == NULL) {
+ vector_item_new(&(PS.vct[i]), 0, (long)(vector->size * 1000.));
}
return 1;
Modified: grass-addons/postscript/ps.output/raster.c
===================================================================
--- grass-addons/postscript/ps.output/raster.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/raster.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -17,10 +17,8 @@
{
int i;
- for (i = 0; i < 3; i++)
- {
- if (PS.rst.fd[i] >= 0)
- {
+ for (i = 0; i < 3; i++) {
+ if (PS.rst.fd[i] >= 0) {
G_close_cell(PS.rst.fd[i]);
G_free(PS.rst.name[i]);
G_free(PS.rst.mapset[i]);
Modified: grass-addons/postscript/ps.output/scanners.c
===================================================================
--- grass-addons/postscript/ps.output/scanners.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/scanners.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -79,13 +79,14 @@
int scan_color(char *data, PSCOLOR * color)
{
int ret;
+
char name[20];
+
double alpha;
ret = sscanf(data, "%[^$]$%lf", name, &alpha);
- if (set_color_name(color, name))
- {
+ if (set_color_name(color, name)) {
color->a = (ret == 2) ? alpha : 1.;
return 1;
}
@@ -97,20 +98,19 @@
int scan_dimen(char *data, double *d)
{
int ret;
+
char unit = ' ';
ret = sscanf(data, "%lf%c", d, &unit);
if (ret == 1)
unit = ' ';
- else if (ret != 2)
- {
+ else if (ret != 2) {
*d = 0.;
return 0;
}
- switch (unit)
- {
+ switch (unit) {
/* metric to points */
case 'i':
*d *= INCH_TO_POINT;
@@ -133,14 +133,14 @@
int scan_second(char *data, double *d)
{
int ret;
+
char unit = ' ';
ret = sscanf(data, "%lf%c", d, &unit);
if (ret == 1)
unit = ' ';
- else if (ret != 2 || *d < 0.)
- {
+ else if (ret != 2 || *d < 0.) {
*d = 0.;
return 0;
}
Modified: grass-addons/postscript/ps.output/set_draw.c
===================================================================
--- grass-addons/postscript/ps.output/set_draw.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/set_draw.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -27,41 +27,38 @@
int set_draw(char *key, char *data)
{
char h, label[100], buf[256];
+
char e1[20], n1[20], e2[20], n2[20];
+
int i, x, y, dg, mg;
+
double east, north, lw, d, sg;
+
PSCOLOR color;
- if (KEY("direct"))
- {
+ if (KEY("direct")) {
fprintf(PS.fp, " %s ", data);
}
- else if (KEY("color"))
- {
- if (!scan_color(data, &color))
- error(key, data, "color: color");
- set_ps_color(&color);
+ else if (KEY("color")) {
+ if (!scan_color(data, &color))
+ error(key, data, "color: color");
+ set_ps_color(&color);
}
- else if (KEY("fcolor"))
- {
+ else if (KEY("fcolor")) {
scan_color(data, &fcolor);
}
- else if (KEY("linewidth"))
- {
- if (sscanf(data, "%s", label) != 1 ||
- scan_dimen(label, &lw) != 1)
+ else if (KEY("linewidth")) {
+ if (sscanf(data, "%s", label) != 1 || scan_dimen(label, &lw) != 1)
error(key, data, "linewidth: width");
fprintf(PS.fp, "%.1f LW ", lw);
}
- else if (KEY("linedash"))
- {
+ else if (KEY("linedash")) {
if (sscanf(data, "%[^\n]", label) != 1)
- fprintf(PS.fp, "[] 0 LD ");
- else
- fprintf(PS.fp, "[%s] 0 LD ", label);
+ fprintf(PS.fp, "[] 0 LD ");
+ else
+ fprintf(PS.fp, "[%s] 0 LD ", label);
}
- else if (KEY("font"))
- {
+ else if (KEY("font")) {
i = sscanf(data, "%s %s %lf", label, buf, &d);
if ((i != 2 && i != 3) || (scan_dimen(buf, &lw) != 1))
@@ -75,77 +72,62 @@
}
/* Drawing text */
else if (KEY("text") ||
- KEY("ltext") ||
- KEY("ctext") ||
- KEY("rtext") ||
- KEY("xtext") ||
- KEY("vtext"))
- {
+ KEY("ltext") ||
+ KEY("ctext") || KEY("rtext") || KEY("xtext") || KEY("vtext")) {
if (sscanf(data, "%s %s %[^\n]", e1, n1, label) != 3)
error(key, data, "text: east, north and text");
- if (atoi(e1) < 0)
- {
+ if (atoi(e1) < 0) {
fprintf(PS.fp, "GS %s ROT (%s) ", n1, label);
- }
- else
- {
+ }
+ else {
sprintf(buf, "M (%s) ", label);
set_on_paper("GS", e1, n1, buf);
}
- switch (*key)
- {
- case 'x':
- strcpy(buf, "SHCC");
- break;
- case 'c':
- strcpy(buf, "SHC");
- break;
- case 'r':
- strcpy(buf, "SHR");
- break;
- case 'v':
- strcpy(buf, "SVC");
- break;
- default:
- strcpy(buf, "TXT");
- break;
- }
- fprintf(PS.fp, "%s GR\n", buf);
+ switch (*key) {
+ case 'x':
+ strcpy(buf, "SHCC");
+ break;
+ case 'c':
+ strcpy(buf, "SHC");
+ break;
+ case 'r':
+ strcpy(buf, "SHR");
+ break;
+ case 'v':
+ strcpy(buf, "SVC");
+ break;
+ default:
+ strcpy(buf, "TXT");
+ break;
+ }
+ fprintf(PS.fp, "%s GR\n", buf);
}
- else if (KEY("-text"))
- {
+ else if (KEY("-text")) {
fprintf(PS.fp, " (%s) SHL ", data);
}
- else if (KEY("textc"))
- {
+ else if (KEY("textc")) {
if (sscanf(data, "%s %s %[^\n]", e1, n1, label) != 3)
- error(key, data, "ctext: east, north, and text");
+ error(key, data, "ctext: east, north, and text");
sprintf(buf, "M GS (%s) dup SHCC GR "
- "SWH 2 copy gt {pop} {exch pop} ifelse 2 div 2 add "
- "cP 3 -1 roll 0 360 NP arc CP S\n", label);
+ "SWH 2 copy gt {pop} {exch pop} ifelse 2 div 2 add "
+ "cP 3 -1 roll 0 360 NP arc CP S\n", label);
set_on_paper("", e1, n1, buf);
}
- else if (KEY("labels") ||
- KEY("label"))
- {
+ else if (KEY("labels") || KEY("label")) {
if (sscanf(data, "%s", label) != 1)
error(key, data, "labels: filename");
label_in_file(label);
}
/* Drawing paths */
- else if (KEY("moveto"))
- {
+ else if (KEY("moveto")) {
if (sscanf(data, "%s %s", e1, n1) != 2)
error(key, data, "moveto: east and north");
set_on_paper("", e1, n1, "M ");
}
- else if (KEY("lineto") ||
- KEY("ruteto"))
- {
- switch (sscanf(data, "%s %s %[^\n]", e1, n1, buf))
- {
+ else if (KEY("lineto") || KEY("ruteto")) {
+ switch (sscanf(data, "%s %s %[^\n]", e1, n1, buf)) {
case 2:
set_on_paper("", e1, n1, "L ");
break;
@@ -153,37 +135,31 @@
set_on_paper("cP exch 2 copy", e1, n1, "L GS cP 2 copy 8 2 roll");
fprintf(PS.fp,
" 4 -1 roll add 2 div 3 1 roll add 2 div exch M"
- " 4 1 roll sub 3 1 roll exch sub atan ROT 0 2 MR (%s) SHC S GR\n", buf);
+ " 4 1 roll sub 3 1 roll exch sub atan ROT 0 2 MR (%s) SHC S GR\n",
+ buf);
break;
default:
error(key, data, "lineto: east, north, and [text]");
}
}
- else if (KEY("endline"))
- {
- fprintf(PS.fp, " S");
+ else if (KEY("endline")) {
+ fprintf(PS.fp, " S");
}
- else if (KEY("line"))
- {
+ else if (KEY("line")) {
if (sscanf(data, "%s %s %s %s", e1, n1, e2, n2) != 4)
- error(key, data, "line: east/north east/north");
+ error(key, data, "line: east/north east/north");
set_on_paper("", e1, n1, "M");
/* if e2 < 0 polares angulo y longitud */
set_on_paper("", e2, n2, "LS\n");
}
- else if (KEY("border"))
- {
- if (sscanf(data, "%s", label) != 1 ||
- scan_dimen(label, &d) != 1)
- error(key, data, "border: width");
- set_ps_brd(d);
+ else if (KEY("border")) {
+ if (sscanf(data, "%s", label) != 1 || scan_dimen(label, &d) != 1)
+ error(key, data, "border: width");
+ set_ps_brd(d);
}
- else if (KEY("rect") ||
- KEY("rectangle"))
- {
- switch (sscanf(data, "%s %s %s %s %s", e1, n1, e2, n2, buf))
- {
+ else if (KEY("rect") || KEY("rectangle")) {
+ switch (sscanf(data, "%s %s %s %s %s", e1, n1, e2, n2, buf)) {
case 4:
set_on_paper("", e1, n1, "");
set_on_paper("", e2, n2, "B S\n");
@@ -196,20 +172,19 @@
fprintf(PS.fp, "fill GR S\n");
break;
default:
- error(key, data, "rectangle: east/north and east/north [fill color])");
+ error(key, data,
+ "rectangle: east/north and east/north [fill color])");
}
}
- else if (KEY("circ") ||
- KEY("circle"))
- {
+ else if (KEY("circ") || KEY("circle")) {
if (sscanf(data, "%s %s %lf", e1, n1, &d) != 3)
error(key, data, "circle: x, y and radius");
- sprintf(buf, "%.1f 0 360 arc S\n", d * (MT_TO_POINT / (double)PS.scale));
+ sprintf(buf, "%.1f 0 360 arc S\n",
+ d * (MT_TO_POINT / (double)PS.scale));
set_on_paper("", e1, n1, buf);
}
- else if (KEY("arc"))
- {
+ else if (KEY("arc")) {
if (sscanf(data, "%s %s %lf %s %s", e1, n1, &d, e2, n2) != 5)
error(key, data, "arc need 5 parameters");
@@ -218,27 +193,22 @@
set_on_paper(buf, e2, n2, "arc S\n");
}
/* Include files */
- else if (KEY("psfile") ||
- KEY("epsfile"))
- {
- if (sscanf(data, "%lf %s %s %s", &d, e1, n1, label) != 4)
- {
+ else if (KEY("psfile") || KEY("epsfile")) {
+ if (sscanf(data, "%lf %s %s %s", &d, e1, n1, label) != 4) {
error(key, data, "psfile: scale, east, north, and filename");
}
set_on_paper("GS", e1, n1, "TR ");
fprintf(PS.fp, "%.2f dup scale ", d);
FILE *fp;
- if ((fp = fopen(label, "r")) != NULL)
- {
+ if ((fp = fopen(label, "r")) != NULL) {
G_message("Reading PostScript file <%s> ...", label);
fprintf(PS.fp, "\n");
/*
while (fgets(buf, 256, fp) != NULL)
fprintf(PS.fp, "%s", buf);
*/
- while (fgets(buf, 256, fp) != NULL)
- {
+ while (fgets(buf, 256, fp) != NULL) {
if (strcmp(buf, "showpage\n") == 0)
continue;
fprintf(PS.fp, "%s", buf);
@@ -249,33 +219,33 @@
fprintf(PS.fp, "GR\n");
}
/* Drawing complements */
- else if (KEY("maplimit") ||
- KEY("maplimits"))
- {
+ else if (KEY("maplimit") || KEY("maplimits")) {
if (sscanf(data, "%s", label) != 1)
d = 0.;
else
scan_dimen(label, &d);
- fprintf(PS.fp, "%.1f %.1f add %.1f %.1f add M ", PS.map_right, d, PS.map_top, d);
+ fprintf(PS.fp, "%.1f %.1f add %.1f %.1f add M ", PS.map_right, d,
+ PS.map_top, d);
format_northing(PS.map.north, buf, PS.map.proj);
fprintf(PS.fp, "GS (%s) dup SWH ++ neg dup MR pop SHR GR\n", buf);
format_easting(PS.map.east, buf, PS.map.proj);
- fprintf(PS.fp, "GS (%s) dup SWH ++ dup neg 3 1 roll add neg MR 270 ROT SHR GR\n", buf);
+ fprintf(PS.fp,
+ "GS (%s) dup SWH ++ dup neg 3 1 roll add neg MR 270 ROT SHR GR\n",
+ buf);
- fprintf(PS.fp, "%.1f %.1f sub %.1f %.1f sub M ", PS.map_x, d, PS.map_y, d);
+ fprintf(PS.fp, "%.1f %.1f sub %.1f %.1f sub M ", PS.map_x, d,
+ PS.map_y, d);
format_northing(PS.map.south, buf, PS.map.proj);
fprintf(PS.fp, "GS (%s) dup SWH ++ 1 MR pop SHL GR\n", buf);
format_easting(PS.map.west, buf, PS.map.proj);
fprintf(PS.fp, "GS (%s) dup SWH ++ dup MR pop 90 ROT SHL GR\n", buf);
}
- else if (KEY("northarrow") ||
- KEY("north"))
- {
- switch (sscanf(data, "%s %s %s", e1, n1, buf))
- {
+ else if (KEY("northarrow") || KEY("north")) {
+ switch (sscanf(data, "%s %s %s", e1, n1, buf)) {
case 2:
- sprintf(buf, "M 5 dup neg dup 3 mul LR dup dup LR dup neg LR CP cP S M 0 2 MR (N) SHC\n");
+ sprintf(buf,
+ "M 5 dup neg dup 3 mul LR dup dup LR dup neg LR CP cP S M 0 2 MR (N) SHC\n");
set_on_paper("NP .2 mm LW", e1, n1, buf);
break;
case 3:
@@ -291,19 +261,18 @@
error(key, data, "northarrow: x, y and radius");
}
}
- else if (KEY("declination"))
- {
+ else if (KEY("declination")) {
}
- else if (KEY("compass") ||
- KEY("rose"))
- {
+ else if (KEY("compass") || KEY("rose")) {
char h;
+
int dg, mn;
+
double conv, sec;
- if (sscanf(data, "%lf %lf %lf %lf", &east, &north, &d, &conv) != 4)
- {
- error(key, data, "compass: x, y, radius and magnetic declination");
+ if (sscanf(data, "%lf %lf %lf %lf", &east, &north, &d, &conv) != 4) {
+ error(key, data,
+ "compass: x, y, radius and magnetic declination");
}
d *= (MT_TO_POINT / (double)PS.scale);
set_xy_where(".25 LW", east, north, "M ");
@@ -326,8 +295,7 @@
fprintf(PS.fp, "2 div 1 MR (%s) SHC GR\n", buf);
}
/* Oops ending */
- else
- {
+ else {
error(key, data, "not found\n");
}
@@ -338,35 +306,36 @@
void label_in_file(char *name)
{
FILE *in = NULL;
+
char buf[1024], code[1024], data[1024];
+
int x, y;
+
double n;
+
PSFRAME frame;
+
PSFONT font;
frame.xref = CENTER;
frame.yref = CENTER;
- if (*name)
- {
+ if (*name) {
in = fopen(name, "r");
- if (in == NULL)
- {
+ if (in == NULL) {
G_message("Labels file <%s> can't open", name);
return;
}
}
- while (fgets(buf, sizeof(buf), in))
- {
+ while (fgets(buf, sizeof(buf), in)) {
*code = 0;
*data = 0;
if (sscanf(buf, "%[^:]:%[^\n]", code, data) < 1)
continue;
G_strip(data);
- if (CODE("text"))
- {
+ if (CODE("text")) {
G_plot_where_xy(frame.x, frame.y, &x, &y);
frame.x = ((double)x) / 10.;
@@ -375,93 +344,73 @@
set_ps_font(&font);
fprintf(PS.fp, "GS\n");
fprintf(PS.fp, "/ARo [(%s)] def\n", data);
- fprintf(PS.fp, "/ARw [ARo SWx] def ");
- fprintf(PS.fp, "/ARh [FS0] def\n");
+ fprintf(PS.fp, "/ARw [ARo SWx] def ");
+ fprintf(PS.fp, "/ARh [FS0] def\n");
set_box_auto(&frame, &font, 0.25);
- fprintf(PS.fp, "(%s) READJUST ", data);
+ fprintf(PS.fp, "(%s) READJUST ", data);
set_box_draw(&frame);
fprintf(PS.fp, "GR\n");
- fprintf(PS.fp, "(%s) xo wd 2 div add yo hg 2 div sub M SHCC\n", data);
+ fprintf(PS.fp, "(%s) xo wd 2 div add yo hg 2 div sub M SHCC\n",
+ data);
}
/* Option to modify the text */
- else if (CODE("east"))
- {
+ else if (CODE("east")) {
frame.x = atof(data);
}
- else if (CODE("north"))
- {
+ else if (CODE("north")) {
frame.y = atof(data);
}
- else if (CODE("xoffset"))
- {
+ else if (CODE("xoffset")) {
frame.xset = atof(data);
}
- else if (CODE("yoffset"))
- {
+ else if (CODE("yoffset")) {
frame.yset = atof(data);
}
- else if (CODE("ref"))
- {
+ else if (CODE("ref")) {
scan_ref(data, &(frame.xref), &(frame.yref));
}
- else if (CODE("font"))
- {
+ else if (CODE("font")) {
get_font(data);
strcpy(font.name, data);
}
- else if (CODE("fontsize"))
- {
+ else if (CODE("fontsize")) {
if (scan_dimen(data, &(font.size)) != 1)
font.size = 10.;
}
- else if (CODE("size"))
- {
+ else if (CODE("size")) {
n = atof(data);
font.size = (n * MT_TO_POINT) / PS.scale;
}
- else if (CODE("color"))
- {
- if (!scan_color(data, &(font.color)))
- {
+ else if (CODE("color")) {
+ if (!scan_color(data, &(font.color))) {
set_color_rgb(&(font.color), 0, 0, 0);
}
}
- else if (CODE("space"))
- {
+ else if (CODE("space")) {
}
- else if (CODE("rotation"))
- {
+ else if (CODE("rotation")) {
frame.rotate = atof(data);
}
- else if (CODE("width"))
- {
- if (scan_dimen(data, &(frame.border)) != 1)
- {
+ else if (CODE("width")) {
+ if (scan_dimen(data, &(frame.border)) != 1) {
frame.border = -1;
}
}
- else if (CODE("hcolor"))
- {
+ else if (CODE("hcolor")) {
}
- else if (CODE("hwidth"))
- {
+ else if (CODE("hwidth")) {
}
- else if (CODE("background"))
- {
- if (!scan_color(data, &(frame.fcolor)))
- {
+ else if (CODE("background")) {
+ if (!scan_color(data, &(frame.fcolor))) {
unset_color(&(frame.fcolor));
}
}
- else if (CODE("border"))
- {
- if (!scan_color(data, &(frame.color)))
- {
+ else if (CODE("border")) {
+ if (!scan_color(data, &(frame.color))) {
unset_color(&(frame.color));
}
}
- else if (CODE("opaque"))
- {
+ else if (CODE("opaque")) {
}
}
fclose(in);
@@ -473,22 +422,22 @@
int set_on_paper(char *pre, char *c_x, char *c_y, char *post)
{
char xunit, yunit;
+
int xret, yret, x, y;
+
double dx, dy;
xret = sscanf(c_x, "%lf%c", &dx, &xunit);
yret = sscanf(c_y, "%lf%c", &dy, &yunit);
/* east | north */
- if (xret == 1 && yret == 1)
- {
+ if (xret == 1 && yret == 1) {
G_plot_where_xy(dx, dy, &x, &y);
dx = ((double)x) / 10.;
dy = ((double)y) / 10.;
}
/* x | y */
- else if (xret == 2 && yret == 2)
- {
+ else if (xret == 2 && yret == 2) {
xret = scan_dimen(c_x, &dx);
yret = scan_dimen(c_y, &dy);
/* percent */
@@ -500,8 +449,8 @@
dx = (PS.page.width + dx);
if (yret < 0)
dy = (PS.page.height + dy);
- /* margen inferior */
- dy = PS.page.height - dy;
+ /* margen inferior */
+ dy = PS.page.height - dy;
}
fprintf(PS.fp, "%s %.1f %.1f %s", pre, dx, dy, post);
return xret;
Modified: grass-addons/postscript/ps.output/set_geogrid.c
===================================================================
--- grass-addons/postscript/ps.output/set_geogrid.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/set_geogrid.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -34,7 +34,9 @@
int set_geogrid_lines(PSLINE * line, int grid_sep)
{
double sep, n_min, nmin, e_min, emin;
+
double e, n, east, west, north, south;
+
struct pj_info ll_proj, proj;
if (PS.geogrid.sep <= 0 || PS.geogrid.line.color.none)
@@ -53,10 +55,8 @@
e_min = ceil(east / sep) * sep;
/* latitude lines */
- for (nmin = n_min; nmin >= south; nmin -= sep)
- {
- for (emin = e_min; emin >= west; emin -= sep)
- {
+ for (nmin = n_min; nmin >= south; nmin -= sep) {
+ for (emin = e_min; emin >= west; emin -= sep) {
e = emin;
n = nmin;
pj_do_proj(&e, &n, &ll_proj, &proj); /* LL to PROJ */
@@ -69,10 +69,8 @@
}
}
/* longitude lines */
- for (emin = e_min; emin >= west; emin -= sep)
- {
- for (nmin = n_min; nmin >= south; nmin -= sep)
- {
+ for (emin = e_min; emin >= west; emin -= sep) {
+ for (nmin = n_min; nmin >= south; nmin -= sep) {
e = emin;
n = nmin;
pj_do_proj(&e, &n, &ll_proj, &proj);
@@ -94,10 +92,15 @@
int set_numbers_geogrid(void)
{
char label[50];
+
int i, x, y;
+
double dx, dy;
+
double grid_sep, nmin, emin, dif;
+
double e, n, east, west, north, south;
+
struct pj_info ll_proj, proj;
if (PS.geogrid.sep <= 0)
@@ -115,8 +118,7 @@
/* vertical-right numbers */
fprintf(PS.fp, "/GRR [\n");
nmin = floor(north / grid_sep) * grid_sep;
- for (; nmin > south; nmin -= grid_sep)
- {
+ for (; nmin > south; nmin -= grid_sep) {
e = east;
n = nmin;
pj_do_proj(&e, &n, &ll_proj, &proj);
@@ -137,8 +139,7 @@
/* horizontal-bottom numbers */
fprintf(PS.fp, "/GRB [\n");
emin = floor(east / grid_sep) * grid_sep;
- for (; emin > west; emin -= grid_sep)
- {
+ for (; emin > west; emin -= grid_sep) {
n = south;
e = emin;
pj_do_proj(&e, &n, &ll_proj, &proj);
@@ -157,8 +158,7 @@
fprintf(PS.fp, "] def\n");
/* select format */
- switch (PS.geogrid.format)
- {
+ switch (PS.geogrid.format) {
case 0:
set_geogrid_inner_numbers();
break;
@@ -183,7 +183,9 @@
if (PS.geogrid.fcolor.none)
fprintf(PS.fp, "SW .5 add neg .5 MR ");
else
- fprintf(PS.fp, "SWH m 2 mul add 1 index m 1 add add neg " "exch dup -2 div 0 exch MR Rf ++ neg m MR ");
+ fprintf(PS.fp,
+ "SWH m 2 mul add 1 index m 1 add add neg "
+ "exch dup -2 div 0 exch MR Rf ++ neg m MR ");
set_ps_color(&(PS.geogrid.font.color));
fprintf(PS.fp, "%s} for\n", (PS.geogrid.trim < 0 ? "COOR" : "SHL"));
@@ -193,9 +195,12 @@
if (PS.geogrid.fcolor.none)
fprintf(PS.fp, "pop -.5 .5 MR ");
else
- fprintf(PS.fp, "SWH m 2 mul add exch m 1 add add 1 index -2 div 0 MR " "1 index exch Rf m sub 1 MR ");
+ fprintf(PS.fp,
+ "SWH m 2 mul add exch m 1 add add 1 index -2 div 0 MR "
+ "1 index exch Rf m sub 1 MR ");
set_ps_color(&(PS.geogrid.font.color));
- fprintf(PS.fp, "GS 90 ROT %s GR} for\n", (PS.geogrid.trim < 0 ? "COOR" : "SHL"));
+ fprintf(PS.fp, "GS 90 ROT %s GR} for\n",
+ (PS.geogrid.trim < 0 ? "COOR" : "SHL"));
fprintf(PS.fp, "GR\n");
return 0;
@@ -210,12 +215,14 @@
/* vertical numbers */
fprintf(PS.fp,
"0 1 GRR length -- {GRR exch GET M dup "
- "SW 2 div %.2f exch MR GS 270 ROT %s GR} for ", PS.brd.width + 1., (PS.geogrid.trim < 0 ? "COOR" : "SHL"));
+ "SW 2 div %.2f exch MR GS 270 ROT %s GR} for ", PS.brd.width + 1.,
+ (PS.geogrid.trim < 0 ? "COOR" : "SHL"));
/* horizontal numbers */
fprintf(PS.fp,
"0 1 GRB length -- {GRB exch GET M dup "
- "SWH %.2f add neg exch -2 div exch MR %s} for ", PS.brd.width + 1., (PS.geogrid.trim < 0 ? "COOR" : "SHL"));
+ "SWH %.2f add neg exch -2 div exch MR %s} for ",
+ PS.brd.width + 1., (PS.geogrid.trim < 0 ? "COOR" : "SHL"));
fprintf(PS.fp, "GR\n");
return 0;
Modified: grass-addons/postscript/ps.output/set_grid.c
===================================================================
--- grass-addons/postscript/ps.output/set_grid.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/set_grid.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -24,8 +24,7 @@
{
fprintf(PS.fp, "/XY {get aload pop exch pop} D\n");
- if (PS.grid.msep > 0)
- {
+ if (PS.grid.msep > 0) {
set_grid_lines('m', &(PS.grid.mline), PS.grid.msep);
}
set_grid_lines('M', &(PS.grid.line), PS.grid.sep);
@@ -34,7 +33,9 @@
int set_grid_lines(char code, PSLINE * line, int grid_sep)
{
char label[50], h;
+
int i, x, y, zero, d, m;
+
double sep, north, west, dx, dy, s;
if (grid_sep <= 0)
@@ -42,20 +43,16 @@
/* detect trailer zeros if format zero and not LL */
zero = 1;
- if (PS.map.proj == PROJECTION_LL)
- {
+ if (PS.map.proj == PROJECTION_LL) {
sep = (double)grid_sep / 3600.;
/* break iho */
}
- else
- {
+ else {
sep = (double)grid_sep;
- if (PS.grid.format < 2 && PS.grid.trim > 0)
- {
+ if (PS.grid.format < 2 && PS.grid.trim > 0) {
while (PS.grid.sep % zero == 0)
zero *= 10;
- if (zero > 1)
- {
+ if (zero > 1) {
zero /= 10;
for (i = 0, x = 1; i < PS.grid.trim; i++)
x *= 10;
@@ -68,16 +65,13 @@
/* vertical numbers */
fprintf(PS.fp, "/VGR%c [\n", code);
north = floor(PS.map.north / sep) * sep;
- for (; north >= PS.map.south; north -= sep)
- {
+ for (; north >= PS.map.south; north -= sep) {
G_plot_where_xy(PS.map.east, north, &x, &y);
dy = ((double)y) / 10.;
- if (PS.grid.format == 2)
- {
+ if (PS.grid.format == 2) {
format_iho(north, label);
}
- else
- {
+ else {
format_easting(north / zero, label, PS.map.proj);
}
fprintf(PS.fp, "[(%s) %.2f]\n", label, dy);
@@ -87,16 +81,13 @@
/* horizontal numbers */
fprintf(PS.fp, "/HGR%c [\n", code);
west = ceil(PS.map.west / sep) * sep;
- for (; west < PS.map.east; west += sep)
- {
+ for (; west < PS.map.east; west += sep) {
G_plot_where_xy(west, PS.map.south, &x, &y);
dx = ((double)x) / 10.;
- if (PS.grid.format == 2)
- {
+ if (PS.grid.format == 2) {
format_iho(west, label);
}
- else
- {
+ else {
format_easting(west / zero, label, PS.map.proj);
}
fprintf(PS.fp, "[(%s) %.2f]\n", label, dx);
@@ -104,30 +95,31 @@
fprintf(PS.fp, "] def\n");
- if (line->color.none != 1)
- {
+ if (line->color.none != 1) {
set_ps_line(line);
- if (PS.grid.cross <= 0.)
- { /* draw lines */
+ if (PS.grid.cross <= 0.) { /* draw lines */
fprintf(PS.fp,
"VGR%c 0 1 2 index length -- {1 index exch XY "
- "%.2f exch dup %.2f exch M LS} for pop\n", code, PS.map_x, PS.map_right);
+ "%.2f exch dup %.2f exch M LS} for pop\n", code, PS.map_x,
+ PS.map_right);
fprintf(PS.fp,
"HGR%c 0 1 2 index length -- {1 index exch XY "
- "%.2f 1 index %.2f M LS} for pop\n", code, PS.map_y, PS.map_top);
+ "%.2f 1 index %.2f M LS} for pop\n", code, PS.map_y,
+ PS.map_top);
}
- else
- { /* draw crosses */
+ else { /* draw crosses */
G_plot_where_xy(PS.map.east, PS.map.north, &x, &y);
dx = ((double)x) / 10.;
- G_plot_where_xy(PS.map.east - PS.grid.cross, PS.map.north, &x, &y);
+ G_plot_where_xy(PS.map.east - PS.grid.cross, PS.map.north, &x,
+ &y);
dy = ((double)x) / 10.;
fprintf(PS.fp,
"VGR%c 0 1 2 index length -- {1 index exch XY "
"HGR%c 0 1 2 index length -- {1 index exch XY "
- "2 index M 0 90 270 {GS ROT 0 %.2f LRS GR} for} " "for pop pop} for pop\n", code, code, dx - dy);
+ "2 index M 0 90 270 {GS ROT 0 %.2f LRS GR} for} "
+ "for pop pop} for pop\n", code, code, dx - dy);
}
}
/* draw crosses como rotate una longitud desde el punto central */
@@ -143,42 +135,43 @@
set_ps_color(&(PS.grid.fcolor));
/* make numbers */
- switch (PS.grid.format)
- {
+ switch (PS.grid.format) {
case 0:
set_ps_brd2(.2 * MM_TO_POINT, 0.);
set_grid_inner_numbers();
break;
case 1:
set_ps_brd2(.2 * MM_TO_POINT, 0.);
- if (PS.grid.msep > 0)
- {
- if (PS.grid.msubdiv >= 0)
- {
+ if (PS.grid.msep > 0) {
+ if (PS.grid.msubdiv >= 0) {
double mrga = 0.4 * PS.brd.width - .2 * MM_TO_POINT;
+
double mrgb = 0.6 * PS.brd.width - .2 * MM_TO_POINT;
- set_grid_minordiv_border(PS.grid.msubdiv, .2 * MM_TO_POINT, mrga);
+ set_grid_minordiv_border(PS.grid.msubdiv, .2 * MM_TO_POINT,
+ mrga);
set_grid_minor_border(.2 * MM_TO_POINT + mrga, mrgb, mrgb);
}
else
- set_grid_minor_border(.2 * MM_TO_POINT, PS.brd.width - .2 * MM_TO_POINT, PS.brd.width);
+ set_grid_minor_border(.2 * MM_TO_POINT,
+ PS.brd.width - .2 * MM_TO_POINT,
+ PS.brd.width);
}
set_grid_outer_numbers(2);
break;
case 2:
set_ps_brd2(.2 * MM_TO_POINT, 0.);
- if (PS.grid.msep > 0)
- {
+ if (PS.grid.msep > 0) {
fprintf(PS.fp, "0.2 mm LW ");
- set_grid_minordiv_border(PS.grid.msubdiv, 0.2 * MM_TO_POINT, 0.4 * MM_TO_POINT);
- set_grid_minor_border(0.8 * MM_TO_POINT, 1.0 * MM_TO_POINT, 0.2 * MM_TO_POINT);
+ set_grid_minordiv_border(PS.grid.msubdiv, 0.2 * MM_TO_POINT,
+ 0.4 * MM_TO_POINT);
+ set_grid_minor_border(0.8 * MM_TO_POINT, 1.0 * MM_TO_POINT,
+ 0.2 * MM_TO_POINT);
fprintf(PS.fp, "0.8 mm LW ");
set_grid_major_border(2.0 * MM_TO_POINT, 9.9 * MM_TO_POINT);
set_grid_iho_numbers(2.0 * MM_TO_POINT, 9.9 * MM_TO_POINT);
}
- else
- {
+ else {
fprintf(PS.fp, "0.8 mm LW ");
set_grid_major_border(0.2 * MM_TO_POINT, 11.7 * MM_TO_POINT);
set_grid_iho_numbers(0.2 * MM_TO_POINT, 11.7 * MM_TO_POINT);
@@ -186,10 +179,12 @@
break;
case 3:
fprintf(PS.fp, "0.005 inch LW ");
- set_grid_minordiv_border(PS.grid.msubdiv, 0.005 * INCH_TO_POINT, 0.035 * INCH_TO_POINT);
- if (PS.grid.msep > 0)
- {
- set_grid_minor_border(0.045 * INCH_TO_POINT, 0.025 * INCH_TO_POINT, 0.025 * INCH_TO_POINT);
+ set_grid_minordiv_border(PS.grid.msubdiv, 0.005 * INCH_TO_POINT,
+ 0.035 * INCH_TO_POINT);
+ if (PS.grid.msep > 0) {
+ set_grid_minor_border(0.045 * INCH_TO_POINT,
+ 0.025 * INCH_TO_POINT,
+ 0.025 * INCH_TO_POINT);
}
set_ps_brd(15.605 * MM_TO_POINT);
set_ps_brd2(0.025 * INCH_TO_POINT, 17.3322 * MM_TO_POINT);
@@ -209,14 +204,15 @@
set_ps_font(&(PS.grid.font));
/* vertical numbers */
- fprintf(PS.fp, "0 1 VGRM length -- {VGRM exch GET %.2f exch M ", PS.map_x);
- if (PS.grid.fcolor.none)
- {
+ fprintf(PS.fp, "0 1 VGRM length -- {VGRM exch GET %.2f exch M ",
+ PS.map_x);
+ if (PS.grid.fcolor.none) {
fprintf(PS.fp, ".2 mm .2 mm MR ");
}
- else
- {
- fprintf(PS.fp, "dup SWH m 2 mul add exch m 1 add add exch " "dup 2 div neg 0 exch MR GS ");
+ else {
+ fprintf(PS.fp,
+ "dup SWH m 2 mul add exch m 1 add add exch "
+ "dup 2 div neg 0 exch MR GS ");
set_ps_color(&(PS.grid.fcolor));
fprintf(PS.fp, "Rf GR 1 m MR ");
}
@@ -224,17 +220,18 @@
/* horizontal numbers */
fprintf(PS.fp, "0 1 HGRM length -- {HGRM exch GET %.2f M ", PS.map_top);
- if (PS.grid.fcolor.none)
- {
+ if (PS.grid.fcolor.none) {
fprintf(PS.fp, "dup SW .5 add neg -.5 exch MR ");
}
- else
- {
- fprintf(PS.fp, "dup SWH m 2 mul add exch m 1 add add " "1 index 2 div 1 index neg MR exch neg exch GS ");
+ else {
+ fprintf(PS.fp,
+ "dup SWH m 2 mul add exch m 1 add add "
+ "1 index 2 div 1 index neg MR exch neg exch GS ");
set_ps_color(&(PS.grid.fcolor));
fprintf(PS.fp, "Rf GR m neg m MR ");
}
- fprintf(PS.fp, "GS 90 ROT %s GR} for\n", (PS.grid.trim < 0 ? "COOR" : "SHL"));
+ fprintf(PS.fp, "GS 90 ROT %s GR} for\n",
+ (PS.grid.trim < 0 ? "COOR" : "SHL"));
fprintf(PS.fp, "GR\n");
return 0;
@@ -249,25 +246,29 @@
set_ps_font(&(PS.grid.font));
/* vertical numbers */
- fprintf(PS.fp, "0 1 VGRM length -- {VGRM exch GET %.2f exch M ", PS.map_x);
+ fprintf(PS.fp, "0 1 VGRM length -- {VGRM exch GET %.2f exch M ",
+ PS.map_x);
fprintf(PS.fp, "dup SW -2 div -%.2f exch MR ", PS.brd.width + M);
- fprintf(PS.fp, "GS 90 ROT %s GR} for\n", (PS.grid.trim < 0 ? "COOR" : "SHL"));
+ fprintf(PS.fp, "GS 90 ROT %s GR} for\n",
+ (PS.grid.trim < 0 ? "COOR" : "SHL"));
/* horizontal numbers */
fprintf(PS.fp, "0 1 HGRM length -- {HGRM exch GET %.2f M ", PS.map_top);
fprintf(PS.fp, "dup SW -2 div %.2f MR ", PS.brd.width + M);
fprintf(PS.fp, "%s} for\n", (PS.grid.trim < 0 ? "COOR" : "SHL"));
- if (PS.grid.lsides == 4)
- {
+ if (PS.grid.lsides == 4) {
/* right vertical numbers */
- fprintf(PS.fp, "0 1 VGRM length -- {VGRM exch GET %.2f exch M ", PS.map_right);
+ fprintf(PS.fp, "0 1 VGRM length -- {VGRM exch GET %.2f exch M ",
+ PS.map_right);
fprintf(PS.fp, "dup SW 2 div %.2f exch MR ", PS.brd.width + M);
- fprintf(PS.fp, "GS 270 ROT %s GR} for\n", (PS.grid.trim < 0 ? "COOR" : "SHL"));
+ fprintf(PS.fp, "GS 270 ROT %s GR} for\n",
+ (PS.grid.trim < 0 ? "COOR" : "SHL"));
/* bottom horizontal numbers */
fprintf(PS.fp, "0 1 HGRM length -- {HGRM exch GET %.2f M ", PS.map_y);
- fprintf(PS.fp, "dup SWH %.2f add neg exch -2 div exch MR ", PS.brd.width + M);
+ fprintf(PS.fp, "dup SWH %.2f add neg exch -2 div exch MR ",
+ PS.brd.width + M);
fprintf(PS.fp, "%s} for\n", (PS.grid.trim < 0 ? "COOR" : "SHL"));
}
@@ -283,22 +284,28 @@
set_ps_font(&(PS.grid.font));
/* vertical numbers */
- fprintf(PS.fp, "0 1 VGRM length -- {VGRM exch GET %.2f exch M ", PS.map_x - A - B / 2.);
+ fprintf(PS.fp, "0 1 VGRM length -- {VGRM exch GET %.2f exch M ",
+ PS.map_x - A - B / 2.);
fprintf(PS.fp, " (|) search pop exch pop ");
- fprintf(PS.fp, "GS 0 1.25 MR SHC GR GS FR dup SWH exch pop 1.25 add neg 0 exch MR SHC GR} for\n");
+ fprintf(PS.fp,
+ "GS 0 1.25 MR SHC GR GS FR dup SWH exch pop 1.25 add neg 0 exch MR SHC GR} for\n");
/* right vertical numbers */
- fprintf(PS.fp, "0 1 VGRM length -- {VGRM exch GET %.2f exch M ", PS.map_right + A + B / 2.);
+ fprintf(PS.fp, "0 1 VGRM length -- {VGRM exch GET %.2f exch M ",
+ PS.map_right + A + B / 2.);
fprintf(PS.fp, " (|) search pop exch pop ");
- fprintf(PS.fp, "GS 0 1.25 MR SHC GR GS FR dup SWH exch pop 1.25 add neg 0 exch MR SHC GR} for\n");
+ fprintf(PS.fp,
+ "GS 0 1.25 MR SHC GR GS FR dup SWH exch pop 1.25 add neg 0 exch MR SHC GR} for\n");
/* horizontal numbers */
- fprintf(PS.fp, "0 1 HGRM length -- {HGRM exch GET %.2f M ", PS.map_top + A + B / 2.);
+ fprintf(PS.fp, "0 1 HGRM length -- {HGRM exch GET %.2f M ",
+ PS.map_top + A + B / 2.);
fprintf(PS.fp, " (|) search pop exch pop ");
fprintf(PS.fp, "GS -1.25 0 MR SHRC GR GS FR 1.25 0 MR SHLC GR} for\n");
/* bottom horizontal numbers */
- fprintf(PS.fp, "0 1 HGRM length -- {HGRM exch GET %.2f M ", PS.map_y - A - B / 2.);
+ fprintf(PS.fp, "0 1 HGRM length -- {HGRM exch GET %.2f M ",
+ PS.map_y - A - B / 2.);
fprintf(PS.fp, " (|) search pop exch pop ");
fprintf(PS.fp, "GS -1.25 0 MR SHRC GR GS FR 1.25 0 MR SHLC GR} for\n");
@@ -314,19 +321,23 @@
set_ps_font(&(PS.grid.font));
/* vertical numbers */
- fprintf(PS.fp, "0 1 VGRM length -- {VGRM exch GET %.2f exch M ", PS.map_x - A - B / 2.);
+ fprintf(PS.fp, "0 1 VGRM length -- {VGRM exch GET %.2f exch M ",
+ PS.map_x - A - B / 2.);
fprintf(PS.fp, "dup SWH 2 div neg exch 2 div neg exch MR COOR} for\n");
/* right vertical numbers */
- fprintf(PS.fp, "0 1 VGRM length -- {VGRM exch GET %.2f exch M ", PS.map_right + A + B / 2.);
+ fprintf(PS.fp, "0 1 VGRM length -- {VGRM exch GET %.2f exch M ",
+ PS.map_right + A + B / 2.);
fprintf(PS.fp, "dup SWH 2 div neg exch 2 div neg exch MR COOR} for\n");
/* horizontal numbers */
- fprintf(PS.fp, "0 1 HGRM length -- {HGRM exch GET %.2f M ", PS.map_top + A + B / 2.);
+ fprintf(PS.fp, "0 1 HGRM length -- {HGRM exch GET %.2f M ",
+ PS.map_top + A + B / 2.);
fprintf(PS.fp, "dup SWH 2 div neg exch 2 div neg exch MR COOR} for\n");
/* bottom horizontal numbers */
- fprintf(PS.fp, "0 1 HGRM length -- {HGRM exch GET %.2f M ", PS.map_y - A - B / 2.);
+ fprintf(PS.fp, "0 1 HGRM length -- {HGRM exch GET %.2f M ",
+ PS.map_y - A - B / 2.);
fprintf(PS.fp, "dup SWH 2 div neg exch 2 div neg exch MR COOR} for\n");
fprintf(PS.fp, "GR\n");
@@ -339,54 +350,62 @@
void set_grid_minordiv_border(int div, double margin, double width)
{
- fprintf(PS.fp, "%.2f %.2f %.2f %.2f RO\n", PS.map_x, PS.map_top + margin, PS.map_w, width);
+ fprintf(PS.fp, "%.2f %.2f %.2f %.2f RO\n", PS.map_x, PS.map_top + margin,
+ PS.map_w, width);
- fprintf(PS.fp, "%.2f %.2f %.2f %.2f RO\n", PS.map_x, PS.map_y - margin, PS.map_w, -width);
+ fprintf(PS.fp, "%.2f %.2f %.2f %.2f RO\n", PS.map_x, PS.map_y - margin,
+ PS.map_w, -width);
- fprintf(PS.fp, "%.2f %.2f %.2f %.2f RO\n", PS.map_x - margin - width, PS.map_y, width, PS.map_h);
+ fprintf(PS.fp, "%.2f %.2f %.2f %.2f RO\n", PS.map_x - margin - width,
+ PS.map_y, width, PS.map_h);
- fprintf(PS.fp, "%.2f %.2f %.2f %.2f RO\n", PS.map_right + margin, PS.map_y, width, PS.map_h);
+ fprintf(PS.fp, "%.2f %.2f %.2f %.2f RO\n", PS.map_right + margin,
+ PS.map_y, width, PS.map_h);
- if (div > 0)
- {
+ if (div > 0) {
fprintf(PS.fp,
"1 1 VGRm length -- {dup VGRm exch XY exch -- VGRm exch XY "
"1 index sub %d div exch %d ++ {"
"dup %.2f exch M %.2f 0 LR dup %.2f exch M %.2f 0 LR S "
- "1 index add} repeat pop pop} for ", div, div, PS.map_x - margin, -width, PS.map_right + margin, width);
+ "1 index add} repeat pop pop} for ", div, div,
+ PS.map_x - margin, -width, PS.map_right + margin, width);
fprintf(PS.fp,
"1 1 HGRm length -- {dup HGRm exch XY exch -- HGRm exch XY "
"1 index sub %d div exch %d ++ {"
"dup %.2f M 0 %.2f LR dup %.2f M 0 %.2f LR S "
- "1 index add} repeat pop pop} for ", div, div, PS.map_y - margin, -width, PS.map_top + margin, width);
+ "1 index add} repeat pop pop} for ", div, div,
+ PS.map_y - margin, -width, PS.map_top + margin, width);
}
- if (div > 1)
- {
+ if (div > 1) {
fprintf(PS.fp,
"VGRm 0 XY VGRm 1 XY 1 index sub neg %d div exch {"
"1 index add dup %.2f gt {exit} {"
"dup %.2f exch M %.2f 0 LR dup %.2f exch M %.2f 0 LR S "
- "} ifelse} loop ", div, PS.map_top, PS.map_x - margin, -width, PS.map_right + margin, width);
+ "} ifelse} loop ", div, PS.map_top, PS.map_x - margin, -width,
+ PS.map_right + margin, width);
fprintf(PS.fp,
"/i VGRm length -- def VGRm i XY VGRm i -- XY 1 index sub neg %d div exch {"
"1 index add dup %.2f lt {exit} {"
"dup %.2f exch M %.2f 0 LR dup %.2f exch M %.2f 0 LR S "
- "} ifelse} loop ", div, PS.map_y, PS.map_x - margin, -width, PS.map_right + margin, width);
+ "} ifelse} loop ", div, PS.map_y, PS.map_x - margin, -width,
+ PS.map_right + margin, width);
fprintf(PS.fp,
"HGRm 0 XY HGRm 1 XY 1 index sub neg %d div exch {"
"1 index add dup %.2f lt {exit} {"
"dup %.2f M 0 %.2f LR dup %.2f M 0 %.2f LR S "
- "} ifelse} loop ", div, PS.map_x, PS.map_y - margin, -width, PS.map_top + margin, width);
+ "} ifelse} loop ", div, PS.map_x, PS.map_y - margin, -width,
+ PS.map_top + margin, width);
fprintf(PS.fp,
"/i HGRm length -- def HGRm i XY HGRm i -- XY 1 index sub neg %d div exch {"
"1 index add dup %.2f gt {exit} {"
"dup %.2f M 0 %.2f LR dup %.2f M 0 %.2f LR S "
- "} ifelse} loop\n", div, PS.map_right, PS.map_y - margin, -width, PS.map_top + margin, width);
+ "} ifelse} loop\n", div, PS.map_right, PS.map_y - margin,
+ -width, PS.map_top + margin, width);
}
}
@@ -409,17 +428,18 @@
"%.2f M %.2f 0 exch LR %.2f M %.2f 0 exch LRS} for\n",
PS.map_y - margin, -width, PS.map_top + margin, width);
- if (midline > 0)
- {
+ if (midline > 0) {
fprintf(PS.fp, "GS %.2f LW ", midline);
fprintf(PS.fp,
"1 2 VGRm length -- {/i XD VGRm i XY VGRm i -- XY 2 copy "
- "%.2f exch M cP pop exch LS %.2f exch M cP pop exch LS} for\n", PS.map_x - dist, PS.map_right + dist);
+ "%.2f exch M cP pop exch LS %.2f exch M cP pop exch LS} for\n",
+ PS.map_x - dist, PS.map_right + dist);
fprintf(PS.fp,
"1 2 HGRm length -- {/i XD HGRm i XY HGRm i -- XY 2 copy "
- "%.2f M cP exch pop LS %.2f M cP exch pop LS} for\n", PS.map_y - dist, PS.map_top + dist);
+ "%.2f M cP exch pop LS %.2f M cP exch pop LS} for\n",
+ PS.map_y - dist, PS.map_top + dist);
fprintf(PS.fp,
"VGRm length 2 mod 0 ne {VGRm dup length -- XY %.2f 2 copy "
@@ -428,7 +448,8 @@
fprintf(PS.fp,
"HGRm length 2 mod 0 ne {HGRm dup length -- XY %.2f 2 copy "
- "%.2f M cP exch pop LS %.2f M cP exch pop LS} if\n", PS.map_right, PS.map_y - dist, PS.map_top + dist);
+ "%.2f M cP exch pop LS %.2f M cP exch pop LS} if\n",
+ PS.map_right, PS.map_y - dist, PS.map_top + dist);
fprintf(PS.fp, "GR\n");
}
@@ -454,14 +475,18 @@
void set_grid_corners(double margin, double width)
{
fprintf(PS.fp, "%.2f cLW 2 div sub %.2f cLW 2 div sub M "
- "%.2f dup 0 LR neg 0 exch LRS ", PS.map_x - margin - width, PS.map_y - margin, width);
+ "%.2f dup 0 LR neg 0 exch LRS ", PS.map_x - margin - width,
+ PS.map_y - margin, width);
fprintf(PS.fp, "%.2f cLW 2 div sub %.2f cLW 2 div add M "
- "%.2f dup 0 LR 0 exch LRS ", PS.map_x - margin - width, PS.map_top + margin, width);
+ "%.2f dup 0 LR 0 exch LRS ", PS.map_x - margin - width,
+ PS.map_top + margin, width);
fprintf(PS.fp, "%.2f cLW 2 div add %.2f cLW 2 div sub M "
- "%.2f neg dup 0 LR 0 exch LRS ", PS.map_right + margin + width, PS.map_y - margin, width);
+ "%.2f neg dup 0 LR 0 exch LRS ", PS.map_right + margin + width,
+ PS.map_y - margin, width);
fprintf(PS.fp, "%.2f cLW 2 div add %.2f cLW 2 div add M "
- "%.2f dup neg 0 LR 0 exch LRS ", PS.map_right + margin + width, PS.map_top + margin, width);
+ "%.2f dup neg 0 LR 0 exch LRS ", PS.map_right + margin + width,
+ PS.map_top + margin, width);
}
Modified: grass-addons/postscript/ps.output/set_mask.c
===================================================================
--- grass-addons/postscript/ps.output/set_mask.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/set_mask.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -19,50 +19,46 @@
int set_mask(void)
{
int i, byte, row, col, br;
+
void *cbuf, *cptr;
+
RASTER_MAP_TYPE map_type;
static int bit[] = { 128, 64, 32, 16, 8, 4, 2, 1 };
- if (PS.rst.fd[1] < 0)
- { /* there is no mask */
+ if (PS.rst.fd[1] < 0) { /* there is no mask */
G_warning(_("Any raster mask to read, don't mask!"));
if (PS.need_mask)
PS.need_mask = 0;
return 0;
}
- fprintf(PS.fp, "currentfile /ASCIIHexDecode filter /ReusableStreamDecode filter\n");
+ fprintf(PS.fp,
+ "currentfile /ASCIIHexDecode filter /ReusableStreamDecode filter\n");
/* storing the bytes of the mask */
map_type = G_get_raster_map_type(PS.rst.fd[1]);
cbuf = G_allocate_raster_buf(map_type);
- for (br = 0, row = 0; row < PS.map.rows; row++)
- {
+ for (br = 0, row = 0; row < PS.map.rows; row++) {
G_get_raster_row(PS.rst.fd[1], cbuf, row, map_type);
cptr = cbuf;
i = byte = 0;
- for (col = 0; col < PS.map.cols; col++)
- {
- if (G_is_null_value(cptr, map_type))
- {
+ for (col = 0; col < PS.map.cols; col++) {
+ if (G_is_null_value(cptr, map_type)) {
byte |= bit[i];
}
++i;
- if (i == 8)
- {
+ if (i == 8) {
fprintf(PS.fp, "%02x", byte);
i = byte = 0;
}
- if (br++ == 45)
- {
+ if (br++ == 45) {
br = 0;
fprintf(PS.fp, "\n");
}
cptr = G_incr_void_ptr(cptr, G_raster_size(map_type));
}
- if (i)
- {
+ if (i) {
while (i < 8)
byte |= bit[i++];
fprintf(PS.fp, "%02x", byte);
@@ -79,7 +75,8 @@
fprintf(PS.fp, " /BitsPerComponent 1\n");
/* fprintf(PS.fp, " /Interpolate true\n"); */
fprintf(PS.fp, " /Decode [1 0]\n");
- fprintf(PS.fp, " /ImageMatrix [%d 0 0 %d 0 %d]\n", PS.map.cols, -PS.map.rows, PS.map.rows);
+ fprintf(PS.fp, " /ImageMatrix [%d 0 0 %d 0 %d]\n", PS.map.cols,
+ -PS.map.rows, PS.map.rows);
fprintf(PS.fp, " /DataSource maskstream\n");
fprintf(PS.fp, ">> store\n");
@@ -87,7 +84,8 @@
fprintf(PS.fp, "maskstream resetfile\n");
fprintf(PS.fp, "mapstream resetfile\n");
fprintf(PS.fp, "gsave\n");
- fprintf(PS.fp, " /Device%s setcolorspace\n", PS.rst.do_grey ? "Gray" : "RGB");
+ fprintf(PS.fp, " /Device%s setcolorspace\n",
+ PS.rst.do_grey ? "Gray" : "RGB");
fprintf(PS.fp, " %.2f %.2f translate\n", PS.map_x, PS.map_y);
fprintf(PS.fp, " %.1f %.1f scale\n", PS.map_w, PS.map_h);
fprintf(PS.fp, " << /ImageType 3\n");
Modified: grass-addons/postscript/ps.output/set_note.c
===================================================================
--- grass-addons/postscript/ps.output/set_note.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/set_note.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -21,20 +21,20 @@
int set_note(int i)
{
int rows, type;
+
double x, y, dy, fontsize;
+
char *chr, *str, txt[1024];
rows = 0; /* useful to decide if write it */
fontsize = set_ps_font(&(PS.note[i].font));
- if (strncmp(PS.note[i].text, ":file", 5) == 0)
- {
+ if (strncmp(PS.note[i].text, ":file", 5) == 0) {
str = PS.note[i].text + 6;
rows = note_in_file(str);
type = -1;
}
- else if (strncmp(PS.note[i].text, ":maplim", 7) == 0)
- {
+ else if (strncmp(PS.note[i].text, ":maplim", 7) == 0) {
char label[50];
/* get north, south, east and west strings */
@@ -51,29 +51,27 @@
rows = 4;
type = 0;
}
- else if (strncmp(PS.note[i].text, ":dimen", 6) == 0)
- {
+ else if (strncmp(PS.note[i].text, ":dimen", 6) == 0) {
fprintf(PS.fp, "/ARo [\n");
fprintf(PS.fp, "(Map Area)");
- fprintf(PS.fp, "(Position: %.1f mm x %.1f mm)\n", POINT_TO_MM * PS.map_x, POINT_TO_MM * PS.map_y);
- fprintf(PS.fp, "(Dimension: %.1f mm x %.1f mm)\n", POINT_TO_MM * PS.map_w, POINT_TO_MM * PS.map_h);
+ fprintf(PS.fp, "(Position: %.1f mm x %.1f mm)\n",
+ POINT_TO_MM * PS.map_x, POINT_TO_MM * PS.map_y);
+ fprintf(PS.fp, "(Dimension: %.1f mm x %.1f mm)\n",
+ POINT_TO_MM * PS.map_w, POINT_TO_MM * PS.map_h);
fprintf(PS.fp, "] def\n");
rows = 3;
type = 1;
}
- else if (strncmp(PS.note[i].text, ":scale", 6) == 0)
- {
+ else if (strncmp(PS.note[i].text, ":scale", 6) == 0) {
str = PS.note[i].text + 7;
fprintf(PS.fp, "/ARo [(%s 1 : %d)] def\n", str, PS.scale);
rows = 1;
type = 2;
}
- else
- { /* free line of text with "|" to cut lines */
+ else { /* free line of text with "|" to cut lines */
fprintf(PS.fp, "/ARo [\n");
chr = str = PS.note[i].text;
- while (*chr)
- {
+ while (*chr) {
while (*str && *str != '|')
str++;
*str++ = '\0';
@@ -85,24 +83,23 @@
type = 4;
}
- if (rows > 0)
- {
+ if (rows > 0) {
/* Define ARw */
- if (PS.note[i].width > 0.)
- {
- x = PS.note[i].box.margin;
- if (x < 0.)
- x = 0.4 * PS.note[i].font.size;
+ if (PS.note[i].width > 0.) {
+ x = PS.note[i].box.margin;
+ if (x < 0.)
+ x = 0.4 * PS.note[i].font.size;
- fprintf(PS.fp, "/ARw [%.3f] def\n", PS.note[i].width - 2 * x);
- }
+ fprintf(PS.fp, "/ARw [%.3f] def\n", PS.note[i].width - 2 * x);
+ }
else
- fprintf(PS.fp, "/ARw [ARo SWx] def\n");
- //fprintf(PS.fp, "/ARw 1 array def ARw 0 ARo SWx put\n");
+ fprintf(PS.fp, "/ARw [ARo SWx] def\n");
+ //fprintf(PS.fp, "/ARw 1 array def ARw 0 ARo SWx put\n");
/* Define ARh: todas de igual altura */
fprintf(PS.fp, "/ARh ARo length array def ");
- fprintf(PS.fp, "0 1 ARo length -- {ARh exch %.2f put} for\n", fontsize);
+ fprintf(PS.fp, "0 1 ARo length -- {ARh exch %.2f put} for\n",
+ fontsize);
/* Make de frame */
set_box_orig(&(PS.note[i].box));
@@ -113,19 +110,23 @@
/* Draw the content */
fprintf(PS.fp, "RESET ");
- fprintf(PS.fp, "0 1 ARo length 1 sub {dup ROW ARo exch get x y ARh row get sub M ");
- switch (type)
- {
+ fprintf(PS.fp,
+ "0 1 ARo length 1 sub {dup ROW ARo exch get x y ARh row get sub M ");
+ switch (type) {
case 0:
- fprintf(PS.fp, "GS dup SW ARw 0 get exch sub 0 32 4 -1 roll widthshow GR");
+ fprintf(PS.fp,
+ "GS dup SW ARw 0 get exch sub 0 32 4 -1 roll widthshow GR");
break;
case 2:
- fprintf(PS.fp, "GS dup SWH exch pop 0 MR %.2f ROT show GR", PS.note[i].angle);
+ fprintf(PS.fp, "GS dup SWH exch pop 0 MR %.2f ROT show GR",
+ PS.note[i].angle);
break;
default:
- fprintf(PS.fp, "(.) anchorsearch {GS pop %.3f 2 div 0 MR SHC GR} {SHL} ifelse", PS.note[i].width);
+ fprintf(PS.fp,
+ "(.) anchorsearch {GS pop %.3f 2 div 0 MR SHC GR} {SHL} ifelse",
+ PS.note[i].width);
break;
}
fprintf(PS.fp, "} for\n");
@@ -137,21 +138,20 @@
int note_in_file(char *name)
{
FILE *in = NULL;
+
char buf[1024];
+
int r = 0;
- if (*name)
- {
+ if (*name) {
in = fopen(name, "r");
- if (in == NULL)
- {
+ if (in == NULL) {
G_message(_("Comment file <%s> can't open"), name);
return 0;
}
}
fprintf(PS.fp, "/ARo [\n");
- while (fgets(buf, sizeof(buf), in))
- { /* TODO don't read end-of-line */
+ while (fgets(buf, sizeof(buf), in)) { /* TODO don't read end-of-line */
fprintf(PS.fp, "(%s)\n", buf);
++r;
}
Modified: grass-addons/postscript/ps.output/set_outline.c
===================================================================
--- grass-addons/postscript/ps.output/set_outline.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/set_outline.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -18,12 +18,16 @@
int set_outline(void)
{
int row, col;
+
double nrow, n_rw, erow, e_rw;
+
void *rbuf, *nbuf, *rptr, *nptr, *next;
+
RASTER_MAP_TYPE map_type;
/* let user know what's happenning */
- G_message(_("Reading raster map <%s in %s> ..."), PS.rst.name[0], PS.rst.mapset[0]);
+ G_message(_("Reading raster map <%s in %s> ..."), PS.rst.name[0],
+ PS.rst.mapset[0]);
/* set the outline color and width */
set_ps_line(&(PS.rst.outline));
@@ -34,8 +38,7 @@
map_type = G_get_raster_map_type(PS.rst.fd[0]);
rbuf = G_allocate_raster_buf(map_type);
nbuf = G_allocate_raster_buf(map_type);
- for (row = 0; row < PS.map.rows - 1; row++)
- {
+ for (row = 0; row < PS.map.rows - 1; row++) {
nrow = G_row_to_northing((double)row, &(PS.map));
n_rw = G_row_to_northing((double)row + 1, &(PS.map));
/* load buffers */
@@ -44,21 +47,18 @@
/* set pointers */
rptr = rbuf;
nptr = nbuf;
- for (col = 0; col < PS.map.cols - 1; col++)
- {
+ for (col = 0; col < PS.map.cols - 1; col++) {
erow = G_col_to_easting((double)col + 1, &(PS.map));
e_rw = G_col_to_easting((double)col, &(PS.map));
/* check right outline */
next = G_incr_void_ptr(rptr, G_raster_size(map_type));
- if (G_raster_cmp(rptr, next, map_type) != 0)
- {
+ if (G_raster_cmp(rptr, next, map_type) != 0) {
set_ps_where('M', erow, nrow);
set_ps_where('L', erow, n_rw);
fprintf(PS.fp, "S\n");
}
/* check bottom outline */
- if (G_raster_cmp(rptr, nptr, map_type) != 0)
- {
+ if (G_raster_cmp(rptr, nptr, map_type) != 0) {
set_ps_where('M', e_rw, n_rw);
set_ps_where('L', erow, n_rw);
fprintf(PS.fp, "S\n");
Modified: grass-addons/postscript/ps.output/set_ps.c
===================================================================
--- grass-addons/postscript/ps.output/set_ps.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/set_ps.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -24,14 +24,16 @@
void set_ps_brd(double margin)
{
fprintf(PS.fp, "%.3f %.3f %.3f %.3f RO\n",
- PS.map_x - margin, PS.map_y - margin, PS.map_w + 2. * margin, PS.map_h + 2. * margin);
+ PS.map_x - margin, PS.map_y - margin, PS.map_w + 2. * margin,
+ PS.map_h + 2. * margin);
return;
}
void set_ps_brd2(double lwidth, double margin)
{
fprintf(PS.fp, "%.3f LW %.3f %.3f %.3f %.3f RO\n",
- lwidth, PS.map_x - margin, PS.map_y - margin, PS.map_w + 2. * margin, PS.map_h + 2. * margin);
+ lwidth, PS.map_x - margin, PS.map_y - margin,
+ PS.map_w + 2. * margin, PS.map_h + 2. * margin);
return;
}
@@ -40,6 +42,7 @@
int set_ps_where(char action, double east, double north)
{
int x, y;
+
double dx, dy;
G_plot_where_xy(east, north, &x, &y);
@@ -57,6 +60,7 @@
int set_xy_where(char *pre, double east, double north, char *post)
{
int x, y;
+
double dx, dy;
G_plot_where_xy(east, north, &x, &y);
@@ -71,6 +75,7 @@
int is_xy_outside(double east, double north)
{
int x, y;
+
double dx, dy;
G_plot_where_xy(east, north, &x, &y);
@@ -78,7 +83,8 @@
dx = ((double)x) / 10.;
dy = ((double)y) / 10.;
- if (dx < PS.map_x || dx > PS.map_right || dy < PS.map_y || dy > PS.map_top)
+ if (dx < PS.map_x || dx > PS.map_right || dy < PS.map_y ||
+ dy > PS.map_top)
return 1;
return 0;
@@ -90,24 +96,26 @@
int set_ps_pattern(int code, char *eps, VAREAS * va)
{
FILE *fp;
+
char buf[1024];
+
int ret = 0;
+
double llx, lly, urx, ury;
- if ((fp = fopen(eps, "r")) == NULL)
- {
+ if ((fp = fopen(eps, "r")) == NULL) {
G_message("File <%s> not found!\n", eps);
return 0;
}
/* find the bounding box in EPS */
llx = lly = urx = ury = 0.;
- while (fgets(buf, 128, fp) != NULL && ret != 4)
- {
- ret = sscanf(buf, "%%%%BoundingBox: %lf %lf %lf %lf", &llx, &lly, &urx, &ury);
+ while (fgets(buf, 128, fp) != NULL && ret != 4) {
+ ret =
+ sscanf(buf, "%%%%BoundingBox: %lf %lf %lf %lf", &llx, &lly, &urx,
+ &ury);
}
- if (llx == 0. && lly == 0. && urx == 0. && ury == 0.)
- {
+ if (llx == 0. && lly == 0. && urx == 0. && ury == 0.) {
fclose(fp);
error(eps, "", "ERROR: Bounding box in <%s> was not found");
}
@@ -118,14 +126,15 @@
ury *= va->sc_pat;
fprintf(PS.fp, "/PATTERN%d\n", code);
- fprintf(PS.fp, "<< /PatternType 1\n /PaintType %d\n /TilingType 1\n", va->type_pat);
+ fprintf(PS.fp, "<< /PatternType 1\n /PaintType %d\n /TilingType 1\n",
+ va->type_pat);
fprintf(PS.fp, " /BBox [%.4f %.3f %.4f %.4f]\n", llx, lly, urx, ury);
- fprintf(PS.fp, " /XStep %.4f\n /YStep %.4f\n", (urx - llx), (ury - lly));
+ fprintf(PS.fp, " /XStep %.4f\n /YStep %.4f\n", (urx - llx),
+ (ury - lly));
fprintf(PS.fp, " /PaintProc\n");
fprintf(PS.fp, " { begin\n");
fprintf(PS.fp, " %.4f dup scale\n", va->sc_pat);
- if (va->type_pat == 1)
- {
+ if (va->type_pat == 1) {
fprintf(PS.fp, " ");
set_ps_color(&(va->fcolor));
fprintf(PS.fp, "\n");
@@ -146,18 +155,18 @@
int set_ps_symbol_eps(int code, char *eps)
{
FILE *fp;
+
char buf[1024];
- if ((fp = fopen(eps, "r")) == NULL)
- {
+ if ((fp = fopen(eps, "r")) == NULL) {
G_message("File <%s> not found!\n", eps);
return 0;
}
fprintf(PS.fp, "/SYMBOL%d {\n", code);
- while (fgets(buf, 1024, fp) != NULL)
- {
- if (strncmp(buf, "%!PS-Adobe", 10) == 0 || strncmp(buf, "%%BoundingBox", 13) == 0)
+ while (fgets(buf, 1024, fp) != NULL) {
+ if (strncmp(buf, "%!PS-Adobe", 10) == 0 ||
+ strncmp(buf, "%%BoundingBox", 13) == 0)
continue;
fprintf(PS.fp, " %s", buf);
}
Modified: grass-addons/postscript/ps.output/set_raster.c
===================================================================
--- grass-addons/postscript/ps.output/set_raster.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/set_raster.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -28,15 +28,15 @@
int i;
/* starting */
- if (PS.need_mask && PS.rst.do_mask)
- {
- fprintf(PS.fp, "currentfile /ASCIIHexDecode filter /ReusableStreamDecode filter\n");
+ if (PS.need_mask && PS.rst.do_mask) {
+ fprintf(PS.fp,
+ "currentfile /ASCIIHexDecode filter /ReusableStreamDecode filter\n");
}
- else
- {
+ else {
fprintf(PS.fp, "GS\n");
/* Map Dictionary when no mask needed, no reusable stream */
- fprintf(PS.fp, "/Device%s setcolorspace\n", PS.rst.do_grey ? "Gray" : "RGB");
+ fprintf(PS.fp, "/Device%s setcolorspace\n",
+ PS.rst.do_grey ? "Gray" : "RGB");
fprintf(PS.fp, "%.2f %.2f translate\n", PS.map_x, PS.map_y);
fprintf(PS.fp, "%.1f %.1f scale\n", PS.map_w, PS.map_h);
fprintf(PS.fp, "<< /ImageType 1\n");
@@ -44,31 +44,29 @@
fprintf(PS.fp, " /Height %d\n", PS.map.rows);
fprintf(PS.fp, " /BitsPerComponent 8\n");
/* fprintf(PS.fp, " /Interpolate true\n"); */
- fprintf(PS.fp, " /Decode [%s]\n", PS.rst.do_grey ? "0 1" : "0 1 0 1 0 1");
- fprintf(PS.fp, " /ImageMatrix [%d 0 0 %d 0 %d]\n", PS.map.cols, -PS.map.rows, PS.map.rows);
+ fprintf(PS.fp, " /Decode [%s]\n",
+ PS.rst.do_grey ? "0 1" : "0 1 0 1 0 1");
+ fprintf(PS.fp, " /ImageMatrix [%d 0 0 %d 0 %d]\n", PS.map.cols,
+ -PS.map.rows, PS.map.rows);
fprintf(PS.fp, " /DataSource currentfile /ASCIIHexDecode filter\n");
fprintf(PS.fp, ">> ");
fprintf(PS.fp, "image\n");
}
/* split loading stream for some better speed */
- if (PS.rst.do_rgb)
- {
+ if (PS.rst.do_rgb) {
set_raster_rgb();
}
- else if (PS.rst.do_mask)
- {
+ else if (PS.rst.do_mask) {
if (PS.rst.fd[2] < 0)
set_raster_maskcolor();
else
set_raster_maskcell();
}
- else
- {
+ else {
set_raster_cell();
}
/* ending */
- if (PS.need_mask && PS.rst.do_mask)
- {
+ if (PS.need_mask && PS.rst.do_mask) {
fprintf(PS.fp, "\n> ");
fprintf(PS.fp, "/mapstream exch def\n");
/* Map Dictionary when mask needed, reusable stream */
@@ -78,19 +76,21 @@
fprintf(PS.fp, " /Height %d\n", PS.map.rows);
fprintf(PS.fp, " /BitsPerComponent 8\n");
/* fprintf(PS.fp, " /Interpolate true\n"); */
- fprintf(PS.fp, " /Decode [%s]\n", PS.rst.do_grey ? "0 1" : "0 1 0 1 0 1");
- fprintf(PS.fp, " /ImageMatrix [%d 0 0 %d 0 %d]\n", PS.map.cols, -PS.map.rows, PS.map.rows);
+ fprintf(PS.fp, " /Decode [%s]\n",
+ PS.rst.do_grey ? "0 1" : "0 1 0 1 0 1");
+ fprintf(PS.fp, " /ImageMatrix [%d 0 0 %d 0 %d]\n", PS.map.cols,
+ -PS.map.rows, PS.map.rows);
fprintf(PS.fp, " /DataSource mapstream\n");
fprintf(PS.fp, ">> store\n");
fprintf(PS.fp, "gsave\n");
- fprintf(PS.fp, " /Device%s setcolorspace\n", PS.rst.do_grey ? "Gray" : "RGB");
+ fprintf(PS.fp, " /Device%s setcolorspace\n",
+ PS.rst.do_grey ? "Gray" : "RGB");
fprintf(PS.fp, " %.2f %.2f translate\n", PS.map_x, PS.map_y);
fprintf(PS.fp, " %.1f %.1f scale\n", PS.map_w, PS.map_h);
fprintf(PS.fp, " mapstream resetfile\n");
fprintf(PS.fp, " MapDictionary image\n");
}
- else
- {
+ else {
fprintf(PS.fp, ">\n");
}
fprintf(PS.fp, "GR\n");
@@ -102,36 +102,35 @@
int set_raster_cell(void)
{
int row, col, br, R, G, B;
+
void *cbuf, *cptr;
+
RASTER_MAP_TYPE map_type;
/* let user know what's happenning */
- G_message(_("Reading raster map <%s in %s> ..."), PS.rst.name[0], PS.rst.mapset[0]);
+ G_message(_("Reading raster map <%s in %s> ..."), PS.rst.name[0],
+ PS.rst.mapset[0]);
/* storing the bytes of the image */
map_type = G_get_raster_map_type(PS.rst.fd[0]);
cbuf = G_allocate_raster_buf(map_type);
- for (br = 0, row = 0; row < PS.map.rows; row++)
- {
+ for (br = 0, row = 0; row < PS.map.rows; row++) {
G_get_raster_row(PS.rst.fd[0], cbuf, row, map_type);
cptr = cbuf;
- for (col = 0; col < PS.map.cols; col++)
- {
+ for (col = 0; col < PS.map.cols; col++) {
/* get the map colors */
- G_get_raster_color(cptr, &R, &G, &B, &(PS.rst.colors[0]), map_type);
+ G_get_raster_color(cptr, &R, &G, &B, &(PS.rst.colors[0]),
+ map_type);
cptr = G_incr_void_ptr(cptr, G_raster_size(map_type));
/* processing data to the postscript file */
- if (PS.rst.do_grey)
- {
+ if (PS.rst.do_grey) {
fprintf(PS.fp, "%02X", (int)NTSC(R, G, B));
}
- else
- {
+ else {
fprintf(PS.fp, "%02X%02X%02X", R, G, B);
}
- if (br++ == 15)
- {
+ if (br++ == 15) {
br = 0;
fprintf(PS.fp, "\n");
}
@@ -146,8 +145,11 @@
int set_raster_rgb(void)
{
int i, row, col, br;
+
int R[3], G[3], B[3];
+
void *cbuf[3], *cptr[3];
+
RASTER_MAP_TYPE map_type[3];
@@ -155,35 +157,31 @@
G_message(_("Reading raster maps in group <%s> ..."), PS.rst.title);
/* storing the bytes of the image */
- for (i = 0; i < 3; i++)
- {
+ for (i = 0; i < 3; i++) {
map_type[i] = G_get_raster_map_type(PS.rst.fd[i]);
cbuf[i] = G_allocate_raster_buf(map_type[i]);
}
- for (br = 0, row = 0; row < PS.map.rows; row++)
- {
- for (i = 0; i < 3; i++)
- {
+ for (br = 0, row = 0; row < PS.map.rows; row++) {
+ for (i = 0; i < 3; i++) {
G_get_raster_row(PS.rst.fd[i], cbuf[i], row, map_type[i]);
cptr[i] = cbuf[i];
}
- for (col = 0; col < PS.map.cols; col++)
- {
+ for (col = 0; col < PS.map.cols; col++) {
/* get the map colors */
- G_get_raster_color(cptr[0], &(R[0]), &(G[0]), &(B[0]), &(PS.rst.colors[0]), map_type[0]);
- G_get_raster_color(cptr[1], &(R[1]), &(G[1]), &(B[1]), &(PS.rst.colors[1]), map_type[1]);
- G_get_raster_color(cptr[2], &(R[2]), &(G[2]), &(B[2]), &(PS.rst.colors[2]), map_type[2]);
+ G_get_raster_color(cptr[0], &(R[0]), &(G[0]), &(B[0]),
+ &(PS.rst.colors[0]), map_type[0]);
+ G_get_raster_color(cptr[1], &(R[1]), &(G[1]), &(B[1]),
+ &(PS.rst.colors[1]), map_type[1]);
+ G_get_raster_color(cptr[2], &(R[2]), &(G[2]), &(B[2]),
+ &(PS.rst.colors[2]), map_type[2]);
/* processing data to the postscript file */
- if (PS.rst.do_grey)
- {
+ if (PS.rst.do_grey) {
fprintf(PS.fp, "%02X", (int)NTSC(R[0], G[1], B[2]));
}
- else
- {
+ else {
fprintf(PS.fp, "%02X%02X%02X", R[0], G[1], B[2]);
}
- if (br++ == 15)
- {
+ if (br++ == 15) {
br = 0;
fprintf(PS.fp, "\n");
}
@@ -193,8 +191,7 @@
cptr[2] = G_incr_void_ptr(cptr[2], G_raster_size(map_type[2]));
}
}
- for (i = 0; i < 3; i++)
- {
+ for (i = 0; i < 3; i++) {
G_free(cbuf[i]);
G_close_cell(PS.rst.fd[i]);
G_free_colors(&(PS.rst.colors[i]));
@@ -209,9 +206,13 @@
int set_raster_maskcell(void)
{
int i, row, col, br;
+
int r, g, b, R[3], G[3], B[3];
+
double f, red, green, blue;
+
void *cbuf[3], *cptr[3];
+
RASTER_MAP_TYPE map_type[3];
red = (1. - PS.rst.mask_color.r);
@@ -222,63 +223,57 @@
B[1] = (int)(255. * PS.rst.mask_color.b);
/* let user know what's happenning */
- G_message(_("Reading raster map <%s in %s> ... %d rows"), PS.rst.name[0], PS.rst.mapset[0], PS.map.rows);
- G_message(_("... mask raster <%s in %s>"), PS.rst.name[1], PS.rst.mapset[1]);
- G_message(_("... background raster <%s in %s>"), PS.rst.name[2], PS.rst.mapset[2]);
+ G_message(_("Reading raster map <%s in %s> ... %d rows"), PS.rst.name[0],
+ PS.rst.mapset[0], PS.map.rows);
+ G_message(_("... mask raster <%s in %s>"), PS.rst.name[1],
+ PS.rst.mapset[1]);
+ G_message(_("... background raster <%s in %s>"), PS.rst.name[2],
+ PS.rst.mapset[2]);
/* storing the bytes of the image */
- for (i = 0; i < 3; i++)
- {
+ for (i = 0; i < 3; i++) {
map_type[i] = G_get_raster_map_type(PS.rst.fd[i]);
cbuf[i] = G_allocate_raster_buf(map_type[i]);
}
- for (br = 0, row = 0; row < PS.map.rows; row++)
- {
- for (i = 0; i < 3; i++)
- {
+ for (br = 0, row = 0; row < PS.map.rows; row++) {
+ for (i = 0; i < 3; i++) {
/* G_get_raster_row(PS.rst.fd[i], cbuf[i], row, map_type[i]); */
G_get_raster_row_nomask(PS.rst.fd[i], cbuf[i], row, map_type[i]);
cptr[i] = cbuf[i];
}
- for (col = 0; col < PS.map.cols; col++)
- {
+ for (col = 0; col < PS.map.cols; col++) {
/* get the map colors */
- G_get_raster_color(cptr[0], &(R[0]), &(G[0]), &(B[0]), &(PS.rst.colors[0]), map_type[0]);
- G_get_raster_color(cptr[2], &(R[2]), &(G[2]), &(B[2]), &(PS.rst.colors[2]), map_type[2]);
+ G_get_raster_color(cptr[0], &(R[0]), &(G[0]), &(B[0]),
+ &(PS.rst.colors[0]), map_type[0]);
+ G_get_raster_color(cptr[2], &(R[2]), &(G[2]), &(B[2]),
+ &(PS.rst.colors[2]), map_type[2]);
/* select color by mask */
- if (G_is_null_value(cptr[1], map_type[1]))
- {
- if (PS.rst.mask_color.none)
- {
+ if (G_is_null_value(cptr[1], map_type[1])) {
+ if (PS.rst.mask_color.none) {
r = R[2];
g = G[2];
b = B[2];
}
- else
- {
+ else {
f = (double)GREY(R[2], G[2], B[2]);
r = (int)(f * red + (double)R[1]);
g = (int)(f * green + (double)G[1]);
b = (int)(f * blue + (double)B[1]);
}
}
- else
- {
+ else {
r = R[0];
g = G[0];
b = B[0];
}
/* processing data to the postscript file */
- if (PS.rst.do_grey)
- {
+ if (PS.rst.do_grey) {
fprintf(PS.fp, "%02X", (int)NTSC(r, g, b));
}
- else
- {
+ else {
fprintf(PS.fp, "%02X%02X%02X", r, g, b);
}
- if (br++ == 15)
- {
+ if (br++ == 15) {
fprintf(PS.fp, "\n");
br = 0;
}
@@ -300,60 +295,56 @@
int set_raster_maskcolor(void)
{
int i, row, col, br;
+
int color, r, g, b, R, G, B;
+
void *cbuf[2], *cptr[2];
+
RASTER_MAP_TYPE map_type[2];
- if (PS.rst.mask_color.none)
- {
+ if (PS.rst.mask_color.none) {
r = g = b = 255.;
}
- else
- {
+ else {
r = (int)(255. * PS.rst.mask_color.r);
g = (int)(255. * PS.rst.mask_color.g);
b = (int)(255. * PS.rst.mask_color.b);
}
/* let user know what's happenning */
- G_message(_("Reading raster map <%s in %s> ... %d rows"), PS.rst.name[0], PS.rst.mapset[0], PS.map.rows);
- G_message(_("... raster to mask <%s in %s>"), PS.rst.name[1], PS.rst.mapset[1]);
+ G_message(_("Reading raster map <%s in %s> ... %d rows"), PS.rst.name[0],
+ PS.rst.mapset[0], PS.map.rows);
+ G_message(_("... raster to mask <%s in %s>"), PS.rst.name[1],
+ PS.rst.mapset[1]);
/* storing the bytes of the image */
- for (i = 0; i < 2; i++)
- {
+ for (i = 0; i < 2; i++) {
map_type[i] = G_get_raster_map_type(PS.rst.fd[i]);
cbuf[i] = G_allocate_raster_buf(map_type[i]);
}
- for (br = 0, row = 0; row < PS.map.rows; row++)
- {
- for (i = 0; i < 2; i++)
- {
+ for (br = 0, row = 0; row < PS.map.rows; row++) {
+ for (i = 0; i < 2; i++) {
G_get_raster_row(PS.rst.fd[i], cbuf[i], row, map_type[i]);
cptr[i] = cbuf[i];
}
- for (col = 0; col < PS.map.cols; col++)
- {
+ for (col = 0; col < PS.map.cols; col++) {
/* get the map colors */
- G_get_raster_color(cptr[0], &R, &G, &B, &(PS.rst.colors[0]), map_type[0]);
+ G_get_raster_color(cptr[0], &R, &G, &B, &(PS.rst.colors[0]),
+ map_type[0]);
/* select color by mask */
- if (G_is_null_value(cptr[1], map_type[1]))
- {
+ if (G_is_null_value(cptr[1], map_type[1])) {
R = r;
G = g;
B = b;
}
/* processing data to the postscript file */
- if (PS.rst.do_grey)
- {
+ if (PS.rst.do_grey) {
fprintf(PS.fp, "%02X", (int)NTSC(R, G, B));
}
- else
- {
+ else {
fprintf(PS.fp, "%02X%02X%02X", R, G, B);
}
- if (br++ == 15)
- {
+ if (br++ == 15) {
br = 0;
fprintf(PS.fp, "\n");
}
Modified: grass-addons/postscript/ps.output/set_rlegend.c
===================================================================
--- grass-addons/postscript/ps.output/set_rlegend.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/set_rlegend.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -20,29 +20,32 @@
int set_rlegend_cats(void)
{
int i, j, k, n, R, G, B;
+
char *label;
+
int num_cats, rows, cols;
+
double fontsize, fwidth;
+
DCELL dmin, dmax, val;
/* Let user know what's happenning */
- G_message(_("Raster legend with category <%s in %s>..."), PS.rl.name, PS.rl.mapset);
+ G_message(_("Raster legend with category <%s in %s>..."), PS.rl.name,
+ PS.rl.mapset);
/* Load the categories */
- if (G_read_raster_cats(PS.rl.name, PS.rl.mapset, &(PS.rst.cats)) != 0)
- {
+ if (G_read_raster_cats(PS.rl.name, PS.rl.mapset, &(PS.rst.cats)) != 0) {
G_warning(_("Category file for <%s> not available"), PS.rl.name);
return 1;
}
/* Reload colors if raster in rlegend is not the same as raster command.
If the same, don't touch to not overwrite setcolor command */
- if (strcmp(PS.rl.name, PS.rst.name[0]) != 0)
- {
+ if (strcmp(PS.rl.name, PS.rst.name[0]) != 0) {
G_warning("Using color table of %s in %s", PS.rl.name, PS.rl.mapset);
- if (G_read_colors(PS.rl.name, PS.rl.mapset, &PS.rst.colors[0]) == -1)
- {
- G_warning("Can't load color table of %s in %s", PS.rl.name, PS.rl.mapset);
+ if (G_read_colors(PS.rl.name, PS.rl.mapset, &PS.rst.colors[0]) == -1) {
+ G_warning("Can't load color table of %s in %s", PS.rl.name,
+ PS.rl.mapset);
return 1;
}
PS.rst.do_grey = 0; /* Null grey because is not the same map as raster */
@@ -51,8 +54,7 @@
/* Sort categories by user (min value) */
CELL *ip = (CELL *) G_malloc(sizeof(CELL) * PS.rst.cats.ncats);
- for (i = 0; i < PS.rst.cats.ncats; i++)
- {
+ for (i = 0; i < PS.rst.cats.ncats; i++) {
G_get_ith_d_raster_cat(&(PS.rst.cats), i, &dmin, &dmax);
ip[i] = (CELL) dmin;
}
@@ -61,28 +63,25 @@
/* How many categories to show */
G_debug(3, "colortable: %d categories", num_cats);
num_cats = PS.rst.cats.ncats;
- if (num_cats <= 0)
- {
+ if (num_cats <= 0) {
G_warning(_("Your cats/ file is invalid. A cats/ file with "
"categories and labels is required for 'colortable' when using "
- "CELL rasters. No colortable will be assigned to this output " "postscript file."));
+ "CELL rasters. No colortable will be assigned to this output "
+ "postscript file."));
return 1;
}
- else if (num_cats > 100)
- {
+ else if (num_cats > 100) {
G_warning(_("Your cats/ file has %d cats (limit to 100)!"), num_cats);
}
if (PS.rl.do_nodata)
++num_cats; /* slot for no_data */
/* define number of rows */
- if (num_cats < PS.rl.legend.cols)
- {
+ if (num_cats < PS.rl.legend.cols) {
PS.rl.legend.cols = num_cats;
rows = 1;
}
- else
- {
+ else {
rows = (int)num_cats / PS.rl.legend.cols;
if (num_cats % PS.rl.legend.cols)
++rows;
@@ -101,45 +100,44 @@
fprintf(PS.fp, "/ARw %d array def\n", cols);
i = PS.rl.do_nodata ? 0 : 1;
- for (n = 0; n < cols; n++)
- {
+ for (n = 0; n < cols; n++) {
fprintf(PS.fp, "/AR%d [\n", n);
- for (j = 0; j < rows && i < num_cats; j++, i++)
- {
+ for (j = 0; j < rows && i < num_cats; j++, i++) {
/* labels */
- if (i == 0)
- {
+ if (i == 0) {
fprintf(PS.fp, "(%s) ", "no data");
G_get_null_value_color(&R, &G, &B, &(PS.rst.colors[0]));
dmin = dmax = 0.;
}
- else
- {
- label = G_get_ith_d_raster_cat(&(PS.rst.cats), ip[i - 1], &dmin, &dmax);
+ else {
+ label =
+ G_get_ith_d_raster_cat(&(PS.rst.cats), ip[i - 1], &dmin,
+ &dmax);
fprintf(PS.fp, "(%s) ", label);
}
/* colors */
fprintf(PS.fp, "[");
- if (dmin == dmax)
- {
+ if (dmin == dmax) {
G_get_d_raster_color(&dmin, &R, &G, &B, &(PS.rst.colors[0]));
- fprintf(PS.fp, "%.3f %.3f %.3f", R / 255., G / 255., B / 255.);
+ fprintf(PS.fp, "%.3f %.3f %.3f", R / 255., G / 255.,
+ B / 255.);
}
- else
- {
- for (k = 0; k < 5; k++)
- {
+ else {
+ for (k = 0; k < 5; k++) {
val = dmin + (double)k *(dmax - dmin) / 5;
- G_get_d_raster_color(&val, &R, &G, &B, &(PS.rst.colors[0]));
- fprintf(PS.fp, "%.3f %.3f %.3f ", R / 255., G / 255., B / 255.);
+ G_get_d_raster_color(&val, &R, &G, &B,
+ &(PS.rst.colors[0]));
+ fprintf(PS.fp, "%.3f %.3f %.3f ", R / 255., G / 255.,
+ B / 255.);
}
}
fprintf(PS.fp, "]\n");
}
fprintf(PS.fp, "] def\n");
fprintf(PS.fp, "/mx 0 def 0 2 AR%d length -- {", n);
- fprintf(PS.fp, "AR%d exch get SW /t XD t mx gt {/mx t def} if} for\n", n);
+ fprintf(PS.fp, "AR%d exch get SW /t XD t mx gt {/mx t def} if} for\n",
+ n);
fprintf(PS.fp, "ARw %d mx put\n", n);
}
@@ -159,23 +157,26 @@
fprintf(PS.fp, "/xw syw %.2f mul def ", 0.8); /* symbol-width */
fprintf(PS.fp, "/yh %.2f def ", -fontsize); /* symbol-height */
fprintf(PS.fp, "/t yh %d div def\n", 5); /* gradient symbol-height, if any */
- for (n = 0; n < cols; n++)
- {
+ for (n = 0; n < cols; n++) {
fprintf(PS.fp, "%d COL 0 ROW\n", n);
fprintf(PS.fp, "0 2 AR%d length -- {/i XD\n", n);
fprintf(PS.fp, "x y -- xw yh\nAR%d i ++ get aload length 3 eq ", n);
fprintf(PS.fp, "{%s 4 copy RF} ", PS.rst.do_grey ? "CG" : "C");
- fprintf(PS.fp, "{/z y def %d {C /z t add def x z xw t neg RF} repeat} ", 5);
+ fprintf(PS.fp,
+ "{/z y def %d {C /z t add def x z xw t neg RF} repeat} ", 5);
fprintf(PS.fp, "ifelse\n0 0 0 C RE\n");
set_ps_color(&(PS.rl.legend.font.color));
- fprintf(PS.fp, "AR%d i get x syw add y ARh row get sub MS row 1 add ROW} for\n", n);
+ fprintf(PS.fp,
+ "AR%d i get x syw add y ARh row get sub MS row 1 add ROW} for\n",
+ n);
}
/* Make the title of legend */
- if (PS.rl.legend.title[0] != 0)
- {
+ if (PS.rl.legend.title[0] != 0) {
set_ps_font(&(PS.rl.legend.title_font));
- fprintf(PS.fp, "xo mgx add yo mgy mg sub sub M wd mgx 2 mul sub (%s) SHS\n", PS.rl.legend.title);
+ fprintf(PS.fp,
+ "xo mgx add yo mgy mg sub sub M wd mgx 2 mul sub (%s) SHS\n",
+ PS.rl.legend.title);
}
return 0;
@@ -185,52 +186,54 @@
int set_rlegend_gradient(void)
{
int i, k, rows, nlines, dec;
+
int R, G, B;
+
DCELL dmin, dmax, val;
+
double fontsize, step, fwidth;
+
struct Colors colors;
+
struct FPRange range;
+
char *units[GNAME_MAX];
+
char format[50];
/* let user know what's happenning */
- G_message(_("Raster legend with gradient <%s in %s> ..."), PS.rl.name, PS.rl.mapset);
+ G_message(_("Raster legend with gradient <%s in %s> ..."), PS.rl.name,
+ PS.rl.mapset);
/* Get color range */
- if (G_read_fp_range(PS.rl.name, PS.rl.mapset, &range) == -1)
- {
+ if (G_read_fp_range(PS.rl.name, PS.rl.mapset, &range) == -1) {
G_warning(_("Range information not available (run r.support)"));
return 1;
}
/* range and check */
- if (PS.rl.custom_range)
- {
+ if (PS.rl.custom_range) {
dmin = PS.rl.min;
dmax = PS.rl.max;
}
- else
- {
+ else {
G_get_fp_range_min_max(&range, &dmin, &dmax);
PS.rl.min = dmin;
PS.rl.max = dmax;
}
- if (dmin == dmax)
- {
+ if (dmin == dmax) {
G_warning(_("It is not a range of values (max = min)"));
return 1;
}
/* color table */
- if (G_read_colors(PS.rl.name, PS.rl.mapset, &colors) == -1)
- {
+ if (G_read_colors(PS.rl.name, PS.rl.mapset, &colors) == -1) {
G_warning(_("Unable to read colors for rlegend"));
}
/* units label */
- if (G_read_raster_units(PS.rl.name, PS.rl.mapset, (char *)units) != 0)
- {
+ if (G_read_raster_units(PS.rl.name, PS.rl.mapset, (char *)units) != 0) {
units[0] = 0;
}
@@ -238,8 +241,7 @@
fontsize = set_ps_font(&(PS.rl.legend.font));
/* set standard height */
- if (PS.rl.height <= 0.)
- {
+ if (PS.rl.height <= 0.) {
PS.rl.height = 15. * fontsize;
rows = 10; /* = PS.rl.height / 1.5*fontsize */
}
@@ -255,15 +257,16 @@
/* Array of strings and widths */
sprintf(format, "(%%.%df) %%.8f\n", dec);
fprintf(PS.fp, "/AR0 [\n");
- while (val <= dmax)
- {
+ while (val <= dmax) {
fprintf(PS.fp, format, val, (dmax - val) / (dmax - dmin));
val += step;
}
fprintf(PS.fp, "] def\n");
fprintf(PS.fp, "/ARh 1 array def ARh 0 %.2f put\n", fontsize);
fprintf(PS.fp, "/ARw 1 array def "
- "/mx 0 def 0 2 AR0 length 1 sub {" "AR0 exch get SW /t XD t mx gt {/mx t def} if } for " "ARw 0 mx put\n");
+ "/mx 0 def 0 2 AR0 length 1 sub {"
+ "AR0 exch get SW /t XD t mx gt {/mx t def} if } for "
+ "ARw 0 mx put\n");
PS.rl.legend.xspan = 0.; /* needed for auto adjust */
@@ -286,15 +289,16 @@
fprintf(PS.fp, "/y y %.3f sub def\n", fwidth / 2.);
fprintf(PS.fp, "0 2 AR0 length -- {/i XD\n");
fprintf(PS.fp, "x y ch AR0 i ++ get mul\n");
- if (PS.rl.tickbar)
- {
+ if (PS.rl.tickbar) {
fprintf(PS.fp, "GS ");
fprintf(PS.fp, "3 copy sub ");
fprintf(PS.fp, "NM -1 0 MR -%d 0 LR CS GR\n", PS.rl.tickbar); /* length of tickbar */
}
/* Ajusta los extremos que no salgan de la barra */
fprintf(PS.fp, "%.3f ", 0.6 * fontsize); /* aprox part upper tickbar */
- fprintf(PS.fp, "2 copy lt {2 div add}" " {2 div add dup ch gt {pop ch} if} ifelse ");
+ fprintf(PS.fp,
+ "2 copy lt {2 div add}"
+ " {2 div add dup ch gt {pop ch} if} ifelse ");
fprintf(PS.fp, "sub M AR0 i get show} for\n");
/* Prepare the border and stroke area */
@@ -306,15 +310,18 @@
/* draw the colorbar and frame */
fprintf(PS.fp, "dy 1.1 mul LW x y chg sub\n"); /* stack x and y */
fprintf(PS.fp, "[\n");
- for (val = dmin; val <= dmax; val += step)
- {
+ for (val = dmin; val <= dmax; val += step) {
G_get_d_raster_color(&val, &R, &G, &B, &colors);
if (PS.rst.do_grey)
- fprintf(PS.fp, "[%.3f]\n", (0.30 * (double)R + 0.59 * (double)G + 0.11 * (double)B) / 255.);
+ fprintf(PS.fp, "[%.3f]\n",
+ (0.30 * (double)R + 0.59 * (double)G +
+ 0.11 * (double)B) / 255.);
else
- fprintf(PS.fp, "[%.3f %.3f %.3f]\n", R / 255., G / 255., B / 255.);
+ fprintf(PS.fp, "[%.3f %.3f %.3f]\n", R / 255., G / 255.,
+ B / 255.);
}
- fprintf(PS.fp, "] {aload pop %c 2 copy M dx 0 LR stroke dy add} forall\n", PS.rst.do_grey ? 'G' : 'C');
+ fprintf(PS.fp, "] {aload pop %c 2 copy M dx 0 LR stroke dy add} forall\n",
+ PS.rst.do_grey ? 'G' : 'C');
fprintf(PS.fp, "pop pop\n");
fprintf(PS.fp, "GS 4 copy RC\n");
if (PS.rl.whiteframe > 0.) /* white border: print on colors */
@@ -324,12 +331,12 @@
fprintf(PS.fp, "%.5f LW RO\n", fwidth);
/* print units label, if present */
- if (units[0])
- {
+ if (units[0]) {
set_ps_color(&(PS.rl.legend.font.color));
fprintf(PS.fp, "%.1f FS ", 0.8 * fontsize);
fprintf(PS.fp, "RESET (%s) dup SW ", units);
- fprintf(PS.fp, "x cwd add exch sub y chg %.1f add sub MS\n", fontsize);
+ fprintf(PS.fp, "x cwd add exch sub y chg %.1f add sub MS\n",
+ fontsize);
}
G_free_colors(&colors);
@@ -348,28 +355,23 @@
step = diff / cuts;
- for (i = 0; i < 4; i++)
- {
+ for (i = 0; i < 4; i++) {
dec = 0;
/* smalest n for which nice step >= raw step */
- if (nice_steps[i] <= step)
- {
+ if (nice_steps[i] <= step) {
ex = 1;
while (nice_steps[i] * ex < step)
ex *= 10;
}
- else
- {
+ else {
ex = 0.1;
- while (nice_steps[i] * ex > step)
- {
+ while (nice_steps[i] * ex > step) {
++dec;
ex *= 0.1;
}
ex *= 10;
}
- if (i == 0 || (nice_steps[i] * ex - step) < cur_d)
- {
+ if (i == 0 || (nice_steps[i] * ex - step) < cur_d) {
cur_step = i;
cur_d = nice_steps[i] * ex - step;
cur_ex = ex;
Modified: grass-addons/postscript/ps.output/set_scalebar.c
===================================================================
--- grass-addons/postscript/ps.output/set_scalebar.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/set_scalebar.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -12,6 +12,7 @@
int set_scalebar(void)
{
int i, j;
+
double width, segment;
if (PS.sbar.length <= 0 || PS.sbar.segments <= 0)
@@ -21,8 +22,7 @@
/* width of scalebar in points */
width = PS.sbar.length;
- switch (PS.sbar.ucode)
- {
+ switch (PS.sbar.ucode) {
case SB_UNITS_KM:
width *= KILOMETERS_TO_METERS;
break;
@@ -41,8 +41,7 @@
}
width *= (1000. * MM_TO_POINT / (double)PS.scale);
- if (PS.sbar.subsegs > 0 && PS.sbar.type != 'I')
- {
+ if (PS.sbar.subsegs > 0 && PS.sbar.type != 'I') {
segment = width / (double)PS.sbar.segments;
width += segment;
}
@@ -57,62 +56,60 @@
/* labels of the scalebar */
fprintf(PS.fp, "/AR0 [");
segment = (PS.sbar.length / PS.sbar.segments);
- for (i = 0; i <= PS.sbar.segments; i += PS.sbar.labels)
- {
+ for (i = 0; i <= PS.sbar.segments; i += PS.sbar.labels) {
fprintf(PS.fp, "(%s)", strnumber(i * segment));
}
fprintf(PS.fp, "] def\n");
/* sublabels of the scalebar */
- if (PS.sbar.type != 'I')
- {
+ if (PS.sbar.type != 'I') {
fprintf(PS.fp, "/AR1 [(0)");
segment = (PS.sbar.length / PS.sbar.segments) / PS.sbar.subsegs;
- for (i = PS.sbar.sublabs; i <= PS.sbar.subsegs; i += PS.sbar.sublabs)
- {
+ for (i = PS.sbar.sublabs; i <= PS.sbar.subsegs; i += PS.sbar.sublabs) {
fprintf(PS.fp, "(%s)", strnumber(i * segment));
}
fprintf(PS.fp, "] def\n");
}
/* The text in PS.sbar.units used to calculate size of text */
- if (PS.sbar.type == 'I')
- {
+ if (PS.sbar.type == 'I') {
fprintf(PS.fp,
- "/mgy mg def (%s) SWH 2 add /chg XD " "chg mg 2 mul add /hg XD 2 add wd add /wd XD\n", PS.sbar.units);
+ "/mgy mg def (%s) SWH 2 add /chg XD "
+ "chg mg 2 mul add /hg XD 2 add wd add /wd XD\n",
+ PS.sbar.units);
}
- else if (PS.sbar.type == 's' || PS.sbar.type == 'S')
- {
+ else if (PS.sbar.type == 's' || PS.sbar.type == 'S') {
fprintf(PS.fp,
"AR0 dup length -- get SWH "
"mg add /mgy XD 2 div dup mg add /mgr XD wd add (%s) SW 2 add add /wd XD "
"/hg mgy 2 add mg add chg add def\n", PS.sbar.units);
}
- else
- {
+ else {
fprintf(PS.fp,
"AR0 dup length -- get SWH "
- "mg add /mgy XD 2 div dup mg add /mgr XD wd add /wd XD " "/hg mgy 2 mul ++ chg add def\n");
+ "mg add /mgy XD 2 div dup mg add /mgr XD wd add /wd XD "
+ "/hg mgy 2 mul ++ chg add def\n");
}
/* prepare the scalebar */
- if (PS.sbar.subsegs == 0 || PS.sbar.type == 'I')
- {
- fprintf(PS.fp, "/dx cwd %d div def " "/mgx mg def\n", PS.sbar.segments);
+ if (PS.sbar.subsegs == 0 || PS.sbar.type == 'I') {
+ fprintf(PS.fp, "/dx cwd %d div def " "/mgx mg def\n",
+ PS.sbar.segments);
}
- else
- {
+ else {
fprintf(PS.fp,
"/dx cwd %d div def\n"
- "AR1 dup length -- get SW 2 div dup " "mg add dx add /mgx XD wd add /wd XD\n", PS.sbar.segments + 1);
+ "AR1 dup length -- get SW 2 div dup "
+ "mg add dx add /mgx XD wd add /wd XD\n",
+ PS.sbar.segments + 1);
}
/* do the scalebar */
set_box_draw(&(PS.sbar.box));
- switch (PS.sbar.type)
- {
+ switch (PS.sbar.type) {
case 'I':
fprintf(PS.fp, "/RBAR {{x exch dx mul add y dx dy RF} for} D\n");
- fprintf(PS.fp, "/RTXT {{dup x exch dx mul add -- y M AR0 exch get SHR} for} D\n");
- fprintf(PS.fp, "/mgy mg def RESET /dy chg neg def\n");
+ fprintf(PS.fp,
+ "/RTXT {{dup x exch dx mul add -- y M AR0 exch get SHR} for} D\n");
+ fprintf(PS.fp, "/mgy mg def RESET /dy chg neg def\n");
set_ps_color(&(PS.sbar.font.color));
fprintf(PS.fp, "1 LW x y cwd dy RE\n");
fprintf(PS.fp, "1 2 %d RBAR\n", PS.sbar.segments - 1);
@@ -128,42 +125,43 @@
case 'F':
fprintf(PS.fp, "/RBAR ");
if (PS.sbar.type == 'F')
- fprintf(PS.fp, "{ {x exch dx mul add y chg 2 div sub dx 3 index RF} for pop} D\n");
+ fprintf(PS.fp,
+ "{ {x exch dx mul add y chg 2 div sub dx 3 index RF} for pop} D\n");
else
- fprintf(PS.fp, "{ {x exch dx mul add y dx 3 index RF} for pop} D\n");
+ fprintf(PS.fp,
+ "{ {x exch dx mul add y dx 3 index RF} for pop} D\n");
fprintf(PS.fp,
"/RTXT {1 2 index length -- "
- "{dup x exch dx mul i mul add y 1 add M" " 1 index exch get SHC} for pop} D\n");
+ "{dup x exch dx mul i mul add y 1 add M"
+ " 1 index exch get SHC} for pop} D\n");
fprintf(PS.fp, "RESET /dy chg neg def\n");
set_ps_color(&(PS.sbar.fcolor));
- fprintf(PS.fp, "x %s y cwd dy 4 copy RF ", (PS.sbar.subsegs > 0 ? "dx sub" : ""));
+ fprintf(PS.fp, "x %s y cwd dy 4 copy RF ",
+ (PS.sbar.subsegs > 0 ? "dx sub" : ""));
set_ps_color(&(PS.sbar.font.color));
fprintf(PS.fp, ".5 LW RE\n");
- if (PS.sbar.type == 'F')
- {
+ if (PS.sbar.type == 'F') {
fprintf(PS.fp, "dy 2 div neg 0 2 %d RBAR ", PS.sbar.segments - 1);
fprintf(PS.fp, "dy 2 div 1 2 %d RBAR\n", PS.sbar.segments - 1);
}
- else
- {
+ else {
fprintf(PS.fp, "dy 0 2 %d RBAR ", PS.sbar.segments - 1);
}
fprintf(PS.fp, "/i %d def AR0 0 RTXT ", PS.sbar.labels);
- if (PS.sbar.subsegs > 0)
- {
+ if (PS.sbar.subsegs > 0) {
fprintf(PS.fp, "/dx dx %d div neg def ", PS.sbar.subsegs);
- if (PS.sbar.type == 'F')
- {
+ if (PS.sbar.type == 'F') {
fprintf(PS.fp, "dy 2 div 0 2 %d RBAR ", PS.sbar.subsegs - 1);
- fprintf(PS.fp, "dy 2 neg div 1 2 %d RBAR ", PS.sbar.subsegs - 1);
+ fprintf(PS.fp, "dy 2 neg div 1 2 %d RBAR ",
+ PS.sbar.subsegs - 1);
}
- else
- {
+ else {
fprintf(PS.fp, "dy 1 2 %d RBAR ", PS.sbar.subsegs - 1);
}
fprintf(PS.fp, "/i %d def AR1 1 RTXT\n", PS.sbar.sublabs);
}
- fprintf(PS.fp, "xo wd add mgr sub yo hg sub mg add M (%s) SHR\n", PS.sbar.units);
+ fprintf(PS.fp, "xo wd add mgr sub yo hg sub mg add M (%s) SHR\n",
+ PS.sbar.units);
break;
case 's':
case 'S':
@@ -171,31 +169,33 @@
fprintf(PS.fp,
"/RBAR { {x exch dx mul add y M dup 0 exch LRS} for pop} D\n"
"/RTXT {1 2 index length -- "
- "{dup x exch dx mul i mul add y dy add ++ M" " 1 index exch get SHC} for pop} D\n");
+ "{dup x exch dx mul i mul add y dy add ++ M"
+ " 1 index exch get SHC} for pop} D\n");
fprintf(PS.fp, "RESET /dy chg 2 div def /y y dy sub def .5 LW\n");
- if (PS.sbar.type == 'S')
- {
+ if (PS.sbar.type == 'S') {
set_ps_color(&(PS.sbar.fcolor));
- fprintf(PS.fp, "x %s y cwd dy neg 4 copy RF ", (PS.sbar.subsegs > 0 ? "dx sub" : ""));
+ fprintf(PS.fp, "x %s y cwd dy neg 4 copy RF ",
+ (PS.sbar.subsegs > 0 ? "dx sub" : ""));
set_ps_color(&(PS.sbar.font.color));
fprintf(PS.fp, "RE\n", PS.sbar.segments);
}
- else
- {
+ else {
set_ps_color(&(PS.sbar.font.color));
- fprintf(PS.fp, "GS 2 LC x %s y dy sub M cwd 0 LRS GR\n", (PS.sbar.subsegs > 0 ? "dx sub" : ""));
+ fprintf(PS.fp, "GS 2 LC x %s y dy sub M cwd 0 LRS GR\n",
+ (PS.sbar.subsegs > 0 ? "dx sub" : ""));
}
fprintf(PS.fp, "dy neg 0 1 %d RBAR\n", PS.sbar.segments);
fprintf(PS.fp, "/i %d def AR0 0 RTXT ", PS.sbar.labels);
fprintf(PS.fp, "dy 0 %d %d RBAR\n", PS.sbar.labels, PS.sbar.segments);
- if (PS.sbar.subsegs > 0)
- {
+ if (PS.sbar.subsegs > 0) {
fprintf(PS.fp, "/dx dx %d div neg def ", PS.sbar.subsegs);
fprintf(PS.fp, "dy neg 1 1 %d RBAR ", PS.sbar.subsegs);
fprintf(PS.fp, "/i %d def AR1 1 RTXT\n", PS.sbar.sublabs);
- fprintf(PS.fp, "dy 0 %d %d RBAR ", PS.sbar.sublabs, PS.sbar.subsegs);
+ fprintf(PS.fp, "dy 0 %d %d RBAR ", PS.sbar.sublabs,
+ PS.sbar.subsegs);
}
- fprintf(PS.fp, "xo wd add mg sub y dy add ++ M (%s) SHR\n", PS.sbar.units);
+ fprintf(PS.fp, "xo wd add mg sub y dy add ++ M (%s) SHR\n",
+ PS.sbar.units);
break;
}
fprintf(PS.fp, "GR\n");
Modified: grass-addons/postscript/ps.output/set_vareas.c
===================================================================
--- grass-addons/postscript/ps.output/set_vareas.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/set_vareas.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -21,8 +21,7 @@
/* TO DRAW AREAS */
int vector_area(struct line_pnts *lpoints, double sep)
{
- if (lpoints->n_points > 0)
- {
+ if (lpoints->n_points > 0) {
struct line_pnts *opoints;
opoints = Vect_new_line_struct();
@@ -30,14 +29,12 @@
register int i;
set_ps_where('M', lpoints->x[0], lpoints->y[0]);
- for (i = 1; i < lpoints->n_points; i++)
- {
+ for (i = 1; i < lpoints->n_points; i++) {
set_ps_where('L', lpoints->x[i], lpoints->y[i]);
}
Vect_line_parallel(lpoints, sep, 0.01, 0, opoints);
Vect_line_reverse(opoints);
- for (i = 0; i < opoints->n_points; i++)
- {
+ for (i = 0; i < opoints->n_points; i++) {
set_ps_where('L', opoints->x[i], opoints->y[i]);
}
set_ps_where('L', lpoints->x[0], lpoints->y[0]);
@@ -49,9 +46,13 @@
int set_vareas(VECTOR * vec, VAREAS * va)
{
int k, ret, cat;
+
int area, nareas, island, nislands, centroid;
+
struct line_cats *lcats;
+
struct line_pnts *lpoints;
+
BOUND_BOX box;
nareas = Vect_get_num_areas(&(vec->Map));
@@ -59,15 +60,15 @@
fprintf(PS.fp, "GS 1 setlinejoin\n");
/* Create vector array, if required */
- if (vec->cats != NULL)
- {
+ if (vec->cats != NULL) {
vec->Varray = Vect_new_varray(nareas);
- Vect_set_varray_from_cat_string(&(vec->Map), vec->layer, vec->cats, GV_AREA, 1, vec->Varray);
+ Vect_set_varray_from_cat_string(&(vec->Map), vec->layer, vec->cats,
+ GV_AREA, 1, vec->Varray);
}
- else if (vec->where != NULL)
- {
+ else if (vec->where != NULL) {
vec->Varray = Vect_new_varray(nareas);
- Vect_set_varray_from_db(&(vec->Map), vec->layer, vec->where, GV_AREA, 1, vec->Varray);
+ Vect_set_varray_from_db(&(vec->Map), vec->layer, vec->where, GV_AREA,
+ 1, vec->Varray);
}
else
vec->Varray = NULL;
@@ -79,18 +80,15 @@
/* load attributes if fcolor is named */
dbCatValArray rgbcv, idcv;
- if (va->rgbcol != NULL)
- {
+ if (va->rgbcol != NULL) {
load_catval_array(&(vec->Map), va->rgbcol, &rgbcv);
- if (va->idcol != NULL)
+ if (va->idcol != NULL)
load_catval_array(&(vec->Map), va->idcol, &idcv);
}
/* read and plot vectors */
- for (area = 1; area <= nareas; area++)
- {
- if (vec->Varray != NULL && vec->Varray->c[area] == 0)
- {
+ for (area = 1; area <= nareas; area++) {
+ if (vec->Varray != NULL && vec->Varray->c[area] == 0) {
continue;
}
/* check if is a island */
@@ -99,7 +97,8 @@
continue;
/* check if in window */
Vect_get_area_box(&(vec->Map), area, &box);
- if (box.N < PS.map.south || box.S > PS.map.north || box.E < PS.map.west || box.W > PS.map.east)
+ if (box.N < PS.map.south || box.S > PS.map.north ||
+ box.E < PS.map.west || box.W > PS.map.east)
continue;
/* Oops is a correct area, I can draw it */
if (Vect_get_area_points(&(vec->Map), area, lpoints) < 0)
@@ -109,11 +108,9 @@
vector_line(lpoints);
fprintf(PS.fp, "CP\n");
/* islands */
- if (centroid > 0 && va->island)
- {
+ if (centroid > 0 && va->island) {
nislands = Vect_get_area_num_isles(&(vec->Map), area);
- for (island = 0; island < nislands; island++)
- {
+ for (island = 0; island < nislands; island++) {
k = Vect_get_area_isle(&(vec->Map), area, island);
if (Vect_get_isle_points(&(vec->Map), k, lpoints) < 0)
return -1; /* ? break; */
@@ -123,57 +120,48 @@
}
}
/* set the fill */
- if (!va->fcolor.none || va->rgbcol != NULL)
- {
+ if (!va->fcolor.none || va->rgbcol != NULL) {
PSCOLOR color;
- if (va->rgbcol == NULL)
- {
+ if (va->rgbcol == NULL) {
set_color_pscolor(&color, &(va->fcolor));
}
- else
- {
+ else {
cat = Vect_get_area_cat(&(vec->Map), area, vec->layer);
set_color_name(&color, get_string(&rgbcv, cat, 0));
color.a = va->fcolor.a;
- if (va->idcol != NULL)
- {
+ if (va->idcol != NULL) {
double value;
get_number(&idcv, cat, &value);
- vector_item_new(vec, value, color_to_long(&color));
- }
- else
- {
+ vector_item_new(vec, value, color_to_long(&color));
+ }
+ else {
vector_item_new(vec, 0, color_to_long(&color));
- }
+ }
}
/* set the type of fill if color */
- if (!color.none)
- {
+ if (!color.none) {
fprintf(PS.fp, "GS %.2f O ", color.a);
- if (va->name_pat == NULL || va->type_pat == 2)
- {
- fprintf(PS.fp, "%.3f %.3f %.3f ", color.r, color.g, color.b);
+ if (va->name_pat == NULL || va->type_pat == 2) {
+ fprintf(PS.fp, "%.3f %.3f %.3f ", color.r, color.g,
+ color.b);
}
- if (va->name_pat != NULL)
- {
+ if (va->name_pat != NULL) {
fprintf(PS.fp, "PATTERN%d setpattern ", vec->id);
}
- else
- {
+ else {
fprintf(PS.fp, "C ");
}
fprintf(PS.fp, "fill GR ");
}
}
/* set the line style */
- if (va->line.width > 0. && !va->line.color.none)
- {
- set_ps_line(&(va->line));
- fprintf(PS.fp, "S\n");
- }
+ if (va->line.width > 0. && !va->line.color.none) {
+ set_ps_line(&(va->line));
+ fprintf(PS.fp, "S\n");
+ }
}
fprintf(PS.fp, "GR\n");
@@ -184,9 +172,13 @@
int set_vareas_line(VECTOR * vec, VAREAS * va)
{
int ret, cat;
+
int ln, nlines, pt, npoints;
+
double width;
+
struct line_cats *lcats;
+
struct line_pnts *lpoints;
@@ -195,15 +187,18 @@
fprintf(PS.fp, "GS 1 setlinejoin\n"); /* lines with linejoin = round */
/* Create vector array, if required */
- if (vec->cats != NULL)
- {
+ if (vec->cats != NULL) {
vec->Varray = Vect_new_varray(nlines);
- ret = Vect_set_varray_from_cat_string(&(vec->Map), vec->layer, vec->cats, GV_LINE, 1, vec->Varray);
+ ret =
+ Vect_set_varray_from_cat_string(&(vec->Map), vec->layer,
+ vec->cats, GV_LINE, 1,
+ vec->Varray);
}
- else if (vec->where != NULL)
- {
+ else if (vec->where != NULL) {
vec->Varray = Vect_new_varray(nlines);
- ret = Vect_set_varray_from_db(&(vec->Map), vec->layer, vec->where, GV_LINE, 1, vec->Varray);
+ ret =
+ Vect_set_varray_from_db(&(vec->Map), vec->layer, vec->where,
+ GV_LINE, 1, vec->Varray);
}
else
vec->Varray = NULL;
@@ -214,13 +209,12 @@
/* process only vectors in current window */
Vect_set_constraint_region(&(vec->Map),
- PS.map.north, PS.map.south,
- PS.map.east, PS.map.west,
- PORT_DOUBLE_MAX, -PORT_DOUBLE_MAX);
+ PS.map.north, PS.map.south,
+ PS.map.east, PS.map.west,
+ PORT_DOUBLE_MAX, -PORT_DOUBLE_MAX);
/* read and plot lines */
- for (ln = 1; ln <= nlines; ln++)
- {
+ for (ln = 1; ln <= nlines; ln++) {
ret = Vect_read_line(&(vec->Map), lpoints, lcats, ln);
if (ret < 0)
continue;
@@ -234,10 +228,9 @@
vector_area(lpoints, va->width * POINT_TO_MM / 1000. * PS.scale);
fprintf(PS.fp, "CP\n");
/* set the fill */
- if (!va->fcolor.none)
- {
- fprintf(PS.fp, "GS %.2f O %.3f %.3f %.3f ",
- va->fcolor.a, va->fcolor.r, va->fcolor.g, va->fcolor.b);
+ if (!va->fcolor.none) {
+ fprintf(PS.fp, "GS %.2f O %.3f %.3f %.3f ",
+ va->fcolor.a, va->fcolor.r, va->fcolor.g, va->fcolor.b);
if (va->name_pat != NULL)
fprintf(PS.fp, "PATTERN%d setpattern fill ", vec->id);
else
@@ -245,8 +238,7 @@
fprintf(PS.fp, "GR ");
}
/* set the line style */
- if (va->line.width > 0. && !va->line.color.none)
- {
+ if (va->line.width > 0. && !va->line.color.none) {
set_ps_line(&(va->line));
fprintf(PS.fp, "S\n");
}
Modified: grass-addons/postscript/ps.output/set_vector.c
===================================================================
--- grass-addons/postscript/ps.output/set_vector.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/set_vector.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -23,69 +23,57 @@
int set_vector(int masked, int type)
{
int i;
+
char buf[1024];
- for (i = PS.vct_files - 1; i >= 0; i--)
- {
- if (masked && !PS.vct[i].masked)
- {
+ for (i = PS.vct_files - 1; i >= 0; i--) {
+ if (masked && !PS.vct[i].masked) {
continue;
}
- if (!masked && PS.vct[i].masked)
- {
+ if (!masked && PS.vct[i].masked) {
continue;
}
- if (PS.vct[i].type != type)
- {
+ if (PS.vct[i].type != type) {
continue;
}
- /* select the type of output, NONE: no draw anything */
- if (PS.vct[i].type == AREAS)
- {
+ /* select the type of output, NONE: no draw anything */
+ if (PS.vct[i].type == AREAS) {
VAREAS *va = (VAREAS *) PS.vct[i].data;
- if (va->name_pat != NULL)
- {
- set_ps_pattern(PS.vct[i].id, va->name_pat, va);
+ if (va->name_pat != NULL) {
+ set_ps_pattern(PS.vct[i].id, va->name_pat, va);
}
- if (va->width != 0.)
- {
- set_vareas_line(&(PS.vct[i]), va);
- }
- else
- {
- set_vareas(&(PS.vct[i]), va);
- }
+ if (va->width != 0.) {
+ set_vareas_line(&(PS.vct[i]), va);
+ }
+ else {
+ set_vareas(&(PS.vct[i]), va);
+ }
}
- else if (PS.vct[i].type == LABELS)
- {
+ else if (PS.vct[i].type == LABELS) {
VLABELS *vl = (VLABELS *) PS.vct[i].data;
set_vlabels(&(PS.vct[i]), vl);
}
- else if (PS.vct[i].type == LINES)
- {
+ else if (PS.vct[i].type == LINES) {
VLINES *vl = (VLINES *) PS.vct[i].data;
- if (vl->hline.width > 0 && !(vl->hline.color.none))
- {
+ if (vl->hline.width > 0 && !(vl->hline.color.none)) {
set_vlines(&(PS.vct[i]), vl, DRAW_HLINE);
Vect_rewind(&(PS.vct[i].Map));
}
set_vlines(&(PS.vct[i]), vl, DRAW_LINE);
}
- else if (PS.vct[i].type == POINTS)
- {
+ else if (PS.vct[i].type == POINTS) {
SYMBOL *symb;
+
VPOINTS *vp = (VPOINTS *) PS.vct[i].data;
symb = S_read(vp->symbol);
- if (symb != NULL)
- {
+ if (symb != NULL) {
symbol_save(PS.vct[i].id, vp, symb);
}
- else
- {
+ else {
set_ps_symbol_eps(PS.vct[i].id, vp->symbol);
}
if (vp->distance > 0.)
Modified: grass-addons/postscript/ps.output/set_vlabels.c
===================================================================
--- grass-addons/postscript/ps.output/set_vlabels.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/set_vlabels.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -22,22 +22,25 @@
int set_vlabels(VECTOR * vec, VLABELS * vx)
{
int ret, cat;
+
int x, y, pt, npoints;
+
struct line_cats *lcats;
+
struct line_pnts *lpoints;
npoints = Vect_get_num_lines(&(vec->Map));
/* Create vector array, if required */
- if (vec->cats != NULL)
- {
+ if (vec->cats != NULL) {
vec->Varray = Vect_new_varray(npoints);
- Vect_set_varray_from_cat_string(&(vec->Map), vec->layer, vec->cats, vx->type, 1, vec->Varray);
+ Vect_set_varray_from_cat_string(&(vec->Map), vec->layer, vec->cats,
+ vx->type, 1, vec->Varray);
}
- else if (vec->where != NULL)
- {
+ else if (vec->where != NULL) {
vec->Varray = Vect_new_varray(npoints);
- Vect_set_varray_from_db(&(vec->Map), vec->layer, vec->where, vx->type, 1, vec->Varray);
+ Vect_set_varray_from_db(&(vec->Map), vec->layer, vec->where, vx->type,
+ 1, vec->Varray);
}
else
vec->Varray = NULL;
@@ -49,9 +52,8 @@
/* load attributes if any */
dbCatValArray cv_label;
- if (vx->labelcol != NULL)
- {
- load_catval_array(&(vec->Map), vx->labelcol, &cv_label);
+ if (vx->labelcol != NULL) {
+ load_catval_array(&(vec->Map), vx->labelcol, &cv_label);
}
else
return 0;
@@ -60,12 +62,11 @@
set_ps_font(&(vx->font));
/* read and plot lines */
- for (pt = 1; pt <= npoints; pt++)
- {
+ for (pt = 1; pt <= npoints; pt++) {
ret = Vect_read_line(&(vec->Map), lpoints, lcats, pt);
if (ret < 0)
continue;
- if (!(ret & GV_POINTS) || !(ret & vx->type))
+ if (!(ret & GV_POINTS) || !(ret & vx->type))
continue;
if (vec->Varray != NULL && vec->Varray->c[pt] == 0)
continue;
@@ -73,19 +74,19 @@
G_plot_where_xy(lpoints->x[0], lpoints->y[0], &x, &y);
PS.x = (double)x / 10.;
PS.y = (double)y / 10.;
- if (PS.x < PS.map_x || PS.x > PS.map_right || PS.y < PS.map_y || PS.y > PS.map_top)
+ if (PS.x < PS.map_x || PS.x > PS.map_right || PS.y < PS.map_y ||
+ PS.y > PS.map_top)
continue;
/* Oops the point is correct, I can draw it */
Vect_cat_get(lcats, 1, &cat);
- fprintf(PS.fp, "%.4f %.4f M (%s) ",
- PS.x, PS.y, get_string(&cv_label, cat, vx->decimals));
+ fprintf(PS.fp, "%.4f %.4f M (%s) ",
+ PS.x, PS.y, get_string(&cv_label, cat, vx->decimals));
/* Draw text with a style */
- if (vx->style != 0)
- {
- fprintf(PS.fp, "GS %.2f LW [] 0 LD dup TCIR GR\n", vx->style);
- }
+ if (vx->style != 0) {
+ fprintf(PS.fp, "GS %.2f LW [] 0 LD dup TCIR GR\n", vx->style);
+ }
fprintf(PS.fp, "SHCC ");
}
fprintf(PS.fp, "GR\n");
Modified: grass-addons/postscript/ps.output/set_vlegend.c
===================================================================
--- grass-addons/postscript/ps.output/set_vlegend.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/set_vlegend.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -28,8 +28,7 @@
G_debug(1, "Placing vlegend ...");
/* How many vectors to draw? */
- for (n_vct = 0, i = 0; i < PS.vct_files; i++)
- {
+ for (n_vct = 0, i = 0; i < PS.vct_files; i++) {
if (PS.vct[i].lpos >= 0)
++n_vct;
}
@@ -39,17 +38,13 @@
/* Reorder as defined by the user */
int *ip = (int *)G_malloc(n_vct * sizeof(int));
- for (i = 0; i < n_vct; i++)
- {
+ for (i = 0; i < n_vct; i++) {
ip[i] = -1;
}
- for (i = 0; i < PS.vct_files; i++)
- {
- if (PS.vct[i].lpos > 0)
- {
+ for (i = 0; i < PS.vct_files; i++) {
+ if (PS.vct[i].lpos > 0) {
j = PS.vct[i].lpos - 1;
- if (j < n_vct && ip[j] < 0)
- {
+ if (j < n_vct && ip[j] < 0) {
ip[j] = i;
PS.vct[i].lpos = -1;
}
@@ -57,10 +52,8 @@
PS.vct[i].lpos = 0;
}
}
- for (i = 0; i < PS.vct_files; i++)
- {
- if (PS.vct[i].lpos == 0)
- {
+ for (i = 0; i < PS.vct_files; i++) {
+ if (PS.vct[i].lpos == 0) {
j = 0;
while (j < n_vct && ip[j] >= 0)
j++;
@@ -74,7 +67,7 @@
PS.vl.legend.box.margin = 0.4 * PS.vl.legend.font.size;
if (PS.vl.legend.width <= 0)
- PS.vl.legend.width = 2.4 * PS.vl.legend.font.size;
+ PS.vl.legend.width = 2.4 * PS.vl.legend.font.size;
if (PS.vl.legend.xspan <= 0)
PS.vl.legend.xspan = PS.vl.legend.box.margin;
@@ -99,43 +92,36 @@
/* Prepare the content of legend by vector */
int K, n;
- for (i = 0; i < n_vct; i++)
- {
+ for (i = 0; i < n_vct; i++) {
j = ip[i];
- qsort(PS.vct[j].item, PS.vct[j].n_item, sizeof(ITEMS), cmpitems);
- if (PS.vct[j].yspan <= 0)
+ qsort(PS.vct[j].item, PS.vct[j].n_item, sizeof(ITEMS), cmpitems);
+ if (PS.vct[j].yspan <= 0)
PS.vct[j].yspan = PS.vl.legend.yspan;
}
set_ps_font(&(PS.vl.legend.font));
- for (K = 0, i = 0; i < n_vct; i++, K++)
- {
- j = ip[i];
- /* if (PS.vct[j].n_item == 1) continue; con K-- */
- if (PS.vct[j].n_item == 1)
- {
- n = 0;
- while ((i+n) < n_vct && PS.vct[ip[i+n]].n_item == 1)
- {
- ++n;
- }
- set_vlegend_simple(K, ip + i, n);
- i += (n-1);
- }
- else
- {
- set_vlegend_multi(K, &(PS.vct[j]));
- }
+ for (K = 0, i = 0; i < n_vct; i++, K++) {
+ j = ip[i];
+ /* if (PS.vct[j].n_item == 1) continue; con K-- */
+ if (PS.vct[j].n_item == 1) {
+ n = 0;
+ while ((i + n) < n_vct && PS.vct[ip[i + n]].n_item == 1) {
+ ++n;
+ }
+ set_vlegend_simple(K, ip + i, n);
+ i += (n - 1);
+ }
+ else {
+ set_vlegend_multi(K, &(PS.vct[j]));
+ }
}
n_vct = K;
G_free(ip);
/* Prepare the title of the legend */
- if (!PS.vl.legend.title || PS.vl.legend.title[0] == 0)
- {
+ if (!PS.vl.legend.title || PS.vl.legend.title[0] == 0) {
fprintf(PS.fp, "/mgy 0 def\n");
}
- else
- {
+ else {
fprintf(PS.fp, "GS ");
set_ps_font(&(PS.vl.legend.title_font));
fprintf(PS.fp, "(%s) SWH ", PS.vl.legend.title);
@@ -145,18 +131,20 @@
}
/* Prepare and draw the frame of the legend */
- fprintf(PS.fp, "hg BKh {add dyy add} forall dyy sub BKt {add} forall /hg XD\n");
- fprintf(PS.fp, "wd BKw {mg 2 mul add 2 copy lt {exch} if pop} forall /wd XD\n");
+ fprintf(PS.fp,
+ "hg BKh {add dyy add} forall dyy sub BKt {add} forall /hg XD\n");
+ fprintf(PS.fp,
+ "wd BKw {mg 2 mul add 2 copy lt {exch} if pop} forall /wd XD\n");
set_box_orig(&(PS.vl.legend.box));
set_box_draw(&(PS.vl.legend.box));
/* Draw the title of the legend */
- if (PS.vl.legend.title && PS.vl.legend.title[0] != 0)
- {
+ if (PS.vl.legend.title && PS.vl.legend.title[0] != 0) {
fprintf(PS.fp, "GS ");
set_ps_font(&(PS.vl.legend.title_font));
- fprintf(PS.fp, "xo mg add yo mgy sub M wd mg 2 mul sub (%s) SHS\n", PS.vl.legend.title);
+ fprintf(PS.fp, "xo mg add yo mgy sub M wd mg 2 mul sub (%s) SHS\n",
+ PS.vl.legend.title);
fprintf(PS.fp, "GR\n");
}
@@ -166,36 +154,39 @@
"dup 0 get /dy XD\n"
"dup 1 get dup length 0 eq {pop} {x y dy add MS} ifelse y roh sub /y XD /yt y def\n"
"dup 2 exch length 2 sub getinterval {"
- "dup 0 3 2 index length -- {"
- "3 getinterval aload pop /code XD aload pop\n");
+ "dup 0 3 2 index length -- {"
+ "3 getinterval aload pop /code XD aload pop\n");
fprintf(PS.fp,
"code %d eq {"
"GS 0 ne {LW 0 LD C x syw add 0 roh sub 2 div neg y add dup x exch ML [] 0 LD} if "
- "x syw 2 div add 0.65 roh mul 2 div y add TR SC ROT LW cvx cvn exec GR} if\n", POINTS);
+ "x syw 2 div add 0.65 roh mul 2 div y add TR SC ROT LW cvx cvn exec GR} if\n",
+ POINTS);
+ fprintf(PS.fp, "code %d eq {"
+ // "GS {LW 0 LD C roh .35 mul /z XD x y z add M syw .3 mul z neg syw .6 mul z syw .9 mul 0 rcurveto S} repeat GR} if\n", LINES);
+ "GS {LW 0 LD C x syw add y roh 0.35 mul add dup x exch ML} repeat GR} if\n",
+ LINES);
fprintf(PS.fp,
- "code %d eq {"
-// "GS {LW 0 LD C roh .35 mul /z XD x y z add M syw .3 mul z neg syw .6 mul z syw .9 mul 0 rcurveto S} repeat GR} if\n", LINES);
- "GS {LW 0 LD C x syw add y roh 0.35 mul add dup x exch ML} repeat GR} if\n", LINES);
- fprintf(PS.fp,
- "code %d eq {"
- "GS [] 0 LD x y -- x syw .9 mul add y roh add -- B "
- "GS 0 ne {0 eq {C} {setpattern} ifelse fill} if GR 0 ne {LW 0 LD C S} if GR} if\n", AREAS);
+ "code %d eq {"
+ "GS [] 0 LD x y -- x syw .9 mul add y roh add -- B "
+ "GS 0 ne {0 eq {C} {setpattern} ifelse fill} if GR 0 ne {LW 0 LD C S} if GR} if\n",
+ AREAS);
set_ps_color(&(PS.vl.legend.font.color));
fprintf(PS.fp,
"x syw add y MS\n"
- "y roh dy add sub /y XD dup} for pop pop\n" "x cow dxx add add /x XD yt /y XD} forall} D\n");
+ "y roh dy add sub /y XD dup} for pop pop\n"
+ "x cow dxx add add /x XD yt /y XD} forall} D\n");
fprintf(PS.fp, "yo mgy mg add sub /yo XD\n");
- for (i = 0; i < n_vct; i++)
- {
- /* caja del elemento *
- fprintf(PS.fp, "GS .2 LW [1] 0 LD ");
- fprintf(PS.fp, "xo mg add yo BKw %d get BKh %d get BKt %d get add neg RE GR\n", i, i, i);
- */
+ for (i = 0; i < n_vct; i++) {
+ /* caja del elemento *
+ fprintf(PS.fp, "GS .2 LW [1] 0 LD ");
+ fprintf(PS.fp, "xo mg add yo BKw %d get BKh %d get BKt %d get add neg RE GR\n", i, i, i);
+ */
fprintf(PS.fp, "/x xo mg add def ");
fprintf(PS.fp, "/y yo BKt %d get sub def\n", i);
fprintf(PS.fp, "BK%d VLEGEND\n", i);
- fprintf(PS.fp, "yo BKh %i get BKt %d get dyy add add sub /yo XD\n", i, i);
+ fprintf(PS.fp, "yo BKh %i get BKt %d get dyy add add sub /yo XD\n", i,
+ i);
}
return 1;
@@ -204,6 +195,7 @@
void make_vareas(VECTOR * vec, int rows)
{
int i, item;
+
VAREAS *va = (VAREAS *) vec->data;
/* Set the title of the vector */
@@ -214,61 +206,48 @@
/* Iterate by items */
fprintf(PS.fp, "[\n");
- for (item = 0, i = 0; i < vec->n_item; i++, item++)
- {
- if (item == rows)
- {
+ for (item = 0, i = 0; i < vec->n_item; i++, item++) {
+ if (item == rows) {
item = 0;
fprintf(PS.fp, "][\n");
}
/* set the label of the item */
- if (va->rgbcol == NULL)
- {
+ if (va->rgbcol == NULL) {
fprintf(PS.fp, "( %s)", vec->label);
}
- else
- {
- int id = vec->item[i].rule;
+ else {
+ int id = vec->item[i].rule;
- if (id == -1)
- {
+ if (id == -1) {
fprintf(PS.fp, "( )");
}
- else
- {
+ else {
fprintf(PS.fp, "( %s)", vec->rule[id].label);
}
long_to_color(vec->item[i].data, &(va->fcolor));
}
/* set the specific data of the item */
fprintf(PS.fp, " [");
- if (va->line.color.none || va->line.width <= 0)
- {
+ if (va->line.color.none || va->line.width <= 0) {
fprintf(PS.fp, "0 ");
}
- else
- {
+ else {
fprintf(PS.fp, "%.3f %.3f %.3f [%s] %.3f 1 ",
- va->line.color.r, va->line.color.g, va->line.color.b,
- va->line.dash, va->line.width);
+ va->line.color.r, va->line.color.g, va->line.color.b,
+ va->line.dash, va->line.width);
}
- if (va->fcolor.none && va->name_pat == NULL)
- {
+ if (va->fcolor.none && va->name_pat == NULL) {
fprintf(PS.fp, "0");
}
- else
- {
- if (va->name_pat == NULL || va->type_pat == 2)
- {
- fprintf(PS.fp, "%.3f %.3f %.3f ",
- va->fcolor.r, va->fcolor.g, va->fcolor.b);
+ else {
+ if (va->name_pat == NULL || va->type_pat == 2) {
+ fprintf(PS.fp, "%.3f %.3f %.3f ",
+ va->fcolor.r, va->fcolor.g, va->fcolor.b);
}
- if (va->name_pat != NULL)
- {
+ if (va->name_pat != NULL) {
fprintf(PS.fp, "PATTERN%d 1 1", vec->id);
}
- else
- {
+ else {
fprintf(PS.fp, "0 1");
}
}
@@ -280,6 +259,7 @@
void make_vlines(VECTOR * vec, int rows)
{
int i, item;
+
VLINES *vl = (VLINES *) vec->data;
/* Set the title of the vector */
@@ -290,28 +270,22 @@
/* Iterate by items */
fprintf(PS.fp, "[\n");
- for (item = 0, i = 0; i < vec->n_item; i++, item++)
- {
- if (item == rows)
- {
+ for (item = 0, i = 0; i < vec->n_item; i++, item++) {
+ if (item == rows) {
item = 0;
fprintf(PS.fp, "][\n");
}
/* set the label of the item */
- if (vl->rgbcol == NULL)
- {
+ if (vl->rgbcol == NULL) {
fprintf(PS.fp, "( %s)", vec->label);
}
- else
- {
- int id = vec->item[i].rule;
+ else {
+ int id = vec->item[i].rule;
- if (id == -1)
- {
+ if (id == -1) {
fprintf(PS.fp, "( )");
}
- else
- {
+ else {
fprintf(PS.fp, "( %s)", vec->rule[id].label);
}
long_to_color(vec->item[i].data, &(vl->line.color));
@@ -319,15 +293,15 @@
/* set the specific data of the item */
fprintf(PS.fp, " [");
fprintf(PS.fp, "%.3f %.3f %.3f [%s] %.4f",
- vl->line.color.r, vl->line.color.g, vl->line.color.b, vl->line.dash, vl->line.width);
- if (vl->hline.width <= 0)
- {
+ vl->line.color.r, vl->line.color.g, vl->line.color.b,
+ vl->line.dash, vl->line.width);
+ if (vl->hline.width <= 0) {
fprintf(PS.fp, " 1");
}
- else
- {
+ else {
fprintf(PS.fp, " %.3f %.3f %.3f [%s] %.4f",
- vl->hline.color.r, vl->hline.color.g, vl->hline.color.b, vl->hline.dash, vl->hline.width);
+ vl->hline.color.r, vl->hline.color.g, vl->hline.color.b,
+ vl->hline.dash, vl->hline.width);
fprintf(PS.fp, " 2");
}
fprintf(PS.fp, "] %d\n", vec->type);
@@ -338,6 +312,7 @@
void make_vpoints(VECTOR * vec, int rows)
{
int i, item;
+
VPOINTS *vp = (VPOINTS *) vec->data;
/* Set the title of the vector */
@@ -348,31 +323,25 @@
/* Iterate by items */
fprintf(PS.fp, "[\n");
- for (item = 0, i = 0; i < vec->n_item; i++, item++)
- {
+ for (item = 0, i = 0; i < vec->n_item; i++, item++) {
/* if vp->size == 0 => no draw? */
- if (item == rows)
- {
+ if (item == rows) {
item = 0;
fprintf(PS.fp, "][\n");
}
/* set the label of the item */
- if (vp->sizecol == NULL || vec->n_rule == 0)
- {
+ if (vp->sizecol == NULL || vec->n_rule == 0) {
fprintf(PS.fp, "( %s)", vec->label);
}
- else
- {
- int id = vec->item[i].rule;
+ else {
+ int id = vec->item[i].rule;
- if (id == -1)
- {
+ if (id == -1) {
vp->size = (double)(vec->item[i].data / 1000.);
- fprintf(PS.fp, "( %.3f)", vp->size);
+ fprintf(PS.fp, "( %.3f)", vp->size);
}
- else
- {
+ else {
fprintf(PS.fp, "( %s)", vec->rule[id].label);
vp->size = vec->rule[id].value;
}
@@ -381,21 +350,20 @@
/* set the specific data of the item */
fprintf(PS.fp, " [");
fprintf(PS.fp, "(SYMBOL%d)", vec->id);
-// fprintf(PS.fp, " %.4f", vp->line.width / vp->size); /* div! 0 */
- if (vp->size == 0.)
- fprintf(PS.fp, " %.4f", vp->line.width);
- else
- fprintf(PS.fp, " %.4f", vp->line.width / vp->size);
+ // fprintf(PS.fp, " %.4f", vp->line.width / vp->size); /* div! 0 */
+ if (vp->size == 0.)
+ fprintf(PS.fp, " %.4f", vp->line.width);
+ else
+ fprintf(PS.fp, " %.4f", vp->line.width / vp->size);
fprintf(PS.fp, " %.3f", vp->rotate);
fprintf(PS.fp, " %.3f dup", vp->size);
- if (vp->distance != 0.)
- {
+ if (vp->distance != 0.) {
fprintf(PS.fp, " %.3f %.3f %.3f [%s] %.4f",
- vp->cline.color.r, vp->cline.color.g, vp->cline.color.b, vp->cline.dash, vp->cline.width);
+ vp->cline.color.r, vp->cline.color.g, vp->cline.color.b,
+ vp->cline.dash, vp->cline.width);
fprintf(PS.fp, " 1");
}
- else
- {
+ else {
fprintf(PS.fp, " 0");
}
fprintf(PS.fp, "] %d\n", vec->type);
@@ -404,7 +372,7 @@
}
/* Join vector legend with simple line */
-int set_vlegend_simple(int i, const int * ip, int items)
+int set_vlegend_simple(int i, const int *ip, int items)
{
int x, rows, cols, item;
@@ -414,50 +382,40 @@
++rows;
fprintf(PS.fp, "/BK%d [\n%.4f ()\n[\n", i, PS.vl.legend.yspan);
- for (item = 0, x = 0; x < items; x++, item++)
- {
+ for (item = 0, x = 0; x < items; x++, item++) {
VECTOR *vec = &(PS.vct[ip[x]]);
- if (item == rows)
- {
+ if (item == rows) {
item = 0;
fprintf(PS.fp, "][\n");
}
fprintf(PS.fp, "( %s)", vec->label);
- switch (vec->type)
- {
+ switch (vec->type) {
case AREAS:
{
VAREAS *va = (VAREAS *) vec->data;
fprintf(PS.fp, " [");
- if (va->line.color.none || va->line.width <= 0)
- {
+ if (va->line.color.none || va->line.width <= 0) {
fprintf(PS.fp, "0 ");
}
- else
- {
+ else {
fprintf(PS.fp, "%.3f %.3f %.3f [%s] %.3f 1 ",
- va->line.color.r, va->line.color.g, va->line.color.b,
- va->line.dash, va->line.width);
+ va->line.color.r, va->line.color.g,
+ va->line.color.b, va->line.dash, va->line.width);
}
- if (va->fcolor.none && va->name_pat == NULL)
- {
+ if (va->fcolor.none && va->name_pat == NULL) {
fprintf(PS.fp, "0");
}
- else
- {
- if (va->name_pat == NULL || va->type_pat == 2)
- {
- fprintf(PS.fp, "%.3f %.3f %.3f ",
- va->fcolor.r, va->fcolor.g, va->fcolor.b);
+ else {
+ if (va->name_pat == NULL || va->type_pat == 2) {
+ fprintf(PS.fp, "%.3f %.3f %.3f ",
+ va->fcolor.r, va->fcolor.g, va->fcolor.b);
}
- if (va->name_pat != NULL)
- {
+ if (va->name_pat != NULL) {
fprintf(PS.fp, "PATTERN%d 1 1", vec->id);
}
- else
- {
+ else {
fprintf(PS.fp, "0 1");
}
}
@@ -470,17 +428,16 @@
fprintf(PS.fp, " [");
fprintf(PS.fp, "%.3f %.3f %.3f [%s] %.4f",
- vl->line.color.r, vl->line.color.g, vl->line.color.b,
- vl->line.dash, vl->line.width);
- if (vl->hline.width <= 0)
- {
+ vl->line.color.r, vl->line.color.g, vl->line.color.b,
+ vl->line.dash, vl->line.width);
+ if (vl->hline.width <= 0) {
fprintf(PS.fp, " 1");
}
- else
- {
+ else {
fprintf(PS.fp, " %.3f %.3f %.3f [%s] %.4f",
- vl->hline.color.r, vl->hline.color.g, vl->hline.color.b,
- vl->hline.dash, vl->hline.width);
+ vl->hline.color.r, vl->hline.color.g,
+ vl->hline.color.b, vl->hline.dash,
+ vl->hline.width);
fprintf(PS.fp, " 2");
}
fprintf(PS.fp, "] %d\n", vec->type);
@@ -495,15 +452,14 @@
fprintf(PS.fp, " %.4f", vp->line.width / vp->size); /* div! 0 */
fprintf(PS.fp, " %.3f", vp->rotate);
fprintf(PS.fp, " %.3f dup", vp->size);
- if (vp->distance != 0.)
- {
+ if (vp->distance != 0.) {
fprintf(PS.fp, " %.3f %.3f %.3f [%s] %.4f",
- vp->cline.color.r, vp->cline.color.g, vp->cline.color.b,
- vp->cline.dash, vp->cline.width);
+ vp->cline.color.r, vp->cline.color.g,
+ vp->cline.color.b, vp->cline.dash,
+ vp->cline.width);
fprintf(PS.fp, " 1");
}
- else
- {
+ else {
fprintf(PS.fp, " 0");
}
fprintf(PS.fp, "] %d\n", vec->type);
@@ -532,22 +488,21 @@
/* Make de legend */
fprintf(PS.fp, "/BK%d [\n%.4f ", i, vec->yspan);
- switch (vec->type)
- {
+ switch (vec->type) {
case AREAS:
- {
- make_vareas(vec, rows);
- }
+ {
+ make_vareas(vec, rows);
+ }
break;
case LINES:
- {
- make_vlines(vec, rows);
- }
+ {
+ make_vlines(vec, rows);
+ }
break;
case POINTS:
- {
- make_vpoints(vec, rows);
- }
+ {
+ make_vpoints(vec, rows);
+ }
break;
}
fprintf(PS.fp, "] def\n");
@@ -562,14 +517,16 @@
void set_vlegend_ps(int i, int rows, int cols)
{
fprintf(PS.fp, "BK%d aload length 2 sub {"
- "aload length 3 idiv"
- "{pop pop SW syw add cow 2 copy lt {pop} {exch /cow XD} ifelse pop}"
- "repeat} repeat exch /dy XD\n", i);
+ "aload length 3 idiv"
+ "{pop pop SW syw add cow 2 copy lt {pop} {exch /cow XD} ifelse pop}"
+ "repeat} repeat exch /dy XD\n", i);
fprintf(PS.fp, "BKh %d roh dy add %d mul dy sub put\n", i, rows);
fprintf(PS.fp, "BKw %d cow dxx add %d mul dxx sub put\n", i, cols);
fprintf(PS.fp, "dup length 0 eq {BKt %d 0 put} ", i);
fprintf(PS.fp, "{SWH BKt %d 3 -1 roll dy add put ", i);
- fprintf(PS.fp, "BKw %d get 2 copy gt {pop BKw %d 3 -1 roll put} {pop pop} ifelse} ifelse\n", i, i);
+ fprintf(PS.fp,
+ "BKw %d get 2 copy gt {pop BKw %d 3 -1 roll put} {pop pop} ifelse} ifelse\n",
+ i, i);
}
Modified: grass-addons/postscript/ps.output/set_vlines.c
===================================================================
--- grass-addons/postscript/ps.output/set_vlines.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/set_vlines.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -24,13 +24,11 @@
/* TO DRAW LINES */
int vector_line(struct line_pnts *lpoints)
{
- if (lpoints->n_points > 0)
- {
+ if (lpoints->n_points > 0) {
register int i;
set_ps_where('M', lpoints->x[0], lpoints->y[0]);
- for (i = 1; i <= lpoints->n_points - 1; i++)
- {
+ for (i = 1; i <= lpoints->n_points - 1; i++) {
set_ps_where('L', lpoints->x[i], lpoints->y[i]);
}
}
@@ -41,8 +39,11 @@
int set_vlines(VECTOR * vec, VLINES * vl, int flag)
{
int ret, cat;
+
int ln, nlines, pt, npoints;
+
struct line_cats *lcats;
+
struct line_pnts *lpoints;
@@ -51,15 +52,18 @@
fprintf(PS.fp, "GS 1 setlinejoin NP\n"); /* lines with linejoin = round */
/* Create vector array, if required */
- if (vec->cats != NULL)
- {
+ if (vec->cats != NULL) {
vec->Varray = Vect_new_varray(nlines);
- ret = Vect_set_varray_from_cat_string(&(vec->Map), vec->layer, vec->cats, vl->type, 1, vec->Varray);
+ ret =
+ Vect_set_varray_from_cat_string(&(vec->Map), vec->layer,
+ vec->cats, vl->type, 1,
+ vec->Varray);
}
- else if (vec->where != NULL)
- {
+ else if (vec->where != NULL) {
vec->Varray = Vect_new_varray(nlines);
- ret = Vect_set_varray_from_db(&(vec->Map), vec->layer, vec->where, vl->type, 1, vec->Varray);
+ ret =
+ Vect_set_varray_from_db(&(vec->Map), vec->layer, vec->where,
+ vl->type, 1, vec->Varray);
}
else
vec->Varray = NULL;
@@ -70,17 +74,15 @@
/* process only vectors in current window */
Vect_set_constraint_region(&(vec->Map),
- PS.map.north, PS.map.south,
- PS.map.east, PS.map.west,
- PORT_DOUBLE_MAX, -PORT_DOUBLE_MAX);
+ PS.map.north, PS.map.south,
+ PS.map.east, PS.map.west,
+ PORT_DOUBLE_MAX, -PORT_DOUBLE_MAX);
/* load attributes if fcolor is named */
dbCatValArray rgbcv, idcv;
- if (flag == DRAW_LINE)
- {
- if (vl->rgbcol != NULL)
- {
+ if (flag == DRAW_LINE) {
+ if (vl->rgbcol != NULL) {
load_catval_array(&(vec->Map), vl->rgbcol, &rgbcv);
if (vl->idcol != NULL)
load_catval_array(&(vec->Map), vl->idcol, &idcv);
@@ -88,8 +90,7 @@
}
/* read and plot lines */
- for (ln = 1; ln <= nlines; ln++)
- {
+ for (ln = 1; ln <= nlines; ln++) {
ret = Vect_read_line(&(vec->Map), lpoints, lcats, ln);
if (ret < 0)
continue;
@@ -100,11 +101,10 @@
/* Oops the line is correct, I can draw it */
/* How I can draw it? */
- if (flag == DRAW_HLINE)
- {
- if (vl->offset != 0.)
- {
+ if (flag == DRAW_HLINE) {
+ if (vl->offset != 0.) {
double dis;
+
struct line_pnts *opoints = Vect_new_line_struct();
/* perhaps dont run in Lat/Lon */
@@ -112,21 +112,17 @@
Vect_line_parallel(lpoints, dis, 0.1, 0, opoints);
vector_line(opoints);
}
- else
- {
+ else {
vector_line(lpoints);
}
set_ps_line(&(vl->hline));
}
- else
- {
+ else {
vector_line(lpoints);
- if (vl->rgbcol == NULL)
- {
+ if (vl->rgbcol == NULL) {
set_ps_color(&(vl->line.color));
}
- else
- {
+ else {
PSCOLOR color;
Vect_cat_get(lcats, 1, &cat);
@@ -134,8 +130,7 @@
color.a = vl->line.color.a;
set_ps_color(&color);
- if (vl->idcol != NULL)
- {
+ if (vl->idcol != NULL) {
double value;
get_number(&idcv, cat, &value);
Modified: grass-addons/postscript/ps.output/set_vpoints.c
===================================================================
--- grass-addons/postscript/ps.output/set_vpoints.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/set_vpoints.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -22,23 +22,27 @@
int set_vpoints(VECTOR * vec, VPOINTS * vp)
{
int ret, cat;
+
int pt, npoints;
+
double tmp, size, rotate;
+
struct line_cats *lcats;
+
struct line_pnts *lpoints;
npoints = Vect_get_num_lines(&(vec->Map));
/* Create vector array, if required */
- if (vec->cats != NULL)
- {
+ if (vec->cats != NULL) {
vec->Varray = Vect_new_varray(npoints);
- Vect_set_varray_from_cat_string(&(vec->Map), vec->layer, vec->cats, vp->type, 1, vec->Varray);
+ Vect_set_varray_from_cat_string(&(vec->Map), vec->layer, vec->cats,
+ vp->type, 1, vec->Varray);
}
- else if (vec->where != NULL)
- {
+ else if (vec->where != NULL) {
vec->Varray = Vect_new_varray(npoints);
- Vect_set_varray_from_db(&(vec->Map), vec->layer, vec->where, vp->type, 1, vec->Varray);
+ Vect_set_varray_from_db(&(vec->Map), vec->layer, vec->where, vp->type,
+ 1, vec->Varray);
}
else
vec->Varray = NULL;
@@ -50,18 +54,15 @@
/* load attributes if any */
dbCatValArray sizecv, rotcv;
- if (vp->rotatecol != NULL)
- {
+ if (vp->rotatecol != NULL) {
load_catval_array(&(vec->Map), vp->rotatecol, &rotcv);
}
- if (vp->sizecol != NULL)
- {
+ if (vp->sizecol != NULL) {
load_catval_array(&(vec->Map), vp->sizecol, &sizecv);
}
/* read and plot lines */
- for (pt = 1; pt <= npoints; pt++)
- {
+ for (pt = 1; pt <= npoints; pt++) {
ret = Vect_read_line(&(vec->Map), lpoints, lcats, pt);
if (ret < 0)
continue;
@@ -75,32 +76,29 @@
G_plot_where_xy(lpoints->x[0], lpoints->y[0], &x, &y);
PS.x = (double)x / 10.;
PS.y = (double)y / 10.;
- if (PS.x < PS.map_x || PS.x > PS.map_right || PS.y < PS.map_y || PS.y > PS.map_top)
+ if (PS.x < PS.map_x || PS.x > PS.map_right || PS.y < PS.map_y ||
+ PS.y > PS.map_top)
continue;
/* Oops the point is correct, I can draw it */
Vect_cat_get(lcats, 1, &cat);
fprintf(PS.fp, "GS ");
fprintf(PS.fp, "%.4f %.4f TR ", PS.x, PS.y);
/* symbol size */
- if (vp->sizecol == NULL)
- {
+ if (vp->sizecol == NULL) {
size = vp->size;
}
- else
- {
+ else {
get_number(&sizecv, cat, &tmp);
- size = tmp * vp->scale + vp->bias;
- if (vec->n_rule == 0)
- {
- vector_item_new(vec, tmp, (long)(vp->size * 1000.));
+ size = tmp * vp->scale + vp->bias;
+ if (vec->n_rule == 0) {
+ vector_item_new(vec, tmp, (long)(vp->size * 1000.));
}
- else
- {
+ else {
int i;
i = vector_item_new(vec, tmp, (long)(size * 1000.));
- if (vec->item[i].rule != -1)
- size = vec->rule[vec->item[i].rule].value;
+ if (vec->item[i].rule != -1)
+ size = vec->rule[vec->item[i].rule].value;
}
}
if (size <= 0.)
@@ -108,12 +106,10 @@
fprintf(PS.fp, "%.3f dup SC ", size);
/* symbol rotate */
- if (vp->rotatecol == NULL)
- {
+ if (vp->rotatecol == NULL) {
rotate = vp->rotate;
}
- else
- {
+ else {
get_number(&rotcv, cat, &rotate);
}
if (rotate > 0.)
@@ -131,9 +127,13 @@
int set_vpoints_line(VECTOR * vec, VPOINTS * vp)
{
int ret, cat;
+
double size, rotate;
+
int ln, nlines, pt, npoints;
+
struct line_cats *lcats;
+
struct line_pnts *lpoints;
@@ -142,15 +142,18 @@
fprintf(PS.fp, "GS 1 setlinejoin NP\n"); /* lines with linejoin = round */
/* Create vector array, if required */
- if (vec->cats != NULL)
- {
+ if (vec->cats != NULL) {
vec->Varray = Vect_new_varray(nlines);
- ret = Vect_set_varray_from_cat_string(&(vec->Map), vec->layer, vec->cats, vp->type, 1, vec->Varray);
+ ret =
+ Vect_set_varray_from_cat_string(&(vec->Map), vec->layer,
+ vec->cats, vp->type, 1,
+ vec->Varray);
}
- else if (vec->where != NULL)
- {
+ else if (vec->where != NULL) {
vec->Varray = Vect_new_varray(nlines);
- ret = Vect_set_varray_from_db(&(vec->Map), vec->layer, vec->where, vp->type, 1, vec->Varray);
+ ret =
+ Vect_set_varray_from_db(&(vec->Map), vec->layer, vec->where,
+ vp->type, 1, vec->Varray);
}
else
vec->Varray = NULL;
@@ -161,40 +164,36 @@
/* process only vectors in current window */
Vect_set_constraint_region(&(vec->Map),
- PS.map.north, PS.map.south, PS.map.east, PS.map.west, PORT_DOUBLE_MAX, -PORT_DOUBLE_MAX);
+ PS.map.north, PS.map.south, PS.map.east,
+ PS.map.west, PORT_DOUBLE_MAX,
+ -PORT_DOUBLE_MAX);
/* prepare the symbol to draw */
/* load attributes if any */
dbCatValArray cv_size, cv_rot;
- if (vp->sizecol != NULL)
- {
+ if (vp->sizecol != NULL) {
load_catval_array(&(vec->Map), vp->sizecol, &cv_size);
}
- if (vp->rotatecol != NULL)
- {
+ if (vp->rotatecol != NULL) {
load_catval_array(&(vec->Map), vp->rotatecol, &cv_rot);
}
fprintf(PS.fp, "/LSYMBOL {GS %.3f TR [] 0 LD ", vp->voffset);
/* symbol size */
- if (vp->sizecol == NULL)
- {
+ if (vp->sizecol == NULL) {
size = vp->size;
}
- else
- {
+ else {
get_number(&cv_size, cat, &size);
size *= vp->scale;
}
if (size > 0.)
fprintf(PS.fp, "%.3f dup SC ", size);
/* symbol rotate */
- if (vp->rotatecol == NULL)
- {
+ if (vp->rotatecol == NULL) {
rotate = vp->rotate;
}
- else
- {
+ else {
get_number(&cv_rot, cat, &rotate);
}
if (rotate > 0.)
@@ -206,8 +205,7 @@
fprintf(PS.fp, "GR} def\n");
/* read and plot lines */
- for (ln = 1; ln <= nlines; ln++)
- {
+ for (ln = 1; ln <= nlines; ln++) {
ret = Vect_read_line(&(vec->Map), lpoints, lcats, ln);
if (ret < 0)
continue;
Modified: grass-addons/postscript/ps.output/start_map.c
===================================================================
--- grass-addons/postscript/ps.output/start_map.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/start_map.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -16,20 +16,20 @@
#include "conversion.h"
int move_local(int x, int y);
+
int cont_local(int x, int y);
int start_map(void)
{
double width, height;
+
double fact, d_ns, ns, d_ew, ew;
/* default position */
- if (PS.map_x < 0)
- {
+ if (PS.map_x < 0) {
PS.map_x = PS.page.left + PS.brd.width;
}
- if (PS.map_top < 0)
- {
+ if (PS.map_top < 0) {
PS.map_top = PS.page.top + PS.brd.width;
}
@@ -38,40 +38,34 @@
height = PS.page.height - PS.map_top - (PS.page.bot + PS.brd.width);
/* default size */
- if (PS.map_w < 0 || PS.map_w > width)
- {
+ if (PS.map_w < 0 || PS.map_w > width) {
PS.map_w = width;
}
- if (PS.map_h < 0 || PS.map_h > height)
- {
+ if (PS.map_h < 0 || PS.map_h > height) {
PS.map_h = height;
}
/* distance calculation, throught center of map */
G_begin_distance_calculations();
- if (PS.map.proj == PROJECTION_LL)
- {
+ if (PS.map.proj == PROJECTION_LL) {
ns = (PS.map.north + PS.map.south) / 2.;
d_ew = G_distance(PS.map.east, ns, PS.map.west, ns);
ew = (PS.map.east + PS.map.west) / 2.;
d_ns = G_distance(ew, PS.map.north, ew, PS.map.south);
}
- else
- {
+ else {
d_ew = (PS.map.east - PS.map.west);
d_ns = (PS.map.north - PS.map.south);
}
/* to define the scale */
- if (PS.scale > 0)
- {
+ if (PS.scale > 0) {
fact = MT_TO_POINT / (double)PS.scale;
ew = fact * d_ew;
ns = fact * d_ns;
- if (ew <= PS.map_w && ns <= PS.map_h)
- {
+ if (ew <= PS.map_w && ns <= PS.map_h) {
PS.map_w = ew;
PS.map_h = ns;
}
@@ -79,8 +73,7 @@
PS.scale = 0; /* forze readjust scale */
}
/* auto scale */
- if (PS.scale <= 0)
- {
+ if (PS.scale <= 0) {
ew = d_ew / PS.map_w;
ns = d_ns / PS.map_h;
fact = (ew > ns) ? ew : ns;
@@ -101,7 +94,8 @@
PS.map_top = PS.map_y + PS.map_h;
G_setup_plot(10. * (PS.map_y + PS.map_h), 10. * PS.map_y,
- 10. * PS.map_x, 10. * (PS.map_x + PS.map_w), move_local, cont_local);
+ 10. * PS.map_x, 10. * (PS.map_x + PS.map_w), move_local,
+ cont_local);
return 0;
}
@@ -112,6 +106,7 @@
fprintf(PS.fp, "%.1f %.1f M\n", (double)x / 10., (double)y / 10.);
return 0;
}
+
int cont_local(int x, int y)
{
fprintf(PS.fp, "%.1f %.1f L ", (double)x / 10., (double)y / 10.);
Modified: grass-addons/postscript/ps.output/symbol.c
===================================================================
--- grass-addons/postscript/ps.output/symbol.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/symbol.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -14,22 +14,22 @@
int draw_chain(SYMBCHAIN * chain, double s)
{
int k, l;
+
char *mvcmd;
+
SYMBEL *elem;
- for (k = 0; k < chain->count; k++)
- {
+ for (k = 0; k < chain->count; k++) {
elem = chain->elem[k];
- switch (elem->type)
- {
+ switch (elem->type) {
case S_LINE:
- for (l = 0; l < elem->coor.line.count; l++)
- {
+ for (l = 0; l < elem->coor.line.count; l++) {
if (k == 0 && l == 0)
mvcmd = "M";
else
mvcmd = "L";
- fprintf(PS.fp, "%.4f %.4f %s\n", s * elem->coor.line.x[l], s * elem->coor.line.y[l], mvcmd);
+ fprintf(PS.fp, "%.4f %.4f %s\n", s * elem->coor.line.x[l],
+ s * elem->coor.line.y[l], mvcmd);
}
break;
case S_ARC:
@@ -39,7 +39,8 @@
mvcmd = "arc";
fprintf(PS.fp, "%.4f %.4f %.4f %.4f %.4f %s\n",
s * elem->coor.arc.x,
- s * elem->coor.arc.y, s * elem->coor.arc.r, elem->coor.arc.a1, elem->coor.arc.a2, mvcmd);
+ s * elem->coor.arc.y, s * elem->coor.arc.r,
+ elem->coor.arc.a1, elem->coor.arc.a2, mvcmd);
break;
}
}
@@ -51,8 +52,11 @@
int symbol_save(int code, VPOINTS * vp, SYMBOL * Symb)
{
SYMBPART *part;
+
SYMBCHAIN *chain;
+
int i, j, points;
+
double s, xo[4], yo[4];
points = 4;
@@ -70,57 +74,51 @@
fprintf(PS.fp, "/SYMBOL%d {\n", code);
s *= Symb->scale;
- for (i = 0; i < Symb->count; i++)
- {
+ for (i = 0; i < Symb->count; i++) {
part = Symb->part[i];
- switch (part->type)
- {
+ switch (part->type) {
case S_POLYGON:
fprintf(PS.fp, "NP\n"); /* Start ring */
- for (j = 0; j < part->count; j++)
- { /* RINGS */
+ for (j = 0; j < part->count; j++) { /* RINGS */
chain = part->chain[j];
draw_chain(chain, s);
fprintf(PS.fp, "CP\n"); /* Close one ring */
}
/* Fill */
- if (part->fcolor.color == S_COL_DEFAULT && !vp->fcolor.none)
- {
+ if (part->fcolor.color == S_COL_DEFAULT && !vp->fcolor.none) {
set_ps_color(&(vp->fcolor));
fprintf(PS.fp, "F\n"); /* Fill polygon */
}
- else if (part->fcolor.color == S_COL_DEFINED)
- {
- fprintf(PS.fp, "%.3f %.3f %.3f C ", part->fcolor.fr, part->fcolor.fg, part->fcolor.fb);
+ else if (part->fcolor.color == S_COL_DEFINED) {
+ fprintf(PS.fp, "%.3f %.3f %.3f C ", part->fcolor.fr,
+ part->fcolor.fg, part->fcolor.fb);
fprintf(PS.fp, "F\n");
}
/* Outline */
- if (part->color.color == S_COL_DEFAULT && !vp->line.color.none)
- {
+ if (part->color.color == S_COL_DEFAULT && !vp->line.color.none) {
set_ps_color(&(vp->line.color));
fprintf(PS.fp, "S\n"); /* Draw boundary */
}
- else if (part->color.color == S_COL_DEFINED)
- {
- fprintf(PS.fp, "%.3f %.3f %.3f C ", part->color.fr, part->color.fg, part->color.fb);
+ else if (part->color.color == S_COL_DEFINED) {
+ fprintf(PS.fp, "%.3f %.3f %.3f C ", part->color.fr,
+ part->color.fg, part->color.fb);
fprintf(PS.fp, "S\n");
}
break;
case S_STRING: /* string has 1 chain */
- if (part->color.color != S_COL_NONE)
- {
+ if (part->color.color != S_COL_NONE) {
fprintf(PS.fp, "NP\n");
chain = part->chain[0];
draw_chain(chain, s);
/* Color */
- if (part->color.color == S_COL_DEFAULT && !vp->line.color.none)
- {
+ if (part->color.color == S_COL_DEFAULT &&
+ !vp->line.color.none) {
set_ps_color(&(vp->line.color));
fprintf(PS.fp, "S\n");
}
- else
- {
- fprintf(PS.fp, "%.3f %.3f %.3f C ", part->color.fr, part->color.fg, part->color.fb);
+ else {
+ fprintf(PS.fp, "%.3f %.3f %.3f C ", part->color.fr,
+ part->color.fg, part->color.fb);
fprintf(PS.fp, "S\n");
}
}
Modified: grass-addons/postscript/ps.output/val_list.c
===================================================================
--- grass-addons/postscript/ps.output/val_list.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/val_list.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -14,7 +14,9 @@
int sort_list(char *order, int items, CELL ** item)
{
int i, j, k, count, tmp;
+
CELL *ip, val;
+
DCELL *vlist;
/* initial order */
@@ -23,16 +25,11 @@
ip[i] = i;
/* if any to order */
- if (order[0] != 0 && (count = parse_val_list(order, &vlist)) > 0)
- {
- for (i = 0, j = 0; j < count; j += 2)
- {
- for (val = vlist[j]; val <= vlist[j + 1]; val++)
- {
- for (k = i; k < items; k++)
- {
- if ((*item)[k] == val)
- {
+ if (order[0] != 0 && (count = parse_val_list(order, &vlist)) > 0) {
+ for (i = 0, j = 0; j < count; j += 2) {
+ for (val = vlist[j]; val <= vlist[j + 1]; val++) {
+ for (k = i; k < items; k++) {
+ if ((*item)[k] == val) {
tmp = ip[k];
ip[k] = ip[i];
ip[i] = tmp;
@@ -76,21 +73,19 @@
int parse_val_list(char *buf, DCELL ** list)
{
int count;
+
DCELL a, b;
+
DCELL *lp;
count = 0;
lp = (DCELL *) G_malloc(sizeof(DCELL));
- while (*buf)
- {
- while (*buf == ' ' || *buf == '\t' || *buf == ',' || *buf == '\n')
- {
+ while (*buf) {
+ while (*buf == ' ' || *buf == '\t' || *buf == ',' || *buf == '\n') {
buf++;
}
- if (sscanf(buf, "%lf-%lf", &a, &b) == 2)
- {
- if (a > b)
- {
+ if (sscanf(buf, "%lf-%lf", &a, &b) == 2) {
+ if (a > b) {
DCELL t;
t = a;
@@ -101,14 +96,12 @@
lp[count++] = a;
lp[count++] = b;
}
- else if (sscanf(buf, "%lf", &a) == 1)
- {
+ else if (sscanf(buf, "%lf", &a) == 1) {
lp = (DCELL *) G_realloc(lp, (count + 2) * sizeof(DCELL));
lp[count++] = a;
lp[count++] = a;
}
- else
- {
+ else {
G_free(lp);
return -1;
}
Modified: grass-addons/postscript/ps.output/vector.c
===================================================================
--- grass-addons/postscript/ps.output/vector.c 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/vector.c 2010-12-08 23:19:08 UTC (rev 44565)
@@ -47,13 +47,10 @@
{
int i, j;
- for (i = 0; i < vct->n_rule; i++)
- {
- for (j = 0; j < vct->rule[i].count; j++)
- {
- if (value >= vct->rule[i].val_list[j] &&
- value <= vct->rule[i].val_list[j + 1])
- {
+ for (i = 0; i < vct->n_rule; i++) {
+ for (j = 0; j < vct->rule[i].count; j++) {
+ if (value >= vct->rule[i].val_list[j] &&
+ value <= vct->rule[i].val_list[j + 1]) {
return i;
}
}
@@ -69,16 +66,13 @@
rule = vector_rule_find(vct, value);
/* Check if already exist */
- for (k = 0; k < vct->n_item; k++)
- {
- if (vct->item[k].rule == -1)
- {
+ for (k = 0; k < vct->n_item; k++) {
+ if (vct->item[k].rule == -1) {
if (vct->item[k].data == data)
return k;
}
- else
- {
- if (vct->item[k].rule == rule)
+ else {
+ if (vct->item[k].rule == rule)
return k;
}
}
Modified: grass-addons/postscript/ps.output/vpoints.h
===================================================================
--- grass-addons/postscript/ps.output/vpoints.h 2010-12-08 22:53:50 UTC (rev 44564)
+++ grass-addons/postscript/ps.output/vpoints.h 2010-12-08 23:19:08 UTC (rev 44565)
@@ -24,7 +24,7 @@
PSLINE line;
PSCOLOR fcolor;
- double size, scale, bias; /* standard size, scale and bias to draw */
+ double size, scale, bias; /* standard size, scale and bias to draw */
char *sizecol; /* size from database or rule */
double rotate; /* standard rotate */
More information about the grass-commit
mailing list