int zoom_window_update(void *closure, int sxn, int syn, int button) { struct zoom_window *zw = closure; if (zw->mode == 1) { i_prompt_buttons(_("1. corner"), _("2. corner"), _("Quit")); zw->next_mode = 2; } G_debug(2, "button = %d x = %d y = %d", button, sxn, syn); if (button == 3) return 1; if (zw->mode == 2 && button == 2) { double x1 = D_d_to_u_col(zw->sxo); double y1 = D_d_to_u_row(zw->syo); double x2 = D_d_to_u_col(sxn); double y2 = D_d_to_u_row(syn); G_debug(2, "x1 = %f x2 = %f y1 = %f y2 = %f", x1, x2, y1, y2); window.north = y1 > y2 ? y1 : y2; window.south = y1 < y2 ? y1 : y2; window.west = x1 < x2 ? x1 : x2; window.east = x1 > x2 ? x1 : x2; G_debug(2, "w = %f e = %f n = %f s = %f", window.west, window.east, window.north, window.south); G_adjust_Cell_head(&window, 0, 0); G_put_window(&window); G_set_window(&window); display_redraw(); i_prompt_buttons(_("1. corner"), _("1. corner"), _("Quit")); zw->next_mode = 1; } zw->sxo = sxn; zw->syo = syn; zw->mode = zw->next_mode; set_mode(zw->mode == 2 ? MOUSE_BOX : MOUSE_POINT); set_location(zw->sxo, zw->syo); return 0; }
int zoom_pan_update(void *closure, int sxn, int syn, int button) { G_debug(2, "button = %d x = %d y = %d", button, sxn, syn); if (button == 3) return 1; if (button == 1) { double x = D_d_to_u_col(sxn); double y = D_d_to_u_row(syn); double dx = (window.east - window.west) / 2; double dy = (window.north - window.south) / 2; window.north = y + dy; window.south = y - dy; window.east = x + dx; window.west = x - dx; G_debug(2, "w = %f e = %f n = %f s = %f", window.west, window.east, window.north, window.south); G_adjust_Cell_head(&window, 0, 0); G_put_window(&window); G_set_window(&window); display_redraw(); } return 0; }
int driver_open(void) { double n, s, e, w; if (Tcl_Eval(Toolbox, "create_screen") != TCL_OK) G_warning("create_screen: %s", Tcl_GetStringResult(Toolbox)); setup(); n = D_d_to_u_row(D_get_d_north()); s = D_d_to_u_row(D_get_d_south()); w = D_d_to_u_col(D_get_d_west()); e = D_d_to_u_col(D_get_d_east()); Scale = (n - s) / (D_get_d_south() - D_get_d_north()); G_setup_plot(D_get_d_north(), D_get_d_south(), D_get_d_west(), D_get_d_east(), driver_move_abs, driver_cont_abs); return 1; }
static int get_coordinates(double *x, double *y, double *east, double *north, struct rectinfo win, char **at, char pixel, char geocoor) { double e, n; if (at) { e = atof(at[0]); n = atof(at[1]); if (pixel) { *x = e + win.l; *y = n + win.t; e = D_d_to_u_col(*x); n = D_d_to_u_row(*y); } else if (geocoor) { *x = D_u_to_d_col(e); *y = D_u_to_d_row(n); } else { *x = win.l + (win.r - win.l) * e / 100.0; *y = win.t + (win.b - win.t) * (100.0 - n) / 100.0; e = D_d_to_u_col(*x); n = D_d_to_u_row(*y); } } else return 1; if (east) *east = e; if (north) *north = n; return 0; }
int make_window_box(struct Cell_head *window, double magnify, int full, int hand) { int screen_x, screen_y; double px, py, ux1, uy1, ux2, uy2; double ns, ew; int button; int cur_screen_x, cur_screen_y; int mode; /* 1, 2 */ int resetwin; struct Cell_head defwin; int printmenu = 1; G_get_default_window(&defwin); mode = 1; while (1) { resetwin = 0; if (!hand) { if (printmenu) { fprintf(stderr, "\n\nButtons:\n"); fprintf(stderr, "Left: 1. corner\n"); fprintf(stderr, "Middle: Unzoom\n"); if (full) fprintf(stderr, "Right: Main menu\n\n"); else fprintf(stderr, "Right: Quit\n\n"); printmenu = 0; } } else { if (mode == 1) fprintf(stderr, "\r1. corner"); else fprintf(stderr, "\r2. corner"); } if (mode == 1) { if (!hand) { R_get_location_with_pointer(&screen_x, &screen_y, &button); } else { R_get_location_with_box(0, 0, &screen_x, &screen_y, &button); } cur_screen_x = screen_x; cur_screen_y = screen_y; } else { R_get_location_with_box(cur_screen_x, cur_screen_y, &screen_x, &screen_y, &button); } /* For print only */ px = D_d_to_u_col((double)screen_x); py = D_d_to_u_row((double)screen_y); if (!hand) print_coor(window, py, px); if (button == 1) { if (!hand) { if (mode == 1) { fprintf(stderr, "\n\nButtons:\n"); fprintf(stderr, "Left: 1. corner (reset)\n"); fprintf(stderr, "Middle: 2. corner\n"); if (full) fprintf(stderr, "Right: Main menu\n\n"); else fprintf(stderr, "Right: Quit\n\n"); mode = 2; } if (mode == 2) { cur_screen_x = screen_x; cur_screen_y = screen_y; } } else { /* hand */ if (mode == 1) { mode = 2; } else { ux1 = D_d_to_u_col((double)cur_screen_x); uy1 = D_d_to_u_row((double)cur_screen_y); ux2 = D_d_to_u_col((double)screen_x); uy2 = D_d_to_u_row((double)screen_y); resetwin = 1; mode = 1; } } } else if (button == 2) { if (mode == 1) { /* unzoom */ ux2 = D_d_to_u_col((double)screen_x); uy2 = D_d_to_u_row((double)screen_y); ew = window->east - window->west; ns = window->north - window->south; if (ns <= window->ns_res) ns = 2 * window->ns_res; else ew /= magnify; if (ew <= window->ew_res) ew = 2 * window->ew_res; else ns /= magnify; ux1 = window->east + ew / 2; ux2 = window->west - ew / 2; uy1 = window->north + ns / 2; uy2 = window->south - ns / 2; } else { ux1 = D_d_to_u_col((double)cur_screen_x); uy1 = D_d_to_u_row((double)cur_screen_y); ux2 = D_d_to_u_col((double)screen_x); uy2 = D_d_to_u_row((double)screen_y); printmenu = 1; mode = 1; } fprintf(stderr, "\n"); resetwin = 1; } else { fprintf(stderr, "\n"); return 1; } if (resetwin) { set_win(window, ux1, uy1, ux2, uy2, hand); } } fprintf(stderr, "\n"); return 1; /* not reached */ }
int draw_n_arrow(double east, double north, double fontsize, char *n_arrow_num, double line_width) { double x_pos, y_pos; double t, b, l, r; double tt, tb, tl, tr; /* text box*/ SYMBOL *Symb; RGBA_Color *line_color, *fill_color; int R, G, B; double x0, y0; char icon[64]; double symbol_size; /* Establish text size */ if (fontsize > 0) D_text_size(fontsize, fontsize); D_setup_unity(0); D_get_src(&t, &b, &l, &r); x_pos = east * (r - l) / 100.; y_pos = (100. - north) * (b - t) / 100.; if (line_width > 0) D_line_width(line_width); if (fontsize > 0) { /* draw the "N" */ D_get_text_box("N", &tt, &tb, &tl, &tr); D_use_color(fg_color); /* positions manually tuned */ switch (n_arrow_num[0]) { case '1': D_pos_abs(x_pos - (tr + tl) / 2, y_pos - 45); D_text("N"); break; case '3': D_pos_abs(x_pos - (tr + tl) / 2, y_pos - 60); D_text("N"); break; case '4': D_pos_abs(x_pos - (tr + tl) / 2, y_pos - 45); D_text("N"); break; case '7': D_pos_abs(x_pos - (tr + tl) / 2, y_pos - 70); D_text("N"); break; case '9': case 'f': D_pos_abs(x_pos - (tr + tl) / 2, y_pos - 55); D_text("N"); break; case 'b': D_pos_abs(x_pos - (tr + tl) / 2, y_pos - 48.5); D_text("N"); break; case '2': case '5': case '6': case '8': break; default: G_fatal_error(_("Could not parse symbol")); } } /* display the north arrow symbol */ line_color = G_malloc(sizeof(RGBA_Color)); fill_color = G_malloc(sizeof(RGBA_Color)); if (D_color_number_to_RGB(fg_color, &R, &G, &B) == 0) /* fall back to black on failure */ G_str_to_color(DEFAULT_FG_COLOR, &R, &G, &B); line_color->r = (unsigned char)R; line_color->g = (unsigned char)G; line_color->b = (unsigned char)B; line_color->a = RGBA_COLOR_OPAQUE; if (D_color_number_to_RGB(bg_color, &R, &G, &B) == 0) /* fall back to black on failure */ G_str_to_color(DEFAULT_FG_COLOR, &R, &G, &B); fill_color->r = (unsigned char)R; fill_color->g = (unsigned char)G; fill_color->b = (unsigned char)B; fill_color->a = RGBA_COLOR_OPAQUE; if (n_arrow_num[0] == '2' || n_arrow_num[0] == '9') fill_color->a = RGBA_COLOR_TRANSPARENT; /* sizes manually tuned */ switch (n_arrow_num[0]) { case '1': symbol_size = 35.; break; case '2': symbol_size = 19.; break; case '3': symbol_size = 20.; break; case '4': symbol_size = 15.; break; case '5': case '6': symbol_size = 14.; break; case '7': symbol_size = 23.; break; case '8': case '9': symbol_size = 17.; break; case 'b': symbol_size = 80.; break; case 'f': symbol_size = 100.; break; default: G_fatal_error(_("Could not parse symbol")); } x0 = D_d_to_u_col(x_pos); y0 = D_d_to_u_row(y_pos); if (n_arrow_num[0] == 'b') strcpy(icon, "n_arrows/basic_compass"); else if (n_arrow_num[0] == 'f') strcpy(icon, "n_arrows/fancy_compass"); else { strcpy(icon, "n_arrows/n_arrow"); strncat(icon, n_arrow_num, 32); } Symb = S_read(icon); if(!Symb) G_fatal_error(_("Could not read symbol \"%s\""), icon); S_stroke(Symb, symbol_size, 0.0, 0); D_symbol(Symb, x0, y0, line_color, fill_color); if (line_width > 0) D_line_width(0); G_free(Symb); G_free(line_color); G_free(fill_color); return 0; }
int draw_n_arrow(double east, double north, double rotation, char *lbl, int rot_with_text, double fontsize, char *n_arrow_num, double line_width) { double x_pos, y_pos; double t, b, l, r; double tt, tb, tl, tr; /* text box */ SYMBOL *Symb; RGBA_Color *line_color, *fill_color; int R, G, B; double x0, y0; char icon[64]; double symbol_size; /* Establish text size */ if (fontsize > 0) D_text_size(fontsize, fontsize); D_setup_unity(0); D_get_src(&t, &b, &l, &r); x_pos = l + (int)(east * (r - l) / 100.); y_pos = t + (int)((100. - north) * (b - t) / 100.); if (line_width > 0) D_line_width(line_width); if (fontsize > 0) { /* draw the label (default "N") */ if (rot_with_text) D_text_rotation(rotation * 180.0 / M_PI); D_get_text_box(lbl, &tt, &tb, &tl, &tr); D_use_color(text_color); /* positions manually tuned */ switch (n_arrow_num[0]) { case '1': D_pos_abs(x_pos - sin(rotation) * 50 - (tr + tl) / 2, y_pos - cos(rotation) * 50 - (tb + tt) / 2); D_text(lbl); break; case '3': D_pos_abs(x_pos - sin(rotation) * 60 - (tr + tl) / 2, y_pos - cos(rotation) * 60 - (tb + tt) / 2); D_text(lbl); break; case '4': D_pos_abs(x_pos - sin(rotation) * 45 - (tr + tl) / 2, y_pos - cos(rotation) * 45 - (tb + tt) / 2); D_text(lbl); break; case '7': D_pos_abs(x_pos - sin(rotation) * 70 - (tr + tl) / 2, y_pos - cos(rotation) * 70 - (tb + tt) / 2); D_text(lbl); break; case '8': D_pos_abs(x_pos - sin(rotation) * 60 - (tr + tl) / 2, y_pos - cos(rotation) * 60 - (tb + tt) / 2); D_text(lbl); break; case '9': D_pos_abs(x_pos - sin(rotation) * 55 - (tr + tl) / 2, y_pos - cos(rotation) * 55 - (tb + tt) / 2); D_text(lbl); break; case 'f': D_pos_abs(x_pos - sin(rotation) * 55 - (tr + tl) / 2, y_pos - cos(rotation) * 55 - (tb + tt) / 2); D_text(lbl); break; case 'b': D_pos_abs(x_pos - sin(rotation) * 48.5 - (tr + tl) / 2, y_pos - cos(rotation) * 48.5 - (tb + tt) / 2); D_text(lbl); break; case 'a': D_pos_abs(x_pos - sin(rotation) * 50 - (tr + tl) / 2, y_pos - cos(rotation) * 50 - (tb + tt) / 2); D_text(lbl); break; case 's': D_pos_abs(x_pos - sin(rotation) * 50 - (tr + tl) / 2, y_pos - cos(rotation) * 50 - (tb + tt) / 2); D_text(lbl); break; case '2': case '5': case '6': break; default: G_fatal_error(_("Could not parse symbol")); } } /* display the north arrow symbol */ line_color = G_malloc(sizeof(RGBA_Color)); fill_color = G_malloc(sizeof(RGBA_Color)); if (D_color_number_to_RGB(fg_color, &R, &G, &B) == 0) line_color->a = RGBA_COLOR_TRANSPARENT; else line_color->a = RGBA_COLOR_OPAQUE; line_color->r = (unsigned char)R; line_color->g = (unsigned char)G; line_color->b = (unsigned char)B; if (D_color_number_to_RGB(bg_color, &R, &G, &B) == 0) fill_color->a = RGBA_COLOR_TRANSPARENT; else fill_color->a = RGBA_COLOR_OPAQUE; fill_color->r = (unsigned char)R; fill_color->g = (unsigned char)G; fill_color->b = (unsigned char)B; /* sizes manually tuned */ switch (n_arrow_num[0]) { case '1': symbol_size = 35.; break; case '2': symbol_size = 19.; break; case '3': symbol_size = 20.; break; case '4': symbol_size = 15.; break; case '5': case '6': symbol_size = 14.; break; case '7': symbol_size = 23.; break; case '8': case '9': symbol_size = 17.; break; case 'b': symbol_size = 80.; break; case 'f': symbol_size = 100.; break; case 'a': if (n_arrow_num[5] == '2') symbol_size = 53.; else symbol_size = 70.; break; case 's': symbol_size = 80.; break; default: G_fatal_error(_("Could not parse symbol")); } x0 = D_d_to_u_col(x_pos); y0 = D_d_to_u_row(y_pos); if (n_arrow_num[0] == 'b') strcpy(icon, "n_arrows/basic_compass"); else if (n_arrow_num[0] == 'f') strcpy(icon, "n_arrows/fancy_compass"); else if (n_arrow_num[0] == 'a' && n_arrow_num[5] == '1') strcpy(icon, "basic/arrow1"); else if (n_arrow_num[0] == 'a' && n_arrow_num[5] == '2') strcpy(icon, "basic/arrow2"); else if (n_arrow_num[0] == 'a' && n_arrow_num[5] == '3') strcpy(icon, "basic/arrow3"); else if (n_arrow_num[0] == 's') strcpy(icon, "extra/4pt_star"); else { strcpy(icon, "n_arrows/n_arrow"); strncat(icon, n_arrow_num, 32); } Symb = S_read(icon); if (!Symb) G_fatal_error(_("Could not read symbol \"%s\""), icon); S_stroke(Symb, symbol_size, rotation * (180 / M_PI), 0); D_symbol(Symb, x0, y0, line_color, fill_color); if (line_width > 0) D_line_width(0); G_free(Symb); G_free(line_color); G_free(fill_color); return 0; }
int move_line_update(void *closure, int sxn, int syn, int button) { struct move_line *ml = closure; double x = D_d_to_u_col(sxn); double y = D_d_to_u_row(syn); G_debug(3, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y); if (ml->last_line > 0) { display_line(ml->last_line, SYMB_DEFAULT, 1); } if (button == 3) return 1; if (button == 1) { /* Select / new location */ int type; if (ml->last_line == 0) { /* Select line */ ml->line = Vect_find_line(&Map, x, y, 0, GV_POINT | GV_CENTROID, ml->thresh, 0, 0); G_debug(2, "point found = %d", ml->line); if (ml->line == 0) ml->line = Vect_find_line(&Map, x, y, 0, GV_LINE | GV_BOUNDARY, ml->thresh, 0, 0); G_debug(2, "line found = %d", ml->line); /* Display new selected line if any */ if (ml->line > 0) { display_line(ml->line, SYMB_HIGHLIGHT, 1); /* Find the nearest point on the line */ type = Vect_read_line(&Map, ml->Points, NULL, ml->line); Vect_line_distance(ml->Points, x, y, 0, 0, &ml->xo, &ml->yo, NULL, NULL, NULL, NULL); set_location(D_u_to_d_col(ml->xo), D_u_to_d_row(ml->yo)); i_prompt_buttons(_("New location"), _("Unselect"), _("Quit tool")); } ml->last_line = ml->line; } else { /* Line is already selected */ int node1, node2; int i; display_line(ml->last_line, SYMB_BACKGROUND, 1); Vect_get_line_nodes(&Map, ml->last_line, &node1, &node2); display_node(node1, SYMB_BACKGROUND, 1); display_node(node2, SYMB_BACKGROUND, 1); type = Vect_read_line(&Map, ml->Points, ml->Cats, ml->last_line); for (i = 0; i < ml->Points->n_points; i++) { ml->Points->x[i] = ml->Points->x[i] + x - ml->xo; ml->Points->y[i] = ml->Points->y[i] + y - ml->yo; } Vect_rewrite_line(&Map, ml->last_line, type, ml->Points, ml->Cats); updated_lines_and_nodes_erase_refresh_display(); ml->last_line = 0; } } if (button == 2) { /* Unselect */ if (ml->last_line > 0) { ml->last_line = 0; } } if (ml->last_line == 0) { i_prompt_buttons(_("Select"), "", _("Quit tool")); set_mode(MOUSE_POINT); } else set_mode(MOUSE_LINE); return 0; }
int delete_line_update(void *closure, int sxn, int syn, int button) { struct delete_line *dl = closure; double x = D_d_to_u_col(sxn); double y = D_d_to_u_row(syn); G_debug(3, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y); /* Display last highlighted in normal color */ if (dl->last_line > 0) { display_line(dl->last_line, SYMB_DEFAULT, 1); } if (button == 3) /* Quit tool */ return 1; if (button == 1) { /* Confirm / select */ /* Delete last if any */ if (dl->last_line > 0) { int node1, node2; int i; /* Erase line and nodes !!! (because if the line is not connected to any other, nodes will die */ display_line(dl->last_line, SYMB_BACKGROUND, 1); Vect_get_line_nodes(&Map, dl->line, &node1, &node2); G_debug(2, "delete line = %d node1 = %d node2 = %d", dl->last_line, node1, node2); display_node(node1, SYMB_BACKGROUND, 1); display_node(node2, SYMB_BACKGROUND, 1); Vect_read_line(&Map, NULL, dl->Cats, dl->last_line); Vect_delete_line(&Map, dl->last_line); for (i = 0; i < dl->Cats->n_cats; i++) { check_record(dl->Cats->field[i], dl->Cats->cat[i]); } for (i = 0; i < Vect_get_num_updated_lines(&Map); i++) G_debug(2, "Updated line: %d", Vect_get_updated_line(&Map, i)); for (i = 0; i < Vect_get_num_updated_nodes(&Map); i++) G_debug(2, "Updated node: %d", Vect_get_updated_node(&Map, i)); updated_lines_and_nodes_erase_refresh_display(); } /* Find neares point or line */ dl->line = Vect_find_line(&Map, x, y, 0, GV_POINT | GV_CENTROID, dl->thresh, 0, 0); G_debug(2, "point found = %d", dl->line); if (dl->line == 0) dl->line = Vect_find_line(&Map, x, y, 0, GV_LINE | GV_BOUNDARY, dl->thresh, 0, 0); G_debug(2, "line found = %d", dl->line); /* Display new selected line if any */ if (dl->line > 0) { display_line(dl->line, SYMB_HIGHLIGHT, 1); } } else { /* button == 2 -> unselect */ dl->line = 0; } if (dl->line > 0) i_prompt_buttons(_("Confirm and select next"), _("Unselect"), _("Quit tool")); else i_prompt_buttons(_("Select"), _("Unselect"), _("Quit tool")); dl->last_line = dl->line; dl->first = 0; return 0; }
int edit_line_update(void *closure, int sxn, int syn, int button) { struct edit_line *el = closure; double x = D_d_to_u_col(sxn); double y = D_d_to_u_row(syn); G_debug(3, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y); if (button == 3) /* Tool broken by GUI */ return 1; switch (el->phase) { case 1: if (button != 1) return 0; /* Find nearest point or line */ el->line = Vect_find_line(&Map, x, y, 0, GV_LINE | GV_BOUNDARY, el->thresh, 0, 0); G_debug(2, "line found = %d", el->line); /* Display new selected line if any */ if (el->line > 0) { display_line(el->line, SYMB_HIGHLIGHT, 1); edit_line_phase2(el, x, y); } break; case 2: if (button == 1) { /* New point */ snap(&x, &y); Vect_append_point(el->Points, x, y, 0); if (el->line_type == GV_LINE) symb_set_driver_color(SYMB_LINE); else symb_set_driver_color(SYMB_BOUNDARY_0); display_points(el->Points, 1); set_location(sxn, syn); i_prompt_buttons(_("New Point"), _("Undo Last Point"), _("Close line")); } else if (button == 2) { /* Undo last point */ if (el->Points->n_points > 1) { symb_set_driver_color(SYMB_BACKGROUND); display_points(el->Points, 1); el->Points->n_points--; if (el->line_type == GV_LINE) symb_set_driver_color(SYMB_LINE); else symb_set_driver_color(SYMB_BOUNDARY_0); display_points(el->Points, 1); set_location(D_u_to_d_col (el->Points->x[el->Points->n_points - 1]), D_u_to_d_row(el->Points-> y[el->Points->n_points - 1]) ); if (el->Points->n_points == 1) i_prompt_buttons(_("New Point"), "", _("Delete line and exit")); } } break; } return 0; }
int new_line_update(void *closure, int sxn, int syn, int button) { struct new_line *nl = closure; double x = D_d_to_u_col(sxn); double y = D_d_to_u_row(syn); double dist; G_debug(3, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y); if (nl->first && button == 3) { /* Quit tool ( points & lines ), first is always for points */ Tool_next = TOOL_NOTHING; return 1; } if (button > 3) /* Do nothing on mouse scroll */ return 0; if (nl->type & GV_POINTS && (button == 1 || button == 2)) { snap(&x, &y); Vect_append_point(nl->Points, x, y, 0); write_line(&Map, nl->type, nl->Points); updated_lines_and_nodes_erase_refresh_display(); return 1; } else { /* GV_LINES */ /* Button may be 1,2,3 */ if (button == 1) { /* New point */ if (snap(&x, &y) == 0) { /* If not snapping to other features, try to snap to lines start. * Allows to create area of single boundary. */ if (nl->Points->n_points > 2) { dist = Vect_points_distance(nl->Points->x[0], nl->Points->y[0], 0, x, y, 0, WITHOUT_Z); if (dist < get_thresh()) { x = nl->Points->x[0]; y = nl->Points->y[0]; } } } if (Vect_append_point(nl->Points, x, y, 0) == -1) { G_warning(_("Out of memory! Point not added.")); return 0; } if (nl->type == GV_LINE) symb_set_driver_color(SYMB_LINE); else symb_set_driver_color(SYMB_BOUNDARY_0); display_points(nl->Points, 1); set_location(D_u_to_d_col(x), D_u_to_d_row(y)); nl->first = 0; set_mode(MOUSE_LINE); } else if (button == 2) { /* Undo last point */ if (nl->Points->n_points >= 1) { symb_set_driver_color(SYMB_BACKGROUND); display_points(nl->Points, 1); nl->Points->n_points--; if (nl->type == GV_LINE) symb_set_driver_color(SYMB_LINE); else symb_set_driver_color(SYMB_BOUNDARY_0); display_points(nl->Points, 1); set_location(D_u_to_d_col (nl->Points->x[nl->Points->n_points - 1]), D_u_to_d_row(nl->Points-> y[nl->Points->n_points - 1]) ); } if (nl->Points->n_points == 0) { i_prompt_buttons(_("New point"), "", _("Quit tool")); nl->first = 1; set_mode(MOUSE_POINT); } } else if (button == 3) { /* write the line and quit */ if (nl->Points->n_points > 1) { /* Before the line is written, we must check if connected to existing nodes, if yes, * such nodes must be add to update list before! the line is written (areas/isles */ int node1 = Vect_find_node(&Map, nl->Points->x[0], nl->Points->y[0], nl->Points->z[0], 0, Vect_is_3d(&Map)); int i = nl->Points->n_points - 1; int node2 = Vect_find_node(&Map, nl->Points->x[i], nl->Points->y[i], nl->Points->z[i], 0, Vect_is_3d(&Map)); G_debug(2, " old node1 = %d old node2 = %d", node1, node2); write_line(&Map, nl->type, nl->Points); updated_lines_and_nodes_erase_refresh_display(); } else G_warning(_("Less than 2 points for line -> nothing written")); return 1; } G_debug(2, "n_points = %d", nl->Points->n_points); } i_prompt_buttons(_("New point"), _("Undo last point"), _("Close line")); return 0; }