Boolean next_arc_found(int x, int y, int tolerance, int *px, int *py, unsigned int shift) { int i; if (!arc_in_mask()) return False; if (a == NULL) if (shift) a = last_arc(objects.arcs); else a = objects.arcs; else if (shift) a = prev_arc(objects.arcs, a); for (; a != NULL; a = (shift? prev_arc(objects.arcs, a): a->next), n++) { if (!active_layer(a->depth)) continue; for (i = 0; i < 3; i++) { if ((abs(a->point[i].x - x) <= tolerance) && (abs(a->point[i].y - y) <= tolerance)) { *px = a->point[i].x; *py = a->point[i].y; return True; } } { /* still nothing */ /* check if we're at the arc radius from the arc center */ double dist = hypot((double)y - (double)(a->center.y), (double)x - (double)(a->center.x)); double radius = hypot((double)(a->point[1].y) - (double)(a->center.y), (double)(a->point[1].x) - (double)(a->center.x)); if (fabs(radius - dist) < (double)tolerance) { /* ok, we're somewhere on the circle the arc is part of */ /* now, check if we're on the arc itself */ if (True == is_point_on_arc(a, x, y)) { /* yep, we're on the actual arc */ /* now we find the closest control point */ double mind = HUGE_VAL; int pp; for (i = 0; i < 3; i++) { dist = hypot((double)y - (double)(a->point[i].y), (double)x - (double)(a->point[i].x)); if (dist < mind) { mind = dist; pp = i; } } *px = a->point[pp].x; *py = a->point[pp].y; return True; } } } } return False; }
static void sel_line(int xmin, int ymin, int xmax, int ymax) { F_line *l; F_point *p; int inbound; for (l = objects.lines; l != NULL; l = l->next) { if (!active_layer(l->depth)) continue; for (inbound = 1, p = l->points; p != NULL && inbound; p = p->next) { inbound = 0; if (xmin > p->x) continue; if (xmax < p->x) continue; if (ymin > p->y) continue; if (ymax < p->y) continue; inbound = 1; } if (!inbound) continue; l->tagged = 1 - l->tagged; toggle_linehighlight(l); } }
static void align_spline(void) { F_spline *s; for (s = cur_c->splines; s != NULL; s = s->next) { if (!active_layer(s->depth)) continue; spline_bound(s, &llx, &lly, &urx, &ury); get_dx_dy(); translate_spline(s, dx, dy); } }
static void align_line(void) { F_line *l; for (l = cur_c->lines; l != NULL; l = l->next) { if (!active_layer(l->depth)) continue; line_bound(l, &llx, &lly, &urx, &ury); get_dx_dy(); translate_line(l, dx, dy); } }
static void align_arc(void) { F_arc *a; for (a = cur_c->arcs; a != NULL; a = a->next) { if (!active_layer(a->depth)) continue; arc_bound(a, &llx, &lly, &urx, &ury); get_dx_dy(); translate_arc(a, dx, dy); } }
static void align_ellipse(void) { F_ellipse *e; for (e = cur_c->ellipses; e != NULL; e = e->next) { if (!active_layer(e->depth)) continue; ellipse_bound(e, &llx, &lly, &urx, &ury); get_dx_dy(); translate_ellipse(e, dx, dy); } }
static void align_text(void) { F_text *t; int dum; for (t = cur_c->texts; t != NULL; t = t->next) { if (!active_layer(t->depth)) continue; text_bound(t, &llx, &lly, &urx, &ury, &dum,&dum,&dum,&dum,&dum,&dum,&dum,&dum); get_dx_dy(); translate_text(t, dx, dy); } }
static void sel_text(int xmin, int ymin, int xmax, int ymax) { F_text *t; int txmin, txmax, tymin, tymax; int dum; for (t = objects.texts; t != NULL; t = t->next) { if (!active_layer(t->depth)) continue; text_bound(t, &txmin, &tymin, &txmax, &tymax, &dum,&dum,&dum,&dum,&dum,&dum,&dum,&dum); if (xmin > txmin || xmax < txmax || ymin > tymin || ymax < tymax) continue; t->tagged = 1 - t->tagged; toggle_texthighlight(t); } }
static void sel_ellipse(int xmin, int ymin, int xmax, int ymax) { F_ellipse *e; for (e = objects.ellipses; e != NULL; e = e->next) { if (!active_layer(e->depth)) continue; if (xmin > e->center.x - e->radiuses.x) continue; if (xmax < e->center.x + e->radiuses.x) continue; if (ymin > e->center.y - e->radiuses.y) continue; if (ymax < e->center.y + e->radiuses.y) continue; e->tagged = 1 - e->tagged; toggle_ellipsehighlight(e); } }
static void sel_spline(int xmin, int ymin, int xmax, int ymax) { F_spline *s; int urx, ury, llx, lly; for (s = objects.splines; s != NULL; s = s->next) { if (!active_layer(s->depth)) continue; spline_bound(s, &llx, &lly, &urx, &ury); if (xmin > llx) continue; if (xmax < urx) continue; if (ymin > lly) continue; if (ymax < ury) continue; s->tagged = 1 - s->tagged; toggle_splinehighlight(s); } }
static void sel_arc(int xmin, int ymin, int xmax, int ymax) { F_arc *a; int urx, ury, llx, lly; for (a = objects.arcs; a != NULL; a = a->next) { if (!active_layer(a->depth)) continue; arc_bound(a, &llx, &lly, &urx, &ury); if (xmin > llx) continue; if (xmax < urx) continue; if (ymin > lly) continue; if (ymax < ury) continue; a->tagged = 1 - a->tagged; toggle_archighlight(a); } }