Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 18273) +++ trunk/scconfig/Rev.h (revision 18274) @@ -1 +1 @@ -static const int myrev = 18166; +static const int myrev = 18273; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 18273) +++ trunk/scconfig/Rev.tab (revision 18274) @@ -1,3 +1,4 @@ +18273 configure introducing the cam system: rename hid_helper to hid_cam 18166 configure swithc over to scconfig's cquote 17960 configure script plugin 17691 configure action code cleanup Index: trunk/src/hid_helper.h =================================================================== --- trunk/src/hid_helper.h (revision 18273) +++ trunk/src/hid_helper.h (nonexistent) @@ -1,61 +0,0 @@ -#ifndef PCB_HID_HELPER_H -#define PCB_HID_HELPER_H - -/* maximum size of a derived suffix */ -#define PCB_DERIVE_FN_SUFF_LEN 20 - -typedef enum pcb_file_name_style_e { - /* Files for copper layers are named top, groupN, bottom. */ - PCB_FNS_fixed, - /* Groups with multiple layers are named as above, else the single - layer name is used. */ - PCB_FNS_single, - /* The name of the first layer in each group is used. */ - PCB_FNS_first -} pcb_file_name_style_t; - -/* Returns a filename base that can be used to output the layer. */ -char *pcb_layer_to_file_name(char *dest, pcb_layer_id_t lid, unsigned int flags, pcb_file_name_style_t style); - -/* Returns a filename base that can be used to output the layer; if flags is 0, - look it up. Copies result in dest (which should be at least PCB_DERIVE_FN_SUFF_LEN bytes wide). - Returns dest. */ -void pcb_derive_default_filename(const char *pcbfile, pcb_hid_attribute_t * filename_attrib, const char *suffix, char **memory); - -/*** CAM API ***/ -typedef struct pcb_cam_s { - /* public */ - const char *fn; - pcb_bool active; - int grp_vis[PCB_MAX_LAYERGRP]; /* whether a real layer group should be rendered */ - int vgrp_vis[PCB_VLY_end]; /* whether a virtual layer group should be rendered */ - - /* private/internal/cache */ - char *inst; - pcb_board_t *pcb; - int orig_vis[PCB_MAX_LAYER]; /* backup of the original layer visibility */ - int exported_grps; -} pcb_cam_t; - -int pcb_cam_begin(pcb_board_t *pcb, pcb_cam_t *dst, const char *src, const pcb_hid_attribute_t *attr_tbl, int numa, pcb_hid_attr_val_t *options); - -/* Finish cam export, free all memory, mark cam export inactive and report - the number of layer groups exported */ -int pcb_cam_end(pcb_cam_t *dst); - - -/* Shall be the first rule in a cam capable exporter's set_layer_group() - callback: decides not to draw a layer group in cam mode if the - group is not scheduled for export */ -#define pcb_cam_set_layer_group(cam, group, flags) \ -do { \ - if (pcb_cam_set_layer_group_(cam, group, flags)) \ - return 0; \ -} while(0) - -/* the logics behind pcb_cam_set_layer_group(); returns non-zero if the macro - should return (and skip the current group) */ -int pcb_cam_set_layer_group_(pcb_cam_t *cam, pcb_layergrp_id_t group, unsigned int flags); - - -#endif Index: trunk/src/hid_helper.c =================================================================== --- trunk/src/hid_helper.c (revision 18273) +++ trunk/src/hid_helper.c (nonexistent) @@ -1,343 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * (this file is based on PCB, interactive printed circuit board design) - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 2004 harry eaton - * - * 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: email to pcb-rnd (at) igor2.repo.hu - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - */ - -#include "config.h" -#include "board.h" -#include "data.h" -#include "hid_helper.h" -#include "hid_attrib.h" -#include "hid_helper.h" -#include "compat_misc.h" -#include "layer_vis.h" -#include "plug_io.h" - -char *pcb_layer_to_file_name(char *dest, pcb_layer_id_t lid, unsigned int flags, pcb_file_name_style_t style) -{ - const pcb_virt_layer_t *v; - pcb_layergrp_id_t group; - int nlayers; - const char *single_name, *res = NULL; - - if (flags == 0) - flags = pcb_layer_flags(PCB, lid); - - if (flags & PCB_LYT_OUTLINE) { - strcpy(dest, "outline"); - return dest; - } - - v = pcb_vlayer_get_first(flags); - if (v != NULL) { - strcpy(dest, v->name); - return dest; - } - - - group = pcb_layer_get_group(PCB, lid); - nlayers = PCB->LayerGroups.grp[group].len; - single_name = pcb_layer_name(PCB->Data, lid); - - if (flags & PCB_LYT_TOP) { - if (style == PCB_FNS_first || (style == PCB_FNS_single && nlayers == 2)) - res = single_name; - if (flags & PCB_LYT_SILK) - res = "topsilk"; - else if (flags & PCB_LYT_MASK) - res = "topmask"; - else if (flags & PCB_LYT_PASTE) - res = "toppaste"; - else - res = "top"; - } - else if (flags & PCB_LYT_BOTTOM) { - if (style == PCB_FNS_first || (style == PCB_FNS_single && nlayers == 2)) - res = single_name; - if (flags & PCB_LYT_SILK) - res = "bottomsilk"; - else if (flags & PCB_LYT_MASK) - res = "bottommask"; - else if (flags & PCB_LYT_PASTE) - res = "bottompaste"; - else - res = "bottom"; - } - else { - static char buf[PCB_DERIVE_FN_SUFF_LEN]; - if (style == PCB_FNS_first || (style == PCB_FNS_single && nlayers == 1)) - res = single_name; - sprintf(buf, "group%ld", group); - res = buf; - } - - assert(res != NULL); - strcpy(dest, res); - return dest; -} - - -void pcb_derive_default_filename(const char *pcbfile, pcb_hid_attribute_t * filename_attrib, const char *suffix, char **memory) -{ - char *buf; - char *pf; - - if (pcbfile == NULL) - pf = pcb_strdup("unknown.pcb"); - else - pf = pcb_strdup(pcbfile); - - if (!pf || (memory && filename_attrib->default_val.str_value != *memory)) - return; - - buf = (char *) malloc(strlen(pf) + strlen(suffix) + 1); - if (memory) - *memory = buf; - if (buf) { - size_t bl; - pcb_plug_io_t *i; - strcpy(buf, pf); - bl = strlen(buf); - for(i = pcb_plug_io_chain; i != NULL; i = i->next) { - if (i->default_extension != NULL) { - int slen = strlen(i->default_extension); - if (bl > slen && strcmp(buf + bl - slen, i->default_extension) == 0) { - buf[bl - slen] = 0; - break; - } - } - } - strcat(buf, suffix); - if (filename_attrib->default_val.str_value) - free((void *) filename_attrib->default_val.str_value); - filename_attrib->default_val.str_value = buf; - } - - free(pf); -} - -/* remove leading and trailing whitespace */ -static char *strip(char *s) -{ - char *end; - while(isspace(*s)) s++; - end = s + strlen(s) - 1; - while((end >= s) && (isspace(*end))) { - *end = '\0'; - end--; - } - return s; -} - -static void layervis_save_and_reset(pcb_cam_t *cam) -{ - pcb_layer_id_t n; - for(n = 0; n < cam->pcb->Data->LayerN; n++) { - cam->orig_vis[n] = cam->pcb->Data->Layer[n].meta.real.vis; - cam->pcb->Data->Layer[n].meta.real.vis = 0; - } -} - -static void layervis_restore(pcb_cam_t *cam) -{ - pcb_layer_id_t n; - for(n = 0; n < cam->pcb->Data->LayerN; n++) - cam->pcb->Data->Layer[n].meta.real.vis = cam->orig_vis[n]; -} - -static int parse_layer_type(char *type, pcb_layer_type_t *lyt, int *offs, int *has_offs) -{ - char *soffs, *end, *nxt, *cur; - pcb_layer_type_t l; - - *lyt = 0; - *offs = *has_offs = 0; - - soffs = strchr(type, ':'); - if (soffs != NULL) { - *soffs = '\0'; - *offs = strtol(soffs+1, &end, 10); - if (*end != '\0') { - pcb_message(PCB_MSG_ERROR, "CAM rule: invalid offset '%s'\n", soffs); - return 1; - } - *has_offs = 1; - } - - for(cur = type; cur != NULL; cur = nxt) { - nxt = strchr(cur, '-'); - if (nxt != NULL) { - *nxt = '\0'; - nxt++; - } - l = pcb_layer_type_str2bit(cur); - if (l == 0) { - pcb_message(PCB_MSG_ERROR, "CAM rule: invalid layer type '%s'\n", cur); - return 1; - } - (*lyt) |= l; - } - return 0; -} - -int pcb_cam_begin(pcb_board_t *pcb, pcb_cam_t *dst, const char *src, const pcb_hid_attribute_t *attr_tbl, int numa, pcb_hid_attr_val_t *options) -{ - char *curr, *next; - - if (src == NULL) - return 0; - - memset(dst, 0, sizeof(pcb_cam_t)); - dst->pcb = pcb; - dst->inst = pcb_strdup(src); - layervis_save_and_reset(dst); - - - /* Syntax: fn=layergrp,layergrp,layergrp;--opt=val;--opt=val */ - /* parse: get file name name */ - next = strchr(dst->inst, '='); - if (next == NULL) { - pcb_message(PCB_MSG_ERROR, "CAM rule missing '='\n"); - goto err; - } - *next = '\0'; - next++; - dst->fn = strip(dst->inst); -pcb_trace("CAM FN='%s'\n", dst->fn); - - while(isspace(*next)) - next++; - - /* parse layers */ - for(curr = next; curr != NULL; curr = next) { - - next = strchr(curr, ','); - if (next != NULL) { - *next = '\0'; - next++; - } - curr = strip(curr); - if (*curr == '@') { - /* named layer */ - pcb_layergrp_id_t gid; - curr++; - gid = pcb_layergrp_by_name(pcb, curr); - if (gid < 0) { - pcb_message(PCB_MSG_ERROR, "CAM rule: no such layer group '%s'\n", curr); - goto err; - } - if (pcb->LayerGroups.grp[gid].len <= 0) - continue; - pcb_layervis_change_group_vis(pcb->LayerGroups.grp[gid].lid[0], 1, 0); - dst->grp_vis[gid] = 1; - } - else { - /* by layer type */ - int offs, has_offs; - pcb_layer_type_t lyt; - pcb_virt_layer_t *vl; - - if (parse_layer_type(curr, &lyt, &offs, &has_offs) != 0) - goto err; - - vl = pcb_vlayer_get_first(lyt); - if (vl == NULL) { - pcb_layergrp_id_t gids[PCB_MAX_LAYERGRP]; - int n, len = pcb_layergrp_list(dst->pcb, lyt, gids, sizeof(gids)/sizeof(gids[0])); - if (has_offs) { - if (offs < 0) - offs = len - offs; - else - offs--; - if ((offs >= 0) && (offs < len)) { - pcb_layergrp_id_t gid = gids[offs]; - pcb_layervis_change_group_vis(pcb->LayerGroups.grp[gid].lid[0], 1, 0); - dst->grp_vis[gid] = 1; - } - } - else { - for(n = 0; n < len; n++) { - pcb_layergrp_id_t gid = gids[n]; - pcb_layervis_change_group_vis(pcb->LayerGroups.grp[gid].lid[0], 1, 0); - dst->grp_vis[gid] = 1; - } - } - - } - else { - int vid = vl->new_id - PCB_LYT_VIRTUAL - 1; - dst->vgrp_vis[vid] = 1; - } - } - } - - dst->active = 1; - return 0; - err:; - layervis_restore(dst); - free(dst->inst); - dst->inst = NULL; - return -1; -} - -int pcb_cam_end(pcb_cam_t *dst) -{ - free(dst->inst); - dst->inst = NULL; - if (!dst->active) - return; - layervis_restore(dst); - dst->active = 0; - return dst->exported_grps; -} - - -int pcb_cam_set_layer_group_(pcb_cam_t *cam, pcb_layergrp_id_t group, unsigned int flags) -{ - pcb_virt_layer_t *vl; - - if (!cam->active) - return 0; - - vl = pcb_vlayer_get_first(flags); - if (vl == NULL) { - if (group == -1) - return 1; - - if (!cam->grp_vis[group]) - return 1; - } - else { - int vid = vl->new_id - PCB_LYT_VIRTUAL - 1; - if (!cam->vgrp_vis[vid]) - return 1; - } - - cam->exported_grps++; - return 0; -} - Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 18273) +++ trunk/src/Makefile.dep (revision 18274) @@ -451,7 +451,7 @@ ../src_3rd/puplug/os_dep.h ../src_3rd/puplug/config.h \ ../src_3rd/puplug/libs.h ../src_3rd/puplug/error.h compat_misc.h \ compat_fs.h misc_util.h rtree.h hid.h hid_attrib.h hid_nogui.h \ - hid_draw_helpers.h hid_init.h hid_helper.h + hid_draw_helpers.h hid_init.h hid_cam.h ../src_plugins/export_bom/bom.o: ../src_plugins/export_bom/bom.c \ ../config.h conf_core.h conf.h global_typedefs.h pcb_bool.h unit.h \ pcb-printf.h ../src_3rd/genvector/gds_char.h \ @@ -477,7 +477,7 @@ ../src_3rd/puplug/libs.h ../src_3rd/puplug/os_dep.h \ ../src_3rd/puplug/config.h ../src_3rd/puplug/libs.h \ ../src_3rd/puplug/error.h compat_misc.h safe_fs.h hid.h hid_nogui.h \ - hid_attrib.h hid_helper.h hid_init.h macro.h + hid_attrib.h hid_cam.h hid_init.h macro.h ../src_plugins/export_dsn/dsn.o: ../src_plugins/export_dsn/dsn.c \ ../config.h ../src_3rd/genvector/gds_char.h \ ../src_3rd/genvector/genvector_impl.h \ @@ -502,7 +502,7 @@ draw.h undo.h ../src_3rd/libuundo/uundo.h undo_old.h pcb-printf.h \ polygon.h compat_misc.h layer.h safe_fs.h conf.h pcb-printf.h \ ../src_3rd/liblihata/lihata.h list_conf.h hid.h hid_draw_helpers.h \ - hid_nogui.h actions.h hid_init.h hid_attrib.h hid_helper.h plugins.h \ + hid_nogui.h actions.h hid_init.h hid_attrib.h hid_cam.h plugins.h \ ../src_3rd/puplug/puplug.h ../src_3rd/puplug/libs.h \ ../src_3rd/puplug/os_dep.h ../src_3rd/puplug/config.h \ ../src_3rd/puplug/libs.h ../src_3rd/puplug/error.h obj_line.h \ @@ -533,7 +533,7 @@ ../src_3rd/puplug/libs.h ../src_3rd/puplug/error.h pcb-printf.h \ compat_misc.h ../src_plugins/export_dxf/lht_template.h safe_fs.h hid.h \ hid_nogui.h hid_draw_helpers.h hid_init.h hid_attrib.h hid_color.h \ - hid_helper.h hid_flags.h ../src_plugins/export_dxf/dxf_draw.c dolists.h + hid_cam.h hid_flags.h ../src_plugins/export_dxf/dxf_draw.c dolists.h ../src_plugins/export_dxf/dxf_templ_lht.o: \ ../src_plugins/export_dxf/dxf_templ_lht.c ../src_plugins/export_dxf/lht_template.o: \ @@ -568,7 +568,7 @@ ../src_3rd/puplug/os_dep.h ../src_3rd/puplug/config.h \ ../src_3rd/puplug/libs.h ../src_3rd/puplug/error.h pcb-printf.h \ compat_misc.h plug_io.h safe_fs.h hid.h hid_nogui.h hid_draw_helpers.h \ - hid_init.h hid_attrib.h hid_color.h hid_helper.h hid_flags.h \ + hid_init.h hid_attrib.h hid_color.h hid_cam.h hid_flags.h \ ../src_plugins/lib_compat_help/pstk_compat.h obj_pstk.h dolists.h ../src_plugins/export_gcode/curve.o: ../src_plugins/export_gcode/curve.c \ ../config.h ../src_plugins/export_gcode/potracelib.h \ @@ -605,7 +605,7 @@ rtree.h ../src_3rd/genrtree/genrtree_api.h rtree2_compat.h ht_subc.h \ ../src_3rd/genht/ht.h ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h \ vtpadstack.h obj_pstk_shape.h polygon.h vtpadstack_t.h rats.h netlist.h \ - route_style.h hid_helper.h layer.h compat_misc.h safe_fs.h hid.h \ + route_style.h hid_cam.h layer.h compat_misc.h safe_fs.h hid.h \ hid_nogui.h hid_draw_helpers.h ../src_plugins/export_gcode/gcode.h \ ../src_plugins/export_gcode/bitmap.h \ ../src_plugins/export_gcode/potracelib.h \ @@ -644,7 +644,7 @@ vtpadstack_t.h error.h draw.h layer.h pcb-printf.h plugins.h \ ../src_3rd/puplug/puplug.h ../src_3rd/puplug/libs.h \ ../src_3rd/puplug/os_dep.h ../src_3rd/puplug/config.h \ - ../src_3rd/puplug/libs.h ../src_3rd/puplug/error.h hid_helper.h \ + ../src_3rd/puplug/libs.h ../src_3rd/puplug/error.h hid_cam.h \ compat_misc.h safe_fs.h conf.h pcb-printf.h \ ../src_3rd/liblihata/lihata.h list_conf.h macro.h hid.h hid_nogui.h \ hid_draw_helpers.h hid_init.h hid_attrib.h hid_flags.h hid_inlines.h \ @@ -673,7 +673,7 @@ ../src_3rd/liblihata/lihata.h list_conf.h conf_core.h compat_misc.h \ netlist.h route_style.h math_helper.h layer.h obj_arc.h obj_line.h \ obj_poly.h obj_subc.h obj_pstk.h obj_pstk_inlines.h data.h thermal.h \ - hid.h hid_nogui.h hid_helper.h hid_attrib.h hid_init.h plugins.h \ + hid.h hid_nogui.h hid_cam.h hid_attrib.h hid_init.h plugins.h \ ../src_3rd/puplug/puplug.h ../src_3rd/puplug/libs.h \ ../src_3rd/puplug/os_dep.h ../src_3rd/puplug/config.h \ ../src_3rd/puplug/libs.h ../src_3rd/puplug/error.h @@ -726,9 +726,9 @@ vtpadstack_t.h layer.h rats.h netlist.h route_style.h plugins.h \ ../src_3rd/puplug/puplug.h ../src_3rd/puplug/libs.h \ ../src_3rd/puplug/os_dep.h ../src_3rd/puplug/config.h \ - ../src_3rd/puplug/libs.h ../src_3rd/puplug/error.h hid_helper.h \ - safe_fs.h conf.h pcb-printf.h ../src_3rd/liblihata/lihata.h list_conf.h \ - hid.h hid_nogui.h hid_draw_helpers.h hid_init.h hid_attrib.h hid_flags.h \ + ../src_3rd/puplug/libs.h ../src_3rd/puplug/error.h hid_cam.h safe_fs.h \ + conf.h pcb-printf.h ../src_3rd/liblihata/lihata.h list_conf.h hid.h \ + hid_nogui.h hid_draw_helpers.h hid_init.h hid_attrib.h hid_flags.h \ hid_color.h dolists.h ../src_plugins/export_openems/export_openems.o: \ ../src_plugins/export_openems/export_openems.c ../config.h conf_core.h \ @@ -755,10 +755,10 @@ ../src_3rd/puplug/libs.h ../src_3rd/puplug/os_dep.h \ ../src_3rd/puplug/config.h ../src_3rd/puplug/libs.h \ ../src_3rd/puplug/error.h safe_fs.h obj_subc_parent.h obj_pstk_inlines.h \ - thermal.h hid.h actions.h hid_nogui.h hid_helper.h hid_flags.h \ - hid_attrib.h hid_init.h hid_draw_helpers.h \ - ../src_plugins/lib_polyhelp/topoly.h obj_common.h \ - ../src_plugins/export_openems/mesh.h layer.h vtc0.h vtr0.h dolists.h + thermal.h hid.h actions.h hid_nogui.h hid_cam.h hid_flags.h hid_attrib.h \ + hid_init.h hid_draw_helpers.h ../src_plugins/lib_polyhelp/topoly.h \ + obj_common.h ../src_plugins/export_openems/mesh.h layer.h vtc0.h vtr0.h \ + dolists.h ../src_plugins/export_openems/mesh.o: \ ../src_plugins/export_openems/mesh.c ../config.h \ ../src_plugins/export_openems/mesh.h layer.h globalconst.h \ @@ -809,7 +809,7 @@ ../src_3rd/puplug/config.h ../src_3rd/puplug/libs.h \ ../src_3rd/puplug/error.h safe_fs.h obj_pstk_inlines.h data.h thermal.h \ hid.h hid_nogui.h hid_draw_helpers.h hid_init.h actions.h hid_attrib.h \ - hid_color.h hid_helper.h hid_flags.h \ + hid_color.h hid_cam.h hid_flags.h \ ../src_plugins/export_openscad/scad_draw.c \ ../src_plugins/export_openscad/../lib_polyhelp/topoly.h obj_common.h \ plug_io.h ../src_plugins/export_openscad/scad_models.c dolists.h @@ -839,7 +839,7 @@ ../src_3rd/puplug/config.h ../src_3rd/puplug/libs.h \ ../src_3rd/puplug/error.h safe_fs.h hid.h hid_nogui.h hid_draw_helpers.h \ ../src_plugins/export_png/png.h hid_init.h hid_attrib.h hid_color.h \ - hid_helper.h hid_flags.h dolists.h + hid_cam.h hid_flags.h dolists.h ../src_plugins/export_ps/eps.o: ../src_plugins/export_ps/eps.c \ ../config.h conf_core.h conf.h global_typedefs.h pcb_bool.h unit.h \ pcb-printf.h ../src_3rd/genvector/gds_char.h \ @@ -862,7 +862,7 @@ ../src_3rd/genht/ht.h ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h \ vtpadstack.h obj_pstk_shape.h polygon.h vtpadstack_t.h layer.h \ pcb-printf.h safe_fs.h hid.h hid_nogui.h hid_draw_helpers.h \ - ../src_plugins/export_ps/ps.h hid_init.h hid_attrib.h hid_helper.h \ + ../src_plugins/export_ps/ps.h hid_init.h hid_attrib.h hid_cam.h \ hid_flags.h hid_color.h ../src_plugins/export_ps/ps.o: ../src_plugins/export_ps/ps.c ../config.h \ math_helper.h board.h global_typedefs.h pcb_bool.h unit.h vtroutestyle.h \ @@ -886,10 +886,10 @@ vtpadstack_t.h layer.h error.h draw.h pcb-printf.h plugins.h \ ../src_3rd/puplug/puplug.h ../src_3rd/puplug/libs.h \ ../src_3rd/puplug/os_dep.h ../src_3rd/puplug/config.h \ - ../src_3rd/puplug/libs.h ../src_3rd/puplug/error.h hid_helper.h \ - safe_fs.h conf.h pcb-printf.h ../src_3rd/liblihata/lihata.h list_conf.h \ - hid.h hid_nogui.h hid_draw_helpers.h ../src_plugins/export_ps/ps.h \ - hid_init.h hid_attrib.h hid_flags.h actions.h conf_core.h compat_misc.h \ + ../src_3rd/puplug/libs.h ../src_3rd/puplug/error.h hid_cam.h safe_fs.h \ + conf.h pcb-printf.h ../src_3rd/liblihata/lihata.h list_conf.h hid.h \ + hid_nogui.h hid_draw_helpers.h ../src_plugins/export_ps/ps.h hid_init.h \ + hid_attrib.h hid_flags.h actions.h conf_core.h compat_misc.h \ compat_nls.h stub_draw.h dolists.h ../src_plugins/export_stat/stat.o: ../src_plugins/export_stat/stat.c \ ../config.h conf_core.h conf.h global_typedefs.h pcb_bool.h unit.h \ @@ -918,7 +918,7 @@ ../src_3rd/puplug/libs.h ../src_3rd/puplug/error.h pcb-printf.h \ compat_misc.h plug_io.h safe_fs.h obj_pstk_inlines.h thermal.h hid.h \ hid_nogui.h hid_draw_helpers.h hid_init.h hid_attrib.h hid_color.h \ - hid_helper.h hid_flags.h dolists.h + hid_cam.h hid_flags.h dolists.h ../src_plugins/export_svg/svg.o: ../src_plugins/export_svg/svg.c \ ../config.h conf_core.h conf.h global_typedefs.h pcb_bool.h unit.h \ pcb-printf.h ../src_3rd/genvector/gds_char.h \ @@ -944,7 +944,7 @@ ../src_3rd/puplug/libs.h ../src_3rd/puplug/os_dep.h \ ../src_3rd/puplug/config.h ../src_3rd/puplug/libs.h \ ../src_3rd/puplug/error.h safe_fs.h hid.h hid_nogui.h hid_draw_helpers.h \ - hid_init.h hid_attrib.h hid_color.h hid_helper.h hid_flags.h dolists.h + hid_init.h hid_attrib.h hid_color.h hid_cam.h hid_flags.h dolists.h ../src_plugins/export_test/export_test.o: \ ../src_plugins/export_test/export_test.c ../config.h conf_core.h conf.h \ global_typedefs.h pcb_bool.h unit.h pcb-printf.h \ @@ -969,7 +969,7 @@ pcb-printf.h plugins.h ../src_3rd/puplug/puplug.h \ ../src_3rd/puplug/libs.h ../src_3rd/puplug/os_dep.h \ ../src_3rd/puplug/config.h ../src_3rd/puplug/libs.h \ - ../src_3rd/puplug/error.h hid.h hid_nogui.h hid_attrib.h hid_helper.h \ + ../src_3rd/puplug/error.h hid.h hid_nogui.h hid_attrib.h hid_cam.h \ hid_init.h ../src_plugins/export_xy/xy.o: ../src_plugins/export_xy/xy.c ../config.h \ conf_core.h conf.h global_typedefs.h pcb_bool.h unit.h pcb-printf.h \ @@ -998,7 +998,7 @@ ../src_3rd/puplug/error.h compat_misc.h obj_pstk_inlines.h thermal.h \ layer.h netlist.h route_style.h safe_fs.h macro.h \ ../src_plugins/export_xy/xy_conf.h conf.h hid.h hid_nogui.h hid_attrib.h \ - hid_helper.h hid_init.h ../src_plugins/lib_compat_help/elem_rot.h \ + hid_cam.h hid_init.h ../src_plugins/lib_compat_help/elem_rot.h \ ../src_plugins/export_xy/conf_internal.c \ ../src_plugins/export_xy/xy_conf_fields.h ../src_plugins/extedit/extedit.o: ../src_plugins/extedit/extedit.c \ @@ -1219,7 +1219,7 @@ ../src_3rd/genht/ht.h ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h \ vtpadstack.h obj_pstk_shape.h polygon.h vtpadstack_t.h layer.h grid.h \ board.h vtroutestyle.h library.h rats_patch.h hid_draw_helpers.h \ - hid_attrib.h hid_helper.h hid_color.h ../src_plugins/lib_gtk_hid/gui.h \ + hid_attrib.h hid_cam.h hid_color.h ../src_plugins/lib_gtk_hid/gui.h \ hid.h ../src_plugins/lib_gtk_common/ui_zoompan.h unit.h pcb_bool.h \ ../src_plugins/lib_gtk_common/in_mouse.h hid_cfg_input.h hid_cfg.h \ ../src_plugins/lib_gtk_common/glue.h conf.h \ @@ -1311,7 +1311,7 @@ ../src_3rd/genrtree/genrtree_api.h rtree2_compat.h ht_subc.h \ ../src_3rd/genht/ht.h ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h \ ../src_3rd/genvector/vtp0.h vtpadstack.h obj_pstk_shape.h polygon.h \ - vtpadstack_t.h layer.h hid_draw_helpers.h hid_attrib.h hid_helper.h \ + vtpadstack_t.h layer.h hid_draw_helpers.h hid_attrib.h hid_cam.h \ hid_color.h ../src_plugins/lib_hid_common/clip.h global_typedefs.h \ ../src_plugins/lib_gtk_config/hid_gtk_conf.h conf.h pcb-printf.h \ ../src_3rd/liblihata/lihata.h list_conf.h conf.h \ @@ -1410,7 +1410,7 @@ ../src_3rd/genht/ht.h ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h \ vtpadstack.h obj_pstk_shape.h polygon.h vtpadstack_t.h layer.h grid.h \ board.h vtroutestyle.h library.h rats_patch.h hid_draw_helpers.h \ - hid_attrib.h hid_helper.h hid_color.h ../src_plugins/lib_gtk_hid/gui.h \ + hid_attrib.h hid_cam.h hid_color.h ../src_plugins/lib_gtk_hid/gui.h \ hid.h ../src_plugins/lib_gtk_common/ui_zoompan.h unit.h pcb_bool.h \ ../src_plugins/lib_gtk_common/in_mouse.h hid_cfg_input.h hid_cfg.h \ ../src_plugins/lib_gtk_common/glue.h conf.h \ @@ -1608,11 +1608,10 @@ hid.h hid_nogui.h hid_draw_helpers.h hid_cfg.h \ ../src_plugins/hid_lesstif/lesstif.h hid_cfg_input.h hid_cfg.h \ compat_nls.h board.h vtroutestyle.h library.h rats_patch.h board.h \ - hid_attrib.h hid_helper.h hid_init.h hid_color.h hid_extents.h \ - hid_flags.h actions.h ../src_plugins/hid_lesstif/stdarg.h grid.h \ - misc_util.h compat_misc.h layer_vis.h tool.h \ - ../src_plugins/lib_hid_common/clip.h global_typedefs.h \ - ../src_plugins/lib_hid_common/util.h \ + hid_attrib.h hid_cam.h hid_init.h hid_color.h hid_extents.h hid_flags.h \ + actions.h ../src_plugins/hid_lesstif/stdarg.h grid.h misc_util.h \ + compat_misc.h layer_vis.h tool.h ../src_plugins/lib_hid_common/clip.h \ + global_typedefs.h ../src_plugins/lib_hid_common/util.h \ ../src_plugins/hid_lesstif/dlg_preview.c stub_draw.h dolists.h ../src_plugins/hid_lesstif/menu.o: ../src_plugins/hid_lesstif/menu.c \ ../src_plugins/hid_lesstif/xincludes.h ../config.h conf_core.h conf.h \ @@ -2264,7 +2263,7 @@ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h layer_grp.h hid_draw_helpers.h \ hid_nogui.h actions.h hid.h ../src_3rd/libfungw/fungw.h \ - ../src_3rd/genht/htpp.h hid_init.h hid_attrib.h hid_helper.h plugins.h \ + ../src_3rd/genht/htpp.h hid_init.h hid_attrib.h hid_cam.h plugins.h \ ../src_3rd/puplug/puplug.h ../src_3rd/puplug/libs.h \ ../src_3rd/puplug/os_dep.h ../src_3rd/puplug/config.h \ ../src_3rd/puplug/libs.h ../src_3rd/puplug/error.h event.h plug_io.h \ @@ -5910,6 +5909,26 @@ ../src_3rd/genht/htip.h box.h math_helper.h move.h misc_util.h \ ../src_3rd/genvector/gds_char.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h layer_grp.h pcb-printf.h +hid_cam.o: hid_cam.c ../config.h board.h global_typedefs.h pcb_bool.h \ + unit.h vtroutestyle.h attrib.h ../src_3rd/genvector/genvector_impl.h \ + ../src_3rd/genvector/genvector_undef.h layer.h globalconst.h \ + obj_arc_list.h obj_common.h flag.h data_parent.h obj_arc.h \ + ../src_3rd/genlist/gendlist.h ../src_3rd/genlist/gentdlist_impl.h \ + ../src_3rd/genlist/gendlist.h ../src_3rd/genlist/gentdlist_undef.h \ + obj_line_list.h obj_line.h obj_poly_list.h obj_poly.h polyarea.h \ + obj_text_list.h obj_text.h font.h ../src_3rd/genht/htip.h \ + ../src_3rd/genht/ht.h box.h math_helper.h move.h misc_util.h \ + ../src_3rd/genvector/gds_char.h layer_grp.h library.h rats_patch.h \ + data.h crosshair.h vtonpoint.h hid.h ../src_3rd/liblihata/dom.h \ + ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ + ../src_3rd/genht/htsp.h error.h drc.h route.h buffer.h \ + ../src_3rd/libfungw/fungw.h ../src_3rd/genht/htpp.h obj_rat_list.h \ + obj_rat.h obj_subc_list.h obj_subc.h ../src_3rd/libminuid/libminuid.h \ + rtree.h ../src_3rd/genrtree/genrtree_api.h rtree2_compat.h ht_subc.h \ + ../src_3rd/genht/ht.h ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h \ + ../src_3rd/genvector/vtp0.h vtpadstack.h obj_pstk_shape.h polygon.h \ + vtpadstack_t.h hid_cam.h hid_attrib.h compat_misc.h layer_vis.h \ + plug_io.h conf.h pcb-printf.h ../src_3rd/liblihata/lihata.h list_conf.h hid_cfg.o: hid_cfg.c ../src_3rd/liblihata/lihata.h \ ../src_3rd/liblihata/tree.h ../src_3rd/liblihata/dom.h \ ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ @@ -6020,27 +6039,6 @@ vtpadstack_t.h board.h vtroutestyle.h library.h rats_patch.h conf.h \ pcb-printf.h ../src_3rd/liblihata/lihata.h list_conf.h hid_flags.h \ actions.h -hid_helper.o: hid_helper.c ../config.h board.h global_typedefs.h \ - pcb_bool.h unit.h vtroutestyle.h attrib.h \ - ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h layer.h globalconst.h \ - obj_arc_list.h obj_common.h flag.h data_parent.h obj_arc.h \ - ../src_3rd/genlist/gendlist.h ../src_3rd/genlist/gentdlist_impl.h \ - ../src_3rd/genlist/gendlist.h ../src_3rd/genlist/gentdlist_undef.h \ - obj_line_list.h obj_line.h obj_poly_list.h obj_poly.h polyarea.h \ - obj_text_list.h obj_text.h font.h ../src_3rd/genht/htip.h \ - ../src_3rd/genht/ht.h box.h math_helper.h move.h misc_util.h \ - ../src_3rd/genvector/gds_char.h layer_grp.h library.h rats_patch.h \ - data.h crosshair.h vtonpoint.h hid.h ../src_3rd/liblihata/dom.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ - ../src_3rd/genht/htsp.h error.h drc.h route.h buffer.h \ - ../src_3rd/libfungw/fungw.h ../src_3rd/genht/htpp.h obj_rat_list.h \ - obj_rat.h obj_subc_list.h obj_subc.h ../src_3rd/libminuid/libminuid.h \ - rtree.h ../src_3rd/genrtree/genrtree_api.h rtree2_compat.h ht_subc.h \ - ../src_3rd/genht/ht.h ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h \ - ../src_3rd/genvector/vtp0.h vtpadstack.h obj_pstk_shape.h polygon.h \ - vtpadstack_t.h hid_helper.h hid_attrib.h compat_misc.h plug_io.h conf.h \ - pcb-printf.h ../src_3rd/liblihata/lihata.h list_conf.h hid_init.o: hid_init.c ../config.h hid.h ../src_3rd/liblihata/dom.h \ ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h error.h drc.h unit.h \ Index: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in (revision 18273) +++ trunk/src/Makefile.in (revision 18274) @@ -88,11 +88,11 @@ hid_cfg.o hid_cfg_action.o hid_cfg_input.o + hid_cam.o hid_color.o hid_draw_helpers.o hid_extents.o hid_flags.o - hid_helper.o hid_init.o hid_nogui.o ht_subc.o Index: trunk/src/hid_cam.c =================================================================== --- trunk/src/hid_cam.c (nonexistent) +++ trunk/src/hid_cam.c (revision 18274) @@ -0,0 +1,342 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * (this file is based on PCB, interactive printed circuit board design) + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 2004 harry eaton + * + * 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: email to pcb-rnd (at) igor2.repo.hu + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + * + */ + +#include "config.h" +#include "board.h" +#include "data.h" +#include "hid_cam.h" +#include "hid_attrib.h" +#include "compat_misc.h" +#include "layer_vis.h" +#include "plug_io.h" + +char *pcb_layer_to_file_name(char *dest, pcb_layer_id_t lid, unsigned int flags, pcb_file_name_style_t style) +{ + const pcb_virt_layer_t *v; + pcb_layergrp_id_t group; + int nlayers; + const char *single_name, *res = NULL; + + if (flags == 0) + flags = pcb_layer_flags(PCB, lid); + + if (flags & PCB_LYT_OUTLINE) { + strcpy(dest, "outline"); + return dest; + } + + v = pcb_vlayer_get_first(flags); + if (v != NULL) { + strcpy(dest, v->name); + return dest; + } + + + group = pcb_layer_get_group(PCB, lid); + nlayers = PCB->LayerGroups.grp[group].len; + single_name = pcb_layer_name(PCB->Data, lid); + + if (flags & PCB_LYT_TOP) { + if (style == PCB_FNS_first || (style == PCB_FNS_single && nlayers == 2)) + res = single_name; + if (flags & PCB_LYT_SILK) + res = "topsilk"; + else if (flags & PCB_LYT_MASK) + res = "topmask"; + else if (flags & PCB_LYT_PASTE) + res = "toppaste"; + else + res = "top"; + } + else if (flags & PCB_LYT_BOTTOM) { + if (style == PCB_FNS_first || (style == PCB_FNS_single && nlayers == 2)) + res = single_name; + if (flags & PCB_LYT_SILK) + res = "bottomsilk"; + else if (flags & PCB_LYT_MASK) + res = "bottommask"; + else if (flags & PCB_LYT_PASTE) + res = "bottompaste"; + else + res = "bottom"; + } + else { + static char buf[PCB_DERIVE_FN_SUFF_LEN]; + if (style == PCB_FNS_first || (style == PCB_FNS_single && nlayers == 1)) + res = single_name; + sprintf(buf, "group%ld", group); + res = buf; + } + + assert(res != NULL); + strcpy(dest, res); + return dest; +} + + +void pcb_derive_default_filename(const char *pcbfile, pcb_hid_attribute_t * filename_attrib, const char *suffix, char **memory) +{ + char *buf; + char *pf; + + if (pcbfile == NULL) + pf = pcb_strdup("unknown.pcb"); + else + pf = pcb_strdup(pcbfile); + + if (!pf || (memory && filename_attrib->default_val.str_value != *memory)) + return; + + buf = (char *) malloc(strlen(pf) + strlen(suffix) + 1); + if (memory) + *memory = buf; + if (buf) { + size_t bl; + pcb_plug_io_t *i; + strcpy(buf, pf); + bl = strlen(buf); + for(i = pcb_plug_io_chain; i != NULL; i = i->next) { + if (i->default_extension != NULL) { + int slen = strlen(i->default_extension); + if (bl > slen && strcmp(buf + bl - slen, i->default_extension) == 0) { + buf[bl - slen] = 0; + break; + } + } + } + strcat(buf, suffix); + if (filename_attrib->default_val.str_value) + free((void *) filename_attrib->default_val.str_value); + filename_attrib->default_val.str_value = buf; + } + + free(pf); +} + +/* remove leading and trailing whitespace */ +static char *strip(char *s) +{ + char *end; + while(isspace(*s)) s++; + end = s + strlen(s) - 1; + while((end >= s) && (isspace(*end))) { + *end = '\0'; + end--; + } + return s; +} + +static void layervis_save_and_reset(pcb_cam_t *cam) +{ + pcb_layer_id_t n; + for(n = 0; n < cam->pcb->Data->LayerN; n++) { + cam->orig_vis[n] = cam->pcb->Data->Layer[n].meta.real.vis; + cam->pcb->Data->Layer[n].meta.real.vis = 0; + } +} + +static void layervis_restore(pcb_cam_t *cam) +{ + pcb_layer_id_t n; + for(n = 0; n < cam->pcb->Data->LayerN; n++) + cam->pcb->Data->Layer[n].meta.real.vis = cam->orig_vis[n]; +} + +static int parse_layer_type(char *type, pcb_layer_type_t *lyt, int *offs, int *has_offs) +{ + char *soffs, *end, *nxt, *cur; + pcb_layer_type_t l; + + *lyt = 0; + *offs = *has_offs = 0; + + soffs = strchr(type, ':'); + if (soffs != NULL) { + *soffs = '\0'; + *offs = strtol(soffs+1, &end, 10); + if (*end != '\0') { + pcb_message(PCB_MSG_ERROR, "CAM rule: invalid offset '%s'\n", soffs); + return 1; + } + *has_offs = 1; + } + + for(cur = type; cur != NULL; cur = nxt) { + nxt = strchr(cur, '-'); + if (nxt != NULL) { + *nxt = '\0'; + nxt++; + } + l = pcb_layer_type_str2bit(cur); + if (l == 0) { + pcb_message(PCB_MSG_ERROR, "CAM rule: invalid layer type '%s'\n", cur); + return 1; + } + (*lyt) |= l; + } + return 0; +} + +int pcb_cam_begin(pcb_board_t *pcb, pcb_cam_t *dst, const char *src, const pcb_hid_attribute_t *attr_tbl, int numa, pcb_hid_attr_val_t *options) +{ + char *curr, *next; + + if (src == NULL) + return 0; + + memset(dst, 0, sizeof(pcb_cam_t)); + dst->pcb = pcb; + dst->inst = pcb_strdup(src); + layervis_save_and_reset(dst); + + + /* Syntax: fn=layergrp,layergrp,layergrp;--opt=val;--opt=val */ + /* parse: get file name name */ + next = strchr(dst->inst, '='); + if (next == NULL) { + pcb_message(PCB_MSG_ERROR, "CAM rule missing '='\n"); + goto err; + } + *next = '\0'; + next++; + dst->fn = strip(dst->inst); +pcb_trace("CAM FN='%s'\n", dst->fn); + + while(isspace(*next)) + next++; + + /* parse layers */ + for(curr = next; curr != NULL; curr = next) { + + next = strchr(curr, ','); + if (next != NULL) { + *next = '\0'; + next++; + } + curr = strip(curr); + if (*curr == '@') { + /* named layer */ + pcb_layergrp_id_t gid; + curr++; + gid = pcb_layergrp_by_name(pcb, curr); + if (gid < 0) { + pcb_message(PCB_MSG_ERROR, "CAM rule: no such layer group '%s'\n", curr); + goto err; + } + if (pcb->LayerGroups.grp[gid].len <= 0) + continue; + pcb_layervis_change_group_vis(pcb->LayerGroups.grp[gid].lid[0], 1, 0); + dst->grp_vis[gid] = 1; + } + else { + /* by layer type */ + int offs, has_offs; + pcb_layer_type_t lyt; + pcb_virt_layer_t *vl; + + if (parse_layer_type(curr, &lyt, &offs, &has_offs) != 0) + goto err; + + vl = pcb_vlayer_get_first(lyt); + if (vl == NULL) { + pcb_layergrp_id_t gids[PCB_MAX_LAYERGRP]; + int n, len = pcb_layergrp_list(dst->pcb, lyt, gids, sizeof(gids)/sizeof(gids[0])); + if (has_offs) { + if (offs < 0) + offs = len - offs; + else + offs--; + if ((offs >= 0) && (offs < len)) { + pcb_layergrp_id_t gid = gids[offs]; + pcb_layervis_change_group_vis(pcb->LayerGroups.grp[gid].lid[0], 1, 0); + dst->grp_vis[gid] = 1; + } + } + else { + for(n = 0; n < len; n++) { + pcb_layergrp_id_t gid = gids[n]; + pcb_layervis_change_group_vis(pcb->LayerGroups.grp[gid].lid[0], 1, 0); + dst->grp_vis[gid] = 1; + } + } + + } + else { + int vid = vl->new_id - PCB_LYT_VIRTUAL - 1; + dst->vgrp_vis[vid] = 1; + } + } + } + + dst->active = 1; + return 0; + err:; + layervis_restore(dst); + free(dst->inst); + dst->inst = NULL; + return -1; +} + +int pcb_cam_end(pcb_cam_t *dst) +{ + free(dst->inst); + dst->inst = NULL; + if (!dst->active) + return; + layervis_restore(dst); + dst->active = 0; + return dst->exported_grps; +} + + +int pcb_cam_set_layer_group_(pcb_cam_t *cam, pcb_layergrp_id_t group, unsigned int flags) +{ + pcb_virt_layer_t *vl; + + if (!cam->active) + return 0; + + vl = pcb_vlayer_get_first(flags); + if (vl == NULL) { + if (group == -1) + return 1; + + if (!cam->grp_vis[group]) + return 1; + } + else { + int vid = vl->new_id - PCB_LYT_VIRTUAL - 1; + if (!cam->vgrp_vis[vid]) + return 1; + } + + cam->exported_grps++; + return 0; +} + Index: trunk/src/hid_cam.h =================================================================== --- trunk/src/hid_cam.h (nonexistent) +++ trunk/src/hid_cam.h (revision 18274) @@ -0,0 +1,61 @@ +#ifndef PCB_HID_HELPER_H +#define PCB_HID_HELPER_H + +/* maximum size of a derived suffix */ +#define PCB_DERIVE_FN_SUFF_LEN 20 + +typedef enum pcb_file_name_style_e { + /* Files for copper layers are named top, groupN, bottom. */ + PCB_FNS_fixed, + /* Groups with multiple layers are named as above, else the single + layer name is used. */ + PCB_FNS_single, + /* The name of the first layer in each group is used. */ + PCB_FNS_first +} pcb_file_name_style_t; + +/* Returns a filename base that can be used to output the layer. */ +char *pcb_layer_to_file_name(char *dest, pcb_layer_id_t lid, unsigned int flags, pcb_file_name_style_t style); + +/* Returns a filename base that can be used to output the layer; if flags is 0, + look it up. Copies result in dest (which should be at least PCB_DERIVE_FN_SUFF_LEN bytes wide). + Returns dest. */ +void pcb_derive_default_filename(const char *pcbfile, pcb_hid_attribute_t * filename_attrib, const char *suffix, char **memory); + +/*** CAM API ***/ +typedef struct pcb_cam_s { + /* public */ + const char *fn; + pcb_bool active; + int grp_vis[PCB_MAX_LAYERGRP]; /* whether a real layer group should be rendered */ + int vgrp_vis[PCB_VLY_end]; /* whether a virtual layer group should be rendered */ + + /* private/internal/cache */ + char *inst; + pcb_board_t *pcb; + int orig_vis[PCB_MAX_LAYER]; /* backup of the original layer visibility */ + int exported_grps; +} pcb_cam_t; + +int pcb_cam_begin(pcb_board_t *pcb, pcb_cam_t *dst, const char *src, const pcb_hid_attribute_t *attr_tbl, int numa, pcb_hid_attr_val_t *options); + +/* Finish cam export, free all memory, mark cam export inactive and report + the number of layer groups exported */ +int pcb_cam_end(pcb_cam_t *dst); + + +/* Shall be the first rule in a cam capable exporter's set_layer_group() + callback: decides not to draw a layer group in cam mode if the + group is not scheduled for export */ +#define pcb_cam_set_layer_group(cam, group, flags) \ +do { \ + if (pcb_cam_set_layer_group_(cam, group, flags)) \ + return 0; \ +} while(0) + +/* the logics behind pcb_cam_set_layer_group(); returns non-zero if the macro + should return (and skip the current group) */ +int pcb_cam_set_layer_group_(pcb_cam_t *cam, pcb_layergrp_id_t group, unsigned int flags); + + +#endif Index: trunk/src_plugins/export_bboard/bboard.c =================================================================== --- trunk/src_plugins/export_bboard/bboard.c (revision 18273) +++ trunk/src_plugins/export_bboard/bboard.c (revision 18274) @@ -60,7 +60,7 @@ #include "hid_nogui.h" #include "hid_draw_helpers.h" #include "hid_init.h" -#include "hid_helper.h" +#include "hid_cam.h" #include Index: trunk/src_plugins/export_bom/bom.c =================================================================== --- trunk/src_plugins/export_bom/bom.c (revision 18273) +++ trunk/src_plugins/export_bom/bom.c (revision 18274) @@ -19,7 +19,7 @@ #include "hid.h" #include "hid_nogui.h" #include "hid_attrib.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "hid_init.h" #include "macro.h" Index: trunk/src_plugins/export_dsn/dsn.c =================================================================== --- trunk/src_plugins/export_dsn/dsn.c (revision 18273) +++ trunk/src_plugins/export_dsn/dsn.c (revision 18274) @@ -63,7 +63,7 @@ #include "actions.h" #include "hid_init.h" #include "hid_attrib.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "plugins.h" #include "obj_line.h" #include "obj_pstk_inlines.h" Index: trunk/src_plugins/export_dxf/dxf.c =================================================================== --- trunk/src_plugins/export_dxf/dxf.c (revision 18273) +++ trunk/src_plugins/export_dxf/dxf.c (revision 18274) @@ -52,7 +52,7 @@ #include "hid_init.h" #include "hid_attrib.h" #include "hid_color.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "hid_flags.h" static const char *layer_names[] = { Index: trunk/src_plugins/export_fidocadj/fidocadj.c =================================================================== --- trunk/src_plugins/export_fidocadj/fidocadj.c (revision 18273) +++ trunk/src_plugins/export_fidocadj/fidocadj.c (revision 18274) @@ -58,7 +58,7 @@ #include "hid_init.h" #include "hid_attrib.h" #include "hid_color.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "hid_flags.h" #include "../src_plugins/lib_compat_help/pstk_compat.h" Index: trunk/src_plugins/export_gcode/gcode.c =================================================================== --- trunk/src_plugins/export_gcode/gcode.c (revision 18273) +++ trunk/src_plugins/export_gcode/gcode.c (revision 18274) @@ -53,7 +53,7 @@ #include "error.h" #include "data.h" #include "rats.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "layer.h" #include "compat_misc.h" #include "safe_fs.h" Index: trunk/src_plugins/export_gerber/gerber.c =================================================================== --- trunk/src_plugins/export_gerber/gerber.c (revision 18273) +++ trunk/src_plugins/export_gerber/gerber.c (revision 18274) @@ -20,7 +20,7 @@ #include "layer.h" #include "pcb-printf.h" #include "plugins.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "compat_misc.h" #include "safe_fs.h" #include "macro.h" Index: trunk/src_plugins/export_ipcd356/ipcd356.c =================================================================== --- trunk/src_plugins/export_ipcd356/ipcd356.c (revision 18273) +++ trunk/src_plugins/export_ipcd356/ipcd356.c (revision 18274) @@ -47,7 +47,7 @@ #include "hid.h" #include "hid_nogui.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "hid_attrib.h" #include "hid_init.h" #include "plugins.h" Index: trunk/src_plugins/export_nelma/nelma.c =================================================================== --- trunk/src_plugins/export_nelma/nelma.c (revision 18273) +++ trunk/src_plugins/export_nelma/nelma.c (revision 18274) @@ -72,7 +72,7 @@ #include "layer.h" #include "rats.h" #include "plugins.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "safe_fs.h" #include "hid.h" Index: trunk/src_plugins/export_openems/export_openems.c =================================================================== --- trunk/src_plugins/export_openems/export_openems.c (revision 18273) +++ trunk/src_plugins/export_openems/export_openems.c (revision 18274) @@ -45,7 +45,7 @@ #include "hid.h" #include "actions.h" #include "hid_nogui.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "hid_flags.h" #include "hid_attrib.h" #include "hid_init.h" Index: trunk/src_plugins/export_openscad/export_openscad.c =================================================================== --- trunk/src_plugins/export_openscad/export_openscad.c (revision 18273) +++ trunk/src_plugins/export_openscad/export_openscad.c (revision 18274) @@ -56,7 +56,7 @@ #include "actions.h" #include "hid_attrib.h" #include "hid_color.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "hid_flags.h" Index: trunk/src_plugins/export_png/png.c =================================================================== --- trunk/src_plugins/export_png/png.c (revision 18273) +++ trunk/src_plugins/export_png/png.c (revision 18274) @@ -59,7 +59,7 @@ #include "hid_init.h" #include "hid_attrib.h" #include "hid_color.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "hid_flags.h" #define PNG_SCALE_HACK1 0 Index: trunk/src_plugins/export_ps/eps.c =================================================================== --- trunk/src_plugins/export_ps/eps.c (revision 18273) +++ trunk/src_plugins/export_ps/eps.c (revision 18274) @@ -20,7 +20,7 @@ #include "ps.h" #include "hid_init.h" #include "hid_attrib.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "hid_flags.h" #include "hid_color.h" Index: trunk/src_plugins/export_ps/ps.c =================================================================== --- trunk/src_plugins/export_ps/ps.c (revision 18273) +++ trunk/src_plugins/export_ps/ps.c (revision 18274) @@ -15,7 +15,7 @@ #include "draw.h" #include "pcb-printf.h" #include "plugins.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "safe_fs.h" #include "hid.h" Index: trunk/src_plugins/export_stat/stat.c =================================================================== --- trunk/src_plugins/export_stat/stat.c (revision 18273) +++ trunk/src_plugins/export_stat/stat.c (revision 18274) @@ -61,7 +61,7 @@ #include "hid_init.h" #include "hid_attrib.h" #include "hid_color.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "hid_flags.h" Index: trunk/src_plugins/export_svg/svg.c =================================================================== --- trunk/src_plugins/export_svg/svg.c (revision 18273) +++ trunk/src_plugins/export_svg/svg.c (revision 18274) @@ -58,7 +58,7 @@ #include "hid_init.h" #include "hid_attrib.h" #include "hid_color.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "hid_flags.h" Index: trunk/src_plugins/export_test/export_test.c =================================================================== --- trunk/src_plugins/export_test/export_test.c (revision 18273) +++ trunk/src_plugins/export_test/export_test.c (revision 18274) @@ -17,7 +17,7 @@ #include "hid.h" #include "hid_nogui.h" #include "hid_attrib.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "hid_init.h" const char *export_test_cookie = "export_test HID"; Index: trunk/src_plugins/export_xy/xy.c =================================================================== --- trunk/src_plugins/export_xy/xy.c (revision 18273) +++ trunk/src_plugins/export_xy/xy.c (revision 18274) @@ -27,7 +27,7 @@ #include "hid.h" #include "hid_nogui.h" #include "hid_attrib.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "hid_init.h" #include "../src_plugins/lib_compat_help/elem_rot.h" Index: trunk/src_plugins/hid_gtk2_gdk/gtkhid-gdk.c =================================================================== --- trunk/src_plugins/hid_gtk2_gdk/gtkhid-gdk.c (revision 18273) +++ trunk/src_plugins/hid_gtk2_gdk/gtkhid-gdk.c (revision 18274) @@ -9,7 +9,7 @@ #include "grid.h" #include "hid_draw_helpers.h" #include "hid_attrib.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "hid_color.h" #include "../src_plugins/lib_gtk_hid/gui.h" Index: trunk/src_plugins/hid_gtk2_gl/gtkhid-gl.c =================================================================== --- trunk/src_plugins/hid_gtk2_gl/gtkhid-gl.c (revision 18273) +++ trunk/src_plugins/hid_gtk2_gl/gtkhid-gl.c (revision 18274) @@ -7,7 +7,7 @@ #include "layer.h" #include "hid_draw_helpers.h" #include "hid_attrib.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "hid_color.h" #include "../src_plugins/lib_hid_common/clip.h" Index: trunk/src_plugins/hid_gtk3_cairo/gtkhid-cairo.c =================================================================== --- trunk/src_plugins/hid_gtk3_cairo/gtkhid-cairo.c (revision 18273) +++ trunk/src_plugins/hid_gtk3_cairo/gtkhid-cairo.c (revision 18274) @@ -37,7 +37,7 @@ #include "grid.h" #include "hid_draw_helpers.h" #include "hid_attrib.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "hid_color.h" #include "../src_plugins/lib_gtk_hid/gui.h" Index: trunk/src_plugins/hid_lesstif/main.c =================================================================== --- trunk/src_plugins/hid_lesstif/main.c (revision 18273) +++ trunk/src_plugins/hid_lesstif/main.c (revision 18274) @@ -35,7 +35,7 @@ #include "lesstif.h" #include "hid_cfg_input.h" #include "hid_attrib.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "hid_init.h" #include "hid_color.h" #include "hid_extents.h" Index: trunk/src_plugins/io_hyp/io_hyp.c =================================================================== --- trunk/src_plugins/io_hyp/io_hyp.c (revision 18273) +++ trunk/src_plugins/io_hyp/io_hyp.c (revision 18274) @@ -39,7 +39,7 @@ #include "actions.h" #include "hid_init.h" #include "hid_attrib.h" -#include "hid_helper.h" +#include "hid_cam.h" #include "plugins.h" #include "event.h" #include "plug_io.h"