static void place_line_x(int x, int y) { int dx, dy; canvas_leftbut_proc = null_proc; canvas_middlebut_proc = null_proc; canvas_rightbut_proc = null_proc; canvas_locmove_proc = null_proc; canvas_ref_proc = null_proc; adjust_pos(x, y, fix_x, fix_y, &x, &y); dx = x - fix_x; dy = y - fix_y; translate_line(new_l, dx, dy); clean_up(); set_latestline(new_l); if (return_proc == copy_selected) { add_line(new_l); adjust_links(cur_linkmode, cur_links, dx, dy, 0, 0, 1.0, 1.0, True); free_linkinfo(&cur_links); } else { list_add_line(&objects.lines, new_l); adjust_links(cur_linkmode, cur_links, dx, dy, 0, 0, 1.0, 1.0, False); set_lastposition(fix_x, fix_y); set_newposition(x, y); set_lastlinkinfo(cur_linkmode, cur_links); cur_links = NULL; set_action_object(F_MOVE, O_POLYLINE); } set_modifiedflag(); redisplay_line(new_l); /* turn back on all relevant markers */ update_markers(new_objmask); (*return_proc) (); draw_mousefun_canvas(); }
void box_2_box(F_line *old_l) { F_line *new_l; new_l = copy_line(old_l); switch (old_l->type) { case T_BOX: new_l->type = T_ARCBOX; if (new_l->radius == DEFAULT || new_l->radius == 0) new_l->radius = cur_boxradius; break; case T_ARCBOX: new_l->type = T_BOX; break; } list_delete_line(&objects.lines, old_l); list_add_line(&objects.lines, new_l); clean_up(); old_l->next = new_l; set_latestline(old_l); set_action_object(F_CONVERT, O_POLYLINE); set_modifiedflag(); /* save pointer to this line for undo */ latest_line = new_l; redisplay_line(new_l); return; }
void linepoint_deleting(F_line *line, F_point *prev_point, F_point *selected_point) { F_point *p, *next_point; next_point = selected_point->next; /* delete it and redraw underlying objects */ list_delete_line(&objects.lines, line); redisplay_line(line); if (line->type == T_POLYGON) { if (prev_point == NULL) { /* The deleted point is the first point */ line->points = next_point; for (prev_point = next_point, p = prev_point->next; p->next != NULL; prev_point = p, p = p->next); /* * prev_point now points at next to last point (the last point is * a copy of the first). */ p->x = next_point->x; p->y = next_point->y; next_point = p; /* * next_point becomes the last point. If this operation (point * deletion) is reversed (undo), the selected_point will not be * inserted into it original place, but will be between * prev_point and next_point. */ } else prev_point->next = next_point; } else { /* polyline */ if (prev_point == NULL) line->points = next_point; else prev_point->next = next_point; } /* put it back in the list and draw the new line */ list_add_line(&objects.lines, line); /* redraw it and anything on top of it */ redisplay_line(line); clean_up(); set_modifiedflag(); set_action_object(F_DELETE_POINT, O_POLYLINE); set_latestline(line); set_last_prevpoint(prev_point); set_last_selectedpoint(selected_point); set_last_nextpoint(next_point); }
static void cancel_line(void) { canvas_ref_proc = canvas_locmove_proc = null_proc; elastic_moveline(new_l->points); /* erase last lengths if appres.showlengths is true */ erase_lengths(); free_linkinfo(&cur_links); if (return_proc == copy_selected) { free_line(&new_l); } else { list_add_line(&objects.lines, new_l); redisplay_line(new_l); } /* turn back on all relevant markers */ update_markers(new_objmask); (*return_proc) (); draw_mousefun_canvas(); }
void undo_delete(void) { int xmin, ymin, xmax, ymax; char ctemp[PATH_MAX]; switch (last_object) { case O_POLYLINE: list_add_line(&objects.lines, saved_objects.lines); redisplay_line(saved_objects.lines); break; case O_ELLIPSE: list_add_ellipse(&objects.ellipses, saved_objects.ellipses); redisplay_ellipse(saved_objects.ellipses); break; case O_TXT: list_add_text(&objects.texts, saved_objects.texts); redisplay_text(saved_objects.texts); break; case O_SPLINE: list_add_spline(&objects.splines, saved_objects.splines); redisplay_spline(saved_objects.splines); break; case O_ARC: list_add_arc(&objects.arcs, saved_objects.arcs); redisplay_arc(saved_objects.arcs); break; case O_COMPOUND: list_add_compound(&objects.compounds, saved_objects.compounds); redisplay_compound(saved_objects.compounds); break; case O_ALL_OBJECT: saved_objects.next = NULL; compound_bound(&saved_objects, &xmin, &ymin, &xmax, &ymax); tail(&objects, &object_tails); append_objects(&objects, &saved_objects, &object_tails); redisplay_zoomed_region(xmin, ymin, xmax, ymax); } last_action = F_ADD; }
void spline_line(F_spline *s) { F_line *l; F_point *tmppoint; /* Now we turn s into a line */ if ((l = create_line()) == NULL) return; if (open_spline(s)) { l->type = T_POLYLINE; l->points = s->points; } else { l->type = T_POLYGON; if ((l->points = create_point())==NULL) return; tmppoint = last_point(s->points); l->points->x = tmppoint->x; l->points->y = tmppoint->y; l->points->next = copy_points(s->points); } l->style = s->style; l->thickness = s->thickness; l->pen_color = s->pen_color; l->fill_color = s->fill_color; l->depth = s->depth; l->style_val = s->style_val; l->cap_style = s->cap_style; l->join_style = cur_joinstyle; l->pen_style = s->pen_style; l->radius = DEFAULT; l->fill_style = s->fill_style; if (s->for_arrow) { l->for_arrow = create_arrow(); l->for_arrow->type = s->for_arrow->type; l->for_arrow->style = s->for_arrow->style; l->for_arrow->thickness = s->for_arrow->thickness; l->for_arrow->wd = s->for_arrow->wd; l->for_arrow->ht = s->for_arrow->ht; } else { l->for_arrow = NULL; } if (s->back_arrow) { l->back_arrow = create_arrow(); l->back_arrow->type = s->back_arrow->type; l->back_arrow->style = s->back_arrow->style; l->back_arrow->thickness = s->back_arrow->thickness; l->back_arrow->wd = s->back_arrow->wd; l->back_arrow->ht = s->back_arrow->ht; } else { l->back_arrow = NULL; } /* now we have finished creating the line, we can get rid of the spline */ delete_spline(s); /* and put in the new line */ mask_toggle_linemarker(l); list_add_line(&objects.lines, l); redisplay_line(l); set_action_object(F_CONVERT, O_SPLINE); set_latestline(l); set_modifiedflag(); return; }