2
/****************************************************************************
5
* AUTHOR(S): James Westervelt, U.S. Army CERL (original contributor)
6
* Michael Shapiro, U.S. Army CERL (original contributor)
7
* Markus Neteler <neteler itc.it>
8
* Bernhard Reiter <bernhard intevation.de>, Eric G. Miller <egm2 jps.net>,
9
* Glynn Clements <glynn gclements.plus.com>, Hamish Bowman <hamish_b yahoo.com>,
10
* Jan-Oliver Wagner <jan intevation.de>
12
* COPYRIGHT: (C) 1999-2007 by the GRASS Development Team
14
* This program is free software under the GNU General Public
15
* License (>=v2). Read the file COPYING that comes with GRASS
18
*****************************************************************************/
20
* d.frame [-cps] [frame=name] [at=bottom,top,left,right]
22
* at=... create frame here (implies -c)
23
* top, bottom, left, and right are % coordinates of window;
24
* 0,0 is lower left; 100,100 is upper right
29
#include <grass/gis.h>
30
#include <grass/display.h>
31
#include <grass/raster.h>
32
#include <grass/glocale.h>
37
int main(int argc, char *argv[])
40
int create, select, print, debug, list;
41
struct GModule *module;
44
struct Option *frame, *at;
52
struct Flag *printall;
59
module = G_define_module();
60
module->keywords = _("display, setup");
62
_("Manages display frames on the user's graphics monitor.");
64
flag.create = G_define_flag();
65
flag.create->key = 'c';
66
flag.create->description = _("Create a new frame");
68
flag.select = G_define_flag();
69
flag.select->key = 's';
70
flag.select->description = _("Select a frame");
72
flag.erase = G_define_flag();
73
flag.erase->key = 'e';
74
flag.erase->description = _("Remove all frames and erase the screen");
76
flag.print = G_define_flag();
77
flag.print->key = 'p';
78
flag.print->description = _("Print name of current frame");
80
flag.printall = G_define_flag();
81
flag.printall->key = 'a';
82
flag.printall->description = _("Print names of all frames");
84
flag.list = G_define_flag();
86
flag.list->description = _("List map names displayed in GRASS monitor");
88
flag.debug = G_define_flag();
89
flag.debug->key = 'D';
90
flag.debug->description = _("Debugging output");
92
parm.frame = G_define_option();
93
parm.frame->key = "frame";
94
parm.frame->type = TYPE_STRING;
95
parm.frame->key_desc = _("name");
96
parm.frame->required = NO;
97
parm.frame->multiple = NO;
98
parm.frame->description = _("Frame to be created/selected");
100
parm.at = G_define_option();
102
parm.at->key_desc = _("bottom,top,left,right");
103
parm.at->type = TYPE_DOUBLE;
104
parm.at->required = NO;
105
parm.at->multiple = NO;
106
parm.at->description =
107
_("Where to place the frame, values in percent (implies -c)");
108
parm.at->checker = check_at;
110
if (G_parser(argc, argv))
113
create = flag.create->answer;
114
print = flag.print->answer;
115
select = flag.select->answer;
116
debug = flag.debug->answer;
117
list = flag.list->answer;
119
/* if frame name is given without a control option, treat it as select */
120
if (parm.frame->answer && (!create && !print && !select && !list))
123
/* at= placement implies creation */
127
if (flag.erase->answer) {
128
if (R_open_driver() != 0)
129
G_fatal_error(_("No graphics device selected"));
135
R_standard_color(D_translate_color(DEFAULT_BG_COLOR));
144
sprintf(buf, "%s/etc/frame.create", G_gisbase());
145
if (parm.frame->answer) {
146
strcat(buf, " frame='");
147
strcat(buf, parm.frame->answer);
150
if (parm.at->answer) {
151
strcat(buf, " at='");
152
strcat(buf, parm.at->answer);
159
sprintf(buf, "%s/etc/frame.select", G_gisbase());
160
if (parm.frame->answer) {
161
strcat(buf, " frame='");
162
strcat(buf, parm.frame->answer);
170
sprintf(buf, "%s/etc/frame.dumper", G_gisbase());
176
sprintf(buf, "%s/etc/frame.list", G_gisbase());
182
if (R_open_driver() != 0)
183
G_fatal_error(_("No graphics device selected"));
187
fprintf(stdout, "%s\n", buf);
190
if (flag.printall->answer)
198
int check_at(char *s)
200
float top, bottom, left, right;
206
if (4 != sscanf(s, "%f,%f,%f,%f", &bottom, &top, &left, &right)
207
|| bottom < 0.0 || top > 100.0 || bottom >= top
208
|| left < 0.0 || right > 100.0 || left >= right) {
209
fprintf(stderr, "<at=%s> invalid request\n", s);
222
if (R_open_driver() != 0)
223
G_fatal_error(_("No graphics device selected"));
225
R_pad_list(&pads, &npads);
227
for (p = npads - 1; p >= 0; p--)
228
fprintf(stdout, "%s\n", pads[p]);