~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to ps/ps.map/ps_clrtbl.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 ** Author: Paul W. Carlson     April 1992
4
4
 */
5
5
 
 
6
#include <grass/raster.h>
6
7
#include <grass/glocale.h>
7
 
#include "ps_info.h"
8
8
#include "colortable.h"
9
9
#include "local_proto.h"
10
10
 
24
24
    int center_cols;
25
25
    DCELL dmin, dmax, val;
26
26
    struct Colors colors;
27
 
    double t, l, r;
 
27
    double t, l /*, r */;
28
28
    double x1, x2, y, dy, fontsize, tl;
29
29
    double col_width;
30
30
    int do_color;
35
35
    G_message(_("Creating color table for <%s in %s>..."),
36
36
              ct.name, ct.mapset);
37
37
 
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);
40
40
        return 1;
41
41
    }
42
42
 
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"));
45
45
 
46
 
    rast_type = G_raster_map_type(ct.name, ct.mapset);
 
46
    rast_type = Rast_map_type(ct.name, ct.mapset);
47
47
 
48
48
    do_color = (PS.grey == 0 && PS.level == 2);
49
49
 
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);
53
53
    if (!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;
82
82
 
83
 
    r = l + 72.0 * ct.width;
 
83
    /* r = l + 72.0 * ct.width; */ /* unused */
84
84
    col_width = ct.width / (double)ct.cols;
85
85
 
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");
96
96
        else {
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));
101
101
        }
102
102
    }
103
103
    fprintf(PS.fp, "] def\n");
146
146
 
147
147
            /* fill box and outline in black */
148
148
            if (i) {
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);
151
151
            }
152
152
 
154
154
 
155
155
            x2 = x1 + fontsize;
156
156
 
157
 
            if (!i || dmax == dmin)
 
157
            if (!i || dmax == dmin) {
158
158
                /* draw a 1-color rectangle */
159
 
            {
 
159
 
160
160
                /* set box fill color */
161
161
                if (!i)
162
 
                    G_get_null_value_color(&R, &G, &B, &colors);
 
162
                    Rast_get_null_value_color(&R, &G, &B, &colors);
163
163
                else {
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);
167
167
                    }
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);
171
171
                    }
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");
175
175
 
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);
203
203
            }
204
 
            else
 
204
            else {
205
205
                /* split the rectangle into NSTEPS horizontal strips and
206
206
                   draw each with the corresponding value's color */
207
 
            {
 
207
 
208
208
                for (jj = 0; jj < NSTEPS; jj++) {
209
209
                    /* set box fill color */
210
210
                    val = dmin + (double)jj *(dmax - dmin) / NSTEPS;
211
211
 
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 */
228
228
 
229
 
                /* outline the box in black */
 
229
                /* outline the box in the specified color, see above */
230
230
                fprintf(PS.fp, "%.1f ", x1);
231
231
                if (center_cols)
232
232
                    fprintf(PS.fp, "mvx ");
235
235
                if (center_cols)
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);
 
241
 
239
242
            }   /* done drawing the box */
240
243
 
241
244
            /* do the text */
254
257
    if (PS.min_y > y)
255
258
        PS.min_y = y;
256
259
 
257
 
    G_free_colors(&colors);
 
260
    Rast_free_colors(&colors);
258
261
 
259
262
    return 0;
260
263
}