GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
get_win.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <grass/raster.h>
3 
4 int get_win_w_mouse(float *top, float *bottom, float *left, float *right)
5 {
6  int button;
7  int st, sb, sl, sr;
8  int t, b, l, r;
9 
10  st = R_screen_top();
11  sb = R_screen_bot();
12  sl = R_screen_left();
13  sr = R_screen_rite();
14 
15  fprintf(stderr, "\nButtons:\n");
16  fprintf(stderr, "Left: Establish a corner\n");
17  fprintf(stderr, "Right: Accept window\n");
18 
19  l = sl;
20  b = sb;
21  r = l + 10;
22  t = b - 10;
23 
24  do {
25  R_get_location_with_box(l, b, &r, &t, &button);
26  if (button == 1) {
27  l = r;
28  b = t;
29  }
30  } while (button != 3);
31 
32  if (l > r) {
33  button = l;
34  l = r;
35  r = button;
36  }
37 
38  if (t > b) {
39  button = t;
40  t = b;
41  b = button;
42  }
43  *bottom = 100. - 100. * (b - st) / (sb - st);
44  *top = 100. - 100. * (t - st) / (sb - st);
45  *left = 100. * (l - sl) / (sr - sl);
46  *right = 100. * (r - sl) / (sr - sl);
47 
48  return 0;
49 }
int l
Definition: dataquad.c:292
float b
Definition: named_colr.c:8
int R_screen_bot(void)
bottom of screen
Definition: com_proto.c:52
float r
Definition: named_colr.c:8
int R_screen_rite(void)
screen right edge
Definition: com_proto.c:38
int R_screen_left(void)
screen left edge
Definition: com_proto.c:24
int R_screen_top(void)
top of screen
Definition: com_proto.c:67
int get_win_w_mouse(float *top, float *bottom, float *left, float *right)
Definition: get_win.c:4
void R_get_location_with_box(int cx, int cy, int *wx, int *wy, int *button)
Definition: com_get.c:7