-
-
Notifications
You must be signed in to change notification settings - Fork 54
Gerbv does not Acknowledge Rotation of Circle Primitives in Aperture Macros #254
Copy link
Copy link
Closed
Description
This might also be connected to Issue #253 but I'm not entirely sure.
I have an aperture macro that creates a C-shaped aperture that can be rotated.
*%FSLAX23Y23*%
*%MOIN*%
G01*
%AMC20-60-20*
0 C-shaped aperture with rounded corners, with rotation*
0 The origin of the aperture is its center*
0 $1 X-size*
0 $2 Y-size*
0 $3 Rotation angle, in degrees counterclockwise*
0 Add 4 overlapping rectangle primitives as box body*
21,1,$1,$2/3,0,0,$3*
21,1,$1x4/5,$2x2/3,0,0 + $2/6,$3*
21,1,$1/5,$2x2/3,0-$1x2/5,0,$3*
21,1,$1/5,$2x2/3,0+$1x2/5,0,$3*
0 Add four circle primitives for the rounded corners*
$5=$1/2*
$6=$2/2*
$7=$1/5*
1,1,$7,0+$1x2/5,0-$2/3,$3*
1,1,$7,0+$1x2/5,0+$2/3,$3*
1,1,$7,0-$1x2/5,0-$2/3,$3*
1,1,$7,0-$1x2/5,0+$2/3,$3*%
%ADD11C,0.005*%
%ADD12C,0.060*%
%ADD13C,0.010*%
%ADD26C20-60-20,0.1X0.06X90*%
%ADD27C20-60-20,0.1X0.06X270*%
%ADD28C20-60-20,0.1X0.06X0*%
%ADD29C20-60-20,0.1X0.06X180*%
D26*
X5345Y4329D03*
D27*
X5480Y4329D03*
D28*
X5817Y4444D03*
D29*
X5817Y4309D03*
D02*
M02*
and here is how it looks in Gerbv

I looked at the code and I think the problem is in the gerb_image.c file at line 542.
case GERBV_APTYPE_MACRO_CIRCLE:
/* TODO: test circle macro center rotation */
sam->parameter[CIRCLE_CENTER_X] *= trans->scaleX;
sam->parameter[CIRCLE_CENTER_Y] *= trans->scaleY;
gerbv_rotate_coord(
sam->parameter + CIRCLE_CENTER_X, sam->parameter + CIRCLE_CENTER_Y, trans->rotation
);
if (trans->scaleX != trans->scaleY) {
err_scale_circle++;
break;
}
sam->parameter[CIRCLE_DIAMETER] *= trans->scaleX;
break;I guess nobody got around to testing it.
Not only that, but when I compared it to "case GERBV_APTYPE_MACRO_LINE22" at Line 591, it looks like "case GERBV_APTYPE_MACRO_CIRCLE" is missing a lot of the features and contingencies that allow the rectangles to be rotated. That would explain why Gerbv is able to rotate my rectangles, but not my circles.
case GERBV_APTYPE_MACRO_LINE22:
/* Lower left line rectangle */
/* Using LINE21 parameters array
* indexes for LINE21 and LINE22, as
* they are equal */
if (trans->scaleX == trans->scaleY) {
sam->parameter[LINE21_WIDTH] *= trans->scaleX;
sam->parameter[LINE21_HEIGHT] *= trans->scaleX;
} else if (fabs(sam->parameter[LINE21_ROTATION]) == 0 || fabs(sam->parameter[LINE21_ROTATION]) == 180) {
sam->parameter[LINE21_WIDTH] *= trans->scaleX;
sam->parameter[LINE21_HEIGHT] *= trans->scaleY;
} else if (fabs(sam->parameter[LINE21_ROTATION]) == 90 || fabs(sam->parameter[LINE21_ROTATION]) == 270) {
double t;
t = sam->parameter[LINE21_WIDTH];
sam->parameter[LINE21_WIDTH] = trans->scaleY * sam->parameter[LINE21_HEIGHT];
sam->parameter[LINE21_HEIGHT] = trans->scaleX * t;
} else {
/* TODO: make outline macro */
err_scale_line_macro++;
break;
}
sam->parameter[LINE21_CENTER_X] *= trans->scaleX;
sam->parameter[LINE21_CENTER_Y] *= trans->scaleY;
sam->parameter[LINE21_ROTATION] += RAD2DEG(trans->rotation);
gerbv_rotate_coord(
sam->parameter + LINE21_CENTER_X, sam->parameter + LINE21_CENTER_Y, trans->rotation
);
break;There might be more code to fix that I'm missing, but I figured this was a good place to start.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
