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(); }
/* * pos_ellipse: If the position of the given ellipse is less * than passed in and the ellipse hasn't already been distributed, adjust the * value of the passed in parameter. Also set the width/height if smaller. * If dir == 0, handle horizontal, otherwise vertical. */ static Boolean pos_ellipse (F_ellipse *e, int *min, int *size, int dir) { int center; ellipse_bound (e, &llx, &lly, &urx, &ury); if (dir == 0) { if (cur_halign == ALIGN_DISTRIB_C) center = (urx + llx)/2; else center = min2(urx, llx); } else { if (cur_valign == ALIGN_DISTRIB_C) center = (ury + lly)/2; else center = min2(ury, lly); } if ( (center < *min) && (e->distrib == 0) ) { *min = center; if (dir == 0) *size = abs(urx - llx); else *size = abs(ury - lly); return True; } else return False; } /* pos_ellipse */
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); } }
/* * Determine: * - the number of objects, * - the sum of the widths/heights of all objects, * - the left/top most left/top object edge, * - the right/bottom most right/bottom object edge, * - mark all objects as not distributed. * * dir = 0 for horizontal, 1 for vertical. */ static int init_distrib_edges (int *min, int *max, int *sum, int dir) { F_ellipse *e; F_arc *a; F_line *l; F_spline *s; F_compound *c; F_text *t; int num_objects = 0; *min = INT_MAX; *max = INT_MIN; *sum = 0; for (e = cur_c->ellipses; e != NULL; e = e->next) { num_objects++; e->distrib = 0; ellipse_bound (e, &llx, &lly, &urx, &ury); if (dir == 0) { *sum += abs(urx - llx); if (llx < *min) *min = llx; if (urx > *max) *max = urx; } else { *sum += abs(ury - lly); if (lly < *min) *min = lly; if (ury > *max) *max = ury; } } for (a = cur_c->arcs; a != NULL; a = a->next) { num_objects++; a->distrib = 0; arc_bound (a, &llx, &lly, &urx, &ury); if (dir == 0) { *sum += abs(urx - llx); if (llx < *min) *min = llx; if (urx > *max) *max = urx; } else { *sum += abs(ury - lly); if (lly < *min) *min = lly; if (ury > *max) *max = ury; } } for (l = cur_c->lines; l != NULL; l = l->next) { num_objects++; l->distrib = 0; line_bound (l, &llx, &lly, &urx, &ury); if (dir == 0) { *sum += abs(urx - llx); if (llx < *min) *min = llx; if (urx > *max) *max = urx; } else { *sum += abs(ury - lly); if (lly < *min) *min = lly; if (ury > *max) *max = ury; } } for (s = cur_c->splines; s != NULL; s = s->next) { num_objects++; s->distrib = 0; spline_bound (s, &llx, &lly, &urx, &ury); if (dir == 0) { *sum += abs(urx - llx); if (llx < *min) *min = llx; if (urx > *max) *max = urx; } else { *sum += abs(ury - lly); if (lly < *min) *min = lly; if (ury > *max) *max = ury; } } for (c = cur_c->compounds; c != NULL; c = c->next) { num_objects++; c->distrib = 0; compound_bound (c, &llx, &lly, &urx, &ury); if (dir == 0) { *sum += abs(urx - llx); if (llx < *min) *min = llx; if (urx > *max) *max = urx; } else { *sum += abs(ury - lly); if (lly < *min) *min = lly; if (ury > *max) *max = ury; } } for (t = cur_c->texts; t != NULL; t = t->next) { int dum; num_objects++; t->distrib = 0; text_bound (t, &llx, &lly, &urx, &ury, &dum,&dum,&dum,&dum,&dum,&dum,&dum,&dum); if (dir == 0) { *sum += abs(urx - llx); if (llx < *min) *min = llx; if (urx > *max) *max = urx; } else { *sum += abs(ury - lly); if (lly < *min) *min = lly; if (ury > *max) *max = ury; } } return (num_objects); } /* init_distrib_edges */
/* * Determine: * - the number of objects, * - the left/top most centre and the right/bottom most centre, * - mark all objects as not distributed. * * dir = 0 for horizontal, 1 for vertical. */ static int init_distrib_centres (int *min, int *max, int dir) { F_ellipse *e; F_arc *a; F_line *l; F_spline *s; F_compound *c; F_text *t; int num_objects = 0; *min = INT_MAX; *max = INT_MIN; for (e = cur_c->ellipses; e != NULL; e = e->next) { num_objects++; e->distrib = 0; ellipse_bound (e, &llx, &lly, &urx, &ury); if (dir == 0) MIN_MAX_CENTRE(llx, urx, *min, *max) else MIN_MAX_CENTRE(lly, ury, *min, *max) } for (a = cur_c->arcs; a != NULL; a = a->next) { num_objects++; a->distrib = 0; arc_bound (a, &llx, &lly, &urx, &ury); if (dir == 0) MIN_MAX_CENTRE(llx, urx, *min, *max) else MIN_MAX_CENTRE(lly, ury, *min, *max) } for (l = cur_c->lines; l != NULL; l = l->next) { num_objects++; l->distrib = 0; line_bound (l, &llx, &lly, &urx, &ury); if (dir == 0) MIN_MAX_CENTRE(llx, urx, *min, *max) else MIN_MAX_CENTRE(lly, ury, *min, *max) } for (s = cur_c->splines; s != NULL; s = s->next) { num_objects++; s->distrib = 0; spline_bound (s, &llx, &lly, &urx, &ury); if (dir == 0) MIN_MAX_CENTRE(llx, urx, *min, *max) else MIN_MAX_CENTRE(lly, ury, *min, *max) } for (c = cur_c->compounds; c != NULL; c = c->next) { num_objects++; c->distrib = 0; compound_bound (c, &llx, &lly, &urx, &ury); if (dir == 0) MIN_MAX_CENTRE(llx, urx, *min, *max) else MIN_MAX_CENTRE(lly, ury, *min, *max) } for (t = cur_c->texts; t != NULL; t = t->next) { int dum; num_objects++; t->distrib = 0; text_bound (t, &llx, &lly, &urx, &ury, &dum,&dum,&dum,&dum,&dum,&dum,&dum,&dum); if (dir == 0) MIN_MAX_CENTRE(llx, urx, *min, *max) else MIN_MAX_CENTRE(lly, ury, *min, *max) } return (num_objects); } /* init_distrib_centres */