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 undo_move(void) { int dx, dy; int xmin1, ymin1, xmax1, ymax1; int xmin2, ymin2, xmax2, ymax2; int dum; dx = last_position.x - new_position.x; dy = last_position.y - new_position.y; switch (last_object) { case O_POLYLINE: line_bound(saved_objects.lines, &xmin1, &ymin1, &xmax1, &ymax1); translate_line(saved_objects.lines, dx, dy); line_bound(saved_objects.lines, &xmin2, &ymin2, &xmax2, &ymax2); adjust_links(last_linkmode, last_links, dx, dy, 0, 0, 1.0, 1.0, False); redisplay_regions(xmin1, ymin1, xmax1, ymax1, xmin2, ymin2, xmax2, ymax2); break; case O_ELLIPSE: ellipse_bound(saved_objects.ellipses, &xmin1, &ymin1, &xmax1, &ymax1); translate_ellipse(saved_objects.ellipses, dx, dy); ellipse_bound(saved_objects.ellipses, &xmin2, &ymin2, &xmax2, &ymax2); redisplay_regions(xmin1, ymin1, xmax1, ymax1, xmin2, ymin2, xmax2, ymax2); break; case O_TXT: text_bound(saved_objects.texts, &xmin1, &ymin1, &xmax1, &ymax1, &dum,&dum,&dum,&dum,&dum,&dum,&dum,&dum); translate_text(saved_objects.texts, dx, dy); text_bound(saved_objects.texts, &xmin2, &ymin2, &xmax2, &ymax2, &dum,&dum,&dum,&dum,&dum,&dum,&dum,&dum); redisplay_regions(xmin1, ymin1, xmax1, ymax1, xmin2, ymin2, xmax2, ymax2); break; case O_SPLINE: spline_bound(saved_objects.splines, &xmin1, &ymin1, &xmax1, &ymax1); translate_spline(saved_objects.splines, dx, dy); spline_bound(saved_objects.splines, &xmin2, &ymin2, &xmax2, &ymax2); redisplay_regions(xmin1, ymin1, xmax1, ymax1, xmin2, ymin2, xmax2, ymax2); break; case O_ARC: arc_bound(saved_objects.arcs, &xmin1, &ymin1, &xmax1, &ymax1); translate_arc(saved_objects.arcs, dx, dy); arc_bound(saved_objects.arcs, &xmin2, &ymin2, &xmax2, &ymax2); redisplay_regions(xmin1, ymin1, xmax1, ymax1, xmin2, ymin2, xmax2, ymax2); break; case O_COMPOUND: compound_bound(saved_objects.compounds, &xmin1, &ymin1, &xmax1, &ymax1); translate_compound(saved_objects.compounds, dx, dy); compound_bound(saved_objects.compounds, &xmin2, &ymin2, &xmax2, &ymax2); adjust_links(last_linkmode, last_links, dx, dy, 0, 0, 1.0, 1.0, False); redisplay_regions(xmin1, ymin1, xmax1, ymax1, xmin2, ymin2, xmax2, ymax2); break; } swap_newp_lastp(); }
void Trace::thin_trace(TracePointList& tlist, const unsigned mrange_sq) { if (tlist.size() < 2) return; TracePointList::iterator it_prev = tlist.begin(); TracePointList::iterator it = tlist.begin(); ++it; TracePointList::iterator it_next = it; ++it_next; for (; it_next != tlist.end();) { if (it->approx_sq_dist(*it_prev) < mrange_sq) { adjust_links(*it_prev, *it, *it_next); it = tlist.erase(it); it_next = it; ++it_next; } else { ++it; ++it_next; ++it_prev; } } }