From c979bf09899ad36dd0038b5c16a10d95fb1e04c4 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Mon, 25 Jul 2016 00:50:48 -0300 Subject: [PATCH] sch2fig/: support circles --- sch2fig/fig.c | 16 ++++++++++++++++ sch2fig/fig.h | 1 + sch2fig/lib.c | 29 +++++++++++++++++++++++++++-- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/sch2fig/fig.c b/sch2fig/fig.c index bf88a0c..6ae66df 100644 --- a/sch2fig/fig.c +++ b/sch2fig/fig.c @@ -223,12 +223,15 @@ void fig_glabel(int x, int y, const char *s, int dir, int dim, void fig_junction(int x, int y) { +#if 0 // Type Thick Depth StyleV Cx Rx Sx Ex // SubTy Color Pen Dir Cy Ry Sy Ey // Style FillCol AreaFil Angle printf("1 3 0 0 -1 %d %d -1 20 0.0 1 0.0 %d %d %d %d %d %d %d %d\n", COLOR_WIRE, LAYER_WIRES, cx(x), cy(y), JUNCTION_R, JUNCTION_R, cx(x), cy(y), cx(x) + JUNCTION_R, cy(y)); +#endif + fig_circ(x, y, JUNCTION_R, COLOR_NONE, COLOR_WIRE, LAYER_WIRES); } @@ -303,6 +306,19 @@ void fig_poly(int points, int x[points], int y[points], } +void fig_circ(int x, int y, int r, int color, int fill_color, unsigned layer) +{ + // Type Thick Depth StyleV Cx Rx Sx Ex + // SubTy Color Pen Dir Cy Ry Sy Ey + // Style FillCol AreaFil Angle + printf("1 3 0 %d %d %d %d -1 %d 0.0 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), r, r, + cx(x), cy(y), cx(x) + r, cy(y)); +} + + void fig_text(int x, int y, const char *s, unsigned size, enum text_align align, int rot, unsigned color, unsigned layer) { diff --git a/sch2fig/fig.h b/sch2fig/fig.h index ed77aaf..56f5d0f 100644 --- a/sch2fig/fig.h +++ b/sch2fig/fig.h @@ -45,6 +45,7 @@ void fig_rect(int sx, int sy, int ex, int ey, int color, int fill_color, unsigned layer); void fig_poly(int points, int x[points], int y[points], int color, int fill_color, unsigned layer); +void fig_circ(int x, int y, int r, int color, int fill_color, unsigned layer); void fig_text(int x, int y, const char *s, unsigned size, enum text_align align, int rot, unsigned color, unsigned layer); diff --git a/sch2fig/lib.c b/sch2fig/lib.c index 5d19c76..ddb8559 100644 --- a/sch2fig/lib.c +++ b/sch2fig/lib.c @@ -53,7 +53,7 @@ struct obj { int sx, sy; int ex, ey; } rect; - struct { + struct circ_obj { int x, y; int r; int thick; @@ -163,6 +163,31 @@ static void draw_rect(const struct rect_obj *rect, int m[6]) } +static void draw_circ(const struct circ_obj *circ, int m[6]) +{ + int x = mx(circ->x, circ->y, m); + int y = my(circ->x, circ->y, m); + int r = circ->r; + + fig_circ(x, y, r, COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG); + + switch (circ->fill) { + case 'N': + break; + case 'F': + fig_circ(x, y, r, COLOR_NONE, COLOR_COMP_DWG, + LAYER_COMP_DWG_BG); + break; + case 'f': + fig_circ(x, y, r, COLOR_NONE, COLOR_COMP_DWG_BG, + LAYER_COMP_DWG_BG); + break; + default: + abort(); + } +} + + static void draw_pin(const struct comp *comp, const struct pin_obj *pin, int m[6]) { @@ -279,7 +304,7 @@ static void draw(const struct comp *comp, const struct obj *obj, int m[6]) draw_rect(&obj->u.rect, m); break; case obj_circ: - unsupported("circle"); + draw_circ(&obj->u.circ, m); break; case obj_arc: unsupported("arc");