Index: trunk/src/layer.c =================================================================== --- trunk/src/layer.c (revision 19103) +++ trunk/src/layer.c (revision 19104) @@ -38,8 +38,6 @@ #include "layer_ui.h" #include "layer_vis.h" #include "rtree.h" -#include "funchash.h" -#include "funchash_core.h" #include "obj_pstk_inlines.h" #include "list_common.h" @@ -469,35 +467,6 @@ return pcb_layer_rename_(&data->Layer[layer], pcb_strdup(color)); } -int pcb_layer_set_purpose__(pcb_layer_t *ly, char *purpose) -{ - free(ly->purpose); - if (purpose == NULL) { - ly->purpose = NULL; - ly->purpi = F_user; - } - else { - ly->purpose = purpose; - ly->purpi = pcb_funchash_get(purpose, NULL); - if (ly->purpi < 0) - ly->purpi = F_user; - } - return 0; -} - -int pcb_layer_set_purpose_(pcb_layer_t *ly, char *purpose) -{ - int ret = pcb_layer_set_purpose__(ly, purpose); - pcb_event(PCB_EVENT_LAYERS_CHANGED, NULL); - return ret; -} - -int pcb_layer_set_purpose(pcb_layer_t *ly, const char *purpose) -{ - return pcb_layer_set_purpose_(ly, pcb_strdup(purpose)); -} - - #undef APPEND static int is_last_top_copper_layer(pcb_board_t *pcb, int layer) Index: trunk/src/layer.h =================================================================== --- trunk/src/layer.h (revision 19103) +++ trunk/src/layer.h (revision 19104) @@ -115,8 +115,6 @@ const char *name; /* layer name */ pcb_layer_combining_t comb; /* how to combine this layer with other layers in the group */ - char *purpose; /* what a doc/mech layer is used for */ - int purpi; /* integer version of purpose from the funtion hash (cache) */ /* for bound layers these point to the board layer's*/ pcb_rtree_t *line_tree, *text_tree, *polygon_tree, *arc_tree; @@ -136,6 +134,7 @@ pcb_layer_type_t type; /* for comb, use the ->comb from the common part */ int stack_offs; /* offset in the stack for PCB_LYT_INNER: positive is counted from primary side, negative from the opposite side */ + char *purpose; /* what the target doc/mech layer is used for */ unsigned user_specified:1; /* 1 if the user forced the binding */ pcb_layer_id_t user_lid; @@ -270,12 +269,6 @@ int pcb_layer_rename_(pcb_layer_t *Layer, char *Name); int pcb_layer_recolor_(pcb_layer_t *Layer, char *color); -/* Change the purpose field and recalc purpi (not undoable) */ -int pcb_layer_set_purpose__(pcb_layer_t *ly, char *purpose); /* no strdup, no event */ -int pcb_layer_set_purpose_(pcb_layer_t *ly, char *purpose); /* no strdup, send layer change event */ -int pcb_layer_set_purpose(pcb_layer_t *ly, const char *purpose); /* strdup, send event */ - - /* index is 0..PCB_MAX_LAYER-1. If old_index is -1, a new layer is inserted at that index. If new_index is -1, the specified layer is deleted. Returns non-zero on error, zero if OK. */ Index: trunk/src/layer_grp.c =================================================================== --- trunk/src/layer_grp.c (revision 19103) +++ trunk/src/layer_grp.c (revision 19104) @@ -33,6 +33,8 @@ #include "layer_grp.h" #include "compat_misc.h" #include "event.h" +#include "funchash.h" +#include "funchash_core.h" /* notify the rest of the code after layer group changes so that the GUI and other parts sync up */ @@ -698,6 +700,34 @@ return pcb_layergrp_rename_(grp, pcb_strdup(name)); } +int pcb_layergrp_set_purpose__(pcb_layergrp_t *lg, char *purpose) +{ + free(lg->purpose); + if (purpose == NULL) { + lg->purpose = NULL; + lg->purpi = F_user; + } + else { + lg->purpose = purpose; + lg->purpi = pcb_funchash_get(purpose, NULL); + if (lg->purpi < 0) + lg->purpi = F_user; + } + return 0; +} + +int pcb_layergrp_set_purpose_(pcb_layergrp_t *lg, char *purpose) +{ + int ret = pcb_layergrp_set_purpose__(lg, purpose); + pcb_event(PCB_EVENT_LAYERS_CHANGED, NULL); + return ret; +} + +int pcb_layergrp_set_purpose(pcb_layergrp_t *lg, const char *purpose) +{ + return pcb_layergrp_set_purpose_(lg, pcb_strdup(purpose)); +} + pcb_layergrp_id_t pcb_layergrp_by_name(pcb_board_t *pcb, const char *name) { pcb_layergrp_id_t n; Index: trunk/src/layer_grp.h =================================================================== --- trunk/src/layer_grp.h (revision 19103) +++ trunk/src/layer_grp.h (revision 19104) @@ -44,7 +44,10 @@ pcb_cardinal_t len; /* number of layer IDs in use */ pcb_layer_id_t lid[PCB_MAX_LAYER]; /* lid=layer ID */ char *name; /* name of the physical layer (independent of the name of the layer groups) */ + pcb_layer_type_t ltype; + char *purpose; /* what a doc/mech layer is used for */ + int purpi; /* integer version of purpose from the funtion hash (cache) */ unsigned valid:1; /* 1 if it's a new-style, valid layer group; 0 after loading old files with no layer stackup info */ unsigned vis:1; /* 1 if layer group is visible on the GUI */ @@ -150,6 +153,12 @@ /* changes the name of a layer; memory has to be already allocated */ int pcb_layergrp_rename_(pcb_layergrp_t *grp, char *name); +/* Change the purpose field and recalc purpi (not undoable) */ +int pcb_layergrp_set_purpose__(pcb_layergrp_t *lg, char *purpose); /* no strdup, no event */ +int pcb_layergrp_set_purpose_(pcb_layergrp_t *lg, char *purpose); /* no strdup, send layer change event */ +int pcb_layergrp_set_purpose(pcb_layergrp_t *lg, const char *purpose); /* strdup, send event */ + + /* Slow linear search for a layer group by name */ pcb_layergrp_id_t pcb_layergrp_by_name(pcb_board_t *pcb, const char *name);