~ubuntu-branches/ubuntu/wily/grass/wily

« back to all changes in this revision

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

Tags: 7.0.0~rc1+ds1-1~exp1
* New upstream release candidate.
* Repack upstream tarball, remove precompiled Python objects.
* Add upstream metadata.
* Update gbp.conf and Vcs-Git URL to use the experimental branch.
* Update watch file for GRASS 7.0.
* Drop build dependencies for Tcl/Tk, add build dependencies:
  python-numpy, libnetcdf-dev, netcdf-bin, libblas-dev, liblapack-dev
* Update Vcs-Browser URL to use cgit instead of gitweb.
* Update paths to use grass70.
* Add configure options: --with-netcdf, --with-blas, --with-lapack,
  remove --with-tcltk-includes.
* Update patches for GRASS 7.
* Update copyright file, changes:
  - Update copyright years
  - Group files by license
  - Remove unused license sections
* Add patches for various typos.
* Fix desktop file with patch instead of d/rules.
* Use minimal dh rules.
* Bump Standards-Version to 3.9.6, no changes.
* Use dpkg-maintscript-helper to replace directories with symlinks.
  (closes: #776349)
* Update my email to use @debian.org address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
#include <stdlib.h>
7
7
#include <string.h>
8
 
#include "ps_info.h"
 
8
#include <grass/colors.h>
 
9
#include <grass/glocale.h>
 
10
#include "clr.h"
9
11
#include "local_proto.h"
10
12
 
11
13
#define KEY(x) (strcmp(x,key)==0)
16
18
    "cross      cross_size",
17
19
    "color      color",
18
20
    "numbers    # [color]",
 
21
    "width      #",
19
22
    ""
20
23
};
21
24
 
30
33
int getgrid(void)
31
34
{
32
35
    int spacing;
33
 
    int color = 0, fontsize = PS_FONT_DEFAULT_SIZE;
 
36
    int fontsize = PS_FONT_DEFAULT_SIZE;
 
37
    int ret, r, g, b;
34
38
    char temp[30];
35
39
    char buf[1024];
36
40
    char ch, *key, *data;
 
41
    PSCOLOR color, text_color;
37
42
 
38
43
    PS.grid_font = G_store("Helvetica");
39
44
    PS.grid_fontsize = 0;
40
 
    PS.grid_color = BLACK;
41
45
    PS.grid_numbers = 0;
42
46
    PS.grid_cross = 0.;
43
47
    PS.grid_width = 0.25;
 
48
    set_color(&color, 0, 0, 0);
 
49
    set_color(&text_color, 0, 0, 0);
44
50
 
45
51
    while (input(2, buf, help)) {
46
52
        if (!key_data(buf, &key, &data))
47
53
            continue;
48
54
 
49
55
        if (KEY("color")) {
50
 
            color = get_color_number(data);
51
 
            if (color < 0)
52
 
                error(key, data, "illegal color request");
 
56
            ret = G_str_to_color(data, &r, &g, &b); 
 
57
            if (ret == 1)
 
58
                set_color(&color, r, g, b);
 
59
            else if (ret == 2)  /* i.e. "none" */
 
60
                /* unset_color(&color); */
 
61
                error(key, data, _("Unsupported color request"));
53
62
            else
54
 
                PS.grid_color = color;
 
63
                error(key, data, _("illegal color request"));
 
64
 
55
65
            continue;
56
66
        }
57
67
 
60
70
 
61
71
            if (strlen(data) == 0) {
62
72
                spacing = 1;
63
 
                color = BLACK;
 
73
                set_color(&text_color, 0, 0, 0);
64
74
            }
65
75
 
66
76
            switch (sscanf(data, "%d %[^\n]", &spacing, temp)) {
67
77
            case 1:
68
 
                color = BLACK;
 
78
                set_color(&text_color, 0, 0, 0);
69
79
                break;
70
80
            case 2:
71
 
                color = get_color_number(temp);
72
 
                if (color < 0)
 
81
                ret = G_str_to_color(temp, &r, &g, &b);
 
82
                if (ret == 1)
 
83
                    set_color(&text_color, r, g, b);
 
84
                else if (ret == 2)  /* i.e. "none" */
 
85
                    error(key, data, _("Unsupported color request"));
 
86
                else
 
87
                    error(key, data, _("illegal color request"));
 
88
 
 
89
                if (ret < 1)
73
90
                    spacing = -1;
 
91
 
74
92
                break;
75
93
            }
76
94
            if (spacing < 0)
77
 
                error(key, data, "illegal numbers request");
 
95
                error(key, data, _("illegal numbers request"));
78
96
            else {
79
97
                PS.grid_numbers = spacing;
80
 
                PS.grid_numbers_color = color;
 
98
                PS.grid_numbers_color = text_color;
81
99
            }
82
100
            continue;
83
101
        }
105
123
            if ((sscanf(data, "%lf%c", &PS.grid_width, &ch) < 1) ||
106
124
                (PS.grid_width < 0.)) {
107
125
                PS.grid_width = 1.;
108
 
                error(key, data, "illegal grid width request");
 
126
                error(key, data, _("illegal grid width request"));
109
127
            }
110
128
            if (ch == 'i')
111
 
                PS.grid_width = PS.grid_width / 72.0;
 
129
                PS.grid_width = PS.grid_width * 72.0;
112
130
            continue;
113
131
        }
114
 
        error(key, data, "illegal request (getgrid)");
 
132
        error(key, data, _("illegal request (grid)"));
115
133
    }
116
134
 
117
135
    PS.grid_fontsize = fontsize;
 
136
    PS.grid_color = color;
118
137
 
119
138
    return 0;
120
139
}
125
144
int getgeogrid(void)
126
145
{
127
146
    int spacing;
128
 
    int color = 0, fontsize = PS_FONT_DEFAULT_SIZE;
 
147
    int fontsize = PS_FONT_DEFAULT_SIZE;
 
148
    int ret, r, g, b;
129
149
    char temp[30];
130
150
    char buf[1024];
131
151
    char ch, *key, *data;
 
152
    PSCOLOR color, text_color;
132
153
 
133
154
    PS.geogrid_font = G_store("Helvetica");
134
155
    PS.geogrid_fontsize = 0;
135
 
    PS.geogrid_color = BLACK;
136
156
    PS.geogrid_numbers = 0;
137
157
    PS.geogrid_width = 0.25;
 
158
    set_color(&color, 0, 0, 0);
 
159
    set_color(&text_color, 0, 0, 0);
138
160
 
139
161
    while (input(2, buf, help2)) {
140
162
        if (!key_data(buf, &key, &data))
141
163
            continue;
142
164
 
143
165
        if (KEY("color")) {
144
 
            color = get_color_number(data);
145
 
            if (color < 0)
146
 
                error(key, data, "illegal color request");
 
166
            ret = G_str_to_color(data, &r, &g, &b); 
 
167
            if (ret == 1)
 
168
                set_color(&color, r, g, b);
 
169
            else if (ret == 2)  /* i.e. "none" */
 
170
                /* unset_color(&color); */
 
171
                error(key, data, _("Unsupported color request"));
147
172
            else
148
 
                PS.geogrid_color = color;
 
173
                error(key, data, _("illegal color request"));
 
174
 
149
175
            continue;
150
176
        }
151
177
 
154
180
 
155
181
            if (strlen(data) == 0) {
156
182
                spacing = 1;
157
 
                color = BLACK;
 
183
                set_color(&text_color, 0, 0, 0);
158
184
            }
159
185
 
160
186
            switch (sscanf(data, "%d %[^\n]", &spacing, temp)) {
161
187
            case 1:
162
 
                color = BLACK;
 
188
                set_color(&text_color, 0, 0, 0);
163
189
                break;
164
190
            case 2:
165
 
                color = get_color_number(temp);
166
 
                if (color < 0)
 
191
                ret = G_str_to_color(temp, &r, &g, &b);
 
192
                if (ret == 1)
 
193
                    set_color(&text_color, r, g, b);
 
194
                else if (ret == 2)  /* i.e. "none" */
 
195
                    error(key, data, _("Unsupported color request"));
 
196
                else
 
197
                    error(key, data, _("illegal color request"));
 
198
 
 
199
                if (ret < 1)
167
200
                    spacing = -1;
 
201
 
168
202
                break;
169
203
            }
170
204
 
171
205
            if (spacing < 0)
172
 
                error(key, data, "illegal numbers request");
 
206
                error(key, data, _("illegal numbers request"));
173
207
            else {
174
208
                PS.geogrid_numbers = spacing;
175
 
                PS.geogrid_numbers_color = color;
 
209
                PS.geogrid_numbers_color = text_color;
176
210
            }
177
211
 
178
212
            continue;
197
231
            if ((sscanf(data, "%lf%c", &PS.geogrid_width, &ch) < 1) ||
198
232
                (PS.geogrid_width < 0.)) {
199
233
                PS.geogrid_width = 1.;
200
 
                error(key, data, "illegal grid width request");
 
234
                error(key, data, _("illegal grid width request"));
201
235
            }
202
236
            if (ch == 'i')
203
 
                PS.geogrid_width = PS.geogrid_width / 72.0;
 
237
                PS.geogrid_width = PS.geogrid_width * 72.0;
204
238
            continue;
205
239
        }
206
 
        error(key, data, "illegal request (getgrid)");
 
240
        error(key, data, _("illegal request (geogrid)"));
207
241
    }
208
242
 
209
243
    PS.geogrid_fontsize = fontsize;
 
244
    PS.geogrid_color = color;
210
245
 
211
246
    return 0;
212
247
}