Index: trunk/src/event.c =================================================================== --- trunk/src/event.c (revision 20549) +++ trunk/src/event.c (revision 20550) @@ -45,6 +45,7 @@ "pcbev_route_styles_changed", "pcbev_netlist_changed", "pcbev_layers_changed", + "pcbev_layer_changed_grp", "pcbev_layervis_changed", "pcbev_library_changed", "pcbev_font_changed", Index: trunk/src/event.h =================================================================== --- trunk/src/event.h (revision 20549) +++ trunk/src/event.h (revision 20550) @@ -42,6 +42,7 @@ PCB_EVENT_ROUTE_STYLES_CHANGED, /* called after any route style change (used to be the RouteStylesChanged action) */ PCB_EVENT_NETLIST_CHANGED, /* called after any netlist change (used to be the NetlistChanged action) */ PCB_EVENT_LAYERS_CHANGED, /* called after layers or layer groups change (used to be the LayersChanged action) */ + PCB_EVENT_LAYER_CHANGED_GRP, /* called after a layer changed its group; argument: layer pointer */ PCB_EVENT_LAYERVIS_CHANGED, /* called after the visibility of layers has changed */ PCB_EVENT_LIBRARY_CHANGED, /* called after a change in the footprint lib (used to be the LibraryChanged action) */ PCB_EVENT_FONT_CHANGED, /* called when a font has changed; argument is the font ID */ Index: trunk/src/layer_grp.c =================================================================== --- trunk/src/layer_grp.c (revision 20549) +++ trunk/src/layer_grp.c (revision 20550) @@ -185,6 +185,7 @@ if (pcb_layergrp_del_layer(pcb, -1, lid) != 0) return -1; pcb_layer_add_in_group(pcb, lid, gid); + pcb_event(PCB_EVENT_LAYER_CHANGED_GRP, "p", &pcb->Data->Layer[lid]); NOTIFY(pcb); return gid; } Index: trunk/src/main.c =================================================================== --- trunk/src/main.c (revision 20549) +++ trunk/src/main.c (revision 20550) @@ -247,6 +247,7 @@ void pcb_main_uninit(void) { pcb_brave_uninit(); + pcb_polygon_uninit(); if (conf_isdirty(CFR_USER)) conf_save_file(NULL, NULL, CFR_USER, NULL); Index: trunk/src/polygon.c =================================================================== --- trunk/src/polygon.c (revision 20549) +++ trunk/src/polygon.c (revision 20550) @@ -51,6 +51,7 @@ #include "compat_nls.h" #include "obj_poly_draw.h" #include "polygon_selfi.h" +#include "event.h" #define ROUND(x) ((long)(((x) >= 0 ? (x) + 0.5 : (x) - 0.5))) @@ -70,6 +71,29 @@ static int Unsubtract(pcb_polyarea_t * np1, pcb_poly_t * p); +static const char *polygon_cookie = "core polygon"; + + +void pcb_poly_layers_chg(void *user_data, int argc, pcb_event_arg_t argv[]) +{ + pcb_layer_t *ly; + pcb_data_t *data; + + if ((argc < 2) || (argv[1].type != PCB_EVARG_PTR)) + return; + ly = argv[1].d.p; + if ((ly->is_bound) || (ly->parent_type != PCB_PARENT_DATA)) + return; + + data = ly->parent.data; + pcb_data_clip_inhibit_inc(data); + PCB_POLY_LOOP(ly); { + polygon->clip_dirty = 1; + } + PCB_END_LOOP; + pcb_data_clip_inhibit_dec(data, 1); +} + void pcb_polygon_init(void) { double cos_ang = cos(2.0 * M_PI / PCB_POLY_CIRC_SEGS_F); @@ -79,8 +103,15 @@ rotate_circle_seg[1] = -sin_ang; rotate_circle_seg[2] = sin_ang; rotate_circle_seg[3] = cos_ang; + + pcb_event_bind(PCB_EVENT_LAYER_CHANGED_GRP, pcb_poly_layers_chg, NULL, polygon_cookie); } +void pcb_polygon_uninit(void) +{ + pcb_event_unbind_allcookie(polygon_cookie); +} + pcb_cardinal_t pcb_poly_point_idx(pcb_poly_t *polygon, pcb_point_t *point) { assert(point >= polygon->Points); Index: trunk/src/polygon.h =================================================================== --- trunk/src/polygon.h (revision 20549) +++ trunk/src/polygon.h (revision 20550) @@ -55,6 +55,7 @@ /* Prototypes */ void pcb_polygon_init(void); +void pcb_polygon_uninit(void); pcb_cardinal_t pcb_poly_point_idx(pcb_poly_t *polygon, pcb_point_t *point); pcb_cardinal_t pcb_poly_contour_point(pcb_poly_t *polygon, pcb_cardinal_t point); pcb_cardinal_t pcb_poly_contour_prev_point(pcb_poly_t *polygon, pcb_cardinal_t point);