pcb 4.1.1
An interactive printed circuit board layout editor.
|
00001 00030 #ifdef HAVE_CONFIG_H 00031 #include "config.h" 00032 #endif 00033 00034 #include <math.h> 00035 #include <stdio.h> 00036 #include <stdlib.h> 00037 #ifdef HAVE_STRING_H 00038 #include <string.h> 00039 #endif 00040 00041 #include "global.h" 00042 #include "data.h" 00043 #include "pcb-printf.h" 00044 00045 #include <glib.h> 00046 00047 #ifdef HAVE_LIBDMALLOC 00048 #include <dmalloc.h> 00049 #endif 00050 00051 int pcb_flag_eq (FlagType *f1, FlagType *f2); 00052 00059 int 00060 pcb_flag_eq (FlagType *f1, FlagType *f2) 00061 { 00062 if (f1->f != f2->f) 00063 return 0; 00064 00065 return (memcmp(f1->t, &f2->t, sizeof(f1->t)) == 0); 00066 } 00067 00068 static int 00069 FlagCurrentStyle (void *data) 00070 { 00071 STYLE_LOOP (PCB); 00072 { 00073 if (style->Thick == Settings.LineThickness && 00074 style->Diameter == Settings.ViaThickness && 00075 style->Hole == Settings.ViaDrillingHole && 00076 style->Keepaway == Settings.Keepaway) 00077 return n + 1; 00078 } 00079 END_LOOP; 00080 return 0; 00081 } 00082 00083 static int 00084 FlagGrid (void *data) 00085 { 00086 return PCB->Grid > 1; 00087 } 00088 00089 static int 00090 FlagGridSize (void *data) 00091 { 00092 return PCB->Grid; 00093 } 00094 00095 static int 00096 FlagUnitsMm (void *data) 00097 { 00098 static const Unit *u = NULL; 00099 if (u == NULL) 00100 u = get_unit_struct ("mm"); 00101 return (Settings.grid_unit == u); 00102 } 00103 00104 static int 00105 FlagUnitsMil (void *data) 00106 { 00107 static const Unit *u = NULL; 00108 if (u == NULL) 00109 u = get_unit_struct ("mil"); 00110 return (Settings.grid_unit == u); 00111 } 00112 00113 static int 00114 FlagBuffer (void *data) 00115 { 00116 return (int) (Settings.BufferNumber + 1); 00117 } 00118 00119 static int 00120 FlagElementName (void *data) 00121 { 00122 if (TEST_FLAG (NAMEONPCBFLAG, PCB)) 00123 return 2; 00124 if (TEST_FLAG (DESCRIPTIONFLAG, PCB)) 00125 return 1; 00126 return 3; 00127 } 00128 00129 static int 00130 FlagTESTFLAG (void *data) 00131 { 00132 int bit = GPOINTER_TO_INT (data); 00133 return TEST_FLAG (bit, PCB) ? 1 : 0; 00134 } 00135 00136 static int 00137 FlagSETTINGS (void *data) 00138 { 00139 size_t ofs = (size_t)data; 00140 return *(bool *) ((char *)(&Settings) + ofs); 00141 } 00142 00143 static int 00144 FlagMode (void *data) 00145 { 00146 int x = GPOINTER_TO_INT (data); 00147 if (x == -1) 00148 return Settings.Mode; 00149 return Settings.Mode == x; 00150 } 00151 00152 static int 00153 FlagHaveRegex (void *data) 00154 { 00155 #if defined(HAVE_REGCOMP) || defined(HAVE_RE_COMP) 00156 return 1; 00157 #else 00158 return 0; 00159 #endif 00160 } 00161 00162 enum { 00163 FL_SILK = -6, 00164 FL_PINS, 00165 FL_RATS, 00166 FL_VIAS, 00167 FL_BACK, 00168 FL_MASK 00169 }; 00170 00171 static int 00172 FlagLayerShown (void *data) 00173 { 00174 int n = GPOINTER_TO_INT (data); 00175 switch (n) 00176 { 00177 case FL_SILK: 00178 return PCB->ElementOn; 00179 case FL_PINS: 00180 return PCB->PinOn; 00181 case FL_RATS: 00182 return PCB->RatOn; 00183 case FL_VIAS: 00184 return PCB->ViaOn; 00185 case FL_BACK: 00186 return PCB->InvisibleObjectsOn; 00187 case FL_MASK: 00188 return TEST_FLAG (SHOWMASKFLAG, PCB); 00189 default: 00190 if (n >= 0 && n < max_copper_layer) 00191 return PCB->Data->Layer[n].On; 00192 } 00193 return 0; 00194 } 00195 00196 static int 00197 FlagLayerActive (void *data) 00198 { 00199 int test_layer = GPOINTER_TO_INT (data); 00200 int current_layer; 00201 if (PCB->RatDraw) 00202 current_layer = FL_RATS; 00203 else if (PCB->SilkActive) 00204 current_layer = FL_SILK; 00205 else 00206 return 0; 00207 00208 return current_layer == test_layer; 00209 } 00210 00211 #define OFFSET_POINTER(a, b) (&(((a *)0)->b)) 00212 00213 HID_Flag flags_flag_list[] = { 00214 {"style", FlagCurrentStyle, NULL}, 00215 {"grid", FlagGrid, NULL}, 00216 {"gridsize", FlagGridSize, NULL}, 00217 {"elementname", FlagElementName, NULL}, 00218 {"have_regex", FlagHaveRegex, NULL}, 00219 00220 {"silk_shown", FlagLayerShown, GINT_TO_POINTER (FL_SILK)}, 00221 {"pins_shown", FlagLayerShown, GINT_TO_POINTER (FL_PINS)}, 00222 {"rats_shown", FlagLayerShown, GINT_TO_POINTER (FL_RATS)}, 00223 {"vias_shown", FlagLayerShown, GINT_TO_POINTER (FL_VIAS)}, 00224 {"back_shown", FlagLayerShown, GINT_TO_POINTER (FL_BACK)}, 00225 {"mask_shown", FlagLayerShown, GINT_TO_POINTER (FL_MASK)}, 00226 00227 {"silk_active", FlagLayerActive, GINT_TO_POINTER (FL_SILK)}, 00228 {"rats_active", FlagLayerActive, GINT_TO_POINTER (FL_RATS)}, 00229 00230 {"mode", FlagMode, GINT_TO_POINTER (-1)}, 00231 {"nomode", FlagMode, GINT_TO_POINTER (NO_MODE)}, 00232 {"arcmode", FlagMode, GINT_TO_POINTER (ARC_MODE)}, 00233 {"arrowmode", FlagMode, GINT_TO_POINTER (ARROW_MODE)}, 00234 {"copymode", FlagMode, GINT_TO_POINTER (COPY_MODE)}, 00235 {"insertpointmode", FlagMode, GINT_TO_POINTER (INSERTPOINT_MODE)}, 00236 {"linemode", FlagMode, GINT_TO_POINTER (LINE_MODE)}, 00237 {"lockmode", FlagMode, GINT_TO_POINTER (LOCK_MODE)}, 00238 {"movemode", FlagMode, GINT_TO_POINTER (MOVE_MODE)}, 00239 {"pastebuffermode", FlagMode, GINT_TO_POINTER (PASTEBUFFER_MODE)}, 00240 {"polygonmode", FlagMode, GINT_TO_POINTER (POLYGON_MODE)}, 00241 {"polygonholemode", FlagMode, GINT_TO_POINTER (POLYGONHOLE_MODE)}, 00242 {"rectanglemode", FlagMode, GINT_TO_POINTER (RECTANGLE_MODE)}, 00243 {"removemode", FlagMode, GINT_TO_POINTER (REMOVE_MODE)}, 00244 {"rotatemode", FlagMode, GINT_TO_POINTER (ROTATE_MODE)}, 00245 {"rubberbandmovemode", FlagMode, GINT_TO_POINTER (RUBBERBANDMOVE_MODE)}, 00246 {"textmode", FlagMode, GINT_TO_POINTER (TEXT_MODE)}, 00247 {"thermalmode", FlagMode, GINT_TO_POINTER (THERMAL_MODE)}, 00248 {"viamode", FlagMode, GINT_TO_POINTER (VIA_MODE)}, 00249 00250 {"shownumber", FlagTESTFLAG, GINT_TO_POINTER (SHOWNUMBERFLAG)}, 00251 {"localref", FlagTESTFLAG, GINT_TO_POINTER (LOCALREFFLAG)}, 00252 {"checkplanes", FlagTESTFLAG, GINT_TO_POINTER (CHECKPLANESFLAG)}, 00253 {"showdrc", FlagTESTFLAG, GINT_TO_POINTER (SHOWDRCFLAG)}, 00254 {"rubberband", FlagTESTFLAG, GINT_TO_POINTER (RUBBERBANDFLAG)}, 00255 {"description", FlagTESTFLAG, GINT_TO_POINTER (DESCRIPTIONFLAG)}, 00256 {"nameonpcb", FlagTESTFLAG, GINT_TO_POINTER (NAMEONPCBFLAG)}, 00257 {"autodrc", FlagTESTFLAG, GINT_TO_POINTER (AUTODRCFLAG)}, 00258 {"alldirection", FlagTESTFLAG, GINT_TO_POINTER (ALLDIRECTIONFLAG)}, 00259 {"swapstartdir", FlagTESTFLAG, GINT_TO_POINTER (SWAPSTARTDIRFLAG)}, 00260 {"uniquename", FlagTESTFLAG, GINT_TO_POINTER (UNIQUENAMEFLAG)}, 00261 {"clearnew", FlagTESTFLAG, GINT_TO_POINTER (CLEARNEWFLAG)}, 00262 {"snappin", FlagTESTFLAG, GINT_TO_POINTER (SNAPPINFLAG)}, 00263 {"showmask", FlagTESTFLAG, GINT_TO_POINTER (SHOWMASKFLAG)}, 00264 {"thindraw", FlagTESTFLAG, GINT_TO_POINTER (THINDRAWFLAG)}, 00265 {"orthomove", FlagTESTFLAG, GINT_TO_POINTER (ORTHOMOVEFLAG)}, 00266 {"liveroute", FlagTESTFLAG, GINT_TO_POINTER (LIVEROUTEFLAG)}, 00267 {"thindrawpoly", FlagTESTFLAG, GINT_TO_POINTER (THINDRAWPOLYFLAG)}, 00268 {"locknames", FlagTESTFLAG, GINT_TO_POINTER (LOCKNAMESFLAG)}, 00269 {"onlynames", FlagTESTFLAG, GINT_TO_POINTER (ONLYNAMESFLAG)}, 00270 {"newfullpoly", FlagTESTFLAG, GINT_TO_POINTER (NEWFULLPOLYFLAG)}, 00271 {"hidenames", FlagTESTFLAG, GINT_TO_POINTER (HIDENAMESFLAG)}, 00272 {"autoburiedvias", FlagTESTFLAG, GINT_TO_POINTER (AUTOBURIEDVIASFLAG)}, 00273 00274 {"grid_units_mm", FlagUnitsMm, NULL}, 00275 {"grid_units_mil", FlagUnitsMil, NULL}, 00276 00277 {"fullpoly", FlagSETTINGS, OFFSET_POINTER (SettingType, FullPoly)}, 00278 {"clearline", FlagSETTINGS, OFFSET_POINTER (SettingType, ClearLine)}, 00279 {"uniquenames", FlagSETTINGS, OFFSET_POINTER (SettingType, UniqueNames)}, 00280 {"showsolderside", FlagSETTINGS, OFFSET_POINTER (SettingType, ShowBottomSide)}, 00281 {"savelastcommand", FlagSETTINGS, OFFSET_POINTER (SettingType, SaveLastCommand)}, 00282 {"saveintmp", FlagSETTINGS, OFFSET_POINTER (SettingType, SaveInTMP)}, 00283 {"drawgrid", FlagSETTINGS, OFFSET_POINTER (SettingType, DrawGrid)}, 00284 {"ratwarn", FlagSETTINGS, OFFSET_POINTER (SettingType, RatWarn)}, 00285 {"stipplepolygons", FlagSETTINGS, OFFSET_POINTER (SettingType, StipplePolygons)}, 00286 {"alldirectionlines", FlagSETTINGS, OFFSET_POINTER (SettingType, AllDirectionLines)}, 00287 {"rubberbandmode", FlagSETTINGS, OFFSET_POINTER (SettingType, RubberBandMode)}, 00288 {"swapstartdirection", FlagSETTINGS, OFFSET_POINTER (SettingType, SwapStartDirection)}, 00289 {"showdrcmode", FlagSETTINGS, OFFSET_POINTER (SettingType, ShowDRC)}, 00290 {"resetafterelement", FlagSETTINGS, OFFSET_POINTER (SettingType, ResetAfterElement)}, 00291 {"ringbellwhenfinished", FlagSETTINGS, OFFSET_POINTER (SettingType, RingBellWhenFinished)}, 00292 00293 {"buffer", FlagBuffer, NULL}, 00294 00295 }; 00296 00297 REGISTER_FLAGS (flags_flag_list) 00298