mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-08-23 02:29:54 +03:00
sch2fig/: properly interpret KiCad arcs
They can be clockwise or counter-clockwise, but are always < 180 degrees.
This commit is contained in:
parent
b44293c4d6
commit
dd5f9d2128
@ -1,4 +1,3 @@
|
||||
- arcs aren't quite right yet
|
||||
- comment text orientation ?
|
||||
- better text size guessing
|
||||
- hierarchical labels
|
||||
|
@ -376,14 +376,13 @@ void fig_arc(int x, int y, int r, int sa, int ea,
|
||||
// Type Thick Depth StyleV FwdAr
|
||||
// SubTy Color Pen Cap BwdAr
|
||||
// Style FillCol AreaFil Dir points
|
||||
printf("5 1 0 %d %d %d %d -1 %d 0.0 1 0 0 0 %d %d %d %d %d %d %d %d\n",
|
||||
printf("5 1 0 %d %d %d %d -1 %d 0.0 1 1 0 0 %d %d %d %d %d %d %d %d\n",
|
||||
color == -1 ? 0 : WIDTH_COMP_DWG, color, fill_color, layer,
|
||||
fill_color == -1 ? -1 : 20,
|
||||
cx(x), cy(y),
|
||||
ax(x, y, r, sa), ay(x, y, r, sa),
|
||||
ax(x, y, r, ma), ay(x, y, r, ma),
|
||||
ax(x, y, r, ea), ay(x, y, r, ea));
|
||||
/* @@@ Note: with y flipped, we counter-clockwise becomes clockwise */
|
||||
}
|
||||
|
||||
|
||||
|
@ -461,8 +461,26 @@ static bool parse_arc(struct obj *obj, const char *line)
|
||||
&arc->thick, &arc->fill) != 9)
|
||||
return 0;
|
||||
|
||||
arc->start_a = a1 / 10;
|
||||
arc->end_a = a2 / 10;
|
||||
/*
|
||||
* KiCad arcs can be clockwise or counter-clockwise. They must always
|
||||
* be smaller than 180 degrees.
|
||||
*/
|
||||
|
||||
while (a1 < 0)
|
||||
a1 += 3600;
|
||||
while (a2 < 0)
|
||||
a2 += 3600;
|
||||
a1 %= 3600;
|
||||
a2 %= 3600;
|
||||
if (a2 < a1)
|
||||
a2 += 3600;
|
||||
assert(a2 - a1 != 1800);
|
||||
if (a2 - a1 > 1800)
|
||||
swap(a1, a2);
|
||||
|
||||
arc->start_a = (a1 % 3600) / 10;
|
||||
arc->end_a = (a2 % 3600) / 10;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user