static int rast_redraw(void) { Erase_view(VIEW_MAP1); drawcell(VIEW_MAP1, 0); /* 0 means don't initialize VIEW_MAP2 */ display_points(1); return 0; }
int display_title(View * view) { View *title; char left[100], center[100]; int size; *left = 0; *center = 0; if (view->cell.configured) { sprintf(center, "%s (mag %.1f)", view->cell.name, magnification(view)); } if (view == VIEW_MAP1) { sprintf(left, "%s", G_location()); title = VIEW_TITLE1; } else if (view == VIEW_MAP1_ZOOM) { title = VIEW_TITLE1_ZOOM; } if (view == VIEW_MAP2) { sprintf(left, "%s", G_location()); title = VIEW_TITLE2; } else if (view == VIEW_MAP2_ZOOM) { title = VIEW_TITLE2_ZOOM; } Erase_view(title); R_standard_color(WHITE); size = title->nrows - 4; R_text_size(size, size); Text(left, title->top, title->bottom, title->left, title->right, 2); if (*center) { R_standard_color(YELLOW); Text(center, title->top, title->bottom, (title->left + title->right - Text_width(center)) / 2, title->right, 2); } return 0; }
int Menu_msg(char *msg) { int size, edge; size = VIEW_MENU->nrows - 4; edge = 2; Erase_view(VIEW_MENU); if (*msg) { R_text_size(size, size); R_standard_color(BLACK); Text(msg, VIEW_MENU->top, VIEW_MENU->bottom, VIEW_MENU->left, VIEW_MENU->right, edge); } R_flush(); replot = 1; return 0; }
int Configure_view(View * view, char *name, char *mapset, double ns_res, double ew_res /* original map resolution */ ) { Erase_view(view); view->cell.configured = 0; /* copy the cell name into the view */ strcpy(view->cell.name, name); strcpy(view->cell.mapset, mapset); /* determine the map edges */ view->cell.left = view->left + (view->ncols - view->cell.head.cols) / 2; view->cell.right = view->cell.left + view->cell.head.cols - 1; view->cell.top = view->top + (view->nrows - view->cell.head.rows) / 2; view->cell.bottom = view->cell.top + view->cell.head.rows - 1; /* remember original resolutions */ view->cell.ns_res = ns_res; view->cell.ew_res = ew_res; view->cell.configured = 1; return 0; }
static int drawvect(int zoomit, /* -1 = refresh, 0 = new image, 1 = zoom, 2 = warp */ View * zoom_view, double E[], double N[], int trans_order) { /* order of transformation if warping vectors */ int stat = 0; int i; char name[GNAME_MAX], mapset[GMAPSET_MAX]; struct Cell_head cellhd; struct line_pnts *Points; char msg[100], win_name[100]; int t, b, l, r; int blank = 0; View *active_view; int left, top, nrows, ncols; static int vectclr[VFILES]; /* if refresh screen or overlay & no displayed vector maps return */ if ((zoomit == DO_REFRESH || zoomit == DO_WARP) && !numfiles) { if (zoomit == DO_REFRESH) display_points(1); return 0; } /* numfiles stays at 0 until the end of the first vector map init */ if (numfiles >= VFILES) { G_warning ("Can't display another map; reached maximum number of files"); return 0; } select_target_env(); if (zoomit == DO_REFRESH || zoomit == DO_NEW) { /* New Map File or Refresh Screen */ if (zoomit == DO_NEW) { /* zoomit==0, Draw New Map File */ if (!choose_vectfile(name, mapset)) return 0; strcpy(vect_file[numfiles], name); strcpy(vect_mapset[numfiles], mapset); get_vector_color(); /* ask line_color to draw map */ if (!numfiles) { /* first map: SET VECTOR WINDOW BY WIND */ G_get_window(&cellhd); G_copy(&VIEW_MAP2->cell.head, &cellhd, sizeof(cellhd)); } else /* not the first map */ G_copy(&cellhd, &VIEW_MAP2->cell.head, sizeof(VIEW_MAP2->cell.head)); numfiles++; } else { /* zoomit=-1 Refresh Screen */ G_copy(&cellhd, &VIEW_MAP2->cell.head, sizeof(VIEW_MAP2->cell.head)); if (!cellmap_present) Erase_view(VIEW_MAP2_ZOOM); VIEW_MAP2_ZOOM->cell.configured = 0; blank = BLACK; } strcpy(win_name, "vect_map"); if (!view2on) { t = VIEW_MAP2->top; b = VIEW_MAP2->bottom; l = VIEW_MAP2->left; r = VIEW_MAP2->right; D_new_window(win_name, t, b, l, r); if (!cellmap_present) blank = BLACK; else blank = 0; /* don't erase viewport */ view2on = 1; } active_view = VIEW_MAP2; } else { /* zoomit>0 Zoom or Warp */ G_copy(&cellhd, &zoom_view->cell.head, sizeof(zoom_view->cell.head)); if (!(zoom_view == VIEW_MAP1)) { /* target side */ VIEW_MAP2_ZOOM->cell.configured = 0; strcpy(win_name, "zoom_map"); if (!view2zoomon) { t = VIEW_MAP2_ZOOM->top; b = VIEW_MAP2_ZOOM->bottom; l = VIEW_MAP2_ZOOM->left; r = VIEW_MAP2_ZOOM->right; D_new_window(win_name, t, b, l, r); view2zoomon = 1; } active_view = VIEW_MAP2_ZOOM; blank = BLACK; } else { strcpy(win_name, "warp_map"); /* defined in drawcell routine */ active_view = VIEW_MAP1; blank = 0; /* don't erase viewport */ } } nrows = active_view->nrows; ncols = active_view->ncols; left = active_view->left; top = active_view->top; D_set_cur_wind(win_name); R_standard_color(YELLOW); Outline_box(top, top + nrows - 1, left, left + ncols - 1); Points = Vect_new_line_struct(); if (zoomit != DO_WARP) { Curses_clear_window(INFO_WINDOW); Curses_write_window(INFO_WINDOW, 1, 13, "COORDINATES"); Curses_write_window(INFO_WINDOW, 3, 2, "MAIN WINDOW"); sprintf(msg, "N = %10.2f E = %10.2f", VIEW_MAP2->cell.head.north, VIEW_MAP2->cell.head.east); Curses_write_window(INFO_WINDOW, 5, 4, msg); sprintf(msg, "S = %10.2f W = %10.2f", VIEW_MAP2->cell.head.south, VIEW_MAP2->cell.head.west); Curses_write_window(INFO_WINDOW, 6, 4, msg); Curses_write_window(INFO_WINDOW, 9, 2, "ZOOM WINDOW"); sprintf(msg, "N = %10.2f E = %10.2f", VIEW_MAP2_ZOOM->cell.head.north, VIEW_MAP2_ZOOM->cell.head.east); Curses_write_window(INFO_WINDOW, 11, 4, msg); sprintf(msg, "S = %10.2f W = %10.2f", VIEW_MAP2_ZOOM->cell.head.south, VIEW_MAP2_ZOOM->cell.head.west); Curses_write_window(INFO_WINDOW, 12, 4, msg); } if (zoomit) { /* ie ! DO_NEW */ dsp_setup(blank, &cellhd); for (i = 0; i < numfiles; i++) { sprintf(msg, "Displaying %s", vect_file[i]); Menu_msg(msg); R_standard_color(vectclr[i]); if (zoomit != DO_WARP) stat = plot(vect_file[i], vect_mapset[i], Points); else stat = plot_warp(vect_file[i], vect_mapset[i], Points, E, N, trans_order); } } else { /* ie DO_NEW */ if (numfiles == 1) { /* let first file set window */ G_copy(&VIEW_MAP2->cell.head, &cellhd, sizeof(cellhd)); cellhd.rows = VIEW_MAP2->nrows; cellhd.cols = VIEW_MAP2->ncols; cellhd.ns_res = (cellhd.north - cellhd.south) / cellhd.rows; cellhd.ew_res = (cellhd.east - cellhd.west) / cellhd.cols; if (cellhd.ns_res > cellhd.ew_res) cellhd.ew_res = cellhd.ns_res; else cellhd.ns_res = cellhd.ew_res; VIEW_MAP2->cell.ns_res = cellhd.ns_res; VIEW_MAP2->cell.ew_res = cellhd.ew_res; G_copy(&VIEW_MAP2->cell.head, &cellhd, sizeof(cellhd)); G_adjust_window_to_box(&cellhd, &VIEW_MAP2->cell.head, VIEW_MAP2->nrows, VIEW_MAP2->ncols); if (!cellmap_present) { Configure_view(VIEW_MAP2, vect_file[numfiles - 1], vect_mapset[numfiles - 1], cellhd.ns_res, cellhd.ew_res); } Curses_write_window(INFO_WINDOW, 15, 2, "WHERE CURSOR-> Mid Button"); } dsp_setup(blank, &cellhd); R_standard_color(YELLOW); Outline_box(top, top + nrows - 1, left, left + ncols - 1); sprintf(msg, "Displaying %s", vect_file[numfiles - 1]); Menu_msg(msg); R_standard_color(line_color); vectclr[numfiles - 1] = line_color; get_clr_name(vect_color[numfiles - 1], line_color); stat = plot(vect_file[numfiles - 1], vect_mapset[numfiles - 1], Points); } display_points(1); R_standard_color(WHITE); Outline_box(top, top + nrows - 1, left, left + ncols - 1); Menu_msg(""); Vect_destroy_line_struct(Points); /* VIEW_MAP2->cell.configured = 1; XXX */ select_current_env(); if (from_screen < 0) { from_flag = 1; from_screen = 0; if (from_keyboard < 0) { from_keyboard = 0; from_screen = 1; } } if (numfiles) { Curses_clear_window(MENU_WINDOW); Curses_write_window(MENU_WINDOW, 1, 5, "COLOR MAP FILE"); for (i = 0; i < numfiles; i++) { sprintf(msg, "%7s %s", vect_color[i], vect_file[i]); Curses_write_window(MENU_WINDOW, i + 3, 3, msg); } } return 0; }
static int draw_objects(Objects * objects) { Objects *obj; int top, bottom, left, right; int size, edge; /* erase the menu window */ Erase_view(VIEW_MENU); R_flush(); /* determine sizes and text indentation */ size = VIEW_MENU->nrows - 4; edge = 2; R_text_size(size, size); left = VIEW_MENU->left; top = VIEW_MENU->top; bottom = VIEW_MENU->bottom; /* put the (boxed) text on the menu view */ for (obj = objects; obj->type; obj++) { if (!visible(obj)) continue; switch (obj->type) { case OPTION_OBJECT: case MENU_OBJECT: right = left + 2 * edge + Text_width(obj->label); obj->left = left; obj->right = right; obj->top = top; obj->bottom = bottom; R_standard_color(FILL_COLOR); R_box_abs(left, top, right, bottom); R_standard_color(TEXT_COLOR); Text(obj->label, top, bottom, left, right, edge); R_standard_color(OUTLINE_COLOR); Outline_box(top, bottom, left, right); left = right; break; case INFO_OBJECT: if (*obj->label == 0) break; if (*obj->status < 0) break; right = left + 2 * edge + Text_width(obj->label); R_standard_color(BLACK); Text(obj->label, top, bottom, left, right, edge); left = right; break; } } draw_option_boxes(objects); R_flush(); return 0; }