Index: Makefile =================================================================== --- Makefile (nonexistent) +++ Makefile (revision 3883) @@ -0,0 +1,5 @@ +all: + cd ../../src && make mod_distalign + +clean: + rm *.o *.so 2>/dev/null ; true Index: Plug.tmpasm =================================================================== --- Plug.tmpasm (nonexistent) +++ Plug.tmpasm (revision 3883) @@ -0,0 +1,8 @@ +put /local/pcb/mod {distalign} +put /local/pcb/mod/OBJS [@ $(PLUGDIR)/distalign/distalign.o @] + +switch /local/pcb/distalign/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: README =================================================================== --- README (nonexistent) +++ README (revision 3883) @@ -0,0 +1,8 @@ +Introducing Align() and Distribute(), which work much like the similarly +named functions in Visio. Given that PCB does not have the concept of +"first selected object" to draw on, the reference points can be selected +by arguments. + +#state: works +#default: buildin +#implements: (feature) Index: distalign.c =================================================================== --- distalign.c (revision 3882) +++ distalign.c (revision 3883) @@ -9,6 +9,8 @@ * \copyright Licensed under the terms of the GNU General Public * License, version 2 or later. * + * Ported to pcb-rnd by Tibor 'Igor2' Palinkas in 2016. + * * From: Ben Jackson * To: geda-user@moria.seul.org * Date: Sat, 24 Feb 2007 22:13:51 -0800 @@ -113,6 +115,8 @@ #include "move.h" #include "draw.h" #include "set.h" +#include "plugins.h" +#include "hid_actions.h" #define ARG(n) (argc > (n) ? argv[n] : 0) @@ -143,20 +147,20 @@ }; static const char *keywords[] = { - [K_X] "X", - [K_Y] "Y", - [K_Lefts] "Lefts", - [K_Rights] "Rights", - [K_Tops] "Tops", - [K_Bottoms] "Bottoms", - [K_Centers] "Centers", - [K_Marks] "Marks", - [K_Gaps] "Gaps", - [K_First] "First", - [K_Last] "Last", - [K_Average] "Average", - [K_Crosshair] "Crosshair", - [K_Gridless] "Gridless", + /*[K_X] */ "X", + /*[K_Y] */ "Y", + /*[K_Lefts] */ "Lefts", + /*[K_Rights] */ "Rights", + /*[K_Tops] */ "Tops", + /*[K_Bottoms] */ "Bottoms", + /*[K_Centers] */ "Centers", + /*[K_Marks] */ "Marks", + /*[K_Gaps] */ "Gaps", + /*[K_First] */ "First", + /*[K_Last] */ "Last", + /*[K_Average] */ "Average", + /*[K_Crosshair] */ "Crosshair", + /*[K_Gridless] */ "Gridless", }; static int keyword(const char *s) @@ -245,7 +249,7 @@ dir = dir == K_X ? K_Y : K_X; /* see above */ ELEMENT_LOOP(PCB->Data); { - if (!TEST_FLAG(SELECTEDFLAG, element)) + if (!TEST_FLAG(PCB_FLAG_SELECTED, element)) continue; nsel++; } @@ -257,7 +261,7 @@ nsel = 0; ELEMENT_LOOP(PCB->Data); { - if (!TEST_FLAG(SELECTEDFLAG, element)) + if (!TEST_FLAG(PCB_FLAG_SELECTED, element)) continue; elements_by_pos[nsel].element = element; elements_by_pos[nsel++].pos = coord(element, dir, point); @@ -298,7 +302,7 @@ q = 0; ELEMENT_LOOP(PCB->Data); { - if (!TEST_FLAG(SELECTEDFLAG, element)) + if (!TEST_FLAG(PCB_FLAG_SELECTED, element)) continue; q += coord(element, dir, point); nsel++; @@ -340,7 +344,7 @@ * * Defaults are Marks, First. */ -static int align(int argc, char **argv, Coord x, Coord y) +static int align(int argc, const char **argv, Coord x, Coord y) { int dir; int point; @@ -414,7 +418,7 @@ { Coord p, dp, dx, dy; - if (!TEST_FLAG(SELECTEDFLAG, element)) + if (!TEST_FLAG(PCB_FLAG_SELECTED, element)) continue; /* find delta from reference point to reference point */ p = coord(element, dir, point); @@ -431,7 +435,7 @@ else dx = 0; MoveElementLowLevel(PCB->Data, element, dx, dy); - AddObjectToMoveUndoList(ELEMENT_TYPE, NULL, NULL, element, dx, dy); + AddObjectToMoveUndoList(PCB_TYPE_ELEMENT, NULL, NULL, element, dx, dy); changed = 1; } } @@ -461,7 +465,7 @@ * Distributed elements always retain the same relative order they had * before they were distributed. \n */ -static int distribute(int argc, char **argv, Coord x, Coord y) +static int distribute(int argc, const char **argv, Coord x, Coord y) { int dir; int point; @@ -596,7 +600,7 @@ else dx = 0; MoveElementLowLevel(PCB->Data, element, dx, dy); - AddObjectToMoveUndoList(ELEMENT_TYPE, NULL, NULL, element, dx, dy); + AddObjectToMoveUndoList(PCB_TYPE_ELEMENT, NULL, NULL, element, dx, dy); changed = 1; } /* in gaps mode, accumulate part widths */ @@ -622,9 +626,20 @@ {"align", NULL, align, "Align Elements", align_syntax} }; -REGISTER_ACTIONS(distalign_action_list) +static char *distalign_cookie = "distalign plugin"; -void hid_distalign_init() +REGISTER_ACTIONS(distalign_action_list, distalign_cookie) + +static void hid_distalign_uninit(void) { - register_distalign_action_list(); + hid_remove_actions_by_cookie(distalign_cookie); } + +#include "dolists.h" +pcb_uninit_t hid_distalign_init() +{ + REGISTER_ACTIONS(distalign_action_list, distalign_cookie); + return hid_distalign_uninit; +} + +