Index: trunk/src_plugins/export_openems/export_openems.c =================================================================== --- trunk/src_plugins/export_openems/export_openems.c (revision 31993) +++ trunk/src_plugins/export_openems/export_openems.c (revision 31994) @@ -85,6 +85,7 @@ rnd_coord_t ox, oy; unsigned warn_subc_term:1; unsigned warn_port_pstk:1; + unsigned fmt_matlab:1; /* when 1, use matlab syntax; 0 means xml syntax */ } wctx_t; static FILE *f = NULL; @@ -91,6 +92,7 @@ static wctx_t *ems_ctx; static int openems_ovr; + #define THMAX RND_MM_TO_COORD(100) rnd_export_opt_t openems_attribute_list[] = { @@ -601,6 +603,7 @@ wctx.fsim = fsim; wctx.pcb = PCB; wctx.options = options; + wctx.fmt_matlab = fmt_matlab; ems_ctx = &wctx; ctx.view.X1 = 0; @@ -778,9 +781,14 @@ wctx_t *ctx = ems_ctx; long oid = ctx->oid++; - rnd_fprintf(ctx->f, "points%ld(1, 1) = %mm; points%ld(2, 1) = %mm;\n", oid, cx, oid, -cy); - rnd_fprintf(ctx->f, "points%ld(1, 2) = %mm; points%ld(2, 2) = %mm;\n", oid, cx, oid, -cy); - rnd_fprintf(ctx->f, "CSX = AddPcbrndTrace(CSX, PCBRND, %d, points%ld, %mm, 0);\n", ctx->clayer, oid, radius*2); + if (ctx->fmt_matlab) { + rnd_fprintf(ctx->f, "points%ld(1, 1) = %mm; points%ld(2, 1) = %mm;\n", oid, cx, oid, -cy); + rnd_fprintf(ctx->f, "points%ld(1, 2) = %mm; points%ld(2, 2) = %mm;\n", oid, cx, oid, -cy); + rnd_fprintf(ctx->f, "CSX = AddPcbrndTrace(CSX, PCBRND, %d, points%ld, %mm, 0);\n", ctx->clayer, oid, radius*2); + } + else { + rnd_fprintf(ctx->f, "TODO: fill circle %mm;%mm\n", cx, cy); + } } static void openems_fill_polygon_offs(rnd_hid_gc_t gc, int n_coords, rnd_coord_t *x, rnd_coord_t *y, rnd_coord_t dx, rnd_coord_t dy) @@ -787,12 +795,18 @@ { wctx_t *ctx = ems_ctx; int n; - long oid = ctx->oid++; - for(n = 0; n < n_coords; n++) - rnd_fprintf(ctx->f, "poly%ld_xy(1, %ld) = %mm; poly%ld_xy(2, %ld) = %mm;\n", oid, n+1, x[n]+dx, oid, n+1, -(y[n]+dy)); + if (ctx->fmt_matlab) { + long oid = ctx->oid++; - fprintf(ctx->f, "CSX = AddPcbrndPoly(CSX, PCBRND, %d, poly%ld_xy, 1);\n", ctx->clayer, oid); + for(n = 0; n < n_coords; n++) + rnd_fprintf(ctx->f, "poly%ld_xy(1, %ld) = %mm; poly%ld_xy(2, %ld) = %mm;\n", oid, n+1, x[n]+dx, oid, n+1, -(y[n]+dy)); + + fprintf(ctx->f, "CSX = AddPcbrndPoly(CSX, PCBRND, %d, poly%ld_xy, 1);\n", ctx->clayer, oid); + } + else { + rnd_fprintf(ctx->f, "TODO: poly offs %mm;%mm\n", dx, dy); + } } static void openems_fill_polygon(rnd_hid_gc_t gc, int n_coords, rnd_coord_t *x, rnd_coord_t *y) @@ -800,26 +814,40 @@ openems_fill_polygon_offs(gc, n_coords, x, y, 0, 0); } +static void openems_draw_line_body(rnd_hid_gc_t gc, rnd_coord_t x1, rnd_coord_t y1, rnd_coord_t x2, rnd_coord_t y2) +{ + rnd_coord_t x[4], y[4]; + pcb_line_t tmp = {0}; + tmp.Point1.X = x1; + tmp.Point1.Y = y1; + tmp.Point2.X = x2; + tmp.Point2.Y = y2; + tmp.Thickness = gc->width; + pcb_sqline_to_rect(&tmp, x, y); + openems_fill_polygon_offs(gc, 4, x, y, 0, 0); + +} + static void openems_draw_line(rnd_hid_gc_t gc, rnd_coord_t x1, rnd_coord_t y1, rnd_coord_t x2, rnd_coord_t y2) { wctx_t *ctx = ems_ctx; if (gc->cap == rnd_cap_square) { - rnd_coord_t x[4], y[4]; - pcb_line_t tmp; - tmp.Point1.X = x1; - tmp.Point1.Y = y1; - tmp.Point2.X = x2; - tmp.Point2.Y = y2; - pcb_sqline_to_rect(&tmp, x, y); - openems_fill_polygon_offs(gc, 4, x, y, 0, 0); + openems_draw_line_body(gc, x1, y1, x2, y2); + return; } - else { + + if (ctx->fmt_matlab) { long oid = ctx->oid++; rnd_fprintf(ctx->f, "points%ld(1, 1) = %mm; points%ld(2, 1) = %mm;\n", oid, x1, oid, -y1); rnd_fprintf(ctx->f, "points%ld(1, 2) = %mm; points%ld(2, 2) = %mm;\n", oid, x2, oid, -y2); rnd_fprintf(ctx->f, "CSX = AddPcbrndTrace(CSX, PCBRND, %d, points%ld, %mm, 0);\n", ctx->clayer, oid, gc->width); } + else { + openems_fill_circle(gc, x1, y1, gc->width/2); + openems_fill_circle(gc, x2, y2, gc->width/2); + openems_draw_line_body(gc, x1, y1, x2, y2); + } } Index: trunk/src_plugins/export_openems/openems_xml.c =================================================================== --- trunk/src_plugins/export_openems/openems_xml.c (revision 31993) +++ trunk/src_plugins/export_openems/openems_xml.c (revision 31994) @@ -48,7 +48,9 @@ static void openems_wr_xml_layers(wctx_t *ctx) { + rnd_hid_expose_ctx_t ectx = {0}; rnd_cardinal_t gid; + fprintf(ctx->f, " \n"); for(gid = 0; gid < ctx->pcb->LayerGroups.len; gid++) { pcb_layergrp_t *g = &ctx->pcb->LayerGroups.grp[gid]; @@ -57,6 +59,14 @@ else if (g->ltype & PCB_LYT_SUBSTRATE) openems_wr_xml_grp_substrate(ctx, g); } + + ectx.view.X1 = 0; + ectx.view.Y1 = 0; + ectx.view.X2 = ctx->pcb->hidlib.size_x; + ectx.view.Y2 = ctx->pcb->hidlib.size_y; + + rnd_expose_main(&openems_hid, &ectx, NULL); + fprintf(ctx->f, " \n"); }