2
#include <grass/raster.h>
6
static int x1, y1, x2, y2;
7
static View *pick_view, *zoom_view, *main_view;
8
static int target_flag;
9
static int cancel(void);
10
static int zoom1(int, int);
11
static int zoom2(int, int);
18
static Objects objects[] = {
19
MENU("CANCEL", cancel, &use),
20
INFO(" Mark first corner of window ", &use),
25
Input_pointer(objects);
29
static int zoom1( /* called by Input_pointer */
31
{ /* called by Input_pointer */
33
static Objects objects[] = {
34
MENU("CANCEL", cancel, &use),
35
INFO(" Define the window ", &use),
41
* user has marked first corner
42
* this determines which view is being zoomed
47
if (In_view(pick_view = VIEW_MAP1, x1, y1)) {
48
main_view = VIEW_MAP1;
49
zoom_view = VIEW_MAP1_ZOOM;
53
else if (In_view (pick_view = VIEW_MAP2, x1, y1))
55
if (!pick_view->cell.configured)
56
return 0; *//* ignore the mouse event *//*
57
main_view = VIEW_MAP2;
58
zoom_view = VIEW_MAP2_ZOOM;
62
else if (In_view(pick_view = VIEW_MAP1_ZOOM, x1, y1)) {
63
if (!pick_view->cell.configured)
64
return 0; /* ignore the mouse event */
65
main_view = VIEW_MAP1;
66
zoom_view = VIEW_MAP1_ZOOM;
70
else if (In_view (pick_view = VIEW_MAP2_ZOOM, x1, y1))
72
if (!pick_view->cell.configured)
73
return 0; *//* ignore the mouse event *//*
74
main_view = VIEW_MAP2;
75
zoom_view = VIEW_MAP2_ZOOM;
80
return 0; /* ignore the mouse event */
81
if (!pick_view->cell.configured)
82
return 0; /* just to be sure */
84
return Input_box(objects, x, y);
87
static int zoom2(int x, int y)
89
int top, bottom, left, right;
91
struct Cell_head cellhd;
96
* user has completed the zoom window.
97
* must be in same view as first corner
99
if (x1 == x2 || y1 == y2)
100
return 0; /* ignore event */
101
if (!In_view(pick_view, x2, y2))
104
* ok, erase menu messages
109
* assign window coordinates to top,bottom,left,right
129
* Determine the the zoom window (ie, cellhd)
130
* must copy the current view cellhd first, to preserve header info
131
* (such as projection, zone, and other items.)
132
* compute zoom window northings,eastings, rows, cols, and resolution
135
G_copy(&cellhd, &pick_view->cell.head, sizeof(cellhd));
137
/* convert top to northing at top edge of cell
138
* left to easting at left edge
140
col = view_to_col(pick_view, left);
141
row = view_to_row(pick_view, top);
142
cellhd.north = row_to_northing(&pick_view->cell.head, row, 0.0);
143
cellhd.west = col_to_easting(&pick_view->cell.head, col, 0.0);
145
/* convert bottom to northing at bottom edge of cell
146
* right to easting at right edge
148
col = view_to_col(pick_view, right);
149
row = view_to_row(pick_view, bottom);
150
cellhd.south = row_to_northing(&pick_view->cell.head, row, 1.0);
151
cellhd.east = col_to_easting(&pick_view->cell.head, col, 1.0);
154
cellhd.rows = bottom - top + 1;
155
cellhd.cols = right - left + 1;
156
cellhd.ns_res = (cellhd.north - cellhd.south) / cellhd.rows;
157
cellhd.ew_res = (cellhd.east - cellhd.west) / cellhd.cols;
160
* Outline the zoom window on the main map
161
* Turn previous one to grey.
163
if (zoom_view->cell.configured) {
164
R_standard_color(GREY);
165
Outline_cellhd(main_view, &zoom_view->cell.head);
167
R_standard_color(RED);
168
Outline_cellhd(main_view, &cellhd);
176
G_adjust_window_to_box(&cellhd, &zoom_view->cell.head, zoom_view->nrows,
178
Configure_view(zoom_view, pick_view->cell.name, pick_view->cell.mapset,
179
pick_view->cell.ns_res, pick_view->cell.ew_res);
181
select_current_env();
182
display_ref_points(1);
183
return 1; /* pop back */
187
static int cancel(void)