mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2025-01-03 20:20:15 +02:00
cameo/: new command "flip" to flip paths on the X or Y axis
This commit is contained in:
parent
c73509dacc
commit
a030eff963
@ -99,6 +99,7 @@ Horizontal adjustments:
|
|||||||
array <x-step> <y-step> <x-index> <y-index>
|
array <x-step> <y-step> <x-index> <y-index>
|
||||||
translate <x> <y>
|
translate <x> <y>
|
||||||
rotate <angle>
|
rotate <angle>
|
||||||
|
flip <axis> [<center>]
|
||||||
reset
|
reset
|
||||||
|
|
||||||
"translate" shifts the currently loaded paths by the specified distance.
|
"translate" shifts the currently loaded paths by the specified distance.
|
||||||
@ -139,6 +140,9 @@ Note that rotation is applied before translation. Therefore, using
|
|||||||
"rotate" after "translate", "array", or "align" may yield unexpected
|
"rotate" after "translate", "array", or "align" may yield unexpected
|
||||||
results.
|
results.
|
||||||
|
|
||||||
|
"flip" flips X/Y coordinates on the respective axis ("x" or "y"). If
|
||||||
|
the center is omitted, the piece is flipped on (xymin+xymax)/2.
|
||||||
|
|
||||||
"reset" sets translation and rotation to zero. The way "reset" is currently
|
"reset" sets translation and rotation to zero. The way "reset" is currently
|
||||||
implemented, it does not affect the currently loaded toolpath. (But it's
|
implemented, it does not affect the currently loaded toolpath. (But it's
|
||||||
better to use it only with "clean".)
|
better to use it only with "clean".)
|
||||||
|
@ -45,6 +45,7 @@ NUM -?[0-9]+\.?[0-9]*
|
|||||||
<INITIAL>clear return TOK_CLEAR;
|
<INITIAL>clear return TOK_CLEAR;
|
||||||
<INITIAL>drill return TOK_DRILL;
|
<INITIAL>drill return TOK_DRILL;
|
||||||
<INITIAL>empty return TOK_EMPTY;
|
<INITIAL>empty return TOK_EMPTY;
|
||||||
|
<INITIAL>flip return TOK_FLIP;
|
||||||
<INITIAL>keep return TOK_KEEP;
|
<INITIAL>keep return TOK_KEEP;
|
||||||
<INITIAL>mill return TOK_MILL;
|
<INITIAL>mill return TOK_MILL;
|
||||||
<INITIAL>offset return TOK_OFFSET;
|
<INITIAL>offset return TOK_OFFSET;
|
||||||
@ -57,6 +58,8 @@ NUM -?[0-9]+\.?[0-9]*
|
|||||||
<INITIAL>rotate return TOK_ROTATE;
|
<INITIAL>rotate return TOK_ROTATE;
|
||||||
<INITIAL>stats return TOK_STATS;
|
<INITIAL>stats return TOK_STATS;
|
||||||
<INITIAL>translate return TOK_TRANSLATE;
|
<INITIAL>translate return TOK_TRANSLATE;
|
||||||
|
<INITIAL>x return TOK_X;
|
||||||
|
<INITIAL>y return TOK_Y;
|
||||||
<INITIAL>z return TOK_Z;
|
<INITIAL>z return TOK_Z;
|
||||||
|
|
||||||
<INITIAL>append { BEGIN(FILENAME);
|
<INITIAL>append { BEGIN(FILENAME);
|
||||||
|
66
cameo/lang.y
66
cameo/lang.y
@ -80,6 +80,43 @@ static void rotate(struct path *list, double angle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void flip(struct path *list, enum axis axis, double center)
|
||||||
|
{
|
||||||
|
const struct path *path;
|
||||||
|
struct point *p;
|
||||||
|
|
||||||
|
for (path = list; path; path = path->next)
|
||||||
|
for (p = path->first; p; p = p->next) {
|
||||||
|
if (axis == axis_x)
|
||||||
|
p->x = 2*center-p->x;
|
||||||
|
else
|
||||||
|
p->y = 2*center-p->y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void flip_center(struct path *list, enum axis axis)
|
||||||
|
{
|
||||||
|
double min = 0, max = 0;
|
||||||
|
double coord;
|
||||||
|
const struct path *path;
|
||||||
|
const struct point *p;
|
||||||
|
int first = 1;
|
||||||
|
|
||||||
|
for (path = list; path; path = path->next)
|
||||||
|
for (p = path->first; p; p = p->next) {
|
||||||
|
coord = axis == axis_x ? p->x : p->y;
|
||||||
|
if (first || coord < min)
|
||||||
|
min = coord;
|
||||||
|
if (first || coord > max)
|
||||||
|
max = coord;
|
||||||
|
first = 0;
|
||||||
|
}
|
||||||
|
flip(list, axis, (min+max)/2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static double ref_pick_1(int ref, double a, double b)
|
static double ref_pick_1(int ref, double a, double b)
|
||||||
{
|
{
|
||||||
switch (ref) {
|
switch (ref) {
|
||||||
@ -184,14 +221,19 @@ static struct path **classify(struct path **anchor, struct path *path)
|
|||||||
OO_DOG = 1 << 0,
|
OO_DOG = 1 << 0,
|
||||||
OO_INSIDE = 1 << 1,
|
OO_INSIDE = 1 << 1,
|
||||||
} oopt;
|
} oopt;
|
||||||
|
enum axis {
|
||||||
|
axis_x,
|
||||||
|
axis_y
|
||||||
|
} axis;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
%token TOK_ALIGN TOK_AREA TOK_ARRAY TOK_CLEAR TOK_DRILL TOK_EMPTY
|
%token TOK_ALIGN TOK_AREA TOK_ARRAY TOK_CLEAR TOK_DRILL TOK_EMPTY
|
||||||
%token TOK_KEEP TOK_MILL TOK_OFFSET TOK_OPTIMIZE
|
%token TOK_FLIP TOK_KEEP TOK_MILL TOK_OFFSET TOK_OPTIMIZE
|
||||||
%token TOK_OUTSIDE TOK_REMAINDER
|
%token TOK_OUTSIDE TOK_REMAINDER
|
||||||
%token TOK_REMOVE TOK_RESET
|
%token TOK_REMOVE TOK_RESET
|
||||||
%token TOK_REVERSE TOK_ROTATE TOK_STATS TOK_TRANSLATE TOK_Z
|
%token TOK_REVERSE TOK_ROTATE TOK_STATS TOK_TRANSLATE
|
||||||
|
%token TOK_X TOK_Y TOK_Z
|
||||||
%token TOK_APPEND TOK_GERBER TOK_GNUPLOT TOK_EXCELLON TOK_WRITE
|
%token TOK_APPEND TOK_GERBER TOK_GNUPLOT TOK_EXCELLON TOK_WRITE
|
||||||
%token TOK_DOG TOK_INSIDE TOK_ANY
|
%token TOK_DOG TOK_INSIDE TOK_ANY
|
||||||
|
|
||||||
@ -202,6 +244,7 @@ static struct path **classify(struct path **anchor, struct path *path)
|
|||||||
%type <num> dimen number x_size y_size
|
%type <num> dimen number x_size y_size
|
||||||
%type <flag> opt_any
|
%type <flag> opt_any
|
||||||
%type <oopt> offset_options offset_option
|
%type <oopt> offset_options offset_option
|
||||||
|
%type <axis> axis
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
@ -283,6 +326,14 @@ command:
|
|||||||
rotate(paths, $2);
|
rotate(paths, $2);
|
||||||
rot += $2;
|
rot += $2;
|
||||||
}
|
}
|
||||||
|
| TOK_FLIP axis
|
||||||
|
{
|
||||||
|
flip_center(paths, $2);
|
||||||
|
}
|
||||||
|
| TOK_FLIP axis dimen
|
||||||
|
{
|
||||||
|
flip(paths, $2, $3);
|
||||||
|
}
|
||||||
| TOK_STATS
|
| TOK_STATS
|
||||||
{
|
{
|
||||||
path_stats(paths);
|
path_stats(paths);
|
||||||
@ -489,6 +540,17 @@ offset_option:
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
axis:
|
||||||
|
TOK_X
|
||||||
|
{
|
||||||
|
$$ = axis_x;
|
||||||
|
}
|
||||||
|
| TOK_Y
|
||||||
|
{
|
||||||
|
$$ = axis_y;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
opt_comma:
|
opt_comma:
|
||||||
| ','
|
| ','
|
||||||
;
|
;
|
||||||
|
Loading…
Reference in New Issue
Block a user