00001
00043 #include <stdio.h>
00044 #include <math.h>
00045
00046 #include "global.h"
00047 #include "data.h"
00048 #include "hid.h"
00049 #include "misc.h"
00050 #include "create.h"
00051 #include "rtree.h"
00052 #include "undo.h"
00053 #include "set.h"
00054 #include "error.h"
00055
00063 static int
00064 upth2pth (int argc, char **argv, int x, int y)
00065 {
00066 int selected = 0;
00067 int all = 0;
00068 if (argc > 0 && strcasecmp (argv[0], "Selected") == 0)
00069 selected = 1;
00070 else if (argc >0 && strcasecmp (argv[0], "All") == 0)
00071 all = 1;
00072 else
00073 {
00074 Message ("ERROR: in Upth2pth the argument should be either Selected or All.\n");
00075 return 1;
00076 }
00077 SET_FLAG (NAMEONPCBFLAG, PCB);
00078 VIA_LOOP(PCB->Data);
00079 {
00080 if (!TEST_FLAG (LOCKFLAG, via))
00081 {
00082
00083 if (all)
00084 {
00085 CLEAR_FLAG(HOLEFLAG, via);
00086 }
00087 else if (selected)
00088 {
00089 if (TEST_FLAG (SELECTEDFLAG, via))
00090 {
00091 CLEAR_FLAG(HOLEFLAG, via);
00092 }
00093 }
00094 }
00095 }
00096 END_LOOP;
00097 ELEMENT_LOOP(PCB->Data);
00098 {
00099 if (!TEST_FLAG (LOCKFLAG, element))
00100 {
00101
00102 if (all)
00103 {
00104 PIN_LOOP(element);
00105 {
00106 CLEAR_FLAG(HOLEFLAG, pin);
00107 }
00108 END_LOOP;
00109 }
00110 }
00111 }
00112 END_LOOP;
00113 gui->invalidate_all ();
00114 IncrementUndoSerialNumber ();
00115 return 0;
00116 }
00117
00118
00126 static int
00127 pth2upth (int argc, char **argv, int x, int y)
00128 {
00129 int selected = 0;
00130 int all = 0;
00131 if (argc > 0 && strcasecmp (argv[0], "Selected") == 0)
00132 selected = 1;
00133 else if (argc >0 && strcasecmp (argv[0], "All") == 0)
00134 all = 1;
00135 else
00136 {
00137 Message ("ERROR: in Upth2pth the argument should be either Selected or All.\n");
00138 return 1;
00139 }
00140 SET_FLAG (NAMEONPCBFLAG, PCB);
00141 VIA_LOOP(PCB->Data);
00142 {
00143 if (!TEST_FLAG (LOCKFLAG, via))
00144 {
00145
00146 if (all)
00147 {
00148 SET_FLAG(HOLEFLAG, via);
00149 }
00150 else if (selected)
00151 {
00152 if (TEST_FLAG (SELECTEDFLAG, via))
00153 {
00154 SET_FLAG(HOLEFLAG, via);
00155 }
00156 }
00157 }
00158 }
00159 END_LOOP;
00160 ELEMENT_LOOP(PCB->Data);
00161 {
00162 if (!TEST_FLAG (LOCKFLAG, element))
00163 {
00164
00165 if (all)
00166 {
00167 PIN_LOOP(element);
00168 {
00169 SET_FLAG(HOLEFLAG, pin);
00170 }
00171 END_LOOP;
00172 }
00173 }
00174 }
00175 END_LOOP;
00176 gui->invalidate_all ();
00177 IncrementUndoSerialNumber ();
00178 return 0;
00179 }
00180
00181
00182 static HID_Action upth2pth_action_list[] =
00183 {
00184 {"Upth2pth", NULL, upth2pth, "Change selected or all unplated holes to plated holes", NULL},
00185 {"Pth2upth", NULL, pth2upth, "Change selected or all plated holes to unplated holes", NULL}
00186 };
00187
00188
00189 REGISTER_ACTIONS (upth2pth_action_list)
00190
00191
00192 void
00193 pcb_plugin_init()
00194 {
00195 register_upth2pth_action_list();
00196 }
00197
00198