Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 30180) +++ trunk/scconfig/Rev.h (revision 30181) @@ -1 +1 @@ -static const int myrev = 30175; +static const int myrev = 30181; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 30180) +++ trunk/scconfig/Rev.tab (revision 30181) @@ -1,4 +1,4 @@ -30175 configure query plugin: make bloat/shrink net drc loop reusable +30181 configure query plugin: make bloat/shrink net drc loop reusable 30169 configure query plugin: function implementation/split 29927 configure generalizing zoom and pan actions for ringdove 29778 configure new object type: gfx Index: trunk/scconfig/plugins.h =================================================================== --- trunk/scconfig/plugins.h (revision 30180) +++ trunk/scconfig/plugins.h (revision 30181) @@ -146,6 +146,8 @@ plugin_dep("dialogs", "lib_hid_common", 0) plugin_dep("dialogs", "lib_hid_pcbui", 0) plugin_dep("draw_fab", "report", 0) +plugin_dep("drc_orig", "query", 0) +plugin_dep("drc_query", "query", 0) plugin_dep("export_fidocadj", "lib_compat_help", 0) plugin_dep("export_gcode", "millpath", 0) plugin_dep("export_gerber", "export_excellon", 0) Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 30180) +++ trunk/src/Makefile.dep (revision 30181) @@ -1717,8 +1717,8 @@ librnd/core/pcb-printf.h librnd/core/compat_misc.h conf_core.h \ librnd/core/conf.h ../src_3rd/liblihata/lihata.h librnd/core/list_conf.h \ obj_text.h obj_text_draw.h obj_line_draw.h -../src_plugins/drc_orig/drc_net_int.o: \ - ../src_plugins/drc_orig/drc_net_int.c ../config.h librnd/config.h \ +../src_plugins/query/net_int.o: \ + ../src_plugins/query/net_int.c ../config.h librnd/config.h \ board.h ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ librnd/core/global_typedefs.h librnd/core/pcb_bool.h vtroutestyle.h \ librnd/core/unit.h librnd/core/attrib.h \ @@ -1733,7 +1733,7 @@ librnd/core/math_helper.h librnd/core/misc_util.h \ ../src_3rd/genvector/gds_char.h obj_gfx_list.h obj_gfx.h layer_grp.h \ rats_patch.h board.h librnd/core/hidlib.h librnd/core/global_typedefs.h \ - find.h ../src_3rd/genvector/vtp0.h ../src_plugins/drc_orig/drc_net_int.h \ + find.h ../src_3rd/genvector/vtp0.h ../src_plugins/query/net_int.h \ view.h idpath.h obj_common.h drc.h view.h ../src_plugins/drc_orig/drc_orig.o: ../src_plugins/drc_orig/drc_orig.c \ ../config.h librnd/config.h drc.h view.h ../src_3rd/genlist/gendlist.h \ @@ -1766,7 +1766,7 @@ ../src_3rd/puplug/error.h layer_vis.h obj_arc_draw.h draw.h \ obj_rat_draw.h obj_line_draw.h obj_text_draw.h obj_poly_draw.h \ obj_pstk_draw.h board.h vtroutestyle.h rats_patch.h obj_subc_list.h \ - ../src_plugins/drc_orig/drc_net_int.h obj_common.h + ../src_plugins/query/net_int.h obj_common.h ../src_plugins/drc_query/drc_query.o: \ ../src_plugins/drc_query/drc_query.c ../config.h librnd/config.h \ librnd/core/plugins.h ../src_3rd/puplug/puplug.h \ Index: trunk/src_plugins/drc_orig/drc_net_int.c =================================================================== --- trunk/src_plugins/drc_orig/drc_net_int.c (revision 30180) +++ trunk/src_plugins/drc_orig/drc_net_int.c (nonexistent) @@ -1,112 +0,0 @@ -/* - * - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * (this file is based on PCB, interactive printed circuit board design) - * Copyright (C) 2018,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 St, 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") - * - */ - -#include "config.h" - -#include "board.h" -#include "find.h" -#include "drc_net_int.h" - -TODO("remove:") -#include "drc.h" - -#define PCB dontuse - -TODO("find: get rid of this global state") -extern pcb_coord_t Bloat; - - -/* evaluates to true if obj was marked on list (fa or fb) */ -#define IS_FOUND(obj, list) (PCB_DFLAG_TEST(&(obj->Flags), ctx->list.mark)) - -static int pcb_int_broken_cb(pcb_find_t *fctx, pcb_any_obj_t *new_obj, pcb_any_obj_t *arrived_from, pcb_found_conn_type_t ctype) -{ - pcb_net_int_t *ctx = fctx->user_data; - - if (arrived_from == NULL) /* ingore the starting object - it must be marked as we started from the same object in the first search */ - return 0; - - /* broken if new object is not marked in the shrunk search (fa) but - the arrived_from object was marked (so we notify direct breaks only) */ - if (!IS_FOUND(new_obj, fa) && IS_FOUND(arrived_from, fa)) { - int r = ctx->broken_cb(ctx, new_obj, arrived_from, ctype); - if (r != 0) return r; - return ctx->fast; /* if fast is 1, we are aborting the search, returning the first hit only */ - } - return 0; -} - -pcb_bool pcb_net_integrity(pcb_board_t *pcb, pcb_view_list_t *lst, pcb_any_obj_t *from, pcb_coord_t shrink, pcb_coord_t bloat, pcb_int_broken_cb_t *cb, void *cb_data) -{ - pcb_net_int_t ctx; - - ctx.pcb = pcb; - ctx.fast = 1; - ctx.data = pcb->Data; - ctx.lst = lst; - ctx.bloat = bloat; - ctx.shrink = shrink; - ctx.broken_cb = cb; - ctx.cb_data = cb_data; - - memset(&ctx.fa, 0, sizeof(ctx.fa)); - memset(&ctx.fb, 0, sizeof(ctx.fb)); - ctx.fa.user_data = ctx.fb.user_data = &ctx; - ctx.fb.found_cb = pcb_int_broken_cb; - - /* Check for minimal overlap: shrink mark all objects on the net in fa; - restart the search without shrink in fb: if anything new is found, it did - not have enough overlap and shrink disconnected it. */ - if (shrink != 0) { - ctx.shrunk = 1; - Bloat = -shrink; - pcb_find_from_obj(&ctx.fa, pcb->Data, from); - Bloat = 0; - pcb_find_from_obj(&ctx.fb, pcb->Data, from); - pcb_find_free(&ctx.fa); - pcb_find_free(&ctx.fb); - } - - /* Check for minimal distance: bloat mark all objects on the net in fa; - restart the search without bloat in fb: if anything new is found, it did - not have a connection without the bloat. */ - if (bloat != 0) { - ctx.shrunk = 0; - Bloat = 0; - pcb_find_from_obj(&ctx.fa, pcb->Data, from); - Bloat = bloat; - pcb_find_from_obj(&ctx.fb, pcb->Data, from); - pcb_find_free(&ctx.fa); - pcb_find_free(&ctx.fb); - } - - Bloat = 0; - - return pcb_false; -} Index: trunk/src_plugins/drc_orig/drc_net_int.h =================================================================== --- trunk/src_plugins/drc_orig/drc_net_int.h (revision 30180) +++ trunk/src_plugins/drc_orig/drc_net_int.h (nonexistent) @@ -1,28 +0,0 @@ -#include "view.h" -#include "obj_common.h" - -typedef struct pcb_net_int_s pcb_net_int_t; -typedef int (pcb_int_broken_cb_t)(pcb_net_int_t *ctx, pcb_any_obj_t *new_obj, pcb_any_obj_t *arrived_from, pcb_found_conn_type_t ctype); - -struct pcb_net_int_s { - pcb_board_t *pcb; - pcb_find_t fa, fb; - pcb_data_t *data; - pcb_view_list_t *lst; - pcb_coord_t bloat, shrink; - unsigned fast:1; - unsigned shrunk:1; - - /* called on integrity check failure: either broken trace (shrunk==1) or - short circuit (shrunk==0); like 'find' callback; return - non-zero to break the search */ - pcb_int_broken_cb_t *broken_cb; - void *cb_data; -}; - - -/* Check for DRC violations on a single net starting from the pad or pin - sees if the connectivity changes when everything is bloated, or shrunk. - If shrink or bloat is 0, that side of the test is skipped */ -pcb_bool pcb_net_integrity(pcb_board_t *pcb, pcb_view_list_t *lst, pcb_any_obj_t *from, pcb_coord_t shrink, pcb_coord_t bloat, pcb_int_broken_cb_t *cb, void *cb_data); - Index: trunk/src_plugins/drc_orig/Plug.tmpasm =================================================================== --- trunk/src_plugins/drc_orig/Plug.tmpasm (revision 30180) +++ trunk/src_plugins/drc_orig/Plug.tmpasm (revision 30181) @@ -1,7 +1,6 @@ put /local/pcb/mod {drc_orig} put /local/pcb/mod/OBJS [@ $(PLUGDIR)/drc_orig/drc_orig.o - $(PLUGDIR)/drc_orig/drc_net_int.o @] switch /local/pcb/drc_orig/controls Index: trunk/src_plugins/drc_orig/drc_orig.c =================================================================== --- trunk/src_plugins/drc_orig/drc_orig.c (revision 30180) +++ trunk/src_plugins/drc_orig/drc_orig.c (revision 30181) @@ -48,7 +48,7 @@ #include "obj_subc_list.h" -#include "drc_net_int.h" +#include "../src_plugins/query/net_int.h" static const char *drc_orig_cookie = "drc_orig"; @@ -115,7 +115,7 @@ } /* announce shorted or broken net */ -static int drc_broken_cb(drc_ctx_t *ctx, pcb_any_obj_t *new_obj, pcb_any_obj_t *arrived_from, pcb_found_conn_type_t ctype) +static int drc_broken_cb(pcb_net_int_t *ctx, pcb_any_obj_t *new_obj, pcb_any_obj_t *arrived_from, pcb_found_conn_type_t ctype) { pcb_view_t *violation; Index: trunk/src_plugins/drc_orig/drc_orig.pup =================================================================== --- trunk/src_plugins/drc_orig/drc_orig.pup (revision 30180) +++ trunk/src_plugins/drc_orig/drc_orig.pup (revision 30181) @@ -3,4 +3,5 @@ $long A few simple, hardwired Design Rule Checks. $package (core) default buildin +dep query autoload 1 Index: trunk/src_plugins/drc_query/drc_query.pup =================================================================== --- trunk/src_plugins/drc_query/drc_query.pup (revision 30180) +++ trunk/src_plugins/drc_query/drc_query.pup (revision 30181) @@ -3,4 +3,5 @@ $long Scriptable DRC based on query() $package (core) default buildin +dep query autoload 1 Index: trunk/src_plugins/query/Plug.tmpasm =================================================================== --- trunk/src_plugins/query/Plug.tmpasm (revision 30180) +++ trunk/src_plugins/query/Plug.tmpasm (revision 30181) @@ -7,6 +7,7 @@ $(PLUGDIR)/query/query_l.o $(PLUGDIR)/query/query_y.o $(PLUGDIR)/query/fnc.o + $(PLUGDIR)/query/net_int.o $(PLUGDIR)/query/fields_sphash.o @] put /local/pcb/mod/YACC {$(PLUGDIR)/query/query_y} Index: trunk/src_plugins/query/net_int.c =================================================================== --- trunk/src_plugins/query/net_int.c (nonexistent) +++ trunk/src_plugins/query/net_int.c (revision 30181) @@ -0,0 +1,112 @@ +/* + * + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * (this file is based on PCB, interactive printed circuit board design) + * Copyright (C) 2018,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 St, 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") + * + */ + +#include "config.h" + +#include "board.h" +#include "find.h" +#include "net_int.h" + +TODO("remove:") +#include "drc.h" + +#define PCB dontuse + +TODO("find: get rid of this global state") +extern pcb_coord_t Bloat; + + +/* evaluates to true if obj was marked on list (fa or fb) */ +#define IS_FOUND(obj, list) (PCB_DFLAG_TEST(&(obj->Flags), ctx->list.mark)) + +static int pcb_int_broken_cb(pcb_find_t *fctx, pcb_any_obj_t *new_obj, pcb_any_obj_t *arrived_from, pcb_found_conn_type_t ctype) +{ + pcb_net_int_t *ctx = fctx->user_data; + + if (arrived_from == NULL) /* ingore the starting object - it must be marked as we started from the same object in the first search */ + return 0; + + /* broken if new object is not marked in the shrunk search (fa) but + the arrived_from object was marked (so we notify direct breaks only) */ + if (!IS_FOUND(new_obj, fa) && IS_FOUND(arrived_from, fa)) { + int r = ctx->broken_cb(ctx, new_obj, arrived_from, ctype); + if (r != 0) return r; + return ctx->fast; /* if fast is 1, we are aborting the search, returning the first hit only */ + } + return 0; +} + +pcb_bool pcb_net_integrity(pcb_board_t *pcb, pcb_view_list_t *lst, pcb_any_obj_t *from, pcb_coord_t shrink, pcb_coord_t bloat, pcb_int_broken_cb_t *cb, void *cb_data) +{ + pcb_net_int_t ctx; + + ctx.pcb = pcb; + ctx.fast = 1; + ctx.data = pcb->Data; + ctx.lst = lst; + ctx.bloat = bloat; + ctx.shrink = shrink; + ctx.broken_cb = cb; + ctx.cb_data = cb_data; + + memset(&ctx.fa, 0, sizeof(ctx.fa)); + memset(&ctx.fb, 0, sizeof(ctx.fb)); + ctx.fa.user_data = ctx.fb.user_data = &ctx; + ctx.fb.found_cb = pcb_int_broken_cb; + + /* Check for minimal overlap: shrink mark all objects on the net in fa; + restart the search without shrink in fb: if anything new is found, it did + not have enough overlap and shrink disconnected it. */ + if (shrink != 0) { + ctx.shrunk = 1; + Bloat = -shrink; + pcb_find_from_obj(&ctx.fa, pcb->Data, from); + Bloat = 0; + pcb_find_from_obj(&ctx.fb, pcb->Data, from); + pcb_find_free(&ctx.fa); + pcb_find_free(&ctx.fb); + } + + /* Check for minimal distance: bloat mark all objects on the net in fa; + restart the search without bloat in fb: if anything new is found, it did + not have a connection without the bloat. */ + if (bloat != 0) { + ctx.shrunk = 0; + Bloat = 0; + pcb_find_from_obj(&ctx.fa, pcb->Data, from); + Bloat = bloat; + pcb_find_from_obj(&ctx.fb, pcb->Data, from); + pcb_find_free(&ctx.fa); + pcb_find_free(&ctx.fb); + } + + Bloat = 0; + + return pcb_false; +} Index: trunk/src_plugins/query/net_int.h =================================================================== --- trunk/src_plugins/query/net_int.h (nonexistent) +++ trunk/src_plugins/query/net_int.h (revision 30181) @@ -0,0 +1,28 @@ +#include "view.h" +#include "obj_common.h" + +typedef struct pcb_net_int_s pcb_net_int_t; +typedef int (pcb_int_broken_cb_t)(pcb_net_int_t *ctx, pcb_any_obj_t *new_obj, pcb_any_obj_t *arrived_from, pcb_found_conn_type_t ctype); + +struct pcb_net_int_s { + pcb_board_t *pcb; + pcb_find_t fa, fb; + pcb_data_t *data; + pcb_view_list_t *lst; + pcb_coord_t bloat, shrink; + unsigned fast:1; + unsigned shrunk:1; + + /* called on integrity check failure: either broken trace (shrunk==1) or + short circuit (shrunk==0); like 'find' callback; return + non-zero to break the search */ + pcb_int_broken_cb_t *broken_cb; + void *cb_data; +}; + + +/* Check for DRC violations on a single net starting from the pad or pin + sees if the connectivity changes when everything is bloated, or shrunk. + If shrink or bloat is 0, that side of the test is skipped */ +pcb_bool pcb_net_integrity(pcb_board_t *pcb, pcb_view_list_t *lst, pcb_any_obj_t *from, pcb_coord_t shrink, pcb_coord_t bloat, pcb_int_broken_cb_t *cb, void *cb_data); +