35
35
G_message(_("Creating color table for <%s in %s>..."),
36
36
ct.name, ct.mapset);
38
if (G_read_cats(ct.name, ct.mapset, &PS.cats) == -1) {
38
if (Rast_read_cats(ct.name, ct.mapset, &PS.cats) == -1) {
39
39
G_warning(_("Category file for <%s> not available"), ct.name);
43
if (G_read_colors(ct.name, ct.mapset, &colors) == -1)
43
if (Rast_read_colors(ct.name, ct.mapset, &colors) == -1)
44
44
G_warning(_("Unable to read colors for colorbar"));
46
rast_type = G_raster_map_type(ct.name, ct.mapset);
46
rast_type = Rast_map_type(ct.name, ct.mapset);
48
48
do_color = (PS.grey == 0 && PS.level == 2);
50
50
/* How many categories to show */
51
num_cats = G_number_of_raster_cats(&PS.cats);
51
num_cats = Rast_number_of_cats(&PS.cats);
52
52
G_debug(3, "clrtbl: %d categories", num_cats);
54
54
G_warning(_("Your cats/ file is invalid. A cats/ file with categories "
80
80
if (ct.width <= 0.0 || ct.width > PS.page_width - PS.right_marg - ct.x)
81
81
ct.width = PS.page_width - PS.right_marg - ct.x;
83
r = l + 72.0 * ct.width;
83
/* r = l + 72.0 * ct.width; */ /* unused */
84
84
col_width = ct.width / (double)ct.cols;
86
86
G_debug(3, "clrtbl: adjusted ct.x=[%.3f] ct.y=[%.3f] ct.width=[%.3f] "
95
95
fprintf(PS.fp, "(%s)\n", "no data");
97
97
fprintf(PS.fp, "(%s)\n",
98
G_get_ith_d_raster_cat(&PS.cats, i - 1, &dmin, &dmax));
98
Rast_get_ith_d_cat(&PS.cats, i - 1, &dmin, &dmax));
99
99
G_debug(5, "i=%d dmin=%f dmax=%f catlabel=[%s]", i, dmin, dmax,
100
G_get_ith_d_raster_cat(&PS.cats, i - 1, &dmin, &dmax));
100
Rast_get_ith_d_cat(&PS.cats, i - 1, &dmin, &dmax));
103
103
fprintf(PS.fp, "] def\n");
147
147
/* fill box and outline in black */
149
label = G_get_ith_d_raster_cat(&PS.cats, i - 1, &dmin, &dmax);
149
label = Rast_get_ith_d_cat(&PS.cats, i - 1, &dmin, &dmax);
150
150
G_debug(5, "j=%d i=%d label=[%s]", j, i, label);
155
155
x2 = x1 + fontsize;
157
if (!i || dmax == dmin)
157
if (!i || dmax == dmin) {
158
158
/* draw a 1-color rectangle */
160
160
/* set box fill color */
162
G_get_null_value_color(&R, &G, &B, &colors);
162
Rast_get_null_value_color(&R, &G, &B, &colors);
164
164
if (rast_type == CELL_TYPE) {
165
165
CELL cmin = (CELL)dmin;
166
G_get_c_raster_color(&cmin, &R, &G, &B, &colors);
166
Rast_get_c_color(&cmin, &R, &G, &B, &colors);
168
168
else if (rast_type == FCELL_TYPE) {
169
169
FCELL fmin = (FCELL)dmin;
170
G_get_f_raster_color(&fmin, &R, &G, &B, &colors);
170
Rast_get_f_color(&fmin, &R, &G, &B, &colors);
172
172
else if (rast_type == DCELL_TYPE)
173
G_get_raster_color(&dmin, &R, &G, &B, &colors, rast_type);
173
Rast_get_color(&dmin, &R, &G, &B, &colors, rast_type);
174
174
else G_fatal_error("Please contact development team");
176
176
G_debug(5, " dmin=%f RGB=%d:%d:%d", dmin, R, G, B);
199
199
/* grey border fprintf(PS.fp, "B F .247 .247 .247 C 1 W stroke\n"); */
200
200
fprintf(PS.fp, "B F ");
201
201
set_ps_color(&ct.color);
202
fprintf(PS.fp, "1 W stroke\n");
202
fprintf(PS.fp, "%.2f W stroke\n", ct.lwidth);
205
205
/* split the rectangle into NSTEPS horizontal strips and
206
206
draw each with the corresponding value's color */
208
208
for (jj = 0; jj < NSTEPS; jj++) {
209
209
/* set box fill color */
210
210
val = dmin + (double)jj *(dmax - dmin) / NSTEPS;
212
G_get_d_raster_color(&val, &R, &G, &B, &colors);
212
Rast_get_d_color(&val, &R, &G, &B, &colors);
213
213
fprintf(PS.fp, "%.3f %.3f %.3f C\n",
214
214
(double)R / 255., (double)G / 255.,
215
215
(double)B / 255.);
226
226
fprintf(PS.fp, "B CF stroke\n");
227
227
} /* done filling the box */
229
/* outline the box in black */
229
/* outline the box in the specified color, see above */
230
230
fprintf(PS.fp, "%.1f ", x1);
232
232
fprintf(PS.fp, "mvx ");
236
236
fprintf(PS.fp, "mvx ");
237
237
fprintf(PS.fp, "%.1f ", y + fontsize);
238
fprintf(PS.fp, "B BW stroke\n");
238
fprintf(PS.fp, "B ");
239
set_ps_color(&ct.color);
240
fprintf(PS.fp, "%.2f W stroke\n", ct.lwidth);
239
242
} /* done drawing the box */
241
244
/* do the text */