Index: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in (revision 1091) +++ trunk/src/Makefile.in (revision 1092) @@ -52,6 +52,7 @@ plugins.o polygon.o polygon1.o + polygon_act.o print.o rats.o rats_act.o @@ -100,8 +101,9 @@ # main: action registrations put /local/pcb/ACTION_REG_SRC { action.c buffer.c change_act.c command.c file_act.c flags.c gui_act.c - import_sch.c main.c misc.c move.c netlist.c object_act.c plugins.c rats_act.c - rats_patch.c remove_act.c report.c select_act.c undo_act.c + import_sch.c main.c misc.c move.c netlist.c object_act.c plugins.c + polygon_act.c rats_act.c rats_patch.c remove_act.c report.c + select_act.c undo_act.c } #---- modules ----# Index: trunk/src/action.c =================================================================== --- trunk/src/action.c (revision 1091) +++ trunk/src/action.c (revision 1092) @@ -2047,56 +2047,6 @@ return 0; } -/* --------------------------------------------------------------------------- */ - -static const char morphpolygon_syntax[] = "MorphPolygon(Object|Selected)"; - -static const char morphpolygon_help[] = "Converts dead polygon islands into separate polygons."; - -/* %start-doc actions MorphPolygon - -If a polygon is divided into unconnected "islands", you can use -this command to convert the otherwise disappeared islands into -separate polygons. Be sure the cursor is over a portion of the -polygon that remains visible. Very small islands that may flake -off are automatically deleted. - -%end-doc */ - -static int ActionMorphPolygon(int argc, char **argv, Coord x, Coord y) -{ - char *function = ARG(0); - if (function) { - switch (GetFunctionID(function)) { - case F_Object: - { - int type; - void *ptr1, *ptr2, *ptr3; - - gui->get_coords(_("Select an Object"), &x, &y); - if ((type = SearchScreen(x, y, POLYGON_TYPE, &ptr1, &ptr2, &ptr3)) != NO_TYPE) { - MorphPolygon((LayerType *) ptr1, (PolygonType *) ptr3); - Draw(); - IncrementUndoSerialNumber(); - } - break; - } - case F_Selected: - case F_SelectedObjects: - ALLPOLYGON_LOOP(PCB->Data); - { - if (TEST_FLAG(SELECTEDFLAG, polygon)) - MorphPolygon(layer, polygon); - } - ENDALL_LOOP; - Draw(); - IncrementUndoSerialNumber(); - break; - } - } - return 0; -} - /* --------------------------------------------------------------------------- * no operation, just for testing purposes * syntax: Bell(volume) @@ -2295,51 +2245,6 @@ /* --------------------------------------------------------------------------- */ -static const char polygon_syntax[] = "Polygon(Close|PreviousPoint)"; - -static const char polygon_help[] = "Some polygon related stuff."; - -/* %start-doc actions Polygon - -Polygons need a special action routine to make life easier. - -@table @code - -@item Close -Creates the final segment of the polygon. This may fail if clipping -to 45 degree lines is switched on, in which case a warning is issued. - -@item PreviousPoint -Resets the newly entered corner to the previous one. The Undo action -will call Polygon(PreviousPoint) when appropriate to do so. - -@end table - -%end-doc */ - -static int ActionPolygon(int argc, char **argv, Coord x, Coord y) -{ - char *function = ARG(0); - if (function && Settings.Mode == POLYGON_MODE) { - notify_crosshair_change(false); - switch (GetFunctionID(function)) { - /* close open polygon if possible */ - case F_Close: - ClosePolygon(); - break; - - /* go back to the previous point */ - case F_PreviousPoint: - GoToPreviousPoint(); - break; - } - notify_crosshair_change(true); - } - return 0; -} - -/* --------------------------------------------------------------------------- */ - static const char routestyle_syntax[] = "RouteStyle(1|2|3|4)"; static const char routestyle_help[] = "Copies the indicated routing style into the current sizes."; @@ -2525,9 +2430,6 @@ {"MinClearGap", 0, ActionMinClearGap, mincleargap_help, mincleargap_syntax} , - {"MorphPolygon", 0, ActionMorphPolygon, - morphpolygon_help, morphpolygon_syntax} - , {"PasteBuffer", 0, ActionPasteBuffer, pastebuffer_help, pastebuffer_syntax} , @@ -2542,9 +2444,6 @@ {"SetSame", N_("Select item to use attributes from"), ActionSetSame, setsame_help, setsame_syntax} , - {"Polygon", 0, ActionPolygon, - polygon_help, polygon_syntax} - , {"RouteStyle", 0, ActionRouteStyle, routestyle_help, routestyle_syntax} , Index: trunk/src/action_list.h =================================================================== --- trunk/src/action_list.h (revision 1091) +++ trunk/src/action_list.h (revision 1092) @@ -57,6 +57,9 @@ /* report.c () */ REGISTER_ACTIONS(report_action_list) +/* polygon_act.c () */ +REGISTER_ACTIONS(polygon_action_list) + /* netlist.c () */ REGISTER_ACTIONS(netlist_action_list) Index: trunk/src/polygon_act.c =================================================================== --- trunk/src/polygon_act.c (nonexistent) +++ trunk/src/polygon_act.c (revision 1092) @@ -0,0 +1,144 @@ +/* + * 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 "action.h" +#include "change.h" +#include "error.h" +#include "undo.h" + +#include "polygon.h" +#include "draw.h" +#include "search.h" +#include "crosshair.h" + +/* --------------------------------------------------------------------------- */ + +static const char morphpolygon_syntax[] = "MorphPolygon(Object|Selected)"; + +static const char morphpolygon_help[] = "Converts dead polygon islands into separate polygons."; + +/* %start-doc actions MorphPolygon + +If a polygon is divided into unconnected "islands", you can use +this command to convert the otherwise disappeared islands into +separate polygons. Be sure the cursor is over a portion of the +polygon that remains visible. Very small islands that may flake +off are automatically deleted. + +%end-doc */ + +static int ActionMorphPolygon(int argc, char **argv, Coord x, Coord y) +{ + char *function = ARG(0); + if (function) { + switch (GetFunctionID(function)) { + case F_Object: + { + int type; + void *ptr1, *ptr2, *ptr3; + + gui->get_coords(_("Select an Object"), &x, &y); + if ((type = SearchScreen(x, y, POLYGON_TYPE, &ptr1, &ptr2, &ptr3)) != NO_TYPE) { + MorphPolygon((LayerType *) ptr1, (PolygonType *) ptr3); + Draw(); + IncrementUndoSerialNumber(); + } + break; + } + case F_Selected: + case F_SelectedObjects: + ALLPOLYGON_LOOP(PCB->Data); + { + if (TEST_FLAG(SELECTEDFLAG, polygon)) + MorphPolygon(layer, polygon); + } + ENDALL_LOOP; + Draw(); + IncrementUndoSerialNumber(); + break; + } + } + return 0; +} + +/* --------------------------------------------------------------------------- */ + +static const char polygon_syntax[] = "Polygon(Close|PreviousPoint)"; + +static const char polygon_help[] = "Some polygon related stuff."; + +/* %start-doc actions Polygon + +Polygons need a special action routine to make life easier. + +@table @code + +@item Close +Creates the final segment of the polygon. This may fail if clipping +to 45 degree lines is switched on, in which case a warning is issued. + +@item PreviousPoint +Resets the newly entered corner to the previous one. The Undo action +will call Polygon(PreviousPoint) when appropriate to do so. + +@end table + +%end-doc */ + +static int ActionPolygon(int argc, char **argv, Coord x, Coord y) +{ + char *function = ARG(0); + if (function && Settings.Mode == POLYGON_MODE) { + notify_crosshair_change(false); + switch (GetFunctionID(function)) { + /* close open polygon if possible */ + case F_Close: + ClosePolygon(); + break; + + /* go back to the previous point */ + case F_PreviousPoint: + GoToPreviousPoint(); + break; + } + notify_crosshair_change(true); + } + return 0; +} + + +HID_Action polygon_action_list[] = { + {"MorphPolygon", 0, ActionMorphPolygon, + morphpolygon_help, morphpolygon_syntax} + , + {"Polygon", 0, ActionPolygon, + polygon_help, polygon_syntax} +}; + +REGISTER_ACTIONS(polygon_action_list)