Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 32945) +++ trunk/scconfig/Rev.h (revision 32946) @@ -1 +1 @@ -static const int myrev = 32934; +static const int myrev = 32946; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 32945) +++ trunk/scconfig/Rev.tab (revision 32946) @@ -1,3 +1,4 @@ +32946 configure new plugin: ch_editpoint draw edit points of objects 32934 configure moving onpoint from core to plugin 32857 configure menu item for import_ttf 32739 configure export_test plugin removed in favor of the loghid plugin Index: trunk/scconfig/plugins.h =================================================================== --- trunk/scconfig/plugins.h (revision 32945) +++ trunk/scconfig/plugins.h (revision 32946) @@ -28,6 +28,7 @@ plugin_def("autocrop", "crop board to fit objects", sbuildin, 1, 0) plugin_def("autoplace", "auto place components", sbuildin, 1, 0) plugin_def("autoroute", "the original autorouter", sbuildin, 1, 0) +plugin_def("ch_editpoint", "crosshair: on-point highlight", sbuildin, 1, 0) plugin_def("ch_onpoint", "crosshair: on-point highlight", sbuildin, 1, 0) plugin_def("diag", "diagnostic acts. for devs", sdisable, 1, 0) plugin_def("dialogs", "HID-independent GUI dialogs", sdisable, 1, 0) Index: trunk/src/obj_common.h =================================================================== --- trunk/src/obj_common.h (revision 32945) +++ trunk/src/obj_common.h (revision 32946) @@ -224,6 +224,7 @@ pcb_parent_t parent; \ rnd_box_t bbox_naked; \ unsigned ind_onpoint:1; \ + unsigned ind_editpoint:1; \ pcb_attribute_list_t Attributes \ #define PCB_ANY_PRIMITIVE_FIELDS \ Index: trunk/src_plugins/ch_editpoint/Makefile =================================================================== --- trunk/src_plugins/ch_editpoint/Makefile (nonexistent) +++ trunk/src_plugins/ch_editpoint/Makefile (revision 32946) @@ -0,0 +1,5 @@ +all: + cd ../../src && $(MAKE) mod_ch_editpoint + +clean: + rm *.o *.so 2>/dev/null ; true Index: trunk/src_plugins/ch_editpoint/Plug.tmpasm =================================================================== --- trunk/src_plugins/ch_editpoint/Plug.tmpasm (nonexistent) +++ trunk/src_plugins/ch_editpoint/Plug.tmpasm (revision 32946) @@ -0,0 +1,11 @@ +put /local/pcb/mod {ch_editpoint} +put /local/pcb/mod/OBJS [@ + $(PLUGDIR)/ch_editpoint/ch_editpoint.o +@] + + +switch /local/pcb/ch_editpoint/controls + case {buildin} include /local/pcb/tmpasm/buildin; end; + case {plugin} include /local/pcb/tmpasm/plugin; end; + case {disable} include /local/pcb/tmpasm/disable; end; +end Index: trunk/src_plugins/ch_editpoint/ch_editpoint.c =================================================================== --- trunk/src_plugins/ch_editpoint/ch_editpoint.c (nonexistent) +++ trunk/src_plugins/ch_editpoint/ch_editpoint.c (revision 32946) @@ -0,0 +1,152 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * + * crosshair: display edit points of the objects that are under the cursor + * pcb-rnd 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") + */ + +/* Draw the editpoints of objects which are under the crosshair */ + +#include "config.h" + +#include + +#include +#include +#include +#include +#include "board.h" +#include "conf_core.h" +#include "crosshair.h" +#include "data.h" +#include "draw.h" +#include "event.h" + + +static const char pcb_ch_editpoint_cookie[] = "ch_editpoint plugin"; + +static vtp0_t editpoint_raw[2]; +static vtp0_t *editpoint_objs = &editpoint_raw[0], *old_editpoint_objs = &editpoint_raw[1]; + +static rnd_r_dir_t editpoint_callback(const rnd_box_t *box, void *cl) +{ + pcb_any_obj_t *obj = (pcb_any_obj_t *)box; + + vtp0_append(editpoint_objs, obj); + obj->ind_editpoint = 1; + return RND_R_DIR_FOUND_CONTINUE; +} + +static void *editpoint_find(vtp0_t *vect, pcb_any_obj_t *obj_ptr) +{ + int n; + + for(n = 0; n < vect->used; n++) { + pcb_any_obj_t *op = vect->array[n]; + if (op == obj_ptr) + return op; + } + return NULL; +} + +/* Searches for lines/arcs which have points that are exactly at the given coords + and adds them to the object list along with their respective type. */ +static void editpoint_work(pcb_crosshair_t *crosshair, rnd_coord_t X, rnd_coord_t Y) +{ + rnd_box_t SearchBox = rnd_point_box(X, Y); + int n; + rnd_bool redraw = rnd_false; + vtp0_t *tmp; + + /* swap old and new */ + tmp = editpoint_objs; + editpoint_objs = old_editpoint_objs; + old_editpoint_objs = tmp; + + /* Do not truncate to 0 because that may free the array */ + vtp0_truncate(editpoint_objs, 1); + editpoint_objs->used = 0; + + for(n = 0; n < pcb_max_layer(PCB); n++) { + pcb_layer_t *layer = &PCB->Data->Layer[n]; + /* Only find points of arcs and lines on currently visible layers. */ + if (!layer->meta.real.vis) + continue; + rnd_r_search(layer->line_tree, &SearchBox, NULL, editpoint_callback, NULL, NULL); + rnd_r_search(layer->arc_tree, &SearchBox, NULL, editpoint_callback, NULL, NULL); + rnd_r_search(layer->polygon_tree, &SearchBox, NULL, editpoint_callback, NULL, NULL); + } + + /* Undraw the old objects */ + for(n = 0; n < old_editpoint_objs->used; n++) { + pcb_any_obj_t *op = old_editpoint_objs->array[n]; + + /* only remove and redraw those which aren't in the new list */ + if (editpoint_find(editpoint_objs, op) != NULL) + continue; + + op->ind_editpoint = 0; + pcb_draw_obj(op); + redraw = rnd_true; + } + + /* draw the new objects */ + for(n = 0; n < editpoint_objs->used; n++) { + pcb_any_obj_t *op = editpoint_objs->array[n]; + + /* only draw those which aren't in the old list */ + if (editpoint_find(old_editpoint_objs, op) != NULL) + continue; + pcb_draw_obj(op); + redraw = rnd_true; + } + + if (redraw) + rnd_hid_redraw(PCB); +} + +static void pcb_ch_editpoint(rnd_hidlib_t *hidlib, void *user_data, int argc, rnd_event_arg_t argv[]) +{ + pcb_crosshair_t *ch = argv[1].d.p; + if (conf_core.editor.highlight_on_point) + editpoint_work(ch, ch->X, ch->Y); +} + +int pplg_check_ver_ch_editpoint(int ver_needed) { return 0; } + +void pplg_uninit_ch_editpoint(void) +{ + rnd_event_unbind_allcookie(pcb_ch_editpoint_cookie); + vtp0_uninit(editpoint_objs); + vtp0_uninit(old_editpoint_objs); +} + +int pplg_init_ch_editpoint(void) +{ + RND_API_CHK_VER; + + rnd_event_bind(PCB_EVENT_CROSSHAIR_NEW_POS, pcb_ch_editpoint, NULL, pcb_ch_editpoint_cookie); + + return 0; +} Index: trunk/src_plugins/ch_editpoint/ch_editpoint.pup =================================================================== --- trunk/src_plugins/ch_editpoint/ch_editpoint.pup (nonexistent) +++ trunk/src_plugins/ch_editpoint/ch_editpoint.pup (revision 32946) @@ -0,0 +1,8 @@ +$class feature +$short crosshair: on-point highlight +$long crosshair: highlight object upon crosshair on edit point +$state works +$package core +default buildin +autoload 1 + Index: trunk/src_plugins/plugins_ALL.tmpasm =================================================================== --- trunk/src_plugins/plugins_ALL.tmpasm (revision 32945) +++ trunk/src_plugins/plugins_ALL.tmpasm (revision 32946) @@ -23,6 +23,7 @@ include {../src_plugins/autoplace/Plug.tmpasm} include {../src_plugins/autoroute/Plug.tmpasm} include {../src_plugins/cam/Plug.tmpasm} +include {../src_plugins/ch_editpoint/Plug.tmpasm} include {../src_plugins/ch_onpoint/Plug.tmpasm} include {../src_plugins/ddraft/Plug.tmpasm} include {../src_plugins/diag/Plug.tmpasm}