From 7cb25c5a3fe36eba8466e38c37c9f11c9aabc99b Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Wed, 15 Dec 2010 06:34:53 -0300 Subject: [PATCH] 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 --- cameo/lang.y | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/cameo/lang.y b/cameo/lang.y index 9faab0c..af69ae7 100644 --- a/cameo/lang.y +++ b/cameo/lang.y @@ -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 point *p; - for (path = paths; path; path = path->next) + for (path = list; path; path = path->next) for (p = path->first; p; p = p->next) { p->x += x; p->y += y; @@ -103,7 +103,7 @@ static void align(int ref, double x, double y) xd = x-xr; yd = y-yr; - translate(xd, yd, 0); + translate(paths, xd, yd, 0); xo += xd; yo += yd; } @@ -191,7 +191,7 @@ command: double x = $2*$4; double y = $3*$5; - translate(x, y, 0); + translate(paths, x, y, 0); xo += x; yo += y; } @@ -210,7 +210,7 @@ command: } | TOK_TRANSLATE dimen dimen { - translate($2, $3, 0); + translate(paths, $2, $3, 0); xo += $2; yo += $3; } @@ -224,30 +224,39 @@ command: } | TOK_GERBER dimen opt_filename { - add_paths(gerber_read($3, $2/2)); - translate(xo, yo, 0); + struct path *new; + + new = gerber_read($3, $2/2); + translate(new, xo, yo, 0); + add_paths(new); } | TOK_GNUPLOT dimen opt_filename { - add_paths(gnuplot_read($3, $2/2)); - translate(xo, yo, 0); + struct path *new; + + new = gnuplot_read($3, $2/2); + translate(new, xo, yo, 0); + add_paths(new); } | TOK_EXCELLON opt_filename { - add_paths(excellon_read($2)); - translate(xo, yo, 0); + struct path *new; + + new = excellon_read($2); + translate(new, xo, yo, 0); + add_paths(new); } | TOK_WRITE opt_filename { - translate(0, 0, zo); + translate(paths, 0, 0, zo); gnuplot_write($2, paths); - translate(0, 0, -zo); + translate(paths, 0, 0, -zo); } | TOK_APPEND opt_filename { - translate(0, 0, zo); + translate(paths, 0, 0, zo); gnuplot_append($2, paths); - translate(0, 0, -zo); + translate(paths, 0, 0, -zo); } | TOK_DRILL dimen dimen {