File: list.c

package info (click to toggle)
grass 6.4.4-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 104,028 kB
  • ctags: 40,409
  • sloc: ansic: 419,980; python: 63,559; tcl: 46,692; cpp: 29,791; sh: 18,564; makefile: 7,000; xml: 3,505; yacc: 561; perl: 559; lex: 480; sed: 70; objc: 7
file content (268 lines) | stat: -rw-r--r-- 5,721 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
/*  Routines to manage the graphics window contents list
 *
 * D_clear_window()
 *     Removes all information about current window
 *
 * D_add_to_list(string)
 *     Adds string to growing list of screen contents.
 *     "string" is, by convention, a command string.
 *
 * D_get_list(list,count)
 *     returns the list of the commands for the maps currently displayed
 *
 * D_set_cell_name(name)
 *     sets the name of the cell file currently displayed
 *
 * D_get_cell_name(name)
 *     returns the name of the cell file currently displayed
 *
 * D_set_dig_name(name)
 *     sets the name of the dig file currently displayed
 *
 * D_get_dig_name(name)
 *     returns the name of the dig file currently displayed
 *
 * D_set_site_name(name)
 *     sets the name of the site_lists file currently displayed
 *
 * D_get_site_name(name)
 *     returns the name of the site_lists file currently displayed
 *
 * D_add_to_cell_list(name)
 *     adds the name of the cell file currently displayed to cell_list
 *
 * D_get_cell_list(list,count)
 *     returns the list of the cell_list currently displayed
 *
 * D_add_to_dig_list(name)
 *     adds the name of the dig file currently displayed to dig_list
 *
 * D_get_dig_list(list,count)
 *     returns the list of the dig_list currently displayed
 *
 * D_add_to_site_list(name)
 *     adds the name of the site_lists file currently displayed to site_list
 *
 * D_get_site_list(list,count)
 *     returns the list of the site_list currently displayed
 *
 * D_set_erase_color(color)
 *     sets the color name of the current erase color for the window
 *
 * D_get_erase_color(color)
 *     returns the current erase color name for window
 *
 */

#include <string.h>
#include <stdio.h>
#include <grass/display.h>
#include <grass/raster.h>


/*!
 * \brief add raster map name to display list
 *
 * Stores the raster\remarks{As with the change from <i>window</i> to
 * <i>frame</i>, GRASS 4.0 changed word usage from <i>cell</i> to
 * <i>raster.</i> For compatibility with existing code, the routines have not
 * changed their names.} map <b>name</b> in the information associated with
 * the current frame.
 *
 *  \param name
 *  \return int
 */

int D_set_cell_name(const char *name)
{
    R_pad_delete_item("cell");

    return (R_pad_set_item("cell", name));
}


/*!
 * \brief retrieve raster map name
 *
 * Returns the <b>name</b> of the raster map associated with the current frame.
 *
 *  \param name
 *  \return int
 */

int D_get_cell_name(char *name)
{
    int stat;
    char **list;
    int count;

    if ((stat = R_pad_get_item("cell", &list, &count)))
	return (-1);

    strcpy(name, list[0]);

    R_pad_freelist(list, count);
    return (0);
}


/*!
 * \brief add vector map name to display list
 *
 * Stores the vector map <b>name</b> in the information associated with
 * the current frame.
 *
 *  \param name
 *  \return int
 */

int D_set_dig_name(const char *name)
{
    R_pad_delete_item("dig");

    return (R_pad_set_item("dig", name));
}


/*!
 * \brief retrieve vector map name
 *
 * Returns the <b>name</b> of the vector map associated with the current frame.
 *
 *  \param name
 *  \return int
 */

int D_get_dig_name(char *name)
{
    int stat;
    char **list;
    int count;

    if ((stat = R_pad_get_item("dig", &list, &count)))
	return (-1);

    strcpy(name, list[0]);

    R_pad_freelist(list, count);
    return (0);
}


int D_add_to_cell_list(const char *name)
{
    return (R_pad_append_item("cell_list", name, 1));
}

int D_get_cell_list(char ***list, int *count)
{
    int stat;

    if ((stat = R_pad_get_item("cell_list", list, count)))
	return (-1);

    return (0);
}

int D_add_to_dig_list(const char *name)
{
    return (R_pad_append_item("dig_list", name, 1));
}

int D_get_dig_list(char ***list, int *count)
{
    int stat;

    if ((stat = R_pad_get_item("dig_list", list, count)))
	return (-1);

    return (0);
}


/*!
 * \brief add command to frame display list
 *
 * Adds <b>string</b> to list of screen contents. By convention,
 * <b>string</b> is a command string which could be used to recreate a part of
 * the graphics contents. This should be done for all screen graphics except for
 * the display of raster maps. The <i>D_set_cell_name</i> routine,the
 * <i>D_set_dig_name</i> routine and the <i>D_set_site_name</i> routine
 * are used for this special case.
 *
 *  \param string
 *  \return int
 */

int D_add_to_list(const char *string)
{
    return (R_pad_append_item("list", string, 0));
}

int D_get_list(char ***list, int *count)
{
    int stat;

    if ((stat = R_pad_get_item("list", list, count)))
	return (-1);

    return (0);
}


/*!
 * \brief clears information about current frame
 *
 * Removes all information about the current frame. This includes the map region and the
 * frame content lists.
 *
 *  \param ~
 *  \return int
 */


/*!
 * \brief clear frame display lists
 *
 * Removes all display information lists associated with the current frame.
 *
 *  \param ~
 *  \return int
 */

int D_clear_window(void)
{
    R_pad_delete_item("list");
    R_pad_delete_item("cell");
    R_pad_delete_item("dig");
    R_pad_delete_item("site");
    R_pad_delete_item("cell_list");
    R_pad_delete_item("dig_list");
    R_pad_delete_item("site_list");
    R_pad_delete_item("m_win");
    R_pad_delete_item("erase");
    return 0;
}

int D_set_erase_color(const char *colorname)
{
    R_pad_delete_item("erase");

    return (R_pad_set_item("erase", colorname));
}


int D_get_erase_color(char *colorname)
{
    int stat;
    char **list;
    int count;

    if ((stat = R_pad_get_item("erase", &list, &count)))
	return (-1);

    strcpy(colorname, list[0]);

    R_pad_freelist(list, count);
    return (0);
}