6 * PCB, interactive printed circuit board design
7 * Copyright (C) 2005 DJ Delorie
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
39 #include "pcb-printf.h"
41 #ifdef HAVE_LIBDMALLOC
48 FlagCurrentStyle (int dummy
)
52 if (style
->Thick
== Settings
.LineThickness
&&
53 style
->Diameter
== Settings
.ViaThickness
&&
54 style
->Hole
== Settings
.ViaDrillingHole
&&
55 style
->Keepaway
== Settings
.Keepaway
)
69 FlagGridSize (int dummy
)
75 FlagUnitsMm (int dummy
)
77 static const Unit
*u
= NULL
;
79 u
= get_unit_struct ("mm");
80 return (Settings
.grid_unit
== u
);
84 FlagUnitsMil (int dummy
)
86 static const Unit
*u
= NULL
;
88 u
= get_unit_struct ("mil");
89 return (Settings
.grid_unit
== u
);
93 FlagBuffer (int dummy
)
95 return (int) (Settings
.BufferNumber
+ 1);
99 FlagElementName (int dummy
)
101 if (TEST_FLAG (NAMEONPCBFLAG
, PCB
))
103 if (TEST_FLAG (DESCRIPTIONFLAG
, PCB
))
109 FlagTESTFLAG (int bit
)
111 return TEST_FLAG (bit
, PCB
) ? 1 : 0;
115 FlagSETTINGS (int ofs
)
117 return *(bool *) ((char *) (&Settings
) + ofs
);
124 return Settings
.Mode
;
125 return Settings
.Mode
== x
;
129 FlagHaveRegex (int x
)
131 #if defined(HAVE_REGCOMP) || defined(HAVE_RE_COMP)
148 FlagLayerShown (int n
)
153 return PCB
->ElementOn
;
161 return PCB
->InvisibleObjectsOn
;
163 return TEST_FLAG (SHOWMASKFLAG
, PCB
);
165 if (n
>= 0 && n
< max_copper_layer
)
166 return PCB
->Data
->Layer
[n
].On
;
172 FlagLayerActive (int n
)
176 current_layer
= FL_RATS
;
177 else if (PCB
->SilkActive
)
178 current_layer
= FL_SILK
;
182 return current_layer
== n
;
185 /* The cast to (int) is ONLY valid because we know we are
186 * taking offsets on structures where the offset will fit
187 * in an integer variable. It silences compile warnings on
190 #define OffsetOf(a,b) (int)(size_t)(&(((a *)0)->b))
192 HID_Flag flags_flag_list
[] = {
193 {"style", FlagCurrentStyle
, 0},
194 {"grid", FlagGrid
, 0},
195 {"gridsize", FlagGridSize
, 0},
196 {"elementname", FlagElementName
, 0},
197 {"have_regex", FlagHaveRegex
, 0},
199 {"silk_shown", FlagLayerShown
, FL_SILK
},
200 {"pins_shown", FlagLayerShown
, FL_PINS
},
201 {"rats_shown", FlagLayerShown
, FL_RATS
},
202 {"vias_shown", FlagLayerShown
, FL_VIAS
},
203 {"back_shown", FlagLayerShown
, FL_BACK
},
204 {"mask_shown", FlagLayerShown
, FL_MASK
},
205 {"silk_active", FlagLayerActive
, FL_SILK
},
206 {"rats_active", FlagLayerActive
, FL_RATS
},
208 {"mode", FlagMode
, -1},
209 {"nomode", FlagMode
, NO_MODE
},
210 {"arcmode", FlagMode
, ARC_MODE
},
211 {"arrowmode", FlagMode
, ARROW_MODE
},
212 {"copymode", FlagMode
, COPY_MODE
},
213 {"insertpointmode", FlagMode
, INSERTPOINT_MODE
},
214 {"linemode", FlagMode
, LINE_MODE
},
215 {"lockmode", FlagMode
, LOCK_MODE
},
216 {"movemode", FlagMode
, MOVE_MODE
},
217 {"pastebuffermode", FlagMode
, PASTEBUFFER_MODE
},
218 {"polygonmode", FlagMode
, POLYGON_MODE
},
219 {"polygonholemode", FlagMode
, POLYGONHOLE_MODE
},
220 {"rectanglemode", FlagMode
, RECTANGLE_MODE
},
221 {"removemode", FlagMode
, REMOVE_MODE
},
222 {"rotatemode", FlagMode
, ROTATE_MODE
},
223 {"rubberbandmovemode", FlagMode
, RUBBERBANDMOVE_MODE
},
224 {"textmode", FlagMode
, TEXT_MODE
},
225 {"thermalmode", FlagMode
, THERMAL_MODE
},
226 {"viamode", FlagMode
, VIA_MODE
},
228 {"shownumber", FlagTESTFLAG
, SHOWNUMBERFLAG
},
229 {"localref", FlagTESTFLAG
, LOCALREFFLAG
},
230 {"checkplanes", FlagTESTFLAG
, CHECKPLANESFLAG
},
231 {"showdrc", FlagTESTFLAG
, SHOWDRCFLAG
},
232 {"rubberband", FlagTESTFLAG
, RUBBERBANDFLAG
},
233 {"description", FlagTESTFLAG
, DESCRIPTIONFLAG
},
234 {"nameonpcb", FlagTESTFLAG
, NAMEONPCBFLAG
},
235 {"autodrc", FlagTESTFLAG
, AUTODRCFLAG
},
236 {"alldirection", FlagTESTFLAG
, ALLDIRECTIONFLAG
},
237 {"swapstartdir", FlagTESTFLAG
, SWAPSTARTDIRFLAG
},
238 {"uniquename", FlagTESTFLAG
, UNIQUENAMEFLAG
},
239 {"clearnew", FlagTESTFLAG
, CLEARNEWFLAG
},
240 {"snappin", FlagTESTFLAG
, SNAPPINFLAG
},
241 {"showmask", FlagTESTFLAG
, SHOWMASKFLAG
},
242 {"thindraw", FlagTESTFLAG
, THINDRAWFLAG
},
243 {"orthomove", FlagTESTFLAG
, ORTHOMOVEFLAG
},
244 {"liveroute", FlagTESTFLAG
, LIVEROUTEFLAG
},
245 {"thindrawpoly", FlagTESTFLAG
, THINDRAWPOLYFLAG
},
246 {"locknames", FlagTESTFLAG
, LOCKNAMESFLAG
},
247 {"onlynames", FlagTESTFLAG
, ONLYNAMESFLAG
},
248 {"newfullpoly", FlagTESTFLAG
, NEWFULLPOLYFLAG
},
249 {"hidenames", FlagTESTFLAG
, HIDENAMESFLAG
},
251 {"fullpoly", FlagSETTINGS
, OffsetOf (SettingType
, FullPoly
)},
252 {"grid_units_mm", FlagUnitsMm
, -1},
253 {"grid_units_mil", FlagUnitsMil
, -1},
254 {"clearline", FlagSETTINGS
, OffsetOf (SettingType
, ClearLine
)},
255 {"uniquenames", FlagSETTINGS
, OffsetOf (SettingType
, UniqueNames
)},
256 {"showsolderside", FlagSETTINGS
, OffsetOf (SettingType
, ShowSolderSide
)},
257 {"savelastcommand", FlagSETTINGS
, OffsetOf (SettingType
, SaveLastCommand
)},
258 {"saveintmp", FlagSETTINGS
, OffsetOf (SettingType
, SaveInTMP
)},
259 {"drawgrid", FlagSETTINGS
, OffsetOf (SettingType
, DrawGrid
)},
260 {"ratwarn", FlagSETTINGS
, OffsetOf (SettingType
, RatWarn
)},
261 {"stipplepolygons", FlagSETTINGS
, OffsetOf (SettingType
, StipplePolygons
)},
262 {"alldirectionlines", FlagSETTINGS
,
263 OffsetOf (SettingType
, AllDirectionLines
)},
264 {"rubberbandmode", FlagSETTINGS
, OffsetOf (SettingType
, RubberBandMode
)},
265 {"swapstartdirection", FlagSETTINGS
,
266 OffsetOf (SettingType
, SwapStartDirection
)},
267 {"showdrcmode", FlagSETTINGS
, OffsetOf (SettingType
, ShowDRC
)},
268 {"resetafterelement", FlagSETTINGS
,
269 OffsetOf (SettingType
, ResetAfterElement
)},
270 {"ringbellwhenfinished", FlagSETTINGS
,
271 OffsetOf (SettingType
, RingBellWhenFinished
)},
273 {"buffer", FlagBuffer
, 0},
277 REGISTER_FLAGS (flags_flag_list
)