lockelements.c

Go to the documentation of this file.
00001 
00047 #include <stdio.h>
00048 #include <math.h>
00049 
00050 #include "global.h"
00051 #include "data.h"
00052 #include "hid.h"
00053 #include "misc.h"
00054 #include "create.h"
00055 #include "rtree.h"
00056 #include "undo.h"
00057 #include "set.h"
00058 #include "error.h"
00059 
00068 static int
00069 lock_elements (int argc, char **argv, int x, int y)
00070 {
00071         int selected = 0;
00072         int all = 0;
00073         if (argc > 0 && strcasecmp (argv[0], "Selected") == 0)
00074                 selected = 1;
00075         else if (argc >0 && strcasecmp (argv[0], "All") == 0)
00076                 all = 1;
00077         else
00078         {
00079                 Message ("ERROR: in LockElements argument should be either Selected or All.\n");
00080                 return 1;
00081         }
00082         SET_FLAG (NAMEONPCBFLAG, PCB);
00083         ELEMENT_LOOP(PCB->Data);
00084         {
00085                 if (!TEST_FLAG (LOCKFLAG, element))
00086                 {
00087                         /* element is not locked */
00088                         if (all)
00089                                 SET_FLAG(LOCKFLAG, element);
00090                         if (selected)
00091                         {
00092                                 if (TEST_FLAG (SELECTEDFLAG, element))
00093                                 {
00094                                         /* better to unselect element first */
00095                                         CLEAR_FLAG(SELECTEDFLAG, element);
00096                                         SET_FLAG(LOCKFLAG, element);
00097                                 }
00098                         }
00099                 }
00100         }
00101         END_LOOP;
00102         gui->invalidate_all ();
00103         IncrementUndoSerialNumber ();
00104         return 0;
00105 }
00106 
00107 
00116 static int
00117 unlock_elements (int argc, char **argv, int x, int y)
00118 {
00119         int all = 0;
00120         if (strcasecmp (argv[0], "All") == 0)
00121                 all = 1;
00122         else
00123         {
00124                 Message ("ERROR: in UnlockElements argument should be All.\n");
00125                 return 1;
00126         }
00127         SET_FLAG (NAMEONPCBFLAG, PCB);
00128         ELEMENT_LOOP(PCB->Data);
00129         {
00130                 if (TEST_FLAG (LOCKFLAG, element))
00131                 {
00132                         /* element is locked */
00133                         if (all)
00134                                 CLEAR_FLAG(LOCKFLAG, element);
00135                 }
00136         }
00137         END_LOOP;
00138         gui->invalidate_all ();
00139         IncrementUndoSerialNumber ();
00140         return 0;
00141 }
00142 
00143 
00144 static HID_Action lockelements_action_list[] =
00145 {
00146         {"LockElements", NULL, lock_elements, "Lock selected or all elements", NULL},
00147         {"LE", NULL, lock_elements, "Lock selected or all elements", NULL},
00148         {"UnlockElements", NULL, unlock_elements, "Unlock selected or all elements", NULL},
00149         {"UE", NULL, unlock_elements, "Unlock selected or all elements", NULL}
00150 };
00151 
00152 
00153 REGISTER_ACTIONS (lockelements_action_list)
00154 
00155 
00156 void
00157 pcb_plugin_init()
00158 {
00159         register_lockelements_action_list();
00160 }
00161 
00162 /* EOF */

Generated on Tue Aug 17 15:28:04 2010 for pcb-plugins by  doxygen 1.4.6-NO