Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 38816) +++ trunk/scconfig/Rev.h (revision 38817) @@ -1 +1 @@ -static const int myrev = 38810; +static const int myrev = 38817; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 38816) +++ trunk/scconfig/Rev.tab (revision 38817) @@ -1,4 +1,4 @@ -38810 configure new experimental plugin: rubber band stretch router +38817 configure new experimental plugin: rubber band stretch router 38523 configure require librnd >=4.1.0 and enable font2 38351 configure font mode: preview dialog 38025 configure export_bom2: new bom plugin with templates Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 38816) +++ trunk/src/Makefile.dep (revision 38817) @@ -2376,12 +2376,29 @@ ../src_plugins/query/query.h ../src_plugins/query/fields_sphash.h \ obj_common.h flag_str.h ../src_3rd/libgrbs/grbs.h \ ../src_3rd/libgrbs/rtree.h ../src_plugins/rbs_routing/stretch.h \ - ../src_3rd/libgrbs/snapshot.h ../src_plugins/rbs_routing/seq.h \ + ../src_3rd/libgrbs/snapshot.h ../src_plugins/rbs_routing/tool_seq.h \ ../src_plugins/rbs_routing/map.c ../src_3rd/libgrbs/route.h \ ../src_3rd/libgrbs/debug.h ../src_3rd/libgrbs/geo.h obj_pstk_inlines.h \ data.h thermal.h operation.h layer_ui.h draw.h draw_wireframe.h \ - ../src_plugins/rbs_routing/stretch.c remove.h \ - ../src_plugins/rbs_routing/seq.c + ../src_plugins/rbs_routing/stretch.c remove.h +../src_plugins/rbs_routing/tool_seq.o: \ + ../src_plugins/rbs_routing/tool_seq.c ../config.h conf_core.h \ + globalconst.h board.h vtroutestyle.h attrib.h global_typedefs.h layer.h \ + obj_common.h flag.h data_parent.h obj_arc_list.h obj_arc.h \ + obj_line_list.h obj_line.h obj_poly_list.h obj_poly.h obj_text_list.h \ + obj_text.h font.h obj_gfx_list.h obj_gfx.h layer_grp.h rats_patch.h \ + board.h crosshair.h route.h data.h crosshair.h buffer.h obj_rat_list.h \ + obj_rat.h idpath.h obj_subc_list.h obj_subc.h \ + ../src_3rd/libminuid/libminuid.h ht_subc.h obj_pstk_list.h obj_pstk.h \ + vtpadstack.h obj_pstk_shape.h polygon.h vtpadstack_t.h draw.h \ + draw_wireframe.h tool_logic.h ../src_plugins/rbs_routing/map.h layer.h \ + ../src_plugins/lib_netmap/map_2nets.h obj_rat.h obj_poly.h obj_pstk.h \ + ../src_plugins/query/net_len.h ../src_plugins/query/query_exec.h \ + ../src_plugins/query/query.h ../src_plugins/query/fields_sphash.h \ + obj_common.h flag_str.h ../src_3rd/libgrbs/grbs.h \ + ../src_3rd/libgrbs/rtree.h ../src_plugins/rbs_routing/seq.h \ + ../src_3rd/libgrbs/snapshot.h ../src_plugins/rbs_routing/seq.c \ + ../src_plugins/rbs_routing/tool_seq.h ../src_plugins/renumber/renumber.o: ../src_plugins/renumber/renumber.c \ ../config.h board.h vtroutestyle.h attrib.h global_typedefs.h layer.h \ globalconst.h obj_common.h flag.h data_parent.h obj_arc_list.h obj_arc.h \ Index: trunk/src_plugins/rbs_routing/Plug.tmpasm =================================================================== --- trunk/src_plugins/rbs_routing/Plug.tmpasm (revision 38816) +++ trunk/src_plugins/rbs_routing/Plug.tmpasm (revision 38817) @@ -3,6 +3,7 @@ put /local/rnd/mod/MENUVAR {rbs_routing_menu} append /local/rnd/mod/OBJS [@ $(PLUGDIR)/rbs_routing/rbs_routing.o + $(PLUGDIR)/rbs_routing/tool_seq.o $(SRC_3RD_DIR)/libgrbs/grbs.o $(SRC_3RD_DIR)/libgrbs/debug.o $(SRC_3RD_DIR)/libgrbs/addr_hash.o Index: trunk/src_plugins/rbs_routing/map.c =================================================================== --- trunk/src_plugins/rbs_routing/map.c (revision 38816) +++ trunk/src_plugins/rbs_routing/map.c (revision 38817) @@ -193,7 +193,7 @@ #define FIND_PT_DELTA 2 #define FIND_PT_DELTA2 RBSR_R2G(FIND_PT_DELTA * FIND_PT_DELTA) -RND_INLINE grbs_point_t *rbsr_find_point_by_center(rbsr_map_t *rbs, rnd_coord_t cx_, rnd_coord_t cy_) +grbs_point_t *rbsr_find_point_by_center(rbsr_map_t *rbs, rnd_coord_t cx_, rnd_coord_t cy_) { double cx = RBSR_R2G(cx_), cy = RBSR_R2G(cy_), bestd2 = FIND_PT_DELTA2+1; grbs_point_t *pt, *best= NULL; Index: trunk/src_plugins/rbs_routing/map.h =================================================================== --- trunk/src_plugins/rbs_routing/map.h (revision 38816) +++ trunk/src_plugins/rbs_routing/map.h (revision 38817) @@ -41,5 +41,5 @@ /*** utility ***/ /* Return the point that's close enough to cx;cy or NULL if nothing is close */ -RND_INLINE grbs_point_t *rbsr_find_point_by_center(rbsr_map_t *rbs, rnd_coord_t cx, rnd_coord_t cy); +grbs_point_t *rbsr_find_point_by_center(rbsr_map_t *rbs, rnd_coord_t cx, rnd_coord_t cy); Index: trunk/src_plugins/rbs_routing/rbs_routing.c =================================================================== --- trunk/src_plugins/rbs_routing/rbs_routing.c (revision 38816) +++ trunk/src_plugins/rbs_routing/rbs_routing.c (revision 38817) @@ -38,11 +38,10 @@ #include "map.h" #include "stretch.h" -#include "seq.h" +#include "tool_seq.h" #include "map.c" #include "stretch.c" -#include "seq.c" static const char pcb_acts_RbsConnect[] = "RbsConnect()"; static const char pcb_acth_RbsConnect[] = "Make a new rubber band stretch connection between two points"; @@ -116,11 +115,13 @@ { rnd_remove_actions_by_cookie(rbs_routing_cookie); rnd_hid_menu_unload(rnd_gui, rbs_routing_cookie); + rnd_tool_unreg_by_cookie(rbs_routing_cookie); } int pplg_init_rbs_routing(void) { RND_API_CHK_VER; + rnd_tool_reg(&pcb_tool_seq, rbs_routing_cookie); RND_REGISTER_ACTIONS(rbs_routing_action_list, rbs_routing_cookie) rnd_hid_menu_load(rnd_gui, NULL, rbs_routing_cookie, 175, NULL, 0, rbs_routing_menu, "plugin: rbs_routing"); return 0; Index: trunk/src_plugins/rbs_routing/seq.h =================================================================== --- trunk/src_plugins/rbs_routing/seq.h (revision 38816) +++ trunk/src_plugins/rbs_routing/seq.h (revision 38817) @@ -1,3 +1,11 @@ +/* undo leftover from librnd's own rtree before including grbs' rtree */ +#undef RTR +#undef RTRU +#undef RTREE_NO_TREE_TYPEDEFS + +#include +#include + #define RBSR_SEQ_MAX 256 typedef struct rbsr_seq_s { Index: trunk/src_plugins/rbs_routing/tool_seq.c =================================================================== --- trunk/src_plugins/rbs_routing/tool_seq.c (nonexistent) +++ trunk/src_plugins/rbs_routing/tool_seq.c (revision 38817) @@ -0,0 +1,166 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design - Rubber Band Stretch Router + * Copyright (C) 2024 Tibor 'Igor2' Palinkas + * (Supported by NLnet NGI0 Entrust in 2024) + * + * 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") + */ + +#include "config.h" + +#include "conf_core.h" +#include + +#include "board.h" +#include "crosshair.h" +#include "data.h" +#include "draw.h" +#include "draw_wireframe.h" +#include "tool_logic.h" + +#include "map.h" +#include "seq.h" +#include "seq.c" + +#include "tool_seq.h" + +static pcb_layer_t *last_layer; + +void pcb_tool_seq_init(void) +{ + rnd_hid_notify_crosshair_change(&PCB->hidlib, rnd_false); + /* TODO: tool activated */ + rnd_hid_notify_crosshair_change(&PCB->hidlib, rnd_true); +} + +void pcb_tool_seq_uninit(void) +{ + rnd_hid_notify_crosshair_change(&PCB->hidlib, rnd_false); + /* TODO: do we need this? */ + rnd_hid_notify_crosshair_change(&PCB->hidlib, rnd_true); +} + +/* creates next point of the route */ +static void notify_line(rnd_design_t *hl) +{ + pcb_board_t *pcb = (pcb_board_t *)hl; + + switch (pcb_crosshair.AttachedLine.State) { + case PCB_CH_STATE_FIRST: + if (pcb->RatDraw) + return; /* do not route rats */ + + /* TODO: start routing */ + last_layer = PCB_CURRLAYER(pcb); +/* pcb_crosshair.X, pcb_crosshair.Y + pcb_crosshair.AttachedLine.State = PCB_CH_STATE_SECOND;*/ + break; + + case PCB_CH_STATE_SECOND: + /* TODO: route to next point */ + break; + } +} + +void pcb_tool_seq_notify_mode(rnd_design_t *hl) +{ + /* TODO: consider next */ +/* if (pcb_crosshair.X == pcb_crosshair.AttachedLine.Point1.X && pcb_crosshair.Y == pcb_crosshair.AttachedLine.Point1.Y) { + rnd_tool_select_by_name(hl, "line"); + return; + }*/ +} + +void pcb_tool_seq_adjust_attached_objects(rnd_design_t *hl) +{ + /* TODO: figure if we need this: */ +/* + if (rnd_gui->control_is_pressed(rnd_gui)) { + pcb_crosshair.AttachedLine.draw = rnd_false; + } + else { + pcb_crosshair.AttachedLine.draw = rnd_true; + pcb_line_adjust_attached(); + } +*/ +} + +void pcb_tool_seq_draw_attached(rnd_design_t *hl) +{ + pcb_board_t *pcb = (pcb_board_t *)hl; + + /* TODO: draw attached to pcb_crosshair.X, pcb_crosshair.Y, consider new route point */ +} + +void pcb_tool_seq_escape(rnd_design_t *hl) +{ + rnd_tool_select_by_name(hl, "arrow"); +} + +/* XPM */ +static const char *seq_icon[] = { +/* columns rows colors chars-per-pixel */ +"21 21 4 1", +" c #000000", +". c #7A8584", +"X c #6EA5D7", +"O c None", +/* pixels */ +"OOOOOOOOOOOOOOOOOOOOO", +"OO...OOOOOOOOOOOOOOOO", +"O.OOO.OOOOOOOOOOOOOOO", +"O.OXXXOOOOOOOOOOOOOOO", +"O.OOO.XXXOOOOOOOOOOOO", +"OO...OOOOXXXOOOO...OO", +"OOOOOOOOOOOOXXX.OOO.O", +"OOOOOXOOOOOOOOOXXXO.O", +"OXXXXXXXXOOOOOO.OOO.O", +"OOOOOXOOOOOOOOOO...OO", +"OOOOOXOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOO", +" OOOO O OOOO O O", +" OOOOO OO OOO O OOOO", +" OOOOO OO O OO O OOOO", +" OOOOO OO O OO O OOOO", +" OOOOO OO OO O O OO", +" OOOOO OO OO O O OOOO", +" OOOOO OO OOO O OOOO", +" O O OOOO O O", +"OOOOOOOOOOOOOOOOOOOOO" +}; + + +rnd_tool_t pcb_tool_seq = { + "rbsr_seq", "rubber band stretch route: sequential", + NULL, 1100, seq_icon, RND_TOOL_CURSOR_NAMED("pencil"), 1, + pcb_tool_seq_init, + pcb_tool_seq_uninit, + pcb_tool_seq_notify_mode, + NULL, + pcb_tool_seq_adjust_attached_objects, + pcb_tool_seq_draw_attached, + NULL, /* pcb_tool_seq_undo_act, */ + NULL, /* pcb_tool_seq_redo_act, */ + pcb_tool_seq_escape, + + PCB_TLF_RAT +}; Index: trunk/src_plugins/rbs_routing/tool_seq.h =================================================================== --- trunk/src_plugins/rbs_routing/tool_seq.h (nonexistent) +++ trunk/src_plugins/rbs_routing/tool_seq.h (revision 38817) @@ -0,0 +1,4 @@ +#include + +extern rnd_tool_t pcb_tool_seq; +