Beispiel #1
0
void Save_cellhd(View * view, struct Cell_head *cellhd, char *file)
{
    int row, col;
    int top, bottom, left, right;

    row = northing_to_row(&view->cell.head, cellhd->north) + .5;
    top = view->cell.top + row - 5;

    col = easting_to_col(&view->cell.head, cellhd->west) + .5;
    left = view->cell.left + col - 5;

    row = northing_to_row(&view->cell.head, cellhd->south) + .5;
    bottom = view->cell.top + row + 5;

    col = easting_to_col(&view->cell.head, cellhd->east) + .5;
    right = view->cell.left + col + 5;

    R_panel_save(file, top, bottom, left, right);
}
Beispiel #2
0
int Outline_cellhd(View * view, struct Cell_head *cellhd)
{
    int row, col;
    int top, bottom, left, right;

    row = northing_to_row(&view->cell.head, cellhd->north) + .5;
    top = row_to_view(view, row);

    col = easting_to_col(&view->cell.head, cellhd->west) + .5;
    left = col_to_view(view, col);

    row = northing_to_row(&view->cell.head, cellhd->south) + .5;
    bottom = row_to_view(view, row);

    col = easting_to_col(&view->cell.head, cellhd->east) + .5;
    right = col_to_view(view, col);

    Outline_box(top, bottom, left, right);

    return 0;
}
Beispiel #3
0
int display_one_point(View * view, double east, double north)
{
    int row, col, x, y;

    row = northing_to_row(&view->cell.head, north) + .5;
    col = easting_to_col(&view->cell.head, east) + .5;
    y = row_to_view(view, row);
    x = col_to_view(view, col);
    if (In_view(view, x, y))
	dot(x, y);

    return 0;
}
Beispiel #4
0
static int zoom1(int x, int y)
{				/* called by Input_pointer */
    int top, bottom, left, right;
    int n, row, col;
    int nrows, ncols;
    struct Cell_head cellhd;
    int mag;
    double magnification();
    double north, south, east, west;

    if (In_view(pick_view = VIEW_MAP1, x, y)) {
	main_view = VIEW_MAP1;
	zoom_view = VIEW_MAP1_ZOOM;
	target_flag = 0;
    }
    else if (In_view(pick_view = VIEW_MAP2, x, y)) {
	if (!pick_view->cell.configured)
	    return 0;		/* ignore the mouse event */
	main_view = VIEW_MAP2;
	zoom_view = VIEW_MAP2_ZOOM;
	target_flag = 1;
    }
    else if (In_view(pick_view = VIEW_MAP1_ZOOM, x, y)) {
	if (!pick_view->cell.configured)
	    return 0;		/* ignore the mouse event */
	main_view = VIEW_MAP1;
	zoom_view = VIEW_MAP1_ZOOM;
	target_flag = 0;
    }
    else if (In_view(pick_view = VIEW_MAP2_ZOOM, x, y)) {
	if (!pick_view->cell.configured)
	    return 0;		/* ignore the mouse event */
	main_view = VIEW_MAP2;
	zoom_view = VIEW_MAP2_ZOOM;
	target_flag = 1;
    }
    else
	return 0;		/* ignore the mouse event */
    if (!pick_view->cell.configured)
	return 0;		/* just to be sure */
    /*
     * make sure point is within edges of image as well
     */
    if (x <= pick_view->cell.left)
	return 0;
    if (x >= pick_view->cell.right)
	return 0;
    if (y <= pick_view->cell.top)
	return 0;
    if (y >= pick_view->cell.bottom)
	return 0;


    /*
     * ok, erase menu messages
     */
    Menu_msg("");

    /* determine magnification of zoom */
    if (zoom_view->cell.configured) {
	if (zoom_view == pick_view)
	    mag = floor(magnification(zoom_view) + 1.0) + .1;
	else
	    mag = ceil(magnification(zoom_view)) + .1;
    }
    else {
	mag = floor(magnification(main_view) + 1.0) + .1;
    }
    if (!ask_magnification(&mag))
	return 1;
    /* 
     * Determine the the zoom window (ie, cellhd)
     */

    G_copy(&cellhd, &main_view->cell.head, sizeof(cellhd));
    cellhd.ns_res = main_view->cell.ns_res / mag;
    cellhd.ew_res = main_view->cell.ew_res / mag;
    cellhd.cols = (cellhd.east - cellhd.west) / cellhd.ew_res;
    cellhd.rows = (cellhd.north - cellhd.south) / cellhd.ns_res;


    /* convert x,y to col,row */

    col = view_to_col(pick_view, x);
    east = col_to_easting(&pick_view->cell.head, col, 0.5);
    col = easting_to_col(&cellhd, east);

    row = view_to_row(pick_view, y);
    north = row_to_northing(&pick_view->cell.head, row, 0.5);
    row = northing_to_row(&cellhd, north);

    ncols = zoom_view->ncols;
    nrows = zoom_view->nrows;


    n = cellhd.cols - col;
    if (n > col)
	n = col;
    if (n + n + 1 >= ncols) {
	n = ncols / 2;
	if (n + n + 1 >= ncols)
	    n--;
    }
    left = col - n;
    right = col + n;

    n = cellhd.rows - row;
    if (n > row)
	n = row;
    if (n + n + 1 >= nrows) {
	n = nrows / 2;
	if (n + n + 1 >= nrows)
	    n--;
    }
    top = row - n;
    bottom = row + n;


    north = row_to_northing(&cellhd, top, 0.0);
    west = col_to_easting(&cellhd, left, 0.0);
    south = row_to_northing(&cellhd, bottom, 1.0);
    east = col_to_easting(&cellhd, right, 1.0);


    cellhd.north = north;
    cellhd.south = south;
    cellhd.east = east;
    cellhd.west = west;

    cellhd.rows = (cellhd.north - cellhd.south) / cellhd.ns_res;
    cellhd.cols = (cellhd.east - cellhd.west) / cellhd.ew_res;

    /*
     * Outline the zoom window on the main map
     * Turn previous one to grey.
     */
    if (zoom_view->cell.configured) {
	R_standard_color(GREY);
	Outline_cellhd(main_view, &zoom_view->cell.head);
    }
    R_standard_color(RED);
    Outline_cellhd(main_view, &cellhd);


    /*
     * zoom
     */
    if (target_flag)
	select_target_env();
    G_copy(&zoom_view->cell.head, &cellhd, sizeof(cellhd));
    Configure_view(zoom_view, pick_view->cell.name, pick_view->cell.mapset,
		   pick_view->cell.ns_res, pick_view->cell.ew_res);
    drawcell(zoom_view);
    select_current_env();
    display_points(1);

    return 1;			/* pop back */
}