3
#include <grass/raster.h>
7
static View *pick_view, *zoom_view, *main_view;
8
static int target_flag;
9
static int zoom1(int, int);
10
static int cancel(void);
17
static Objects objects[] = {
18
MENU("CANCEL", cancel, &use),
19
INFO(" Mark center of area to be zoomed ", &use),
24
Input_pointer(objects);
28
static int zoom1(int x, int y)
29
{ /* called by Input_pointer */
30
int top, bottom, left, right;
33
struct Cell_head cellhd;
35
double north, south, east, west;
37
if (In_view(pick_view = VIEW_MAP1, x, y)) {
38
main_view = VIEW_MAP1;
39
zoom_view = VIEW_MAP1_ZOOM;
43
else if (In_view (pick_view = VIEW_MAP2, x, y))
45
if (!pick_view->cell.configured)
46
return 0; *//* ignore the mouse event *//*
47
main_view = VIEW_MAP2;
48
zoom_view = VIEW_MAP2_ZOOM;
52
else if (In_view(pick_view = VIEW_MAP1_ZOOM, x, y)) {
53
if (!pick_view->cell.configured)
54
return 0; /* ignore the mouse event */
55
main_view = VIEW_MAP1;
56
zoom_view = VIEW_MAP1_ZOOM;
60
else if (In_view (pick_view = VIEW_MAP2_ZOOM, x, y))
62
if (!pick_view->cell.configured)
63
return 0; *//* ignore the mouse event *//*
64
main_view = VIEW_MAP2;
65
zoom_view = VIEW_MAP2_ZOOM;
70
return 0; /* ignore the mouse event */
71
if (!pick_view->cell.configured)
72
return 0; /* just to be sure */
74
* make sure point is within edges of image as well
76
if (x <= pick_view->cell.left)
78
if (x >= pick_view->cell.right)
80
if (y <= pick_view->cell.top)
82
if (y >= pick_view->cell.bottom)
87
* ok, erase menu messages
91
/* determine magnification of zoom */
92
if (zoom_view->cell.configured) {
93
if (zoom_view == pick_view)
94
mag = floor(magnification(zoom_view) + 1.0) + .1;
96
mag = ceil(magnification(zoom_view)) + .1;
99
mag = floor(magnification(main_view) + 1.0) + .1;
101
if (!ask_magnification(&mag))
104
* Determine the the zoom window (ie, cellhd)
107
G_copy(&cellhd, &main_view->cell.head, sizeof(cellhd));
108
cellhd.ns_res = main_view->cell.ns_res / mag;
109
cellhd.ew_res = main_view->cell.ew_res / mag;
110
cellhd.cols = (cellhd.east - cellhd.west) / cellhd.ew_res;
111
cellhd.rows = (cellhd.north - cellhd.south) / cellhd.ns_res;
114
/* convert x,y to col,row */
116
col = view_to_col(pick_view, x);
117
east = col_to_easting(&pick_view->cell.head, col, 0.5);
118
col = easting_to_col(&cellhd, east);
120
row = view_to_row(pick_view, y);
121
north = row_to_northing(&pick_view->cell.head, row, 0.5);
122
row = northing_to_row(&cellhd, north);
124
ncols = zoom_view->ncols;
125
nrows = zoom_view->nrows;
128
n = cellhd.cols - col;
131
if (n + n + 1 >= ncols) {
133
if (n + n + 1 >= ncols)
139
n = cellhd.rows - row;
142
if (n + n + 1 >= nrows) {
144
if (n + n + 1 >= nrows)
151
north = row_to_northing(&cellhd, top, 0.0);
152
west = col_to_easting(&cellhd, left, 0.0);
153
south = row_to_northing(&cellhd, bottom, 1.0);
154
east = col_to_easting(&cellhd, right, 1.0);
157
cellhd.north = north;
158
cellhd.south = south;
162
cellhd.rows = (cellhd.north - cellhd.south) / cellhd.ns_res;
163
cellhd.cols = (cellhd.east - cellhd.west) / cellhd.ew_res;
166
* Outline the zoom window on the main map
167
* Turn previous one to grey.
169
if (zoom_view->cell.configured) {
170
R_standard_color(GREY);
171
Outline_cellhd(main_view, &zoom_view->cell.head);
173
R_standard_color(RED);
174
Outline_cellhd(main_view, &cellhd);
182
G_copy(&zoom_view->cell.head, &cellhd, sizeof(cellhd));
183
Configure_view(zoom_view, pick_view->cell.name, pick_view->cell.mapset,
184
pick_view->cell.ns_res, pick_view->cell.ew_res);
186
select_current_env();
187
display_ref_points(1);
189
return 1; /* pop back */
192
static int cancel(void)