Index: trunk/doc-rnd/TODO =================================================================== --- trunk/doc-rnd/TODO (revision 1107) +++ trunk/doc-rnd/TODO (revision 1108) @@ -1,11 +1,11 @@ CLEANUP - write mods.html - - ActionBell() - Makefile.dep vs. plugins - move to plugin: - - libstroke - import_sch.c - warnings in util/ + - scconfig: detect libstroke + - libstroke: zoom BACK ANNOTATION - some netlist thing doesn't work; grep for BA_TODO Index: trunk/scconfig/hooks.c =================================================================== --- trunk/scconfig/hooks.c (revision 1107) +++ trunk/scconfig/hooks.c (revision 1108) @@ -80,6 +80,10 @@ {"buildin-renumber", "/local/pcb/renumber/buildin", arg_true, "$static link the renumber action into the executable"}, {"plugin-renumber", "/local/pcb/renumber/buildin", arg_false, "$the renumber action is dynamic loadable plugin"}, + {"disable-stroke", "/local/pcb/stroke/enable", arg_false, "$do not compile libstroke gestures"}, + {"buildin-stroke", "/local/pcb/stroke/buildin", arg_true, "$static link libstroke gestures into the executable"}, + {"plugin-stroke", "/local/pcb/stroke/buildin", arg_false, "$libstroke gestures is dynamic loadable plugin"}, + {NULL, NULL, NULL, NULL} }; @@ -180,6 +184,10 @@ put("/local/pcb/renumber/enable", strue); put("/local/pcb/renumber/buildin", strue); + db_mkdir("/local/pcb/stroke"); + put("/local/pcb/stroke/enable", strue); + put("/local/pcb/stroke/buildin", strue); + return 0; } @@ -403,7 +411,9 @@ plugin_stat("Mincut: ", "/local/pcb/mincut"); plugin_stat("renumber:", "/local/pcb/renumber"); plugin_stat("old actions:", "/local/pcb/oldactions"); + plugin_stat("stroke:", "/local/pcb/stroke"); + if (manual_config) printf("\n\n * NOTE: you may want to edit config.manual.h (user preferences) *\n"); } Index: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in (revision 1107) +++ trunk/src/Makefile.in (revision 1108) @@ -71,6 +71,7 @@ strflags.o stub_edif.o stub_mincut.o + stub_stroke.o stub_vendor.o thermal.o undo.o @@ -144,6 +145,7 @@ include {../src_plugins/toporouter/Plug.tmpasm} include {../src_plugins/oldactions/Plug.tmpasm} include {../src_plugins/renumber/Plug.tmpasm} +include {../src_plugins/stroke/Plug.tmpasm} append /local/pcb/CFLAGS /target/libs/sul/glib/cflags append /local/pcb/LIBS /target/libs/sul/glib/ldflags Index: trunk/src/action.c =================================================================== --- trunk/src/action.c (revision 1107) +++ trunk/src/action.c (revision 1108) @@ -69,6 +69,7 @@ #include "plugins.h" #include "rats_patch.h" #include "portability.h" +#include "stub_stroke.h" #include #include /* rand() */ @@ -164,123 +165,12 @@ static Cardinal polyIndex = 0; bool saved_mode = false; -#ifdef HAVE_LIBSTROKE -bool mid_stroke = false; -BoxType StrokeBox; -#endif /* --------------------------------------------------------------------------- * some local routines */ static void AdjustAttachedBox(void); -#ifdef HAVE_LIBSTROKE -void FinishStroke(void); -extern void stroke_init(void); -extern void stroke_record(int x, int y); -extern int stroke_trans(char *s); -#endif - -#ifdef HAVE_LIBSTROKE - /* --------------------------------------------------------------------------- - * FinishStroke - try to recognize the stroke sent - */ -void FinishStroke(void) -{ - char msg[255]; - int type; - unsigned long num; - void *ptr1, *ptr2, *ptr3; - - mid_stroke = false; - if (stroke_trans(msg)) { - num = atoi(msg); - switch (num) { - case 456: - if (Settings.Mode == LINE_MODE) { - SetMode(LINE_MODE); - } - break; - case 9874123: - case 74123: - case 987412: - case 8741236: - case 874123: - RotateScreenObject(StrokeBox.X1, StrokeBox.Y1, SWAP_IDENT ? 1 : 3); - break; - case 7896321: - case 786321: - case 789632: - case 896321: - RotateScreenObject(StrokeBox.X1, StrokeBox.Y1, SWAP_IDENT ? 3 : 1); - break; - case 258: - SetMode(LINE_MODE); - break; - case 852: - SetMode(ARROW_MODE); - break; - case 1478963: - ActionUndo(0, NULL, 0, 0); - break; - case 147423: - case 147523: - case 1474123: - Redo(true); - break; - case 148963: - case 147863: - case 147853: - case 145863: - SetMode(VIA_MODE); - break; - case 951: - case 9651: - case 9521: - case 9621: - case 9851: - case 9541: - case 96521: - case 96541: - case 98541: - PCB->Zoom = 1000; /* special zoom extents */ - break; - case 159: - case 1269: - case 1259: - case 1459: - case 1569: - case 1589: - case 12569: - case 12589: - case 14589: - { - Coord x = (StrokeBox.X1 + StrokeBox.X2) / 2; - Coord y = (StrokeBox.Y1 + StrokeBox.Y2) / 2; - double z; - /* XXX: PCB->MaxWidth and PCB->MaxHeight may be the wrong - * divisors below. The old code WAS broken, but this - * replacement has not been tested for correctness. - */ - z = 1 + log(fabs(StrokeBox.X2 - StrokeBox.X1) / PCB->MaxWidth) / log(2.0); - z = MAX(z, 1 + log(fabs(StrokeBox.Y2 - StrokeBox.Y1) / PCB->MaxHeight) / log(2.0)); - PCB->Zoom = z; - - CenterDisplay(x, y); - break; - } - - default: - Message(_("Unknown stroke %s\n"), msg); - break; - } - } - else - gui->beep(); -} -#endif - -/* --------------------------------------------------------------------------- * Clear warning color from pins/pads */ void ClearWarnings() @@ -1268,15 +1158,8 @@ */ void EventMoveCrosshair(int ev_x, int ev_y) { -#ifdef HAVE_LIBSTROKE - if (mid_stroke) { - StrokeBox.X2 = ev_x; - StrokeBox.Y2 = ev_y; - fprintf(stderr, "stroke: %d %d\n", ev_x >> 16, ev_y >> 16); - stroke_record(ev_x >> 16, ev_y >> 16); - return; - } -#endif /* HAVE_LIBSTROKE */ + if (mid_stroke) + stub_stroke_record(ev_x, ev_y); if (MoveCrosshairAbsolute(ev_x, ev_y)) { /* update object position and cursor location */ AdjustAttachedObjects(); Index: trunk/src/gui_act.c =================================================================== --- trunk/src/gui_act.c (revision 1107) +++ trunk/src/gui_act.c (revision 1108) @@ -38,6 +38,7 @@ #include "find.h" #include "set.h" #include "misc.h" +#include "stub_stroke.h" /* --------------------------------------------------------------------------- */ @@ -713,7 +714,7 @@ break; case F_Release: if ((mid_stroke) && (Settings.EnableStroke)) - FinishStroke(); + stub_stroke_finish(); else ReleaseMode(); break; @@ -728,10 +729,7 @@ break; case F_Stroke: if (Settings.EnableStroke) { - fprintf(stderr, "stroke: MIID!\n"); - mid_stroke = true; - StrokeBox.X1 = Crosshair.X; - StrokeBox.Y1 = Crosshair.Y; + stub_stroke_start(); break; } /* Handle middle mouse button restarts of drawing mode. If not in Index: trunk/src/main.c =================================================================== --- trunk/src/main.c (revision 1107) +++ trunk/src/main.c (revision 1108) @@ -1748,10 +1748,6 @@ if (!ReadLibraryContents() && Library.MenuN) hid_action("LibraryChanged"); -#ifdef HAVE_LIBSTROKE - stroke_init(); -#endif - if (Settings.ScriptFilename) { Message(_("Executing startup script file %s\n"), Settings.ScriptFilename); hid_actionl("ExecuteFile", Settings.ScriptFilename, NULL); Index: trunk/src/stub_stroke.c =================================================================== --- trunk/src/stub_stroke.c (nonexistent) +++ trunk/src/stub_stroke.c (revision 1108) @@ -0,0 +1,38 @@ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 2016 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +#include +#include "error.h" + +bool mid_stroke = false; + +static void stub_stroke_record_dummy(int ev_x, int ev_y) +{ +} + +static void stub_stroke_start_dummy(void) +{ + Message("Can not use libstroke: not compiled as a buildin and not loaded as a plugin\n"); +} + +void (*stub_stroke_record)(int ev_x, int ev_y) = stub_stroke_record_dummy; +void (*stub_stroke_start)(void) = stub_stroke_start_dummy; +void (*stub_stroke_finish)(void) = stub_stroke_start_dummy; Index: trunk/src/stub_stroke.h =================================================================== --- trunk/src/stub_stroke.h (nonexistent) +++ trunk/src/stub_stroke.h (revision 1108) @@ -0,0 +1,26 @@ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 2016 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +extern bool mid_stroke; +extern void (*stub_stroke_record)(int ev_x, int ev_y); +extern void (*stub_stroke_start)(void); +extern void (*stub_stroke_finish)(void); Index: trunk/src_plugins/stroke/Makefile =================================================================== --- trunk/src_plugins/stroke/Makefile (nonexistent) +++ trunk/src_plugins/stroke/Makefile (revision 1108) @@ -0,0 +1,5 @@ +all: + cd ../../src && make mod_stroke + +clean: + rm *.o *.so 2>/dev/null ; true Index: trunk/src_plugins/stroke/Plug.tmpasm =================================================================== --- trunk/src_plugins/stroke/Plug.tmpasm (nonexistent) +++ trunk/src_plugins/stroke/Plug.tmpasm (revision 1108) @@ -0,0 +1,17 @@ +append /local/pcb/stroke/enable {} +append /local/pcb/stroke/buildin {} +append /local/pcb/LDFLAGS {-lstroke} + +put /local/pcb/mod {stroke} +put /local/pcb/mod/OBJS [@ $(PLUGDIR)/stroke/stroke.o @] + +if /local/pcb/stroke/enable then + if /local/pcb/stroke/buildin then + include {Makefile.in.mod/Buildin} + else + include {Makefile.in.mod/Plugin} + end +end + + + Index: trunk/src_plugins/stroke/stroke.c =================================================================== --- trunk/src_plugins/stroke/stroke.c (nonexistent) +++ trunk/src_plugins/stroke/stroke.c (revision 1108) @@ -0,0 +1,168 @@ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton + * + * 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 addresses for paper mail and Email: + * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA + * haceaton@aplcomm.jhuapl.edu + * + */ + +#include "config.h" +#include "global.h" +#include "data.h" +#include "crosshair.h" +#include "stub_stroke.h" +#include "rotate.h" +#include "undo.h" +#include "set.h" +#include "error.h" +#include "misc.h" + +void FinishStroke(void); +extern void stroke_init(void); +extern void stroke_record(int x, int y); +extern int stroke_trans(char *s); + +BoxType StrokeBox; + +/* --------------------------------------------------------------------------- + * FinishStroke - try to recognize the stroke sent + */ +static void real_stroke_finish(void) +{ + char msg[255]; + int type; + unsigned long num; + void *ptr1, *ptr2, *ptr3; + + mid_stroke = false; + if (stroke_trans(msg)) { + num = atoi(msg); + switch (num) { + case 456: + if (Settings.Mode == LINE_MODE) { + SetMode(LINE_MODE); + } + break; + case 9874123: + case 74123: + case 987412: + case 8741236: + case 874123: + RotateScreenObject(StrokeBox.X1, StrokeBox.Y1, SWAP_IDENT ? 1 : 3); + break; + case 7896321: + case 786321: + case 789632: + case 896321: + RotateScreenObject(StrokeBox.X1, StrokeBox.Y1, SWAP_IDENT ? 3 : 1); + break; + case 258: + SetMode(LINE_MODE); + break; + case 852: + SetMode(ARROW_MODE); + break; + case 1478963: + ActionUndo(0, NULL, 0, 0); + break; + case 147423: + case 147523: + case 1474123: + Redo(true); + break; + case 148963: + case 147863: + case 147853: + case 145863: + SetMode(VIA_MODE); + break; + case 951: + case 9651: + case 9521: + case 9621: + case 9851: + case 9541: + case 96521: + case 96541: + case 98541: + PCB->Zoom = 1000; /* special zoom extents */ + break; + case 159: + case 1269: + case 1259: + case 1459: + case 1569: + case 1589: + case 12569: + case 12589: + case 14589: + { + Coord x = (StrokeBox.X1 + StrokeBox.X2) / 2; + Coord y = (StrokeBox.Y1 + StrokeBox.Y2) / 2; + double z; + /* XXX: PCB->MaxWidth and PCB->MaxHeight may be the wrong + * divisors below. The old code WAS broken, but this + * replacement has not been tested for correctness. + */ + z = 1 + log(fabs(StrokeBox.X2 - StrokeBox.X1) / PCB->MaxWidth) / log(2.0); + z = MAX(z, 1 + log(fabs(StrokeBox.Y2 - StrokeBox.Y1) / PCB->MaxHeight) / log(2.0)); + PCB->Zoom = z; + + CenterDisplay(x, y); + break; + } + + default: + Message(_("Unknown stroke %s\n"), msg); + break; + } + } + else + gui->beep(); +} + +static void real_stroke_record(int ev_x, int ev_y) +{ + StrokeBox.X2 = ev_x; + StrokeBox.Y2 = ev_y; + fprintf(stderr, "stroke: %d %d\n", ev_x >> 16, ev_y >> 16); + stroke_record(ev_x >> 16, ev_y >> 16); + return; +} + +static void real_stroke_start(void) +{ + fprintf(stderr, "stroke: MIID!\n"); + mid_stroke = true; + StrokeBox.X1 = Crosshair.X; + StrokeBox.Y1 = Crosshair.Y; +} + +void hid_stroke_init(void) +{ + stroke_init(); + + stub_stroke_record = real_stroke_record; + stub_stroke_start = real_stroke_start; + stub_stroke_finish = real_stroke_finish; +} +