Index: trunk/src/obj_subc.c =================================================================== --- trunk/src/obj_subc.c (revision 16773) +++ trunk/src/obj_subc.c (revision 16774) @@ -1671,3 +1671,47 @@ { return pcb_data_is_empty(subc->data); } + +pcb_layer_t *pcb_subc_get_layer(pcb_subc_t *sc, pcb_layer_type_t lyt, pcb_layer_combining_t comb, pcb_bool_t alloc, const char *name, pcb_bool req_name_match) +{ + int n; + + /* look for an existing layer with matching lyt and comb first */ + for(n = 0; n < sc->data->LayerN; n++) { + if (sc->data->Layer[n].meta.bound.type != lyt) + continue; + if ((comb != -1) && (sc->data->Layer[n].comb != comb)) + continue; + if (req_name_match && (strcmp(sc->data->Layer[n].name, name) != 0)) + continue; + return &sc->data->Layer[n]; + } + + if (!alloc) + return NULL; + + if (sc->data->LayerN == PCB_MAX_LAYER) + return NULL; + + n = sc->data->LayerN++; + if (name == NULL) + name = ""; + + if (comb == -1) { + /* "any" means default, for the given layer type */ + if (lyt & PCB_LYT_MASK) + comb = PCB_LYC_SUB; + else + comb = 0; /* positive, manual */ + } + + memset(&sc->data->Layer[n], 0, sizeof(sc->data->Layer[n])); + sc->data->Layer[n].name = pcb_strdup(name); + sc->data->Layer[n].comb = comb; + sc->data->Layer[n].is_bound = 1; + sc->data->Layer[n].meta.bound.type = lyt; + sc->data->Layer[n].parent.data = sc->data; + sc->data->Layer[n].parent_type = PCB_PARENT_DATA; + sc->data->Layer[n].type = PCB_OBJ_LAYER; + return &sc->data->Layer[n]; +} Index: trunk/src/obj_subc.h =================================================================== --- trunk/src/obj_subc.h (revision 16773) +++ trunk/src/obj_subc.h (revision 16774) @@ -31,6 +31,7 @@ #include #include #include "obj_common.h" +#include "layer.h" #include "global_typedefs.h" @@ -91,6 +92,11 @@ /* Do the initial global bindings of subc to pcb (rtree links) */ void pcb_subc_bind_globals(pcb_board_t *pcb, pcb_subc_t *subc); +/* Look up a layer by lyt and comb (and name, if req_name_match is true); + if not found and alloc is true, allocate a new layer with the given name. + Return NULL on error. */ +pcb_layer_t *pcb_subc_get_layer(pcb_subc_t *sc, pcb_layer_type_t lyt, pcb_layer_combining_t comb, pcb_bool_t alloc, const char *name, pcb_bool req_name_match); + #include "rtree.h" pcb_r_dir_t draw_subc_mark_callback(const pcb_box_t *b, void *cl); void DrawSubc(pcb_subc_t *sc); Index: trunk/src_plugins/lib_compat_help/subc_help.c =================================================================== --- trunk/src_plugins/lib_compat_help/subc_help.c (revision 16773) +++ trunk/src_plugins/lib_compat_help/subc_help.c (revision 16774) @@ -26,50 +26,6 @@ #include "subc_help.h" -pcb_layer_t *pcb_subc_get_layer(pcb_subc_t *sc, pcb_layer_type_t lyt, pcb_layer_combining_t comb, pcb_bool_t alloc, const char *name, pcb_bool req_name_match) -{ - int n; - - /* look for an existing layer with matching lyt and comb first */ - for(n = 0; n < sc->data->LayerN; n++) { - if (sc->data->Layer[n].meta.bound.type != lyt) - continue; - if ((comb != -1) && (sc->data->Layer[n].comb != comb)) - continue; - if (req_name_match && (strcmp(sc->data->Layer[n].name, name) != 0)) - continue; - return &sc->data->Layer[n]; - } - - if (!alloc) - return NULL; - - if (sc->data->LayerN == PCB_MAX_LAYER) - return NULL; - - n = sc->data->LayerN++; - if (name == NULL) - name = ""; - - if (comb == -1) { - /* "any" means default, for the given layer type */ - if (lyt & PCB_LYT_MASK) - comb = PCB_LYC_SUB; - else - comb = 0; /* positive, manual */ - } - - memset(&sc->data->Layer[n], 0, sizeof(sc->data->Layer[n])); - sc->data->Layer[n].name = pcb_strdup(name); - sc->data->Layer[n].comb = comb; - sc->data->Layer[n].is_bound = 1; - sc->data->Layer[n].meta.bound.type = lyt; - sc->data->Layer[n].parent.data = sc->data; - sc->data->Layer[n].parent_type = PCB_PARENT_DATA; - sc->data->Layer[n].type = PCB_OBJ_LAYER; - return &sc->data->Layer[n]; -} - pcb_text_t *pcb_subc_add_dyntex(pcb_subc_t *sc, pcb_coord_t x, pcb_coord_t y, unsigned direction, int scale, pcb_bool bottom, const char *pattern) { pcb_layer_type_t side = bottom ? PCB_LYT_BOTTOM : PCB_LYT_TOP; Index: trunk/src_plugins/lib_compat_help/subc_help.h =================================================================== --- trunk/src_plugins/lib_compat_help/subc_help.h (revision 16773) +++ trunk/src_plugins/lib_compat_help/subc_help.h (revision 16774) @@ -4,11 +4,6 @@ #include "obj_subc.h" #include "layer.h" -/* Look up a layer by lyt and comb (and name, if req_name_match is true); - if not found and alloc is true, allocate a new layer with the given name. - Return NULL on error. */ -pcb_layer_t *pcb_subc_get_layer(pcb_subc_t *sc, pcb_layer_type_t lyt, pcb_layer_combining_t comb, pcb_bool_t alloc, const char *name, pcb_bool req_name_match); - /* Create dynamic text on the top silk layer (creates the layer if needed). Returns the text object, or NULL on error. Does not set any subc attribute. The refdes version is just a shorthand for the pattern. */