1 /*
2  * FIG : Facility for Interactive Generation of figures
3  * Copyright (c) 1985-1988 by Supoj Sutanthavibul
4  * Parts Copyright (c) 1989-2007 by Brian V. Smith
5  * Parts Copyright (c) 1991 by Paul King
6  *
7  * Any party obtaining a copy of these files is granted, free of charge, a
8  * full and unrestricted irrevocable, world-wide, paid up, royalty-free,
9  * nonexclusive right and license to deal in this software and documentation
10  * files (the "Software"), including without limitation the rights to use,
11  * copy, modify, merge, publish, distribute, sublicense and/or sell copies of
12  * the Software, and to permit persons who receive copies from any such
13  * party to do so, with the only requirement being that the above copyright
14  * and this permission notice remain intact.
15  *
16  */
17 
18 #include "fig.h"
19 #include "resources.h"
20 #include "object.h"
21 
22 
23 void translate_lines (F_line *lines, int dx, int dy);
24 void translate_splines (F_spline *splines, int dx, int dy);
25 void translate_ellipses (F_ellipse *ellipses, int dx, int dy);
26 void translate_arcs (F_arc *arcs, int dx, int dy);
27 void translate_texts (F_text *texts, int dx, int dy);
28 void translate_compounds (F_compound *compounds, int dx, int dy);
29 
translate_ellipse(F_ellipse * ellipse,int dx,int dy)30 void translate_ellipse(F_ellipse *ellipse, int dx, int dy)
31 {
32     ellipse->center.x += dx;
33     ellipse->center.y += dy;
34     ellipse->start.x += dx;
35     ellipse->start.y += dy;
36     ellipse->end.x += dx;
37     ellipse->end.y += dy;
38 }
39 
translate_arc(F_arc * arc,int dx,int dy)40 void translate_arc(F_arc *arc, int dx, int dy)
41 {
42     arc->center.x += (float) dx;
43     arc->center.y += (float) dy;
44     arc->point[0].x += dx;
45     arc->point[0].y += dy;
46     arc->point[1].x += dx;
47     arc->point[1].y += dy;
48     arc->point[2].x += dx;
49     arc->point[2].y += dy;
50 }
51 
translate_line(F_line * line,int dx,int dy)52 void translate_line(F_line *line, int dx, int dy)
53 {
54     F_point	   *point;
55 
56     for (point = line->points; point != NULL; point = point->next) {
57 	point->x += dx;
58 	point->y += dy;
59     }
60 }
61 
translate_text(F_text * text,int dx,int dy)62 void translate_text(F_text *text, int dx, int dy)
63 {
64     text->base_x += dx;
65     text->base_y += dy;
66 }
67 
translate_spline(F_spline * spline,int dx,int dy)68 void translate_spline(F_spline *spline, int dx, int dy)
69 {
70     F_point	   *point;
71 
72     for (point = spline->points; point != NULL; point = point->next) {
73 	point->x += dx;
74 	point->y += dy;
75     }
76 
77 }
78 
translate_compound(F_compound * compound,int dx,int dy)79 void translate_compound(F_compound *compound, int dx, int dy)
80 {
81     compound->nwcorner.x += dx;
82     compound->nwcorner.y += dy;
83     compound->secorner.x += dx;
84     compound->secorner.y += dy;
85 
86     translate_lines(compound->lines, dx, dy);
87     translate_splines(compound->splines, dx, dy);
88     translate_ellipses(compound->ellipses, dx, dy);
89     translate_arcs(compound->arcs, dx, dy);
90     translate_texts(compound->texts, dx, dy);
91     translate_compounds(compound->compounds, dx, dy);
92 }
93 
translate_arcs(F_arc * arcs,int dx,int dy)94 void translate_arcs(F_arc *arcs, int dx, int dy)
95 {
96     F_arc	   *a;
97 
98     for (a = arcs; a != NULL; a = a->next)
99 	translate_arc(a, dx, dy);
100 }
101 
translate_compounds(F_compound * compounds,int dx,int dy)102 void translate_compounds(F_compound *compounds, int dx, int dy)
103 {
104     F_compound	   *c;
105 
106     for (c = compounds; c != NULL; c = c->next)
107 	translate_compound(c, dx, dy);
108 }
109 
translate_ellipses(F_ellipse * ellipses,int dx,int dy)110 void translate_ellipses(F_ellipse *ellipses, int dx, int dy)
111 {
112     F_ellipse	   *e;
113 
114     for (e = ellipses; e != NULL; e = e->next)
115 	translate_ellipse(e, dx, dy);
116 }
117 
translate_lines(F_line * lines,int dx,int dy)118 void translate_lines(F_line *lines, int dx, int dy)
119 {
120     F_line	   *l;
121 
122     for (l = lines; l != NULL; l = l->next)
123 	translate_line(l, dx, dy);
124 }
125 
translate_splines(F_spline * splines,int dx,int dy)126 void translate_splines(F_spline *splines, int dx, int dy)
127 {
128     F_spline	   *s;
129 
130     for (s = splines; s != NULL; s = s->next)
131 	translate_spline(s, dx, dy);
132 }
133 
translate_texts(F_text * texts,int dx,int dy)134 void translate_texts(F_text *texts, int dx, int dy)
135 {
136     F_text	   *t;
137 
138     for (t = texts; t != NULL; t = t->next)
139 	translate_text(t, dx, dy);
140 }
141