Index: layertab.c =================================================================== --- layertab.c (nonexistent) +++ layertab.c (revision 33559) @@ -0,0 +1,47 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 2020 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") + * + */ + + +typedef struct { + int id; /* in eagle */ + pcb_layer_type_t lyt; + const char *purp; + const char *name; + int color; +} eagle_layertab_t; + +static const eagle_layertab_t eagle_layertab[] = { + + /* tDocu & bDocu are used for info used when designing, but not necessarily for + exporting to Gerber i.e. package outlines that cross pads, or instructions. + These layers within the silk groups will be needed when subc replaces elements + since most Eagle packages use tDocu, bDocu for some of their artwork */ + {51, PCB_LYT_SILK | PCB_LYT_TOP, NULL, "tDocu", 14}, + {52, PCB_LYT_SILK | PCB_LYT_BOTTOM, NULL, "bDocu", 7}, + + {0} +}; Index: read.c =================================================================== --- read.c (revision 33558) +++ read.c (revision 33559) @@ -369,13 +369,10 @@ return 0; } +#include "layertab.c" + static pcb_layer_t *eagle_layer_get(read_state_t *st, eagle_layerid_t id, eagle_loc_t loc, void *obj) { - /* tDocu & bDocu are used for info used when designing, but not necessarily for - exporting to Gerber i.e. package outlines that cross pads, or instructions. - These layers within the silk groups will be needed when subc replaces elements - since most Eagle packages use tDocu, bDocu for some of their artwork */ - eagle_layer_t *ly = htip_get(&st->layers, id); rnd_layer_id_t lid; pcb_subc_t *subc = obj; @@ -384,24 +381,18 @@ /* if more than 51 or 52 are considered useful, we could relax the test here: */ if ((ly == NULL) || (ly->lid < 0)) { - TODO("move this out to a separate function") - if (id == 51 || id == 52) { + const eagle_layertab_t *t; + + for(t = eagle_layertab; t->id != 0; t++) + if (t->id == id) + break; + + if (t->id == id) { /* create docu on the first reference */ - pcb_layer_type_t typ; + pcb_layer_type_t typ = t->lyt; rnd_layergrp_id_t gid; - switch (id) { - case 51: /* = tDocu */ - typ = PCB_LYT_SILK | PCB_LYT_TOP; - ly->name = "tDocu"; - ly->color = 14; - break; - default: /* i.e. 52 = bDocu: */ - typ = PCB_LYT_SILK | PCB_LYT_BOTTOM; - ly->name = "bDocu"; - ly->color = 7; - break; - } - + ly->name = t->name; + ly->color = t->color; ly->fill = 1; ly->visible = 0; ly->active = 1;