Index: trunk/doc/TODO =================================================================== --- trunk/doc/TODO (revision 36607) +++ trunk/doc/TODO (revision 36608) @@ -13,7 +13,6 @@ - librnd API upgrade: + merge sch-rnd r4212 [report: Alain] - librnd 3.2.0+: use lib_exp_* and lib_imp_* - - export_ps, export_svg - remove export_lpr/lpr_hid.[ch] in favor of librnd's - librnd 3.2.0+: export dialog - remove dialogs/dlg_export, make the old ExportGUI and PrintGUI call librnd's ExportDialog and PrintDialog Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 36607) +++ trunk/scconfig/Rev.h (revision 36608) @@ -1 +1 @@ -static const int myrev = 36607; +static const int myrev = 36608; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 36607) +++ trunk/scconfig/Rev.tab (revision 36608) @@ -1,4 +1,4 @@ -36607 configure remove export png, ps, eps code in favor of librnd's +36608 configure remove low level export png, ps, eps and svg code in favor of librnd's 36602 configure remove local pixmap support in favor of librnd's 36562 configure font engine rewrite 36322 configure generalize export_lpr so it can be moved to librnd Index: trunk/scconfig/plugins.h =================================================================== --- trunk/scconfig/plugins.h (revision 36607) +++ trunk/scconfig/plugins.h (revision 36608) @@ -150,6 +150,7 @@ plugin_dep("export_png", "lib_exp_pixmap") plugin_dep("export_ps", "lib_compat_help") plugin_dep("export_ps", "lib_exp_text") +plugin_dep("export_svg", "lib_exp_text") plugin_dep("export_vfs_fuse", "lib_vfs") plugin_dep("export_vfs_mc", "lib_vfs") plugin_dep("export_xy", "export_bom") Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 36607) +++ trunk/src/Makefile.dep (revision 36608) @@ -825,9 +825,6 @@ ../src_plugins/export_stl/stl_models.c \ ../src_plugins/export_stl/model_load_stl.c \ ../src_plugins/export_stl/model_load_amf.c -../src_plugins/export_svg/draw_svg.o: \ - ../src_plugins/export_svg/draw_svg.c \ - ../src_plugins/export_svg/draw_svg.h ../src_plugins/export_svg/svg.o: ../src_plugins/export_svg/svg.c \ ../config.h conf_core.h globalconst.h board.h vtroutestyle.h attrib.h \ global_typedefs.h layer.h obj_common.h flag.h data_parent.h \ @@ -839,8 +836,7 @@ obj_rat.h idpath.h obj_subc_list.h obj_subc.h \ ../src_3rd/libminuid/libminuid.h ht_subc.h obj_pstk_list.h obj_pstk.h \ vtpadstack.h obj_pstk_shape.h polygon.h vtpadstack_t.h draw.h layer.h \ - layer_vis.h funchash_core.h funchash_core_list.h hid_cam.h \ - ../src_plugins/export_svg/draw_svg.h + layer_vis.h funchash_core.h funchash_core_list.h hid_cam.h ../src_plugins/export_vfs_fuse/export_vfs_fuse.o: \ ../src_plugins/export_vfs_fuse/export_vfs_fuse.c \ ../src_plugins/export_vfs_fuse/fuse_includes.h ../config.h conf_core.h \ Index: trunk/src_plugins/export_svg/draw_svg.h =================================================================== --- trunk/src_plugins/export_svg/draw_svg.h (revision 36607) +++ trunk/src_plugins/export_svg/draw_svg.h (nonexistent) @@ -1,65 +0,0 @@ -#include - -typedef struct { - /* public: config */ - rnd_hidlib_t *hidlib; - FILE *outf; - gds_t sbright, sdark, snormal, sclip; /* accumulators for various groups generated parallel */ - int opacity; - int flip; - int true_size; - - /* public: result */ - long drawn_objs; - - /* private: cache */ - int group_open, comp_cnt; - rnd_composite_op_t drawing_mode; - - /* private: pcb-rnd leftover */ - int photo_mode, photo_noise, drawing_mask, drawing_hole; -} rnd_svg_t; - - -void rnd_svg_init(rnd_svg_t *pctx, rnd_hidlib_t *hidlib, FILE *f, int opacity, int flip, int true_size); -void rnd_svg_uninit(rnd_svg_t *pctx); - -/* Write header or footer. Footer also writes cached groups and closes them. */ -void rnd_svg_header(rnd_svg_t *pctx); -void rnd_svg_footer(rnd_svg_t *pctx); - -int rnd_svg_new_file(rnd_svg_t *pctx, FILE *f, const char *fn); -void rnd_svg_layer_group_begin(rnd_svg_t *pctx, long group, const char *name, int is_our_mask); - -void rnd_svg_background(rnd_svg_t *pctx); - - -rnd_hid_gc_t rnd_svg_make_gc(rnd_hid_t *hid); -void rnd_svg_destroy_gc(rnd_hid_gc_t gc); -void rnd_svg_set_line_cap(rnd_hid_gc_t gc, rnd_cap_style_t style); -void rnd_svg_set_line_width(rnd_hid_gc_t gc, rnd_coord_t width); -void rnd_svg_set_draw_xor(rnd_hid_gc_t gc, int xor_); -void rnd_svg_set_crosshair(rnd_hid_t *hid, rnd_coord_t x, rnd_coord_t y, int a); - - - -void rnd_svg_set_drawing_mode(rnd_svg_t *pctx, rnd_hid_t *hid, rnd_composite_op_t op, rnd_bool direct, const rnd_box_t *screen); -void rnd_svg_set_color(rnd_svg_t *pctx, rnd_hid_gc_t gc, const rnd_color_t *color); -void rnd_svg_draw_rect(rnd_svg_t *pctx, rnd_hid_gc_t gc, rnd_coord_t x1, rnd_coord_t y1, rnd_coord_t x2, rnd_coord_t y2); -void rnd_svg_fill_rect(rnd_svg_t *pctx, rnd_hid_gc_t gc, rnd_coord_t x1, rnd_coord_t y1, rnd_coord_t x2, rnd_coord_t y2); -void rnd_svg_draw_line(rnd_svg_t *pctx, rnd_hid_gc_t gc, rnd_coord_t x1, rnd_coord_t y1, rnd_coord_t x2, rnd_coord_t y2); -void rnd_svg_draw_arc(rnd_svg_t *pctx, rnd_hid_gc_t gc, rnd_coord_t cx, rnd_coord_t cy, rnd_coord_t width, rnd_coord_t height, rnd_angle_t start_angle, rnd_angle_t delta_angle); -void rnd_svg_fill_circle(rnd_svg_t *pctx, rnd_hid_gc_t gc, rnd_coord_t cx, rnd_coord_t cy, rnd_coord_t radius); -void rnd_svg_fill_polygon_offs(rnd_svg_t *pctx, rnd_hid_gc_t gc, int n_coords, rnd_coord_t *x, rnd_coord_t *y, rnd_coord_t dx, rnd_coord_t dy); - -/* leftover for pcb-rnd */ -typedef enum { - RND_SVG_PHOTO_MASK, - RND_SVG_PHOTO_SILK, - RND_SVG_PHOTO_COPPER, - RND_SVG_PHOTO_INNER -} rnd_svg_photo_color_t; - -extern rnd_svg_photo_color_t rnd_svg_photo_color; - - Index: trunk/src_plugins/export_svg/draw_svg.c =================================================================== --- trunk/src_plugins/export_svg/draw_svg.c (revision 36607) +++ trunk/src_plugins/export_svg/draw_svg.c (nonexistent) @@ -1,640 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * (this file is based on PCB, interactive printed circuit board design) - * Copyright (C) 2006 Dan McMahill - * Copyright (C) 2016,2022 Tibor 'Igor2' Palinkas - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - */ - -/* Based on the png exporter by Dan McMahill */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include "draw_svg.h" - -typedef struct rnd_hid_gc_s { - rnd_core_gc_t core_gc; - rnd_hid_t *me_pointer; - rnd_cap_style_t cap; - int width; - char *color; - int drill; - unsigned warned_elliptical:1; -} rnd_hid_gc_s; - -static const char *CAPS(rnd_cap_style_t cap) -{ - switch (cap) { - case rnd_cap_round: - return "round"; - case rnd_cap_square: - return "square"; - default: - assert(!"unhandled cap"); - return "round"; - } - return ""; -} - -/* Photo mode colors and hacks */ -static const char *rnd_svg_board_color = "#464646"; -static const char *mask_color = "#00ff00"; -static float mask_opacity_factor = 0.5; - -rnd_svg_photo_color_t rnd_svg_photo_color; - -static struct { - const char *bright; - const char *normal; - const char *dark; - rnd_coord_t offs; -} photo_palette[] = { - /* MASK */ { "#00ff00", "#00ff00", "#00ff00", RND_MM_TO_COORD(0) }, - /* SILK */ { "#ffffff", "#eeeeee", "#aaaaaa", RND_MM_TO_COORD(0) }, - /* COPPER */ { "#bbbbbb", "#707090", "#555555", RND_MM_TO_COORD(0.05) }, - /* INNER */ { "#222222", "#111111", "#000000", RND_MM_TO_COORD(0) } -}; - -#define TRX(x) -#define TRY(y) \ -do { \ - if (pctx->flip) \ - y = pctx->hidlib->size_y - y; \ -} while(0) - -void rnd_svg_init(rnd_svg_t *pctx, rnd_hidlib_t *hidlib, FILE *f, int opacity, int flip, int true_size) -{ - memset(pctx, 0, sizeof(rnd_svg_t)); - pctx->hidlib = hidlib; - pctx->outf = f; - pctx->opacity = opacity; - pctx->flip = flip; - pctx->true_size = true_size; -} - -void rnd_svg_uninit(rnd_svg_t *pctx) -{ - gds_uninit(&pctx->sbright); - gds_uninit(&pctx->sdark); - gds_uninit(&pctx->snormal); - gds_uninit(&pctx->sclip); -} - -static void group_close(rnd_svg_t *pctx) -{ - if (pctx->group_open == 1) { - if (gds_len(&pctx->sdark) > 0) { - fprintf(pctx->outf, "\n"); - fprintf(pctx->outf, "%s", pctx->sdark.array); - gds_truncate(&pctx->sdark, 0); - } - - if (gds_len(&pctx->sbright) > 0) { - fprintf(pctx->outf, "\n"); - fprintf(pctx->outf, "%s", pctx->sbright.array); - gds_truncate(&pctx->sbright, 0); - } - - if (gds_len(&pctx->snormal) > 0) { - fprintf(pctx->outf, "\n"); - fprintf(pctx->outf, "%s", pctx->snormal.array); - gds_truncate(&pctx->snormal, 0); - } - - } - fprintf(pctx->outf, "\n"); -} - -void rnd_svg_header(rnd_svg_t *pctx) -{ - rnd_coord_t w, h, x1, y1, x2, y2; - - fprintf(pctx->outf, "\n"); - w = pctx->hidlib->size_x; - h = pctx->hidlib->size_y; - while((w < RND_MM_TO_COORD(1024)) && (h < RND_MM_TO_COORD(1024))) { - w *= 2; - h *= 2; - } - - x2 = pctx->hidlib->size_x; - y2 = pctx->hidlib->size_y; - if (pctx->true_size) { - rnd_fprintf(pctx->outf, "\n", x2, y2, x2, y2); - } - else { - x1 = RND_MM_TO_COORD(2); - y1 = RND_MM_TO_COORD(2); - x2 += RND_MM_TO_COORD(5); - y2 += RND_MM_TO_COORD(5); - rnd_fprintf(pctx->outf, "\n", w, h, x1, y1, x2, y2); - } -} - -void rnd_svg_footer(rnd_svg_t *pctx) -{ - while(pctx->group_open) { - group_close(pctx); - pctx->group_open--; - } - - /* blend some noise on top to make it a bit more artificial */ - if (pctx->photo_mode && pctx->photo_noise) { - fprintf(pctx->outf, "\n"); - fprintf(pctx->outf, " \n"); - fprintf(pctx->outf, "\n"); - fprintf(pctx->outf, "\n"); - rnd_fprintf(pctx->outf, " \n", - 0, 0, pctx->hidlib->size_x, pctx->hidlib->size_y); - fprintf(pctx->outf, "\n"); - } - - fprintf(pctx->outf, "\n"); -} - -int rnd_svg_new_file(rnd_svg_t *pctx, FILE *f, const char *fn) -{ - int ern = errno; - - if (pctx->outf != NULL) { - rnd_svg_footer(pctx); - fclose(pctx->outf); - } - - if (f == NULL) { - rnd_message(RND_MSG_ERROR, "rnd_svg_new_file(): failed to open %s: %s\n", fn, strerror(ern)); - perror(fn); - return -1; - } - - pctx->outf = f; - return 0; -} - -void rnd_svg_background(rnd_svg_t *pctx) -{ - if (pctx->photo_mode) { - rnd_fprintf(pctx->outf, "\n", - 0, 0, pctx->hidlib->size_x, pctx->hidlib->size_y, rnd_svg_board_color); - } -} - -void rnd_svg_layer_group_begin(rnd_svg_t *pctx, long group, const char *name, int is_our_mask) -{ - int opa; - - while(pctx->group_open) { - group_close(pctx); - pctx->group_open--; - } - fprintf(pctx->outf, "opacity; - if (is_our_mask) - opa *= mask_opacity_factor; - if (opa != 100) - fprintf(pctx->outf, " opacity=\"%.2f\"", ((float)opa) / 100.0); - fprintf(pctx->outf, ">\n"); - pctx->group_open = 1; -} - -static int rnd_svg_me; - -rnd_hid_gc_t rnd_svg_make_gc(rnd_hid_t *hid) -{ - rnd_hid_gc_t rv = (rnd_hid_gc_t) calloc(sizeof(rnd_hid_gc_s), 1); - rv->me_pointer = (rnd_hid_t *)&rnd_svg_me; - rv->cap = rnd_cap_round; - rv->width = 1; - rv->color = NULL; - return rv; -} - -void rnd_svg_destroy_gc(rnd_hid_gc_t gc) -{ - free(gc); -} - -void rnd_svg_set_drawing_mode(rnd_svg_t *pctx, rnd_hid_t *hid, rnd_composite_op_t op, rnd_bool direct, const rnd_box_t *screen) -{ - pctx->drawing_mode = op; - - if (direct) - return; - - switch(op) { - case RND_HID_COMP_RESET: - pctx->comp_cnt++; - gds_init(&pctx->sclip); - rnd_append_printf(&pctx->snormal, "\n"); - rnd_append_printf(&pctx->snormal, "\n"); - rnd_append_printf(&pctx->snormal, "\n", pctx->comp_cnt); - rnd_append_printf(&pctx->sclip, "\n", pctx->comp_cnt, pctx->hidlib->size_x, pctx->hidlib->size_y); - break; - - case RND_HID_COMP_POSITIVE: - case RND_HID_COMP_POSITIVE_XOR: - case RND_HID_COMP_NEGATIVE: - break; - - case RND_HID_COMP_FLUSH: - rnd_append_printf(&pctx->snormal, "\n"); - rnd_append_printf(&pctx->sclip, "\n"); - gds_append_str(&pctx->snormal, pctx->sclip.array); - rnd_append_printf(&pctx->snormal, "\n"); - rnd_append_printf(&pctx->snormal, "\n", pctx->comp_cnt, pctx->comp_cnt); - rnd_append_printf(&pctx->snormal, "\n"); - gds_uninit(&pctx->sclip); - break; - } -} - -static const char *svg_color(rnd_hid_gc_t gc) -{ - return gc->color; -} - -static const char *svg_clip_color(rnd_svg_t *pctx, rnd_hid_gc_t gc) -{ - if ((pctx->drawing_mode == RND_HID_COMP_POSITIVE) || (pctx->drawing_mode == RND_HID_COMP_POSITIVE_XOR)) - return "#FFFFFF"; - if (pctx->drawing_mode == RND_HID_COMP_NEGATIVE) - return "#000000"; - return NULL; -} - -void rnd_svg_set_color(rnd_svg_t *pctx, rnd_hid_gc_t gc, const rnd_color_t *color) -{ - const char *name; - gc->drill = 0; - - if (color == NULL) - name = "#ff0000"; - else - name = color->str; - - if (rnd_color_is_drill(color)) { - name = "#ffffff"; - gc->drill = 1; - } - if (pctx->drawing_mask) - name = mask_color; - if ((gc->color != NULL) && (strcmp(gc->color, name) == 0)) - return; - free(gc->color); - gc->color = rnd_strdup(name); - if (strlen(gc->color) > 7) - gc->color[7] = '\0'; -} - -void rnd_svg_set_line_cap(rnd_hid_gc_t gc, rnd_cap_style_t style) -{ - gc->cap = style; -} - -void rnd_svg_set_line_width(rnd_hid_gc_t gc, rnd_coord_t width) -{ - gc->width = width < RND_MM_TO_COORD(0.01) ? RND_MM_TO_COORD(0.01) : width; -} - -void rnd_svg_set_draw_xor(rnd_hid_gc_t gc, int xor_) -{ - ; -} - -static void indent(rnd_svg_t *pctx, gds_t *s) -{ - static char ind[] = " "; - if (pctx->group_open < sizeof(ind)-1) { - ind[pctx->group_open] = '\0'; - if (s == NULL) - rnd_fprintf(pctx->outf, ind); - else - rnd_append_printf(s, ind); - ind[pctx->group_open] = ' '; - return; - } - - if (s == NULL) - rnd_fprintf(pctx->outf, ind); - else - rnd_append_printf(s, ind); -} - - -#define fix_rect_coords() \ - if (x1 > x2) {\ - rnd_coord_t t = x1; \ - x1 = x2; \ - x2 = t; \ - } \ - if (y1 > y2) { \ - rnd_coord_t t = y1; \ - y1 = y2; \ - y2 = t; \ - } - -static void draw_rect(rnd_svg_t *pctx, rnd_hid_gc_t gc, rnd_coord_t x1, rnd_coord_t y1, rnd_coord_t w, rnd_coord_t h, rnd_coord_t stroke) -{ - const char *clip_color = svg_clip_color(pctx, gc); - - indent(pctx, &pctx->snormal); - rnd_append_printf(&pctx->snormal, "\n", - x1, y1, w, h, stroke, svg_color(gc), CAPS(gc->cap)); - if (clip_color != NULL) { - indent(pctx, &pctx->sclip); - rnd_append_printf(&pctx->sclip, "\n", - x1, y1, w, h, stroke, clip_color, CAPS(gc->cap)); - } -} - -void rnd_svg_draw_rect(rnd_svg_t *pctx, rnd_hid_gc_t gc, rnd_coord_t x1, rnd_coord_t y1, rnd_coord_t x2, rnd_coord_t y2) -{ - pctx->drawn_objs++; - fix_rect_coords(); - draw_rect(pctx, gc, x1, y1, x2-x1, y2-y1, gc->width); -} - -static void draw_fill_rect(rnd_svg_t *pctx, rnd_hid_gc_t gc, rnd_coord_t x1, rnd_coord_t y1, rnd_coord_t w, rnd_coord_t h) -{ - const char *clip_color = svg_clip_color(pctx, gc); - if (pctx->photo_mode) { - rnd_coord_t photo_offs = photo_palette[rnd_svg_photo_color].offs; - if (photo_offs != 0) { - indent(pctx, &pctx->sdark); - rnd_append_printf(&pctx->sdark, "\n", - x1+photo_offs, y1+photo_offs, w, h, photo_palette[rnd_svg_photo_color].dark); - indent(pctx, &pctx->sbright); - rnd_append_printf(&pctx->sbright, "\n", - x1-photo_offs, y1-photo_offs, w, h, photo_palette[rnd_svg_photo_color].bright); - } - indent(pctx, &pctx->snormal); - rnd_append_printf(&pctx->snormal, "\n", - x1, y1, w, h, photo_palette[rnd_svg_photo_color].normal); - } - else { - indent(pctx, &pctx->snormal); - rnd_append_printf(&pctx->snormal, "\n", - x1, y1, w, h, svg_color(gc)); - } - if (clip_color != NULL) - rnd_append_printf(&pctx->sclip, "\n", - x1, y1, w, h, clip_color); -} - -void rnd_svg_fill_rect(rnd_svg_t *pctx, rnd_hid_gc_t gc, rnd_coord_t x1, rnd_coord_t y1, rnd_coord_t x2, rnd_coord_t y2) -{ - pctx->drawn_objs++; - TRX(x1); TRY(y1); TRX(x2); TRY(y2); - fix_rect_coords(); - draw_fill_rect(pctx, gc, x1, y1, x2-x1, y2-y1); -} - -static void pcb_line_draw(rnd_svg_t *pctx, rnd_hid_gc_t gc, rnd_coord_t x1, rnd_coord_t y1, rnd_coord_t x2, rnd_coord_t y2) -{ - const char *clip_color = svg_clip_color(pctx, gc); - if (pctx->photo_mode) { - rnd_coord_t photo_offs = photo_palette[rnd_svg_photo_color].offs; - if (photo_offs != 0) { - indent(pctx, &pctx->sbright); - rnd_append_printf(&pctx->sbright, "\n", - x1-photo_offs, y1-photo_offs, x2-photo_offs, y2-photo_offs, gc->width, photo_palette[rnd_svg_photo_color].bright, CAPS(gc->cap)); - indent(pctx, &pctx->sdark); - rnd_append_printf(&pctx->sdark, "\n", - x1+photo_offs, y1+photo_offs, x2+photo_offs, y2+photo_offs, gc->width, photo_palette[rnd_svg_photo_color].dark, CAPS(gc->cap)); - } - indent(pctx, &pctx->snormal); - rnd_append_printf(&pctx->snormal, "\n", - x1, y1, x2, y2, gc->width, photo_palette[rnd_svg_photo_color].normal, CAPS(gc->cap)); - } - else { - indent(pctx, &pctx->snormal); - rnd_append_printf(&pctx->snormal, "\n", - x1, y1, x2, y2, gc->width, svg_color(gc), CAPS(gc->cap)); - } - if (clip_color != NULL) { - rnd_append_printf(&pctx->sclip, "\n", - x1, y1, x2, y2, gc->width, clip_color, CAPS(gc->cap)); - } -} - -void rnd_svg_draw_line(rnd_svg_t *pctx, rnd_hid_gc_t gc, rnd_coord_t x1, rnd_coord_t y1, rnd_coord_t x2, rnd_coord_t y2) -{ - pctx->drawn_objs++; - TRX(x1); TRY(y1); TRX(x2); TRY(y2); - pcb_line_draw(pctx, gc, x1, y1, x2, y2); -} - -static void pcb_arc_draw(rnd_svg_t *pctx, rnd_hid_gc_t gc, rnd_coord_t x1, rnd_coord_t y1, rnd_coord_t r, rnd_coord_t x2, rnd_coord_t y2, rnd_coord_t stroke, int large, int sweep) -{ - const char *clip_color = svg_clip_color(pctx, gc); - TRX(x1); TRY(y1); TRX(x2); TRY(y2); - if (pctx->photo_mode) { - rnd_coord_t photo_offs = photo_palette[rnd_svg_photo_color].offs; - if (photo_offs != 0) { - indent(pctx, &pctx->sbright); - rnd_append_printf(&pctx->sbright, "\n", - x1-photo_offs, y1-photo_offs, r, r, large, sweep, x2-photo_offs, y2-photo_offs, gc->width, photo_palette[rnd_svg_photo_color].bright, CAPS(gc->cap)); - indent(pctx, &pctx->sdark); - rnd_append_printf(&pctx->sdark, "\n", - x1+photo_offs, y1+photo_offs, r, r, large, sweep, x2+photo_offs, y2+photo_offs, gc->width, photo_palette[rnd_svg_photo_color].dark, CAPS(gc->cap)); - } - indent(pctx, &pctx->snormal); - rnd_append_printf(&pctx->snormal, "\n", - x1, y1, r, r, large, sweep, x2, y2, gc->width, photo_palette[rnd_svg_photo_color].normal, CAPS(gc->cap)); - } - else { - indent(pctx, &pctx->snormal); - rnd_append_printf(&pctx->snormal, "\n", - x1, y1, r, r, large, sweep, x2, y2, gc->width, svg_color(gc), CAPS(gc->cap)); - } - if (clip_color != NULL) - rnd_append_printf(&pctx->sclip, "\n", - x1, y1, r, r, large, sweep, x2, y2, gc->width, clip_color, CAPS(gc->cap)); -} - -void rnd_svg_draw_arc(rnd_svg_t *pctx, rnd_hid_gc_t gc, rnd_coord_t cx, rnd_coord_t cy, rnd_coord_t width, rnd_coord_t height, rnd_angle_t start_angle, rnd_angle_t delta_angle) -{ - rnd_coord_t x1, y1, x2, y2, diff = 0, diff2, maxdiff; - rnd_angle_t sa, ea; - - pctx->drawn_objs++; - - /* degenerate case: r=0 means a single dot */ - if ((width == 0) && (height == 0)) { - pcb_line_draw(pctx, gc, cx, cy, cx, cy); - return; - } - - /* detect elliptical arcs: if diff between radii is above 0.1% */ - diff2 = width - height; - if (diff2 < 0) - diff2 = -diff2; - maxdiff = width; - if (height > maxdiff) - maxdiff = height; - if (diff2 > maxdiff / 1000) { - if (!gc->warned_elliptical) { - rnd_message(RND_MSG_ERROR, "Can't draw elliptical arc on svg; object omitted; expect BROKEN TRACE\n"); - gc->warned_elliptical = 1; - } - return; - } - - TRX(cx); TRY(cy); - - /* calculate start and end angles considering flip */ - start_angle = 180 - start_angle; - delta_angle = -delta_angle; - if (pctx->flip) { - start_angle = -start_angle; - delta_angle = -delta_angle; - } - - /* workaround for near-360 deg rendering bugs */ - if ((delta_angle >= +360.0) || (delta_angle <= -360.0)) { - rnd_svg_draw_arc(pctx, gc, cx, cy, width, height, 0, 180); - rnd_svg_draw_arc(pctx, gc, cx, cy, width, height, 180, 180); - return; - } - - if (fabs(delta_angle) <= 0.001) { delta_angle = 0.001; diff=1; } - - sa = start_angle; - ea = start_angle + delta_angle; - - /* calculate the endpoints */ - x2 = rnd_round((double)cx + ((double)width * cos(sa * M_PI / 180))); - y2 = rnd_round((double)cy + ((double)width * sin(sa * M_PI / 180))); - x1 = rnd_round((double)cx + ((double)width * cos(ea * M_PI / 180))+diff); - y1 = rnd_round((double)cy + ((double)width * sin(ea * M_PI / 180))+diff); - - pcb_arc_draw(pctx, gc, x1, y1, width, x2, y2, gc->width, (fabs(delta_angle) > 180), (delta_angle < 0.0)); -} - -static void draw_fill_circle(rnd_svg_t *pctx, rnd_hid_gc_t gc, rnd_coord_t cx, rnd_coord_t cy, rnd_coord_t r, rnd_coord_t stroke) -{ - const char *clip_color = svg_clip_color(pctx, gc); - - pctx->drawn_objs++; - - if (pctx->photo_mode) { - if (!pctx->drawing_hole) { - rnd_coord_t photo_offs = photo_palette[rnd_svg_photo_color].offs; - if ((!gc->drill) && (photo_offs != 0)) { - indent(pctx, &pctx->sbright); - rnd_append_printf(&pctx->sbright, "\n", - cx-photo_offs, cy-photo_offs, r, stroke, photo_palette[rnd_svg_photo_color].bright); - - indent(pctx, &pctx->sdark); - rnd_append_printf(&pctx->sdark, "\n", - cx+photo_offs, cy+photo_offs, r, stroke, photo_palette[rnd_svg_photo_color].dark); - } - indent(pctx, &pctx->snormal); - rnd_append_printf(&pctx->snormal, "\n", - cx, cy, r, stroke, photo_palette[rnd_svg_photo_color].normal); - } - else { - indent(pctx, &pctx->snormal); - rnd_append_printf(&pctx->snormal, "\n", - cx, cy, r, stroke, "#000000"); - } - } - else{ - indent(pctx, &pctx->snormal); - rnd_append_printf(&pctx->snormal, "\n", - cx, cy, r, stroke, svg_color(gc)); - } - if (clip_color != NULL) - rnd_append_printf(&pctx->sclip, "\n", - cx, cy, r, stroke, clip_color); -} - -void rnd_svg_fill_circle(rnd_svg_t *pctx, rnd_hid_gc_t gc, rnd_coord_t cx, rnd_coord_t cy, rnd_coord_t radius) -{ - pctx->drawn_objs++; - TRX(cx); TRY(cy); - draw_fill_circle(pctx, gc, cx, cy, radius, 0); -} - -static void draw_poly(rnd_svg_t *pctx, gds_t *s, rnd_hid_gc_t gc, int n_coords, rnd_coord_t * x, rnd_coord_t * y, rnd_coord_t dx, rnd_coord_t dy, const char *clr) -{ - int i; - float poly_bloat = 0.01; - - indent(pctx, s); - gds_append_str(s, "\n", poly_bloat, clr, clr); -} - -void rnd_svg_fill_polygon_offs(rnd_svg_t *pctx, rnd_hid_gc_t gc, int n_coords, rnd_coord_t *x, rnd_coord_t *y, rnd_coord_t dx, rnd_coord_t dy) -{ - const char *clip_color = svg_clip_color(pctx, gc); - pctx->drawn_objs++; - if (pctx->photo_mode) { - rnd_coord_t photo_offs_x = photo_palette[rnd_svg_photo_color].offs, photo_offs_y = photo_palette[rnd_svg_photo_color].offs; - if (photo_offs_x != 0) { - if (pctx->flip) - photo_offs_y = -photo_offs_y; - draw_poly(pctx, &pctx->sbright, gc, n_coords, x, y, dx-photo_offs_x, dy-photo_offs_y, photo_palette[rnd_svg_photo_color].bright); - draw_poly(pctx, &pctx->sdark, gc, n_coords, x, y, dx+photo_offs_x, dy+photo_offs_y, photo_palette[rnd_svg_photo_color].dark); - } - draw_poly(pctx, &pctx->snormal, gc, n_coords, x, y, dx, dy, photo_palette[rnd_svg_photo_color].normal); - } - else - draw_poly(pctx, &pctx->snormal, gc, n_coords, x, y, dx, dy, svg_color(gc)); - - if (clip_color != NULL) - draw_poly(pctx, &pctx->sclip, gc, n_coords, x, y, dx, dy, clip_color); -} - -void rnd_svg_set_crosshair(rnd_hid_t *hid, rnd_coord_t x, rnd_coord_t y, int a) -{ -} Index: trunk/src_plugins/export_svg/Plug.tmpasm =================================================================== --- trunk/src_plugins/export_svg/Plug.tmpasm (revision 36607) +++ trunk/src_plugins/export_svg/Plug.tmpasm (revision 36608) @@ -1,7 +1,6 @@ put /local/pcb/mod {export_svg} put /local/pcb/mod/OBJS [@ $(PLUGDIR)/export_svg/svg.o - $(PLUGDIR)/export_svg/draw_svg.o @] switch /local/pcb/export_svg/controls Index: trunk/src_plugins/export_svg/export_svg.pup =================================================================== --- trunk/src_plugins/export_svg/export_svg.pup (revision 36607) +++ trunk/src_plugins/export_svg/export_svg.pup (revision 36608) @@ -5,5 +5,6 @@ $fmt-feature-w svg (Scalable Vector Graphics) $state works $package export +dep lib_exp_text default buildin autoload 1 Index: trunk/src_plugins/export_svg/svg.c =================================================================== --- trunk/src_plugins/export_svg/svg.c (revision 36607) +++ trunk/src_plugins/export_svg/svg.c (revision 36608) @@ -61,7 +61,7 @@ #include #include "hid_cam.h" -#include "draw_svg.h" +#include static rnd_hid_t svg_hid;