From 3b18e8b60470ee97e4111a58b4d35e7c3f73c3ed Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sat, 30 Jul 2016 21:55:23 -0300 Subject: [PATCH] sch2fig/: make *_line accept color and layer from dwg --- sch2fig/dwg.c | 13 +++++++++++++ sch2fig/dwg.h | 2 ++ sch2fig/fig.c | 5 +++-- sch2fig/gfx.c | 4 ++-- sch2fig/gfx.h | 5 +++-- sch2fig/sch.c | 2 +- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/sch2fig/dwg.c b/sch2fig/dwg.c index 27b18cd..af37b7c 100644 --- a/sch2fig/dwg.c +++ b/sch2fig/dwg.c @@ -385,6 +385,19 @@ void dwg_noconn(int x, int y) } +/* ----- Lines ------------------------------------------------------------- */ + +/* + * We can't use gfx_poly because lines are dashed and we don't have that + * property at the gfx_poly API. + */ + +void dwg_line(int sx, int sy, int ex, int ey) +{ + gfx_line(sx, sy, ex, ey, COLOR_SHEET_DWG, LAYER_LINES); +} + + /* ----- Wires and busses -------------------------------------------------- */ diff --git a/sch2fig/dwg.h b/sch2fig/dwg.h index 7a1abf8..ea683c6 100644 --- a/sch2fig/dwg.h +++ b/sch2fig/dwg.h @@ -36,6 +36,8 @@ void dwg_glabel(int x, int y, const char *s, int dir, int dim, void dwg_junction(int x, int y); void dwg_noconn(int x, int y); +void dwg_line(int sx, int sy, int ex, int ey); + void dwg_wire(int sx, int sy, int ex, int ey); void dwg_bus(int sx, int sy, int ex, int ey); diff --git a/sch2fig/fig.c b/sch2fig/fig.c index 481c733..f95341a 100644 --- a/sch2fig/fig.c +++ b/sch2fig/fig.c @@ -51,13 +51,14 @@ static inline float pt(int x) /* ----- Schematics items -------------------------------------------------- */ -void fig_line(void *ctx, int sx, int sy, int ex, int ey) +void fig_line(void *ctx, int sx, int sy, int ex, int ey, + int color, unsigned layer) { // TypeStyle FillCol AreaFil Cap FwdAr // SubTy Color Pen StyleV Rad BwdAr // Thick Depth Join Points printf("2 1 2 %d %d 7 %d -1 -1 3.0 1 1 -1 0 0 2\n", - WIDTH_LINE, COLOR_SHEET_DWG, LAYER_LINES); + WIDTH_LINE, color, layer); printf("\t%d %d %d %d\n", cx(sx), cy(sy), cx(ex), cy(ey)); } diff --git a/sch2fig/gfx.c b/sch2fig/gfx.c index 6142ae1..27dab66 100644 --- a/sch2fig/gfx.c +++ b/sch2fig/gfx.c @@ -19,9 +19,9 @@ static const struct gfx_ops *gfx_ops; static void *gfx_ctx; -void gfx_line(int sx, int sy, int ex, int ey) +void gfx_line(int sx, int sy, int ex, int ey, int color, unsigned layer) { - gfx_ops->line(gfx_ctx, sx, sy, ex, ey); + gfx_ops->line(gfx_ctx, sx, sy, ex, ey, color, layer); } diff --git a/sch2fig/gfx.h b/sch2fig/gfx.h index c6f0a17..dce5383 100644 --- a/sch2fig/gfx.h +++ b/sch2fig/gfx.h @@ -18,7 +18,8 @@ struct gfx_ops { - void (*line)(void *ctx, int sx, int sy, int ex, int ey); + void (*line)(void *ctx, int sx, int sy, int ex, int ey, + int color, unsigned layer); void (*rect)(void *ctx, int sx, int sy, int ex, int ey, int color, int fill_color, unsigned layer); void (*poly)(void *ctx, int points, int x[points], int y[points], @@ -35,7 +36,7 @@ struct gfx_ops { /* wrappers */ -void gfx_line(int sx, int sy, int ex, int ey); +void gfx_line(int sx, int sy, int ex, int ey, int color, unsigned layer); void gfx_rect(int sx, int sy, int ex, int ey, int color, int fill_color, unsigned layer); void gfx_poly(int points, int x[points], int y[points], diff --git a/sch2fig/sch.c b/sch2fig/sch.c index 032f133..50aa533 100644 --- a/sch2fig/sch.c +++ b/sch2fig/sch.c @@ -479,7 +479,7 @@ bool sch_parse(struct sch_ctx *ctx, const char *line) } if (sscanf(line, "Wire Notes Line%n", &n) == 0 && n) { ctx->state = sch_wire; - ctx->wire = gfx_line; + ctx->wire = dwg_line; return 1; }