71
73
DCELL dmin, dmax, range_dmin, range_dmax, dval;
73
/* get coordinates of current screen window, in pixels */
74
D_get_screen_window(&t, &b, &l, &r);
75
R_set_window(t, b, l, r);
75
/* get coordinates of current screen window */
76
D_get_src(&t, &b, &l, &r);
77
78
/* create legend box border, to be drawn later */
80
x_line[4] = x_line[0] = x_line[1] = l + (int)(BAR_X1 * width);
81
y_line[4] = y_line[0] = y_line[3] = b - (int)(BAR_Y1 * height);
82
x_line[2] = x_line[3] = l + (int)(BAR_X2 * width);
83
bar_height = y_line[1] = y_line[2] = b - (int)(BAR_Y2 * height);
81
x_line[4] = x_line[0] = x_line[1] = l + (BAR_X1 * width);
82
y_line[4] = y_line[0] = y_line[3] = b - (BAR_Y1 * height);
83
x_line[2] = x_line[3] = l + (BAR_X2 * width);
84
bar_height = y_line[1] = y_line[2] = b - (BAR_Y2 * height);
85
86
/* figure scaling factors and offsets */
86
87
num_cats = dist_stats->maxcat - dist_stats->mincat + 1;
169
G_set_d_null_value(&dval, 1);
170
arc = (double)360 *((double)dist_stats->null_stat
170
Rast_set_d_null_value(&dval, 1);
171
arc = 360.0 *((double)dist_stats->null_stat
171
172
/ (double)dist_stats->sumstat);
172
draw_slice_filled(colors, dval, (int)color, (double)ORIGIN_X,
173
(double)ORIGIN_Y, (double)RADIUS,
173
draw_slice_filled(colors, dval, color, ORIGIN_X,
174
175
arc_counter, arc);
175
176
/*OUTLINE THE SLICE
176
draw_slice_unfilled(colors, (int)color,(double)ORIGIN_X,(double)ORIGIN_Y,
177
(double)RADIUS,arc_counter,arc); */
177
draw_slice_unfilled(colors, color,ORIGIN_X,ORIGIN_Y,
178
RADIUS,arc_counter,arc); */
178
179
arc_counter += arc;
179
180
D_d_color(dval, colors);
189
G_get_ith_d_raster_cat(&cats, (CELL) i, &dmin, &dmax);
190
Rast_get_ith_d_cat(&cats, (CELL) i, &dmin, &dmax);
192
range_dmin + (double)i *(range_dmax -
196
range_dmin + (double)(i + 1) * (range_dmax -
192
dmin = range_dmin + i * (range_dmax - range_dmin) / nsteps;
193
dmax = range_dmin + (i + 1) * (range_dmax - range_dmin) / nsteps;
201
(double)360 *((double)ptr->stat /
202
(double)dist_stats->sumstat);
203
draw_slice(colors, 1, dmin, dmax, (int)color,
204
(double)ORIGIN_X, (double)ORIGIN_Y,
205
(double)RADIUS, arc_counter, arc);
195
arc = 360.0 * ptr->stat / dist_stats->sumstat;
196
draw_slice(colors, 1, dmin, dmax, color, ORIGIN_X, ORIGIN_Y,
197
RADIUS, arc_counter, arc);
206
198
arc_counter += arc;
207
199
D_d_color(dmin, colors);
208
200
/*OUTLINE THE SLICE */
209
draw_slice_unfilled(colors, (int)color, (double)ORIGIN_X,
210
(double)ORIGIN_Y, (double)RADIUS,
201
draw_slice_unfilled(colors, color, ORIGIN_X,
211
203
arc_counter, arc);
214
206
bar_color = ptr->cat;
216
(double)360 *((double)ptr->stat /
217
(double)dist_stats->sumstat);
218
draw_slice_filled(colors, (DCELL) bar_color, (int)color,
219
(double)ORIGIN_X, (double)ORIGIN_Y,
220
(double)RADIUS, arc_counter, arc);
207
arc = 360.0 * ptr->stat / dist_stats->sumstat;
208
draw_slice_filled(colors, (DCELL) bar_color, color,
210
RADIUS, arc_counter, arc);
221
211
D_color((CELL) bar_color, colors);
222
212
arc_counter += arc;
240
G_get_ith_d_raster_cat(&cats, (CELL) i, &dmin,
230
Rast_get_ith_d_cat(&cats, (CELL) i, &dmin, &dmax);
244
range_dmin + (double)i *(range_dmax -
248
range_dmin + (double)(i + 1) * (range_dmax -
232
dmin = range_dmin + i * (range_dmax - range_dmin) / nsteps;
233
dmax = range_dmin + (i + 1) * (range_dmax - range_dmin) / nsteps;
253
(double)360 *((double)ptr->stat /
254
(double)dist_stats->sumstat);
255
draw_slice(colors, 1, dmin, dmax, (int)color,
256
(double)ORIGIN_X, (double)ORIGIN_Y,
257
(double)RADIUS, arc_counter, arc);
235
arc = 360.0 * ptr->stat / dist_stats->sumstat;
236
draw_slice(colors, 1, dmin, dmax, color,
238
RADIUS, arc_counter, arc);
258
239
arc_counter += arc;
259
240
/*OUTLINE THE SLICE */
260
draw_slice_unfilled(colors, (int)color,
262
(double)ORIGIN_Y, (double)RADIUS,
241
draw_slice_unfilled(colors, color,
263
244
arc_counter, arc);
264
245
D_d_color(dmin, colors);
267
248
bar_color = ptr->cat;
269
(double)360 *((double)ptr->stat /
270
(double)dist_stats->sumstat);
249
arc = 360.0 * ptr->stat / dist_stats->sumstat;
271
250
draw_slice_filled(colors, (DCELL) bar_color,
272
(int)color, (double)ORIGIN_X,
273
(double)ORIGIN_Y, (double)RADIUS,
274
253
arc_counter, arc);
275
254
D_color((CELL) bar_color, colors);
276
255
arc_counter += arc;
347
325
if ((rem((long int)i, tic_every) == 0L ||
348
326
((i == dist_stats->mincat) && nodata))
349
327
&& !(nodata && i == dist_stats->mincat + 1)) {
350
329
/* draw a numbered tic-mark */
351
R_standard_color(color);
353
(xoffset + (i - dist_stats->mincat) * xscale -
354
0.5 * xscale), (int)(b - BAR_Y1 * (height)));
355
R_cont_rel((int)0, (int)(BIG_TIC * (height)));
333
+ (i - dist_stats->mincat) * xscale
335
b - BAR_Y1 * height);
336
D_cont_rel(0, BIG_TIC * height);
356
340
if (nodata && i == dist_stats->mincat)
357
341
sprintf(txt, "null");
359
343
sprintf(txt, "%d", (int)(dmin / (double)tic_unit));
361
345
sprintf(txt, "%d", (int)(i / tic_unit));
362
text_height = (height) * TEXT_HEIGHT;
363
text_width = (width) * TEXT_WIDTH;
364
R_text_size(text_width, text_height);
365
R_get_text_box(txt, &tt, &tb, &tl, &tr);
346
text_height = height * TEXT_HEIGHT;
347
text_width = width * TEXT_WIDTH;
348
D_text_size(text_width, text_height);
349
D_get_text_box(txt, &tt, &tb, &tl, &tr);
366
350
while ((tr - tl) > XTIC_DIST) {
367
351
text_width *= 0.95;
368
352
text_height *= 0.95;
369
R_text_size(text_width, text_height);
370
R_get_text_box(txt, &tt, &tb, &tl, &tr);
353
D_text_size(text_width, text_height);
354
D_get_text_box(txt, &tt, &tb, &tl, &tr);
373
(xoffset + (i - dist_stats->mincat) * xscale -
374
0.5 * xscale - (tr - tl) / 2),
375
(int)(b - XNUMS_Y * (height)));
357
+ (i - dist_stats->mincat) * xscale
360
b - XNUMS_Y * height);
378
else if (rem(i, tic_unit) == (float)0) {
363
else if (rem(i, tic_unit) == 0.0) {
379
364
/* draw a tic-mark */
380
R_standard_color((int)color);
382
(xoffset + (i - dist_stats->mincat) * xscale -
383
0.5 * xscale), (int)(b - BAR_Y1 * (height)));
384
R_cont_rel((int)0, (int)(SMALL_TIC * (height)));
368
+ (i - dist_stats->mincat) * xscale
370
b - BAR_Y1 * height);
371
D_cont_rel(0, SMALL_TIC * height);
388
377
/* draw border around pie */
389
R_standard_color((int)color);
390
draw_slice_unfilled(colors, (int)color, (double)ORIGIN_X,
391
(double)ORIGIN_Y, (double)RADIUS, (double)0,
379
draw_slice_unfilled(colors, color, ORIGIN_X, ORIGIN_Y, RADIUS, 0.0, 360.0);
394
381
/* draw border around legend bar */
395
R_standard_color((int)color);
396
R_polyline_abs(x_line, y_line, 5);
383
D_polyline_abs(x_line, y_line, 5);
398
385
/* draw the x-axis label */
399
386
if (tic_unit != 1)
400
387
sprintf(xlabel, "Cell Values %s", tic_name);
402
389
sprintf(xlabel, "Cell Values");
403
text_height = (height) * TEXT_HEIGHT;
404
text_width = (width) * TEXT_WIDTH;
405
R_text_size(text_width, text_height);
406
R_get_text_box(xlabel, &tt, &tb, &tl, &tr);
407
R_move_abs((int)(l + (width) / 2 - (tr - tl) / 2),
408
(int)(b - LABEL * (height)));
409
R_standard_color((int)color);
390
text_height = height * TEXT_HEIGHT;
391
text_width = width * TEXT_WIDTH;
392
D_text_size(text_width, text_height);
393
D_get_text_box(xlabel, &tt, &tb, &tl, &tr);
394
D_pos_abs(l + width / 2 - (tr - tl) / 2,