1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2025-01-03 21:40:16 +02:00

cameo: apply translation after loading a file only to the new file

- lang.y (translate): list of paths is now an argument (instead of always
  using the global path list)
- lang.y: on "gerber", "gnuplot", and "excellon", only translate the new
  paths
This commit is contained in:
Werner Almesberger 2010-12-15 06:34:53 -03:00
parent b76d17fea0
commit 7cb25c5a3f

View File

@ -41,12 +41,12 @@ static void add_paths(struct path *new)
} }
static void translate(double x, double y, double z) static void translate(struct path *list, double x, double y, double z)
{ {
struct path *path; struct path *path;
struct point *p; struct point *p;
for (path = paths; path; path = path->next) for (path = list; path; path = path->next)
for (p = path->first; p; p = p->next) { for (p = path->first; p; p = p->next) {
p->x += x; p->x += x;
p->y += y; p->y += y;
@ -103,7 +103,7 @@ static void align(int ref, double x, double y)
xd = x-xr; xd = x-xr;
yd = y-yr; yd = y-yr;
translate(xd, yd, 0); translate(paths, xd, yd, 0);
xo += xd; xo += xd;
yo += yd; yo += yd;
} }
@ -191,7 +191,7 @@ command:
double x = $2*$4; double x = $2*$4;
double y = $3*$5; double y = $3*$5;
translate(x, y, 0); translate(paths, x, y, 0);
xo += x; xo += x;
yo += y; yo += y;
} }
@ -210,7 +210,7 @@ command:
} }
| TOK_TRANSLATE dimen dimen | TOK_TRANSLATE dimen dimen
{ {
translate($2, $3, 0); translate(paths, $2, $3, 0);
xo += $2; xo += $2;
yo += $3; yo += $3;
} }
@ -224,30 +224,39 @@ command:
} }
| TOK_GERBER dimen opt_filename | TOK_GERBER dimen opt_filename
{ {
add_paths(gerber_read($3, $2/2)); struct path *new;
translate(xo, yo, 0);
new = gerber_read($3, $2/2);
translate(new, xo, yo, 0);
add_paths(new);
} }
| TOK_GNUPLOT dimen opt_filename | TOK_GNUPLOT dimen opt_filename
{ {
add_paths(gnuplot_read($3, $2/2)); struct path *new;
translate(xo, yo, 0);
new = gnuplot_read($3, $2/2);
translate(new, xo, yo, 0);
add_paths(new);
} }
| TOK_EXCELLON opt_filename | TOK_EXCELLON opt_filename
{ {
add_paths(excellon_read($2)); struct path *new;
translate(xo, yo, 0);
new = excellon_read($2);
translate(new, xo, yo, 0);
add_paths(new);
} }
| TOK_WRITE opt_filename | TOK_WRITE opt_filename
{ {
translate(0, 0, zo); translate(paths, 0, 0, zo);
gnuplot_write($2, paths); gnuplot_write($2, paths);
translate(0, 0, -zo); translate(paths, 0, 0, -zo);
} }
| TOK_APPEND opt_filename | TOK_APPEND opt_filename
{ {
translate(0, 0, zo); translate(paths, 0, 0, zo);
gnuplot_append($2, paths); gnuplot_append($2, paths);
translate(0, 0, -zo); translate(paths, 0, 0, -zo);
} }
| TOK_DRILL dimen dimen | TOK_DRILL dimen dimen
{ {