Index: trunk/src/obj_arc.c =================================================================== --- trunk/src/obj_arc.c (revision 11742) +++ trunk/src/obj_arc.c (revision 11743) @@ -727,10 +727,13 @@ return new_arc; } -#define PCB_ARC_FLAGS (PCB_FLAG_FOUND | PCB_FLAG_CLEARLINE | PCB_FLAG_SELECTED | PCB_FLAG_AUTO | PCB_FLAG_RUBBEREND | PCB_FLAG_LOCK | PCB_FLAG_VISIT | PCB_FLAG_TERMNAME) void *pcb_arcop_change_flag(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_arc_t *Arc) { - if ((ctx->chgflag.flag & PCB_ARC_FLAGS) != ctx->chgflag.flag) + static pcb_flag_values_t pcb_arc_flags = 0; + if (pcb_arc_flags == 0) + pcb_arc_flags = pcb_obj_valid_flags(PCB_TYPE_ARC); + + if ((ctx->chgflag.flag & pcb_arc_flags) != ctx->chgflag.flag) return NULL; if ((ctx->chgflag.flag & PCB_FLAG_TERMNAME) && (Arc->term == NULL)) return NULL; Index: trunk/src/obj_common.c =================================================================== --- trunk/src/obj_common.c (revision 11742) +++ trunk/src/obj_common.c (revision 11743) @@ -31,6 +31,7 @@ #include #include #include "conf_core.h" +#include "flag_str.h" #include "global_typedefs.h" #include "const.h" #include "error.h" @@ -187,3 +188,15 @@ } return NULL; } + +pcb_flag_values_t pcb_obj_valid_flags(unsigned long int objtype) +{ + pcb_flag_values_t res = 0; + int n; + + for(n = 0; n < pcb_object_flagbits_len; n++) + if (pcb_object_flagbits[n].object_types & objtype) + res |= pcb_object_flagbits[n].mask; + + return res; +} Index: trunk/src/obj_common.h =================================================================== --- trunk/src/obj_common.h (revision 11742) +++ trunk/src/obj_common.h (revision 11743) @@ -80,7 +80,10 @@ /* Return the user readable name of an object type in a string; never NULL */ const char *pcb_obj_type_name(pcb_objtype_t type); +/* returns a flag mask of all valid flags for an (old) object type */ +pcb_flag_values_t pcb_obj_valid_flags(unsigned long int objtype); + int GetObjectBoundingBox(int Type, void *Ptr1, void *Ptr2, void *Ptr3, pcb_box_t *res); /* memset object to 0, but keep the link field */ Index: trunk/src/obj_line.c =================================================================== --- trunk/src/obj_line.c (revision 11742) +++ trunk/src/obj_line.c (revision 11743) @@ -906,10 +906,13 @@ return (line); } -#define PCB_LINE_FLAGS (PCB_FLAG_FOUND | PCB_FLAG_RAT | PCB_FLAG_CLEARLINE | PCB_FLAG_SELECTED | PCB_FLAG_AUTO | PCB_FLAG_RUBBEREND | PCB_FLAG_LOCK | PCB_FLAG_VISIT | PCB_FLAG_TERMNAME) void *pcb_lineop_change_flag(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_line_t *Line) { - if ((ctx->chgflag.flag & PCB_LINE_FLAGS) != ctx->chgflag.flag) + static pcb_flag_values_t pcb_line_flags = 0; + if (pcb_line_flags == 0) + pcb_line_flags = pcb_obj_valid_flags(PCB_TYPE_LINE); + + if ((ctx->chgflag.flag & pcb_line_flags) != ctx->chgflag.flag) return NULL; if ((ctx->chgflag.flag & PCB_FLAG_TERMNAME) && (Line->term == NULL)) return NULL; Index: trunk/src/obj_pad.c =================================================================== --- trunk/src/obj_pad.c (revision 11742) +++ trunk/src/obj_pad.c (revision 11743) @@ -401,10 +401,13 @@ return (NULL); } -#define PCB_PAD_FLAGS (PCB_FLAG_FOUND | PCB_FLAG_NOPASTE | PCB_FLAG_PININPOLY | PCB_FLAG_SELECTED | PCB_FLAG_AUTO | PCB_FLAG_LOCK | PCB_FLAG_VISIT) void *pcb_padop_change_flag(pcb_opctx_t *ctx, pcb_element_t *elem, pcb_pad_t *pad) { - if ((ctx->chgflag.flag & PCB_PAD_FLAGS) != ctx->chgflag.flag) + static pcb_flag_values_t pcb_pad_flags = 0; + if (pcb_pad_flags == 0) + pcb_pad_flags = pcb_obj_valid_flags(PCB_TYPE_PAD); + + if ((ctx->chgflag.flag & pcb_pad_flags) != ctx->chgflag.flag) return NULL; PCB_FLAG_CHANGE(ctx->chgflag.how, ctx->chgflag.flag, pad); return pad; Index: trunk/src/obj_pinvia.c =================================================================== --- trunk/src/obj_pinvia.c (revision 11742) +++ trunk/src/obj_pinvia.c (revision 11743) @@ -896,11 +896,13 @@ return via; } - -#define PCB_PIN_FLAGS (PCB_FLAG_FOUND | PCB_FLAG_HOLE | PCB_FLAG_PININPOLY | PCB_FLAG_SELECTED | PCB_FLAG_AUTO | PCB_FLAG_LOCK | PCB_FLAG_VISIT | PCB_FLAG_TERMNAME) void *pcb_viaop_change_flag(pcb_opctx_t *ctx, pcb_pin_t *pin) { - if ((ctx->chgflag.flag & PCB_PIN_FLAGS) != ctx->chgflag.flag) + static pcb_flag_values_t pcb_pin_flags = 0; + if (pcb_pin_flags == 0) + pcb_pin_flags = pcb_obj_valid_flags(PCB_TYPE_PIN); + + if ((ctx->chgflag.flag & pcb_pin_flags) != ctx->chgflag.flag) return NULL; if ((ctx->chgflag.flag & PCB_FLAG_TERMNAME) && (pin->term == NULL)) return NULL; Index: trunk/src/obj_poly.c =================================================================== --- trunk/src/obj_poly.c (revision 11742) +++ trunk/src/obj_poly.c (revision 11743) @@ -34,6 +34,7 @@ #include "compat_nls.h" #include "undo.h" #include "polygon.h" +#include "polygon_offs.h" #include "rotate.h" #include "search.h" @@ -862,10 +863,13 @@ return Polygon; } -#define PCB_POLY_FLAGS (PCB_FLAG_FOUND | PCB_FLAG_CLEARPOLY | PCB_FLAG_FULLPOLY | PCB_FLAG_SELECTED | PCB_FLAG_AUTO | PCB_FLAG_LOCK | PCB_FLAG_VISIT) void *pcb_polyop_change_flag(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_polygon_t *Polygon) { - if ((ctx->chgflag.flag & PCB_POLY_FLAGS) != ctx->chgflag.flag) + static pcb_flag_values_t pcb_poly_flags = 0; + if (pcb_poly_flags == 0) + pcb_poly_flags = pcb_obj_valid_flags(PCB_TYPE_POLYGON); + + if ((ctx->chgflag.flag & pcb_poly_flags) != ctx->chgflag.flag) return NULL; if ((ctx->chgflag.flag & PCB_FLAG_TERMNAME) && (Polygon->term == NULL)) return NULL; Index: trunk/src/obj_subc.c =================================================================== --- trunk/src/obj_subc.c (revision 11742) +++ trunk/src/obj_subc.c (revision 11743) @@ -1066,11 +1066,15 @@ } -#define PCB_SUBC_FLAGS (PCB_FLAG_FOUND | PCB_FLAG_SELECTED | PCB_FLAG_AUTO | PCB_FLAG_LOCK | PCB_FLAG_VISIT | PCB_FLAG_NONETLIST) + void *pcb_subcop_change_flag(pcb_opctx_t *ctx, pcb_subc_t *sc) { + static pcb_flag_values_t pcb_subc_flags = 0; + if (pcb_subc_flags == 0) + pcb_subc_flags = pcb_obj_valid_flags(PCB_TYPE_SUBC); + pcb_subc_op(ctx->chgflag.pcb->Data, sc, &ChgFlagFunctions, ctx); - if ((ctx->chgflag.flag & PCB_SUBC_FLAGS) == ctx->chgflag.flag) + if ((ctx->chgflag.flag & pcb_subc_flags) == ctx->chgflag.flag) PCB_FLAG_CHANGE(ctx->chgflag.how, ctx->chgflag.flag, sc); return sc; } Index: trunk/src/obj_text.c =================================================================== --- trunk/src/obj_text.c (revision 11742) +++ trunk/src/obj_text.c (revision 11743) @@ -612,10 +612,13 @@ pcb_poly_clear_from_poly(PCB->Data, PCB_TYPE_TEXT, layer, text); } -#define PCB_TEXT_FLAGS (PCB_FLAG_FOUND | PCB_FLAG_CLEARLINE | PCB_FLAG_SELECTED | PCB_FLAG_AUTO | PCB_FLAG_LOCK | PCB_FLAG_VISIT | PCB_FLAG_TERMNAME) void *pcb_textop_change_flag(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_text_t *Text) { - if ((ctx->chgflag.flag & PCB_TEXT_FLAGS) != ctx->chgflag.flag) + static pcb_flag_values_t pcb_text_flags = 0; + if (pcb_text_flags == 0) + pcb_text_flags = pcb_obj_valid_flags(PCB_TYPE_TEXT); + + if ((ctx->chgflag.flag & pcb_text_flags) != ctx->chgflag.flag) return NULL; if ((ctx->chgflag.flag & PCB_FLAG_TERMNAME) && (Text->term == NULL)) return NULL;